BsMeshRTTI.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "BsCoreApplication.h"
  7. #include "BsMesh.h"
  8. #include "BsSkeleton.h"
  9. #include "BsMorphShapes.h"
  10. #include "BsCoreThread.h"
  11. namespace BansheeEngine
  12. {
  13. /** @cond RTTI */
  14. /** @addtogroup RTTI-Impl-Core
  15. * @{
  16. */
  17. class MeshRTTI : public RTTIType<Mesh, MeshBase, MeshRTTI>
  18. {
  19. BS_BEGIN_RTTI_MEMBERS
  20. BS_RTTI_MEMBER_REFLPTR(mVertexDesc, 0)
  21. BS_RTTI_MEMBER_PLAIN(mIndexType, 1)
  22. BS_RTTI_MEMBER_PLAIN(mUsage, 2)
  23. BS_RTTI_MEMBER_REFLPTR(mSkeleton, 4)
  24. BS_RTTI_MEMBER_REFLPTR(mMorphShapes, 5)
  25. BS_END_RTTI_MEMBERS
  26. SPtr<MeshData> getMeshData(Mesh* obj)
  27. {
  28. SPtr<MeshData> meshData = obj->allocateSubresourceBuffer(0);
  29. obj->readSubresource(gCoreAccessor(), 0, meshData);
  30. gCoreAccessor().submitToCoreThread(true);
  31. return meshData;
  32. }
  33. void setMeshData(Mesh* obj, SPtr<MeshData> meshData)
  34. {
  35. obj->mCPUData = meshData;
  36. }
  37. public:
  38. MeshRTTI()
  39. :mInitMembers(this)
  40. {
  41. addReflectablePtrField("mMeshData", 3, &MeshRTTI::getMeshData, &MeshRTTI::setMeshData);
  42. }
  43. void onDeserializationEnded(IReflectable* obj, const UnorderedMap<String, UINT64>& params) override
  44. {
  45. Mesh* mesh = static_cast<Mesh*>(obj);
  46. mesh->initialize();
  47. }
  48. SPtr<IReflectable> newRTTIObject() override
  49. {
  50. return Mesh::createEmpty();
  51. }
  52. const String& getRTTIName() override
  53. {
  54. static String name = "Mesh";
  55. return name;
  56. }
  57. UINT32 getRTTIId() override
  58. {
  59. return TID_Mesh;
  60. }
  61. };
  62. /** @} */
  63. /** @endcond */
  64. }