Refactor Collider base class to improve code sharing across collider shape types

This commit is contained in:
Wojtek Figat
2021-02-10 14:33:16 +01:00
parent 5cb2322270
commit 8bce445ab0
13 changed files with 154 additions and 351 deletions

View File

@@ -160,19 +160,13 @@ public:
/// </summary>
/// <param name="rigidBody">The rigid body.</param>
/// <returns><c>true</c> if this collider can be attached the specified rigid body; otherwise, <c>false</c>.</returns>
virtual bool CanAttach(RigidBody* rigidBody) const
{
return true;
}
virtual bool CanAttach(RigidBody* rigidBody) const;
/// <summary>
/// Determines whether this collider can be a trigger shape.
/// </summary>
/// <returns><c>true</c> if this collider can be trigger; otherwise, <c>false</c>.</returns>
virtual bool CanBeTrigger() const
{
return true;
}
virtual bool CanBeTrigger() const;
/// <summary>
/// Attaches collider to the specified rigid body.
@@ -198,20 +192,20 @@ protected:
virtual void UpdateBounds() = 0;
/// <summary>
/// Creates the collider shape.
/// Gets the collider shape geometry.
/// </summary>
virtual void CreateShape() = 0;
/// <param name="geometry">The output geometry.</param>
virtual void GetGeometry(PxGeometryHolder& geometry) = 0;
/// <summary>
/// Creates the collider shape from the given geometry.
/// Creates the collider shape.
/// </summary>
/// <param name="geometry">The geometry.</param>
void CreateShapeBase(const PxGeometry& geometry);
virtual void CreateShape();
/// <summary>
/// Updates the shape geometry.
/// </summary>
virtual void UpdateGeometry() = 0;
virtual void UpdateGeometry();
/// <summary>
/// Creates the static actor.
@@ -223,6 +217,10 @@ protected:
/// </summary>
void RemoveStaticActor();
#if USE_EDITOR
virtual void DrawPhysicsDebug(RenderView& view);
#endif
private:
void OnMaterialChanged();
@@ -237,6 +235,10 @@ public:
protected:
// [PhysicsColliderActor]
#if USE_EDITOR
void OnEnable() override;
void OnDisable() override;
#endif
void BeginPlay(SceneBeginData* data) override;
void EndPlay() override;
void OnActiveInTreeChanged() override;