summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Entity.cpp2
-rw-r--r--src/Entities/Entity.h3
-rw-r--r--src/Entities/Floater.cpp2
-rw-r--r--src/Entities/Pawn.cpp2
-rw-r--r--src/Entities/Player.cpp2
-rw-r--r--src/Entities/ProjectileEntity.cpp2
6 files changed, 8 insertions, 5 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index 0f1266445..431d5f54b 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -2353,7 +2353,7 @@ float cEntity::GetExplosionExposureRate(Vector3d a_ExplosionPosition, float a_Ex
return 0;
}
- cBoundingBox EntityBox(GetPosition(), m_Width / 2, m_Height);
+ auto EntityBox = GetBoundingBox();
cBoundingBox ExplosionBox(a_ExplosionPosition, a_ExlosionPower * 2.0);
cBoundingBox IntersectionBox(EntityBox);
diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h
index 2d9781edb..9cb0f970a 100644
--- a/src/Entities/Entity.h
+++ b/src/Entities/Entity.h
@@ -1,6 +1,7 @@
#pragma once
+#include "../BoundingBox.h"
#include "../Item.h"
#include "../OSSupport/AtomicUniquePtr.h"
@@ -239,6 +240,8 @@ public:
int GetChunkX(void) const { return FloorC(m_Position.x / cChunkDef::Width); }
int GetChunkZ(void) const { return FloorC(m_Position.z / cChunkDef::Width); }
+ cBoundingBox GetBoundingBox() const { return cBoundingBox(GetPosition(), GetWidth() / 2, GetHeight()); }
+
void SetHeadYaw (double a_HeadYaw);
void SetMass (double a_Mass);
void SetPosX (double a_PosX) { SetPosition({a_PosX, m_Position.y, m_Position.z}); }
diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp
index bd1e7a637..bb326f70b 100644
--- a/src/Entities/Floater.cpp
+++ b/src/Entities/Floater.cpp
@@ -31,7 +31,7 @@ public:
return false;
}
- cBoundingBox EntBox(a_Entity.GetPosition(), a_Entity.GetWidth() / 2, a_Entity.GetHeight());
+ auto EntBox = a_Entity.GetBoundingBox();
double LineCoeff;
eBlockFace Face;
diff --git a/src/Entities/Pawn.cpp b/src/Entities/Pawn.cpp
index 6a69cf6e5..b872cdfac 100644
--- a/src/Entities/Pawn.cpp
+++ b/src/Entities/Pawn.cpp
@@ -84,7 +84,7 @@ void cPawn::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// Spectators cannot push entities around
if ((!IsPlayer()) || (!static_cast<cPlayer *>(this)->IsGameModeSpectator()))
{
- m_World->ForEachEntityInBox(cBoundingBox(GetPosition(), GetWidth(), GetHeight()), [=](cEntity & a_Entity)
+ m_World->ForEachEntityInBox(GetBoundingBox(), [=](cEntity & a_Entity)
{
if (a_Entity.GetUniqueID() == GetUniqueID())
{
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 55139f65e..46a1606d0 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2780,7 +2780,7 @@ bool cPlayer::DoesPlacingBlocksIntersectEntity(const sSetBlockVector & a_Blocks)
{
return false;
}
- cBoundingBox EntBox(a_Entity.GetPosition(), a_Entity.GetWidth() / 2, a_Entity.GetHeight());
+ auto EntBox = a_Entity.GetBoundingBox();
for (auto BlockBox : PlacementBoxes)
{
// Put in a little bit of wiggle room
diff --git a/src/Entities/ProjectileEntity.cpp b/src/Entities/ProjectileEntity.cpp
index c38fa0180..fa0654ca5 100644
--- a/src/Entities/ProjectileEntity.cpp
+++ b/src/Entities/ProjectileEntity.cpp
@@ -147,7 +147,7 @@ public:
}
}
- cBoundingBox EntBox(a_Entity.GetPosition(), a_Entity.GetWidth() / 2, a_Entity.GetHeight());
+ auto EntBox = a_Entity.GetBoundingBox();
// Instead of colliding the bounding box with another bounding box in motion, we collide an enlarged bounding box with a hairline.
// The results should be good enough for our purposes