mirror of
https://github.com/GTAmodding/re3.git
synced 2024-11-15 19:38:59 +00:00
Vehicle cam object collision fix
This commit is contained in:
parent
95fe5004c8
commit
c504cf02e4
1 changed files with 11 additions and 3 deletions
|
@ -5250,11 +5250,14 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
|
||||||
float timestepFactor = Pow(0.99f, CTimer::GetTimeStep());
|
float timestepFactor = Pow(0.99f, CTimer::GetTimeStep());
|
||||||
dontCollideWithCars = (timestepFactor * dontCollideWithCars) + ((1.0f - timestepFactor) * car->m_vecMoveSpeed.Magnitude());
|
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
|
// Move cam if on collision
|
||||||
CColPoint foundCol;
|
CColPoint foundCol;
|
||||||
CEntity* foundEnt;
|
CEntity* foundEnt;
|
||||||
CWorld::pIgnoreEntity = CamTargetEntity;
|
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 obstacleTargetDist = (TargetCoors - foundCol.point).Magnitude();
|
||||||
float obstacleCamDist = newDistance - obstacleTargetDist;
|
float obstacleCamDist = newDistance - obstacleTargetDist;
|
||||||
if (!foundEnt->IsPed() || obstacleCamDist <= 1.0f) {
|
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));
|
RwCameraSetNearClipPlane(Scene.camera, Max(0.05f, obstacleTargetDist - 0.3f));
|
||||||
}
|
}
|
||||||
} else {
|
} 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;
|
float lessClip = obstacleCamDist - 0.35f;
|
||||||
if (lessClip <= DEFAULT_NEAR)
|
if (lessClip <= DEFAULT_NEAR)
|
||||||
RwCameraSetNearClipPlane(Scene.camera, lessClip);
|
RwCameraSetNearClipPlane(Scene.camera, lessClip);
|
||||||
|
@ -5282,6 +5285,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CWorld::pIgnoreEntity = nil;
|
CWorld::pIgnoreEntity = nil;
|
||||||
float nearClip = RwCameraGetNearClipPlane(Scene.camera);
|
float nearClip = RwCameraGetNearClipPlane(Scene.camera);
|
||||||
float radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
|
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.
|
// If we're seeing blue hell due to camera intersects some surface, fix it.
|
||||||
// SA and LCS have this unrolled.
|
// SA and LCS have this unrolled.
|
||||||
for (int i = 0;
|
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++) {
|
i++) {
|
||||||
|
|
||||||
|
if (IS_TRAFFIC_LIGHT(foundEnt))
|
||||||
|
break;
|
||||||
|
|
||||||
CVector surfaceCamDist = gaTempSphereColPoints->point - Source;
|
CVector surfaceCamDist = gaTempSphereColPoints->point - Source;
|
||||||
CVector frontButInvertedIfTouchesSurface = DotProduct(surfaceCamDist, Front) * Front;
|
CVector frontButInvertedIfTouchesSurface = DotProduct(surfaceCamDist, Front) * Front;
|
||||||
float newNearClip = (surfaceCamDist - frontButInvertedIfTouchesSurface).Magnitude() / radius;
|
float newNearClip = (surfaceCamDist - frontButInvertedIfTouchesSurface).Magnitude() / radius;
|
||||||
|
@ -5309,6 +5316,7 @@ CCam::Process_FollowCar_SA(const CVector& CameraTarget, float TargetOrientation,
|
||||||
nearClip = RwCameraGetNearClipPlane(Scene.camera);
|
nearClip = RwCameraGetNearClipPlane(Scene.camera);
|
||||||
radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
|
radius = Tan(DEGTORAD(FOV * 0.5f)) * CDraw::GetAspectRatio() * 1.1f;
|
||||||
}
|
}
|
||||||
|
#undef IS_TRAFFIC_LIGHT
|
||||||
}
|
}
|
||||||
TheCamera.m_bCamDirectlyBehind = false;
|
TheCamera.m_bCamDirectlyBehind = false;
|
||||||
TheCamera.m_bCamDirectlyInFront = false;
|
TheCamera.m_bCamDirectlyInFront = false;
|
||||||
|
|
Loading…
Reference in a new issue