1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsPhysXPrerequisites.h"
6#include "Physics/BsPhysicsCommon.h"
7#include "Physics/BsFCollider.h"
8#include "PxRigidStatic.h"
9
10namespace bs
11{
12 /** @addtogroup PhysX
13 * @{
14 */
15
16 /** PhysX implementation of FCollider. */
17 class FPhysXCollider : public FCollider
18 {
19 public:
20 explicit FPhysXCollider(physx::PxScene* scene, physx::PxShape* shape);
21 ~FPhysXCollider();
22
23 /** @copydoc FCollider::getPosition */
24 Vector3 getPosition() const override;
25
26 /** @copydoc FCollider::getRotation */
27 Quaternion getRotation() const override;
28
29 /** @copydoc FCollider::setTransform */
30 void setTransform(const Vector3& pos, const Quaternion& rotation) override;
31
32 /** @copydoc FCollider::setIsTrigger */
33 void setIsTrigger(bool value) override;
34
35 /** @copydoc FCollider::getIsTrigger */
36 bool getIsTrigger() const override;
37
38 /** @copydoc FCollider::setIsStatic */
39 void setIsStatic(bool value) override;
40
41 /** @copydoc FCollider::getIsStatic */
42 bool getIsStatic() const override;
43
44 /** @copydoc FCollider::setContactOffset */
45 void setContactOffset(float value) override;
46
47 /** @copydoc FCollider::getContactOffset */
48 float getContactOffset() const override;
49
50 /** @copydoc FCollider::setRestOffset */
51 void setRestOffset(float value) override;
52
53 /** @copydoc FCollider::getRestOffset */
54 float getRestOffset() const override;
55
56 /** @copydoc FCollider::setMaterial */
57 void setMaterial(const HPhysicsMaterial& material) override;
58
59 /** @copydoc FCollider::getLayer */
60 UINT64 getLayer() const override;
61
62 /** @copydoc FCollider::setLayer */
63 void setLayer(UINT64 layer) override;
64
65 /** @copydoc FCollider::getCollisionReportMode */
66 CollisionReportMode getCollisionReportMode() const override;
67
68 /** @copydoc FCollider::setCollisionReportMode */
69 void setCollisionReportMode(CollisionReportMode mode) override;
70
71 /** @copydoc FCollider::_setCCD */
72 void _setCCD(bool enabled) override;
73
74 /** Gets the internal PhysX shape that represents the collider. */
75 physx::PxShape* _getShape() const { return mShape; }
76
77 /**
78 * Assigns a new shape the the collider. Old shape is released, and the new shape inherits any properties from the
79 * old shape, including parent, transform, flags and other.
80 */
81 void _setShape(physx::PxShape* shape);
82 protected:
83 /** Updates shape filter data from stored values. */
84 void updateFilter();
85
86 physx::PxScene* mScene = nullptr;
87 physx::PxShape* mShape = nullptr;
88 physx::PxRigidStatic* mStaticBody = nullptr;
89 bool mIsTrigger = false;
90 bool mIsStatic = true;
91 UINT64 mLayer = 1;
92 bool mCCD = false;
93 CollisionReportMode mCollisionReportMode = CollisionReportMode::None;
94 };
95
96 /** @} */
97}