| 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 | #include "Physics/BsPhysicsMesh.h" | 
| 4 | #include "Private/RTTI/BsPhysicsMeshRTTI.h" | 
| 5 | #include "Resources/BsResources.h" | 
| 6 | #include "Physics/BsPhysics.h" | 
| 7 | |
| 8 | namespace bs | 
| 9 | { | 
| 10 | PhysicsMesh::PhysicsMesh(const SPtr<MeshData>& meshData, PhysicsMeshType type) | 
| 11 | :mInitMeshData(meshData), mType(type) | 
| 12 | { | 
| 13 | // Derived class is responsible for initializing mInternal | 
| 14 | } | 
| 15 | |
| 16 | PhysicsMeshType PhysicsMesh::getType() const | 
| 17 | { | 
| 18 | return mInternal->mType; | 
| 19 | } | 
| 20 | |
| 21 | SPtr<MeshData> PhysicsMesh::getMeshData() const | 
| 22 | { | 
| 23 | return mInternal->getMeshData(); | 
| 24 | } | 
| 25 | |
| 26 | HPhysicsMesh PhysicsMesh::create(const SPtr<MeshData>& meshData, PhysicsMeshType type) | 
| 27 | { | 
| 28 | SPtr<PhysicsMesh> newMesh = _createPtr(meshData, type); | 
| 29 | |
| 30 | return static_resource_cast<PhysicsMesh>(gResources()._createResourceHandle(newMesh)); | 
| 31 | } | 
| 32 | |
| 33 | SPtr<PhysicsMesh> PhysicsMesh::_createPtr(const SPtr<MeshData>& meshData, PhysicsMeshType type) | 
| 34 | { | 
| 35 | SPtr<PhysicsMesh> newMesh = gPhysics().createMesh(meshData, type); | 
| 36 | newMesh->_setThisPtr(newMesh); | 
| 37 | newMesh->initialize(); | 
| 38 | |
| 39 | return newMesh; | 
| 40 | } | 
| 41 | |
| 42 | void PhysicsMesh::initialize() | 
| 43 | { | 
| 44 | mInitMeshData = nullptr; | 
| 45 | |
| 46 | Resource::initialize(); | 
| 47 | } | 
| 48 | |
| 49 | RTTITypeBase* PhysicsMesh::getRTTIStatic() | 
| 50 | { | 
| 51 | return PhysicsMeshRTTI::instance(); | 
| 52 | } | 
| 53 | |
| 54 | RTTITypeBase* PhysicsMesh::getRTTI() const | 
| 55 | { | 
| 56 | return getRTTIStatic(); | 
| 57 | } | 
| 58 | |
| 59 | FPhysicsMesh::FPhysicsMesh(const SPtr<MeshData>& meshData, PhysicsMeshType type) | 
| 60 | :mType(type) | 
| 61 | { | 
| 62 | |
| 63 | } | 
| 64 | |
| 65 | FPhysicsMesh::~FPhysicsMesh() | 
| 66 | { | 
| 67 | |
| 68 | } | 
| 69 | |
| 70 | RTTITypeBase* FPhysicsMesh::getRTTIStatic() | 
| 71 | { | 
| 72 | return FPhysicsMeshRTTI::instance(); | 
| 73 | } | 
| 74 | |
| 75 | RTTITypeBase* FPhysicsMesh::getRTTI() const | 
| 76 | { | 
| 77 | return getRTTIStatic(); | 
| 78 | } | 
| 79 | } | 
| 80 | 
