Collisions, Yet Again, Part 2.

This post is Part 2 of 3 about Metareal’s collision subsystem.

In Part 1, we described the basic, single-axis model of movement, pushing, and blocking. Here we’ll look at more complex movements and collisions, and some special cases.


Diagonal Moves

Objects in the Metareal World can move along diagonals. For collision testing, we do this by moving first in X, then Y, and then Z. This can lead to some ambiguities.

Collisions11

But in practice, most movement is done is smaller steps. This could affect “bullets”, but that doesn’t come up much in Metareal. More importantly, objects can’t escape enclosures such as rooms, regardless of the axis ordering.

Collisions12

Transporting Into A Bulkhead

As was mentioned in Star Trek, one of the failure modes for teleportation is materializing inside a bulkhead. Sometimes objects move instantaneously in Metareal. Some doors need to just slam shut, where by “slam” I mean “not slam but rather appear instantly.” But it might do so on top another object, maybe even you! In this case, we allow the object to move out of intersection, and once freed it cannot move back into intersection.

This behavior arises naturally from the process of checking leading edge movements. The leading edge of an object already intersecting an obstacle won’t freshly cross the obstacle face.

Collisions13

The Roundoff Problem

Problem: Due to arithmetic errors, an object that is just barely touching an obstacle sometimes slides right through it.

Consider the following move:

Collisions14

Object moves to the right, stops at the wall. So far, so good. But all these coordinates are floating point. Adding the difference between wall and object to the object’s center, and recomputing the extents introduced a tiny arithmetic error, it’s actually penetrating the wall jussssssst a leedle.

Collisions15

Next time it moves, it can proceed further to the right, satisfying the “ok to move out of collision” rule. But we want it to hit the wall and stop.

Solution: Add a “fudge factor” to the collision distance. The entire Metareal World is about 1200 units across; I’ve found that adding 0.001 to the collision distance brings all roundoff errors back into the positive, not-already-intersecting, realm.


And Part 3 will conclude this series, with a discussion of compound colliders. It’s all made of boxes.

Leave a Reply

Your email address will not be published. Required fields are marked *