BsPhysicsMeshRTTI.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "BsRTTIType.h"
  6. #include "BsPhysicsMesh.h"
  7. #include "BsPhysics.h"
  8. namespace BansheeEngine
  9. {
  10. /** @cond RTTI */
  11. /** @addtogroup RTTI-Impl-Core
  12. * @{
  13. */
  14. class BS_CORE_EXPORT PhysicsMeshRTTI : public RTTIType<PhysicsMesh, Resource, PhysicsMeshRTTI>
  15. {
  16. private:
  17. BS_REFLPTR_MEMBER(mInternal)
  18. public:
  19. PhysicsMeshRTTI()
  20. {
  21. BS_ADD_REFLPTR_FIELD(mInternal, 0)
  22. }
  23. void onDeserializationEnded(IReflectable* obj) override
  24. {
  25. PhysicsMesh* mesh = static_cast<PhysicsMesh*>(obj);
  26. mesh->initialize();
  27. }
  28. const String& getRTTIName() override
  29. {
  30. static String name = "PhysicsMesh";
  31. return name;
  32. }
  33. UINT32 getRTTIId() override
  34. {
  35. return TID_PhysicsMesh;
  36. }
  37. SPtr<IReflectable> newRTTIObject() override
  38. {
  39. SPtr<PhysicsMesh> mesh = gPhysics().createMesh(nullptr, PhysicsMeshType::Convex);
  40. mesh->_setThisPtr(mesh);
  41. return mesh;
  42. }
  43. };
  44. class BS_CORE_EXPORT FPhysicsMeshRTTI : public RTTIType<FPhysicsMesh, IReflectable, FPhysicsMeshRTTI>
  45. {
  46. private:
  47. BS_PLAIN_MEMBER(mType)
  48. public:
  49. FPhysicsMeshRTTI()
  50. {
  51. BS_ADD_PLAIN_FIELD(mType, 0)
  52. }
  53. const String& getRTTIName() override
  54. {
  55. static String name = "FPhysicsMesh";
  56. return name;
  57. }
  58. UINT32 getRTTIId() override
  59. {
  60. return TID_FPhysicsMesh;
  61. }
  62. SPtr<IReflectable> newRTTIObject() override
  63. {
  64. BS_EXCEPT(InternalErrorException, "Cannot instantiate an abstract class.");
  65. return nullptr;
  66. }
  67. };
  68. /** @} */
  69. /** @endcond */
  70. }