Modularize gargantuan objects (#797)

This commit is contained in:
David Markowitz 2022-10-31 15:32:17 -07:00 committed by GitHub
parent 62213cd701
commit 971e0fb3b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,7 +34,6 @@ dpEntity::dpEntity(const LWOOBJID& objectID, NiPoint3 boxDimensions, bool isStat
m_CollisionGroup = COLLISION_GROUP_ALL; m_CollisionGroup = COLLISION_GROUP_ALL;
m_CollisionShape = new dpShapeBox(this, boxDimensions.x, boxDimensions.y, boxDimensions.z); 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) { 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_CollisionGroup = COLLISION_GROUP_ALL;
m_CollisionShape = new dpShapeBox(this, width, height, depth); m_CollisionShape = new dpShapeBox(this, width, height, depth);
if (width > 100.0f) m_IsGargantuan = true;
} }
dpEntity::dpEntity(const LWOOBJID& objectID, float radius, bool isStatic) { 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_CollisionGroup = COLLISION_GROUP_ALL;
m_CollisionShape = new dpShapeSphere(this, radius); m_CollisionShape = new dpShapeSphere(this, radius);
if (radius > 200.0f) m_IsGargantuan = true;
} }
dpEntity::~dpEntity() { dpEntity::~dpEntity() {
@ -146,5 +143,12 @@ void dpEntity::SetAngularVelocity(const NiPoint3& newAngularVelocity) {
void dpEntity::SetGrid(dpGrid* grid) { void dpEntity::SetGrid(dpGrid* grid) {
m_Grid = grid; m_Grid = grid;
if (m_CollisionShape->GetShapeType() == dpShapeType::Sphere && static_cast<dpShapeSphere*>(m_CollisionShape)->GetRadius() * 2.0f > static_cast<float>(m_Grid->CELL_SIZE)) {
m_IsGargantuan = true;
} else if (m_CollisionShape->GetShapeType() == dpShapeType::Box && static_cast<dpShapeBox*>(m_CollisionShape)->GetWidth() > static_cast<float>(m_Grid->CELL_SIZE)) {
m_IsGargantuan = true;
}
m_Grid->Add(this); m_Grid->Add(this);
} }