1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsPhysXPrerequisites.h"
6#include "Reflection/BsRTTIType.h"
7#include "BsPhysXMesh.h"
8#include "FileSystem/BsDataStream.h"
9
10namespace bs
11{
12 /** @cond RTTI */
13 /** @addtogroup RTTI-Impl-PhysX
14 * @{
15 */
16
17 class FPhysXMeshRTTI : public RTTIType<FPhysXMesh, FPhysicsMesh, FPhysXMeshRTTI>
18 {
19 private:
20 SPtr<DataStream> getCookedData(FPhysXMesh* obj, UINT32& size)
21 {
22 size = obj->mCookedDataSize;
23
24 return bs_shared_ptr_new<MemoryDataStream>(obj->mCookedData, obj->mCookedDataSize, false);
25 }
26
27 void setCookedData(FPhysXMesh* obj, const SPtr<DataStream>& value, UINT32 size)
28 {
29 obj->mCookedData = (UINT8*)bs_alloc(size);
30 obj->mCookedDataSize = size;
31
32 value->read(obj->mCookedData, size);
33 }
34
35 public:
36 FPhysXMeshRTTI()
37 {
38 addDataBlockField("mCookedData", 0, &FPhysXMeshRTTI::getCookedData, &FPhysXMeshRTTI::setCookedData);
39 }
40
41 void onDeserializationEnded(IReflectable* obj, SerializationContext* context) override
42 {
43 FPhysXMesh* mesh = static_cast<FPhysXMesh*>(obj);
44 mesh->initialize();
45 }
46
47 const String& getRTTIName() override
48 {
49 static String name = "FPhysXMesh";
50 return name;
51 }
52
53 UINT32 getRTTIId() override
54 {
55 return TID_FPhysXMesh;
56 }
57
58 SPtr<IReflectable> newRTTIObject() override
59 {
60 return bs_shared_ptr_new<FPhysXMesh>();
61 }
62 };
63
64 /** @} */
65 /** @endcond */
66}