mirror of
https://github.com/GTAmodding/re3.git
synced 2025-07-06 18:34:08 +00:00
CEntity and C(Vu)Vector fixes and cleanup
This commit is contained in:
parent
be019c6126
commit
93e9929925
13 changed files with 57 additions and 52 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "common.h"
|
||||
|
||||
#include "VuVector.h"
|
||||
#include "General.h"
|
||||
#include "RwHelper.h"
|
||||
#include "ModelIndices.h"
|
||||
|
@ -70,7 +71,7 @@ CEntity::CEntity(void)
|
|||
bDistanceFade = false;
|
||||
|
||||
m_flagE1 = false;
|
||||
m_flagE2 = false;
|
||||
bDontCastShadowsOn = false;
|
||||
bOffscreen = false;
|
||||
bIsStaticWaitingForCollision = false;
|
||||
bDontStream = false;
|
||||
|
@ -200,7 +201,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);
|
||||
|
@ -219,21 +220,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
|
||||
|
@ -372,7 +379,7 @@ CEntity::PreRender(void)
|
|||
CVector pos = GetPosition();
|
||||
CShadows::StoreShadowToBeRendered(SHADOWTYPE_DARK,
|
||||
gpShadowPedTex, &pos,
|
||||
0.4f, 0.0f, 0.0f, -0.4f,
|
||||
0.4f, 0.0f, 0.0f, 0.4f,
|
||||
CTimeCycle::GetShadowStrength(),
|
||||
CTimeCycle::GetShadowStrength(),
|
||||
CTimeCycle::GetShadowStrength(),
|
||||
|
@ -418,9 +425,11 @@ CEntity::Render(void)
|
|||
}
|
||||
|
||||
bool
|
||||
CEntity::GetIsTouching(CVector const ¢er, float radius)
|
||||
CEntity::GetIsTouching(CVUVECTOR const ¢er, float radius)
|
||||
{
|
||||
return sq(GetBoundRadius()+radius) > (GetBoundCentre()-center).MagnitudeSqr();
|
||||
CVUVECTOR boundCenter;
|
||||
GetBoundCentre(boundCenter);
|
||||
return sq(GetBoundRadius()+radius) > (boundCenter-center).MagnitudeSqr();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -438,8 +447,7 @@ CEntity::IsVisibleComplex(void)
|
|||
bool
|
||||
CEntity::GetIsOnScreen(void)
|
||||
{
|
||||
return TheCamera.IsSphereVisible(GetBoundCentre(), GetBoundRadius(),
|
||||
&TheCamera.GetCameraMatrix());
|
||||
return TheCamera.IsSphereVisible(GetBoundCentre(), GetBoundRadius());
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -455,7 +463,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;
|
||||
|
@ -610,7 +618,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
|
||||
|
@ -731,11 +739,6 @@ CEntity::PreRenderForGlassWindow(void)
|
|||
bIsVisible = false;
|
||||
}
|
||||
|
||||
/*
|
||||
0x487A10 - SetAtomicAlphaCB
|
||||
0x4879E0 - SetClumpAlphaCB
|
||||
*/
|
||||
|
||||
RpMaterial*
|
||||
SetAtomicAlphaCB(RpMaterial *material, void *data)
|
||||
{
|
||||
|
@ -834,7 +837,7 @@ CEntity::SaveEntityFlags(uint8*& buf)
|
|||
if (bDistanceFade) tmp |= BIT(7);
|
||||
|
||||
if (m_flagE1) tmp |= BIT(8);
|
||||
if (m_flagE2) tmp |= BIT(9);
|
||||
if (bDontCastShadowsOn) tmp |= BIT(9);
|
||||
if (bOffscreen) tmp |= BIT(10);
|
||||
if (bIsStaticWaitingForCollision) tmp |= BIT(11);
|
||||
if (bDontStream) tmp |= BIT(12);
|
||||
|
@ -890,7 +893,7 @@ CEntity::LoadEntityFlags(uint8*& buf)
|
|||
bDistanceFade = !!(tmp & BIT(7));
|
||||
|
||||
m_flagE1 = !!(tmp & BIT(8));
|
||||
m_flagE2 = !!(tmp & BIT(9));
|
||||
bDontCastShadowsOn = !!(tmp & BIT(9));
|
||||
bOffscreen = !!(tmp & BIT(10));
|
||||
bIsStaticWaitingForCollision = !!(tmp & BIT(11));
|
||||
bDontStream = !!(tmp & BIT(12));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue