Page MenuHome

Multi-Object-Mode: Edit Armature Tool recalculate roll (ARMATURE_OT_calculate_roll)
AbandonedPublic

Authored by codemanx on May 17 2018, 1:27 AM.

Details

Summary

Moved some context stuff to the top to trade a tiny bit of memory (a few pointers) for speed - no need to get the current scene multiple times only because we iterate over multiple objects. An alternative would be to use multiple for loops over the objects, but I would try to avoid that.

In case of a premature cancellation of the operator, i.e. missing RegionView3D, the loop over all objects can be aborted early.
Added call MEM_freeN(objects); before return OPERATOR_CANCELLED; because otherwise we would leak memory, wouldn't we?
Any better way to deal with such situations (RAII, goto)? As long as it's a single call to clean up, it should be fine, but maybe there's some better way...

Existing patches seem to skip (continue;) objects that can't be processed. In 2.7x, the operator would be cancelled for the single active object and an error reported.
Not sure if the error reporting in case of multi-object editing should be somehow ported. Per-object errors don't make sense, so maybe report only if the error occurs for all objects?
Or ignore errors if there's more than a single object, but if (object_len == 1) then re-use the existing code and report error & cancel operator?

Diff Detail

Repository
rB Blender

Event Timeline

codemanx edited the summary of this revision. (Show Details)May 17 2018, 1:30 AM

The sugested way is to report only if the same error occurs for all objects(with selected bones).

Campbell Barton (campbellbarton) requested changes to this revision.May 17 2018, 10:51 AM
Campbell Barton (campbellbarton) added inline comments.
source/blender/editors/armature/armature_edit.c
413–419

This should use the active bone of the active object as a reference for all others.

This revision now requires changes to proceed.May 17 2018, 10:51 AM

The sugested way is to report only if the same error occurs for all objects(with selected bones).

If there is only a single active bone among all armature objects in edit mode, then we would only need to check the active object and abort if there is no active bone (see Campbell's inline comment).

BTW. I tried hacking a counter and check if the number of skipped objects is equal to the total amount, but it did not trigger the error report. I might have a logical flaw in there...
Does BKE_view_layer_array_from_objects_in_edit_mode_unique_data give you all objects in editmode regardless of the type? If multiple objects are processed inside the operator with a for loop, and no object type is specified when getting the editmode objects, why doesn't it crash immediately if you try to access e.g. the armature data for a non-armature object? Is there some hidden filtering?

source/blender/editors/armature/armature_edit.c
413–419

Ah, so while you can have bones from multiple armatures selected at the same time, there is still only a single active bone and not one active bone per armature? CTX_data_edit_object(C) refers to the active object, doesn't it?

Does BKE_view_layer_array_from_objects_in_edit_mode_unique_data give you all objects in editmode regardless of the type?

The object types must match the active object.

codemanx updated this revision to Diff 11019.May 17 2018, 11:13 PM

Use active bone of active object for all objects.

codemanx marked 2 inline comments as done.May 17 2018, 11:15 PM
codemanx added inline comments.
source/blender/editors/armature/armature_edit.c
413–419

Oh, never mind. It's a design decision to use the active bone of the active object as reference for all. I shouldn't code late at night ;)

Is this considered bad style? (EditBone *)((bArmature *)ob->data)->act_edbone

Patch seems fine, thanks for it.
I couldn't apply though so I re-created and committed here: rB13dfb911497a7d22d3d5fc473c526c5330a835e1.