Project

General

Profile

« Previous | Next » 

Revision 9af837e8

Added by Leszek Koltunski over 7 years ago

Prevent possibility to enable an effect multiple times.

View differences:

src/main/java/org/distorted/library/effect/Effect.java
38 38
  private final static float[] mUnity= new float[MAX_UNITY_DIM*NUM_EFFECTS];
39 39
  private final static int[]   mUnityDim = new int[NUM_EFFECTS];
40 40

  
41
  static boolean[] mEnabled = new boolean[NUM_EFFECTS];
42

  
43
  static
44
    {
45
    for(int i=0; i<NUM_EFFECTS; i++) mEnabled[i] = false;
46
    }
47

  
41 48
///////////////////////////////////////////////////////////////////////////////////////////////////
42 49

  
43 50
  public abstract boolean compute(float[] uniforms, int index, long currentDuration, long step );
......
47 54
  public static void onDestroy()
48 55
    {
49 56
    mNextID = 0;
57

  
58
    for(int i=0; i<NUM_EFFECTS; i++) mEnabled[i] = false;
50 59
    }
51 60

  
52 61
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/library/effect/FragmentEffect.java
40 40

  
41 41
  static void addEffect(EffectName not_smooth, EffectName yes_smooth, String code)
42 42
    {
43
    int effect1 = not_smooth.ordinal();
44
    int effect2 = yes_smooth.ordinal();
45

  
46
    if( mEnabled[effect1] ) return;
47

  
48
    mEnabled[effect1] = true;
43 49
    mNumEnabled ++;
44 50

  
45 51
    mGLSL +=
46 52

  
47
         "if( fName[i]=="+not_smooth.ordinal()+")\n"
53
         "if( fName[i]=="+effect1+")\n"
48 54
        +  "{\n"
49 55
        +  "degree = sign(degree); \n"
50 56
        +   code +"\n"
51 57
        +  "}\n"
52 58
        +"else\n"
53
        +"if( fName[i]=="+yes_smooth.ordinal()+")\n"
59
        +"if( fName[i]=="+effect2+")\n"
54 60
        +  "{\n"
55 61
        +   code +"\n"
56 62
        +  "}\n"
src/main/java/org/distorted/library/effect/VertexEffect.java
39 39

  
40 40
  static void addEffect(EffectName name, String code)
41 41
    {
42
    int effect = name.ordinal();
43

  
44
    if( mEnabled[effect] ) return;
45

  
46
    mEnabled[effect] = true;
42 47
    mNumEnabled ++;
43 48

  
44 49
    mGLSL +=
45 50

  
46
        "if( vName[i]=="+name.ordinal()+")\n" +
51
        "if( vName[i]=="+effect+")\n" +
47 52
          "{\n" +
48 53
           code +"\n" +
49 54
          "}\n" +

Also available in: Unified diff