BsPhysXPrerequisites.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "foundation\PxVec3.h"
  6. #include "foundation\PxVec4.h"
  7. #include "foundation\PxQuat.h"
  8. #include "foundation\PxTransform.h"
  9. namespace BansheeEngine
  10. {
  11. #if (BS_PLATFORM == BS_PLATFORM_WIN32) && !defined(BS_STATIC_LIB)
  12. # ifdef BS_PHYSX_EXPORTS
  13. # define BS_PHYSX_EXPORT __declspec(dllexport)
  14. # else
  15. # if defined( __MINGW32__ )
  16. # define BS_PHYSX_EXPORT
  17. # else
  18. # define BS_PHYSX_EXPORT __declspec(dllimport)
  19. # endif
  20. # endif
  21. #else
  22. # define BS_PHYSX_EXPORT
  23. #endif
  24. /** @addtogroup Plugins
  25. * @{
  26. */
  27. /** @defgroup PhysX BansheePhysX
  28. * NVIDIA %PhysX implementation of Banshee's physics.
  29. * @{
  30. */
  31. /** @cond RTTI */
  32. /** @defgroup RTTI-Impl-PhysX RTTI types
  33. * Types containing RTTI for specific classes.
  34. */
  35. /** @endcond */
  36. /** @} */
  37. /** @} */
  38. class PhysXRigidbody;
  39. class PhsyXMaterial;
  40. class FPhysXCollider;
  41. /** @addtogroup PhysX
  42. * @{
  43. */
  44. /** Type IDs used by the RTTI system for the PhysX library. */
  45. enum TypeID_BansheeEditor
  46. {
  47. TID_FPhysXMesh = 100000,
  48. };
  49. /** Converts a Banshee vector to a PhysX vector. */
  50. inline const physx::PxVec3& toPxVector(const Vector3& input)
  51. {
  52. return *(physx::PxVec3*)&input;
  53. }
  54. /** Converts a Banshee vector to a PhysX vector. */
  55. inline const physx::PxVec4& toPxVector(const Vector4& input)
  56. {
  57. return *(physx::PxVec4*)&input;
  58. }
  59. /** Converts a Banshee quaternion to a PhysX quaternion. */
  60. inline const physx::PxQuat& toPxQuaternion(const Quaternion& input)
  61. {
  62. return *(physx::PxQuat*)&input;
  63. }
  64. /** Converts a Banshee position/rotation pair to a PhysX transform. */
  65. inline physx::PxTransform toPxTransform(const Vector3& pos, const Quaternion& rot)
  66. {
  67. return physx::PxTransform(toPxVector(pos), toPxQuaternion(rot));
  68. }
  69. /** Converts a PhysX vector to a Banshee vector. */
  70. inline const Vector3& fromPxVector(const physx::PxVec3& input)
  71. {
  72. return *(Vector3*)&input;
  73. }
  74. /** Converts a PhysX vector to a Banshee vector. */
  75. inline const Vector4& fromPxVector(const physx::PxVec4& input)
  76. {
  77. return *(Vector4*)&input;
  78. }
  79. /** Converts a PhysX quaternion to a Banshee quaternion. */
  80. inline const Quaternion& fromPxQuaternion(const physx::PxQuat& input)
  81. {
  82. return *(Quaternion*)&input;
  83. }
  84. /** Flags used on PhysX shape filters. */
  85. enum class PhysXObjectFilterFlag
  86. {
  87. NoReport = 1 << 0, /**< Don't report collision events. */
  88. ReportBasic = 1 << 1, /**< Report start/begin collision events. */
  89. ReportAll = 1 << 2, /**< Report start/begin, as well as persistant collision events. */
  90. CCD = 1 << 3 /**< Use continous collision detection for this shape. */
  91. };
  92. /** @copydoc PhysXObjectFilterFlag */
  93. typedef Flags<PhysXObjectFilterFlag> PhysXObjectFilterFlags;
  94. BS_FLAGS_OPERATORS(PhysXObjectFilterFlag)
  95. /** @} */
  96. }