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/physics.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/physics.h')
| -rw-r--r-- | src/3d/physics.h | 18 |
1 files changed, 18 insertions, 0 deletions
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); +}; |
