Revision 4e2382f3
Added by Leszek Koltunski over 7 years ago
src/main/java/org/distorted/library/DistortedObjectTree.java | ||
---|---|---|
38 | 38 |
private static long mNextNodeID =0; |
39 | 39 |
|
40 | 40 |
private GridObject mGrid; |
41 |
private DistortedObject mObject; |
|
41 |
private DistortedEffectQueues mQueues; |
|
42 |
private DistortedTexture mTexture; |
|
42 | 43 |
private NodeData mData; |
43 | 44 |
|
44 | 45 |
private DistortedObjectTree mParent; |
... | ... | |
87 | 88 |
{ |
88 | 89 |
if( mNumChildren[0]<=0 ) |
89 | 90 |
{ |
90 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mObject.mTextureDataH[0]);
|
|
91 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]);
|
|
91 | 92 |
} |
92 | 93 |
else |
93 | 94 |
{ |
... | ... | |
99 | 100 |
GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
100 | 101 |
GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT); |
101 | 102 |
|
102 |
if( mObject.mBitmapSet[0] )
|
|
103 |
if( mTexture.mBitmapSet[0] )
|
|
103 | 104 |
{ |
104 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mObject.mTextureDataH[0]);
|
|
105 |
mObject.drawNoEffectsPriv(mGrid, mData.mDF);
|
|
105 |
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexture.mTextureDataH[0]);
|
|
106 |
mQueues.drawNoEffectsPriv(mTexture, mGrid, mData.mDF);
|
|
106 | 107 |
} |
107 | 108 |
|
108 | 109 |
synchronized(this) |
... | ... | |
118 | 119 |
mData.mDF.setAsInput(); |
119 | 120 |
} |
120 | 121 |
|
121 |
mObject.drawPriv(currTime, mGrid, df);
|
|
122 |
mQueues.drawPriv(currTime, mTexture, mGrid, df);
|
|
122 | 123 |
} |
123 | 124 |
|
124 | 125 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
146 | 147 |
{ |
147 | 148 |
ArrayList<Long> ret = new ArrayList<>(); |
148 | 149 |
|
149 |
ret.add( mNumChildren[0]>0 ? mObject.getBitmapID() : mObject.getID() );
|
|
150 |
ret.add( mNumChildren[0]>0 ? mTexture.getBitmapID() : mTexture.getID() );
|
|
150 | 151 |
DistortedObjectTree node; |
151 | 152 |
|
152 | 153 |
for(int i=0; i<mNumChildren[0]; i++) |
... | ... | |
177 | 178 |
if( newList.size()>1 ) |
178 | 179 |
{ |
179 | 180 |
if( mData.mDF==null ) |
180 |
mData.mDF = new DistortedFramebuffer(mObject.getWidth(), mObject.getHeight());
|
|
181 |
mData.mDF = new DistortedFramebuffer(mTexture.getWidth(), mTexture.getHeight());
|
|
181 | 182 |
} |
182 | 183 |
else |
183 | 184 |
{ |
... | ... | |
259 | 260 |
/** |
260 | 261 |
* Constructs new Node of the Tree. |
261 | 262 |
* |
262 |
* @param obj DistortedObject to put into the new Node. |
|
263 |
* @param texture DistortedTexture to put into the new Node. |
|
264 |
* @param queues DistortedEffectQueues to put into the new Node. |
|
265 |
* @param grid GridObject to put into the new Node. |
|
263 | 266 |
*/ |
264 |
public DistortedObjectTree(DistortedObject obj, GridObject grid)
|
|
267 |
public DistortedObjectTree(DistortedTexture texture, DistortedEffectQueues queues, GridObject grid)
|
|
265 | 268 |
{ |
266 |
mObject = obj; |
|
269 |
mTexture= texture; |
|
270 |
mQueues = queues; |
|
267 | 271 |
mGrid = grid; |
268 | 272 |
mParent = null; |
269 | 273 |
mChildren = null; |
... | ... | |
271 | 275 |
mNumChildren[0] = 0; |
272 | 276 |
|
273 | 277 |
ArrayList<Long> list = new ArrayList<>(); |
274 |
list.add(obj.getID());
|
|
278 |
list.add(queues.getID()); // TODO: this should depend on both texture and queues! Maybe even on grid as well
|
|
275 | 279 |
|
276 | 280 |
mData = mMapNodeID.get(list); |
277 | 281 |
|
... | ... | |
299 | 303 |
public DistortedObjectTree(DistortedObjectTree node, int flags) |
300 | 304 |
{ |
301 | 305 |
mParent = null; |
302 |
mObject = new DistortedObject(node.mObject,flags); |
|
306 |
mTexture= new DistortedTexture(node.mTexture,flags); |
|
307 |
mQueues = new DistortedEffectQueues(node.mQueues, flags); |
|
303 | 308 |
mGrid = node.mGrid; |
304 | 309 |
|
305 | 310 |
if( (flags & Distorted.CLONE_CHILDREN) != 0 ) |
... | ... | |
352 | 357 |
/** |
353 | 358 |
* Adds a new child to the last position in the list of our Node's children. |
354 | 359 |
* |
355 |
* @param obj DistortedObject to initialize our child Node with. |
|
360 |
* @param texture DistortedTexture to initialize our child Node with. |
|
361 |
* @param queues DistortedEffectQueues to initialize our child Node with. |
|
362 |
* @param grid GridObject to initialize our child Node with. |
|
356 | 363 |
* @return the newly constructed child Node, or null if we couldn't allocate resources. |
357 | 364 |
*/ |
358 |
public synchronized DistortedObjectTree attach(DistortedObject obj, GridObject grid)
|
|
365 |
public synchronized DistortedObjectTree attach(DistortedTexture texture, DistortedEffectQueues queues, GridObject grid)
|
|
359 | 366 |
{ |
360 | 367 |
ArrayList<Long> prev = generateIDList(); |
361 | 368 |
|
362 | 369 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
363 |
DistortedObjectTree node = new DistortedObjectTree(obj,grid);
|
|
370 |
DistortedObjectTree node = new DistortedObjectTree(texture,queues,grid);
|
|
364 | 371 |
node.mParent = this; |
365 | 372 |
mChildren.add(node); |
366 | 373 |
mNumChildren[0]++; |
... | ... | |
401 | 408 |
/** |
402 | 409 |
* Removes the first occurrence of a specified child from the list of children of our Node. |
403 | 410 |
* |
404 |
* @param obj DistortedObject to remove.
|
|
411 |
* @param queues DistortedEffectQueues to remove.
|
|
405 | 412 |
* @return <code>true</code> if the child was successfully removed. |
406 | 413 |
*/ |
407 |
public synchronized boolean detach(DistortedObject obj)
|
|
414 |
public synchronized boolean detach(DistortedEffectQueues queues)
|
|
408 | 415 |
{ |
409 |
long id = obj.getID();
|
|
416 |
long id = queues.getID();
|
|
410 | 417 |
DistortedObjectTree node; |
411 | 418 |
|
412 | 419 |
for(int i=0; i<mNumChildren[0]; i++) |
413 | 420 |
{ |
414 | 421 |
node = mChildren.get(i); |
415 | 422 |
|
416 |
if( node.mObject.getID()==id )
|
|
423 |
if( node.mQueues.getID()==id )
|
|
417 | 424 |
{ |
418 | 425 |
ArrayList<Long> prev = generateIDList(); |
419 | 426 |
|
... | ... | |
480 | 487 |
|
481 | 488 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
482 | 489 |
/** |
483 |
* Returns the DistortedObject object that's in the Node.
|
|
490 |
* Returns the DistortedEffectQueues object that's in the Node.
|
|
484 | 491 |
* |
485 |
* @return The DistortedObject contained in the Node.
|
|
492 |
* @return The DistortedEffectQueues contained in the Node.
|
|
486 | 493 |
*/ |
487 |
public DistortedObject getObject()
|
|
494 |
public DistortedEffectQueues getQueues()
|
|
488 | 495 |
{ |
489 |
return mObject; |
|
496 |
return mQueues; |
|
497 |
} |
|
498 |
|
|
499 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
500 |
/** |
|
501 |
* Returns the DistortedTexture object that's in the Node. |
|
502 |
* |
|
503 |
* @return The DistortedTexture contained in the Node. |
|
504 |
*/ |
|
505 |
public DistortedTexture getTexture() |
|
506 |
{ |
|
507 |
return mTexture; |
|
490 | 508 |
} |
491 | 509 |
|
492 | 510 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Beginnings of split of DistortedObject into two separate classes: DistortedEffectQueues and DistortedTexture.
Still does not compile, but pushing already.