Project

General

Profile

« Previous | Next » 

Revision 8d5a8e06

Added by Leszek Koltunski about 5 years ago

Simplify the way applications can get notifications when an effect finishes.

Now, instead of the 'DistortedEffects.(de)registerForNotifications()' 2 APIs, we call a single 'Effect.notifyWhenFinished()'.

View differences:

src/main/java/org/distorted/examples/deform/DeformRenderer.java
35 35
import org.distorted.library.mesh.MeshFlat;
36 36

  
37 37
import org.distorted.library.message.EffectListener;
38
import org.distorted.library.message.EffectMessage;
39 38
import org.distorted.library.type.Dynamic3D;
40 39
import org.distorted.library.type.Static3D;
41 40
import org.distorted.library.type.Static4D;
......
87 86
      mMove       = new Static3D(0,0,0);
88 87
      mTouchPoint = new Static3D(0,0,0);
89 88

  
90
      mEffects.registerForMessages(this);
91

  
92 89
      // DISTORT
93 90
      Dynamic3D releasedDistortDynamic = new Dynamic3D(NUM_VECTORS*500, 0.5f);
94 91
      releasedDistortDynamic.setMode(Dynamic3D.MODE_PATH);
......
169 166
// keep aborting the 'released' effects, otherwise we are quickly going to run out of room in
170 167
// effect queues.
171 168

  
172
   public void effectMessage(final EffectMessage em, final long effectID, final long objectID)
169
   public void effectFinished(final long effectID)
173 170
     {
174
     switch(em)
175
        {
176
        case EFFECT_FINISHED: mEffects.abortById(effectID); break;
177
        }
171
     mEffects.abortById(effectID);
178 172
     }
179 173

  
180 174
///////////////////////////////////////////////////////////////////////////////////////////////////
......
305 299
                       }
306 300
                     vDistort[NUM_VECTORS-1].set(0,0,0);
307 301
                     mEffects.apply(mReleasedDistort);
302
                     mReleasedDistort.notifyWhenFinished(this);
308 303
                     break;
309 304
       case DEFORM : for(int i=1; i<NUM_VECTORS-1; i++)
310 305
                       {
......
312 307
                       }
313 308
                     vDeform[NUM_VECTORS-1].set(0,0,0);
314 309
                     mEffects.apply(mReleasedDeform);
310
                     mReleasedDeform.notifyWhenFinished(this);
315 311
                     break;
316 312
       case SHEAR  : for(int i=1; i<NUM_VECTORS-1; i++)
317 313
                       {
......
319 315
                       }
320 316
                     vShear[NUM_VECTORS-1].set(0,0,0);
321 317
                     mEffects.apply(mReleasedShear);
318
                     mReleasedShear.notifyWhenFinished(this);
322 319
                     break;
323 320
       }
324 321
     }

Also available in: Unified diff