Project

General

Profile

« Previous | Next » 

Revision d07f2950

Added by Leszek Koltunski almost 8 years ago

Improve aborting Effects.

View differences:

src/main/java/org/distorted/library/DistortedObject.java
12 12
{
13 13
    private static float[] mViewMatrix = new float[16];
14 14
   
15
    protected EffectListMatrix     mM;
16
    protected EffectListFragment   mF;
17
    protected EffectListVertex     mV;
18
    protected EffectListOther      mO;
15
    protected EffectQueueMatrix    mM;
16
    protected EffectQueueFragment  mF;
17
    protected EffectQueueVertex    mV;
18
    protected EffectQueueOther mO;
19 19

  
20 20
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
21 21
 
......
60 60
        } 
61 61
      else
62 62
        {
63
        mM = new EffectListMatrix(d);
63
        mM = new EffectQueueMatrix(d);
64 64
        matrixCloned = false;  
65 65
        }
66 66
    
......
71 71
        } 
72 72
      else
73 73
        {
74
        mV = new EffectListVertex(d);
74
        mV = new EffectQueueVertex(d);
75 75
        vertexCloned = false;  
76 76
        }
77 77
    
......
82 82
        } 
83 83
      else
84 84
        {
85
        mF = new EffectListFragment(d);
85
        mF = new EffectQueueFragment(d);
86 86
        fragmentCloned = false;   
87 87
        }
88 88

  
89
      mO= new EffectListOther(d); // Other effects are never cloned.
89
      mO= new EffectQueueOther(d); // Other effects are never cloned.
90 90
      }
91 91
    
92 92
///////////////////////////////////////////////////////////////////////////////////////////////////
......
187 187
   * Copy constructor used to create a DistortedObject based on various parts of another object.
188 188
   * <p>
189 189
   * Whatever we do not clone gets created just like in the default constructor.
190
   * We only call this from the descendant's classes' constructors where we have to pay attention
191
   * to give it the appropriate type of a DistortedObject!
190 192
   *
191 193
   * @param dc    Source object to create our object from
192 194
   * @param flags A bitmask of values specifying what to copy.
193
   *              For example, CLONE_BITMAP | CLONE_PRESHADER.
195
   *              For example, CLONE_BITMAP | CLONE_MATRIX.
194 196
   */
195 197
    public DistortedObject(DistortedObject dc, int flags)
196 198
      {
......
352 354
    
353 355
///////////////////////////////////////////////////////////////////////////////////////////////////
354 356
/**
355
 * Aborts all Effects. 
357
 * Aborts all Effects.
358
 * @return Number of effects aborted.
356 359
 */
357
    public void abortAllEffects()
360
    public int abortAllEffects()
358 361
      {
359
      mM.abortAll();
360
      mV.abortAll();
361
      mF.abortAll();
362
      mO.abortAll();
362
      return mM.abortAll() + mV.abortAll() + mF.abortAll() + mO.abortAll();
363 363
      }
364 364

  
365 365
///////////////////////////////////////////////////////////////////////////////////////////////////
366 366
/**
367
 * Aborts a subset of Effects.
367
 * Aborts all Effects of a given type, for example all MATRIX Effects.
368 368
 * 
369
 * @param mask Bitmask of the types of effects we want to abort, e.g. TYPE_PRE | TYPE_VERT | TYPE_FRAG.
369
 * @param type one of the constants defined in {@link EffectTypes}
370
 * @return Number of effects aborted.
370 371
 */
371
    public void abortAllEffects(int mask)
372
    public int abortEffects(EffectTypes type)
372 373
      {
373
      if( (mask & EffectTypes.MATRIX.type   ) != 0 ) mM.abortAll();
374
      if( (mask & EffectTypes.VERTEX.type   ) != 0 ) mV.abortAll();
375
      if( (mask & EffectTypes.FRAGMENT.type ) != 0 ) mF.abortAll();
376
      if( (mask & EffectTypes.OTHER.type    ) != 0 ) mO.abortAll();
374
      switch(type)
375
        {
376
        case MATRIX  : return mM.abortAll();
377
        case VERTEX  : return mV.abortAll();
378
        case FRAGMENT: return mF.abortAll();
379
        case OTHER   : return mO.abortAll();
380
        default      : return 0;
381
        }
377 382
      }
378 383
    
379 384
///////////////////////////////////////////////////////////////////////////////////////////////////
......
399 404
/**
400 405
 * Abort all Effects of a given type, for example all rotations.
401 406
 * 
402
 * @param effectType one of the constants defined in {@link EffectNames}
407
 * @param name one of the constants defined in {@link EffectNames}
403 408
 * @return <code>true</code> if a single Effect of type effectType has been found and aborted. 
404 409
 */
405
    public boolean abortEffectType(EffectNames effectType)
410
    public boolean abortEffects(EffectNames name)
406 411
      {
407
      switch(effectType.getType())
412
      switch(name.getType())
408 413
        {
409
        case MATRIX  : return mM.removeByType(effectType);
410
        case VERTEX  : return mV.removeByType(effectType);
411
        case FRAGMENT: return mF.removeByType(effectType);
412
        case OTHER   : return mO.removeByType(effectType);
413
        default           : return false;
414
        case MATRIX  : return mM.removeByType(name);
415
        case VERTEX  : return mV.removeByType(name);
416
        case FRAGMENT: return mF.removeByType(name);
417
        case OTHER   : return mO.removeByType(name);
418
        default      : return false;
414 419
        }
415 420
      }
416 421
    

Also available in: Unified diff