Skip to content

Commit 6dd9733

Browse files
committed
1.3 Release ready (final adjustments)
1 parent eea18ef commit 6dd9733

File tree

3 files changed

+81
-17
lines changed

3 files changed

+81
-17
lines changed

CustomCameraVPlus.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ distanceOffset = 0.0
55
lookLeftAngle = 90.0
66
lookRightAngle = 90.0
77

8+
# If enabled, camera will look down when the car loses acceleration quickly or brakes
9+
#
10+
# Set to 1 to enable, 0 to disable
11+
InertiaAffectsPitch = 0
812

913
[1stPersonView]
1014
fov = 75.0
1115

1216
lookLeftAngle = 75.0
1317
lookRightAngle = 80.0
1418

19+
# If enabled, camera will move forward/backguards based on inertia
20+
#
21+
# Set to 1 to enable, 0 to disable
22+
InertiaEffects = 1
1523

1624
[general]
1725

changelog.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
1.3
22

3-
* Reworked dynamic camera distance based on acceleration and speed. Fixes some bugs and provides better visual feedback.
3+
* Reworked dynamic camera distance based on acceleration and speed (third person camera). Fixes some bugs and provides better visual feedback.
4+
* Fixed 3rd person camera getting too close to the vehicle at high speeds.
5+
* New option "InertiaAffectsPitch" on 3rd person camera, wich makes the camera look down when the car loses acceleration quickly or brakes (Diabled by default)
6+
* New option "InertiaEffects" on 1st person camera, wich makes the camera move forward / back based on vehicle acceleration (Enabled by default)
7+
* Adjusted 1st person camera distance to be a little more distant
48

59
1.2
610

script.cpp

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ float LookRightAngle1p = 80.0f;
165165
float LookLeftAngle3p = 90.0f;
166166
float LookRightAngle3p = 90.0f;
167167

168+
bool InertiaAffectsPitch3p = false;
169+
170+
bool InertiaEffects1p = true;
171+
168172
float semiDelayedVehSpeed = 0.f;
169173
float delayedVehSpeed = 0.f;
170174

@@ -190,6 +194,7 @@ float RelativeLookFactor = 0.f;
190194
bool readInputFromMt = true;
191195
float vehDelayedAccel = 0.f;
192196
float vehDelayedAccel2 = 0.f;
197+
float smoothIsGoingForwardInc = 0.f;
193198

194199
char * reloadKey = "F10";
195200
char * toggleModKey = "1";
@@ -325,6 +330,10 @@ float easeInSine(float t) {
325330
return -1.f * cos(t / 1.f * (PI * 0.5f)) + 1.f;
326331
}
327332

333+
float easeOutSine(float t) {
334+
return sin(t / 1 * (PI * 0.5));
335+
}
336+
328337
// Range -1.f | 1.f
329338
float easeInSineInput(float axisInput)
330339
{
@@ -583,6 +592,10 @@ void ReadSettings(bool notify)
583592

584593
LookLeftAngle3p = (float) ini.GetDoubleValue("3rdPersonView", "lookLeftAngle", 90.0);
585594
LookRightAngle3p = (float)ini.GetDoubleValue("3rdPersonView", "lookRightAngle", 90.0);
595+
596+
InertiaAffectsPitch3p = ini.GetLongValue("3rdPersonView", "InertiaAffectsPitch", 0) > 0;
597+
598+
InertiaEffects1p = ini.GetLongValue("1stPersonView", "InertiaEffects", 1) > 0;
586599

587600
LookLeftAngle1p = (float)ini.GetDoubleValue("1stPersonView", "lookLeftAngle", 75.0);
588601
LookRightAngle1p = (float)ini.GetDoubleValue("1stPersonView", "lookLeftAngle", 80.0);
@@ -946,21 +959,21 @@ void updateVehicleProperties()
946959
if (vehClass == eVehicleClass::VehicleClassCoupes || vehClass == eVehicleClass::VehicleClassSports || vehClass == eVehicleClass::VehicleClassSportsClassics || vehClass == eVehicleClass::VehicleClassMuscle)
947960
{
948961
// sports - coupes - muscles
949-
playerHeadAltitude = 0.65f;
950-
playerHeadDistance = -0.53f;
962+
playerHeadAltitude = 0.675f;
963+
playerHeadDistance = -0.56f;
951964
}
952965
else if (vehClass == eVehicleClass::VehicleClassSuper)
953966
{
954967
// super sport
955-
playerHeadAltitude = 0.615f;
956-
playerHeadDistance = -0.58f;
968+
playerHeadAltitude = 0.645f;
969+
playerHeadDistance = -0.61f;
957970

958971
}
959972
else
960973
{
961974
// anything else
962-
playerHeadAltitude = 0.67f;
963-
playerHeadDistance = -0.53f;
975+
playerHeadAltitude = 0.695f;
976+
playerHeadDistance = -0.56f;
964977
}
965978

966979
skelPos += vehUpVector * playerHeadAltitude;
@@ -1114,10 +1127,30 @@ void updateCameraDriverSeat() {
11141127
UI::SHOW_HUD_COMPONENT_THIS_FRAME(eHudComponent::HudComponentReticle);
11151128
}
11161129

1117-
CAM::SET_CAM_COORD(customCam, camPos.x(), camPos.y(), camPos.z());
1130+
float distIncFinal = 0.f;
1131+
1132+
if (InertiaEffects1p) {
1133+
float accelScale = VEHICLE::GET_VEHICLE_ACCELERATION(veh);
1134+
1135+
float vehDirectAccel = ((double)(vehAcceleration * accelScale)) * 1700.0;
1136+
vehDelayedAccel = lerp(vehDelayedAccel, vehDirectAccel, 1.725f * getDeltaTime());
1137+
vehDelayedAccel2 = lerp(vehDelayedAccel2, vehDirectAccel, 0.765f * getDeltaTime());
1138+
1139+
if (vehSpeed <= 0.02f && vehDelayedAccel > vehDelayedAccel2)
1140+
vehDelayedAccel2 = lerp(vehDelayedAccel2, vehDelayedAccel, 8.f * getDeltaTime());
1141+
1142+
float accelThreshold = (vehDelayedAccel - vehDelayedAccel2);
1143+
1144+
distIncFinal = accelThreshold + max(0.f, vehSpeed * 0.01295f) - 0.3f;
1145+
1146+
distIncFinal *= 0.175f;
1147+
distIncFinal = clamp(distIncFinal, -0.1f, 0.1f);
1148+
}
11181149

11191150
float btnLookingFactor = abs(RelativeLookFactor);
11201151

1152+
Quaternionf finalQ;
1153+
11211154
if (isBike) {
11221155
CAM::STOP_CAM_POINTING(customCam);
11231156
Vector3f rot = toV3f(ENTITY::GET_ENTITY_ROTATION(veh, 2));
@@ -1140,7 +1173,7 @@ void updateCameraDriverSeat() {
11401173
* AngleAxisf(pitch, Vector3f::UnitY())
11411174
* AngleAxisf(yaw, Vector3f::UnitZ());
11421175

1143-
Quaternionf finalQ = smoothQuatSeat * qLookLeftRight;
1176+
finalQ = smoothQuatSeat * qLookLeftRight;
11441177

11451178
if (isAiming || hasInputThisFrame)
11461179
{
@@ -1189,7 +1222,7 @@ void updateCameraDriverSeat() {
11891222
* AngleAxisf(pitch, Vector3f::UnitY())
11901223
* AngleAxisf(yaw, Vector3f::UnitZ());
11911224

1192-
Quaternionf finalQ = smoothQuatSeat * qLookLeftRight;
1225+
finalQ = smoothQuatSeat * qLookLeftRight;
11931226

11941227
if (isAiming || hasInputThisFrame)
11951228
{
@@ -1225,6 +1258,10 @@ void updateCameraDriverSeat() {
12251258
SET_CAM_QUATERNION(customCam, finalQ);
12261259
}
12271260

1261+
camPos = camPos + smoothQuatSeat * back * distIncFinal;
1262+
1263+
CAM::SET_CAM_COORD(customCam, camPos.x(), camPos.y(), camPos.z());
1264+
12281265
CAM::RENDER_SCRIPT_CAMS(true, false, 3000, 1, 0);
12291266
}
12301267

@@ -1375,17 +1412,32 @@ void updateCam3pNfsAlgorithm()
13751412
//smoothAccelDist = lerp(smoothAccelDist, ((vehAcceleration * VEHICLE::GET_VEHICLE_ACCELERATION(veh)) * 1700.f), 0.75f * getDeltaTime());
13761413
//smoothAccelDist = clamp(smoothAccelDist, -0.8f, 1.7f);
13771414

1378-
float vehDirectAccel = (vehAcceleration * VEHICLE::GET_VEHICLE_ACCELERATION(veh)) * 1700.f;
1379-
vehDelayedAccel = lerp(vehDelayedAccel, vehDirectAccel, 1.75f * getDeltaTime());
1380-
vehDelayedAccel2 = lerp(vehDelayedAccel2, vehDirectAccel, 0.95f * getDeltaTime());
1415+
float accelScale = VEHICLE::GET_VEHICLE_ACCELERATION(veh);
1416+
1417+
float vehDirectAccel = ((double)(vehAcceleration * accelScale)) * 1700.0;
1418+
vehDelayedAccel = lerp(vehDelayedAccel, vehDirectAccel, 1.735f * getDeltaTime());
1419+
vehDelayedAccel2 = lerp(vehDelayedAccel2, vehDirectAccel, 0.625f * getDeltaTime());
1420+
1421+
float isGoingForwardInc = clamp( ((vehSpeed - 1.f) * 0.6f) * accelScale, 0.f, 1.2f) * 0.425f;
1422+
smoothIsGoingForwardInc = lerp(smoothIsGoingForwardInc, isGoingForwardInc, 0.8f * getDeltaTime());
13811423

1382-
float distIncFinal = (vehDelayedAccel - vehDelayedAccel2) + max(0.f, vehSpeed * 0.0125f);
1424+
float accelThreshold = (vehDelayedAccel - vehDelayedAccel2);
13831425

1384-
//if (distIncFinal < 0.f)
1385-
// distIncFinal * max(0.f, 1.0f - (smoothStep(0.f, 1.f, unlerp(0.f, -0.8f, distIncFinal)) * 5.f));
1426+
float distIncFinal = clamp(accelThreshold, -1.7f, 1.5f) + max(0.f, vehSpeed * 0.01295f) - 0.3f + smoothIsGoingForwardInc;
13861427

13871428
distIncFinal *= 0.7f;
13881429

1430+
float lookDownThreshold = 0.f;
1431+
1432+
if (InertiaAffectsPitch3p) {
1433+
1434+
lookDownThreshold = clamp(accelThreshold + 0.2f, -1.f, -0.0f);
1435+
1436+
//float aux = -lookDownThreshold;
1437+
//lookDownThreshold = -smoothStep(0.f, 1.f, aux);
1438+
}
1439+
1440+
13891441
float airDistance = lerp(0.f, 2.5f, smoothIsInAirNfs * (lerp(0.6f, 1.2f, smoothIsInAirNfs)));
13901442

13911443
Vector3f posCenter = vehPos + (up * heightOffset3P) + (vehForwardVector * finalPivotFrontOffset);
@@ -1515,7 +1567,7 @@ void updateCam3pNfsAlgorithm()
15151567

15161568
rotEuler[1] = 0.f;
15171569

1518-
CAM::SET_CAM_ROT(customCam, rotEuler.x() /*- heightInc */, rotEuler.y(), rotEuler.z(), 2);
1570+
CAM::SET_CAM_ROT(customCam, rotEuler.x() + (lookDownThreshold * 7.5f), rotEuler.y(), rotEuler.z(), 2);
15191571
}
15201572

15211573
void updateCameraSmooth3P() {

0 commit comments

Comments
 (0)