summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/Entity.cpp32
-rw-r--r--src/entities/Entity.h4
-rw-r--r--src/entities/Physical.cpp8
3 files changed, 26 insertions, 18 deletions
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index 208e6deb..9d5bf73c 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -191,7 +191,7 @@ CEntity::GetBoundRect(void)
{
CRect rect;
CVector v;
- CColModel *col = CModelInfo::GetModelInfo(m_modelIndex)->GetColModel();
+ CColModel *col = CModelInfo::GetColModel(m_modelIndex);
rect.ContainPoint(GetMatrix() * col->boundingBox.min);
rect.ContainPoint(GetMatrix() * col->boundingBox.max);
@@ -210,21 +210,27 @@ CEntity::GetBoundRect(void)
CVector
CEntity::GetBoundCentre(void)
{
- CVector v;
- GetBoundCentre(v);
- return v;
+ return GetMatrix() * CModelInfo::GetColModel(m_modelIndex)->boundingSphere.center;
}
+#ifdef GTA_PS2
+void
+CEntity::GetBoundCentre(CVuVector &out)
+{
+ TransformPoint(out, GetMatrix(), CModelInfo::GetColModel(m_modelIndex)->boundingSphere.center);
+}
+#else
void
CEntity::GetBoundCentre(CVector &out)
{
- out = GetMatrix() * CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingSphere.center;
+ out = GetMatrix() * CModelInfo::GetColModel(m_modelIndex)->boundingSphere.center;
}
+#endif
float
CEntity::GetBoundRadius(void)
{
- return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingSphere.radius;
+ return CModelInfo::GetColModel(m_modelIndex)->boundingSphere.radius;
}
void
@@ -379,10 +385,13 @@ CEntity::Render(void)
}
}
+
bool
-CEntity::GetIsTouching(CVector const &center, float radius)
+CEntity::GetIsTouching(CVUVECTOR const &center, float radius)
{
- return sq(GetBoundRadius()+radius) > (GetBoundCentre()-center).MagnitudeSqr();
+ CVUVECTOR boundCenter;
+ GetBoundCentre(boundCenter);
+ return sq(GetBoundRadius()+radius) > (boundCenter-center).MagnitudeSqr();
}
bool
@@ -400,8 +409,7 @@ CEntity::IsVisibleComplex(void)
bool
CEntity::GetIsOnScreen(void)
{
- return TheCamera.IsSphereVisible(GetBoundCentre(), GetBoundRadius(),
- &TheCamera.GetCameraMatrix());
+ return TheCamera.IsSphereVisible(GetBoundCentre(), GetBoundRadius());
}
bool
@@ -417,7 +425,7 @@ CEntity::GetIsOnScreenComplex(void)
return true;
CRect rect = GetBoundRect();
- CColModel *colmodel = CModelInfo::GetModelInfo(m_modelIndex)->GetColModel();
+ CColModel *colmodel = CModelInfo::GetColModel(m_modelIndex);
float z = GetPosition().z;
float minz = z + colmodel->boundingBox.min.z;
float maxz = z + colmodel->boundingBox.max.z;
@@ -572,7 +580,7 @@ CEntity::Remove(void)
float
CEntity::GetDistanceFromCentreOfMassToBaseOfModel(void)
{
- return -CModelInfo::GetModelInfo(m_modelIndex)->GetColModel()->boundingBox.min.z;
+ return -CModelInfo::GetColModel(m_modelIndex)->boundingBox.min.z;
}
void
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index 7ee638d7..6174b61d 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -141,11 +141,11 @@ public:
return (RpClump*)m_rwObject;
}
- void GetBoundCentre(CVector &out);
+ void GetBoundCentre(CVUVECTOR &out);
CVector GetBoundCentre(void);
float GetBoundRadius(void);
float GetDistanceFromCentreOfMassToBaseOfModel(void);
- bool GetIsTouching(CVector const &center, float r);
+ bool GetIsTouching(CVUVECTOR const &center, float r);
bool GetIsOnScreen(void);
bool GetIsOnScreenComplex(void);
bool IsVisible(void);
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index a7e8beec..182ff46b 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -216,7 +216,7 @@ CPhysical::RemoveAndAdd(void)
CRect
CPhysical::GetBoundRect(void)
{
- CVector center;
+ CVUVECTOR center;
float radius;
GetBoundCentre(center);
radius = GetBoundRadius();
@@ -1086,7 +1086,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CPhysical *A, *B;
CObject *Bobj;
bool canshift;
- CVector center;
+ CVUVECTOR center;
float radius;
int numCollisions;
@@ -1244,7 +1244,7 @@ CPhysical::ProcessCollisionSectorList_SimpleCar(CPtrList *lists)
{
static CColPoint aColPoints[MAX_COLLISION_POINTS];
float radius;
- CVector center;
+ CVUVECTOR center;
int listtype;
CPhysical *A, *B;
int numCollisions;
@@ -1406,7 +1406,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
{
static CColPoint aColPoints[MAX_COLLISION_POINTS];
float radius;
- CVector center;
+ CVUVECTOR center;
CPtrList *list;
CPhysical *A, *B;
CObject *Aobj, *Bobj;