From 86ef521abd7422d435fea25e290e20869af8f833 Mon Sep 17 00:00:00 2001 From: Pontus Fransson Date: Tue, 18 Feb 2014 14:10:12 +0100 Subject: [PATCH] LevelLoader - Added new CollisionGeometry_TriangleMesh. --- Code/Game/GameLogic/LevelLoader/ObjectDefines.h | 16 ++++++++++++++++ .../GameLogic/LevelLoader/ParseFunctions.cpp | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h index 01d17c3e..131b2938 100644 --- a/Code/Game/GameLogic/LevelLoader/ObjectDefines.h +++ b/Code/Game/GameLogic/LevelLoader/ObjectDefines.h @@ -52,6 +52,7 @@ namespace GameLogic CollisionGeometryType_Box, CollisionGeometryType_Sphere, CollisionGeometryType_Cylinder, + CollisionGeometryType_TriangleMesh, CollisionGeometryType_Count, CollisionGeometryType_Unknown = -1 @@ -161,6 +162,12 @@ namespace GameLogic float radius; }; + struct BoundingVolumeTriangleMesh : public BoundingVolumeBase + { + //Null terminated + wchar_t* filename; + }; + struct BoundingVolume { CollisionGeometryType geoType; @@ -169,7 +176,16 @@ namespace GameLogic LevelLoaderInternal::BoundingVolumeBox box; LevelLoaderInternal::BoundingVolumeSphere sphere; LevelLoaderInternal::BoundingVolumeCylinder cylinder; + LevelLoaderInternal::BoundingVolumeTriangleMesh triangleMesh; }; + + virtual ~BoundingVolume() + { + if(geoType == CollisionGeometryType_TriangleMesh) + { + delete[] triangleMesh.filename; + } + } }; } diff --git a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp index dfee72a7..daa62752 100644 --- a/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp +++ b/Code/Game/GameLogic/LevelLoader/ParseFunctions.cpp @@ -175,6 +175,17 @@ namespace GameLogic start += sizeof(volume.cylinder); break; + case CollisionGeometryType_TriangleMesh: + //Get string size + memcpy(&tempSize, &buf[start], sizeof(tempSize)); + start += sizeof(tempSize); + + //Get actual string + volume.triangleMesh.filename = new wchar_t[tempSize+1]; + memcpy(volume.triangleMesh.filename, &buf[start], tempSize); + volume.triangleMesh.filename[tempSize] = '\0'; + break; + default: break; }