summaryrefslogtreecommitdiffstats
path: root/src/entities
diff options
context:
space:
mode:
authorFire_Head <Fire-Head@users.noreply.github.com>2020-07-29 11:20:02 +0200
committerGitHub <noreply@github.com>2020-07-29 11:20:02 +0200
commit52e77c66345399f7f1064b80676a2495e299bb46 (patch)
tree358b7762beb8809084c65358087d5899e4546f18 /src/entities
parentmiami shadows (diff)
parentsome fakerw additions for shadows; update librw (diff)
downloadre3-52e77c66345399f7f1064b80676a2495e299bb46.tar
re3-52e77c66345399f7f1064b80676a2495e299bb46.tar.gz
re3-52e77c66345399f7f1064b80676a2495e299bb46.tar.bz2
re3-52e77c66345399f7f1064b80676a2495e299bb46.tar.lz
re3-52e77c66345399f7f1064b80676a2495e299bb46.tar.xz
re3-52e77c66345399f7f1064b80676a2495e299bb46.tar.zst
re3-52e77c66345399f7f1064b80676a2495e299bb46.zip
Diffstat (limited to 'src/entities')
-rw-r--r--src/entities/Building.cpp2
-rw-r--r--src/entities/Entity.cpp57
-rw-r--r--src/entities/Entity.h4
-rw-r--r--src/entities/Physical.cpp2
4 files changed, 58 insertions, 7 deletions
diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp
index 3217e684..921055ce 100644
--- a/src/entities/Building.cpp
+++ b/src/entities/Building.cpp
@@ -17,7 +17,7 @@ CBuilding::ReplaceWithNewModel(int32 id)
m_modelIndex = id;
if(bIsBIGBuilding)
- if(m_level == LEVEL_NONE || m_level == CGame::currLevel)
+ if(m_level == LEVEL_GENERIC || m_level == CGame::currLevel)
CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE);
}
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index e0cdbeb0..518c36c5 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -31,6 +31,7 @@
#include "Ped.h"
#include "Dummy.h"
#include "WindModifiers.h"
+#include "Occlusion.h"
//--MIAMI: file almost done (see TODO)
@@ -359,8 +360,8 @@ CEntity::SetupBigBuilding(void)
if(mi->m_lodDistances[0] <= 2000.0f)
bStreamBIGBuilding = true;
if(mi->m_lodDistances[0] > 2500.0f || mi->m_ignoreDrawDist)
- m_level = LEVEL_NONE;
- else if(m_level == LEVEL_NONE)
+ m_level = LEVEL_GENERIC;
+ else if(m_level == LEVEL_GENERIC)
printf("%s isn't in a level\n", mi->GetName());
}
@@ -619,6 +620,23 @@ CEntity::PruneReferences(void)
}
}
+// Clean up the reference from *pent -> 'this'
+void
+CEntity::CleanUpOldReference(CEntity **pent)
+{
+ CReference* ref, ** lastnextp;
+ lastnextp = &m_pFirstReference;
+ for (ref = m_pFirstReference; ref; ref = ref->next) {
+ if (ref->pentity == pent) {
+ *lastnextp = ref->next;
+ ref->next = CReferences::pEmptyList;
+ CReferences::pEmptyList = ref;
+ break;
+ }
+ lastnextp = &ref->next;
+ }
+}
+
void
CEntity::UpdateRpHAnim(void)
{
@@ -630,7 +648,7 @@ CEntity::UpdateRpHAnim(void)
char buf[256];
if(this == (CEntity*)FindPlayerPed())
for(i = 0; i < hier->numNodes; i++){
- RpHAnimStdKeyFrame *kf = (RpHAnimStdKeyFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i);
+ RpHAnimStdInterpFrame *kf = (RpHAnimStdInterpFrame*)rpHANIMHIERARCHYGETINTERPFRAME(hier, i);
sprintf(buf, "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %d %s",
kf->q.imag.x, kf->q.imag.y, kf->q.imag.z, kf->q.real,
kf->t.x, kf->t.y, kf->t.z,
@@ -1157,3 +1175,36 @@ bool IsEntityPointerValid(CEntity* pEntity)
}
return false;
}
+
+bool CEntity::IsEntityOccluded(void) {
+
+ CVector coors;
+ float width, height;
+
+ if (COcclusion::NumActiveOccluders == 0 || !CalcScreenCoors(GetBoundCentre(), &coors, &width, &height))
+ return false;
+
+ float area = Max(width, height) * GetBoundRadius() * 0.9f;
+
+ for (int i = 0; i < COcclusion::NumActiveOccluders; i++) {
+ if (coors.z - (GetBoundRadius() * 0.85f) > COcclusion::aActiveOccluders[i].radius) {
+ if (COcclusion::aActiveOccluders[i].IsPointWithinOcclusionArea(coors.x, coors.y, area)) {
+ return true;
+ }
+
+ if (COcclusion::aActiveOccluders[i].IsPointWithinOcclusionArea(coors.x, coors.y, 0.0f)) {
+ CVector min = m_matrix * CModelInfo::GetModelInfo(GetModelIndex())->GetColModel()->boundingBox.min;
+ CVector max = m_matrix * CModelInfo::GetModelInfo(GetModelIndex())->GetColModel()->boundingBox.max;
+
+ if (CalcScreenCoors(min, &coors) && !COcclusion::aActiveOccluders[i].IsPointWithinOcclusionArea(coors.x, coors.y, 0.0f)) continue;
+ if (CalcScreenCoors(CVector(max.x, max.y, min.z), &coors) && !COcclusion::aActiveOccluders[i].IsPointWithinOcclusionArea(coors.x, coors.y, 0.0f)) continue;
+ if (CalcScreenCoors(CVector(max.x, min.y, max.z), &coors) && !COcclusion::aActiveOccluders[i].IsPointWithinOcclusionArea(coors.x, coors.y, 0.0f)) continue;
+ if (CalcScreenCoors(CVector(min.x, max.y, max.z), &coors) && !COcclusion::aActiveOccluders[i].IsPointWithinOcclusionArea(coors.x, coors.y, 0.0f)) continue;
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+} \ No newline at end of file
diff --git a/src/entities/Entity.h b/src/entities/Entity.h
index c3e4cc3b..fd01b6f8 100644
--- a/src/entities/Entity.h
+++ b/src/entities/Entity.h
@@ -156,8 +156,7 @@ public:
bool GetIsOnScreenComplex(void);
bool IsVisible(void) { return m_rwObject && bIsVisible && GetIsOnScreen(); }
bool IsVisibleComplex(void) { return m_rwObject && bIsVisible && GetIsOnScreenComplex(); }
-// TODO(MIAMI):
- bool IsEntityOccluded(void) { return false; }
+ bool IsEntityOccluded(void);
int16 GetModelIndex(void) const { return m_modelIndex; }
void UpdateRwFrame(void);
void SetupBigBuilding(void);
@@ -169,6 +168,7 @@ public:
void RegisterReference(CEntity **pent);
void ResolveReferences(void);
void PruneReferences(void);
+ void CleanUpOldReference(CEntity **pent);
#ifdef PED_SKIN
void UpdateRpHAnim(void);
diff --git a/src/entities/Physical.cpp b/src/entities/Physical.cpp
index 12345cc9..5fe29a79 100644
--- a/src/entities/Physical.cpp
+++ b/src/entities/Physical.cpp
@@ -75,7 +75,7 @@ CPhysical::CPhysical(void)
#ifdef FIX_BUGS
m_nSurfaceTouched = SURFACE_DEFAULT;
#endif
- m_nZoneLevel = LEVEL_NONE;
+ m_nZoneLevel = LEVEL_GENERIC;
bIsFrozen = false;
bDontLoadCollision = false;