BsPhysicsMesh.h 3.2 KB

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