sinisterchipmunk/jax — Issue #48: Unable to reliably pick any object not explicitly added to World
Author: sinisterchipmunk
Created: 2011-12-17 04:34:12+00:00
State: open
Labels: bug

I've marked this as a bug, since it seems to exhibit unintuitive behavior, though a bit of thought might reveal that it is in fact the expected behavior.

I've set up a scene graph, such that only root objects are added to the world. This is nice because it allows each model to determine how best to render its children, if at all.

Unfortunately, this approach breaks `Jax.World#pick` and friends. `Jax.World` keeps an internal array of objects, and iterates through this array when rendering. When picking, the pick index is an index in this array. Because of this design, the model-based scene graph approach breaks down, because any model rendered by one of the root models must inherit the root model's picking index. Thus, any object picked can only be identified as the root model itself.

So, if you set up a BSP or an Octree as a model, add it to the world and try to pick an object within it, you'll only be able to actually pick the octree itself -- not any of the objects within it.

To clarify, this is the current behavior in Jax, but it is not the desired behavior. Jax should be able to pick any object at any time, regardless of how it is rendered. I have a few ideas regarding how to implement this, and am looking into it.