Project

General

Profile

« Previous | Next » 

Revision be60d4ff

Added by Leszek Koltunski about 7 years ago

Children now properly sorted into Postprocessing Buckets.

View differences:

src/main/java/org/distorted/library/DistortedOutputSurface.java
39 39
    {
40 40
    int type;
41 41
    DistortedNode node;
42
    DistortedEffectsPostprocess dep;
42 43

  
43
    Job(int t, DistortedNode n)
44
    Job(int t, DistortedNode n, DistortedEffectsPostprocess d)
44 45
      {
45 46
      type = t;
46 47
      node = n;
48
      dep  = d;
47 49
      }
48 50
    }
49 51

  
......
63 65

  
64 66
  private float mClearR, mClearG, mClearB, mClearA;
65 67
  private float mClearDepth;
66

  
68
/*
69
private String sNew="", sOld="";
70
*/
67 71
///////////////////////////////////////////////////////////////////////////////////////////////////
68 72

  
69 73
  DistortedOutputSurface(int width, int height, int createColor, int createDepth, int fbo, int type)
......
96 100

  
97 101
///////////////////////////////////////////////////////////////////////////////////////////////////
98 102

  
99
  void createProjection()
103
  private void createProjection()
100 104
    {
101 105
    if( mWidth>0 && mHeight>1 )
102 106
      {
......
145 149
    DistortedNode child;
146 150
    DistortedEffectsPostprocess lastP=null, currP;
147 151
    long lastB=0, currB;
148

  
152
/*
153
sNew = "";
154
*/
149 155
    for(int i=0; i<num; i++)
150 156
      {
151 157
      child = children.get(i);
152 158
      currP = child.getEffectsPostprocess();
153 159
      currB = currP==null ? 0 : currP.getBucket();
154

  
160
/*
161
sNew += currB;
162
*/
155 163
      if( lastB!=currB && lastB!=0 )
156 164
        {
157 165
        numRenders += lastP.postprocess(time,this);
......
179 187
      lastP = currP;
180 188
      lastB = currB;
181 189
      }
182

  
190
/*
191
if( !sNew.equals(sOld) )
192
  {
193
  sOld = sNew;
194
  android.util.Log.e("surface", "Surface"+getID()+": "+sOld);
195
  }
196
*/
183 197
    return numRenders;
184 198
    }
185 199

  
200
///////////////////////////////////////////////////////////////////////////////////////////////////
201

  
202
  void newJob(int t, DistortedNode n, DistortedEffectsPostprocess d)
203
    {
204
    mJobs.add(new Job(t,n,d));
205
    }
206

  
186 207
///////////////////////////////////////////////////////////////////////////////////////////////////
187 208
// PUBLIC API
188 209
///////////////////////////////////////////////////////////////////////////////////////////////////
......
399 420
 */
400 421
  public void attach(DistortedNode node)
401 422
    {
402
    mJobs.add(new Job(ATTACH,node));
423
    mJobs.add(new Job(ATTACH,node,null));
403 424
    DistortedMaster.newSlave(this);
404 425
    }
405 426

  
......
418 439
  public DistortedNode attach(DistortedInputSurface surface, DistortedEffects effects, MeshObject mesh)
419 440
    {
420 441
    DistortedNode node = new DistortedNode(surface,effects,mesh);
421
    mJobs.add(new Job(ATTACH,node));
442
    mJobs.add(new Job(ATTACH,node,null));
422 443
    DistortedMaster.newSlave(this);
423 444
    return node;
424 445
    }
......
448 469
      if( node.getEffects().getID()==id )
449 470
        {
450 471
        detached = true;
451
        mJobs.add(new Job(DETACH,node));
472
        mJobs.add(new Job(DETACH,node,null));
452 473
        DistortedMaster.newSlave(this);
453 474
        break;
454 475
        }
......
485 506
 */
486 507
  public void detach(DistortedNode node)
487 508
    {
488
    mJobs.add(new Job(DETACH,node));
509
    mJobs.add(new Job(DETACH,node,null));
489 510
    DistortedMaster.newSlave(this);
490 511
    }
491 512

  
......
498 519
 */
499 520
  public void detachAll()
500 521
    {
501
    mJobs.add(new Job(DETALL,null));
522
    mJobs.add(new Job(DETALL,null,null));
502 523
    DistortedMaster.newSlave(this);
503 524
    }
504 525

  
......
515 536
    int num = mJobs.size();
516 537
    Job job;
517 538

  
518
    int numChanges=0;
519
    int numSorts  =0;
520

  
521 539
    for(int i=0; i<num; i++)
522 540
      {
523 541
      job = mJobs.remove(0);
524 542

  
525 543
      switch(job.type)
526 544
        {
527
        case ATTACH: numChanges++;
528
                     if( mChildren==null ) mChildren = new ArrayList<>(2);
529
                     mChildren.add(job.node);
545
        case ATTACH: if( mChildren==null ) mChildren = new ArrayList<>(2);
546
                     job.node.setSurfaceParent(this);
547
                     DistortedMaster.addSorted(mChildren,job.node);
530 548
                     mNumChildren++;
531 549
                     break;
532
        case DETACH: numChanges++;
533
                     if( mNumChildren>0 && mChildren.remove(job.node) )
550
        case DETACH: if( mNumChildren>0 && mChildren.remove(job.node) )
534 551
                       {
552
                       job.node.setSurfaceParent(null);
535 553
                       mNumChildren--;
536 554
                       }
537 555
                     break;
538
        case DETALL: numChanges++;
539
                     if( mNumChildren>0 )
556
        case DETALL: if( mNumChildren>0 )
540 557
                       {
558
                       DistortedNode tmp;
559

  
560
                       for(int j=mNumChildren-1; j>=0; j--)
561
                         {
562
                         tmp = mChildren.remove(j);
563
                         tmp.setSurfaceParent(null);
564
                         }
565

  
541 566
                       mNumChildren = 0;
542
                       mChildren.clear();
543 567
                       }
544 568
                     break;
545
        case SORT  : numSorts++;
546
                     // TODO: sort
569
        case SORT  : job.node.setPost(job.dep);
570
                     mChildren.remove(job.node);
571
                     DistortedMaster.addSorted(mChildren,job.node);
547 572
                     break;
548 573
        }
549 574
      }
550

  
551
    if( numChanges>0 && numSorts==0 )
552
      {
553
      // TODO: sort
554
      }
555 575
    }
556 576
}

Also available in: Unified diff