From 36612f9ce953d80758f92595e101edd0023d1d44 Mon Sep 17 00:00:00 2001 From: ecker Date: Fri, 5 Sep 2025 21:25:59 -0500 Subject: [PATCH] fixed AABBs calculated from the graph system being wrong because for whatever reason i was transforming the bounds to world space, and this never mattered when using RP3D because it was always fed local extents...... --- bin/data/entities/prop.json | 1 + bin/data/scenes/sourceengine/sourceengine.json | 4 ++-- engine/src/engine/graph/graph.cpp | 8 ++++---- engine/src/utils/math/physics/impl.cpp | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bin/data/entities/prop.json b/bin/data/entities/prop.json index b1987d11..c6f629f1 100644 --- a/bin/data/entities/prop.json +++ b/bin/data/entities/prop.json @@ -6,6 +6,7 @@ "metadata": { "holdable": true, "physics": { + "mass": 0, "type": "bounding box" } } diff --git a/bin/data/scenes/sourceengine/sourceengine.json b/bin/data/scenes/sourceengine/sourceengine.json index feac6dec..95a20fe6 100644 --- a/bin/data/scenes/sourceengine/sourceengine.json +++ b/bin/data/scenes/sourceengine/sourceengine.json @@ -1,9 +1,9 @@ { // "import": "./rp_downtown_v2.json" - "import": "./ss2_medsci1.json" +// "import": "./ss2_medsci1.json" // "import": "./test_grid.json" // "import": "./sh2_mcdonalds.json" // "import": "./animal_crossing.json" -// "import": "./mds_mcdonalds.json" + "import": "./mds_mcdonalds.json" // "import": "./gm_construct.json" } \ No newline at end of file diff --git a/engine/src/engine/graph/graph.cpp b/engine/src/engine/graph/graph.cpp index 1a128d3a..f64b41d3 100644 --- a/engine/src/engine/graph/graph.cpp +++ b/engine/src/engine/graph/graph.cpp @@ -1333,7 +1333,7 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent ) auto& mesh = storage.meshes.map[graph.meshes[node.mesh]]; auto& primitives = storage.primitives.map[graph.primitives[node.mesh]]; - pod::Instance::Bounds bounds; + pod::Instance::Bounds bounds = {}; // setup instances for ( auto i = 0; i < primitives.size(); ++i ) { auto& primitive = primitives[i]; @@ -1373,8 +1373,8 @@ void uf::graph::process( pod::Graph& graph, int32_t index, uf::Object& parent ) uf::stl::string type = phyziks["type"].as(); if ( type != "mesh" ) { - auto min = uf::matrix::multiply( model, bounds.min, 1.0f ); - auto max = uf::matrix::multiply( model, bounds.max, 1.0f ); + auto min = bounds.min; // uf::matrix::multiply( model, bounds.min, 1.0f ); + auto max = bounds.max; // uf::matrix::multiply( model, bounds.max, 1.0f ); pod::Vector3f center = (max + min) * 0.5f; pod::Vector3f corner = uf::vector::abs(max - min) * 0.5f; @@ -1614,7 +1614,7 @@ void uf::graph::reload( pod::Graph& graph, pod::Node& node ) { ext::json::Value tag = ext::json::find( node.name, graphMetadataJson["tags"] ); - pod::Vector3f controllerPosition; + pod::Vector3f controllerPosition = {}; auto& controller = scene.getController(); if ( controller.getName() != "Scene" ) { auto& controllerTransform = controller.getComponent>(); diff --git a/engine/src/utils/math/physics/impl.cpp b/engine/src/utils/math/physics/impl.cpp index ebcb1942..c0fa88de 100644 --- a/engine/src/utils/math/physics/impl.cpp +++ b/engine/src/utils/math/physics/impl.cpp @@ -39,7 +39,7 @@ namespace { .displacementThreshold = 0.25f, .overlapThreshold = 2.0f, .dirtyRatioThreshold = 0.3f, - .maxFramesBeforeRebuild = 600, + .maxFramesBeforeRebuild = 60, }; } @@ -113,7 +113,7 @@ void uf::physics::impl::terminate( pod::World& world ) { // Implementation void uf::physics::impl::substep( pod::World& world, float dt, int32_t substeps ) { float h = dt / substeps; - for ( auto i=0; i < substeps; ++i) { + for ( auto i = 0; i < substeps; ++i ) { uf::physics::impl::step( world, h ); } }