Collision with procedural mesh

Hi kobaska,

Firstly, great response from @Thaumaturge, a lot of good info there.

Not sure if you’ve come across this other post in your searches, if not it might be worth looking into.

I’m considering it for my project which has some similar aspects to your project!
While I’m not using procedurally generated geometry, I do have hexagons that need picking!
Here’s a little preview of it. (To note: I’m picking EVERY frame, and still getting 60+FPS even in it’s unoptimized state, except when showing the collisions :sweat_smile: )

Initially I was using the same approach to pick my objects (picking using visible geometry).
However that quickly became immensely inefficient.
Currently I’m using Blender for modelling, and using blend2bam to convert.
Now rather than GeomNode.getDefaultCollideMask() I’m using CollisionNode.getDefaultCollideMask() and it’s very smooth even with a large amount of models on screen at once! There’s probably a lot more that could be done to optimize it further also.

Some quick thoughts on optimizations that I might look into:

  • Using Cylinder collision primitives (this is pure speculation and I’ve not looked into how any of the collision checks work, but my intuition tells me that a Cylinder would be more efficient than checking multiple triangles).
    • Caveat: This would mean some parts of the Visible Geometry would be outside the Cylinder and thus will be an inaccurate pick operation.
  • Hierarchical collision tree
    • If your scene is static this might be a good option: Magical collision scene optimizer
    • If not, then dividing your scene up dynamically somehow and checking only for collisions in relevant spaces.

Your idea about having multiple planes and testing that was is an interesting one, and I think has a fair amount of potential! Assuming the planes are at discrete steps (and the hex-grid is the same on each plane), then this might actually be the most efficient approach if all you’re looking to pick are the hexagons.
For this I’d recommend:

  • Taking a peek at the Panda3D Chessboard sample. (specifically, the PointAtZ function)
  • From there, check out the following website (specifically, Pixel to Hex (linked)) Hexagonal Grids (Absolutely amazing resource this one!)

Best of luck going forward!
Curious to know which approach you take and how it works out for you. :slight_smile:

2 Likes