Skip to content

Commit 5ca9481

Browse files
committed
- update Fireboyd78 camera code
1 parent e49ffdf commit 5ca9481

File tree

1 file changed

+23
-27
lines changed

1 file changed

+23
-27
lines changed

game/scripts/camera.lua

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -98,40 +98,37 @@ local function PlaceCameraFollowCar(dt)
9898
local aspectZ = (carCos.colBox.vz * 256) / fix.ONE;
9999

100100
local A = (aspectY * (aspectZ / 2));
101-
local B = (aspectZ / (aspectY * 2));
102-
101+
103102
-- Fireboyd78 camera code from ReD2
104103
-- adjust for especially taller/longer cars
105-
if A >= 85 then
106-
local C = (A * B)
104+
if A >= 80 then
105+
local B = aspectZ / (aspectY * 2);
106+
local C = A * B
107107

108108
local camDist = (aspectY * aspectZ)
109109
local camAdjust = 0;
110110

111-
if C < carCos.colBox.vy then
112-
-- taller; keep vehicle in view while respecting ratio
113-
if camDist >= gCameraDefaultScrZ then
114-
addDist = addDist + (gCameraDefaultScrZ - camDist)
115-
elseif camDist < gCameraDefaultScrZ then
116-
addDist = addDist +( gCameraDefaultScrZ - camDist)
111+
if C > addDist then
112+
-- long vehicle but not very tall;
113+
-- move the camera closer and lower it a bit
114+
addDist = addDist - (C - addDist) * 2;
115+
carHeight = carHeight - (A / 2);
116+
elseif (C < carCos.colBox.vy) then
117+
-- tall vehicle but not very long;
118+
-- move up closer in respect to camera aspect
119+
addDist = addDist - (camDist - gCameraDefaultScrZ);
120+
else
121+
-- deal with very large vehicles (like buses)
122+
if camDist < -carHeight + 100 then
123+
-- long and tall, but still fits within view
124+
-- move up closer in respect to camera/vehicle aspect
125+
addDist = addDist - (camDist - (gCameraDefaultScrZ / B));
117126
else
118-
addDist = addDist + (gCameraDefaultScrZ - C)
127+
-- absolutely massive, doesn't fit within view!
128+
-- move up closer; adjust height in respect to camera aspect
129+
addDist = addDist - (camDist / (1 + B));
130+
carHeight = carHeight - (A - gCameraDefaultScrZ) / 2;
119131
end
120-
121-
camAdjust = 1
122-
elseif C > addDist then
123-
-- longer; move camera up
124-
addDist = addDist - (C - addDist) * 2
125-
carHeight = carHeight - (A / 2)
126-
127-
camAdjust = 1;
128-
elseif camDist < (-carHeight + 100) then
129-
-- long and tall (but fits within view)
130-
addDist = addDist - (camDist - (gCameraDefaultScrZ / B))
131-
else
132-
-- long and very tall; probably a huge bus
133-
addDist = addDist - camDist / (1 + B)
134-
carHeight = carHeight - (A - gCameraDefaultScrZ) / 2
135132
end
136133
end
137134

@@ -205,4 +202,3 @@ function InitCamera( params )
205202
camera.MainViewVelocity:set(0.0)
206203
end
207204
end
208-

0 commit comments

Comments
 (0)