Geometry.checkCulling() has side-effect on camera?!

I’m trying to determine (for reasons of my application needs) whether some geometries (attached to the rootNode) are in the FoV of the default camera. Per the docs, I’m calling Geometry.checkCulling() in my simpleRender().

  1. I believe the JavaDocs description is wrong. It says the method “checks the spatial … to see if it should be culled”. i.e. if the spatial is outside the frustum, then it should be culled, meaning the method should then return true. However, the method does the opposite and returns TRUE if the spatial IS VISIBLE (i.e. should NOT be culled).

  2. The test is acting weird and I just realized that the jME behavior seems to be that once checkCulling() returns True (i.e. geometry is visible), then THEREAFTER, calling checkCulling on a DIFFERENT geometry, that even if not visible, the method forever returns true – through the duration of that render cycle. Is this a bug, and if not, what’s the correct way to check which of my geometries are in the FoV?

Thanks in advance!

Mhh the doc says explicitly “@return true if inside or intersecting camera frustum”.
The method is maybe poorly named but the doc is accurate.

For your second point, yes this process is stateful for the camera ,and is not meant to be called outside of the update flow. Checking culling changes planes states (a bit mask) on the camera and if they are not properly reset subsequent calls are wrong.
See how it’s done here

the plane state is saved and restored before any call to checkCull.

Ahh, agreed, but maybe fix the method description then … to “checkCulling checks the spatial with the camera to see if it is visible within the camera frustrum”? After all the description is more prominent in the IDE’s pop-up :grinning:

Thanks for the solution … noted that the ‘warning’ about using is in the docs, but I couldn’t find a better/public API for performing this check. Mentioning what you just wrote, “this process is stateful for the camera”, in the JavaDocs will be very helpful to future developers!

I found a workaround that if I embedded each geometry within its own node, then the multiple checks work.


Question: why do you need this information?

I ask because a lot of times there are better ways. A lot of other times, people don’t really want “in the frustum” and want something else.