BsPhysicsMesh.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /**
  12. * Represents a physics mesh that can be used for physics MeshCollider%s. Physics mesh can be a generic triangle mesh
  13. * or a convex mesh. Convex meshes are limited to 255 faces.
  14. */
  15. class BS_CORE_EXPORT PhysicsMesh : public Resource
  16. {
  17. public:
  18. PhysicsMesh(const MeshDataPtr& meshData, PhysicsMeshType type);
  19. virtual ~PhysicsMesh() { }
  20. /** Returns the type of the physics mesh. */
  21. PhysicsMeshType getType() const { return mType; }
  22. /** Returns the mesh's indices and vertices. */
  23. virtual MeshDataPtr getMeshData() const = 0;
  24. /**
  25. * Creates a new physics mesh.
  26. *
  27. * @param[in] meshData Index and vertices of the mesh data.
  28. * @param[in] type Type of the mesh. If convex the provided mesh geometry will be converted into a convex
  29. * mesh (that might not be the same as the provided mesh data).
  30. */
  31. static HPhysicsMesh create(const MeshDataPtr& meshData, PhysicsMeshType type = PhysicsMeshType::Convex);
  32. /** @cond INTERNAL */
  33. /**
  34. * @copydoc create()
  35. *
  36. * For internal use. Requires manual initialization after creation.
  37. */
  38. static PhysicsMeshPtr _createPtr(const MeshDataPtr& meshData, PhysicsMeshType type);
  39. /** @endcond */
  40. protected:
  41. /** @copydoc Resource::initialize() */
  42. void initialize() override;
  43. PhysicsMeshType mType;
  44. MeshDataPtr mInitMeshData; // Transient, only used during initalization
  45. /************************************************************************/
  46. /* SERIALIZATION */
  47. /************************************************************************/
  48. public:
  49. friend class PhysicsMeshRTTI;
  50. static RTTITypeBase* getRTTIStatic();
  51. RTTITypeBase* getRTTI() const override;
  52. };
  53. /** @} */
  54. }