The construction of 3D Game collision systems varies greatly from game type to game type. For example, sports and FPS games such as need for speed vehicles and hl2 require very precise collision computing and rigid body motion. A good solution is to adopt a mature physical engine. For a wow role-playing game, precise collision is not what it wants most. Because the use of physical engines will occupy too much CPU resources, considering the efficiency, such games generally adopt a simplified collision system.
The core of building the collision system is the construction of the physical world. The physical world does not care about rendering. Only the location and shape of the model in the world space are considered. I will briefly describe the collision detection process.
1. When loading a model (including a terrain) in a scene, extract the corresponding low-touch vertex data and use a specific data structure for management (which can be an octotree or BSP ). When the model is detached from the scenario, the corresponding low-mode data is also detached. It is best to process the data in the background thread.
2. for objects that require touch detection, first let the object detect the box with the low-mode collision, and then perform precise triangle detection through the box (there are many methods in this process)
3. Based on the collision detection results, change the method and speed of entity motion.
4. Simple blocking and collision detection are required for server monster pathfinding. The collision system needs to export a grayscale image based on the low-mode data. You can use the viewpoint method to find the indoor path.