anim-header: fix some review findings + andd base tests.

pull/1077/head
Kim Kulling 2016-11-23 22:00:52 +01:00
parent 83e472cef3
commit 1939aca31c
2 changed files with 47 additions and 13 deletions

View File

@ -291,8 +291,10 @@ struct aiNodeAnim {
, mNumRotationKeys( 0 ) , mNumRotationKeys( 0 )
, mRotationKeys( NULL ) , mRotationKeys( NULL )
, mNumScalingKeys( 0 ) , mNumScalingKeys( 0 )
, mScalingKeys( NULL ) { , mScalingKeys( NULL )
mPreState = mPostState = aiAnimBehaviour_DEFAULT; , mPreState( aiAnimBehaviour_DEFAULT )
, mPostState( aiAnimBehaviour_DEFAULT ) {
// empty
} }
~aiNodeAnim() { ~aiNodeAnim() {
@ -372,21 +374,20 @@ struct aiAnimation {
#ifdef __cplusplus #ifdef __cplusplus
aiAnimation() aiAnimation()
: mDuration(-1.) : mDuration(-1.)
, mTicksPerSecond() , mTicksPerSecond(0.)
, mNumChannels() , mNumChannels(0)
, mChannels() , mChannels(nullptr)
, mNumMeshChannels() , mNumMeshChannels(0)
, mMeshChannels() , mMeshChannels(nullptr) {
{ // empty
} }
~aiAnimation() ~aiAnimation() {
{
// DO NOT REMOVE THIS ADDITIONAL CHECK // DO NOT REMOVE THIS ADDITIONAL CHECK
if (mNumChannels && mChannels) { if ( mNumChannels && mChannels ) {
for( unsigned int a = 0; a < mNumChannels; a++) { for( unsigned int a = 0; a < mNumChannels; a++) {
delete mChannels[a]; delete mChannels[ a ];
} }
delete [] mChannels; delete [] mChannels;
@ -403,6 +404,7 @@ struct aiAnimation {
}; };
#ifdef __cplusplus #ifdef __cplusplus
} }
/// @brief Some C++ utilities for inter- and extrapolation /// @brief Some C++ utilities for inter- and extrapolation

View File

@ -72,4 +72,36 @@ TEST_F( utAnim, aiQuatKeyTest ) {
aiQuatKey constrWithValuesTest( 1.0, q ); aiQuatKey constrWithValuesTest( 1.0, q );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime ); EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( q, constrWithValuesTest.mValue ); EXPECT_EQ( q, constrWithValuesTest.mValue );
}
TEST_F( utAnim, aiNodeAnimTest ) {
bool ok( true );
try {
aiNodeAnim myAnim;
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPreState );
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPostState );
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiMeshAnimTest ) {
bool ok( true );
try {
aiMeshAnim myMeshAnim;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiAnimationTest ) {
bool ok( true );
try {
aiAnimation myAnimation;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
} }