Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2014-04-07 03:30:59 +0400
committerMitchell Stokes <mogurijin@gmail.com>2014-04-07 03:30:59 +0400
commitfe05f97841c0ee3e2a6e15f2252ad160fefc3509 (patch)
tree2a672e5d82448f43471ddb529a95fa547d5c311e /source/gameengine/Converter/BL_SkinDeformer.cpp
parentbe8b4b8b0c4d4fdeed6ebf88d8a3bd480e4c48ce (diff)
BGE: Multi-threading animation updates and skinning.
This required BL_ArmatureObject to have tighter control over armatures and poses. Also, (Blender) armature objects are now copied instead of shared between BL_ArmatureObjects to avoid race conditions. Also, due to the armature copy, shape key drivers need a bit of extra fiddling to get the correct armature copy. Initially OpenMP was used for threading, but then BLI_task was used due to being less compiler dependent. This commit also places time spent on skinning updates in the Animation profiler category (was previously under the Rasterizer category).
Diffstat (limited to 'source/gameengine/Converter/BL_SkinDeformer.cpp')
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.cpp88
1 files changed, 40 insertions, 48 deletions
diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp
index e068a91bf7e..8e1f51238d5 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.cpp
+++ b/source/gameengine/Converter/BL_SkinDeformer.cpp
@@ -152,44 +152,8 @@ void BL_SkinDeformer::Relink(CTR_Map<class CTR_HashedPtr, void*>*map)
bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
{
- RAS_MeshSlot::iterator it;
- RAS_MeshMaterial *mmat;
- RAS_MeshSlot *slot;
- size_t i, nmat, imat;
-
- // update the vertex in m_transverts
- if (!Update())
- return false;
-
- if (m_transverts) {
- // the vertex cache is unique to this deformer, no need to update it
- // if it wasn't updated! We must update all the materials at once
- // because we will not get here again for the other material
- nmat = m_pMeshObject->NumMaterials();
- for (imat=0; imat<nmat; imat++) {
- mmat = m_pMeshObject->GetMeshMaterial(imat);
- if (!mmat->m_slots[(void*)m_gameobj])
- continue;
-
- slot = *mmat->m_slots[(void*)m_gameobj];
-
- // for each array
- for (slot->begin(it); !slot->end(it); slot->next(it)) {
- // for each vertex
- // copy the untransformed data from the original mvert
- for (i=it.startvertex; i<it.endvertex; i++) {
- RAS_TexVert& v = it.vertex[i];
- v.SetXYZ(m_transverts[v.getOrigIndex()]);
- if (m_copyNormals)
- v.SetNormal(m_transnors[v.getOrigIndex()]);
- }
- }
- }
-
- if (m_copyNormals)
- m_copyNormals = false;
- }
- return true;
+ // We do everything in UpdateInternal() now so we can thread it.
+ return false;
}
RAS_Deformer *BL_SkinDeformer::GetReplica()
@@ -331,7 +295,7 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
if (!shape_applied) {
/* store verts locally */
VerifyStorage();
-
+
/* duplicate */
for (int v =0; v<m_bmesh->totvert; v++)
{
@@ -342,15 +306,10 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
m_armobj->ApplyPose();
- switch (m_armobj->GetVertDeformType())
- {
- case ARM_VDEF_BGE_CPU:
- BGEDeformVerts();
- break;
- case ARM_VDEF_BLENDER:
- default:
- BlenderDeformVerts();
- }
+ if (m_armobj->GetVertDeformType() == ARM_VDEF_BGE_CPU)
+ BGEDeformVerts();
+ else
+ BlenderDeformVerts();
/* Update the current frame */
m_lastArmaUpdate=m_armobj->GetLastFrame();
@@ -359,6 +318,39 @@ bool BL_SkinDeformer::UpdateInternal(bool shape_applied)
/* dynamic vertex, cannot use display list */
m_bDynamic = true;
/* indicate that the m_transverts and normals are up to date */
+ RAS_MeshSlot::iterator it;
+ RAS_MeshMaterial *mmat;
+ RAS_MeshSlot *slot;
+ size_t i, nmat, imat;
+
+ if (m_transverts) {
+ // the vertex cache is unique to this deformer, no need to update it
+ // if it wasn't updated! We must update all the materials at once
+ // because we will not get here again for the other material
+ nmat = m_pMeshObject->NumMaterials();
+ for (imat=0; imat<nmat; imat++) {
+ mmat = m_pMeshObject->GetMeshMaterial(imat);
+ if (!mmat->m_slots[(void*)m_gameobj])
+ continue;
+
+ slot = *mmat->m_slots[(void*)m_gameobj];
+
+ // for each array
+ for (slot->begin(it); !slot->end(it); slot->next(it)) {
+ // for each vertex
+ // copy the untransformed data from the original mvert
+ for (i=it.startvertex; i<it.endvertex; i++) {
+ RAS_TexVert& v = it.vertex[i];
+ v.SetXYZ(m_transverts[v.getOrigIndex()]);
+ if (m_copyNormals)
+ v.SetNormal(m_transnors[v.getOrigIndex()]);
+ }
+ }
+ }
+
+ if (m_copyNormals)
+ m_copyNormals = false;
+ }
return true;
}