summaryrefslogtreecommitdiffstats
path: root/src/entities/Entity.cpp
diff options
context:
space:
mode:
authormajestic <majesticcoding@gmail.com>2020-07-05 22:45:09 +0200
committermajestic <majesticcoding@gmail.com>2020-07-20 18:49:39 +0200
commit1ff27e3363c4deb027619375ac289a6148cda529 (patch)
tree3b39a423fff3d683dea4b16fc36308a46118286f /src/entities/Entity.cpp
parentfixes from master, menu helper text (diff)
downloadre3-1ff27e3363c4deb027619375ac289a6148cda529.tar
re3-1ff27e3363c4deb027619375ac289a6148cda529.tar.gz
re3-1ff27e3363c4deb027619375ac289a6148cda529.tar.bz2
re3-1ff27e3363c4deb027619375ac289a6148cda529.tar.lz
re3-1ff27e3363c4deb027619375ac289a6148cda529.tar.xz
re3-1ff27e3363c4deb027619375ac289a6148cda529.tar.zst
re3-1ff27e3363c4deb027619375ac289a6148cda529.zip
Diffstat (limited to '')
-rw-r--r--src/entities/Entity.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index 394b8162..fb59f791 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)
@@ -1157,3 +1158,37 @@ bool IsEntityPointerValid(CEntity* pEntity)
}
return false;
}
+
+bool CEntity::IsEntityOccluded(void) {
+ return false;
+
+ CVector coors;
+ float width, height;
+
+ if (!COcclusion::NumActiveOccluders || !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