Cuboid as Collision Solid

Hello

I started to read about collision in the manual. It doesn’t seem to be to hard. But when I was reading about the solids. My first reaction was: Why are there no cuboids?

The manual states:

Well, I’m pretty sure this will be right, but I don’t get it, a sphere has more polygons than a cuboid, and I think, for many purposes, a cuboid would better fit to an object.

A house? A human? (A sphere around a human has huge “overhead”), smaller things like for example a trash can, a street light?

I’m sure there will be a reason for this, and that i’m not the first one that has this idea.

But what is that reason?

Thanks
Mathias

There are cuboids. Maybe you missed them: http://www.panda3d.org/reference/devel/python/classpanda3d.core.CollisionBox.php

Because a collision sphere (or any other collision “primitive”) is not made up from polygons.

Collision system usually work like this: for each combination of collision solid types (e. g. “sphere vs. box”, “sphere vs. tube”, “sphere vs. triangle mesh” or “plane vs. tube”) there is an algorithm handling this particular combination.

The most simple one is “sphere vs. sphere”: just get the two centers, calculate the distance, and subtract the two radii. The most complex combination is “triangle mesh vs. triangle mesh”. Without any precalculated optimization you would have to loop over all triangle pairs and check if the triangles intersect. You are invited to think about how YOU would implement a simple algorithm, for example “box vs. sphere”.

This is why you should collision PRIMITIVES wherever possible, and only resort to meshes (convex or concave) when needed.

Aha indeed!

I use the manual, not the reference (the reference is harder to understand than the manual in my opinion.)

Thanks for the explanation!