Bugfix : Fixed the Subdivision input mesh to be non-const. ( merged from GitHub, thanks to Riku Palomäki ).

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1221 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/5/head
kimmi 2012-03-20 21:00:16 +00:00
parent 9f6e45d651
commit d7341094ca
2 changed files with 13 additions and 13 deletions

View File

@ -52,15 +52,15 @@ void mydummy() {}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
/** Subdivider stub class to implement the Catmull-Clarke subdivision algorithm. The /** Subdivider stub class to implement the Catmull-Clarke subdivision algorithm. The
* implementation is basing on recursive refinement. Directly evaluating the result is also * 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 class CatmullClarkSubdivider : public Subdivider
{ {
public: public:
void Subdivide (const aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input); void Subdivide (aiMesh* mesh, aiMesh*& out, unsigned int num, bool discard_input);
void Subdivide (const aiMesh* const * smesh, size_t nmesh, void Subdivide (aiMesh** smesh, size_t nmesh,
aiMesh** out, unsigned int num, bool discard_input); 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 // Call the Catmull Clark subdivision algorithm for one mesh
void CatmullClarkSubdivider::Subdivide ( void CatmullClarkSubdivider::Subdivide (
const aiMesh* mesh, aiMesh* mesh,
aiMesh*& out, aiMesh*& out,
unsigned int num, unsigned int num,
bool discard_input bool discard_input
@ -136,7 +136,7 @@ void CatmullClarkSubdivider::Subdivide (
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Call the Catmull Clark subdivision algorithm for multiple meshes // Call the Catmull Clark subdivision algorithm for multiple meshes
void CatmullClarkSubdivider::Subdivide ( void CatmullClarkSubdivider::Subdivide (
const aiMesh* const * smesh, aiMesh** smesh,
size_t nmesh, size_t nmesh,
aiMesh** out, aiMesh** out,
unsigned int num, unsigned int num,
@ -152,8 +152,8 @@ void CatmullClarkSubdivider::Subdivide (
// No subdivision at all. Need to copy all the meshes .. argh. // No subdivision at all. Need to copy all the meshes .. argh.
if (discard_input) { if (discard_input) {
for (size_t s = 0; s < nmesh; ++s) { for (size_t s = 0; s < nmesh; ++s) {
out[s] = const_cast<aiMesh*>( smesh[s] ); out[s] = smesh[s];
const_cast<aiMesh*&>( smesh[s] ) = NULL; smesh[s] = NULL;
} }
} }
else { else {
@ -164,7 +164,7 @@ void CatmullClarkSubdivider::Subdivide (
return; return;
} }
std::vector<const aiMesh*> inmeshes; std::vector<aiMesh*> inmeshes;
std::vector<aiMesh*> outmeshes; std::vector<aiMesh*> outmeshes;
std::vector<unsigned int> maptbl; std::vector<unsigned int> maptbl;
@ -176,14 +176,14 @@ void CatmullClarkSubdivider::Subdivide (
// number of edge cases the subdivider is forced to deal with. Line and // number of edge cases the subdivider is forced to deal with. Line and
// point meshes are simply passed through. // point meshes are simply passed through.
for (size_t s = 0; s < nmesh; ++s) { for (size_t s = 0; s < nmesh; ++s) {
const aiMesh* i = smesh[s]; aiMesh* i = smesh[s];
// FIX - mPrimitiveTypes might not yet be initialized // FIX - mPrimitiveTypes might not yet be initialized
if (i->mPrimitiveTypes && (i->mPrimitiveTypes & (aiPrimitiveType_LINE|aiPrimitiveType_POINT))==i->mPrimitiveTypes) { if (i->mPrimitiveTypes && (i->mPrimitiveTypes & (aiPrimitiveType_LINE|aiPrimitiveType_POINT))==i->mPrimitiveTypes) {
DefaultLogger::get()->debug("Catmull-Clark Subdivider: Skipping pure line/point mesh"); DefaultLogger::get()->debug("Catmull-Clark Subdivider: Skipping pure line/point mesh");
if (discard_input) { if (discard_input) {
out[s] = const_cast<aiMesh*>( i ); out[s] = i;
const_cast<aiMesh*&>( smesh[s] ) = NULL; smesh[s] = NULL;
} }
else { else {
SceneCombiner::Copy(out+s,i); SceneCombiner::Copy(out+s,i);

View File

@ -82,7 +82,7 @@ public:
* improve performance because it allows the optimization * improve performance because it allows the optimization
* to reuse the existing mesh for intermediate results. * to reuse the existing mesh for intermediate results.
* @pre out!=mesh*/ * @pre out!=mesh*/
virtual void Subdivide (const aiMesh* mesh, virtual void Subdivide ( aiMesh* mesh,
aiMesh*& out, unsigned int num, aiMesh*& out, unsigned int num,
bool discard_input = false) = 0; bool discard_input = false) = 0;
@ -108,7 +108,7 @@ public:
* @param num Number of subdivisions to perform. * @param num Number of subdivisions to perform.
* @pre nmesh != 0, smesh and out may not overlap*/ * @pre nmesh != 0, smesh and out may not overlap*/
virtual void Subdivide ( virtual void Subdivide (
const aiMesh* const * smesh, aiMesh** smesh,
size_t nmesh, size_t nmesh,
aiMesh** out, aiMesh** out,
unsigned int num, unsigned int num,