FBX: some refactorings.

pull/2091/head
Kim Kulling 2018-08-10 01:57:11 +02:00
parent 442b258360
commit b3132bd8c2
1 changed files with 135 additions and 137 deletions

View File

@ -413,10 +413,8 @@ void FBXConverter::GetUniqueName( const std::string &name, std::string &uniqueNa
} }
const char* FBXConverter::NameTransformationComp( TransformationComp comp ) const char* FBXConverter::NameTransformationComp( TransformationComp comp ) {
{ switch ( comp ) {
switch ( comp )
{
case TransformationComp_Translation: case TransformationComp_Translation:
return "Translation"; return "Translation";
case TransformationComp_RotationOffset: case TransformationComp_RotationOffset:
@ -457,13 +455,12 @@ const char* FBXConverter::NameTransformationComp( TransformationComp comp )
} }
ai_assert( false ); ai_assert( false );
return NULL;
return nullptr;
} }
const char* FBXConverter::NameTransformationCompProperty( TransformationComp comp ) const char* FBXConverter::NameTransformationCompProperty( TransformationComp comp ) {
{ switch ( comp ) {
switch ( comp )
{
case TransformationComp_Translation: case TransformationComp_Translation:
return "Lcl Translation"; return "Lcl Translation";
case TransformationComp_RotationOffset: case TransformationComp_RotationOffset:
@ -503,7 +500,8 @@ const char* FBXConverter::NameTransformationCompProperty( TransformationComp com
} }
ai_assert( false ); ai_assert( false );
return NULL;
return nullptr;
} }
aiVector3D FBXConverter::TransformationCompDefaultValue( TransformationComp comp ) aiVector3D FBXConverter::TransformationCompDefaultValue( TransformationComp comp )
@ -584,11 +582,15 @@ void FBXConverter::GetRotationMatrix( Model::RotOrder mode, const aiVector3D& ro
default: default:
ai_assert( false ); ai_assert( false );
break;
} }
ai_assert( ( order[ 0 ] >= 0 ) && ( order[ 0 ] <= 2 ) ); ai_assert( order[ 0 ] >= 0 );
ai_assert( ( order[ 1 ] >= 0 ) && ( order[ 1 ] <= 2 ) ); ai_assert( order[ 0 ] <= 2 );
ai_assert( ( order[ 2 ] >= 0 ) && ( order[ 2 ] <= 2 ) ); ai_assert( order[ 1 ] >= 0 );
ai_assert( order[ 1 ] <= 2 );
ai_assert( order[ 2 ] >= 0 );
ai_assert( order[ 2 ] <= 2 );
if ( !is_id[ order[ 0 ] ] ) { if ( !is_id[ order[ 0 ] ] ) {
out = temp[ order[ 0 ] ]; out = temp[ order[ 0 ] ];
@ -639,8 +641,8 @@ std::string FBXConverter::NameTransformationChainNode( const std::string& name,
return name + std::string( MAGIC_NODE_TAG ) + "_" + NameTransformationComp( comp ); return name + std::string( MAGIC_NODE_TAG ) + "_" + NameTransformationComp( comp );
} }
void FBXConverter::GenerateTransformationNodeChain( const Model& model, std::vector<aiNode*>& output_nodes, std::vector<aiNode*>& post_output_nodes ) void FBXConverter::GenerateTransformationNodeChain( const Model& model, std::vector<aiNode*>& output_nodes,
{ std::vector<aiNode*>& post_output_nodes ) {
const PropertyTable& props = model.Props(); const PropertyTable& props = model.Props();
const Model::RotOrder rot = model.RotationOrder(); const Model::RotOrder rot = model.RotationOrder();
@ -1965,8 +1967,7 @@ void FBXConverter::SetShadingPropertiesCommon( aiMaterial* out_mat, const Proper
} }
double FBXConverter::FrameRateToDouble( FileGlobalSettings::FrameRate fp, double customFPSVal ) double FBXConverter::FrameRateToDouble( FileGlobalSettings::FrameRate fp, double customFPSVal ) {
{
switch ( fp ) { switch ( fp ) {
case FileGlobalSettings::FrameRate_DEFAULT: case FileGlobalSettings::FrameRate_DEFAULT:
return 1.0; return 1.0;
@ -2014,6 +2015,7 @@ double FBXConverter::FrameRateToDouble( FileGlobalSettings::FrameRate fp, double
} }
ai_assert( false ); ai_assert( false );
return -1.0f; return -1.0f;
} }
@ -2422,8 +2424,7 @@ void FBXConverter::GenerateNodeAnimations( std::vector<aiNodeAnim*>& node_anims,
bool FBXConverter::IsRedundantAnimationData( const Model& target, bool FBXConverter::IsRedundantAnimationData( const Model& target,
TransformationComp comp, TransformationComp comp,
const std::vector<const AnimationCurveNode*>& curves ) const std::vector<const AnimationCurveNode*>& curves ) {
{
ai_assert( curves.size() ); ai_assert( curves.size() );
// look for animation nodes with // look for animation nodes with
@ -2526,7 +2527,6 @@ aiNodeAnim* FBXConverter::GenerateScalingNodeAnim( const std::string& name,
return na.release(); return na.release();
} }
aiNodeAnim* FBXConverter::GenerateTranslationNodeAnim( const std::string& name, aiNodeAnim* FBXConverter::GenerateTranslationNodeAnim( const std::string& name,
const Model& /*target*/, const Model& /*target*/,
const std::vector<const AnimationCurveNode*>& curves, const std::vector<const AnimationCurveNode*>& curves,
@ -2534,8 +2534,7 @@ aiNodeAnim* FBXConverter::GenerateTranslationNodeAnim( const std::string& name,
int64_t start, int64_t stop, int64_t start, int64_t stop,
double& max_time, double& max_time,
double& min_time, double& min_time,
bool inverse ) bool inverse ) {
{
std::unique_ptr<aiNodeAnim> na( new aiNodeAnim() ); std::unique_ptr<aiNodeAnim> na( new aiNodeAnim() );
na->mNodeName.Set( name ); na->mNodeName.Set( name );
@ -2756,12 +2755,11 @@ FBXConverter::KeyFrameListList FBXConverter::GetKeyframeList( const std::vector<
} }
KeyTimeList FBXConverter::GetKeyTimeList( const KeyFrameListList& inputs ) KeyTimeList FBXConverter::GetKeyTimeList( const KeyFrameListList& inputs ) {
{ ai_assert( !inputs.empty() );
ai_assert( inputs.size() );
// reserve some space upfront - it is likely that the keyframe lists // reserve some space upfront - it is likely that the key-frame lists
// have matching time values, so max(of all keyframe lists) should // have matching time values, so max(of all key-frame lists) should
// be a good estimate. // be a good estimate.
KeyTimeList keys; KeyTimeList keys;