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 "BsCorePrerequisites.h"
6#include "foundation/PxVec3.h"
7#include "foundation/PxVec4.h"
8#include "foundation/PxQuat.h"
9#include "foundation/PxTransform.h"
10
11namespace bs
12{
13/** @addtogroup Plugins
14 * @{
15 */
16
17/** @defgroup PhysX bsfPhysX
18 * NVIDIA %PhysX implementation of framework's physics.
19 * @{
20 */
21
22/** @cond RTTI */
23/** @defgroup RTTI-Impl-PhysX RTTI types
24 * Types containing RTTI for specific classes.
25 */
26/** @endcond */
27
28/** @} */
29/** @} */
30
31 class PhysXRigidbody;
32 class PhsyXMaterial;
33 class FPhysXCollider;
34
35 /** @addtogroup PhysX
36 * @{
37 */
38
39 /** Type IDs used by the RTTI system for the PhysX library. */
40 enum TypeID_PhysX
41 {
42 TID_FPhysXMesh = 100000,
43 };
44
45 /** Converts a framework vector to a PhysX vector. */
46 inline const physx::PxVec3& toPxVector(const Vector3& input)
47 {
48 return *(physx::PxVec3*)&input;
49 }
50
51 /** Converts a framework vector to a PhysX vector. */
52 inline const physx::PxVec4& toPxVector(const Vector4& input)
53 {
54 return *(physx::PxVec4*)&input;
55 }
56
57 /** Converts a framework quaternion to a PhysX quaternion. */
58 inline const physx::PxQuat& toPxQuaternion(const Quaternion& input)
59 {
60 return *(physx::PxQuat*)&input;
61 }
62
63 /** Converts a framework position/rotation pair to a PhysX transform. */
64 inline physx::PxTransform toPxTransform(const Vector3& pos, const Quaternion& rot)
65 {
66 return physx::PxTransform(toPxVector(pos), toPxQuaternion(rot));
67 }
68
69 /** Converts a PhysX vector to framework's vector. */
70 inline const Vector3& fromPxVector(const physx::PxVec3& input)
71 {
72 return *(Vector3*)&input;
73 }
74
75 /** Converts a PhysX vector to framework's vector. */
76 inline const Vector4& fromPxVector(const physx::PxVec4& input)
77 {
78 return *(Vector4*)&input;
79 }
80
81 /** Converts a PhysX quaternion to framework's quaternion. */
82 inline const Quaternion& fromPxQuaternion(const physx::PxQuat& input)
83 {
84 return *(Quaternion*)&input;
85 }
86
87 /** Flags used on PhysX shape filters. */
88 enum class PhysXObjectFilterFlag
89 {
90 NoReport = 1 << 0, /**< Don't report collision events. */
91 ReportBasic = 1 << 1, /**< Report start/begin collision events. */
92 ReportAll = 1 << 2, /**< Report start/begin, as well as persistant collision events. */
93 CCD = 1 << 3 /**< Use continous collision detection for this shape. */
94 };
95
96 /** @copydoc PhysXObjectFilterFlag */
97 typedef Flags<PhysXObjectFilterFlag> PhysXObjectFilterFlags;
98 BS_FLAGS_OPERATORS(PhysXObjectFilterFlag)
99
100 /** @} */
101}