mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-13 15:16:28 +00:00
Node rotation/scale now transforms correctly around the pivot point
This commit is contained in:
@@ -291,13 +291,34 @@ void CSceneNode::Rotate(const CQuaternion& rkRotation, ETransformSpace Transform
|
||||
MarkTransformChanged();
|
||||
}
|
||||
|
||||
void CSceneNode::Rotate(const CQuaternion& rkRotation, const CVector3f& rkPivot, const CQuaternion& rkPivotRotation, ETransformSpace TransformSpace)
|
||||
{
|
||||
Rotate(rkRotation, TransformSpace);
|
||||
|
||||
switch (TransformSpace)
|
||||
{
|
||||
case eWorldTransform:
|
||||
mPosition = rkPivot + (rkRotation * (mPosition - rkPivot));
|
||||
break;
|
||||
case eLocalTransform:
|
||||
mPosition = rkPivot + ((rkPivotRotation * rkRotation * rkPivotRotation.Inverse()) * (mPosition - rkPivot));
|
||||
break;
|
||||
}
|
||||
MarkTransformChanged();
|
||||
}
|
||||
|
||||
void CSceneNode::Scale(const CVector3f& rkScale)
|
||||
{
|
||||
// No support for stretch/skew world-space scaling; local only
|
||||
mScale *= rkScale;
|
||||
MarkTransformChanged();
|
||||
}
|
||||
|
||||
void CSceneNode::Scale(const CVector3f& rkScale, const CVector3f& rkPivot)
|
||||
{
|
||||
mPosition = rkPivot + ((mPosition - rkPivot) * rkScale * rkScale);
|
||||
Scale(rkScale);
|
||||
}
|
||||
|
||||
void CSceneNode::ForceRecalculateTransform() const
|
||||
{
|
||||
_mCachedTransform = CTransform4f::skIdentity;
|
||||
|
||||
@@ -86,7 +86,9 @@ public:
|
||||
// Transform
|
||||
void Translate(const CVector3f& rkTranslation, ETransformSpace TransformSpace);
|
||||
void Rotate(const CQuaternion& rkRotation, ETransformSpace TransformSpace);
|
||||
void Rotate(const CQuaternion& rkRotation, const CVector3f& rkPivot, const CQuaternion& rkPivotRotation, ETransformSpace TransformSpace);
|
||||
void Scale(const CVector3f& rkScale);
|
||||
void Scale(const CVector3f& rkScale, const CVector3f& rkPivot);
|
||||
const CTransform4f& Transform() const;
|
||||
protected:
|
||||
void MarkTransformChanged() const;
|
||||
|
||||
Reference in New Issue
Block a user