commit a56bc359407e20e3cf3232c5a5ad02c0319eac94
Author: Leszek Koltunski <leszek@distoretedandroid.org>
Date:   Mon Dec 12 16:47:53 2016 +0000

    Major change in API: separate the GRID from DistortedObject; completely remove classes derived from DistortedObject.

diff --git a/src/main/java/org/distorted/library/Distorted.java b/src/main/java/org/distorted/library/Distorted.java
index 3d9a753..007f0e1 100644
--- a/src/main/java/org/distorted/library/Distorted.java
+++ b/src/main/java/org/distorted/library/Distorted.java
@@ -379,7 +379,6 @@ public class Distorted
  */
   public static void onDestroy()
     {
-    DistortedGridFactory.release();
     DistortedObject.release();
     DistortedFramebuffer.release();
     DistortedNode.release();
diff --git a/src/main/java/org/distorted/library/DistortedBitmap.java b/src/main/java/org/distorted/library/DistortedBitmap.java
deleted file mode 100644
index 4160a54..0000000
--- a/src/main/java/org/distorted/library/DistortedBitmap.java
+++ /dev/null
@@ -1,102 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted is free software: you can redistribute it and/or modify                             //
-// it under the terms of the GNU General Public License as published by                          //
-// the Free Software Foundation, either version 2 of the License, or                             //
-// (at your option) any later version.                                                           //
-//                                                                                               //
-// Distorted is distributed in the hope that it will be useful,                                  //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
-// GNU General Public License for more details.                                                  //
-//                                                                                               //
-// You should have received a copy of the GNU General Public License                             //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library;
-
-import android.graphics.Bitmap;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * DistortedObject descendant - with a Grid of flat rectangles.
- */
-public class DistortedBitmap extends DistortedObject
-   {
-   
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
-///////////////////////////////////////////////////////////////////////////////////////////////////  
-/**
- * Default constructor: creates a DistortedBitmap (width,height) pixels in size, with the distortion
- * grid of 'cols' and does not fill it up with any Bitmap data just yet.
- * <p>
- * Distortion grid is a grid of rectangles the Bitmap is split to. The vertices of this grid are then 
- * moved around by the Vertex Shader to create various Vertex Effects.
- * <p>
- * Size parameter describes the horizontal size, i.e. the number of rectangles the top (or bottom) edge
- * is split to. So when size=1, the whole Bitmap is just one giant rectangle. When size=10, the Bitmap
- * is split into a grid of 10x10 rectangles.
- * <p>
- * The higher the size, the better Vertex Effects look; on the other hand too high size will slow things 
- * down.  
- *       
- * @param width  width of the DistortedBitmap, in pixels.
- * @param height height of the DistortedBitmap, in pixels.
- * @param cols   Number of columns in the distortion grid. 2<=size&lt;256.
- *               Number of rows gets calculated with 'rows = cols*height/width'.
- */
-   public DistortedBitmap(int width, int height, int cols)
-     {     
-     int xsize = cols;
-     int ysize = cols*height/width;
-
-     if( xsize<1   ) xsize=  1;
-     if( xsize>256 ) xsize=256;
-     if( ysize<1   ) ysize=  1;
-     if( ysize>256 ) ysize=256;
-     
-     mGrid = DistortedGridFactory.getGrid(xsize,ysize);
-     initializeData(width,height,1);
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////   
-/**
- * Creates a DistortedBitmap and immediately fills it up with Bitmap data.
- * The dimensions of the created DistortedBitmap object are the same like that of the passed Bitmap.
- *       
- * @param bmp The android.graphics.Bitmap object to apply effects to and display.
- * @param gridSize Horizontal size of the distortion grid. 1<=size&lt;256.
- */
-   public DistortedBitmap(Bitmap bmp, int gridSize)
-     {
-     this(bmp.getWidth(), bmp.getHeight(), gridSize); 
-     setBitmap(bmp);
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Copy constructor.
- *
- * @param db Object to copy
- * @param flags see {@see DistortedObject#DistortedObject(DistortedObject,int)}
- */
-   public DistortedBitmap(DistortedBitmap db, int flags)
-     {
-     super(db,flags);
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-   protected DistortedObject deepCopy(int flags)
-     {
-     return new DistortedBitmap(this,flags);
-     }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-}
-    
diff --git a/src/main/java/org/distorted/library/DistortedBitmapGrid.java b/src/main/java/org/distorted/library/DistortedBitmapGrid.java
index 9934c24..d7859f7 100644
--- a/src/main/java/org/distorted/library/DistortedBitmapGrid.java
+++ b/src/main/java/org/distorted/library/DistortedBitmapGrid.java
@@ -24,7 +24,7 @@ import java.nio.ByteOrder;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class DistortedBitmapGrid extends DistortedObjectGrid
+public class DistortedBitmapGrid extends DistortedObjectGrid
   {
   private int mCols, mRows;
   private int remainingVert;
@@ -153,7 +153,8 @@ class DistortedBitmapGrid extends DistortedObjectGrid
      }
 */
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-
+// PUBLIC API
+///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Creates the underlying grid of vertices, normals and texture coords.
  *
diff --git a/src/main/java/org/distorted/library/DistortedCubes.java b/src/main/java/org/distorted/library/DistortedCubes.java
deleted file mode 100644
index 2fe4022..0000000
--- a/src/main/java/org/distorted/library/DistortedCubes.java
+++ /dev/null
@@ -1,129 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted is free software: you can redistribute it and/or modify                             //
-// it under the terms of the GNU General Public License as published by                          //
-// the Free Software Foundation, either version 2 of the License, or                             //
-// (at your option) any later version.                                                           //
-//                                                                                               //
-// Distorted is distributed in the hope that it will be useful,                                  //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
-// GNU General Public License for more details.                                                  //
-//                                                                                               //
-// You should have received a copy of the GNU General Public License                             //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library;
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * DistortedObject descendant - with a Grid composed of a set of cubes, centers of which all have equal Z-coords.
- * (a subset of a NxMx1 cuboid build with 1x1x1 cubes, i.e. the MxNx1 cuboid with arbitrary cubes missing)
- */
-public class DistortedCubes extends DistortedObject
-   {
-   
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// PUBLIC API
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Creates internal memory representation of a cuboid subset.
- *
- * @param cols Integer helping to parse the next parameter.
- * @param desc String describing the subset of a MxNx1 cuboid that we want to create.
- *             Its MxN characters - all 0 or 1 - decide of appropriate field is taken or not.
- *      <p></p>
- *      <p>
- *      <pre>
- *      For example, (cols=2, desc="111010") describes the following shape:
- *
- *      XX
- *      X
- *      X
- *
- *      whereas (cols=2,desc="110001") describes
- *
- *      XX
- *
- *       X
- *      </pre>
- *      </p>
- * @param cubeSize size, in pixels, of the single 1x1x1 cube our cuboid is built from
- * @param frontOnly Only create the front wall or side and back as well?
- */
- public DistortedCubes(int cols, String desc, int cubeSize, boolean frontOnly)
-   {
-   int Rs = 0;
-   int Cs = 0;
-     
-   if( cols>0 )
-     {
-     int reallen = desc.length();
-     int len = reallen;
-
-     if( (reallen/cols)*cols != reallen )
-       {
-       len = ((reallen/cols)+1)*cols;
-       for(int i=reallen; i<len; i++) desc += "0";
-       }
-    
-     if( desc.contains("1") )
-       {
-       Cs = cols;
-       Rs = len/cols;
-       }
-     }
-     
-   mGrid = DistortedGridFactory.getGrid(cols,desc, frontOnly);
-   initializeData(cubeSize*Cs,cubeSize*Rs,frontOnly ? 1 : cubeSize);
-   }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Creates internal memory representation of a full, hole-less cuboid subset.
- *
- * @param cols Number of columns
- * @param rows Number of rows
- * @param cubeSize size, in pixels, of the single 1x1x1 cube our cuboid is built from
- * @param frontOnly Only create the front wall or side and back as well?
- */
- public DistortedCubes(int cols, int rows, int cubeSize, boolean frontOnly)
-   {
-   mGrid = DistortedGridFactory.getGrid(cols,rows, frontOnly);
-   initializeData(cubeSize*cols,cubeSize*rows,frontOnly ? 1 : cubeSize);
-   }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Convenience constructor.
- */
- public DistortedCubes(int cols, String desc, int gridSize)
-   {
-   this(cols,desc,gridSize,false);
-   }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Copy constructor.
- *
- * @param dc Object to copy
- * @param flags see {@link DistortedObject#DistortedObject(DistortedObject,int)}
- */
- public DistortedCubes(DistortedCubes dc, int flags)
-   {
-   super(dc,flags);
-   }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
- protected DistortedObject deepCopy(int flags)
-   {
-   return new DistortedCubes(this,flags);
-   }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////   
- }
diff --git a/src/main/java/org/distorted/library/DistortedCubesGrid.java b/src/main/java/org/distorted/library/DistortedCubesGrid.java
index 2d5b949..3573f4f 100644
--- a/src/main/java/org/distorted/library/DistortedCubesGrid.java
+++ b/src/main/java/org/distorted/library/DistortedCubesGrid.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-class DistortedCubesGrid extends DistortedObjectGrid
+public class DistortedCubesGrid extends DistortedObjectGrid
    {
    private static final float R = 0.0f;//0.2f;
    private static final float FRONTZ = 0.5f;
@@ -743,11 +743,28 @@ class DistortedCubesGrid extends DistortedObjectGrid
 /**
  * Creates the underlying grid of vertices, normals, texture coords and colors.
  *    
- * @param cols      See {@link DistortedCubes#DistortedCubes(int,String,int,boolean)}
- * @param desc      See {@link DistortedCubes#DistortedCubes(int,String,int,boolean)}
- * @param frontOnly See {@link DistortedCubes#DistortedCubes(int,String,int,boolean)}
+ * @param cols      Integer helping to parse the next parameter.
+ * @param desc      String describing the subset of a MxNx1 cuboid that we want to create.
+ *                  Its MxN characters - all 0 or 1 - decide of appropriate field is taken or not.
+ *                  <p></p>
+ *                  <p>
+ *                  <pre>
+ *                  For example, (cols=2, desc="111010") describes the following shape:
+ *
+ *                  XX
+ *                  X
+ *                  X
+ *
+ *                  whereas (cols=2,desc="110001") describes
+ *
+ *                  XX
+ *
+ *                   X
+ *                  </pre>
+ *                  </p>
+ * @param frontOnly Only create the front wall or side and back as well?
  */
-   DistortedCubesGrid(int cols, String desc, boolean frontOnly)
+   public DistortedCubesGrid(int cols, String desc, boolean frontOnly)
       {
       prepareDataStructures(cols,desc,frontOnly);
       build(frontOnly);
@@ -757,11 +774,11 @@ class DistortedCubesGrid extends DistortedObjectGrid
 /**
  * Creates a full, hole-less underlying grid of vertices, normals, texture coords and colors.
  *
- * @param cols      See {@link DistortedCubes#DistortedCubes(int,int,int,boolean)}
- * @param rows      See {@link DistortedCubes#DistortedCubes(int,int,int,boolean)}
- * @param frontOnly See {@link DistortedCubes#DistortedCubes(int,int,int,boolean)}
+ * @param cols      Number of columns.
+ * @param rows      Number of rows.
+ * @param frontOnly Only create the front wall or side and back as well?
  */
-   DistortedCubesGrid(int cols, int rows, boolean frontOnly)
+   public DistortedCubesGrid(int cols, int rows, boolean frontOnly)
       {
       prepareDataStructures(cols,rows,frontOnly);
       build(frontOnly);
diff --git a/src/main/java/org/distorted/library/DistortedGridFactory.java b/src/main/java/org/distorted/library/DistortedGridFactory.java
deleted file mode 100644
index d786c9a..0000000
--- a/src/main/java/org/distorted/library/DistortedGridFactory.java
+++ /dev/null
@@ -1,101 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// Copyright 2016 Leszek Koltunski                                                               //
-//                                                                                               //
-// This file is part of Distorted.                                                               //
-//                                                                                               //
-// Distorted is free software: you can redistribute it and/or modify                             //
-// it under the terms of the GNU General Public License as published by                          //
-// the Free Software Foundation, either version 2 of the License, or                             //
-// (at your option) any later version.                                                           //
-//                                                                                               //
-// Distorted is distributed in the hope that it will be useful,                                  //
-// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
-// GNU General Public License for more details.                                                  //
-//                                                                                               //
-// You should have received a copy of the GNU General Public License                             //
-// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-package org.distorted.library;
-
-import java.util.HashMap;
-/**
- * HashMap of all DistortedObjectGrids ever created. The point: we can share the Grids among
- * DistortedObjects that are of the same shape.
- */
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-final class DistortedGridFactory
-  {
-  private static HashMap<String,DistortedObjectGrid> mGrids = new HashMap<>();
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// DistortedCubesGrid
-
-  static synchronized DistortedObjectGrid getGrid(int cols, String desc, boolean frontOnly)
-    {
-    String d = "1_"+cols+"_"+desc+"_"+(frontOnly?"1":"0");
-    Object o = mGrids.get(d);
-
-    if( o!=null )
-      {
-      return (DistortedObjectGrid)o;
-      }
-    else
-      {
-      DistortedObjectGrid grid = new DistortedCubesGrid(cols,desc,frontOnly);
-      mGrids.put(d,grid);
-      return grid;
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// DistortedCubesGrid (full)
-
-  static synchronized DistortedObjectGrid getGrid(int cols, int rows, boolean frontOnly)
-    {
-    String d = "2_"+cols+"_"+rows+"_"+(frontOnly?"1":"0");
-    Object o = mGrids.get(d);
-
-    if( o!=null )
-      {
-      return (DistortedObjectGrid)o;
-      }
-    else
-      {
-      DistortedObjectGrid grid = new DistortedCubesGrid(cols,rows,frontOnly);
-      mGrids.put(d,grid);
-      return grid;
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// DistortedBitmapGrid
-
-  static synchronized DistortedObjectGrid getGrid(int cols, int rows)
-    {
-    String d = cols+"+"+rows;
-    Object o = mGrids.get(d);
-
-    if( o!=null )
-      {
-      return (DistortedObjectGrid)o;
-      }
-    else
-      {
-      DistortedObjectGrid grid = new DistortedBitmapGrid(cols,rows);
-      mGrids.put(d,grid);
-      return grid;
-      }
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  static synchronized void release()
-    {
-    mGrids.clear();
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-  }
diff --git a/src/main/java/org/distorted/library/DistortedNode.java b/src/main/java/org/distorted/library/DistortedNode.java
index 2ad88d8..416df04 100644
--- a/src/main/java/org/distorted/library/DistortedNode.java
+++ b/src/main/java/org/distorted/library/DistortedNode.java
@@ -37,6 +37,7 @@ public class DistortedNode
   private static HashMap<ArrayList<Long>,NodeData> mMapNodeID = new HashMap<>();
   private static long mNextNodeID =0;
 
+  private DistortedObjectGrid mGrid;
   private DistortedObject mObject;
   private NodeData mData;
 
@@ -101,7 +102,7 @@ public class DistortedNode
         if( mObject.mBitmapSet[0] )
           {
           GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mObject.mTextureDataH[0]);
-          mObject.drawNoEffectsPriv(mData.mDF);
+          mObject.drawNoEffectsPriv(mGrid, mData.mDF);
           }
       
         synchronized(this)
@@ -117,7 +118,7 @@ public class DistortedNode
       mData.mDF.setAsInput();
       }
     
-    mObject.drawPriv(currTime, df);
+    mObject.drawPriv(currTime, mGrid, df);
     }
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -222,7 +223,7 @@ public class DistortedNode
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Debug - print all the Node IDs
-
+/*
   void debug(int depth)
     {
     String tmp="";
@@ -251,7 +252,7 @@ public class DistortedNode
       android.util.Log.e("NODE", "key="+key+" NodeID: "+tmp.ID);
       }
     }
-
+*/
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -260,9 +261,10 @@ public class DistortedNode
  *     
  * @param obj DistortedObject to put into the new Node.
  */
-  public DistortedNode(DistortedObject obj)
+  public DistortedNode(DistortedObject obj, DistortedObjectGrid grid)
     {
     mObject = obj;
+    mGrid   = grid;
     mParent = null;
     mChildren = null;
     mNumChildren = new int[1];
@@ -297,7 +299,8 @@ public class DistortedNode
   public DistortedNode(DistortedNode node, int flags)
     {
     mParent = null;
-    mObject = node.mObject.deepCopy(flags);
+    mObject = new DistortedObject(node.mObject,flags);
+    mGrid   = node.mGrid;
 
     if( (flags & Distorted.CLONE_CHILDREN) != 0 )
       {
@@ -352,12 +355,12 @@ public class DistortedNode
  * @param obj DistortedObject to initialize our child Node with.
  * @return the newly constructed child Node, or null if we couldn't allocate resources.
  */
-  public synchronized DistortedNode attach(DistortedObject obj)
+  public synchronized DistortedNode attach(DistortedObject obj, DistortedObjectGrid grid)
     {
     ArrayList<Long> prev = generateIDList(); 
       
     if( mChildren==null ) mChildren = new ArrayList<>(2);
-    DistortedNode node = new DistortedNode(obj);
+    DistortedNode node = new DistortedNode(obj,grid);
     node.mParent = this;
     mChildren.add(node);
     mNumChildren[0]++;
diff --git a/src/main/java/org/distorted/library/DistortedObject.java b/src/main/java/org/distorted/library/DistortedObject.java
index 8ba143a..0310c47 100644
--- a/src/main/java/org/distorted/library/DistortedObject.java
+++ b/src/main/java/org/distorted/library/DistortedObject.java
@@ -59,7 +59,7 @@ import java.util.HashMap;
  * deletion now - actually delete on next render' thing.
  * We need to be able to quickly retrieve an Object by its ID, thus a HashMap.
  */
-public abstract class DistortedObject 
+public class DistortedObject
   {
   private static long mNextID =0;
   private static HashMap<Long,DistortedObject> mObjects = new HashMap<>();
@@ -73,8 +73,6 @@ public abstract class DistortedObject
   private int mSizeX, mSizeY, mSizeZ; // in screen space
   private int mHalfX, mHalfY, mHalfZ; // halfs of the above
 
-  protected DistortedObjectGrid mGrid = null;
-
   private Bitmap[] mBmp= null; //
   int[] mTextureDataH;         // have to be shared among all the cloned Objects
   boolean[] mBitmapSet;        //
@@ -99,11 +97,7 @@ public abstract class DistortedObject
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-  protected abstract DistortedObject deepCopy(int flags);
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  protected void initializeData(int x, int y, int z)
+  private void initializeData(int x, int y, int z)
     {
     mSizeX= x; mHalfX = x/2;
     mSizeY= y; mHalfY = y/2;
@@ -190,7 +184,7 @@ public abstract class DistortedObject
   
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-  void drawPriv(long currTime, DistortedFramebuffer df)
+  void drawPriv(long currTime, DistortedObjectGrid grid, DistortedFramebuffer df)
     {
     DistortedFramebuffer.deleteAllMarked();
 
@@ -204,20 +198,21 @@ public abstract class DistortedObject
         
     mF.compute(currTime);
     mF.send(mHalfX,mHalfY);
-       
-    mGrid.draw();
+
+    grid.draw();
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
-  void drawNoEffectsPriv(DistortedFramebuffer df)
+  void drawNoEffectsPriv(DistortedObjectGrid grid, DistortedFramebuffer df)
     {
     GLES20.glViewport(0, 0, df.mWidth, df.mHeight);
 
     mM.sendZero(df,mHalfX,mHalfY,mHalfZ);
     mV.sendZero();
     mF.sendZero();
-    mGrid.draw();
+
+    grid.draw();
     }
     
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -229,7 +224,6 @@ public abstract class DistortedObject
     if( !fragmentCloned) mF.abortAll(false);
 
     mBmp          = null;
-    mGrid         = null;
     mM            = null;
     mV            = null;
     mF            = null;
@@ -270,11 +264,11 @@ public abstract class DistortedObject
 // PUBLIC API
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
- * Default empty constructor so that derived classes can call it
+ * Create empty effect queue with no Bitmap.
  */
-  public DistortedObject()
+  public DistortedObject(int width, int height, int depth)
     {
-
+    initializeData(width,height,depth);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -302,7 +296,6 @@ public abstract class DistortedObject
     mHalfX = dc.mHalfX;
     mHalfY = dc.mHalfY;
     mHalfZ = dc.mHalfZ;
-    mGrid  = dc.mGrid;
 
     if( (flags & Distorted.CLONE_BITMAP) != 0 )
       {
@@ -331,11 +324,11 @@ public abstract class DistortedObject
  *        This gets passed on to Dynamics inside the Effects that are currently applied to the
  *        Object.
  */
-  public void draw(long currTime)
+  public void draw(long currTime, DistortedObjectGrid grid)
     {
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
-    drawPriv(currTime, Distorted.mFramebuffer);
+    drawPriv(currTime, grid, Distorted.mFramebuffer);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -345,11 +338,11 @@ public abstract class DistortedObject
  * @param currTime Current time, in milliseconds.
  * @param df       Framebuffer to render this to.
  */
-  public void draw(long currTime, DistortedFramebuffer df)
+  public void draw(long currTime, DistortedObjectGrid grid, DistortedFramebuffer df)
     {
     df.setAsOutput();
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);
-    drawPriv(currTime,df);
+    drawPriv(currTime,grid, df);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -372,7 +365,7 @@ public abstract class DistortedObject
  * @param bmp The android.graphics.Bitmap object to apply effects to and display.
  */
    
-  public void setBitmap(Bitmap bmp)
+  public void setTexture(Bitmap bmp)
     {
     mBitmapSet[0] = true;
 
diff --git a/src/main/java/org/distorted/library/DistortedObjectGrid.java b/src/main/java/org/distorted/library/DistortedObjectGrid.java
index ed3c7e1..62edd03 100644
--- a/src/main/java/org/distorted/library/DistortedObjectGrid.java
+++ b/src/main/java/org/distorted/library/DistortedObjectGrid.java
@@ -25,7 +25,7 @@ import android.opengl.GLES20;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-abstract class DistortedObjectGrid
+public abstract class DistortedObjectGrid
    {
    protected static final int BYTES_PER_FLOAT   = 4; //
    protected static final int POSITION_DATA_SIZE= 3; // Size of the position data in elements
