2
0

BsPhysXMeshRTTI.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsPhysXPrerequisites.h"
  5. #include "BsRTTIType.h"
  6. #include "BsPhysXMesh.h"
  7. namespace BansheeEngine
  8. {
  9. /** @cond RTTI */
  10. /** @addtogroup RTTI-Impl-PhysX
  11. * @{
  12. */
  13. class BS_PHYSX_EXPORT FPhysXMeshRTTI : public RTTIType<FPhysXMesh, FPhysicsMesh, FPhysXMeshRTTI>
  14. {
  15. private:
  16. ManagedDataBlock getCookedData(FPhysXMesh* obj)
  17. {
  18. ManagedDataBlock dataBlock((UINT8*)obj->mCookedData, obj->mCookedDataSize);
  19. return dataBlock;
  20. }
  21. void setCookedData(FPhysXMesh* obj, ManagedDataBlock val)
  22. {
  23. // Nothing to do here, the pointer we provided in allocateCookedData() already belongs to PhysXMesh
  24. // so the data is already written
  25. }
  26. static UINT8* allocateCookedData(FPhysXMesh* obj, UINT32 numBytes)
  27. {
  28. obj->mCookedData = (UINT8*)bs_alloc(numBytes);
  29. obj->mCookedDataSize = numBytes;
  30. return obj->mCookedData;
  31. }
  32. public:
  33. FPhysXMeshRTTI()
  34. {
  35. addDataBlockField("mCookedData", 0,
  36. &FPhysXMeshRTTI::getCookedData, &FPhysXMeshRTTI::setCookedData, 0, &FPhysXMeshRTTI::allocateCookedData);
  37. }
  38. /** @copydoc IReflectable::onDeserializationEnded */
  39. void onDeserializationEnded(IReflectable* obj) override
  40. {
  41. FPhysXMesh* mesh = static_cast<FPhysXMesh*>(obj);
  42. mesh->initialize();
  43. }
  44. const String& getRTTIName() override
  45. {
  46. static String name = "FPhysXMesh";
  47. return name;
  48. }
  49. UINT32 getRTTIId() override
  50. {
  51. return TID_FPhysXMesh;
  52. }
  53. SPtr<IReflectable> newRTTIObject() override
  54. {
  55. return bs_shared_ptr_new<FPhysXMesh>();
  56. }
  57. };
  58. /** @} */
  59. /** @endcond */
  60. }