summaryrefslogtreecommitdiff
path: root/src/3d/physics.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-08 07:38:28 +0100
committerskal <pascal.massimino@gmail.com>2026-02-08 07:38:28 +0100
commitb8e6929cafa41681f0b27ac104c9cf1d4e510837 (patch)
tree4a3e9fe6fec6e550506163d57837f075511702a7 /src/3d/physics.cc
parentd74c6dae8614d49c6db958291312c772bf8492c2 (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.cc4
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;
}