diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-25 17:45:57 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-07-25 17:45:57 +0400 |
commit | a7f951f25ef47a4ac98de0270b651dc74a27670d (patch) | |
tree | 72307108dc717119b72dd40109f10509696db820 /source/gameengine/Ketsji/KX_GameObject.cpp | |
parent | ab44742cf36639b73f1aa2c18aa55b14ff059acd (diff) |
BGE patch: approve patch #17312: Multiple material IPOs per mesh in BGE.
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 6c8b32b6d24..3d9c7aafd70 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -442,6 +442,7 @@ void KX_GameObject::UpdateIPO(float curframetime, // IPO update void KX_GameObject::UpdateMaterialData( + dword matname_hash, MT_Vector4 rgba, MT_Vector3 specrgb, MT_Scalar hard, @@ -460,9 +461,26 @@ KX_GameObject::UpdateMaterialData( RAS_IPolyMaterial* poly = (*mit)->GetPolyMaterial(); if(poly->GetFlag() & RAS_BLENDERMAT ) { - SetObjectColor(rgba); KX_BlenderMaterial *m = static_cast<KX_BlenderMaterial*>(poly); - m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); + + if (matname_hash == NULL) + { + m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); + // if mesh has only one material attached to it then use original hack with no need to edit vertices (better performance) + SetObjectColor(rgba); + } + else + { + if (matname_hash == poly->GetMaterialNameHash()) + { + m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha); + m_meshes[mesh]->SetVertexColor(poly,rgba); + + // no break here, because one blender material can be split into several game engine materials + // (e.g. one uvsphere material is split into one material at poles with ras_mode TRIANGLE and one material for the body + // if here was a break then would miss some vertices if material was split + } + } } } } |