Revision f28fffc2
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/library/DistortedNode.java | ||
---|---|---|
40 | 40 |
private static HashMap<ArrayList<Long>,NodeData> mMapNodeID = new HashMap<>(); |
41 | 41 |
private static long mNextNodeID =0; |
42 | 42 |
|
43 |
private DistortedNode mParent; |
|
43 | 44 |
private MeshObject mMesh; |
44 | 45 |
private DistortedEffects mEffects; |
45 | 46 |
private DistortedInputSurface mSurface; |
... | ... | |
109 | 110 |
|
110 | 111 |
for(i=0; i<depth; i++) tmp +=" "; |
111 | 112 |
tmp += ("NodeID="+mData.ID+" nodes pointing: "+mData.numPointingNodes+" surfaceID="+ |
112 |
mSurface.getID()+" FBO="+(mData.mFBO==null ? "null":mData.mFBO.getID())); |
|
113 |
mSurface.getID()+" FBO="+(mData.mFBO==null ? "null":mData.mFBO.getID()))+ |
|
114 |
" parent sID="+(mParent==null ? "null": (mParent.mSurface.getID())); |
|
113 | 115 |
|
114 | 116 |
android.util.Log.e("NODE", tmp); |
115 | 117 |
|
... | ... | |
133 | 135 |
} |
134 | 136 |
|
135 | 137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
138 |
// tree isomorphism algorithm |
|
136 | 139 |
|
137 |
void treeIsomorphism()
|
|
140 |
private void adjustIsomorphism()
|
|
138 | 141 |
{ |
139 |
for(int i=0; i<mNumChildren[0]; i++) |
|
140 |
{ |
|
141 |
mChildren.get(i).treeIsomorphism(); |
|
142 |
} |
|
143 |
|
|
144 | 142 |
ArrayList<Long> newList = generateIDList(); |
145 | 143 |
NodeData newData = mMapNodeID.get(newList); |
146 | 144 |
|
147 |
if( newData==null ) |
|
145 |
if( newData!=null ) |
|
146 |
{ |
|
147 |
newData.numPointingNodes++; |
|
148 |
} |
|
149 |
else |
|
148 | 150 |
{ |
149 |
android.util.Log.d("NODE", "list "+newList+" not found!! node surfaceID="+mSurface.getID()); |
|
150 |
|
|
151 | 151 |
newData = new NodeData(++mNextNodeID,newList); |
152 | 152 |
mMapNodeID.put(newList,newData); |
153 | 153 |
} |
154 |
else if( newData.ID != mData.ID ) |
|
155 |
{ |
|
156 |
android.util.Log.d("NODE", "list "+newList+" found!! node surfaceID="+mSurface.getID()); |
|
157 | 154 |
|
158 |
newData.numPointingNodes++;
|
|
159 |
}
|
|
155 |
boolean deleteOldFBO = false;
|
|
156 |
boolean createNewFBO = false;
|
|
160 | 157 |
|
161 |
if( newData.ID != mData.ID )
|
|
158 |
if( --mData.numPointingNodes==0 )
|
|
162 | 159 |
{ |
163 |
boolean fboUsed = false; |
|
164 |
|
|
165 |
if( mNumChildren[0]>0 && newData.mFBO==null ) |
|
166 |
{ |
|
167 |
if( mData.mFBO!=null ) |
|
168 |
{ |
|
169 |
if( mData.numPointingNodes>1 ) |
|
170 |
{ |
|
171 |
android.util.Log.d("NODE", "creating1 new FBO of node surfaceID="+mSurface.getID()); |
|
172 |
newData.mFBO = new DistortedFramebuffer(true,DistortedSurface.TYPE_TREE,mSurface.getWidth(),mSurface.getHeight()); |
|
173 |
} |
|
174 |
else |
|
175 |
{ |
|
176 |
android.util.Log.d("NODE", "copying over FBO of node surfaceID="+mSurface.getID()); |
|
177 |
newData.mFBO = mData.mFBO; |
|
178 |
fboUsed = true; |
|
179 |
} |
|
180 |
} |
|
181 |
else |
|
182 |
{ |
|
183 |
android.util.Log.d("NODE", "creating2 new FBO of node surfaceID="+mSurface.getID()); |
|
184 |
newData.mFBO = new DistortedFramebuffer(true,DistortedSurface.TYPE_TREE,mSurface.getWidth(),mSurface.getHeight()); |
|
185 |
} |
|
186 |
} |
|
187 |
if( mNumChildren[0]==0 && newData.mFBO!=null ) |
|
188 |
{ |
|
189 |
android.util.Log.d("NODE", "deleting FBO of newData node!!"); |
|
190 |
newData.mFBO.markForDeletion(); |
|
191 |
newData.mFBO = null; |
|
192 |
} |
|
193 |
|
|
194 |
if( --mData.numPointingNodes==0 ) |
|
195 |
{ |
|
196 |
android.util.Log.d("NODE", "deleting1 map key "+mData.key); |
|
197 |
|
|
198 |
mMapNodeID.remove(mData.key); |
|
160 |
mMapNodeID.remove(mData.key); |
|
161 |
if( mData.mFBO!=null ) deleteOldFBO=true; |
|
162 |
} |
|
163 |
if( mNumChildren[0]>0 && newData.mFBO==null ) |
|
164 |
{ |
|
165 |
createNewFBO = true; |
|
166 |
} |
|
167 |
if( mNumChildren[0]==0 && newData.mFBO!=null ) |
|
168 |
{ |
|
169 |
newData.mFBO.markForDeletion(); |
|
170 |
android.util.Log.d("NODE", "ERROR!! this NodeData cannot possibly contain a non-null FBO!! "+newData.mFBO.getID() ); |
|
171 |
newData.mFBO = null; |
|
172 |
} |
|
199 | 173 |
|
200 |
if( !fboUsed && mData.mFBO!=null ) |
|
201 |
{ |
|
202 |
android.util.Log.d("NODE", "deleting FBO of node surfaceID="+mSurface.getID()); |
|
174 |
if( deleteOldFBO && createNewFBO ) |
|
175 |
{ |
|
176 |
newData.mFBO = mData.mFBO; // just copy over |
|
177 |
android.util.Log.d("NODE", "copying over FBOs "+mData.mFBO.getID() ); |
|
178 |
} |
|
179 |
else if( deleteOldFBO ) |
|
180 |
{ |
|
181 |
mData.mFBO.markForDeletion(); |
|
182 |
android.util.Log.d("NODE", "deleting old FBO "+mData.mFBO.getID() ); |
|
183 |
mData.mFBO = null; |
|
184 |
} |
|
185 |
else if( createNewFBO ) |
|
186 |
{ |
|
187 |
newData.mFBO = new DistortedFramebuffer(true, DistortedSurface.TYPE_TREE, mSurface.getWidth(),mSurface.getHeight()); |
|
188 |
android.util.Log.d("NODE", "creating new FBO "+newData.mFBO.getID() ); |
|
189 |
} |
|
203 | 190 |
|
204 |
mData.mFBO.markForDeletion(); |
|
205 |
mData.mFBO = null; |
|
206 |
} |
|
207 |
} |
|
191 |
mData = newData; |
|
208 | 192 |
|
209 |
mData = newData; |
|
210 |
} |
|
193 |
if( mParent!=null ) mParent.adjustIsomorphism(); |
|
211 | 194 |
} |
212 | 195 |
|
213 | 196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
268 | 251 |
mChildren = null; |
269 | 252 |
mNumChildren = new int[1]; |
270 | 253 |
mNumChildren[0]= 0; |
271 |
|
|
254 |
mParent = null; |
|
255 |
|
|
272 | 256 |
ArrayList<Long> list = new ArrayList<>(); |
273 | 257 |
list.add(mSurface.getID()); |
274 | 258 |
list.add(-mEffects.getID()); |
... | ... | |
299 | 283 |
public DistortedNode(DistortedNode node, int flags) |
300 | 284 |
{ |
301 | 285 |
mEffects= new DistortedEffects(node.mEffects,flags); |
302 |
mMesh = node.mMesh; |
|
286 |
mMesh = node.mMesh; |
|
287 |
mParent = null; |
|
303 | 288 |
|
304 | 289 |
if( (flags & Distorted.CLONE_SURFACE) != 0 ) |
305 | 290 |
{ |
... | ... | |
397 | 382 |
{ |
398 | 383 |
if( mChildren==null ) mChildren = new ArrayList<>(2); |
399 | 384 |
|
385 |
node.mParent = this; |
|
400 | 386 |
mChildren.add(node); |
401 | 387 |
mNumChildren[0]++; |
388 |
adjustIsomorphism(); |
|
402 | 389 |
} |
403 | 390 |
|
404 | 391 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
456 | 443 |
{ |
457 | 444 |
if( mNumChildren[0]>0 && mChildren.remove(node) ) |
458 | 445 |
{ |
446 |
node.mParent = null; |
|
459 | 447 |
mNumChildren[0]--; |
460 |
|
|
461 |
if( mNumChildren[0]==0 && mData.mFBO!=null ) |
|
462 |
{ |
|
463 |
if( --mData.numPointingNodes==0 ) |
|
464 |
{ |
|
465 |
mData.mFBO.markForDeletion(); |
|
466 |
android.util.Log.d("NODE", "deleting2 map key "+mData.key); |
|
467 |
|
|
468 |
mMapNodeID.remove(mData.key); |
|
469 |
} |
|
470 |
mData.mFBO = null; |
|
471 |
} |
|
448 |
adjustIsomorphism(); |
|
472 | 449 |
} |
473 | 450 |
} |
474 | 451 |
|
... | ... | |
494 | 471 |
{ |
495 | 472 |
if( mNumChildren[0]>0 ) |
496 | 473 |
{ |
497 |
mNumChildren[0] = 0; |
|
498 |
mChildren.clear(); |
|
474 |
DistortedNode tmp; |
|
499 | 475 |
|
500 |
if( mData.mFBO!=null )
|
|
476 |
for(int i=mNumChildren[0]-1; i>=0; i--)
|
|
501 | 477 |
{ |
502 |
if( --mData.numPointingNodes==0 ) |
|
503 |
{ |
|
504 |
mData.mFBO.markForDeletion(); |
|
505 |
android.util.Log.d("NODE", "deleting3 map key "+mData.key); |
|
506 |
|
|
507 |
mMapNodeID.remove(mData.key); |
|
508 |
} |
|
509 |
mData.mFBO = null; |
|
478 |
tmp = mChildren.remove(i); |
|
479 |
tmp.mParent = null; |
|
510 | 480 |
} |
481 |
|
|
482 |
mNumChildren[0] = 0; |
|
483 |
adjustIsomorphism(); |
|
511 | 484 |
} |
512 | 485 |
} |
513 | 486 |
|
Also available in: Unified diff
A Lot of fixes for the issues uncovered by Olimpic.
Still at least 1 known issue: sometimes, when we re-add a Surface, some garbage pops up on the screen for a brief split second. Visible in Olimpic.