summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/Cam.cpp14
1 files changed, 11 insertions, 3 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;