public unsafe static bool UpdateInterpolation(float t, float fixeddelta) { while (IsSwapping) { } oldState.state.CopyTo(interpolatedState.state); RigidbodyState *iptr = (RigidbodyState *)interpolatedState.state.ptr; RigidbodyState *nptr = (RigidbodyState *)newState.state.ptr; for (int i = 0; i < interpolatedState.state.length; i++) { if ((*nptr).IsAssigned) { Vector3 worldposold = (*iptr).transform.position + Vector3.Transform((*iptr).massOffset, (*iptr).transform.rotation); Vector3 worldposnew = (*nptr).transform.position + Vector3.Transform((*nptr).massOffset, (*nptr).transform.rotation); Vector3 worldposi = Hermite(worldposold, (*iptr).linearVelocity * fixeddelta, worldposnew, (*nptr).linearVelocity * fixeddelta, t); (*iptr).transform.rotation = Quaternion.Lerp((*iptr).transform.rotation, (*nptr).transform.rotation, t); (*iptr).transform.position = worldposi - Vector3.Transform((*iptr).massOffset, (*iptr).transform.rotation); } iptr++; nptr++; if (IsSwapping) { return(false); } } return(true); }
public unsafe Span <RigidbodyState> GetRef(uint index) { RigidbodyState *ptr = (RigidbodyState *)state.ptr; if (index >= state.length) { throw new IndexOutOfRangeException("Index " + index + " is out of bounds for physics state " + state.length); } ptr += index; return(new Span <RigidbodyState>(ptr, 1)); }