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/object.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/3d/object.h') diff --git a/src/3d/object.h b/src/3d/object.h index 2099a5c..6d21393 100644 --- a/src/3d/object.h +++ b/src/3d/object.h @@ -31,9 +31,16 @@ class Object3D { // Material parameters could go here (color, roughness, etc.) vec4 color; + // Physics fields + vec3 velocity; + float mass; + float restitution; + bool is_static; + Object3D(ObjectType t = ObjectType::CUBE) : position(0, 0, 0), rotation(0, 0, 0, 1), scale(1, 1, 1), type(t), - color(1, 1, 1, 1) { + color(1, 1, 1, 1), velocity(0, 0, 0), mass(1.0f), restitution(0.5f), + is_static(false) { } mat4 get_model_matrix() const { @@ -47,6 +54,8 @@ class Object3D { // Returns the local-space AABB of the primitive (before transform) // Used to generate the proxy geometry for rasterization. BoundingVolume get_local_bounds() const { + if (type == ObjectType::TORUS) + return {{-1.5f, -0.5f, -1.5f}, {1.5f, 0.5f, 1.5f}}; // Simple defaults for unit primitives return {{-1, -1, -1}, {1, 1, 1}}; } -- cgit v1.2.3