Batching & BoundingVolume

Hi folks, I was having an issue (which I think is now resolved) where my batched objects would vanish when the camera got ‘too close’ to the objects. Poking around I discovered that BatchNode implements n.setModelBound(BoundingVolume). So…now when I create my batch I’m calling this method with:



n.setModelBound(new BoundingBox(Vector3f.ZERO,50f,50f,25f)).



(I’m not seeing this really being defined in the javadoc, but I’m guessing the BoundingBox(CenterPoint,XBounds,YBounds,ZBounds), is the correct interpretation of constructor.



Anyways I guess my real question is…how does a newly created batch determine its bounding volume, and is typical that manually setting the bounding volume is needed? (note: the Geometries that are batched are imported from blender, and they are separate ‘objects’, with shared instanced meshes).



thanx

1 Like

You shouldn’t need to do that.

Bounding volume is computed during the next update if changes has been made and refresh flags correctly set.



There might be an issue regarding this on the batch Node.

hmm, the objects loaded from the blender are fact all ‘static’ maybe this is a bug in the importer, or batchNode bounding calculation logic. Anyways I guess for now I will just use my workaround.

It seems like a bug in BatchNode. When the batch is first updated, it is OK since the bound refresh flag is set. When the batch is later changed, the vertices of the mesh are changed but the refresh flag for bound is not set, thus the old bound is used which is invalid.

ok, I’ll fix that when I get back.

Hello @danomano

could you give me a test case because can’t find a situation where this happen.

@nehon: Try creating a batch from a single box, then on the next frame, add an additional box that is located far away. When you try to look at the box that’s far away, it will disappear unless the original box is also in view.

ok thanks

Ok I didn’t achieve to have the exact same issue, but I displayed the Bounding box and something was definitely wrong.

It shoud be fixed now.

@danomano could you please check it with your code?

HI guys, I just got some time to try and repo the issue, and still haven’t have been able to repro outside of my game.



I’m still investigating, but when I load the blender file into a clean main, which only setups the batches, I’m not seeing the issue.

I’ve been able to narrow it down to essentialy 2 lines of code.



node.attachChild(spatial);

root.attachChild(node);



Where node is essentialy a new parent node that gets created during my loading process, and is then later manipulated.

The spacial being one of the objects in the batch (acquired via: root.descendantMatches(name))

The parent node (aka the newly created node from above is then added directly into the BatchNode)

This is repeated for all similar spatials that are sharing the geometry/mesh from blender, once complete the .batch() routine called…



regardless I realize this next to nothing to go on, I will try and come up with a cleaner example, that can be ‘spliced’

out to a standalone ‘main’…knowing my luck I will probably discover something else is going on as well)



Cheers

Dano