@@ -91,9 +91,10 @@ Vector3f cachedSurfaceNormal;
9191Vector3f smoothSurfaceNormal;
9292
9393Vector3f smoothVelocity = Vector3f();
94+ Vector3f ultraSmoothVelocity = Vector3f();
9495Quaternionf velocityQuat3P = Quaternionf();
9596Quaternionf smoothQuat3P = Quaternionf();
96- Quaternionf ultraSmoothQuat3P = Quaternionf();
97+ Quaternionf ultraSmoothVelocity3P = Quaternionf();
9798Vector3f smoothRotSeat = Vector3f();
9899Quaternionf smoothQuatSeat = Quaternionf();
99100float smoothIsInAir = 0 .f;
@@ -554,6 +555,9 @@ void showText(float x, float y, float scale, const char* text, int font, const C
554555 UI::END_TEXT_COMMAND_DISPLAY_TEXT (x, y);
555556}
556557
558+ void showText (int index, const char * text) {
559+ showText (0 .1f , 0 .03f * (float )index, 0 .3f , text, 0 , solidWhite, true );
560+ }
557561
558562Vector3f getDimensions (Hash modelHash) {
559563 Vector3 min;
@@ -941,6 +945,7 @@ void updateVehicleVars()
941945 vehForwardVector = toV3f (ENTITY::GET_ENTITY_FORWARD_VECTOR (veh));
942946 vehSpeed = ENTITY::GET_ENTITY_SPEED (veh);
943947 smoothVelocity = lerp (smoothVelocity, vehSpeed > 2 .f ? vehVelocity : vehForwardVector, 10 .f * getDeltaTime ());
948+ ultraSmoothVelocity = lerp (ultraSmoothVelocity, vehSpeed > 2 .f ? vehVelocity : vehForwardVector, 3 .f * getDeltaTime ());
944949
945950 if ((ENTITY::IS_ENTITY_IN_AIR (veh) || (ENTITY::GET_ENTITY_UPRIGHT_VALUE (veh) < 0 .6f )) && smoothIsInAir < 0 .001f )
946951 {
@@ -1471,6 +1476,13 @@ bool LastInputMethodWasMouseAndKeyboard()
14711476 return CONTROLS::_IS_INPUT_DISABLED (2 );
14721477}
14731478
1479+ Vector3f V3Reflect (Vector3f vector, Vector3f normal)
1480+ {
1481+ float dot = vector.dot (normal);
1482+ Vector3f temp = normal * dot * 2 .f ;
1483+ return vector - temp;
1484+ }
1485+
14741486void updateCam3pNfsAlgorithm ()
14751487{
14761488 Vector3f extraCamHeight = up * (0 .14f + extraAngleCamHeight);
@@ -1481,16 +1493,23 @@ void updateCam3pNfsAlgorithm()
14811493
14821494 Quaternionf vehQuat = getEntityQuaternion (veh);
14831495 smoothQuat3P = slerp (smoothQuat3P, vehQuat, 3 .f * getDeltaTime ());
1496+
14841497 velocityQuat3P = lookRotation (smoothVelocity);
1498+ ultraSmoothVelocity3P = lookRotation (ultraSmoothVelocity);
14851499
14861500 // float vehPitch = QuatToEuler(velocityQuat3P).x();
14871501
1488- if (/* isBike && */ vehSpeed > 1 .f )
1502+ float forwardness = vehForwardVector.dot (vehVelocity);
1503+
1504+ if (/* isBike && */ forwardness >= 0 .f && vehSpeed > 1 .f )
14891505 {
1490- Quaternionf quatVel = velocityQuat3P;
1506+ Vector3f VquatVel = QuatToEuler (ultraSmoothVelocity3P);
1507+ Vector3f sm3p;
14911508
1492- Vector3f VquatVel = QuatToEuler (velocityQuat3P);
1493- Vector3f sm3p = QuatToEuler (smoothQuat3P);
1509+ // if (forwardness >= 0.f)
1510+ sm3p = QuatToEuler (smoothQuat3P);
1511+ // else
1512+ // sm3p = QuatToEuler(inverseSmoothQuat3P);
14941513
14951514 VquatVel[2 ] = sm3p[2 ];
14961515
@@ -1578,10 +1597,23 @@ void updateCam3pNfsAlgorithm()
15781597 float mx = (CONTROLS::GET_CONTROL_NORMAL (2 , eControl::ControlLookLeftRight)) * -5 .f ;
15791598 float my = (CONTROLS::GET_CONTROL_NORMAL (2 , eControl::ControlLookUpDown)) * (LastInputMethodWasMouseAndKeyboard ? -5 .f : 5 .f );
15801599
1581- if (!LastInputMethodWasMouseAndKeyboard ())
1600+ if (!LastInputMethodWasMouseAndKeyboard ()) // if gamepad
15821601 {
1583- mx *= 0 .6f ;
1584- my *= 0 .6f ;
1602+ mx *= 0 .2f ;
1603+ my *= 0 .2f ;
1604+
1605+ // showText(1, std::to_string(mx).c_str());
1606+ // showText(2, std::to_string(my).c_str());
1607+
1608+ float deadzone = 0 .275f ;
1609+ Vector2f stickInput = Vector2f (mx, my);
1610+ if (stickInput.norm () < deadzone)
1611+ stickInput = Vector2f (0 .f , 0 .f );
1612+ else
1613+ stickInput = stickInput.normalized () * ((stickInput.norm () - deadzone) / (1 .f - deadzone));
1614+
1615+ mx = stickInput.x () * 2 .f ;
1616+ my = stickInput.y () * 2 .f ;
15851617 }
15861618
15871619 Vector3f vecLook = Vector3f (my, 0 .f , mx);
@@ -1610,7 +1642,7 @@ void updateCam3pNfsAlgorithm()
16101642
16111643 float aimHeightIncrement = lerp (0 .f , 0 .22f , smoothIsAiming);
16121644
1613- Vector3f camPosSmooth = posCenter + extraCamHeight + V3CurrentTowHeightIncrement + (finalQuat3P * back * ((longitudeOffset3P) + 0 .15f + airDistance)) + (up * aimHeightIncrement);
1645+ Vector3f camPosSmooth = posCenter + extraCamHeight + V3CurrentTowHeightIncrement + (finalQuat3P * back * ((longitudeOffset3P) + 0 .185f + airDistance)) + (up * aimHeightIncrement);
16141646 camPosSmooth += slerp (smoothQuat3P, velocityQuat3P, smoothIsInAir) * back * distIncFinal;
16151647
16161648 Vector3f camPosFinal = camPosSmooth;
@@ -1658,7 +1690,7 @@ void DisableCustomCamera()
16581690 CAM::RENDER_SCRIPT_CAMS (false , false , 3000 , true , false );
16591691 camInitialized = false ;
16601692 isInVehicle = false ;
1661- veh = NULL ;
1693+ // veh = NULL;
16621694
16631695 haltCurrentCamera ();
16641696}
@@ -1969,17 +2001,10 @@ void update()
19692001 }
19702002
19712003 if (IsKeyJustUp (str2key (reloadKey))) {
1972-
1973- haltCurrentCamera ();
1974-
2004+ ReadSettings (true );
19752005 updateVehicleVars ();
19762006 updateVehicleProperties ();
1977-
19782007 setupCustomCamera ();
1979-
1980- ReadSettings (true );
1981-
1982- setupCurrentCamera ();
19832008 }
19842009
19852010 updateTimers ();
0 commit comments