BsPhysicsMesh.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 "BsResource.h"
  6. namespace BansheeEngine
  7. {
  8. /** @addtogroup Physics
  9. * @{
  10. */
  11. class FPhysicsMesh;
  12. /**
  13. * Represents a physics mesh that can be used for physics MeshCollider%s. Physics mesh can be a generic triangle mesh
  14. * or a convex mesh. Convex meshes are limited to 255 faces.
  15. */
  16. class BS_CORE_EXPORT PhysicsMesh : public Resource
  17. {
  18. public:
  19. PhysicsMesh(const MeshDataPtr& meshData, PhysicsMeshType type);
  20. virtual ~PhysicsMesh() { }
  21. /** Returns the type of the physics mesh. */
  22. PhysicsMeshType getType() const;
  23. /** Returns the mesh's indices and vertices. */
  24. MeshDataPtr getMeshData() const;
  25. /**
  26. * Creates a new physics mesh.
  27. *
  28. * @param[in] meshData Index and vertices of the mesh data.
  29. * @param[in] type Type of the mesh. If convex the provided mesh geometry will be converted into a convex
  30. * mesh (that might not be the same as the provided mesh data).
  31. */
  32. static HPhysicsMesh create(const MeshDataPtr& meshData, PhysicsMeshType type = PhysicsMeshType::Convex);
  33. /** @cond INTERNAL */
  34. /** Returns the internal implementation of the physics mesh. */
  35. virtual FPhysicsMesh* _getInternal() { return mInternal.get(); }
  36. /**
  37. * @copydoc create()
  38. *
  39. * For internal use. Requires manual initialization after creation.
  40. */
  41. static PhysicsMeshPtr _createPtr(const MeshDataPtr& meshData, PhysicsMeshType type);
  42. /** @endcond */
  43. protected:
  44. /** @copydoc Resource::initialize() */
  45. void initialize() override;
  46. SPtr<FPhysicsMesh> mInternal;
  47. MeshDataPtr mInitMeshData; // Transient, only used during initalization
  48. PhysicsMeshType mType; // Transient, only used during initalization
  49. /************************************************************************/
  50. /* SERIALIZATION */
  51. /************************************************************************/
  52. public:
  53. friend class PhysicsMeshRTTI;
  54. static RTTITypeBase* getRTTIStatic();
  55. RTTITypeBase* getRTTI() const override;
  56. };
  57. /** @cond INTERNAL */
  58. /** Foundation that contains a specific implementation of a PhysicsMesh. */
  59. class BS_CORE_EXPORT FPhysicsMesh : public IReflectable
  60. {
  61. public:
  62. FPhysicsMesh(const MeshDataPtr& meshData, PhysicsMeshType type);
  63. virtual ~FPhysicsMesh();
  64. /** Returns the mesh's indices and vertices. */
  65. virtual MeshDataPtr getMeshData() const = 0;
  66. protected:
  67. friend class PhysicsMesh;
  68. PhysicsMeshType mType;
  69. /************************************************************************/
  70. /* SERIALIZATION */
  71. /************************************************************************/
  72. public:
  73. friend class FPhysicsMeshRTTI;
  74. static RTTITypeBase* getRTTIStatic();
  75. RTTITypeBase* getRTTI() const override;
  76. };
  77. /** @endcond */
  78. /** @} */
  79. }