2
0

BsMeshCollider.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 "BsCollider.h"
  6. #include "BsIResourceListener.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Physics
  10. * @{
  11. */
  12. /** A collider represented by an arbitrary mesh. */
  13. class BS_CORE_EXPORT MeshCollider : public Collider, public IResourceListener
  14. {
  15. public:
  16. MeshCollider();
  17. /**
  18. * Sets a mesh that represents the collider geometry.
  19. *
  20. * @param[in] mesh Generic triangle mesh, or and convex mesh. Triangle meshes are not supported as triggers,
  21. * nor are they supported for colliders that are parts of a non-kinematic rigidbody.
  22. */
  23. void setMesh(const HPhysicsMesh& mesh) { mMesh = mesh; onMeshChanged(); markListenerResourcesDirty(); }
  24. /** Returns a mesh that represents the collider geometry. */
  25. HPhysicsMesh getMesh() const { return mMesh; }
  26. /**
  27. * Creates a new mesh collider.
  28. *
  29. * @param[in] position Position of the collider.
  30. * @param[in] rotation Rotation of the collider.
  31. */
  32. static SPtr<MeshCollider> create(const Vector3& position = Vector3::ZERO,
  33. const Quaternion& rotation = Quaternion::IDENTITY);
  34. protected:
  35. /** @copydoc IResourceListener::getListenerResources */
  36. void getListenerResources(Vector<HResource>& resources) override;
  37. /** @copydoc IResourceListener::notifyResourceLoaded */
  38. void notifyResourceLoaded(const HResource& resource) override;
  39. /** @copydoc IResourceListener::notifyResourceChanged */
  40. void notifyResourceChanged(const HResource& resource) override;
  41. virtual void onMeshChanged() { }
  42. HPhysicsMesh mMesh;
  43. };
  44. /** @} */
  45. }