From 971e0fb3b63a36854d6cd395c0dfe0eb21b1a21d Mon Sep 17 00:00:00 2001 From: David Markowitz <39972741+EmosewaMC@users.noreply.github.com> Date: Mon, 31 Oct 2022 15:32:17 -0700 Subject: [PATCH] Modularize gargantuan objects (#797) --- dPhysics/dpEntity.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/dPhysics/dpEntity.cpp b/dPhysics/dpEntity.cpp index 42c195f2..c7ed56f8 100644 --- a/dPhysics/dpEntity.cpp +++ b/dPhysics/dpEntity.cpp @@ -34,7 +34,6 @@ dpEntity::dpEntity(const LWOOBJID& objectID, NiPoint3 boxDimensions, bool isStat m_CollisionGroup = COLLISION_GROUP_ALL; m_CollisionShape = new dpShapeBox(this, boxDimensions.x, boxDimensions.y, boxDimensions.z); - if (boxDimensions.x > 100.0f) m_IsGargantuan = true; } dpEntity::dpEntity(const LWOOBJID& objectID, float width, float height, float depth, bool isStatic) { @@ -45,7 +44,6 @@ dpEntity::dpEntity(const LWOOBJID& objectID, float width, float height, float de m_CollisionGroup = COLLISION_GROUP_ALL; m_CollisionShape = new dpShapeBox(this, width, height, depth); - if (width > 100.0f) m_IsGargantuan = true; } dpEntity::dpEntity(const LWOOBJID& objectID, float radius, bool isStatic) { @@ -56,7 +54,6 @@ dpEntity::dpEntity(const LWOOBJID& objectID, float radius, bool isStatic) { m_CollisionGroup = COLLISION_GROUP_ALL; m_CollisionShape = new dpShapeSphere(this, radius); - if (radius > 200.0f) m_IsGargantuan = true; } dpEntity::~dpEntity() { @@ -146,5 +143,12 @@ void dpEntity::SetAngularVelocity(const NiPoint3& newAngularVelocity) { void dpEntity::SetGrid(dpGrid* grid) { m_Grid = grid; + + if (m_CollisionShape->GetShapeType() == dpShapeType::Sphere && static_cast(m_CollisionShape)->GetRadius() * 2.0f > static_cast(m_Grid->CELL_SIZE)) { + m_IsGargantuan = true; + } else if (m_CollisionShape->GetShapeType() == dpShapeType::Box && static_cast(m_CollisionShape)->GetWidth() > static_cast(m_Grid->CELL_SIZE)) { + m_IsGargantuan = true; + } + m_Grid->Add(this); }