Refactor Pre Rotation from spline model and spline collider into Pre Transform for more control

This commit is contained in:
Wojtek Figat
2021-02-15 22:09:05 +01:00
parent 81be73ad82
commit 0841f5b479
4 changed files with 32 additions and 32 deletions

View File

@@ -22,16 +22,16 @@ SplineCollider::SplineCollider(const SpawnParams& params)
CollisionData.Loaded.Bind<SplineCollider, &SplineCollider::OnCollisionDataLoaded>(this);
}
Quaternion SplineCollider::GetPreRotation() const
Transform SplineCollider::GetPreTransform() const
{
return _preRotation;
return _preTransform;
}
void SplineCollider::SetPreRotation(const Quaternion& value)
void SplineCollider::SetPreTransform(const Transform& value)
{
if (_preRotation == value)
if (_preTransform == value)
return;
_preRotation = value;
_preTransform = value;
UpdateGeometry();
}
@@ -130,7 +130,7 @@ void SplineCollider::Serialize(SerializeStream& stream, const void* otherObj)
SERIALIZE_GET_OTHER_OBJ(SplineCollider);
SERIALIZE(CollisionData);
SERIALIZE_MEMBER(PreRotation, _preRotation)
SERIALIZE_MEMBER(PreTransform, _preTransform)
}
void SplineCollider::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
@@ -139,7 +139,7 @@ void SplineCollider::Deserialize(DeserializeStream& stream, ISerializeModifier*
Collider::Deserialize(stream, modifier);
DESERIALIZE(CollisionData);
DESERIALIZE_MEMBER(PreRotation, _preRotation);
DESERIALIZE_MEMBER(PreTransform, _preTransform);
}
void SplineCollider::OnParentChanged()
@@ -205,10 +205,10 @@ void SplineCollider::GetGeometry(PxGeometryHolder& geometry)
}
// Apply local mesh transformation
if (!_preRotation.IsIdentity())
if (!_preTransform.IsIdentity())
{
for (int32 i = 0; i < collisionVertices.Count(); i++)
collisionVertices[i] = Vector3::Transform(collisionVertices[i], _preRotation);
collisionVertices[i] = _preTransform.LocalToWorld(collisionVertices[i]);
}
// Find collision geometry local bounds

View File

@@ -21,7 +21,7 @@ private:
PxTriangleMesh* _triangleMesh = nullptr;
Array<Vector3> _vertexBuffer;
Array<int32> _indexBuffer;
Quaternion _preRotation = Quaternion::Identity;
Transform _preTransform = Transform::Identity;
public:
@@ -32,15 +32,15 @@ public:
AssetReference<CollisionData> CollisionData;
/// <summary>
/// Gets the rotation applied to the collision data model geometry before placing it over the spline. Can be used to change the way model goes over the spline.
/// Gets the transformation applied to the collision data model geometry before placing it over the spline. Can be used to change the way model goes over the spline.
/// </summary>
API_PROPERTY(Attributes="EditorOrder(101), EditorDisplay(\"Collider\")")
Quaternion GetPreRotation() const;
Transform GetPreTransform() const;
/// <summary>
/// Sets the rotation applied to the collision data model geometry before placing it over the spline. Can be used to change the way model goes over the spline.
/// Sets the transformation applied to the collision data model geometry before placing it over the spline. Can be used to change the way model goes over the spline.
/// </summary>
API_PROPERTY() void SetPreRotation(const Quaternion& value);
API_PROPERTY() void SetPreTransform(const Transform& value);
#if USE_EDITOR