commit 24804c15800446a857292c46cf27501ae8dc7a55
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sun Aug 23 13:00:06 2020 +0100

    Turn the vName, vEffAnd and vEffEqu integer array uniforms into a one ivec4.
    The point: ivec4s are always packed tightly in UBOs (which is going to be the next step)

diff --git a/src/main/java/org/distorted/library/effect/VertexEffect.java b/src/main/java/org/distorted/library/effect/VertexEffect.java
index e43a864..46610ee 100644
--- a/src/main/java/org/distorted/library/effect/VertexEffect.java
+++ b/src/main/java/org/distorted/library/effect/VertexEffect.java
@@ -34,9 +34,9 @@ public abstract class VertexEffect extends Effect
    */
   public static final int NUM_FLOAT_UNIFORMS = 12;
   /**
-   * 3: name, AND association, equ Association
+   * 4: name, AND association, reserved, EQU Association
    */
-  public static final int NUM_INT_UNIFORMS = 3;
+  public static final int NUM_INT_UNIFORMS = 4;
 
   static final int VALUES_OFFSET = 0;
   static final int CENTER_OFFSET = 5;
@@ -63,7 +63,7 @@ public abstract class VertexEffect extends Effect
     {
     return
 
-        "if( vName[i]=="+effect+" )\n" +
+        "if( vProperties[i].x =="+effect+" )\n" +
           "{\n" +
            code +"\n" +
           "}\n" +
diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueue.java b/src/main/java/org/distorted/library/effectqueue/EffectQueue.java
index fae1679..876dfea 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueue.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueue.java
@@ -265,25 +265,17 @@ public abstract class EffectQueue implements InternalMaster.Slave
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
-// this assumes 0<=effect<mNumEffects
+// this assumes 0<=effect
 
   protected void remove(int effect)
     {
-    mNumEffects--;
-
-    int max = mMax[mIndex];
-
-    for(int i=effect; i<mNumEffects; i++ )
+    if( mNumEffects>effect )
       {
-      mEffects[i]= mEffects[i+1];
-
-      for(int j=0; j<mNumIntUniforms; j++)
-        {
-        mIntUniforms[j*max + i] = mIntUniforms[j*max + i+1];
-        }
+      mNumEffects--;
+      System.arraycopy(mEffects, effect+1, mEffects, effect, mNumEffects-effect);
+      System.arraycopy(mIntUniforms, mNumIntUniforms*(effect+1), mIntUniforms, mNumIntUniforms*effect, mNumIntUniforms*(mNumEffects-effect) );
+      mEffects[mNumEffects] = null;
       }
-
-    mEffects[mNumEffects] = null;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -447,22 +439,19 @@ public abstract class EffectQueue implements InternalMaster.Slave
 
                        if( position==-1 )
                          {
-                         mEffects[mNumEffects]     = job.effect;
-                         mIntUniforms[mNumEffects] = job.effect.getName().ordinal();
+                         mEffects[mNumEffects]                     = job.effect;
+                         mIntUniforms[mNumIntUniforms*mNumEffects] = job.effect.getName().ordinal();
 
                          mNumEffects++;
                          changed = true;
                          }
                        else if( position>=0 && position<=mNumEffects )
                          {
-                         for(int j=mNumEffects; j>position; j--)
-                           {
-                           mEffects[j]     = mEffects[j-1];
-                           mIntUniforms[j] = mIntUniforms[j-1];
-                           }
-
-                         mEffects[position]     = job.effect;
-                         mIntUniforms[position] = job.effect.getName().ordinal();
+                         System.arraycopy(mEffects    , position, mEffects    , position+1, mNumEffects-position);
+                         System.arraycopy(mIntUniforms, mNumIntUniforms*position, mIntUniforms, mNumIntUniforms*(position+1), mNumIntUniforms*(mNumEffects-position) );
+
+                         mEffects[position]                     = job.effect;
+                         mIntUniforms[mNumIntUniforms*position] = job.effect.getName().ordinal();
 
                          mNumEffects++;
                          changed = true;
diff --git a/src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java b/src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java
index be142ac..3d60efb 100644
--- a/src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java
+++ b/src/main/java/org/distorted/library/effectqueue/EffectQueueVertex.java
@@ -38,12 +38,10 @@ public class EffectQueueVertex extends EffectQueue
 
   private static final int INDEX = EffectType.VERTEX.ordinal();
 
-  private static int[] mNumEffectsH    = new int[MAIN_VARIANTS];
-  private static int[] mNameH          = new int[MAIN_VARIANTS];
-  private static int[] mUniformsH      = new int[MAIN_VARIANTS];
-  private static int[] mAndAssociationH= new int[MAIN_VARIANTS];
-  private static int[] mEquAssociationH= new int[MAIN_VARIANTS];
-  private static int[] mInflateH       = new int[MAIN_VARIANTS];
+  private static int[] mNumEffectsH = new int[MAIN_VARIANTS];
+  private static int[] mInflateH    = new int[MAIN_VARIANTS];
+  private static int[] mPropertiesH = new int[MAIN_VARIANTS];
+  private static int[] mUniformsH   = new int[MAIN_VARIANTS];
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
    
@@ -63,12 +61,10 @@ public class EffectQueueVertex extends EffectQueue
 
   static void uniforms(int mProgramH, int variant)
     {
-    mNumEffectsH[variant]    = GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
-    mNameH[variant]          = GLES30.glGetUniformLocation( mProgramH, "vName");
-    mUniformsH[variant]      = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
-    mAndAssociationH[variant]= GLES30.glGetUniformLocation( mProgramH, "vEffAndAssoc");
-    mEquAssociationH[variant]= GLES30.glGetUniformLocation( mProgramH, "vEffEquAssoc");
-    mInflateH[variant]       = GLES30.glGetUniformLocation( mProgramH, "u_Inflate");
+    mNumEffectsH[variant]= GLES30.glGetUniformLocation( mProgramH, "vNumEffects");
+    mInflateH[variant]   = GLES30.glGetUniformLocation( mProgramH, "u_Inflate");
+    mPropertiesH[variant]= GLES30.glGetUniformLocation( mProgramH, "vProperties");
+    mUniformsH[variant]  = GLES30.glGetUniformLocation( mProgramH, "vUniforms");
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -85,7 +81,7 @@ public class EffectQueueVertex extends EffectQueue
 
     for(int i=0; i<mNumEffects; i++)
       {
-      mEffects[i].writeAssociations(mIntUniforms, mMax[INDEX]+i, 2*mMax[INDEX]+i);
+      mEffects[i].writeAssociations(mIntUniforms, NUM_INT_UNIFORMS*i+1, NUM_INT_UNIFORMS*i+3);
 
       if( mEffects[i].compute(mFloatUniforms, NUM_FLOAT_UNIFORMS*i, currTime, step) )
         {
@@ -109,10 +105,8 @@ public class EffectQueueVertex extends EffectQueue
 
     if( mNumEffects>0 )
       {
-      GLES30.glUniform1iv( mNameH[variant]          ,                       mNumEffects, mIntUniforms   , 0            );
-      GLES30.glUniform1iv( mAndAssociationH[variant],                       mNumEffects, mIntUniforms   ,   mMax[INDEX]);
-      GLES30.glUniform1iv( mEquAssociationH[variant],                       mNumEffects, mIntUniforms   , 2*mMax[INDEX]);
-      GLES30.glUniform4fv( mUniformsH[variant]      ,(NUM_FLOAT_UNIFORMS/4)*mNumEffects, mFloatUniforms , 0            );
+      GLES30.glUniform4iv( mPropertiesH[variant],                       mNumEffects, mIntUniforms   , 0);
+      GLES30.glUniform4fv( mUniformsH[variant]  ,(NUM_FLOAT_UNIFORMS/4)*mNumEffects, mFloatUniforms , 0);
       }
     }
   }
diff --git a/src/main/res/raw/main_vertex_shader.glsl b/src/main/res/raw/main_vertex_shader.glsl
index 0742f88..5272e6f 100644
--- a/src/main/res/raw/main_vertex_shader.glsl
+++ b/src/main/res/raw/main_vertex_shader.glsl
@@ -20,45 +20,51 @@
 precision highp float;
 precision highp int;
 
-in vec3 a_Position;                  // Per-vertex position.
-in vec3 a_Normal;                    // Per-vertex normal vector.
-in vec3 a_Inflate;                   // This vector describes the direction this vertex needs to go when we 'inflate' the whole mesh.
-                                     // If the mesh is locally smooth, this is equal to the normal vector. Otherwise (on sharp edges) - no.
-in vec2 a_TexCoordinate;             // Per-vertex texture coordinate.
-in float a_Component;                // The component a vertex belongs to.
-                                     // to a vertex effect. An effect will only be active on a vertex iff (a_Association & vAssociation[effect]) != 0.
-                                     // ( see VertexEffect.retSection() )
-
-out vec3 v_Position;                 //
-out vec3 v_endPosition;              // for Transform Feedback only
+in vec3 a_Position;                   // Per-vertex position.
+in vec3 a_Normal;                     // Per-vertex normal vector.
+in vec3 a_Inflate;                    // This vector describes the direction this vertex needs to go when we 'inflate' the whole mesh.
+                                      // If the mesh is locally smooth, this is equal to the normal vector. Otherwise (on sharp edges) - no.
+in vec2 a_TexCoordinate;              // Per-vertex texture coordinate.
+in float a_Component;                 // The component a vertex belongs to.
+                                      // to a vertex effect. An effect will only be active on a vertex iff (a_Association & vAssociation[effect]) != 0.
+                                      // ( see VertexEffect.retSection() )
+
+out vec3 v_Position;                  //
+out vec3 v_endPosition;               // for Transform Feedback only
 
 #ifdef PREAPPLY
-out vec3 v_Inflate;                  // Transform Feedback for preapply effects
+out vec3 v_Inflate;                   // Transform Feedback for preapply effects
 #endif
 
-out vec3 v_Normal;                   //
-out vec2 v_TexCoordinate;            //
+out vec3 v_Normal;                    //
+out vec2 v_TexCoordinate;             //
 
-uniform mat4 u_MVPMatrix;            // u_MVMatrixP * projection.
-uniform mat4 u_MVMatrixP;            // the combined model/view matrix. (for points)
-uniform mat4 u_MVMatrixV;            // the combined model/view matrix. (for vectors)
-                                     // which need to work differently on points and vectors
-uniform float u_Inflate;             // how much should we inflate (>0.0) or deflate (<0.0) the mesh.
-uniform int u_TransformFeedback;     // are we doing the transform feedback now?
+uniform mat4 u_MVPMatrix;             // u_MVMatrixP * projection.
+uniform mat4 u_MVMatrixP;             // the combined model/view matrix. (for points)
+uniform mat4 u_MVMatrixV;             // the combined model/view matrix. (for vectors)
+                                      // which need to work differently on points and vectors
+uniform float u_Inflate;              // how much should we inflate (>0.0) or deflate (<0.0) the mesh.
+uniform int u_TransformFeedback;      // are we doing the transform feedback now?
 
 #if NUM_VERTEX>0
-uniform int vNumEffects;             // total number of vertex effects
-uniform int vName[NUM_VERTEX];       // their names.
-uniform int vEffAndAssoc[NUM_VERTEX];// Associations of the vertex effects. Those are used to connect an effect to a Mesh component.
-uniform int vEffEquAssoc[NUM_VERTEX];// Components the vertex effects work on. Likewise used to connect an effect to a Mesh component.
+uniform int vNumEffects;              // total number of vertex effects
+uniform ivec4 vProperties[NUM_VERTEX];// their properties, 4 ints:
+                                      // 1: name of the effect
+                                      // 2: effect's AND association
+                                      // 3: reserved int (probably another AND assoc in the future)
+                                      // 4: effect's EQU association
 
-uniform vec4 vUniforms[3*NUM_VERTEX];// i-th effect is 3 consecutive vec4's: [3*i], [3*i+1], [3*i+2].
-                                     // The first vec4 is the Interpolated values,
-                                     // second vec4: first float - cache, next 3: Center, the third -  the Region.
+uniform vec4 vUniforms[3*NUM_VERTEX]; // i-th effect is 3 consecutive vec4's: [3*i], [3*i+1], [3*i+2].
+                                      // The first vec4 is the Interpolated values,
+                                      // second vec4: first float - cache, next 3: Center, the third -  the Region.
 
 layout (std140, binding=3) uniform meshAssociation
   {
-  ivec4 vComAssoc[MAX_COMPON]; // component Associations
+  ivec4 vComAssoc[MAX_COMPON];        // component Associations, 4 ints:
+                                      // 1: component's AND association
+                                      // 2: reserved. Probably another AND assoc in the future.
+                                      // 3: component's EQU association
+                                      // 4: reserved
   };
 
 //////////////////////////////////////////////////////////////////////////////////////////////
@@ -118,7 +124,7 @@ void main()
 
   for(int i=0; i<vNumEffects; i++)
     {
-    if( ((vComAssoc[component].x & vEffAndAssoc[i]) != 0) || (vComAssoc[component].z == vEffEquAssoc[i]) )
+    if( ((vComAssoc[component].x & vProperties[i].y) != 0) || (vComAssoc[component].z == vProperties[i].w) )
       {
       // ENABLED EFFECTS WILL BE INSERTED HERE
 
