C++ 3D Game Tutorial Series: 23 | Terrain Collision Detection | Early Access | Source Code on GitHub
The twenty-third tutorial of C++ 3D Game Tutorial Series is finally available in early access on GitHub!
Monday 5th October 2026

C++ 3D Game Tutorial Series: 23 | Terrain Collision Detection | Source Code on GitHub


 

 

The source code of the 23rd tutorial of the C++ 3D Game Tutorial Series is now available in early access on GitHub!

This tutorial shifts the DX3D engine toward a more modular, physically-aware game loop by centralizing movement and collision handling in a dedicated physics pass.

  • Physics System: Added WorldPhysicsSystem as the central hub for physical interactions. It runs during onInternalUpdate(), gathers CharacterControllerComponent and TerrainComponent instances, and resolves movement and collisions in one predictable pass.

  • Character Controller: Introduced CharacterControllerComponent to store movement direction, travel distance, and vertical height. The Player records input and delegates movement through move(), leaving spatial resolution to the physics system.

  • Terrain Collision: Added getHeightFromWorldPos() for bilinear heightmap sampling and findTerrainHitPosition() for terrain collision detection. This allows the physics system to prevent characters from clipping through or floating above terrain.

  • Supporting Infrastructure: TextureResource now retains raw pixel data and provides getPixelFromTexCoord(). MainGame.cpp was also updated with a 2×2 terrain layout.

You can find the full source code on GitHub here: GitHub Link

I hope you enjoy the tutorial, and thank you for all your support!