Skip to content

Commit bfc2ee0

Browse files
committed
Fix some camera stuff 1st person for bikes (broken in last commit)
1 parent 5313a35 commit bfc2ee0

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

script.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ float LookRightAngle1p = 80.0f;
153153
float LookLeftAngle3p = 90.0f;
154154
float LookRightAngle3p = 90.0f;
155155

156-
bool lookingLeft = false;
157-
bool lookingRight = false;
158-
bool lookingBack = false;
156+
bool isLookingBack = false;
159157

160158
// look left = -1.f; lookRight = 1.f; Center = 0.f (For smooth transitions)
161159
float RelativeLookFactor = 0.f;
@@ -1004,7 +1002,7 @@ void setupCustomCamera() {
10041002

10051003
void updateCameraDriverSeat() {
10061004

1007-
if (CONTROLS::IS_CONTROL_PRESSED(0, eControl::ControlLookBehind) || (readInputFromMt && DECORATOR::DECOR_GET_BOOL(veh, (char *)"mt_looking_back")))
1005+
if (CONTROLS::IS_CONTROL_PRESSED(0, eControl::ControlLookBehind) || isLookingBack)
10081006
{
10091007
lookBehind1p();
10101008

@@ -1049,20 +1047,21 @@ void updateCameraDriverSeat() {
10491047
Vector3f rot = toV3f(ENTITY::GET_ENTITY_ROTATION(veh, 2));
10501048
rot[1] = rot.y() * 0.5f; // rot.y = rot.y * .5f
10511049

1050+
//smoothRotSeat = Vector3fLerpAngle(smoothRotSeat, rot, clamp01(30.f * getDeltaTime()));
1051+
smoothQuatSeat = getEntityQuaternion(veh);
1052+
10521053
if (smoothIsMouseLooking > 0.001f && btnLookingFactor < 0.001f) {
10531054
Vector3f gameplayCamRot = toV3f(CAM::GET_GAMEPLAY_CAM_ROT(2));
10541055
Vector3f finalRotSeat = Vector3fLerpAngle(rot, gameplayCamRot, smoothIsMouseLooking);
10551056
CAM::SET_CAM_ROT(customCam, finalRotSeat.x(), finalRotSeat.y(), finalRotSeat.z(), 2);
10561057
}
10571058
else
10581059
{
1059-
CAM::SET_CAM_ROT(customCam, rot.x(), rot.y(), rot.z(), 2);
1060-
10611060
float leftRightAngle = RelativeLookFactor < 0 ?
10621061
lerp(0.f, -LookLeftAngle1p, -RelativeLookFactor)
10631062
:
10641063
lerp(0.f, LookRightAngle1p, RelativeLookFactor)
1065-
;
1064+
;
10661065

10671066
float leftRightRad = leftRightAngle * DEG_TO_RAD;
10681067

@@ -1072,7 +1071,7 @@ void updateCameraDriverSeat() {
10721071
* AngleAxisf(pitch, Vector3f::UnitY())
10731072
* AngleAxisf(yaw, Vector3f::UnitZ());
10741073

1075-
SET_CAM_QUATERNION(customCam, GET_CAM_QUATERNION(customCam) * qLookLeftRight);
1074+
SET_CAM_QUATERNION(customCam, smoothQuatSeat * qLookLeftRight);
10761075

10771076
}
10781077
}
@@ -1116,12 +1115,14 @@ void updateCameraDriverSeat() {
11161115
CAM::RENDER_SCRIPT_CAMS(true, false, 3000, 1, 0);
11171116
}
11181117

1119-
void ProccessLookLeftRightInput()
1118+
void ProccessLookLeftRightOrBackInput()
11201119
{
11211120
const float rotSpeed = 9.f;
11221121

11231122
bool evalLeft = IsKeyDown(str2key(lookLeftKey)) || (readInputFromMt && DECORATOR::DECOR_GET_BOOL(veh, (char *)"mt_looking_left"));
1124-
bool evalRight = IsKeyDown(str2key(lookRightKey)) || (readInputFromMt && DECORATOR::DECOR_GET_BOOL(veh, (char *)"mt_looking_right"));;
1123+
bool evalRight = IsKeyDown(str2key(lookRightKey)) || (readInputFromMt && DECORATOR::DECOR_GET_BOOL(veh, (char *)"mt_looking_right"));
1124+
1125+
isLookingBack = CONTROLS::IS_CONTROL_PRESSED(0, eControl::ControlVehicleLookBehind) || (readInputFromMt && DECORATOR::DECOR_GET_BOOL(veh, (char *)"mt_looking_back")) || (evalLeft && evalRight);
11251126

11261127
if (evalLeft && !evalRight) {
11271128
RelativeLookFactor += rotSpeed * getDeltaTime();
@@ -1260,7 +1261,7 @@ void updateCameraSmooth3P() {
12601261
Quaternionf mouseLookRot = lookRotation(getGameplayCameraDirection());
12611262

12621263
bool lookBehind = false;
1263-
if (CONTROLS::IS_CONTROL_PRESSED(0, eControl::ControlLookBehind) || (readInputFromMt && DECORATOR::DECOR_GET_BOOL(veh, (char *)"mt_looking_back")))
1264+
if (CONTROLS::IS_CONTROL_PRESSED(0, eControl::ControlLookBehind) || isLookingBack)
12641265
lookBehind = true;
12651266

12661267
float leftRightAngle = 0.f;
@@ -1359,7 +1360,7 @@ void updateCameraSmooth3P() {
13591360
angleFront = -angleFront;
13601361
}
13611362

1362-
if (!lookBehind && !isBike)
1363+
if (!lookBehind /* && !isBike */)
13631364
{
13641365
angle = angle * 0.003f;
13651366
angleFront = angleFront * 0.003f;
@@ -1368,9 +1369,9 @@ void updateCameraSmooth3P() {
13681369
offsetLatPointFront = latVector * (angleFront * (1.f - smoothIsMouseLooking) * (1.f - smoothIsInAir) * (1.f - smoothIsAiming) * clamp01((vehSpeed - 0.002f) * 0.1f) * clamp01(1.f - ((vehSpeed * 0.01f))));
13691370
}
13701371

1371-
if (isBike)
1372-
setCamPos(customCam, camPos);
1373-
else
1372+
//if (isBike)
1373+
// setCamPos(customCam, camPos);
1374+
//else
13741375
setCamPos(customCam, camPos + (offsetLatPointFront * 1.455f));
13751376

13761377
//if (smoothIsMouseLooking > 0.001f) {
@@ -1392,9 +1393,9 @@ void updateCameraSmooth3P() {
13921393
setCamPos(customCam, toV3f(endCoords) + (finalQuat * front * 0.01f));
13931394
}
13941395

1395-
if(isBike)
1396-
camPointAt(customCam, finalPosCenter + (-up * .170f));
1397-
else
1396+
//if(isBike)
1397+
// camPointAt(customCam, finalPosCenter + (-up * .170f));
1398+
//else
13981399
camPointAt(customCam, finalPosCenter + (-up * .170f) + (offsetLatPointFront * -1.4825f));
13991400
}
14001401

@@ -1748,7 +1749,7 @@ void update()
17481749
}
17491750

17501751
updateTimers();
1751-
ProccessLookLeftRightInput();
1752+
ProccessLookLeftRightOrBackInput();
17521753
updateCustomCamera();
17531754

17541755
Vector3 rotCam = CAM::GET_CAM_ROT(customCam, 2);

script.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void ScriptMain();
4444

4545
void lookBehind1p();
4646

47-
void ProccessLookLeftRightInput();
47+
void ProccessLookLeftRightOrBackInput();
4848

4949
Vector3f GetBonePos(Entity entity, char * boneName);
5050

0 commit comments

Comments
 (0)