Project

General

Profile

« Previous | Next » 

Revision d620ff06

Added by Leszek Koltunski about 8 years ago

Speed up ObjectTree: we no longer have to traverse the whole tree before rendering to mark everything as not-rendered-yet.

View differences:

src/main/java/org/distorted/library/DistortedObjectTree.java
51 51
    long ID;
52 52
    int numPointingNodes;
53 53
    DistortedFramebuffer mDF;
54
    boolean mRendered;
54
    int numRendered;
55 55

  
56 56
    NodeData(long id)
57 57
      {
58 58
      ID              = id;
59 59
      numPointingNodes= 1;
60 60
      mDF             = null;
61
      mRendered       = false;
61
      numRendered     = 0;
62 62
      }
63 63
    }
64 64
 
......
70 70
    mMapNodeID.clear();
71 71
    }
72 72

  
73
///////////////////////////////////////////////////////////////////////////////////////////////////
74

  
75
  private void markRecursive()
76
    {
77
    mData.mRendered = false;
78
   
79
    synchronized(this)
80
      {
81
      for(int i=0; i<mNumChildren[0]; i++) mChildren.get(i).markRecursive();
82
      }
83
    }
84
  
85 73
///////////////////////////////////////////////////////////////////////////////////////////////////
86 74
  
87 75
  private void drawRecursive(long currTime, DistortedFramebuffer df)
......
94 82
      }
95 83
    else
96 84
      {
97
      if( !mData.mRendered )
85
      if( mData.numRendered==0 )
98 86
        {
99
        mData.mRendered = true;
100 87
        mData.mDF.setAsOutput();
101 88

  
102 89
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
......
117 104
          }
118 105
        }
119 106

  
107
      mData.numRendered++;
108
      mData.numRendered %= mData.numPointingNodes;
109

  
120 110
      df.setAsOutput();
121 111
      mData.mDF.setAsInput();
122 112
      }
......
206 196

  
207 197
///////////////////////////////////////////////////////////////////////////////////////////////////  
208 198
// this will be called on startup and every time OpenGL context has been lost
209
// also call this from the constructor if the OpenGL context has been created already.
210
    
199

  
211 200
  static void reset()
212 201
    {
213 202
    NodeData tmp;   
......
219 208
      if( tmp.mDF != null )
220 209
        {
221 210
    	  tmp.mDF.reset();
222
        tmp.mRendered  = false;
211
        tmp.numRendered = 0;
223 212
        }
224 213
      }
225 214
    }
......
471 460
  public void draw(long currTime)
472 461
    {  
473 462
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
474
    markRecursive();
475 463
    drawRecursive(currTime,Distorted.mFramebuffer);
476 464
    DistortedFramebuffer.deleteAllMarked();
477 465
    DistortedTexture.deleteAllMarked();
......
489 477
  public void draw(long currTime, DistortedFramebuffer df)
490 478
    {
491 479
    df.setAsOutput();
492
    markRecursive();
493 480
    drawRecursive(currTime,df);
494 481
    DistortedFramebuffer.deleteAllMarked();
495 482
    DistortedTexture.deleteAllMarked();

Also available in: Unified diff