diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-05 16:40:27 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-05 16:40:27 +0100 |
| commit | f6f3c13fcd287774a458730722854baab8a17366 (patch) | |
| tree | 44420eecdd2e2dd84d68be12cb12641064eb1c5a /src/3d/object.h | |
| parent | 93a65b43094641b4c188b4fc260b8ed44c883728 (diff) | |
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.
Diffstat (limited to 'src/3d/object.h')
| -rw-r--r-- | src/3d/object.h | 11 |
1 files changed, 10 insertions, 1 deletions
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}}; } |
