asafbibas / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

BatchNode does not clear batch geometries from "children" before clearing "batches" #465

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In the "doBatch" method, the batch geometries are not cleared from the 
"children" field before the "batches" field is cleared.

This causes batch geometries to build up after multiple calls to the "batch" 
method and meshes to linger after their geometries have been removed from the 
BatchNode.

This is because the "gatherGeometries" method relies on "batches" to determine 
which geometries in "children" are batch geometries.  Since "batches" is 
cleared but the batch geometries are not removed from "children", 
"gatherGeometries" no longer identifies these batch geometries as batch 
geometries.

Original issue reported on code.google.com by roja...@gmail.com on 12 Feb 2012 at 8:06

GoogleCodeExporter commented 8 years ago
The following does not behave as expected:

 1:  BatchNode batchNode = new BatchNode();
 2:  batchNode.attachChild( geom );
 3:  batchNode.batch();
 4:  geom.removeFromParent();

Expected:
geom's mesh no longer appears on the screen because "removeFromParent" re-calls 
"batch" on the batch node after removing itself.

Reality:
The mesh still appears on the screen because its batched version remains in 
"children".  

Commenting out line 3 results in the expected behavior.

Original comment by roja...@gmail.com on 12 Feb 2012 at 8:14

GoogleCodeExporter commented 8 years ago
This seems like a valid bug and it includes test code to show that it fails. 
Although it was submitted in February so it could have been fixed at this point.

Original comment by ShadowIs...@gmail.com on 1 Jun 2012 at 4:07

GoogleCodeExporter commented 8 years ago
This should not occur with actual stable version.

@Kirill if you feel it's not going fast enough feel free to step in.

Original comment by remy.bou...@gmail.com on 1 Jun 2012 at 6:26

GoogleCodeExporter commented 8 years ago
Actually re-reading this issue, and this is expected behavior...

No Add or remove operation from the batch node won't be applied until the 
batch() method is called again.

"Commenting out line 3 results in the expected behavior." 
Absolutely not...because the batch is not batched...and it's not what one would 
expect.

this however works fine: 
 1:  BatchNode batchNode = new BatchNode();
 2:  batchNode.attachChild( geom );
 3:  batchNode.batch();
 4:  geom.removeFromParent();
 5:  batchNode.batch();

Original comment by remy.bou...@gmail.com on 1 Jun 2012 at 5:23

GoogleCodeExporter commented 8 years ago
When I wrote this, calling "removeFromParent" would call batch automatically.  
Even if you called batch yourself afterwards, the removed geometry would still 
show up, but that was fixed a couple months ago.

Original comment by roja...@gmail.com on 1 Jun 2012 at 5:46

GoogleCodeExporter commented 8 years ago
oh ok makes sense.

I'm gonna update the javadoc though, i read it again and the fact that you have 
to batch again is not clearly mentioned.

Original comment by remy.bou...@gmail.com on 1 Jun 2012 at 6:56