summaryrefslogtreecommitdiffstats
path: root/src/render/Occlusion.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-12-29 12:55:26 +0100
committerSergeanur <s.anureev@yandex.ua>2020-12-29 12:55:26 +0100
commitb9e97ab79db84785838f1b995188c37328c26071 (patch)
treec0c2fb73abab36a3f2e92b904287d91ef5032209 /src/render/Occlusion.cpp
parentFix error sound in when entering load/save menu (diff)
downloadre3-b9e97ab79db84785838f1b995188c37328c26071.tar
re3-b9e97ab79db84785838f1b995188c37328c26071.tar.gz
re3-b9e97ab79db84785838f1b995188c37328c26071.tar.bz2
re3-b9e97ab79db84785838f1b995188c37328c26071.tar.lz
re3-b9e97ab79db84785838f1b995188c37328c26071.tar.xz
re3-b9e97ab79db84785838f1b995188c37328c26071.tar.zst
re3-b9e97ab79db84785838f1b995188c37328c26071.zip
Diffstat (limited to 'src/render/Occlusion.cpp')
-rw-r--r--src/render/Occlusion.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/render/Occlusion.cpp b/src/render/Occlusion.cpp
index 5fef6e21..2b15e75b 100644
--- a/src/render/Occlusion.cpp
+++ b/src/render/Occlusion.cpp
@@ -1,6 +1,7 @@
#include "common.h"
#include "main.h"
+#include "Entity.h"
#include "Occlusion.h"
#include "Game.h"
#include "Camera.h"
@@ -493,3 +494,36 @@ void COcclusion::Render() {
DefinedState();
}
#endif
+
+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