Project

General

Profile

« Previous | Next » 

Revision e8c81a8e

Added by Leszek Koltunski almost 8 years ago

Cleanup, consistent variable names, minor details.

View differences:

src/main/java/org/distorted/library/EffectNames.java
93 93
   * Uniforms: (forceX,forceY,forceZ,regionX,regionY,regionRX,regionRY,centerX,centerY)
94 94
   * Unity: (forceX,forceY,forceZ) = (0,0,0)
95 95
   */
96
  DISTORT          ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} ),      // keep this the first VERT effect (reason: getType)
96
  DISTORT          ( EffectTypes.VERTEX  ,   new float[] {0.0f,0.0f,0.0f} ),
97 97
 /**
98 98
   * Deform the whole Object by applying a 2D vector of force to a center point.
99 99
   * <p>
......
126 126
   * Uniforms: (macroblockSize,UNUSED,UNUSED,UNUSED, regionX, regionY, regionRX, regionRY)
127 127
   * Unity: macroblockSize = 1
128 128
   */
129
  MACROBLOCK       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),      // keep this the first FRAG effect (reason: getType)
129
  MACROBLOCK       ( EffectTypes.FRAGMENT,   new float[] {1.0f}           ),
130 130
 /**
131 131
   * Make a given Region (partially) transparent.
132 132
   * <p>
......
204 204
  
205 205
  private static final int MAXDIM = 4;  // maximum supported dimension of an effect  
206 206
  
207
  private EffectTypes type;
208
  private float[] unity;
209
  
210
  static private float[] unities;
211
  static private int[] dimensions;
207
  private final EffectTypes type;
208
  private final float[] unity;
212 209
  
210
  private static final float[] unities;
211
  private static final int[] dimensions;
212
  private static final EffectNames[] names;
213

  
213 214
  static
214 215
    {
215 216
    int len = values().length;
......
217 218
    
218 219
    dimensions = new int[len];
219 220
    unities    = new float[MAXDIM*len];
220
    
221
    names      = new EffectNames[len];
222

  
221 223
    for(EffectNames name: EffectNames.values())
222 224
      {
223 225
      dimensions[i] = (name.unity==null ? 0 : name.unity.length);
224
      
226
      names[i]      = name;
227

  
225 228
      switch(dimensions[i])
226 229
        {
227 230
        case 4: unities[MAXDIM*i+3] = name.unity[3];
......
244 247
    }
245 248

  
246 249
///////////////////////////////////////////////////////////////////////////////////////////////////
247
// yes, I know we could have used values(i) but that allocates a new copy each time!
248 250

  
249 251
  static EffectTypes getType(int ordinal)
250 252
    {
251
    if( ordinal<DISTORT.ordinal()     ) return EffectTypes.MATRIX;
252
    if( ordinal<MACROBLOCK.ordinal()  ) return EffectTypes.VERTEX;
253
    return names[ordinal].type;
254
    }
253 255

  
254
    return EffectTypes.FRAGMENT;
256
///////////////////////////////////////////////////////////////////////////////////////////////////
257

  
258
  static EffectNames getName(int ordinal)
259
    {
260
    return names[ordinal];
255 261
    }
256 262

  
257 263
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff