commit 044b5494c8774b1068387017f12c9d4a29562929
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Wed Feb 26 22:23:45 2020 +0000

    Move the Effects.setStretch to Meshbase.setStretch

diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
index 7374e32..9c39a83 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
@@ -167,9 +167,9 @@ public class EffectQueuePostprocess extends EffectQueue
       MeshBase mesh = node.getMesh();
       DistortedEffects effects = node.getEffects();
 
-      float halfW = effects.getStartchX() / 2.0f;
-      float halfH = effects.getStartchY() / 2.0f;
-      float halfZ = effects.getStartchZ() / 2.0f;
+      float halfW = mesh.getStretchX() / 2.0f;
+      float halfH = mesh.getStretchY() / 2.0f;
+      float halfZ = mesh.getStretchZ() / 2.0f;
 
       int width   = buffer.getWidth();
       int height  = buffer.getHeight();
diff --git a/src/main/java/org/distorted/library/main/DistortedEffects.java b/src/main/java/org/distorted/library/main/DistortedEffects.java
index 0668edd..b87b96c 100644
--- a/src/main/java/org/distorted/library/main/DistortedEffects.java
+++ b/src/main/java/org/distorted/library/main/DistortedEffects.java
@@ -36,8 +36,6 @@ public class DistortedEffects
   private long mID;
   private EffectQueue[] mQueues;
 
-  private int[] mStretchX, mStretchY, mStretchZ;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * @y.exclude
@@ -60,35 +58,8 @@ public class DistortedEffects
 /**
  * Create empty effect queue.
  */
-  public DistortedEffects(int stretchX, int stretchY, int stretchZ)
-    {
-    mStretchX = new int[1];
-    mStretchY = new int[1];
-    mStretchZ = new int[1];
-
-    mStretchX[0] = stretchX;
-    mStretchY[0] = stretchY;
-    mStretchZ[0] = stretchZ;
-
-    mID = ++mNextID;
-    mQueues = new EffectQueue[EffectType.LENGTH];
-    EffectQueue.allocateQueues(mQueues,null,0);
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Temporary constructor.
- */
- public DistortedEffects(int dummy)
+ public DistortedEffects()
     {
-    mStretchX = new int[1];
-    mStretchY = new int[1];
-    mStretchZ = new int[1];
-
-    mStretchX[0] = 1;
-    mStretchY[0] = 1;
-    mStretchZ[0] = 1;
-
     mID = ++mNextID;
     mQueues = new EffectQueue[EffectType.LENGTH];
     EffectQueue.allocateQueues(mQueues,null,0);
@@ -106,57 +77,11 @@ public class DistortedEffects
  */
   public DistortedEffects(DistortedEffects dc, int flags)
     {
-    mStretchX = dc.mStretchX;
-    mStretchY = dc.mStretchY;
-    mStretchZ = dc.mStretchZ;
-
     mID = ++mNextID;
     mQueues = new EffectQueue[EffectType.LENGTH];
     EffectQueue.allocateQueues(mQueues,dc.getQueues(),flags);
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Sets the stretch parameters. Coordinates of all vertices of any Mesh rendered with those Effects
- * will be first pre-multiplied by those.
- */
-  public void setStretch(int sx, int sy, int sz)
-    {
-    mStretchX[0] = sx;
-    mStretchY[0] = sy;
-    mStretchZ[0] = sz;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * X coordinates of all vertices of any Mesh rendered with those Effects will be first pre-multiplied
- * by this parameter.
- */
-  public int getStartchX()
-    {
-    return mStretchX[0];
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Y coordinates of all vertices of any Mesh rendered with those Effects will be first pre-multiplied
- * by this parameter.
- */
-  public int getStartchY()
-    {
-    return mStretchY[0];
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Z coordinates of all vertices of any Mesh rendered with those Effects will be first pre-multiplied
- * by this parameter.
- */
-  public int getStartchZ()
-    {
-    return mStretchZ[0];
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Returns unique ID of this instance.
diff --git a/src/main/java/org/distorted/library/main/DistortedLibrary.java b/src/main/java/org/distorted/library/main/DistortedLibrary.java
index 8319b1c..19d847c 100644
--- a/src/main/java/org/distorted/library/main/DistortedLibrary.java
+++ b/src/main/java/org/distorted/library/main/DistortedLibrary.java
@@ -430,9 +430,9 @@ public class DistortedLibrary
 
   static void drawPrivOIT(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime)
     {
-    float halfX = effects.getStartchX() / 2.0f;
-    float halfY = effects.getStartchY() / 2.0f;
-    float halfZ = effects.getStartchZ() / 2.0f;
+    float halfX = mesh.getStretchX() / 2.0f;
+    float halfY = mesh.getStretchY() / 2.0f;
+    float halfZ = mesh.getStretchZ() / 2.0f;
 
     EffectQueue[] queues = effects.getQueues();
 
@@ -467,9 +467,9 @@ public class DistortedLibrary
 
   static void drawPriv(DistortedEffects effects, MeshBase mesh, InternalOutputSurface surface, long currTime)
     {
-    float halfX = effects.getStartchX() / 2.0f;
-    float halfY = effects.getStartchY() / 2.0f;
-    float halfZ = effects.getStartchZ() / 2.0f;
+    float halfX = mesh.getStretchX() / 2.0f;
+    float halfY = mesh.getStretchY() / 2.0f;
+    float halfZ = mesh.getStretchZ() / 2.0f;
 
     EffectQueue[] queues = effects.getQueues();
 
diff --git a/src/main/java/org/distorted/library/main/DistortedNode.java b/src/main/java/org/distorted/library/main/DistortedNode.java
index d97d65e..b004b2d 100644
--- a/src/main/java/org/distorted/library/main/DistortedNode.java
+++ b/src/main/java/org/distorted/library/main/DistortedNode.java
@@ -240,8 +240,8 @@ public class DistortedNode implements InternalChildrenList.Parent
 
   private DistortedFramebuffer allocateNewFBO()
     {
-    int width  = mFboW <= 0 ? mEffects.getStartchX() : mFboW;
-    int height = mFboH <= 0 ? mEffects.getStartchY() : mFboH;
+    int width  = mFboW <= 0 ? (int)mMesh.getStretchX() : mFboW;
+    int height = mFboH <= 0 ? (int)mMesh.getStretchY() : mFboH;
     return new DistortedFramebuffer(1,mFboDepthStencil, InternalSurface.TYPE_TREE, width, height);
     }
 
diff --git a/src/main/java/org/distorted/library/main/DistortedScreen.java b/src/main/java/org/distorted/library/main/DistortedScreen.java
index 4f25ecd..75af083 100644
--- a/src/main/java/org/distorted/library/main/DistortedScreen.java
+++ b/src/main/java/org/distorted/library/main/DistortedScreen.java
@@ -165,7 +165,8 @@ public class DistortedScreen extends DistortedFramebuffer
       fpsTexture = new DistortedTexture();
       fpsTexture.setTexture(fpsBitmap);
       fpsCanvas = new Canvas(fpsBitmap);
-      fpsEffects = new DistortedEffects(FPS_W,FPS_H,0);
+      fpsEffects = new DistortedEffects();
+      fpsMesh.setStretch(FPS_W,FPS_H,0);
       fpsEffects.apply(mMoveEffect);
 
       mPaint = new Paint();
diff --git a/src/main/java/org/distorted/library/mesh/MeshBase.java b/src/main/java/org/distorted/library/mesh/MeshBase.java
index f7b07e5..295bd38 100644
--- a/src/main/java/org/distorted/library/mesh/MeshBase.java
+++ b/src/main/java/org/distorted/library/mesh/MeshBase.java
@@ -68,6 +68,7 @@ public abstract class MeshBase
    private int mNumVertices;
    private float[] mVertAttribs;      // packed: PosX,PosY,PosZ, NorX,NorY,NorZ, InfX,InfY,InfZ, TexS,TexT
    private float mInflate;
+   private float mStretchX, mStretchY, mStretchZ;
 
    private class Component
      {
@@ -100,8 +101,12 @@ public abstract class MeshBase
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-   MeshBase()
+   MeshBase(float width, float height, float depth)
      {
+     mStretchX = width;
+     mStretchY = height;
+     mStretchZ = depth;
+
      mShowNormals = false;
      mInflate     = 0.0f;
      mComponent = new ArrayList<>();
@@ -116,6 +121,10 @@ public abstract class MeshBase
 
    MeshBase(MeshBase original)
      {
+     mStretchX = original.mStretchX;
+     mStretchY = original.mStretchY;
+     mStretchZ = original.mStretchZ;
+
      mShowNormals = original.mShowNormals;
      mInflate     = original.mInflate;
 
@@ -173,6 +182,44 @@ public abstract class MeshBase
      return mNumVertices;
      }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Sets the stretch parameters. Coordinates of all vertices will be first pre-multiplied by those.
+ */
+  public void setStretch(int sx, int sy, int sz)
+    {
+    mStretchX = sx;
+    mStretchY = sy;
+    mStretchZ = sz;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * X coordinates of all vertices will be first pre-multiplied by this parameter.
+ */
+  public float getStretchX()
+    {
+    return mStretchX;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Y coordinates of all vertices will be first pre-multiplied by this parameter.
+ */
+  public float getStretchY()
+    {
+    return mStretchY;
+    }
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Z coordinates of all vertices will be first pre-multiplied by this parameter.
+ */
+  public float getStretchZ()
+    {
+    return mStretchZ;
+    }
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Not part of public API, do not document (public only because has to be used from the main package)
diff --git a/src/main/java/org/distorted/library/mesh/MeshCubes.java b/src/main/java/org/distorted/library/mesh/MeshCubes.java
index 109ad1e..35ec9ba 100644
--- a/src/main/java/org/distorted/library/mesh/MeshCubes.java
+++ b/src/main/java/org/distorted/library/mesh/MeshCubes.java
@@ -827,6 +827,7 @@ public class MeshCubes extends MeshBase
  */
  public MeshCubes(int cols, String desc, int slices)
    {
+   super(1,1,1);
    Static4D map = new Static4D(0.0f,0.0f,1.0f,1.0f);
    fillTexMappings(map,map,map,map,map,map);
    prepareDataStructures(cols,desc,slices);
@@ -872,6 +873,7 @@ public class MeshCubes extends MeshBase
  */
  public MeshCubes(int cols, String desc, int slices, Static4D front, Static4D back, Static4D left, Static4D right, Static4D top, Static4D bottom)
    {
+   super(1,1,1);
    fillTexMappings(front,back,left,right,top,bottom);
    prepareDataStructures(cols,desc,slices);
    build();
@@ -887,6 +889,7 @@ public class MeshCubes extends MeshBase
  */
  public MeshCubes(int cols, int rows, int slices)
    {
+   super(1,1,1);
    Static4D map = new Static4D(0.0f,0.0f,1.0f,1.0f);
    fillTexMappings(map,map,map,map,map,map);
    prepareDataStructures(cols,rows,slices);
@@ -916,6 +919,7 @@ public class MeshCubes extends MeshBase
  */
  public MeshCubes(int cols, int rows, int slices, Static4D front, Static4D back, Static4D left, Static4D right, Static4D top, Static4D bottom)
    {
+   super(1,1,1);
    fillTexMappings(front,back,left,right,top,bottom);
    prepareDataStructures(cols,rows,slices);
    build();
diff --git a/src/main/java/org/distorted/library/mesh/MeshQuad.java b/src/main/java/org/distorted/library/mesh/MeshQuad.java
index 7cc7967..c0cd055 100644
--- a/src/main/java/org/distorted/library/mesh/MeshQuad.java
+++ b/src/main/java/org/distorted/library/mesh/MeshQuad.java
@@ -56,6 +56,7 @@ public class MeshQuad extends MeshBase
    */
   public MeshQuad()
     {
+    super(1,1,0);
     float[] attribs= new float[VERT_ATTRIBS*4];
 
     addVertex(0.0f,0.0f, attribs,0);
diff --git a/src/main/java/org/distorted/library/mesh/MeshRectangles.java b/src/main/java/org/distorted/library/mesh/MeshRectangles.java
index 4de10af..3b62e91 100644
--- a/src/main/java/org/distorted/library/mesh/MeshRectangles.java
+++ b/src/main/java/org/distorted/library/mesh/MeshRectangles.java
@@ -158,6 +158,7 @@ public class MeshRectangles extends MeshBase
  */
  public MeshRectangles(int cols, int rows)
     {
+    super(1,1,0);
     computeNumberOfVertices(cols,rows);
 
     float[] attribs= new float[VERT_ATTRIBS*numVertices];
diff --git a/src/main/java/org/distorted/library/mesh/MeshSphere.java b/src/main/java/org/distorted/library/mesh/MeshSphere.java
index d26d3ea..194705b 100644
--- a/src/main/java/org/distorted/library/mesh/MeshSphere.java
+++ b/src/main/java/org/distorted/library/mesh/MeshSphere.java
@@ -253,6 +253,7 @@ public class MeshSphere extends MeshBase
    */
   public MeshSphere(int level)
     {
+    super(1,1,1);
     computeNumberOfVertices(level);
     float[] attribs= new float[VERT_ATTRIBS*numVertices];
 
