Page MenuHome

'Transform' Python Function (Quick Hacks) - review
ClosedPublic

Authored by Campbell Barton (campbellbarton) on Dec 16 2013, 12:07 PM.

Details

Summary

from here

Now ED_armature_apply_transform and ED_armature_transform both call a ED_armature_transform_bones function, hope this is not too much!

Added the stubs for blenderplayer too, my system compiles BGE and runs fine without, should have copied ED_mesh_transform anyway though.

I used DAG_id_tag_update(&foo->id, 0) whenever the object didn't update on viewport refresh, mesh and edit-armature look like they're good without.

Diff Detail

Event Timeline

Brecht Van Lommel (brecht) requested changes to this revision.Dec 16 2013, 12:35 PM

Thanks for the changes, some more comments:

source/blender/editors/armature/armature_edit.c
119–120

Code style, it's more consistent to do this:

if (arm->edbo) {
    ED_armature_transform_bones(arm, (float (*)[4])mat);
}
else {
122–123

I think it would be better to change ED_armature_to_edit and ED_armature_edit_free to take bArmature *arm as argument rather than Object *ob. It seems they don't really need the object.

That means you have to make changes to a bunch of files, but it should simply be a matter of adding ->data there.

Paolo Acampora (pkrime) updated this revision to Unknown Object (????).Dec 16 2013, 3:20 PM

Hope I didn't go to far! :)

ED_armature_to_edit and ED_armature_edit_free now have bArmature as parameter, old calls now use ob->data as argument.

Also the function ED_armature_from_edit now uses the new ED_armature_bones_from_edit for the steps not involving the object. This way I can come back to object mode without creating a new object for the armature data.

Looks good to me.

I'll wait a bit to let @Campbell Barton (campbellbarton) give feedback.

Generally looks good,

One thing thats a little asymmetric is how ED_armature_from_edit takes an object but ED_armature_edit_free an armature.

The only thing which obedit is needed for within ED_armature_from_edit is calling DAG_id_tag_update.

This should be able to be replaced with DAG_id_tag_update(arm, OB_RECALC_DATA), but I didnt test this yet, (logically - all other objects which use this armature should be updated too, so updating only one object seems incorrect, though it seems to work OK).

Paolo Acampora (pkrime) updated this revision to Unknown Object (????).Dec 16 2013, 11:01 PM

ED_armature_from_edit now takes a bArmature, changed all entries from ob to ob->data.

after changing ED_armature_from_edit(struct Object *obedit) to ED_armature_from_edit(struct bArmature *arm) it works fine. To me it makes sense:

  • DAG_id_tag_update was using OB_RECALC_DATA so using the armature directly should do.
  • all objects having the armature as data are rebuilt by BKE_pose_rebuild

I must admit that I still don't know the blender architecture well enough to be sure that changing such a widely used function is 100% safe.

source/blender/editors/armature/armature_edit.c
122–123

So do I, I was just afraid to change so many files! There's a new patch.

Paolo Acampora (pkrime) updated this revision to Unknown Object (????).Dec 16 2013, 11:23 PM

With the new functions configuration the inclusion of "BKE_depsgraph.h" I added in armature_edit.c was not needed anymore.

Committed rBf5076d54cb3a95ab583cddb7de07ed746d2e2be6

Changed the function signatures to take float mat[4][4], and use rna wrapper functions.
Avoids annoying casts within the transform functions body.

Thank you for the feedback and for accepting, I'm going to study your edit, cheers