diff --git a/Assets/Application.SHConfig b/Assets/Application.SHConfig index d0fa83df..6fdc7d87 100644 --- a/Assets/Application.SHConfig +++ b/Assets/Application.SHConfig @@ -1,4 +1,4 @@ Start in Fullscreen: false -Starting Scene ID: 97402985 +Starting Scene ID: 92914350 Window Size: {x: 1920, y: 1080} Window Title: SHADE Engine \ No newline at end of file diff --git a/Assets/Editor/Editor.SHConfig b/Assets/Editor/Editor.SHConfig index b492a983..9f915147 100644 --- a/Assets/Editor/Editor.SHConfig +++ b/Assets/Editor/Editor.SHConfig @@ -1,4 +1,4 @@ Start Maximized: true -Working Scene ID: 97402985 +Working Scene ID: 92914350 Window Size: {x: 1920, y: 1080} Style: 0 \ No newline at end of file diff --git a/Assets/Scenes/SS_Playground.shade b/Assets/Scenes/SS_Playground.shade index ffaca467..b3e540b5 100644 --- a/Assets/Scenes/SS_Playground.shade +++ b/Assets/Scenes/SS_Playground.shade @@ -21,7 +21,7 @@ NumberOfChildren: 0 Components: Transform Component: - Translate: {x: 0, y: 0, z: 0} + Translate: {x: 0.5, y: 0, z: 0} Rotate: {x: 0, y: 0, z: 0} Scale: {x: 1, y: 1, z: 1} IsActive: true @@ -31,7 +31,7 @@ - Is Trigger: false Collision Tag: 1 Type: Sphere - Radius: 2 + Radius: 3 Friction: 0.400000006 Bounciness: 0 Density: 1 diff --git a/SHADE_Engine/src/Physics/Collision/Broadphase/SHDynamicAABBTree.cpp b/SHADE_Engine/src/Physics/Collision/Broadphase/SHDynamicAABBTree.cpp index 7177e517..265a5c80 100644 --- a/SHADE_Engine/src/Physics/Collision/Broadphase/SHDynamicAABBTree.cpp +++ b/SHADE_Engine/src/Physics/Collision/Broadphase/SHDynamicAABBTree.cpp @@ -170,20 +170,16 @@ namespace SHADE insertLeaf(NEW_INDEX); } - void SHAABBTree::Update(SHCollisionShapeID id, const SHAABB& AABB) + void SHAABBTree::Update(SHCollisionShapeID id, const SHAABB& newAABB) { // Get node index const int32_t INDEX_TO_UPDATE = nodeMap[id]; Node& nodeToUpdate = nodes[INDEX_TO_UPDATE]; - // If new AABB has not moved enough, skip. - if (nodeToUpdate.AABB.Contains(AABB)) - return; - - removeLeaf(INDEX_TO_UPDATE); - - nodeToUpdate.AABB = AABB; + // Update the AABB directly + const SHAABB OLD_AABB = nodeToUpdate.AABB; + nodeToUpdate.AABB = newAABB; // Fatten the AABB const SHVec3 EXTENSION{ AABB_EXTENSION }; @@ -194,6 +190,13 @@ namespace SHADE nodeToUpdate.AABB.SetMin(newMin); nodeToUpdate.AABB.SetMax(newMax); + // If new AABB has not moved enough, skip. + // We only modify the position &/ size, but the AABB remains within this space. + if (OLD_AABB.Contains(nodeToUpdate.AABB)) + return; + + // Re-insert the node to find it's new neighbour + removeLeaf(INDEX_TO_UPDATE); insertLeaf(INDEX_TO_UPDATE); } diff --git a/SHADE_Engine/src/Physics/Collision/Shapes/SHBox.cpp b/SHADE_Engine/src/Physics/Collision/Shapes/SHBox.cpp index 8022e487..4a9d88bb 100644 --- a/SHADE_Engine/src/Physics/Collision/Shapes/SHBox.cpp +++ b/SHADE_Engine/src/Physics/Collision/Shapes/SHBox.cpp @@ -206,6 +206,10 @@ namespace SHADE // Recompute Relative radius relativeExtents = 2.0f * Extents / scale; + + // Hack: Indicate that the collider needs to update the broadphase proxy + if (collider) + collider->SetScale(collider->GetScale()); } void SHBox::SetRelativeExtents(const SHVec3& newRelativeExtents) noexcept @@ -214,6 +218,10 @@ namespace SHADE // Recompute world radius Extents = relativeExtents * scale * 0.5f; + + // Hack: Indicate that the collider needs to update the broadphase proxy + if (collider) + collider->SetScale(collider->GetScale()); } void SHBox::SetScale(const SHVec3& newScale) noexcept @@ -222,6 +230,10 @@ namespace SHADE // Recompute world radius Extents = relativeExtents * scale * 0.5f; + + // Hack: Indicate that the collider needs to update the broadphase proxy + if (collider) + collider->SetScale(collider->GetScale()); } /*-----------------------------------------------------------------------------------*/ diff --git a/SHADE_Engine/src/Physics/Collision/Shapes/SHSphere.cpp b/SHADE_Engine/src/Physics/Collision/Shapes/SHSphere.cpp index 5708bf91..3023ec68 100644 --- a/SHADE_Engine/src/Physics/Collision/Shapes/SHSphere.cpp +++ b/SHADE_Engine/src/Physics/Collision/Shapes/SHSphere.cpp @@ -167,6 +167,10 @@ namespace SHADE // Recompute Relative radius relativeRadius = 2.0f * Radius / scale; + + // Hack: Indicate that the collider needs to update the broadphase proxy + if (collider) + collider->SetScale(collider->GetScale()); } void SHSphere::SetRelativeRadius(float newRelativeRadius) noexcept @@ -175,6 +179,10 @@ namespace SHADE // Recompute world radius Radius = relativeRadius * scale * 0.5f; + + // Hack: Indicate that the collider needs to update the broadphase proxy + if (collider) + collider->SetScale(collider->GetScale()); } void SHSphere::SetScale(float maxScale) noexcept @@ -183,6 +191,10 @@ namespace SHADE // Recompute world radius Radius = relativeRadius * scale * 0.5f; + + // Hack: Indicate that the collider needs to update the broadphase proxy + if (collider) + collider->SetScale(collider->GetScale()); } /*-----------------------------------------------------------------------------------*/