0
\$\begingroup\$

I want to create simple collision response system (physical simulation is not required now). It is needed just that player can't go through walls.

I consider some variants: - Just create a set of primitive colliders (like AABB, OBB, Spheres) and check collisions in every frame (this approach is impemented now) - Create a BVH for the big level mesh and check collisions with small set of triangles. - Combine these two approaches and use BVH for determine which colliders I need to check.

But, probably, these variants are wrong. What algorithms and appoaches would you advice for this purpose?

\$\endgroup\$
  • \$\begingroup\$ What specifically is "wrong" about the approach you've described? It sounds like a rough outline of every physics engine I've seen. \$\endgroup\$ – DMGregory Dec 7 '18 at 12:03
1
\$\begingroup\$

In my experience, collisions that involve concave meshes sooner or later gets you in a mess.

If I were you, I would keep your current approach of tests that involve convex shapes: there is no ambiguity about inside/outside, and no nasty stuff like self intersecting meshes.

Just make it so that everything in your world has two representations: a visual model that can be as fancy, and as concave as you like.

The other representation for collisions, which is purely a collection of convex shapes, and only roughly follows the object's shape.

As an example: the visual model of an exquisite Edwardian table could be 4000 triangles. But it's physics shape is just 5 boxes.

The worst thing you could do is collide an arbitrary mesh against another arbitrary mesh. It's wasteful, and leads to horrible collision responses.

One more note: Convex dynamic objects against a static concave terrain mesh is often acceptable though. But if your terrain is a bunch of rooms that can adequately be described with boxes, I wouldn't even do that.

\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.