Add Joint.SetJointOrientation utility
This commit is contained in:
@@ -101,6 +101,28 @@ void Joint::SetJointLocation(const Vector3& location)
|
||||
}
|
||||
}
|
||||
|
||||
FORCE_INLINE Quaternion WorldToLocal(const Quaternion& world, const Quaternion& orientation)
|
||||
{
|
||||
Quaternion rot;
|
||||
const Quaternion invRotation = world.Conjugated();
|
||||
Quaternion::Multiply(invRotation, orientation, rot);
|
||||
rot.Normalize();
|
||||
return rot;
|
||||
}
|
||||
|
||||
void Joint::SetJointOrientation(const Quaternion& orientation)
|
||||
{
|
||||
if (GetParent())
|
||||
{
|
||||
SetLocalOrientation(WorldToLocal(GetParent()->GetOrientation(), orientation));
|
||||
}
|
||||
if (Target)
|
||||
{
|
||||
//SetTargetAnchor(Target->GetTransform().WorldToLocal(orientation));
|
||||
SetTargetAnchorRotation(WorldToLocal(Target->GetOrientation(), orientation));
|
||||
}
|
||||
}
|
||||
|
||||
void Joint::GetCurrentForce(Vector3& linear, Vector3& angular) const
|
||||
{
|
||||
if (_joint && _joint->getConstraint())
|
||||
|
||||
@@ -135,6 +135,13 @@ public:
|
||||
/// <param name="location">The joint location to set (world-space).</param>
|
||||
API_FUNCTION() void SetJointLocation(const Vector3& location);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the orientation of the joint by automatically computing local orientation and target anchor orientation to orient a joint at the given rotation (world-space).
|
||||
/// </summary>
|
||||
/// <remarks>Use this utility to automatically rotate joint at the given location after setting up joint parent and target.</remarks>
|
||||
/// <param name="orientation">The joint orientation to set (world-space).</param>
|
||||
API_FUNCTION() void SetJointOrientation(const Quaternion& orientation);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current force applied by the solver to maintain all constraints.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user