Integrate C++11 branch into 5_1-new
This commit is contained in:
+29
-35
@@ -10,7 +10,6 @@
|
||||
#include "RageLog.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "ModelManager.h"
|
||||
#include "Foreach.h"
|
||||
#include "LuaBinding.h"
|
||||
#include "PrefsManager.h"
|
||||
|
||||
@@ -24,13 +23,13 @@ Model::Model()
|
||||
m_bTextureWrapping = true;
|
||||
SetUseZBuffer( true );
|
||||
SetCullMode( CULL_BACK );
|
||||
m_pGeometry = NULL;
|
||||
m_pCurAnimation = NULL;
|
||||
m_pGeometry = nullptr;
|
||||
m_pCurAnimation = nullptr;
|
||||
m_fDefaultAnimationRate = 1;
|
||||
m_fCurAnimationRate = 1;
|
||||
m_bLoop = true;
|
||||
m_bDrawCelShaded = false;
|
||||
m_pTempGeometry = NULL;
|
||||
m_pTempGeometry = nullptr;
|
||||
}
|
||||
|
||||
Model::~Model()
|
||||
@@ -43,12 +42,12 @@ void Model::Clear()
|
||||
if( m_pGeometry )
|
||||
{
|
||||
MODELMAN->UnloadModel( m_pGeometry );
|
||||
m_pGeometry = NULL;
|
||||
m_pGeometry = nullptr;
|
||||
}
|
||||
m_vpBones.clear();
|
||||
m_Materials.clear();
|
||||
m_mapNameToAnimation.clear();
|
||||
m_pCurAnimation = NULL;
|
||||
m_pCurAnimation = nullptr;
|
||||
RecalcAnimationLengthSeconds();
|
||||
|
||||
if( m_pTempGeometry )
|
||||
@@ -81,7 +80,7 @@ void Model::LoadPieces( const RString &sMeshesPath, const RString &sMaterialsPat
|
||||
// TRICKY: Load materials before geometry so we can figure out whether the materials require normals.
|
||||
LoadMaterialsFromMilkshapeAscii( sMaterialsPath );
|
||||
|
||||
ASSERT( m_pGeometry == NULL );
|
||||
ASSERT( m_pGeometry == nullptr );
|
||||
m_pGeometry = MODELMAN->LoadMilkshapeAscii( sMeshesPath, this->MaterialsNeedNormals() );
|
||||
|
||||
// Validate material indices.
|
||||
@@ -288,7 +287,7 @@ bool Model::LoadMilkshapeAsciiBones( const RString &sAniName, const RString &sPa
|
||||
|
||||
bool Model::EarlyAbortDraw() const
|
||||
{
|
||||
return m_pGeometry == NULL || m_pGeometry->m_Meshes.empty();
|
||||
return m_pGeometry == nullptr || m_pGeometry->m_Meshes.empty();
|
||||
}
|
||||
|
||||
void Model::DrawCelShaded()
|
||||
@@ -571,7 +570,7 @@ void Model::SetPosition( float fSeconds )
|
||||
|
||||
void Model::AdvanceFrame( float fDeltaTime )
|
||||
{
|
||||
if( m_pGeometry == NULL ||
|
||||
if( m_pGeometry == nullptr ||
|
||||
m_pGeometry->m_Meshes.empty() ||
|
||||
!m_pCurAnimation )
|
||||
{
|
||||
@@ -611,7 +610,7 @@ void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone
|
||||
}
|
||||
|
||||
// search for the adjacent position keys
|
||||
const msPositionKey *pLastPositionKey = NULL, *pThisPositionKey = NULL;
|
||||
const msPositionKey *pLastPositionKey = nullptr, *pThisPositionKey = nullptr;
|
||||
for( size_t j = 0; j < pBone->PositionKeys.size(); ++j )
|
||||
{
|
||||
const msPositionKey *pPositionKey = &pBone->PositionKeys[j];
|
||||
@@ -624,18 +623,18 @@ void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone
|
||||
}
|
||||
|
||||
RageVector3 vPos;
|
||||
if( pLastPositionKey != NULL && pThisPositionKey != NULL )
|
||||
if( pLastPositionKey != nullptr && pThisPositionKey != nullptr )
|
||||
{
|
||||
const float s = SCALE( fFrame, pLastPositionKey->fTime, pThisPositionKey->fTime, 0, 1 );
|
||||
vPos = pLastPositionKey->Position + (pThisPositionKey->Position - pLastPositionKey->Position) * s;
|
||||
}
|
||||
else if( pLastPositionKey == NULL )
|
||||
else if( pLastPositionKey == nullptr )
|
||||
vPos = pThisPositionKey->Position;
|
||||
else if( pThisPositionKey == NULL )
|
||||
else if( pThisPositionKey == nullptr )
|
||||
vPos = pLastPositionKey->Position;
|
||||
|
||||
// search for the adjacent rotation keys
|
||||
const msRotationKey *pLastRotationKey = NULL, *pThisRotationKey = NULL;
|
||||
const msRotationKey *pLastRotationKey = nullptr, *pThisRotationKey = nullptr;
|
||||
for( size_t j = 0; j < pBone->RotationKeys.size(); ++j )
|
||||
{
|
||||
const msRotationKey *pRotationKey = &pBone->RotationKeys[j];
|
||||
@@ -648,16 +647,16 @@ void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone
|
||||
}
|
||||
|
||||
RageVector4 vRot;
|
||||
if( pLastRotationKey != NULL && pThisRotationKey != NULL )
|
||||
if( pLastRotationKey != nullptr && pThisRotationKey != nullptr )
|
||||
{
|
||||
const float s = SCALE( fFrame, pLastRotationKey->fTime, pThisRotationKey->fTime, 0, 1 );
|
||||
RageQuatSlerp( &vRot, pLastRotationKey->Rotation, pThisRotationKey->Rotation, s );
|
||||
}
|
||||
else if( pLastRotationKey == NULL )
|
||||
else if( pLastRotationKey == nullptr )
|
||||
{
|
||||
vRot = pThisRotationKey->Rotation;
|
||||
}
|
||||
else if( pThisRotationKey == NULL )
|
||||
else if( pThisRotationKey == nullptr )
|
||||
{
|
||||
vRot = pLastRotationKey->Rotation;
|
||||
}
|
||||
@@ -682,7 +681,7 @@ void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone
|
||||
|
||||
void Model::UpdateTempGeometry()
|
||||
{
|
||||
if( m_pGeometry == NULL || m_pTempGeometry == NULL )
|
||||
if( m_pGeometry == nullptr || m_pTempGeometry == nullptr )
|
||||
return;
|
||||
|
||||
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
|
||||
@@ -731,47 +730,42 @@ void Model::Update( float fDelta )
|
||||
int Model::GetNumStates() const
|
||||
{
|
||||
int iMaxStates = 0;
|
||||
FOREACH_CONST( msMaterial, m_Materials, m )
|
||||
iMaxStates = max( iMaxStates, m->diffuse.GetNumStates() );
|
||||
for (msMaterial const &m : m_Materials)
|
||||
iMaxStates = max( iMaxStates, m.diffuse.GetNumStates() );
|
||||
return iMaxStates;
|
||||
}
|
||||
|
||||
void Model::SetState( int iNewState )
|
||||
{
|
||||
FOREACH( msMaterial, m_Materials, m )
|
||||
for (msMaterial &m : m_Materials)
|
||||
{
|
||||
m->diffuse.SetState( iNewState );
|
||||
m->alpha.SetState( iNewState );
|
||||
m.diffuse.SetState( iNewState );
|
||||
m.alpha.SetState( iNewState );
|
||||
}
|
||||
}
|
||||
|
||||
void Model::RecalcAnimationLengthSeconds()
|
||||
void Model::RecalcAnimationLengthSeconds()
|
||||
{
|
||||
m_animation_length_seconds= 0;
|
||||
FOREACH_CONST(msMaterial, m_Materials, m)
|
||||
for (msMaterial const &m : m_Materials)
|
||||
{
|
||||
m_animation_length_seconds= max(m_animation_length_seconds,
|
||||
m->diffuse.GetAnimationLengthSeconds());
|
||||
m.diffuse.GetAnimationLengthSeconds());
|
||||
}
|
||||
}
|
||||
|
||||
void Model::SetSecondsIntoAnimation( float fSeconds )
|
||||
{
|
||||
FOREACH( msMaterial, m_Materials, m )
|
||||
for (msMaterial &m : m_Materials)
|
||||
{
|
||||
m->diffuse.SetSecondsIntoAnimation( fSeconds );
|
||||
m->alpha.SetSecondsIntoAnimation( fSeconds );
|
||||
m.diffuse.SetSecondsIntoAnimation( fSeconds );
|
||||
m.alpha.SetSecondsIntoAnimation( fSeconds );
|
||||
}
|
||||
}
|
||||
|
||||
bool Model::MaterialsNeedNormals() const
|
||||
{
|
||||
FOREACH_CONST( msMaterial, m_Materials, m )
|
||||
{
|
||||
if( m->NeedsNormals() )
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return std::any_of(m_Materials.begin(), m_Materials.end(), [](msMaterial const &m) { return m.NeedsNormals(); });
|
||||
}
|
||||
|
||||
// lua start
|
||||
|
||||
Reference in New Issue
Block a user