Fix some findings in animation header.

pull/1077/head
Kim Kulling 2016-11-23 20:20:11 +01:00
parent f45aeca3f6
commit d87400b76a
5 changed files with 124 additions and 45 deletions

View File

@ -59,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory>
using namespace Assimp;
using namespace Assimp::Collada;
using namespace Assimp::Formatter;

View File

@ -268,8 +268,7 @@ namespace Assimp
Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
/** Finds the item in the given library by its reference, throws if not found */
template <typename Type> const Type& ResolveLibraryReference(
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
template <typename Type> const Type& ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
protected:
/** Filename, for a verbose error message */

View File

@ -39,7 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
/** @file anim.h
/**
* @file anim.h
* @brief Defines the data structures in which the imported animations
* are returned.
*/
@ -47,8 +48,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef AI_ANIM_H_INC
#define AI_ANIM_H_INC
#include "types.h"
#include "quaternion.h"
#include <assimp/types.h>
#include <assimp/quaternion.h>
#ifdef __cplusplus
extern "C" {
@ -66,16 +67,20 @@ struct aiVectorKey
#ifdef __cplusplus
//! Default constructor
aiVectorKey(){}
/// @brief The default constructor.
aiVectorKey()
: mTime( 0.0 )
, mValue() {
// empty
}
/// @brief Construction from a given time and key value.
//! Construction from a given time and key value
aiVectorKey(double time, const aiVector3D& value)
: mTime (time)
, mValue (value)
{}
typedef aiVector3D elem_type;
// Comparison operators. For use with std::find();
@ -93,7 +98,7 @@ struct aiVectorKey
bool operator > (const aiVectorKey& o) const {
return mTime > o.mTime;
}
#endif
#endif // __cplusplus
};
// ---------------------------------------------------------------------------
@ -108,7 +113,10 @@ struct aiQuatKey
C_STRUCT aiQuaternion mValue;
#ifdef __cplusplus
aiQuatKey(){
aiQuatKey()
: mTime( 0.0 )
, mValue() {
// empty
}
/** Construction from a given time and key value */
@ -145,7 +153,7 @@ struct aiMeshKey
double mTime;
/** Index into the aiMesh::mAnimMeshes array of the
* mesh coresponding to the #aiMeshAnim hosting this
* mesh corresponding to the #aiMeshAnim hosting this
* key frame. The referenced anim mesh is evaluated
* according to the rules defined in the docs for #aiAnimMesh.*/
unsigned int mValue;
@ -204,8 +212,6 @@ enum aiAnimBehaviour
* time is t, use the value at (t-n) % (|m-n|).*/
aiAnimBehaviour_REPEAT = 0x3,
/** This value is not used, it is just here to force the
* the compiler to map this enum to a 32 Bit integer */
#ifndef SWIG
@ -228,8 +234,7 @@ enum aiAnimBehaviour
* Duplicate keys don't pass the validation step. Most likely there
* will be no negative time values, but they are not forbidden also ( so
* implementations need to cope with them! ) */
struct aiNodeAnim
{
struct aiNodeAnim {
/** The name of the node affected by this animation. The node
* must exist and it must be unique.*/
C_STRUCT aiString mNodeName;
@ -281,16 +286,16 @@ struct aiNodeAnim
#ifdef __cplusplus
aiNodeAnim()
{
mNumPositionKeys = 0; mPositionKeys = NULL;
mNumRotationKeys = 0; mRotationKeys = NULL;
mNumScalingKeys = 0; mScalingKeys = NULL;
: mNumPositionKeys( 0 )
, mPositionKeys( NULL )
, mNumRotationKeys( 0 )
, mRotationKeys( NULL )
, mNumScalingKeys( 0 )
, mScalingKeys( NULL ) {
mPreState = mPostState = aiAnimBehaviour_DEFAULT;
}
~aiNodeAnim()
{
~aiNodeAnim() {
delete [] mPositionKeys;
delete [] mRotationKeys;
delete [] mScalingKeys;
@ -308,7 +313,7 @@ struct aiMeshAnim
{
/** Name of the mesh to be animated. An empty string is not allowed,
* animated meshes need to be named (not necessarily uniquely,
* the name can basically serve as wildcard to select a group
* the name can basically serve as wild-card to select a group
* of meshes with similar animation setup)*/
C_STRUCT aiString mName;
@ -334,10 +339,9 @@ struct aiMeshAnim
};
// ---------------------------------------------------------------------------
/** An animation consists of keyframe data for a number of nodes. For
/** An animation consists of key-frame data for a number of nodes. For
* each node affected by the animation a separate series of data is given.*/
struct aiAnimation
{
struct aiAnimation {
/** The name of the animation. If the modeling package this data was
* exported from does support only a single animation channel, this
* name is usually empty (length is zero). */
@ -401,15 +405,16 @@ struct aiAnimation
#ifdef __cplusplus
}
// some C++ utilities for inter- and extrapolation
/// @brief Some C++ utilities for inter- and extrapolation
namespace Assimp {
// ---------------------------------------------------------------------------
/** @brief CPP-API: Utility class to simplify interpolations of various data types.
/**
* @brief CPP-API: Utility class to simplify interpolations of various data types.
*
* The type of interpolation is chosen automatically depending on the
* types of the arguments. */
* types of the arguments.
*/
template <typename T>
struct Interpolator
{
@ -445,7 +450,7 @@ struct Interpolator <unsigned int> {
}; // ! Interpolator <aiQuaternion>
template <>
struct Interpolator <aiVectorKey> {
struct Interpolator<aiVectorKey> {
void operator () (aiVector3D& out,const aiVectorKey& a,
const aiVectorKey& b, ai_real d) const
{
@ -455,7 +460,7 @@ struct Interpolator <aiVectorKey> {
}; // ! Interpolator <aiVectorKey>
template <>
struct Interpolator <aiQuatKey> {
struct Interpolator<aiQuatKey> {
void operator () (aiQuaternion& out, const aiQuatKey& a,
const aiQuatKey& b, ai_real d) const
{
@ -465,7 +470,7 @@ struct Interpolator <aiQuatKey> {
}; // ! Interpolator <aiQuatKey>
template <>
struct Interpolator <aiMeshKey> {
struct Interpolator<aiMeshKey> {
void operator () (unsigned int& out, const aiMeshKey& a,
const aiMeshKey& b, ai_real d) const
{
@ -475,9 +480,9 @@ struct Interpolator <aiMeshKey> {
}; // ! Interpolator <aiQuatKey>
//! @endcond
} // ! end namespace Assimp
#endif // __cplusplus
#endif // AI_ANIM_H_INC

View File

@ -56,6 +56,7 @@ SOURCE_GROUP( unit FILES
SET( TEST_SRCS
unit/TestIOSystem.h
unit/utAnim.cpp
unit/AssimpAPITest.cpp
unit/utBatchLoader.cpp
unit/utBlenderIntermediate.cpp

View File

@ -0,0 +1,75 @@
/*
---------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
#include "UnitTestPCH.h"
#include <assimp/anim.h>
using namespace Assimp;
class utAnim : public ::testing::Test {
// empty
};
TEST_F( utAnim, aiVectorKeyCreationTest ) {
aiVectorKey defaultConstTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstTest.mTime );
aiVector3D v( 1, 2, 3 );
aiVectorKey constrWithValuesTest( 1, v );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( v, constrWithValuesTest.mValue );
EXPECT_NE( defaultConstTest, constrWithValuesTest );
EXPECT_TRUE( defaultConstTest != constrWithValuesTest );
defaultConstTest.mTime = 1;
constrWithValuesTest.mTime = 2;
EXPECT_TRUE( defaultConstTest < constrWithValuesTest );
}
TEST_F( utAnim, aiQuatKeyTest ) {
aiQuatKey defaultConstrTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstrTest.mTime );
aiQuaternion q;
aiQuatKey constrWithValuesTest( 1.0, q );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( q, constrWithValuesTest.mValue );
}