From 42def11d132a5e51674b2c47405885cfb0b5e89e Mon Sep 17 00:00:00 2001 From: kimmi Date: Tue, 20 Mar 2012 20:45:33 +0000 Subject: [PATCH] =?UTF-8?q?Bugfix=20:=20Replaced=20ugly=20(const=5F)castin?= =?UTF-8?q?g=20by=20a=20better=20ctor=20and=20placement=20new.=20(=20merge?= =?UTF-8?q?d=20from=20GitHub,=20thanks=20to=20Riku=20Palom=C3=A4ki=20).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1217 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/MDCFileData.h | 6 +++++- code/MDCLoader.cpp | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/code/MDCFileData.h b/code/MDCFileData.h index 337cb601e..d3f7c33c0 100644 --- a/code/MDCFileData.h +++ b/code/MDCFileData.h @@ -115,7 +115,11 @@ struct Surface uint32_t ulOffsetCompVerts ; uint32_t ulOffsetFrameBaseFrames ; uint32_t ulOffsetFrameCompFrames ; - uint32_t ulOffsetEnd ; + uint32_t ulOffsetEnd; + Surface() + { + ucName[AI_MDC_MAXQPATH-1] = '\0'; + } } PACK_STRUCT; // --------------------------------------------------------------------------- diff --git a/code/MDCLoader.cpp b/code/MDCLoader.cpp index 4d78de45c..2b0ab5b90 100644 --- a/code/MDCLoader.cpp +++ b/code/MDCLoader.cpp @@ -230,7 +230,7 @@ void MDCImporter::InternReadFile( // get the number of valid surfaces BE_NCONST MDC::Surface* pcSurface, *pcSurface2; - pcSurface = pcSurface2 = (BE_NCONST MDC::Surface*)(mBuffer + pcHeader->ulOffsetSurfaces); + pcSurface = pcSurface2 = new (mBuffer + pcHeader->ulOffsetSurfaces) MDC::Surface; unsigned int iNumShaders = 0; for (unsigned int i = 0; i < pcHeader->ulNumSurfaces;++i) { @@ -239,7 +239,7 @@ void MDCImporter::InternReadFile( if (pcSurface2->ulNumVertices && pcSurface2->ulNumTriangles)++pScene->mNumMeshes; iNumShaders += pcSurface2->ulNumShaders; - pcSurface2 = (BE_NCONST MDC::Surface*)((int8_t*)pcSurface2 + pcSurface2->ulOffsetEnd); + pcSurface2 = new ((int8_t*)pcSurface2 + pcSurface2->ulOffsetEnd) MDC::Surface; } aszShaders.reserve(iNumShaders); pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; @@ -399,7 +399,7 @@ void MDCImporter::InternReadFile( pcFaceCur->mIndices[2] = iOutIndex + 0; } - pcSurface = (BE_NCONST MDC::Surface*)((int8_t*)pcSurface + pcSurface->ulOffsetEnd); + pcSurface = new ((int8_t*)pcSurface + pcSurface->ulOffsetEnd) MDC::Surface; } // create a flat node graph with a root node and one child for each surface