Merge branch 'blender-v4.0-release'

This commit is contained in:
Hans Goudey
2023-09-28 08:59:27 -04:00
10 changed files with 77 additions and 102 deletions

View File

@@ -3186,7 +3186,6 @@ def km_pose(params):
("pose.select_hierarchy", {"type": 'DOWN_ARROW', "value": 'PRESS', "shift": True, "repeat": True},
{"properties": [("direction", 'CHILD'), ("extend", True)]}),
("pose.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
("pose.bone_layers", {"type": 'G', "value": 'PRESS'}, None),
("anim.keyframe_insert_menu", {"type": 'S', "value": 'PRESS', "shift": True}, None),
("anim.keyframe_insert_by_name", {"type": 'S', "value": 'PRESS'},
{"properties": [("type", 'LocRotScale')]}),

View File

@@ -506,10 +506,48 @@ class ARMATURE_OT_sync_bone_color_to_selected(Operator):
return {'FINISHED'}
class ARMATURE_OT_collection_solo_visibility(Operator):
"""Hide all other bone collections and show the active one"""
bl_idname = "armature.collection_solo_visibility"
bl_label = "Solo Visibility"
bl_options = {'REGISTER', 'UNDO'}
name: StringProperty(name='Bone Collection')
@classmethod
def poll(cls, context):
return context.object and context.object.type == 'ARMATURE' and context.object.data
def execute(self, context):
arm = context.object.data
for bcoll in arm.collections:
bcoll.is_visible = bcoll.name == self.name
return {'FINISHED'}
class ARMATURE_OT_collection_show_all(Operator):
"""Show all bone collections"""
bl_idname = "armature.collection_show_all"
bl_label = "Show All"
bl_options = {'REGISTER', 'UNDO'}
@classmethod
def poll(cls, context):
return context.object and context.object.type == 'ARMATURE' and context.object.data
def execute(self, context):
arm = context.object.data
for bcoll in arm.collections:
bcoll.is_visible = True
return {'FINISHED'}
classes = (
ANIM_OT_keying_set_export,
NLA_OT_bake,
ClearUselessActions,
UpdateAnimatedTransformConstraint,
ARMATURE_OT_sync_bone_color_to_selected,
ARMATURE_OT_collection_solo_visibility,
ARMATURE_OT_collection_show_all,
)

View File

@@ -135,6 +135,9 @@ class DATA_PT_bone_collections(ArmatureButtonsPanel, Panel):
col.separator()
col.operator("armature.collection_move", icon='TRIA_UP', text="").direction = 'UP'
col.operator("armature.collection_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
col.separator()
col.menu("ARMATURE_MT_collection_context_menu", icon='DOWNARROW_HLT', text="")
row = layout.row()
@@ -147,6 +150,20 @@ class DATA_PT_bone_collections(ArmatureButtonsPanel, Panel):
sub.operator("armature.collection_deselect", text="Deselect")
class ARMATURE_MT_collection_context_menu(Menu):
bl_label = "Bone Collection Specials"
def draw(self, context):
layout = self.layout
arm = context.armature
active_bcoll = arm.collections.active
props = layout.operator("armature.collection_solo_visibility")
props.name = active_bcoll.name if active_bcoll else ""
layout.operator("armature.collection_show_all")
class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
bl_label = "Inverse Kinematics"
bl_options = {'DEFAULT_CLOSED'}
@@ -273,6 +290,7 @@ classes = (
DATA_PT_skeleton,
DATA_PT_bone_collections,
DATA_UL_bone_collections,
ARMATURE_MT_collection_context_menu,
DATA_PT_motion_paths,
DATA_PT_motion_paths_display,
DATA_PT_display,

View File

@@ -573,6 +573,9 @@ def draw_attribute_warnings(context, layout):
ob = context.object
mesh = context.mesh
if not mesh:
return
unique_names = set()
colliding_names = []
for collection in (

View File

@@ -3900,12 +3900,6 @@ class VIEW3D_MT_pose(Menu):
layout.separator()
layout.operator_context = 'INVOKE_AREA'
layout.operator("armature.armature_layers", text="Change Armature Layers...")
layout.operator("pose.bone_layers", text="Change Bone Layers...")
layout.separator()
layout.menu("VIEW3D_MT_pose_showhide")
layout.menu("VIEW3D_MT_bone_options_toggle", text="Bone Settings")
@@ -3995,8 +3989,12 @@ class VIEW3D_MT_bone_collections(Menu):
layout.label(text="- select bones to operate on first -")
return
layout.operator("armature.collection_show_all")
layout.separator()
arm = context.object.data
bone = context.active_bone
found_editable_bcoll = False
for bcoll in arm.collections:
if not bcoll.is_editable:

View File

@@ -533,7 +533,7 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
vi.width = vi.gridsize; \
vi.height = vi.gridsize; \
vi.index = vi.vertex.i = vi.grid_indices[vi.g] * vi.key.grid_area - 1; \
vi.grid = vi.grids[vi.grid_indices[vi.g]]; \
vi.grid = CCG_elem_offset(&vi.key, vi.grids[vi.grid_indices[vi.g]], -1); \
if (mode == PBVH_ITER_UNIQUE) { \
vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \
} \
@@ -546,10 +546,10 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m
for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \
for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \
if (vi.grid) { \
vi.grid = CCG_elem_next(&vi.key, vi.grid); \
vi.co = CCG_elem_co(&vi.key, vi.grid); \
vi.fno = CCG_elem_no(&vi.key, vi.grid); \
vi.mask = vi.key.has_mask ? *CCG_elem_mask(&vi.key, vi.grid) : 0.0f; \
vi.grid = CCG_elem_next(&vi.key, vi.grid); \
vi.index++; \
vi.vertex.i++; \
vi.visible = true; \

View File

@@ -134,8 +134,6 @@ void POSE_OT_rotation_mode_set(struct wmOperatorType *ot);
void POSE_OT_quaternions_flip(struct wmOperatorType *ot);
void POSE_OT_bone_layers(struct wmOperatorType *ot);
/** \} */
/* -------------------------------------------------------------------- */

View File

@@ -119,8 +119,6 @@ void ED_operatortypes_armature()
WM_operatortype_append(POSE_OT_quaternions_flip);
WM_operatortype_append(POSE_OT_bone_layers);
WM_operatortype_append(POSE_OT_propagate);
/* POSELIB */

View File

@@ -746,95 +746,6 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot)
ot->srna, "all", true, "All Layers", "Enable all layers or just the first 16 (top row)");
}
/* ------------------- */
/* Present a popup to get the layers that should be used */
static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
/* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
bool layers[32] = {false};
/* get layers that are active already */
CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
short bit;
/* loop over the bits for this pchan's layers, adding layers where they're needed */
for (bit = 0; bit < 32; bit++) {
layers[bit] = (pchan->bone->layer & (1u << bit)) != 0;
}
}
CTX_DATA_END;
/* copy layers to operator */
RNA_boolean_set_array(op->ptr, "layers", layers);
/* part to sync with other similar operators... */
return WM_operator_props_popup(C, op, event);
}
/* Set the visible layers for the active armature (edit and pose modes) */
static int pose_bone_layers_exec(bContext *C, wmOperator *op)
{
/* hardcoded for now - we can only have 32 armature layers, so this should be fine... */
bool layers[32];
/* get the values set in the operator properties */
RNA_boolean_get_array(op->ptr, "layers", layers);
Object *prev_ob = nullptr;
/* Make sure that the pose bone data is up to date.
* (May not always be the case after undo/redo e.g.).
*/
Main *bmain = CTX_data_main(C);
wmWindow *win = CTX_wm_window(C);
View3D *v3d = CTX_wm_view3d(C); /* This may be nullptr in a lot of cases. */
const Scene *scene = WM_window_get_active_scene(win);
ViewLayer *view_layer = WM_window_get_active_view_layer(win);
FOREACH_OBJECT_IN_MODE_BEGIN (scene, view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) {
bArmature *arm = static_cast<bArmature *>(ob_iter->data);
BKE_pose_ensure(bmain, ob_iter, arm, true);
}
FOREACH_OBJECT_IN_MODE_END;
/* set layers of pchans based on the values set in the operator props */
CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
/* get pointer for pchan, and write flags this way */
PointerRNA ptr = RNA_pointer_create((ID *)ob->data, &RNA_Bone, pchan->bone);
RNA_boolean_set_array(&ptr, "layers", layers);
if (prev_ob != ob) {
/* NOTE: notifier might evolve. */
WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
DEG_id_tag_update((ID *)ob->data, ID_RECALC_COPY_ON_WRITE);
prev_ob = ob;
}
}
CTX_DATA_END;
return OPERATOR_FINISHED;
}
void POSE_OT_bone_layers(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Change Bone Layers";
ot->idname = "POSE_OT_bone_layers";
ot->description = "Change the layers that the selected bones belong to";
/* callbacks */
ot->invoke = pose_bone_layers_invoke;
ot->exec = pose_bone_layers_exec;
ot->poll = ED_operator_posemode_exclusive;
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean_layer_member(
ot->srna, "layers", 32, nullptr, "Layer", "Armature layers that bone belongs to");
}
/* ********************************************** */
/* Show/Hide Bones */

View File

@@ -34,6 +34,7 @@
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_mesh.hh"
#include "BKE_mesh_wrapper.hh"
#include "BKE_modifier.h"
#include "BKE_object_deform.h"
#include "BKE_screen.hh"
@@ -380,6 +381,15 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
{
using namespace blender;
if (mesh->totvert == 0) {
/* Output just the start cap even if the mesh is empty. */
Object *start_cap_ob = amd->start_cap;
if (start_cap_ob && start_cap_ob != ctx->object) {
Mesh *start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(start_cap_ob);
if (start_cap_mesh) {
BKE_mesh_wrapper_ensure_mdata(start_cap_mesh);
return BKE_mesh_copy_for_eval(start_cap_mesh);
}
}
return mesh;
}
@@ -428,6 +438,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(start_cap_ob);
if (start_cap_mesh) {
BKE_mesh_wrapper_ensure_mdata(start_cap_mesh);
start_cap_nverts = start_cap_mesh->totvert;
start_cap_nedges = start_cap_mesh->totedge;
start_cap_nloops = start_cap_mesh->totloop;
@@ -443,6 +454,7 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(end_cap_ob);
if (end_cap_mesh) {
BKE_mesh_wrapper_ensure_mdata(end_cap_mesh);
end_cap_nverts = end_cap_mesh->totvert;
end_cap_nedges = end_cap_mesh->totedge;
end_cap_nloops = end_cap_mesh->totloop;