From d7341094ca05d9ec1bc5a96be47c955ede6f8083 Mon Sep 17 00:00:00 2001 From: kimmi Date: Tue, 20 Mar 2012 21:00:16 +0000 Subject: [PATCH] =?UTF-8?q?Bugfix=20:=20Fixed=20the=20Subdivision=20input?= =?UTF-8?q?=20mesh=20to=20be=20non-const.=20(=20merged=20from=20GitHub,=20?= =?UTF-8?q?thanks=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@1221 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/Subdivision.cpp | 22 +++++++++++----------- code/Subdivision.h | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/code/Subdivision.cpp b/code/Subdivision.cpp index f5d652362..74b56a245 100644 --- a/code/Subdivision.cpp +++ b/code/Subdivision.cpp @@ -52,15 +52,15 @@ void mydummy() {} // ------------------------------------------------------------------------------------------------ /** Subdivider stub class to implement the Catmull-Clarke subdivision algorithm. The * implementation is basing on recursive refinement. Directly evaluating the result is also - * possibel and much quicker, but it depends on lengthy matrix lookup tables. */ + * possible and much quicker, but it depends on lengthy matrix lookup tables. */ // ------------------------------------------------------------------------------------------------ class CatmullClarkSubdivider : public Subdivider { public: - void Subdivide (const aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input); - void Subdivide (const aiMesh* const * smesh, size_t nmesh, + void Subdivide (aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input); + void Subdivide (aiMesh** smesh, size_t nmesh, aiMesh** out, unsigned int num, bool discard_input); // --------------------------------------------------------------------------- @@ -123,7 +123,7 @@ Subdivider* Subdivider::Create (Algorithm algo) // ------------------------------------------------------------------------------------------------ // Call the Catmull Clark subdivision algorithm for one mesh void CatmullClarkSubdivider::Subdivide ( - const aiMesh* mesh, + aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input @@ -136,7 +136,7 @@ void CatmullClarkSubdivider::Subdivide ( // ------------------------------------------------------------------------------------------------ // Call the Catmull Clark subdivision algorithm for multiple meshes void CatmullClarkSubdivider::Subdivide ( - const aiMesh* const * smesh, + aiMesh** smesh, size_t nmesh, aiMesh** out, unsigned int num, @@ -152,8 +152,8 @@ void CatmullClarkSubdivider::Subdivide ( // No subdivision at all. Need to copy all the meshes .. argh. if (discard_input) { for (size_t s = 0; s < nmesh; ++s) { - out[s] = const_cast( smesh[s] ); - const_cast( smesh[s] ) = NULL; + out[s] = smesh[s]; + smesh[s] = NULL; } } else { @@ -164,7 +164,7 @@ void CatmullClarkSubdivider::Subdivide ( return; } - std::vector inmeshes; + std::vector inmeshes; std::vector outmeshes; std::vector maptbl; @@ -176,14 +176,14 @@ void CatmullClarkSubdivider::Subdivide ( // number of edge cases the subdivider is forced to deal with. Line and // point meshes are simply passed through. for (size_t s = 0; s < nmesh; ++s) { - const aiMesh* i = smesh[s]; + aiMesh* i = smesh[s]; // FIX - mPrimitiveTypes might not yet be initialized if (i->mPrimitiveTypes && (i->mPrimitiveTypes & (aiPrimitiveType_LINE|aiPrimitiveType_POINT))==i->mPrimitiveTypes) { DefaultLogger::get()->debug("Catmull-Clark Subdivider: Skipping pure line/point mesh"); if (discard_input) { - out[s] = const_cast( i ); - const_cast( smesh[s] ) = NULL; + out[s] = i; + smesh[s] = NULL; } else { SceneCombiner::Copy(out+s,i); diff --git a/code/Subdivision.h b/code/Subdivision.h index 78b0ff4f6..5d019f521 100644 --- a/code/Subdivision.h +++ b/code/Subdivision.h @@ -82,7 +82,7 @@ public: * improve performance because it allows the optimization * to reuse the existing mesh for intermediate results. * @pre out!=mesh*/ - virtual void Subdivide (const aiMesh* mesh, + virtual void Subdivide ( aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input = false) = 0; @@ -108,7 +108,7 @@ public: * @param num Number of subdivisions to perform. * @pre nmesh != 0, smesh and out may not overlap*/ virtual void Subdivide ( - const aiMesh* const * smesh, + aiMesh** smesh, size_t nmesh, aiMesh** out, unsigned int num,