From c999f65a7dbc2e50f70546b5294962cda715e579 Mon Sep 17 00:00:00 2001 From: aramis_acg Date: Tue, 19 Jan 2010 20:05:14 +0000 Subject: [PATCH] FIX: SMDLoader was broken due to erroneous 'rt' in input stream construction. FIX: MD3Loader, revive dead branch. FIX: TargetAnimation - clarify doc on preconditions. FIX: aiMatrix3x3::FromTo - move cross product into a branch to save it we can do it without it. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@530 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/MD3Loader.cpp | 2 +- code/SMDLoader.cpp | 2 +- code/TargetAnimation.cpp | 24 +++++++++++------------- code/TargetAnimation.h | 15 +++++---------- include/aiMatrix3x3.inl | 2 +- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 8ae3354a6..a2a37616d 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -303,7 +303,7 @@ void Q3Shader::ConvertShaderToMaterial(MaterialHelper* out, const ShaderDataBloc type = aiTextureType_EMISSIVE; } } - else if ((*it).blend_src == Q3Shader::BLEND_GL_DST_COLOR && Q3Shader::BLEND_GL_ZERO) { + else if ((*it).blend_src == Q3Shader::BLEND_GL_DST_COLOR && (*it).blend_dest == Q3Shader::BLEND_GL_ZERO) { index = cur_lm++; type = aiTextureType_LIGHTMAP; } diff --git a/code/SMDLoader.cpp b/code/SMDLoader.cpp index 3dfde4b1e..ffeac762f 100644 --- a/code/SMDLoader.cpp +++ b/code/SMDLoader.cpp @@ -96,7 +96,7 @@ void SMDImporter::SetupProperties(const Importer* pImp) void SMDImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) { - boost::scoped_ptr file( pIOHandler->Open( pFile, "rt")); + boost::scoped_ptr file( pIOHandler->Open( pFile, "rb")); // Check whether we can read from the file if( file.get() == NULL) { diff --git a/code/TargetAnimation.cpp b/code/TargetAnimation.cpp index 2882b51dc..f27430819 100644 --- a/code/TargetAnimation.cpp +++ b/code/TargetAnimation.cpp @@ -92,8 +92,9 @@ inline T Interpolate(const T& one, const T& two, float val) void KeyIterator::operator ++() { // If we are already at the end of all keyframes, return - if (reachedEnd)return; - + if (reachedEnd) { + return; + } // Now search in all arrays for the time value closest // to our current position on the time line @@ -125,8 +126,7 @@ void KeyIterator::operator ++() curTime = d0; // interpolate the other - if (1 == targetObjPos->size() || !nextTargetObjPos) - { + if (1 == targetObjPos->size() || !nextTargetObjPos) { curTargetPosition = targetObjPos->at(0).mValue; } else @@ -147,8 +147,7 @@ void KeyIterator::operator ++() curTime = d1; // interpolate the other - if (1 == objPos->size() || !nextObjPos) - { + if (1 == objPos->size() || !nextObjPos) { curPosition = objPos->at(0).mValue; } else @@ -199,15 +198,12 @@ void TargetAnimationHelper::SetFixedMainAnimationChannel( // ------------------------------------------------------------------------------------------------ void TargetAnimationHelper::Process(std::vector* distanceTrack) { - ai_assert(NULL != targetPositions); + ai_assert(NULL != targetPositions && NULL != distanceTrack); // TODO: in most cases we won't need the extra array - std::vector* fill = NULL; std::vector real; - if (distanceTrack) - { - fill = (distanceTrack == objectPositions ? &real : distanceTrack); - } + + std::vector* fill = (distanceTrack == objectPositions ? &real : distanceTrack); fill->reserve(std::max( objectPositions->size(), targetPositions->size() )); // Iterate through all object keys and interpolate their values if necessary. @@ -238,11 +234,13 @@ void TargetAnimationHelper::Process(std::vector* distanceTrack) } else { + // FIXME: handle this } // diff is now the vector in which our camera is pointing } - if (real.size()) + if (real.size()) { *distanceTrack = real; + } } diff --git a/code/TargetAnimation.h b/code/TargetAnimation.h index c06d432a5..df3c4b336 100644 --- a/code/TargetAnimation.h +++ b/code/TargetAnimation.h @@ -125,8 +125,7 @@ private: * 3DS and ASE store the differently to Assimp - there is an animation * channel for the camera/spot light itself and a separate position * animation channels specifying the position of the camera/spot light - * look-at target -*/ + * look-at target */ class ASSIMP_API TargetAnimationHelper { public: @@ -143,8 +142,7 @@ public: * This channel specifies the position of the camera/spot light * target at a specific position. * - * @param targetPositions Translation channel - */ + * @param targetPositions Translation channel*/ void SetTargetAnimationChannel (const std::vector* targetPositions); @@ -152,23 +150,20 @@ public: // ------------------------------------------------------------------ /** Sets the main animation channel * - * @param objectPositions Translation channel - */ + * @param objectPositions Translation channel */ void SetMainAnimationChannel ( const std::vector* objectPositions); // ------------------------------------------------------------------ /** Sets the main animation channel to a fixed value * - * @param fixed Fixed value for the main animation channel - */ + * @param fixed Fixed value for the main animation channel*/ void SetFixedMainAnimationChannel(const aiVector3D& fixed); // ------------------------------------------------------------------ /** Computes final animation channels - * - */ + * @param distanceTrack Receive camera translation keys ... != NULL. */ void Process( std::vector* distanceTrack ); diff --git a/include/aiMatrix3x3.inl b/include/aiMatrix3x3.inl index a9bd420dd..32ea5a54a 100644 --- a/include/aiMatrix3x3.inl +++ b/include/aiMatrix3x3.inl @@ -168,7 +168,6 @@ inline aiMatrix3x3& aiMatrix3x3::Translation( const aiVector2D& v, aiMatrix3x3& inline aiMatrix3x3& aiMatrix3x3::FromToMatrix(const aiVector3D& from, const aiVector3D& to, aiMatrix3x3& mtx) { - const aiVector3D v = from ^ to; const float e = from * to; const float f = (e < 0)? -e:e; @@ -223,6 +222,7 @@ inline aiMatrix3x3& aiMatrix3x3::FromToMatrix(const aiVector3D& from, } else /* the most common case, unless "from"="to", or "from"=-"to" */ { + const aiVector3D v = from ^ to; /* ... use this hand optimized version (9 mults less) */ const float h = 1.0f/(1.0f + e); /* optimization by Gottfried Chen */ const float hvx = h * v.x;