Disable culling checks

Hey guys.

I have been implementing my own sky dome. But there is something I do not understand - how to disable culling.

I was expecting [java]Geometry.setCullHint( Spatial.CullHint.Never );[/java] to completely disable culling, but it seems to make no change to culling. I had to use [java]Geometry.setModelBound( new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO) )[/java] - which obviously does not disable culling, but has the same effect. I could see that this method was used in the SkyFactory aswell, see here (line 106 - 109 in SkyFactory.java):

[java]
Geometry sky = new Geometry(“Sky”, sphereMesh); // L106
sky.setQueueBucket(Bucket.Sky); // L107
sky.setCullHint(Spatial.CullHint.Never); // L108
sky.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO)); // L109
[/java]

There really should be no need to make the ModelBound infinite, L108 and L109 should have the same effect, but L109 smells bad. Am I wrong?

I am running jME 3.0 stable.

The thing is, if you added your spatial to the root node then you would also need to disable culling on the root node. This isn’t done automatically (in fact, for the general case it can’t be, really).

Edit: essentially, every parent of your sky would need to have culling disabled. Making an infinite bounding sphere also does this (because it was fixed) because the parents will then automatically get infinite bounding spheres.

2 Likes

Okay, I understand that. But is there any point in being able to set CullHint.Never on a geometry then, isn’t it always overwritten by the parent node(s)? Isn’t that what CullHint.Inherit is for? Maybe I am misunderstanding this, but I find it a bit counter-intuitive.

And does that not also mean that the root node will always need to have CullHint set to Never - if just one geometry in the scene has CullHint.Never? (Including all nodes between the root and the Geometry, ofc)

Edit: But I see your point, a geometry will never be checked for culling, if it’s parent was already culled. I did not realize a node has bounds that can be checked for culling.

Cull hint inheritance works “down” the scene graph (away from the root node) and is optional. Bounds inheritance works “up” the scene graph (toward the root node) and is mandatory. I don’t see how it could work any other way.