commit 0f10a0b6f05578623782e797f6d8966c59e54da6
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Mon May 4 00:26:50 2020 +0100

    A lot of changes.
    
    1) main vertex shader: remove support for degree_object. This functionality will hopefully come back when we introduce other than circular regions.
    2) MeshBase: remove the need to set a Bounding box (this is the point of the whole thing - we wanted to get rid of this so that the advances in MeshJoined will be easier)
    3) Set ground for removing the MeshBase.setStretch / getStretch (another thing needed to advance MeshJoined )
    4) since we removed the Bounding box, we need to change the DEFORN effect to have 1 additional parameter, the 'radius' which takes over the function of the bounding box in the vertex shader.
    5) since the'res no bounding box, simplify the postprocessing Halo (remove EffectQueueMatrix.magnify() )
    6) adjust applications.
    
    After this we will hopefully be ready to introduce MeshBase.preApply(VertexEffect), i.e. bending several simple Meshes with any VertexEffect - including the freshly-introduced PseudoMatrix-Vertex effects like VertexEffectScale - and then combining them into one MeshJoined.

diff --git a/src/main/java/org/distorted/library/effect/EffectName.java b/src/main/java/org/distorted/library/effect/EffectName.java
index 2661dbf..82f8210 100644
--- a/src/main/java/org/distorted/library/effect/EffectName.java
+++ b/src/main/java/org/distorted/library/effect/EffectName.java
@@ -50,7 +50,7 @@ public enum EffectName
   SHEAR            ( EffectType.MATRIX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 0,     3    , MatrixEffectShear.class        ),
 
   DISTORT          ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4,     3    , VertexEffectDistort.class      ),
-  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 3, 4,     3    , VertexEffectDeform.class       ),
+  DEFORM           ( EffectType.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} , 4, 4,     3    , VertexEffectDeform.class       ),
   SINK             ( EffectType.VERTEX  ,   new float[] {1.0f}           , 1, 4,     3    , VertexEffectSink.class         ),
   PINCH            ( EffectType.VERTEX  ,   new float[] {1.0f}           , 3, 4,     3    , VertexEffectPinch.class        ),
   SWIRL            ( EffectType.VERTEX  ,   new float[] {0.0f}           , 1, 4,     3    , VertexEffectSwirl.class        ),
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectDeform.java b/src/main/java/org/distorted/library/effect/VertexEffectDeform.java
index 5ff45d2..dc35fdd 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectDeform.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectDeform.java
@@ -19,6 +19,7 @@
 
 package org.distorted.library.effect;
 
+import org.distorted.library.type.Data1D;
 import org.distorted.library.type.Data3D;
 import org.distorted.library.type.Data4D;
 
@@ -29,6 +30,7 @@ import org.distorted.library.type.Data4D;
 public class VertexEffectDeform extends VertexEffect
   {
   private Data3D mVector, mCenter;
+  private Data1D mRadius;
   private Data4D mRegion;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -41,6 +43,7 @@ public class VertexEffectDeform extends VertexEffect
     {
     mCenter.get(uniforms,index+CENTER_OFFSET,currentDuration,step);
     mRegion.get(uniforms,index+REGION_OFFSET,currentDuration,step);
+    mRadius.get(uniforms,index+3,currentDuration,step);
     return mVector.get(uniforms,index,currentDuration,step);
     }
 
@@ -98,6 +101,8 @@ public class VertexEffectDeform extends VertexEffect
 //        along the force line is.
 //        0<=C<1 looks completely ridiculous and C<0 destroys the system.
 ///////////////////////////////////////////////////////////////////////////////////////////////////
+// 2020-05-03: replaced vec3 'u_Bounding' with a uniform 'vUniforms[effect].w' (i.e. mRadius)
+///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Have to call this before the shaders get compiled (i.e before DistortedLibrary.onCreate()) for the Effect to work.
  */
@@ -113,8 +118,8 @@ public class VertexEffectDeform extends VertexEffect
       + "vec3 center = vUniforms[effect+1].yzw;                              \n"
       + "vec3 ps     = center-v;                                             \n"
       + "vec3 aPS    = abs(ps);                                              \n"
-      + "vec3 maxps  = u_Bounding + abs(center);                             \n"
-      + "float d     = degree_region(vUniforms[effect+2],ps);                \n"
+      + "vec3 maxps  = vUniforms[effect].w + abs(center);                    \n"
+      + "float d     = degree(vUniforms[effect+2],ps);                       \n"
       + "vec3 force  = vUniforms[effect].xyz * d;                            \n"
       + "vec3 aForce = abs(force);                                           \n"
       + "float denom = dot(ps+(1.0-d)*force,ps);                             \n"
@@ -149,13 +154,16 @@ public class VertexEffectDeform extends VertexEffect
  * a (possibly changing in time) point on the Mesh.
  *
  * @param vector Vector of force that deforms the Mesh.
+ * @param radius How 'bendy' the object is. Don';t set this to 0. Typically set this to the object's
+ *               mesh size (i.e. more or less X of the rightmost vertex - X of the leftmost vertex)
  * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  * @param region Region that masks the Effect.
  */
-  public VertexEffectDeform(Data3D vector, Data3D center, Data4D region)
+  public VertexEffectDeform(Data3D vector, Data1D radius, Data3D center, Data4D region)
     {
     super(EffectName.DEFORM);
     mVector = vector;
+    mRadius = radius;
     mCenter = center;
     mRegion = (region==null ? MAX_REGION : region);
     }
@@ -166,12 +174,15 @@ public class VertexEffectDeform extends VertexEffect
  * a (possibly changing in time) point on the Mesh.
  *
  * @param vector Vector of force that deforms the Mesh.
+ * @param radius How 'bendy' the object is. Don't set this to 0. Typically set this to the object's
+ *               mesh size (i.e. more or less X of the rightmost vertex - X of the leftmost vertex)
  * @param center 3-dimensional Data that, at any given time, returns the Center of the Effect.
  */
-  public VertexEffectDeform(Data3D vector, Data3D center)
+  public VertexEffectDeform(Data3D vector, Data1D radius, Data3D center)
     {
     super(EffectName.DEFORM);
     mVector = vector;
+    mRadius = radius;
     mCenter = center;
     mRegion = MAX_REGION;
     }
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectDistort.java b/src/main/java/org/distorted/library/effect/VertexEffectDistort.java
index ef9de33..b6488e8 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectDistort.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectDistort.java
@@ -125,11 +125,10 @@ public class VertexEffectDistort extends VertexEffect
     {
     addEffect(EffectName.DISTORT,
 
-        "vec3 center = vUniforms[effect+1].yzw;                        \n"
-      + "vec3 ps = center-v;                                           \n"
+        "vec3 ps = vUniforms[effect+1].yzw - v;                        \n"
       + "vec3 force = vUniforms[effect].xyz;                           \n"
       + "vec4 region= vUniforms[effect+2];                             \n"
-      + "float d = degree(region,center,ps);                           \n"
+      + "float d = degree(region,ps);                                  \n"
 
       + "if( d>0.0 )                                                   \n"
       + "  {                                                           \n"
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
index 155b75f..c1fcf95 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectPinch.java
@@ -71,12 +71,11 @@ public class VertexEffectPinch extends VertexEffect
     {
     addEffect(EffectName.PINCH,
 
-        "vec3 center = vUniforms[effect+1].yzw;              \n"
-      + "vec3 ps = center-v;                                 \n"
+        "vec3 ps = vUniforms[effect+1].yzw -v;               \n"
       + "float h         = vUniforms[effect].x;              \n"
       + "float latitude  = vUniforms[effect].y;              \n"
       + "float longitude = vUniforms[effect].z;              \n"
-      + "float deg = degree(vUniforms[effect+2],center,ps);  \n"
+      + "float deg = degree(vUniforms[effect+2],ps);         \n"
       + "float t = deg * (1.0-h)/max(1.0,h);                 \n"
       + "float sinLAT = sin(latitude);                       \n"
       + "float cosLAT = cos(latitude);                       \n"
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectSink.java b/src/main/java/org/distorted/library/effect/VertexEffectSink.java
index 206e186..42ea29b 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectSink.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectSink.java
@@ -60,10 +60,9 @@ public class VertexEffectSink extends VertexEffect
     {
     addEffect(EffectName.SINK,
 
-        "vec3 center = vUniforms[effect+1].yzw;            \n"
-      + "vec3 ps = center-v;                               \n"
+        "vec3 ps = vUniforms[effect+1].yzw - v;            \n"
       + "float h = vUniforms[effect].x;                    \n"
-      + "float deg = degree(vUniforms[effect+2],center,ps);\n"
+      + "float deg = degree(vUniforms[effect+2],ps);       \n"
       + "float t = deg * (1.0-h)/max(1.0,h);               \n"
       + "v += t*ps;                                        \n"
 
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java b/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
index 4efe791..6d441b9 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectSwirl.java
@@ -72,17 +72,16 @@ public class VertexEffectSwirl extends VertexEffect
         "vec3 center = vUniforms[effect+1].yzw;                             \n"
       + "vec3 PS = center-v.xyz;                                            \n"
       + "vec4 SO = vUniforms[effect+2];                                     \n"
-      + "float d1_circle = degree_region(SO,PS);                            \n"
-      + "float d1_object = degree_object(center,PS);                        \n"
+      + "float deg1 = degree(SO,PS);                                        \n"
       + "float alpha = vUniforms[effect].x;                                 \n"
       + "float sinA = sin(alpha);                                           \n"
       + "float cosA = cos(alpha);                                           \n"
 
       + "vec3 PS2 = vec3( PS.x*cosA+PS.y*sinA,-PS.x*sinA+PS.y*cosA, PS.z ); \n" // vector PS rotated by A radians clockwise around center.
-      + "vec4 SG = (1.0-d1_circle)*SO;                                      \n" // coordinates of the dilated circle P is going to get rotated around
-      + "float d2 = max(0.0,degree(SG,center,PS2));                         \n" // make it a max(0,deg) because otherwise when center=left edge of the
+      + "vec4 SG = (1.0-deg1)*SO;                                           \n" // coordinates of the dilated circle P is going to get rotated around
+      + "float d2 = max(0.0,degree(SG,PS2));                                \n" // make it a max(0,deg) because otherwise when center=left edge of the
                                                                                 // object some points end up with d2<0 and they disappear off view.
-      + "v.xy += min(d1_circle,d1_object)*(PS.xy - PS2.xy/(1.0-d2));        \n" // if d2=1 (i.e P=center) we should have P unchanged. How to do it?
+      + "v.xy += deg1 * (PS.xy - PS2.xy/(1.0-d2));                          \n" // if d2=1 (i.e P=center) we should have P unchanged. How to do it?
       );
     }
 
diff --git a/src/main/java/org/distorted/library/effect/VertexEffectWave.java b/src/main/java/org/distorted/library/effect/VertexEffectWave.java
index 603f23e..d545fad 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffectWave.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffectWave.java
@@ -129,61 +129,61 @@ public class VertexEffectWave extends VertexEffect
     {
     addEffect(EffectName.WAVE,
 
-        "vec3 center     = vUniforms[effect+1].yzw; \n"
-      + "float amplitude = vUniforms[effect  ].x; \n"
-      + "float length    = vUniforms[effect  ].y; \n"
+        "vec3 center     = vUniforms[effect+1].yzw;                   \n"
+      + "float amplitude = vUniforms[effect  ].x;                     \n"
+      + "float length    = vUniforms[effect  ].y;                     \n"
 
-      + "vec3 ps = center - v; \n"
-      + "float deg = amplitude*degree_region(vUniforms[effect+2],ps); \n"
+      + "vec3 ps = center - v;                                        \n"
+      + "float deg = amplitude*degree(vUniforms[effect+2],ps);        \n"
 
-      + "if( deg != 0.0 && length != 0.0 ) \n"
-      +   "{ \n"
-      +   "float phase = vUniforms[effect  ].z; \n"
-      +   "float alpha = vUniforms[effect  ].w; \n"
-      +   "float beta  = vUniforms[effect+1].x; \n"
+      + "if( deg != 0.0 && length != 0.0 )                            \n"
+      +   "{                                                          \n"
+      +   "float phase = vUniforms[effect  ].z;                       \n"
+      +   "float alpha = vUniforms[effect  ].w;                       \n"
+      +   "float beta  = vUniforms[effect+1].x;                       \n"
 
-      +   "float sinA = sin(alpha); \n"
-      +   "float cosA = cos(alpha); \n"
-      +   "float sinB = sin(beta); \n"
-      +   "float cosB = cos(beta); \n"
+      +   "float sinA = sin(alpha);                                   \n"
+      +   "float cosA = cos(alpha);                                   \n"
+      +   "float sinB = sin(beta);                                    \n"
+      +   "float cosB = cos(beta);                                    \n"
 
       +   "float angle= 1.578*(ps.x*cosB-ps.y*sinB) / length + phase; \n"
-      +   "vec3 dir= vec3(sinB*cosA,cosB*cosA,sinA); \n"
-      +   "v += sin(angle)*deg*dir; \n"
-
-      +   "if( n.z != 0.0 ) \n"
-      +     "{ \n"
-      +     "float sqrtX = sqrt(dir.y*dir.y + dir.z*dir.z); \n"
-      +     "float sqrtY = sqrt(dir.x*dir.x + dir.z*dir.z); \n"
-
-      +     "float sinX = ( sqrtY==0.0 ? 0.0 : dir.z / sqrtY); \n"
-      +     "float cosX = ( sqrtY==0.0 ? 1.0 : dir.x / sqrtY); \n"
-      +     "float sinY = ( sqrtX==0.0 ? 0.0 : dir.z / sqrtX); \n"
-      +     "float cosY = ( sqrtX==0.0 ? 1.0 : dir.y / sqrtX); \n"
-
-      +     "float abs_z = dir.z <0.0 ? -(sinX*sinY) : (sinX*sinY); \n"
-      +     "float tmp = 1.578*cos(angle)*deg/length; \n"
-
-      +     "float fx =-cosB*tmp; \n"
-      +     "float fy = sinB*tmp; \n"
-
-      +     "vec3 sx = vec3 (1.0+cosX*fx,cosY*sinX*fx,abs_z*fx); \n"
-      +     "vec3 sy = vec3 (cosX*sinY*fy,1.0+cosY*fy,abs_z*fy); \n"
-
-      +     "vec3 normal = cross(sx,sy); \n"
-
-      +     "if( normal.z<=0.0 ) \n"                   // Why this bizarre thing rather than the straightforward
-      +       "{ \n"                                   //
-      +       "normal.x= 0.0; \n"                      // if( normal.z>0.0 )
-      +       "normal.y= 0.0; \n"                      //   {
-      +       "normal.z= 1.0; \n"                      //   n.x = (n.x*normal.z + n.z*normal.x);
-      +       "} \n"                                   //   n.y = (n.y*normal.z + n.z*normal.y);
-                                                       //   n.z = (n.z*normal.z);
-                                                       //   }
-      +     "n.x = (n.x*normal.z + n.z*normal.x); \n"  //
-      +     "n.y = (n.y*normal.z + n.z*normal.y); \n"  // ? Because if we do the above, my Nexus4 crashes
-      +     "n.z = (n.z*normal.z); \n"                 // during shader compilation!
-      +     "} \n"
+      +   "vec3 dir= vec3(sinB*cosA,cosB*cosA,sinA);                  \n"
+      +   "v += sin(angle)*deg*dir;                                   \n"
+
+      +   "if( n.z != 0.0 )                                           \n"
+      +     "{                                                        \n"
+      +     "float sqrtX = sqrt(dir.y*dir.y + dir.z*dir.z);           \n"
+      +     "float sqrtY = sqrt(dir.x*dir.x + dir.z*dir.z);           \n"
+
+      +     "float sinX = ( sqrtY==0.0 ? 0.0 : dir.z / sqrtY);        \n"
+      +     "float cosX = ( sqrtY==0.0 ? 1.0 : dir.x / sqrtY);        \n"
+      +     "float sinY = ( sqrtX==0.0 ? 0.0 : dir.z / sqrtX);        \n"
+      +     "float cosY = ( sqrtX==0.0 ? 1.0 : dir.y / sqrtX);        \n"
+
+      +     "float abs_z = dir.z <0.0 ? -(sinX*sinY) : (sinX*sinY);   \n"
+      +     "float tmp = 1.578*cos(angle)*deg/length;                 \n"
+
+      +     "float fx =-cosB*tmp;                                     \n"
+      +     "float fy = sinB*tmp;                                     \n"
+
+      +     "vec3 sx = vec3 (1.0+cosX*fx,cosY*sinX*fx,abs_z*fx);      \n"
+      +     "vec3 sy = vec3 (cosX*sinY*fy,1.0+cosY*fy,abs_z*fy);      \n"
+
+      +     "vec3 normal = cross(sx,sy);                              \n"
+
+      +     "if( normal.z<=0.0 )                                      \n"   // Why this bizarre thing rather than the straightforward
+      +       "{                                                      \n"   //
+      +       "normal.x= 0.0;                                         \n"   // if( normal.z>0.0 )
+      +       "normal.y= 0.0;                                         \n"   //   {
+      +       "normal.z= 1.0;                                         \n"   //   n.x = (n.x*normal.z + n.z*normal.x);
+      +       "}                                                      \n"   //   n.y = (n.y*normal.z + n.z*normal.y);
+                                                                            //   n.z = (n.z*normal.z);
+                                                                            //   }
+      +     "n.x = (n.x*normal.z + n.z*normal.x);                     \n"   //
+      +     "n.y = (n.y*normal.z + n.z*normal.y);                     \n"   // ? Because if we do the above, my Nexus4 crashes
+      +     "n.z = (n.z*normal.z);                                    \n"   // during shader compilation!
+      +     "}                                                        \n"
       +   "}"
       );
     }
diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java b/src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java
index 949f779..8ee018e 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueueMatrix.java
@@ -37,16 +37,10 @@ class EffectQueueMatrix extends EffectQueue
   private static float[] mMVPMatrix       = new float[16];
   private static float[] mModelViewMatrix = new float[16];
 
-  private static int[] mBoundingH  = new int[MAIN_VARIANTS];
   private static int[] mStretchH   = new int[MAIN_VARIANTS];
   private static int[] mMVPMatrixH = new int[MAIN_VARIANTS];
   private static int[] mMVMatrixH  = new int[MAIN_VARIANTS];
 
-  private static float[] mTmpMatrix = new float[16];
-  private static float[] mTmpResult = new float[4];
-  private static float[] mTmpPoint  = new float[4];
-  private static float mMinX,mMaxX,mMinY,mMaxY;
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
   EffectQueueMatrix()
@@ -58,68 +52,11 @@ class EffectQueueMatrix extends EffectQueue
 
   static void uniforms(int mProgramH, int variant)
     {
-    mBoundingH[variant] = GLES30.glGetUniformLocation(mProgramH, "u_Bounding");
     mStretchH[variant]  = GLES30.glGetUniformLocation(mProgramH, "u_Stretch");
     mMVPMatrixH[variant]= GLES30.glGetUniformLocation(mProgramH, "u_MVPMatrix");
     mMVMatrixH[variant] = GLES30.glGetUniformLocation(mProgramH, "u_MVMatrix");
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-  private void magnifyDir()
-    {
-    Matrix.multiplyMV(mTmpResult,0,mTmpMatrix,0,mTmpPoint,0);
-    float nx = mTmpResult[0]/mTmpResult[3];
-    float ny = mTmpResult[1]/mTmpResult[3];
-
-    if( nx<mMinX ) mMinX = nx;
-    if( nx>mMaxX ) mMaxX = nx;
-    if( ny<mMinY ) mMinY = ny;
-    if( ny>mMaxY ) mMaxY = ny;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// return a float which describes how much larger an object must be so that it appears to be (about)
-// 'marginInPixels' pixels larger in each direction. Used in Postprocessing.
-
-  float magnify(float[] projection, int width, int height, float mipmap, MeshBase mesh, float marginInPixels)
-    {
-    mMinX = Integer.MAX_VALUE;
-    mMaxX = Integer.MIN_VALUE;
-    mMinY = Integer.MAX_VALUE;
-    mMaxY = Integer.MIN_VALUE;
-
-    mTmpPoint[3] = 1.0f;
-
-    Matrix.multiplyMM(mTmpMatrix, 0, projection, 0, mModelViewMatrix, 0);
-
-    float halfX = mesh.getBoundingX();
-    float halfY = mesh.getBoundingY();
-    float halfZ = mesh.getBoundingZ();
-
-    mTmpPoint[0] = +halfX; mTmpPoint[1] = +halfY; mTmpPoint[2] = +halfZ; magnifyDir();
-    mTmpPoint[0] = +halfX; mTmpPoint[1] = +halfY; mTmpPoint[2] = -halfZ; magnifyDir();
-    mTmpPoint[0] = +halfX; mTmpPoint[1] = -halfY; mTmpPoint[2] = +halfZ; magnifyDir();
-    mTmpPoint[0] = +halfX; mTmpPoint[1] = -halfY; mTmpPoint[2] = -halfZ; magnifyDir();
-    mTmpPoint[0] = -halfX; mTmpPoint[1] = +halfY; mTmpPoint[2] = +halfZ; magnifyDir();
-    mTmpPoint[0] = -halfX; mTmpPoint[1] = +halfY; mTmpPoint[2] = -halfZ; magnifyDir();
-    mTmpPoint[0] = -halfX; mTmpPoint[1] = -halfY; mTmpPoint[2] = +halfZ; magnifyDir();
-    mTmpPoint[0] = -halfX; mTmpPoint[1] = -halfY; mTmpPoint[2] = -halfZ; magnifyDir();
-
-    float xLenInPixels = width *(mMaxX-mMinX)/2;
-    float yLenInPixels = height*(mMaxY-mMinY)/2;
-
-    // already margin / avg(xLen,yLen) is the size of the halo.
-    // Here we need a bit more because we are marking not only the halo, but a little bit around
-    // it as well so that the (blur for example) will be smooth on the edges. Thus the 2.0f.
-    // ( 4.0 because there is an extra 2.0 from the avg(xLen,yLen) )
-    //
-    // mMipmap ( 1.0, 0.5, 0.25, 0.125 ) - we need to make the size of the halo independent
-    // of postprocessing effect quality.
-
-    return mipmap*4.0f*marginInPixels/( xLenInPixels+yLenInPixels );
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
   void compute(long currTime)
@@ -164,7 +101,6 @@ class EffectQueueMatrix extends EffectQueue
     // combined Model-View-Projection matrix
     Matrix.multiplyMM(mMVPMatrix, 0, projection, 0, mModelViewMatrix, 0);
 
-    GLES30.glUniform3f( mBoundingH[variant] , mesh.getBoundingX(), mesh.getBoundingY(), mesh.getBoundingZ());
     GLES30.glUniform3f( mStretchH[variant]  , mesh.getStretchX() , mesh.getStretchY() , mesh.getStretchZ() );
     GLES30.glUniformMatrix4fv(mMVMatrixH[variant] , 1, false, mModelViewMatrix, 0);
     GLES30.glUniformMatrix4fv(mMVPMatrixH[variant], 1, false, mMVPMatrix      , 0);
diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
index dade475..78b2839 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueuePostprocess.java
@@ -178,16 +178,8 @@ public class EffectQueuePostprocess extends EffectQueue
     EffectQueueMatrix matrix = (EffectQueueMatrix)queues[0];
     EffectQueueVertex vertex = (EffectQueueVertex)queues[1];
 
-    float inflate=0.0f;
-
     matrix.send(distance, mipmap, projection, mesh, 2);
-
-    if( mHalo!=0.0f )
-      {
-      inflate = matrix.magnify(projection, width, height, mipmap, mesh, mHalo);
-      }
-
-    vertex.send(inflate,2);
+    vertex.send(mHalo*0.01f,2);
 
     if( mA!=0.0f )
       {
diff --git a/src/main/java/org/distorted/library/mesh/MeshBase.java b/src/main/java/org/distorted/library/mesh/MeshBase.java
index 6fb410a..e9a16bd 100644
--- a/src/main/java/org/distorted/library/mesh/MeshBase.java
+++ b/src/main/java/org/distorted/library/mesh/MeshBase.java
@@ -65,7 +65,6 @@ 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 mBoundingX, mBoundingY, mBoundingZ;
    private float mStretchX, mStretchY, mStretchZ;
 
    private static class Component
@@ -99,12 +98,8 @@ public abstract class MeshBase
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-   MeshBase(float bx, float by, float bz)
+   MeshBase()
      {
-     mBoundingX = bx/2;
-     mBoundingY = by/2;
-     mBoundingZ = bz/2;
-
      mStretchX = 1.0f;
      mStretchY = 1.0f;
      mStretchZ = 1.0f;
@@ -122,10 +117,6 @@ public abstract class MeshBase
 
    MeshBase(MeshBase original)
      {
-     mBoundingX = original.mBoundingX;
-     mBoundingY = original.mBoundingY;
-     mBoundingZ = original.mBoundingZ;
-
      mStretchX = original.mStretchX;
      mStretchY = original.mStretchY;
      mStretchZ = original.mStretchZ;
@@ -155,15 +146,6 @@ public abstract class MeshBase
      return mComponent.size();
      }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-
-   void setBounding(float bx, float by, float bz)
-     {
-     mBoundingX = bx/2;
-     mBoundingY = by/2;
-     mBoundingZ = bz/2;
-     }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // when a derived class is done computing its mesh, it has to call this method.
 
@@ -533,37 +515,6 @@ public abstract class MeshBase
      return (component>=0 && component<mComponent.size()) ? mComponent.get(component).mTextureMap : null;
      }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Each mesh has its 'bounding box' - return half of its X-length.
- * <p>
- * In case of all 'simple' Meshes, the bounding box is always 1x1x1 (Sphere, Cubes) or 1x1x0
- * (Rectangles, Triangles, Quad - i.e. all 'flat' Meshes). But this can be something else in case of
- * MeshComponent.
- */
-   public float getBoundingX()
-    {
-    return mBoundingX*mStretchX;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Each mesh has its 'bounding box' - return half of its Y-length.
- */
-   public float getBoundingY()
-    {
-    return mBoundingY*mStretchY;
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Each mesh has its 'bounding box' - return half of its Z-length.
- */
-   public float getBoundingZ()
-    {
-    return mBoundingZ*mStretchZ;
-    }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Sometimes we want to display a Mesh on a rectangular screen. Then we need to stretch it by
diff --git a/src/main/java/org/distorted/library/mesh/MeshCubes.java b/src/main/java/org/distorted/library/mesh/MeshCubes.java
index 35ec9ba..340f8d9 100644
--- a/src/main/java/org/distorted/library/mesh/MeshCubes.java
+++ b/src/main/java/org/distorted/library/mesh/MeshCubes.java
@@ -827,7 +827,7 @@ public class MeshCubes extends MeshBase
  */
  public MeshCubes(int cols, String desc, int slices)
    {
-   super(1,1,1);
+   super();
    Static4D map = new Static4D(0.0f,0.0f,1.0f,1.0f);
    fillTexMappings(map,map,map,map,map,map);
    prepareDataStructures(cols,desc,slices);
@@ -873,7 +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);
+   super();
    fillTexMappings(front,back,left,right,top,bottom);
    prepareDataStructures(cols,desc,slices);
    build();
@@ -889,7 +889,7 @@ public class MeshCubes extends MeshBase
  */
  public MeshCubes(int cols, int rows, int slices)
    {
-   super(1,1,1);
+   super();
    Static4D map = new Static4D(0.0f,0.0f,1.0f,1.0f);
    fillTexMappings(map,map,map,map,map,map);
    prepareDataStructures(cols,rows,slices);
@@ -919,7 +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);
+   super();
    fillTexMappings(front,back,left,right,top,bottom);
    prepareDataStructures(cols,rows,slices);
    build();
diff --git a/src/main/java/org/distorted/library/mesh/MeshJoined.java b/src/main/java/org/distorted/library/mesh/MeshJoined.java
index 5677b37..dc9e9af 100644
--- a/src/main/java/org/distorted/library/mesh/MeshJoined.java
+++ b/src/main/java/org/distorted/library/mesh/MeshJoined.java
@@ -31,30 +31,10 @@ public class MeshJoined extends MeshBase
  */
   public MeshJoined(MeshBase[] meshes)
     {
-    super(1,1,1);
+    super();
     join(meshes);
     }
 
-///////////////////////////////////////////////////////////////////////////////////////////////////
-/**
- * Sets the lengths of the bounding box.
- * <p>
- * The 'bounding box' is an imaginary rectanguloid of size (bx,by,bz) inside of which this Mesh
- * fits tightly.
- * 'Normal' 3D meshes (e.g. Sphere) have this equal to 1,1,1. 'Normal' flat meshes (e.g. Quad) -
- * to 1,1,0. Here however we are joining several, probably already changed by MatrixEffects,
- * Meshes together. If the result fits into the standard 1,1,1 (recommended!) - we don't need to
- * call this function at all.
- *
- * @param bx x-length of the bounding box
- * @param by y-length of the bounding box
- * @param bz z-length of the bounding box
- */
-   public void setBounding(float bx, float by, float bz)
-     {
-     super.setBounding(bx,by,bz);
-     }
-
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Return how many basic Meshes is this Mesh joined from.
diff --git a/src/main/java/org/distorted/library/mesh/MeshQuad.java b/src/main/java/org/distorted/library/mesh/MeshQuad.java
index c0cd055..4db3e0c 100644
--- a/src/main/java/org/distorted/library/mesh/MeshQuad.java
+++ b/src/main/java/org/distorted/library/mesh/MeshQuad.java
@@ -56,7 +56,7 @@ public class MeshQuad extends MeshBase
    */
   public MeshQuad()
     {
-    super(1,1,0);
+    super();
     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 3b62e91..cd6d190 100644
--- a/src/main/java/org/distorted/library/mesh/MeshRectangles.java
+++ b/src/main/java/org/distorted/library/mesh/MeshRectangles.java
@@ -158,7 +158,7 @@ public class MeshRectangles extends MeshBase
  */
  public MeshRectangles(int cols, int rows)
     {
-    super(1,1,0);
+    super();
     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 194705b..51fd536 100644
--- a/src/main/java/org/distorted/library/mesh/MeshSphere.java
+++ b/src/main/java/org/distorted/library/mesh/MeshSphere.java
@@ -253,7 +253,7 @@ public class MeshSphere extends MeshBase
    */
   public MeshSphere(int level)
     {
-    super(1,1,1);
+    super();
     computeNumberOfVertices(level);
     float[] attribs= new float[VERT_ATTRIBS*numVertices];
 
diff --git a/src/main/java/org/distorted/library/mesh/MeshTriangles.java b/src/main/java/org/distorted/library/mesh/MeshTriangles.java
index 4fc0ffb..c960006 100644
--- a/src/main/java/org/distorted/library/mesh/MeshTriangles.java
+++ b/src/main/java/org/distorted/library/mesh/MeshTriangles.java
@@ -107,7 +107,7 @@ public class MeshTriangles extends MeshBase
    */
   public MeshTriangles(int level)
      {
-     super(1,1,0);
+     super();
 
      computeNumberOfVertices(level);
 
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index 683be1c..76d44fd 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -31,7 +31,6 @@ out vec3 v_endPosition;              // for Transform Feedback only
 out vec3 v_Normal;                   //
 out vec2 v_TexCoordinate;            //
 
-uniform vec3 u_Bounding;             // MeshBase.mBounding{X,Y,Z}
 uniform vec3 u_Stretch;              // MeshBase.mStretch{X,Y,Z}
 uniform mat4 u_MVPMatrix;            // the combined model/view/projection matrix.
 uniform mat4 u_MVMatrix;             // the combined model/view matrix.
@@ -46,43 +45,6 @@ uniform vec4 vUniforms[3*NUM_VERTEX];// i-th effect is 3 consecutive vec4's: [3*
 
 //////////////////////////////////////////////////////////////////////////////////////////////
 // HELPER FUNCTIONS
-//////////////////////////////////////////////////////////////////////////////////////////////
-// The trick below is the if-less version of the
-//
-// t = dx<0.0 ? (u_Bounding.x-v.x) / (u_Bounding.x-ux) : (u_Bounding.x+v.x) / (u_Bounding.x+ux);
-// h = dy<0.0 ? (u_Bounding.y-v.y) / (u_Bounding.y-uy) : (u_Bounding.y+v.y) / (u_Bounding.y+uy);
-// d = min(t,h);
-//
-// float d = min(-ps.x/(sign(ps.x)*u_Bounding.x+p.x),-ps.y/(sign(ps.y)*u_Bounding.y+p.y))+1.0;
-//
-// We still have to avoid division by 0 when p.x = +- u_Bounding.x or p.y = +- u_Bounding.y (i.e
-// on the edge of the Object).
-// We do that by first multiplying the above 'float d' with sign(denominator1*denominator2)^2.
-//
-// 2019-01-09: make this 3D. The trick: we want only the EDGES of the cuboid to stay constant.
-// the interiors of the Faces move! Thus, we want the MIDDLE of the PS/(sign(PS)*u_Bounding+S) !
-//////////////////////////////////////////////////////////////////////////////////////////////
-// return degree of the point as defined by the cuboid (u_Bounding.x X u_Bounding.y X u_Bounding.z)
-
-float degree_object(in vec3 S, in vec3 PS)
-  {
-  vec3 ONE = vec3(1.0,1.0,1.0);
-  vec3 A = sign(PS)*u_Bounding + S;
-
-  vec3 signA = sign(A);                      //
-  vec3 signA_SQ = signA*signA;               // div = PS/A if A!=0, 0 otherwise.
-  vec3 div = signA_SQ*PS/(A-(ONE-signA_SQ)); //
-  vec3 ret = sign(u_Bounding)-div;
-
-  float d1= ret.x-ret.y;
-  float d2= ret.y-ret.z;
-  float d3= ret.x-ret.z;
-
-  if( d1*d2>0.0 ) return ret.y;             //
-  if( d1*d3>0.0 ) return ret.z;             // return 1-middle(div.x,div.y,div.z)
-  return ret.x;                             // (unless size of object is 0 then 0-middle)
-  }
-
 //////////////////////////////////////////////////////////////////////////////////////////////
 // Return degree of the point as defined by the Region. Currently only supports spherical regions.
 //
@@ -103,7 +65,7 @@ float degree_object(in vec3 S, in vec3 PS)
 // where a = PS*PO/|PS| but we are really looking for d = |PX|/(|PX|+|PS|) = 1/(1+ (|PS|/|PX|) ) and
 // |PX|/|PS| = -b + sqrt(b^2 + (OX^2-PO^2)/PS^2) where b=PS*PO/|PS|^2 which can be computed with only one sqrt.
 
-float degree_region(in vec4 region, in vec3 PS)
+float degree(in vec4 region, in vec3 PS)
   {
   vec3 PO  = PS + region.xyz;
   float D = region.w*region.w-dot(PO,PO);      // D = |OX|^2 - |PO|^2
@@ -125,39 +87,6 @@ float degree_region(in vec4 region, in vec3 PS)
   return 1.0 / (1.0 + 1.0/(sqrt(DOT*DOT+D*one_over_ps_sq)-DOT));
   }
 
-//////////////////////////////////////////////////////////////////////////////////////////////
-// return min(degree_object,degree_region). Just like degree_region, currently only supports spheres.
-
-float degree(in vec4 region, in vec3 S, in vec3 PS)
-  {
-  vec3 PO  = PS + region.xyz;
-  float D = region.w*region.w-dot(PO,PO);     // D = |OX|^2 - |PO|^2
-
-  if( D<=0.0 ) return 0.0;
-
-  vec3 A = sign(PS)*u_Bounding + S;
-  vec3 signA = sign(A);
-  vec3 signA_SQ = signA*signA;
-  vec3 div = signA_SQ*PS/(A-(vec3(1.0,1.0,1.0)-signA_SQ));
-  vec3 ret = sign(u_Bounding)-div;            // if object is flat, make ret.z 0
-
-  float d1= ret.x-ret.y;
-  float d2= ret.y-ret.z;
-  float d3= ret.x-ret.z;
-  float degree_object;
-
-       if( d1*d2>0.0 ) degree_object= ret.y;  //
-  else if( d1*d3>0.0 ) degree_object= ret.z;  // middle of the ret.{x,y,z} triple
-  else                 degree_object= ret.x;  //
-
-  float ps_sq = dot(PS,PS);
-  float one_over_ps_sq = 1.0/(ps_sq-(sign(ps_sq)-1.0));  // return 1.0 if ps_sq = 0.0
-  float DOT  = dot(PS,PO)*one_over_ps_sq;
-  float degree_region = 1.0/(1.0 + 1.0/(sqrt(DOT*DOT+D*one_over_ps_sq)-DOT));
-
-  return min(degree_region,degree_object);
-  }
-
 #endif  // NUM_VERTEX>0
 
 //////////////////////////////////////////////////////////////////////////////////////////////
