Fix (more) character model rendering artifacts when a freeze segment
lies on beat 0: m_pTempGeometry was not being set up
This commit is contained in:
+38
-36
@@ -512,6 +512,7 @@ void Model::PlayAnimation( CString sAniName, float fPlayRate )
|
||||
|
||||
/* Set up m_vpBones, just in case we're drawn without being Update()d. */
|
||||
SetBones( m_pCurAnimation, m_fCurFrame, m_vpBones );
|
||||
UpdateTempGeometry();
|
||||
}
|
||||
|
||||
void Model::AdvanceFrame( float fDeltaTime )
|
||||
@@ -539,6 +540,7 @@ void Model::AdvanceFrame( float fDeltaTime )
|
||||
}
|
||||
|
||||
SetBones( m_pCurAnimation, m_fCurFrame, m_vpBones );
|
||||
UpdateTempGeometry();
|
||||
}
|
||||
|
||||
void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone_t> &vpBones )
|
||||
@@ -635,6 +637,42 @@ void Model::SetBones( const msAnimation* pAnimation, float fFrame, vector<myBone
|
||||
}
|
||||
}
|
||||
|
||||
void Model::UpdateTempGeometry()
|
||||
{
|
||||
if( m_pGeometry == NULL || m_pTempGeometry == NULL )
|
||||
return;
|
||||
|
||||
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
|
||||
{
|
||||
const msMesh &origMesh = m_pGeometry->m_Meshes[i];
|
||||
msMesh &tempMesh = m_vTempMeshes[i];
|
||||
const vector<RageModelVertex> &origVertices = origMesh.Vertices;
|
||||
vector<RageModelVertex> &tempVertices = tempMesh.Vertices;
|
||||
for( unsigned j = 0; j < origVertices.size(); j++ )
|
||||
{
|
||||
RageVector3& tempPos = tempVertices[j].p;
|
||||
RageVector3& tempNormal = tempVertices[j].n;
|
||||
const RageVector3& originalPos = origVertices[j].p;
|
||||
const RageVector3& originalNormal = origVertices[j].n;
|
||||
int8_t bone = origVertices[j].bone;
|
||||
|
||||
if( bone == -1 )
|
||||
{
|
||||
tempNormal = originalNormal;
|
||||
tempPos = originalPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
RageVec3TransformNormal( &tempNormal, &originalNormal, &m_vpBones[bone].mFinal );
|
||||
RageVec3TransformCoord( &tempPos, &originalPos, &m_vpBones[bone].mFinal );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// send the new vertices to the graphics card
|
||||
m_pTempGeometry->Change( m_vTempMeshes );
|
||||
}
|
||||
|
||||
void Model::Update( float fDelta )
|
||||
{
|
||||
Actor::Update( fDelta );
|
||||
@@ -645,42 +683,6 @@ void Model::Update( float fDelta )
|
||||
m_Materials[i].diffuse.Update( fDelta );
|
||||
m_Materials[i].alpha.Update( fDelta );
|
||||
}
|
||||
|
||||
//
|
||||
// process per-vertex bones
|
||||
//
|
||||
if( m_pGeometry && m_pTempGeometry )
|
||||
{
|
||||
for( unsigned i = 0; i < m_pGeometry->m_Meshes.size(); ++i )
|
||||
{
|
||||
const msMesh &origMesh = m_pGeometry->m_Meshes[i];
|
||||
msMesh &tempMesh = m_vTempMeshes[i];
|
||||
const vector<RageModelVertex> &origVertices = origMesh.Vertices;
|
||||
vector<RageModelVertex> &tempVertices = tempMesh.Vertices;
|
||||
for( unsigned j = 0; j < origVertices.size(); j++ )
|
||||
{
|
||||
RageVector3& tempPos = tempVertices[j].p;
|
||||
RageVector3& tempNormal = tempVertices[j].n;
|
||||
const RageVector3& originalPos = origVertices[j].p;
|
||||
const RageVector3& originalNormal = origVertices[j].n;
|
||||
int8_t bone = origVertices[j].bone;
|
||||
|
||||
if( bone == -1 )
|
||||
{
|
||||
tempNormal = originalNormal;
|
||||
tempPos = originalPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
RageVec3TransformNormal( &tempNormal, &originalNormal, &m_vpBones[bone].mFinal );
|
||||
RageVec3TransformCoord( &tempPos, &originalPos, &m_vpBones[bone].mFinal );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// send the new vertices to the graphics card
|
||||
m_pTempGeometry->Change( m_vTempMeshes );
|
||||
}
|
||||
}
|
||||
|
||||
int Model::GetNumStates() const
|
||||
|
||||
@@ -58,6 +58,7 @@ private:
|
||||
// If any vertex has a bone weight, then then render from m_pTempGeometry.
|
||||
// Otherwise, render directly from m_pGeometry.
|
||||
RageCompiledGeometry* m_pTempGeometry;
|
||||
void UpdateTempGeometry();
|
||||
|
||||
/* Keep a copy of the mesh data only if m_pTempGeometry is in use. The normal and
|
||||
* position data will be changed; the rest is static and kept only to prevent making
|
||||
|
||||
Reference in New Issue
Block a user