summaryrefslogtreecommitdiff
path: root/src/3d/object.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-06 08:46:20 +0100
committerskal <pascal.massimino@gmail.com>2026-02-06 08:46:20 +0100
commit7d60a8a9ece368e365b5c857600004298cb89526 (patch)
treeaa394cb9823939c561b8fb09897f1e192a4059ad /src/3d/object.h
parent180b0961a2216279024b4d35229d105d95a61878 (diff)
fix: Correct mesh normal transformation and floor shadow rendering
Diffstat (limited to 'src/3d/object.h')
-rw-r--r--src/3d/object.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/3d/object.h b/src/3d/object.h
index a7ce0b8..3d4ff35 100644
--- a/src/3d/object.h
+++ b/src/3d/object.h
@@ -40,12 +40,14 @@ class Object3D {
bool is_static;
AssetId mesh_asset_id;
+ vec3 local_extent; // Half-extents for AABB (used by meshes for shadows)
void* user_data; // For tool-specific data, not for general use
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), velocity(0, 0, 0), mass(1.0f), restitution(0.5f),
- is_static(false), mesh_asset_id((AssetId)0), user_data(nullptr) {
+ is_static(false), mesh_asset_id((AssetId)0), local_extent(1, 1, 1),
+ user_data(nullptr) {
}
mat4 get_model_matrix() const {
@@ -61,6 +63,8 @@ class Object3D {
BoundingVolume get_local_bounds() const {
if (type == ObjectType::TORUS)
return {{-1.5f, -0.5f, -1.5f}, {1.5f, 0.5f, 1.5f}};
+ if (type == ObjectType::MESH)
+ return {-local_extent, local_extent};
// Simple defaults for unit primitives
return {{-1, -1, -1}, {1, 1, 1}};
}