| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsPhysXPrerequisites.h"
- #include "BsRTTIType.h"
- #include "BsPhysXMesh.h"
- namespace BansheeEngine
- {
- class BS_PHYSX_EXPORT PhysXMeshRTTI : public RTTIType<PhysXMesh, PhysicsMesh, PhysXMeshRTTI>
- {
- private:
- ManagedDataBlock getCookedData(PhysXMesh* obj)
- {
- ManagedDataBlock dataBlock((UINT8*)obj->mCookedData, obj->mCookedDataSize);
- return dataBlock;
- }
- void setCookedData(PhysXMesh* obj, ManagedDataBlock val)
- {
- // Nothing to do here, the pointer we provided in allocateCookedData() already belongs to PhysXMesh
- // so the data is already written
- }
- static UINT8* allocateCookedData(PhysXMesh* obj, UINT32 numBytes)
- {
- obj->mCookedData = (UINT8*)bs_alloc(numBytes);
- obj->mCookedDataSize = numBytes;
- return obj->mCookedData;
- }
- public:
- PhysXMeshRTTI()
- {
- addDataBlockField("mCookedData", 0,
- &PhysXMeshRTTI::getCookedData, &PhysXMeshRTTI::setCookedData, 0, &PhysXMeshRTTI::allocateCookedData);
- }
- void onDeserializationEnded(IReflectable* obj) override
- {
- PhysXMesh* mesh = static_cast<PhysXMesh*>(obj);
- mesh->initialize();
- }
- const String& getRTTIName() override
- {
- static String name = "PhysXMesh";
- return name;
- }
- UINT32 getRTTIId() override
- {
- return TID_PhysXMesh;
- }
- SPtr<IReflectable> newRTTIObject() override
- {
- return PhysicsMesh::_createPtr(nullptr, PhysicsMeshType::Convex);
- }
- };
- }
|