Revision 7691a39f
Added by Leszek Koltunski about 7 years ago
src/main/java/org/distorted/library/DistortedNode.java | ||
---|---|---|
52 | 52 |
{ |
53 | 53 |
long ID; |
54 | 54 |
int numPointingNodes; |
55 |
int numRendered;
|
|
55 |
int numRender; |
|
56 | 56 |
ArrayList<Long> key; |
57 | 57 |
DistortedFramebuffer mFBO; |
58 | 58 |
|
... | ... | |
61 | 61 |
ID = id; |
62 | 62 |
key = k; |
63 | 63 |
numPointingNodes= 1; |
64 |
numRendered = 0;
|
|
64 |
numRender =-1;
|
|
65 | 65 |
mFBO = null; |
66 | 66 |
} |
67 | 67 |
} |
... | ... | |
81 | 81 |
ArrayList<Long> ret = new ArrayList<>(); |
82 | 82 |
|
83 | 83 |
ret.add( mSurface.getID() ); |
84 |
|
|
85 |
if( mNumChildren[0]==0 ) |
|
86 |
{ |
|
87 |
ret.add(-mEffects.getID()); |
|
88 |
} |
|
89 |
|
|
84 | 90 |
DistortedNode node; |
85 | 91 |
|
86 | 92 |
for(int i=0; i<mNumChildren[0]; i++) |
... | ... | |
92 | 98 |
return ret; |
93 | 99 |
} |
94 | 100 |
|
95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
96 |
// this will be called on startup and every time OpenGL context has been lost |
|
97 |
|
|
98 |
static void reset() |
|
99 |
{ |
|
100 |
NodeData tmp; |
|
101 |
|
|
102 |
for(ArrayList<Long> key: mMapNodeID.keySet()) |
|
103 |
{ |
|
104 |
tmp = mMapNodeID.get(key); |
|
105 |
|
|
106 |
if( tmp.mFBO != null ) tmp.numRendered = 0; |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 | 101 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
111 | 102 |
// Debug - print all the Node IDs |
112 | 103 |
|
... | ... | |
208 | 199 |
} |
209 | 200 |
|
210 | 201 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
202 |
// return the total number of render calls issued |
|
211 | 203 |
|
212 |
void drawRecursive(long currTime, DistortedOutputSurface surface)
|
|
204 |
int drawRecursive(int render, long currTime, DistortedOutputSurface surface)
|
|
213 | 205 |
{ |
206 |
int ret = 0; |
|
214 | 207 |
float halfX = mSurface.getWidth()/2.0f; |
215 | 208 |
float halfY = mSurface.getHeight()/2.0f; |
216 | 209 |
|
... | ... | |
220 | 213 |
} |
221 | 214 |
else |
222 | 215 |
{ |
223 |
if( mData.numRendered==0 )
|
|
216 |
if( mData.numRender!=render )
|
|
224 | 217 |
{ |
218 |
mData.numRender = render; |
|
225 | 219 |
mData.mFBO.setAsOutput(); |
226 | 220 |
|
227 | 221 |
GLES30.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); |
228 | 222 |
GLES30.glClear( GLES30.GL_DEPTH_BUFFER_BIT | GLES30.GL_COLOR_BUFFER_BIT); |
229 | 223 |
|
230 | 224 |
if( mSurface.setAsInput() ) |
231 |
DistortedEffects.drawNoEffectsPriv(halfX, halfY, mMesh, mData.mFBO ); |
|
225 |
{ |
|
226 |
ret++; |
|
227 |
DistortedEffects.drawNoEffectsPriv(halfX, halfY, mMesh, mData.mFBO); |
|
228 |
} |
|
232 | 229 |
|
233 | 230 |
for(int i=0; i<mNumChildren[0]; i++) |
234 | 231 |
{ |
235 |
mChildren.get(i).drawRecursive(currTime, mData.mFBO);
|
|
232 |
ret += mChildren.get(i).drawRecursive(render, currTime, mData.mFBO);
|
|
236 | 233 |
} |
237 | 234 |
} |
238 | 235 |
|
239 |
mData.numRendered++; |
|
240 |
mData.numRendered %= mData.numPointingNodes; |
|
241 | 236 |
mData.mFBO.setAsInput(); |
242 | 237 |
} |
243 | 238 |
|
244 | 239 |
mEffects.drawPriv(halfX, halfY, mMesh, surface, currTime); |
240 |
|
|
241 |
return ret+1; |
|
245 | 242 |
} |
246 | 243 |
|
247 | 244 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
265 | 262 |
|
266 | 263 |
ArrayList<Long> list = new ArrayList<>(); |
267 | 264 |
list.add(mSurface.getID()); |
265 |
list.add(-mEffects.getID()); |
|
268 | 266 |
|
269 | 267 |
mData = mMapNodeID.get(list); |
270 | 268 |
|
Also available in: Unified diff
- workaround for the issue with flashing in StarWars
- return number of objects rendered from OutputSurface.render() and use this in Olympic
- rework tree isomorphism so that it now works even if we don't render the whole tree (and also we don't have to reset() the Tree anymore!)
- current a buf with tree isomorphism: Leaf Nodes have the same NodeData only if they agree in Surface AND Effects!