mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
perf: PredictedRigidbody MoveTowardsCustom: only calculate distance factor once
This commit is contained in:
parent
8705a9b0c2
commit
7cf0b884a6
@ -364,15 +364,18 @@ static Vector3 MoveTowardsCustom(
|
||||
if (_sqrDistance == 0.0 || maxDistanceDelta >= 0.0 && _sqrDistance <= maxDistanceDelta * maxDistanceDelta)
|
||||
return target;
|
||||
|
||||
float distFactor = maxDistanceDelta / _distance; // unlike Vector3.MoveTowards, we only calculate this once
|
||||
return new Vector3(
|
||||
current.x + (_delta.x / _distance) * maxDistanceDelta,
|
||||
current.y + (_delta.y / _distance) * maxDistanceDelta,
|
||||
current.z + (_delta.z / _distance) * maxDistanceDelta);
|
||||
// current.x + (_delta.x / _distance) * maxDistanceDelta,
|
||||
// current.y + (_delta.y / _distance) * maxDistanceDelta,
|
||||
// current.z + (_delta.z / _distance) * maxDistanceDelta);
|
||||
current.x + _delta.x * distFactor,
|
||||
current.y + _delta.y * distFactor,
|
||||
current.z + _delta.z * distFactor);
|
||||
}
|
||||
|
||||
Vector3 newPosition = MoveTowardsCustom(currentPosition, physicsPosition, delta, sqrDistance, distance, positionStep * deltaTime);
|
||||
|
||||
|
||||
// smoothly interpolate to the target rotation.
|
||||
// Quaternion.RotateTowards doesn't seem to work at all, so let's use SLerp.
|
||||
// Quaternions always need to be normalized in order to be a valid rotation after operations
|
||||
|
Loading…
Reference in New Issue
Block a user