BsPhysicsMesh.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /** @name Internal
  34. * @{
  35. */
  36. /** Returns the internal implementation of the physics mesh. */
  37. virtual FPhysicsMesh* _getInternal() { return mInternal.get(); }
  38. /**
  39. * @copydoc create()
  40. *
  41. * For internal use. Requires manual initialization after creation.
  42. */
  43. static PhysicsMeshPtr _createPtr(const MeshDataPtr& meshData, PhysicsMeshType type);
  44. /** @} */
  45. protected:
  46. /** @copydoc Resource::initialize() */
  47. void initialize() override;
  48. SPtr<FPhysicsMesh> mInternal;
  49. MeshDataPtr mInitMeshData; // Transient, only used during initalization
  50. PhysicsMeshType mType; // Transient, only used during initalization
  51. /************************************************************************/
  52. /* SERIALIZATION */
  53. /************************************************************************/
  54. public:
  55. friend class PhysicsMeshRTTI;
  56. static RTTITypeBase* getRTTIStatic();
  57. RTTITypeBase* getRTTI() const override;
  58. };
  59. /** @} */
  60. /** @addtogroup Physics-Internal
  61. * @{
  62. */
  63. /** Foundation that contains a specific implementation of a PhysicsMesh. */
  64. class BS_CORE_EXPORT FPhysicsMesh : public IReflectable
  65. {
  66. public:
  67. FPhysicsMesh(const MeshDataPtr& meshData, PhysicsMeshType type);
  68. virtual ~FPhysicsMesh();
  69. /** Returns the mesh's indices and vertices. */
  70. virtual MeshDataPtr getMeshData() const = 0;
  71. protected:
  72. friend class PhysicsMesh;
  73. PhysicsMeshType mType;
  74. /************************************************************************/
  75. /* SERIALIZATION */
  76. /************************************************************************/
  77. public:
  78. friend class FPhysicsMeshRTTI;
  79. static RTTITypeBase* getRTTIStatic();
  80. RTTITypeBase* getRTTI() const override;
  81. };
  82. /** @} */
  83. }