Motivation

Collision detection is an important module. For a game with multiple movable characters and complex geometry, collision detection will consume more time. In this project, the author proposes a novel SDF-based approach that might be able to reduce redundant collision detection within one frame.

Basic Structure

First, we assume you have already known what SDF is. We need to generate a coarse SDF for 3D scene. Before every collision detection, we will query the SDF voxel texture. The sampled value is the minimal distance and if the minimal distance is more than a fixed threshold value, it means that current collider is still far away from any other colliders. We will skip collision detection.

The basic structure of this optimization is rather straightforward. The bound of this program, as we have implemented the whole logics, is not the core logic of this optimization, but these three parts

Store SDF

In this program, I also adopted different SDF storage strategies. sdf_naive sdf_threshold sdf_interval sdf_layered

Generate SDF

Update SDF