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
pull/1/head
aramis_acg 2010-01-19 20:05:14 +00:00
parent 1c0f3f1b2e
commit c999f65a7d
5 changed files with 19 additions and 26 deletions

View File

@ -303,7 +303,7 @@ void Q3Shader::ConvertShaderToMaterial(MaterialHelper* out, const ShaderDataBloc
type = aiTextureType_EMISSIVE; 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++; index = cur_lm++;
type = aiTextureType_LIGHTMAP; type = aiTextureType_LIGHTMAP;
} }

View File

@ -96,7 +96,7 @@ void SMDImporter::SetupProperties(const Importer* pImp)
void SMDImporter::InternReadFile( void SMDImporter::InternReadFile(
const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
{ {
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, "rt")); boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
// Check whether we can read from the file // Check whether we can read from the file
if( file.get() == NULL) { if( file.get() == NULL) {

View File

@ -92,8 +92,9 @@ inline T Interpolate(const T& one, const T& two, float val)
void KeyIterator::operator ++() void KeyIterator::operator ++()
{ {
// If we are already at the end of all keyframes, return // 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 // Now search in all arrays for the time value closest
// to our current position on the time line // to our current position on the time line
@ -125,8 +126,7 @@ void KeyIterator::operator ++()
curTime = d0; curTime = d0;
// interpolate the other // interpolate the other
if (1 == targetObjPos->size() || !nextTargetObjPos) if (1 == targetObjPos->size() || !nextTargetObjPos) {
{
curTargetPosition = targetObjPos->at(0).mValue; curTargetPosition = targetObjPos->at(0).mValue;
} }
else else
@ -147,8 +147,7 @@ void KeyIterator::operator ++()
curTime = d1; curTime = d1;
// interpolate the other // interpolate the other
if (1 == objPos->size() || !nextObjPos) if (1 == objPos->size() || !nextObjPos) {
{
curPosition = objPos->at(0).mValue; curPosition = objPos->at(0).mValue;
} }
else else
@ -199,15 +198,12 @@ void TargetAnimationHelper::SetFixedMainAnimationChannel(
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void TargetAnimationHelper::Process(std::vector<aiVectorKey>* distanceTrack) void TargetAnimationHelper::Process(std::vector<aiVectorKey>* distanceTrack)
{ {
ai_assert(NULL != targetPositions); ai_assert(NULL != targetPositions && NULL != distanceTrack);
// TODO: in most cases we won't need the extra array // TODO: in most cases we won't need the extra array
std::vector<aiVectorKey>* fill = NULL;
std::vector<aiVectorKey> real; std::vector<aiVectorKey> real;
if (distanceTrack)
{ std::vector<aiVectorKey>* fill = (distanceTrack == objectPositions ? &real : distanceTrack);
fill = (distanceTrack == objectPositions ? &real : distanceTrack);
}
fill->reserve(std::max( objectPositions->size(), targetPositions->size() )); fill->reserve(std::max( objectPositions->size(), targetPositions->size() ));
// Iterate through all object keys and interpolate their values if necessary. // Iterate through all object keys and interpolate their values if necessary.
@ -238,11 +234,13 @@ void TargetAnimationHelper::Process(std::vector<aiVectorKey>* distanceTrack)
} }
else else
{ {
// FIXME: handle this
} }
// diff is now the vector in which our camera is pointing // diff is now the vector in which our camera is pointing
} }
if (real.size()) if (real.size()) {
*distanceTrack = real; *distanceTrack = real;
}
} }

View File

@ -125,8 +125,7 @@ private:
* 3DS and ASE store the differently to Assimp - there is an animation * 3DS and ASE store the differently to Assimp - there is an animation
* channel for the camera/spot light itself and a separate position * channel for the camera/spot light itself and a separate position
* animation channels specifying the position of the camera/spot light * animation channels specifying the position of the camera/spot light
* look-at target * look-at target */
*/
class ASSIMP_API TargetAnimationHelper class ASSIMP_API TargetAnimationHelper
{ {
public: public:
@ -143,8 +142,7 @@ public:
* This channel specifies the position of the camera/spot light * This channel specifies the position of the camera/spot light
* target at a specific position. * target at a specific position.
* *
* @param targetPositions Translation channel * @param targetPositions Translation channel*/
*/
void SetTargetAnimationChannel (const void SetTargetAnimationChannel (const
std::vector<aiVectorKey>* targetPositions); std::vector<aiVectorKey>* targetPositions);
@ -152,23 +150,20 @@ public:
// ------------------------------------------------------------------ // ------------------------------------------------------------------
/** Sets the main animation channel /** Sets the main animation channel
* *
* @param objectPositions Translation channel * @param objectPositions Translation channel */
*/
void SetMainAnimationChannel ( const void SetMainAnimationChannel ( const
std::vector<aiVectorKey>* objectPositions); std::vector<aiVectorKey>* objectPositions);
// ------------------------------------------------------------------ // ------------------------------------------------------------------
/** Sets the main animation channel to a fixed value /** 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); void SetFixedMainAnimationChannel(const aiVector3D& fixed);
// ------------------------------------------------------------------ // ------------------------------------------------------------------
/** Computes final animation channels /** Computes final animation channels
* * @param distanceTrack Receive camera translation keys ... != NULL. */
*/
void Process( std::vector<aiVectorKey>* distanceTrack ); void Process( std::vector<aiVectorKey>* distanceTrack );

View File

@ -168,7 +168,6 @@ inline aiMatrix3x3& aiMatrix3x3::Translation( const aiVector2D& v, aiMatrix3x3&
inline aiMatrix3x3& aiMatrix3x3::FromToMatrix(const aiVector3D& from, inline aiMatrix3x3& aiMatrix3x3::FromToMatrix(const aiVector3D& from,
const aiVector3D& to, aiMatrix3x3& mtx) const aiVector3D& to, aiMatrix3x3& mtx)
{ {
const aiVector3D v = from ^ to;
const float e = from * to; const float e = from * to;
const float f = (e < 0)? -e:e; 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" */ else /* the most common case, unless "from"="to", or "from"=-"to" */
{ {
const aiVector3D v = from ^ to;
/* ... use this hand optimized version (9 mults less) */ /* ... use this hand optimized version (9 mults less) */
const float h = 1.0f/(1.0f + e); /* optimization by Gottfried Chen */ const float h = 1.0f/(1.0f + e); /* optimization by Gottfried Chen */
const float hvx = h * v.x; const float hvx = h * v.x;