From 38e5bfe234235aed7aa2673bdd09f658eb9606f2 Mon Sep 17 00:00:00 2001 From: cutealien Date: Wed, 24 Aug 2022 12:55:45 +0000 Subject: [PATCH] Fix Collada (.dae) writing with 32 bit meshbuffers Was still handling them as 16-bit buffers. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6416 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CColladaMeshWriter.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/Irrlicht/CColladaMeshWriter.cpp b/source/Irrlicht/CColladaMeshWriter.cpp index 496b15ae..91a0a235 100644 --- a/source/Irrlicht/CColladaMeshWriter.cpp +++ b/source/Irrlicht/CColladaMeshWriter.cpp @@ -1865,12 +1865,16 @@ void CColladaMeshWriter::writeMeshGeometry(const irr::core::stringc& meshname, s Writer->writeElement("p", false); + const video::E_INDEX_TYPE iType = buffer->getIndexType(); + const u16* idx16 = buffer->getIndices(); + const u32* idx32 = (u32*)buffer->getIndices(); + core::stringc strP; strP.reserve(100); for (u32 p=0; pgetIndices()[(p*3) + 2]; + u32 irrIdx = iType == video::EIT_16BIT ? idx16[p*3 + 2] : idx32[p*3 + 2]; strP = ""; strP += irrIdx + posIdx; strP += " "; @@ -1884,7 +1888,7 @@ void CColladaMeshWriter::writeMeshGeometry(const irr::core::stringc& meshname, s strP += " "; } - irrIdx = buffer->getIndices()[(p*3) + 1]; + irrIdx = iType == video::EIT_16BIT ? idx16[p*3 + 1] : idx32[p*3 + 1]; strP += irrIdx + posIdx; strP += " "; strP += irrIdx + tCoordIdx; @@ -1897,7 +1901,7 @@ void CColladaMeshWriter::writeMeshGeometry(const irr::core::stringc& meshname, s strP += " "; } - irrIdx = buffer->getIndices()[(p*3) + 0]; + irrIdx = iType == video::EIT_16BIT ? idx16[p*3] : idx32[p*3]; strP += irrIdx + posIdx; strP += " "; strP += irrIdx + tCoordIdx;