BodyReference.GetVelocityForOffset() is local or world? #336
-
Hello, I'm trying to find a way to use It appears the param info is cut off and doesn't specify: /// <summary>
/// Computes the velocity of an offset point attached to the body.
/// </summary>
/// <param name="offset">Offset from the body's center to </param>
/// <param name="velocity">Effective velocity of the point if it were attached to the body.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void GetVelocityForOffset(Vector3 offset, out Vector3 velocity)
{
velocity = Velocity.Linear + Vector3.Cross(Velocity.Angular, offset);
} I'm assuming it is world offset, but it looks like local offset was working for me earlier. If it should be world offset, then perhaps I have a bug since I was using local offset? (It'd explain some behavior I saw.) It appears the documentation for one of the /// <summary>
/// Applies an impulse to a body at the given world space position. Does not modify activity states.
/// </summary>
/// <param name="impulse">Impulse to apply to the body.</param>
/// <param name="impulseOffset">World space offset to apply the impulse at.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void ApplyImpulse(Vector3 impulse, Vector3 impulseOffset)
{
ref var location = ref MemoryLocation;
ApplyImpulse(Bodies.Sets[location.SetIndex], location.Index, impulse, impulseOffset);
} It says it applies at a world space position but it should be a world offset. I tested it and the other overloads also specify it is a world offset, not world position. This makes porting from Unity quite confusing even if you aren't a novice. Here's my code example below: public void Bepu(in Transform3D bepuTra, ref BodyReference br)
{
Vector3 worldOffset = _curGlobalPos - bepuTra.Origin; // Use this instead?
br.GetVelocityForOffset(WheelLocalOfs.ToVector3(), out System.Numerics.Vector3 worldVelAtPoint);
// ...
br.ApplyImpulse(_upForce * up.ToVector3(), worldOffset.ToVector3());
} public void Unity()
{
WorldVel = _rb.GetPointVelocity(transform.position);
// ...
_rb.AddForceAtPosition(_upForce * up, transform.position, ForceMode.Impulse);
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
All world offsets. Typos/comments fixed, thanks for the report! |
Beta Was this translation helpful? Give feedback.
All world offsets. Typos/comments fixed, thanks for the report!