summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/Cam.cpp14
-rw-r--r--src/core/common.h8
-rw-r--r--src/core/templates.h8
3 files changed, 22 insertions, 8 deletions
diff --git a/src/core/Cam.cpp b/src/core/Cam.cpp
index bc01b58e..d1ff6ddb 100644
--- a/src/core/Cam.cpp
+++ b/src/core/Cam.cpp
@@ -5250,11 +5250,14 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
float timestepFactor = Pow(0.99f, CTimer::GetTimeStep());
dontCollideWithCars = (timestepFactor * dontCollideWithCars) + ((1.0f - timestepFactor) * car->m_vecMoveSpeed.Magnitude());
+ // Our addition
+#define IS_TRAFFIC_LIGHT(ent) (ent->IsObject() && IsLightObject(ent->GetModelIndex()))
+
// Move cam if on collision
CColPoint foundCol;
CEntity* foundEnt;
CWorld::pIgnoreEntity = CamTargetEntity;
- if (CWorld::ProcessLineOfSight(TargetCoors, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
+ if (CWorld::ProcessLineOfSight(TargetCoors, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false) && !IS_TRAFFIC_LIGHT(foundEnt)) {
float obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
float obstacleCamDist = newDistance - obstacleTargetDist;
if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) {
@@ -5263,7 +5266,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f));
}
} else {
- if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, false, false, true, false)) {
+ if (!CWorld::ProcessLineOfSight(foundCol.point, Source, foundCol, foundEnt, true, dontCollideWithCars < 0.1f, false, true, false, true, false) || IS_TRAFFIC_LIGHT(foundEnt)) {
float lessClip = obstacleCamDist - 0.35f;
if (lessClip <= DEFAULT_NEAR)
RwCameraSetNearClipPlane(Scene.camera, lessClip);
@@ -5282,6 +5285,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
}
}
}
+
CWorld::pIgnoreEntity = nil;
float nearClip = RwCameraGetNearClipPlane(Scene.camera);
float radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
@@ -5289,9 +5293,12 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
// If we're seeing blue hell due to camera intersects some surface, fix it.
// SA and LCS have this unrolled.
for (int i = 0;
- i <= 5 && CWorld::TestSphereAgainstWorld((nearClip * Front) + Source, radius * nearClip, nil, true, true, false, true, false, false);
+ i <= 5 && (foundEnt = CWorld::TestSphereAgainstWorld((nearClip * Front) + Source, radius * nearClip, nil, true, true, false, true, false, false));
i++) {
+ if (IS_TRAFFIC_LIGHT(foundEnt))
+ break;
+
CVector surfaceCamDist = gaTempSphereColPoints->point - Source;
CVector frontButInvertedIfTouchesSurface = DotProduct(surfaceCamDist, Front) * Front;
float newNearClip = (surfaceCamDist - frontButInvertedIfTouchesSurface).Magnitude() / radius;
@@ -5309,6 +5316,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
nearClip = RwCameraGetNearClipPlane(Scene.camera);
radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
}
+#undef IS_TRAFFIC_LIGHT
}
TheCamera.m_bCamDirectlyBehind = false;
TheCamera.m_bCamDirectlyInFront = false;
diff --git a/src/core/common.h b/src/core/common.h
index 9c81cf3b..181389da 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -251,8 +251,14 @@ void re3_usererror(const char *format, ...);
#define DEBUGBREAK() __debugbreak();
-#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
+// Switch to enable development messages.
+#if 1
+#define DEV(f, ...)
+#else
#define DEV(f, ...) re3_debug("[DEV]: " f, ## __VA_ARGS__)
+#endif
+
+#define debug(f, ...) re3_debug("[DBG]: " f, ## __VA_ARGS__)
#define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, ## __VA_ARGS__)
#define Error(f, ...) re3_debug("[ERROR]: " f, ## __VA_ARGS__)
#define USERERROR(f, ...) re3_usererror(f, ## __VA_ARGS__)
diff --git a/src/core/templates.h b/src/core/templates.h
index 704331c3..bb89814e 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -123,16 +123,16 @@ public:
return m_flags[handle>>8].u == (handle & 0xFF) ?
(T*)&m_entries[handle >> 8] : nil;
}
- int GetIndex(T *entry){
+ int GetIndex(T* entry) {
int i = GetJustIndex_NoFreeAssert(entry);
- return m_flags[i].u + (i<<8);
+ return m_flags[i].u + (i << 8);
}
- int GetJustIndex(T *entry){
+ int GetJustIndex(T* entry) {
int index = GetJustIndex_NoFreeAssert(entry);
assert(!IsFreeSlot(index));
return index;
}
- int GetJustIndex_NoFreeAssert(T* entry){
+ int GetJustIndex_NoFreeAssert(T* entry) {
int index = ((U*)entry - m_entries);
assert((U*)entry == (U*)&m_entries[index]); // cast is unsafe - check required
return index;