Page MenuHome

BGE: Python-driven armature animation got buggy after 2.70
Closed, ResolvedPublic

Description

System Information
Tested on Kubuntu 14.10 64-bit

Blender Version
Broken: 2.71 and newer, tested up to Git version 72341537e872f2870e785d9fb8a24d2dbdd71471
Worked: all releases from 2.69 up to and including 2.70a

Short description of error
In the BGE: Updating an armature at runtime with Python doesn't work, unless there is a Copy Rotation constraint on one of the bones. The constraint can be turned off (eye symbol) or given influence=0, but still it needs to be there.

Exact steps for others to reproduce the error

  1. Open attached blend file with Blender 2.72b or a development version.
  2. Check that there is a disabled "Copy rotation" constraint on bone "Bone.001". I pre-selected the bone for you, so it should be immediately visible.
  3. Start the game engine, and see that the "rot" debug property is increasing its value. As it increases, bones rotate, and the capsule-shaped mesh deforms.
  4. Stop the game engine.
  5. Delete the bone constraint on bone "Bone.001"
  6. Start the game engine, and see that the "rot" debug property is still increasing its value. However, the capsule-shaped mesh doesn't deform.

To verify, open the same blend file in Blender 2.70a (I tested the 64-bit Linux build), remove the constraint, and start the game engine. You can see that here it works just fine (as expected) without the constraint.

Event Timeline

My disabled brother (sybrenstuvel) raised the priority of this task from to 90.

PS: This is the code that runs in the BGE, just so you can look at it without downloading/opening the blend file:

def update(ctrl):
    skel = ctrl.owner
    
    chan = skel.channels['Bone.001']
    chan.rotation_euler = (skel['rot'], 0, 0)

    chan = skel.channels['Bone']
    chan.rotation_euler = (-skel['rot'], 0, 0)

    skel.update()
    
    skel['rot'] += 0.02

After using git bisect to find the bug-introducing commit, I found this one:

fe05f97841c0ee3e2a6e15f2252ad160fefc3509 is the first bad commit
commit fe05f97841c0ee3e2a6e15f2252ad160fefc3509
Author: Mitchell Stokes <mogurijin@gmail.com>
Date: Sun Apr 6 16:30:59 2014 -0700

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).