diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-08 07:38:28 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-08 07:38:28 +0100 |
| commit | b8e6929cafa41681f0b27ac104c9cf1d4e510837 (patch) | |
| tree | 4a3e9fe6fec6e550506163d57837f075511702a7 /src/3d/physics.cc | |
| parent | d74c6dae8614d49c6db958291312c772bf8492c2 (diff) | |
feat(3d): Fix ObjectType::PLANE scaling and consolidate ObjectType mapping
- Implemented correct scaling for planes in both CPU (physics) and GPU (shaders) using the normal-axis scale factor.
- Consolidated ObjectType to type_id mapping in Renderer3D to ensure consistency and support for CUBE.
- Fixed overestimation of distance for non-uniformly scaled ground planes, which caused missing shadows.
- Updated documentation and marked Task A.2 as completed.
Diffstat (limited to 'src/3d/physics.cc')
| -rw-r--r-- | src/3d/physics.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/3d/physics.cc b/src/3d/physics.cc index 351dd06..229eb40 100644 --- a/src/3d/physics.cc +++ b/src/3d/physics.cc @@ -54,7 +54,11 @@ float PhysicsSystem::sample_sdf(const Object3D& obj, vec3 world_p) { float sx = vec3(model.m[0], model.m[1], model.m[2]).len(); float sy = vec3(model.m[4], model.m[5], model.m[6]).len(); float sz = vec3(model.m[8], model.m[9], model.m[10]).len(); + float s = std::min(sx, std::min(sy, sz)); + if (obj.type == ObjectType::PLANE) { + s = sy; // For plane with local normal (0,1,0), scale is sy + } return d * s; } |
