Fix T37171: Camera parented to a bone doesn't move with the bone, unless another object is parented too

Armatures used to check if any of their meshes were culled to see if they needed
to be updated. However, this meant armatures with no meshes would never update,
since non-mesh objects are always considered culled. Instead, if a non-culled
child was not found, we now check to see if the armature contained only
non-mesh objects. If this is the case, always update the armature. If this
becomes a problem, we can look into being able to cull non-mesh objects.
This commit is contained in:
Mitchell Stokes 2013-11-18 14:52:07 -08:00
parent 55e3be560e
commit 0f32bc49ec
Notes: blender-bot 2023-02-14 11:41:35 +01:00
Referenced by issue #37171, Camera parented to a bone doesn't move with the bone, unless another object is parented too.
1 changed files with 14 additions and 1 deletions

View File

@ -1613,16 +1613,29 @@ void KX_Scene::UpdateAnimations(double curtime)
CListValue *children = gameobj->GetChildren();
KX_GameObject *child;
bool has_mesh = false, has_non_mesh = false;
// Check for meshes that haven't been culled
for (int j=0; j<children->GetCount(); ++j) {
child = (KX_GameObject*)children->GetValue(j);
if (child->GetMeshCount() > 0 && !child->GetCulled()) {
if (!child->GetCulled()) {
needs_update = true;
break;
}
if (child->GetMeshCount() == 0)
has_non_mesh = true;
else
has_mesh = true;
}
// If we didn't find a non-culled mesh, check to see
// if we even have any meshes, and update if this
// armature has only non-mesh children.
if (!needs_update && !has_mesh && has_non_mesh)
needs_update = true;
children->Release();
}