Revert "Merge branch 'Tryibion-rot-colliders'" (#1141)
This reverts commit73cb792989, reversing changes made tob4fe3a44aa.
This commit is contained in:
@@ -6,9 +6,7 @@ CapsuleCollider::CapsuleCollider(const SpawnParams& params)
|
||||
: Collider(params)
|
||||
, _radius(20.0f)
|
||||
, _height(100.0f)
|
||||
, _direction(ColliderOrientationDirection::YAxis)
|
||||
{
|
||||
SetColliderDirection(_direction);
|
||||
}
|
||||
|
||||
void CapsuleCollider::SetRadius(const float value)
|
||||
@@ -33,24 +31,6 @@ void CapsuleCollider::SetHeight(const float value)
|
||||
UpdateBounds();
|
||||
}
|
||||
|
||||
void CapsuleCollider::SetColliderDirection(ColliderOrientationDirection value)
|
||||
{
|
||||
_direction = value;
|
||||
switch (value)
|
||||
{
|
||||
case ColliderOrientationDirection::XAxis:
|
||||
SetColliderOrientation(Quaternion::Identity);
|
||||
break;
|
||||
case ColliderOrientationDirection::YAxis:
|
||||
SetColliderOrientation(Quaternion::Euler(0, 0, 90));
|
||||
break;
|
||||
case ColliderOrientationDirection::ZAxis:
|
||||
SetColliderOrientation(Quaternion::Euler(0, 90, 0));
|
||||
break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
#include "Engine/Debug/DebugDraw.h"
|
||||
@@ -61,10 +41,8 @@ void CapsuleCollider::DrawPhysicsDebug(RenderView& view)
|
||||
const BoundingSphere sphere(_sphere.Center - view.Origin, _sphere.Radius);
|
||||
if (!view.CullingFrustum.Intersects(sphere))
|
||||
return;
|
||||
Quaternion collRot;
|
||||
Quaternion::Multiply( _colliderOrientation, Quaternion::Euler(0, 90, 0), collRot);
|
||||
Quaternion rotation;
|
||||
Quaternion::Multiply(_transform.Orientation, collRot, rotation);
|
||||
Quaternion::Multiply(_transform.Orientation, Quaternion::Euler(0, 90, 0), rotation);
|
||||
const float scaling = _cachedScale.GetAbsolute().MaxValue();
|
||||
const float minSize = 0.001f;
|
||||
const float radius = Math::Max(Math::Abs(_radius) * scaling, minSize);
|
||||
@@ -77,10 +55,8 @@ void CapsuleCollider::DrawPhysicsDebug(RenderView& view)
|
||||
|
||||
void CapsuleCollider::OnDebugDrawSelected()
|
||||
{
|
||||
Quaternion collRot;
|
||||
Quaternion::Multiply( _colliderOrientation, Quaternion::Euler(0, 90, 0), collRot);
|
||||
Quaternion rotation;
|
||||
Quaternion::Multiply(_transform.Orientation, collRot, rotation);
|
||||
Quaternion::Multiply(_transform.Orientation, Quaternion::Euler(0, 90, 0), rotation);
|
||||
const float scaling = _cachedScale.GetAbsolute().MaxValue();
|
||||
const float minSize = 0.001f;
|
||||
const float radius = Math::Max(Math::Abs(_radius) * scaling, minSize);
|
||||
@@ -109,11 +85,7 @@ void CapsuleCollider::UpdateBounds()
|
||||
// Cache bounds
|
||||
const float radiusTwice = _radius * 2.0f;
|
||||
OrientedBoundingBox::CreateCentered(_center, Vector3(_height + radiusTwice, radiusTwice, radiusTwice), _orientedBox);
|
||||
Transform transform = _transform;
|
||||
Quaternion rot;
|
||||
Quaternion::Multiply(transform.Orientation, _colliderOrientation, rot);
|
||||
transform.Orientation = rot;
|
||||
_orientedBox.Transform(transform);
|
||||
_orientedBox.Transform(_transform);
|
||||
_orientedBox.GetBoundingBox(_box);
|
||||
BoundingSphere::FromBox(_box, _sphere);
|
||||
}
|
||||
|
||||
@@ -5,27 +5,6 @@
|
||||
#include "Collider.h"
|
||||
#include "Engine/Core/Math/OrientedBoundingBox.h"
|
||||
|
||||
/// <summary>
|
||||
/// The collider orientation direction.
|
||||
/// </summary>
|
||||
API_ENUM() enum class ColliderOrientationDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// Orient to the X-Axis.
|
||||
/// </summary>
|
||||
XAxis,
|
||||
|
||||
/// <summary>
|
||||
/// Orient to the Y-Axis.
|
||||
/// </summary>
|
||||
YAxis,
|
||||
|
||||
/// <summary>
|
||||
/// Orient to the Z-Axis.
|
||||
/// </summary>
|
||||
ZAxis
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// A capsule-shaped primitive collider.
|
||||
/// </summary>
|
||||
@@ -40,7 +19,6 @@ private:
|
||||
float _radius;
|
||||
float _height;
|
||||
OrientedBoundingBox _orientedBox;
|
||||
ColliderOrientationDirection _direction;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
@@ -75,20 +53,6 @@ public:
|
||||
/// <remarks>The capsule height will be scaled by the actor's world scale.</remarks>
|
||||
API_PROPERTY() void SetHeight(float value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the orientation direction of the capsule collider.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(111), DefaultValue(typeof(ColliderOrientationDirection), \"YAxis\"), EditorDisplay(\"Collider\")")
|
||||
FORCE_INLINE ColliderOrientationDirection GetColliderDirection() const
|
||||
{
|
||||
return _direction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the orientation direction of the capsule collider.
|
||||
/// </summary>
|
||||
API_PROPERTY() void SetColliderDirection(ColliderOrientationDirection value);
|
||||
|
||||
public:
|
||||
// [Collider]
|
||||
#if USE_EDITOR
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
Collider::Collider(const SpawnParams& params)
|
||||
: PhysicsColliderActor(params)
|
||||
, _center(Float3::Zero)
|
||||
, _colliderOrientation(Quaternion::Identity)
|
||||
, _isTrigger(false)
|
||||
, _shape(nullptr)
|
||||
, _staticActor(nullptr)
|
||||
@@ -45,36 +44,11 @@ void Collider::SetCenter(const Vector3& value)
|
||||
_center = value;
|
||||
if (_staticActor)
|
||||
{
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(Quaternion::Identity, _colliderOrientation, result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, _center, result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, _center, Quaternion::Identity);
|
||||
}
|
||||
else if (const RigidBody* rigidBody = GetAttachedRigidBody())
|
||||
{
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(_localTransform.Orientation, _colliderOrientation, result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, (_localTransform.Translation + result * _center) * rigidBody->GetScale(), result);
|
||||
}
|
||||
UpdateBounds();
|
||||
}
|
||||
|
||||
void Collider::SetColliderOrientation(const Quaternion& value)
|
||||
{
|
||||
|
||||
if (Quaternion::NearEqual(value, _colliderOrientation))
|
||||
return;
|
||||
_colliderOrientation = value;
|
||||
if (_staticActor)
|
||||
{
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(Quaternion::Identity, _colliderOrientation, result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, _center, result);
|
||||
}
|
||||
else if (const RigidBody* rigidBody = GetAttachedRigidBody())
|
||||
{
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(_localTransform.Orientation, _colliderOrientation, result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, (_localTransform.Translation + result * _center) * rigidBody->GetScale(), result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, (_localTransform.Translation + _localTransform.Orientation * _center) * rigidBody->GetScale(), _localTransform.Orientation);
|
||||
}
|
||||
UpdateBounds();
|
||||
}
|
||||
@@ -194,10 +168,8 @@ void Collider::Attach(RigidBody* rigidBody)
|
||||
|
||||
// Attach
|
||||
PhysicsBackend::AttachShape(_shape, rigidBody->GetPhysicsActor());
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(_localTransform.Orientation, _colliderOrientation, result);
|
||||
_cachedLocalPosePos = (_localTransform.Translation + result * _center) * rigidBody->GetScale();
|
||||
_cachedLocalPoseRot = result;
|
||||
_cachedLocalPosePos = (_localTransform.Translation + _localTransform.Orientation * _center) * rigidBody->GetScale();
|
||||
_cachedLocalPoseRot = _localTransform.Orientation;
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, _cachedLocalPosePos, _cachedLocalPoseRot);
|
||||
if (rigidBody->IsDuringPlay())
|
||||
{
|
||||
@@ -289,9 +261,7 @@ void Collider::CreateStaticActor()
|
||||
_staticActor = PhysicsBackend::CreateRigidStaticActor(nullptr, _transform.Translation, _transform.Orientation, scene);
|
||||
|
||||
// Reset local pos of the shape and link it to the actor
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(Quaternion::Identity, _colliderOrientation, result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, _center, result);
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, _center, Quaternion::Identity);
|
||||
PhysicsBackend::AttachShape(_shape, _staticActor);
|
||||
|
||||
PhysicsBackend::AddSceneActor(scene, _staticActor);
|
||||
@@ -434,19 +404,15 @@ void Collider::OnTransformChanged()
|
||||
|
||||
if (_staticActor)
|
||||
{
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(_localTransform.Orientation, _colliderOrientation, result);
|
||||
PhysicsBackend::SetRigidActorPose(_staticActor, _transform.Translation, result);
|
||||
PhysicsBackend::SetRigidActorPose(_staticActor, _transform.Translation, _transform.Orientation);
|
||||
}
|
||||
else if (const RigidBody* rigidBody = GetAttachedRigidBody())
|
||||
{
|
||||
Quaternion result;
|
||||
Quaternion::Multiply(_localTransform.Orientation, _colliderOrientation, result);
|
||||
const Vector3 localPosePos = (_localTransform.Translation + result * _center) * rigidBody->GetScale();
|
||||
if (_cachedLocalPosePos != localPosePos || _cachedLocalPoseRot != result)
|
||||
const Vector3 localPosePos = (_localTransform.Translation + _localTransform.Orientation * _center) * rigidBody->GetScale();
|
||||
if (_cachedLocalPosePos != localPosePos || _cachedLocalPoseRot != _localTransform.Orientation)
|
||||
{
|
||||
_cachedLocalPosePos = localPosePos;
|
||||
_cachedLocalPoseRot = result;
|
||||
_cachedLocalPoseRot = _localTransform.Orientation;
|
||||
PhysicsBackend::SetShapeLocalPose(_shape, localPosePos, _cachedLocalPoseRot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ API_CLASS(Abstract) class FLAXENGINE_API Collider : public PhysicsColliderActor
|
||||
DECLARE_SCENE_OBJECT_ABSTRACT(Collider);
|
||||
protected:
|
||||
Vector3 _center;
|
||||
Quaternion _colliderOrientation;
|
||||
bool _isTrigger;
|
||||
void* _shape;
|
||||
void* _staticActor;
|
||||
@@ -78,19 +77,6 @@ public:
|
||||
/// </summary>
|
||||
API_PROPERTY() void SetContactOffset(float value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collider's orientation, measured in the object's local space.
|
||||
/// </summary>
|
||||
FORCE_INLINE Quaternion GetColliderOrientation() const
|
||||
{
|
||||
return _colliderOrientation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the orientation of the collider, measured in the object's local space.
|
||||
/// </summary>
|
||||
void SetColliderOrientation(const Quaternion& value);
|
||||
|
||||
/// <summary>
|
||||
/// The physical material used to define the collider physical properties.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user