Small improvements to FirstScene's camera
Former-commit-id: 80545964ee9ab8693f43992b4c4a2610e93e78c9
This commit is contained in:
parent
880c2aa32c
commit
a5fb0c804f
|
|
@ -391,7 +391,7 @@ NzVector3f DampedString(const NzVector3f& currentPos, const NzVector3f& targetPo
|
||||||
float displacementLength = displacement.GetLength();
|
float displacementLength = displacement.GetLength();
|
||||||
|
|
||||||
// Stops small position fluctuations (integration errors probably - since only using euler)
|
// Stops small position fluctuations (integration errors probably - since only using euler)
|
||||||
if (displacementLength < 0.0001f)
|
if (NzNumberEquals(displacementLength, 0.f))
|
||||||
return currentPos;
|
return currentPos;
|
||||||
|
|
||||||
float invDisplacementLength = 1.f/displacementLength;
|
float invDisplacementLength = 1.f/displacementLength;
|
||||||
|
|
@ -403,7 +403,7 @@ NzVector3f DampedString(const NzVector3f& currentPos, const NzVector3f& targetPo
|
||||||
|
|
||||||
// Normalise the displacement and scale by the spring magnitude
|
// Normalise the displacement and scale by the spring magnitude
|
||||||
// and the amount of time passed
|
// and the amount of time passed
|
||||||
float scalar = invDisplacementLength * springMagitude * frametime;
|
float scalar = std::min(invDisplacementLength * springMagitude * frametime, 1.f);
|
||||||
displacement *= scalar;
|
displacement *= scalar;
|
||||||
|
|
||||||
// move the camera a bit towards the target
|
// move the camera a bit towards the target
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue