From f6f3c13fcd287774a458730722854baab8a17366 Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 5 Feb 2026 16:40:27 +0100 Subject: feat(physics): Implement SDF-based physics engine and BVH Completed Task #49. - Implemented CPU-side SDF library (sphere, box, torus, plane). - Implemented Dynamic BVH construction (rebuilt every frame). - Implemented PhysicsSystem with semi-implicit Euler integration and collision resolution. - Added visual debugging for BVH nodes. - Created test_3d_physics interactive test and test_physics unit tests. - Updated project docs and triaged new tasks. --- src/3d/physics.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/3d/physics.h (limited to 'src/3d/physics.h') diff --git a/src/3d/physics.h b/src/3d/physics.h new file mode 100644 index 0000000..a014acd --- /dev/null +++ b/src/3d/physics.h @@ -0,0 +1,18 @@ +// This file is part of the 64k demo project. +// It implements a lightweight SDF-based physics engine. + +#pragma once + +#include "3d/scene.h" +#include "util/mini_math.h" + +class PhysicsSystem { + public: + vec3 gravity = {0.0f, -9.81f, 0.0f}; + + void update(Scene& scene, float dt); + + private: + void resolve_collision(Object3D& a, Object3D& b); + float sample_sdf(const Object3D& obj, vec3 world_p); +}; -- cgit v1.2.3