From 44505b38df557a5711703613685a1dec9fc2c3d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Jun 2018 09:31:30 +0200 Subject: Cleanup: strip trailing space in editors --- .../editors/animation/anim_channels_defines.c | 1148 ++++++++++---------- .../blender/editors/animation/anim_channels_edit.c | 896 +++++++-------- source/blender/editors/animation/anim_deps.c | 92 +- source/blender/editors/animation/anim_draw.c | 52 +- source/blender/editors/animation/anim_filter.c | 884 +++++++-------- source/blender/editors/animation/anim_intern.h | 6 +- source/blender/editors/animation/anim_ipo_utils.c | 58 +- source/blender/editors/animation/anim_markers.c | 230 ++-- source/blender/editors/animation/anim_ops.c | 82 +- source/blender/editors/animation/drivers.c | 318 +++--- source/blender/editors/animation/fmodifier_ui.c | 242 ++--- source/blender/editors/animation/keyframes_draw.c | 314 +++--- source/blender/editors/animation/keyframes_edit.c | 322 +++--- .../blender/editors/animation/keyframes_general.c | 212 ++-- source/blender/editors/animation/keyframing.c | 600 +++++----- source/blender/editors/animation/keyingsets.c | 294 ++--- source/blender/editors/armature/BIF_generate.h | 6 +- source/blender/editors/armature/BIF_retarget.h | 16 +- source/blender/editors/armature/armature_add.c | 176 +-- source/blender/editors/armature/armature_edit.c | 264 ++--- source/blender/editors/armature/armature_intern.h | 10 +- source/blender/editors/armature/armature_naming.c | 64 +- source/blender/editors/armature/armature_ops.c | 102 +- .../blender/editors/armature/armature_relations.c | 236 ++-- source/blender/editors/armature/armature_select.c | 88 +- .../blender/editors/armature/armature_skinning.c | 62 +- source/blender/editors/armature/armature_utils.c | 90 +- .../editors/armature/editarmature_generate.c | 92 +- .../editors/armature/editarmature_retarget.c | 752 ++++++------- .../blender/editors/armature/editarmature_sketch.c | 8 +- source/blender/editors/armature/meshlaplacian.c | 50 +- source/blender/editors/armature/pose_edit.c | 290 ++--- source/blender/editors/armature/pose_group.c | 96 +- source/blender/editors/armature/pose_lib.c | 468 ++++---- source/blender/editors/armature/pose_select.c | 190 ++-- source/blender/editors/armature/pose_slide.c | 432 ++++---- source/blender/editors/armature/pose_transform.c | 216 ++-- source/blender/editors/armature/pose_utils.c | 78 +- source/blender/editors/armature/reeb.c | 848 +++++++-------- source/blender/editors/armature/reeb.h | 14 +- source/blender/editors/curve/curve_ops.c | 18 +- source/blender/editors/curve/editcurve.c | 216 ++-- source/blender/editors/curve/editcurve_paint.c | 2 +- source/blender/editors/curve/editfont.c | 132 +-- source/blender/editors/gpencil/drawgpencil.c | 358 +++--- .../blender/editors/gpencil/editaction_gpencil.c | 152 +-- source/blender/editors/gpencil/gpencil_brush.c | 460 ++++---- source/blender/editors/gpencil/gpencil_convert.c | 324 +++--- source/blender/editors/gpencil/gpencil_data.c | 164 +-- source/blender/editors/gpencil/gpencil_edit.c | 576 +++++----- .../blender/editors/gpencil/gpencil_interpolate.c | 280 ++--- source/blender/editors/gpencil/gpencil_ops.c | 164 +-- source/blender/editors/gpencil/gpencil_paint.c | 516 ++++----- source/blender/editors/gpencil/gpencil_select.c | 324 +++--- source/blender/editors/gpencil/gpencil_undo.c | 52 +- source/blender/editors/gpencil/gpencil_utils.c | 148 +-- source/blender/editors/include/BIF_gl.h | 2 +- source/blender/editors/include/ED_anim_api.h | 92 +- source/blender/editors/include/ED_armature.h | 6 +- source/blender/editors/include/ED_gpencil.h | 2 +- source/blender/editors/include/ED_keyframes_draw.h | 14 +- source/blender/editors/include/ED_keyframes_edit.h | 8 +- source/blender/editors/include/ED_keyframing.h | 30 +- source/blender/editors/include/ED_markers.h | 2 +- source/blender/editors/include/ED_screen_types.h | 2 +- source/blender/editors/include/ED_space_api.h | 4 +- source/blender/editors/include/ED_view3d.h | 2 +- source/blender/editors/include/UI_icons.h | 28 +- source/blender/editors/include/UI_interface.h | 10 +- source/blender/editors/include/UI_resources.h | 46 +- source/blender/editors/include/UI_view2d.h | 6 +- source/blender/editors/io/io_collada.c | 6 +- source/blender/editors/io/io_ops.c | 2 +- source/blender/editors/mask/mask_editaction.c | 10 +- source/blender/editors/mesh/editface.c | 30 +- source/blender/editors/mesh/editmesh_bevel.c | 12 +- source/blender/editors/mesh/editmesh_knife.c | 4 +- source/blender/editors/mesh/editmesh_loopcut.c | 38 +- source/blender/editors/mesh/mesh_data.c | 32 +- source/blender/editors/mesh/mesh_mirror.c | 2 +- source/blender/editors/mesh/mesh_navmesh.c | 8 +- source/blender/editors/mesh/mesh_ops.c | 42 +- source/blender/editors/mesh/meshtools.c | 104 +- source/blender/editors/metaball/mball_edit.c | 36 +- source/blender/editors/metaball/mball_ops.c | 12 +- source/blender/editors/object/object_add.c | 16 +- source/blender/editors/object/object_bake.c | 4 +- source/blender/editors/object/object_bake_api.c | 2 +- source/blender/editors/object/object_constraint.c | 406 +++---- source/blender/editors/object/object_edit.c | 270 ++--- source/blender/editors/object/object_group.c | 44 +- source/blender/editors/object/object_hook.c | 178 +-- source/blender/editors/object/object_modifier.c | 268 ++--- source/blender/editors/object/object_ops.c | 38 +- source/blender/editors/object/object_select.c | 130 +-- source/blender/editors/object/object_shapekey.c | 16 +- source/blender/editors/object/object_transform.c | 98 +- source/blender/editors/object/object_vgroup.c | 72 +- source/blender/editors/physics/dynamicpaint_ops.c | 24 +- source/blender/editors/physics/particle_boids.c | 42 +- source/blender/editors/physics/particle_edit.c | 192 ++-- source/blender/editors/physics/particle_object.c | 192 ++-- source/blender/editors/physics/physics_fluid.c | 266 ++--- source/blender/editors/physics/physics_ops.c | 8 +- .../blender/editors/physics/physics_pointcache.c | 30 +- source/blender/editors/physics/rigidbody_world.c | 4 +- source/blender/editors/render/render_internal.c | 118 +- source/blender/editors/render/render_opengl.c | 12 +- source/blender/editors/render/render_ops.c | 2 +- source/blender/editors/render/render_preview.c | 132 +-- source/blender/editors/render/render_shading.c | 128 +-- source/blender/editors/render/render_update.c | 38 +- source/blender/editors/render/render_view.c | 12 +- source/blender/editors/screen/area.c | 266 ++--- source/blender/editors/screen/glutil.c | 86 +- source/blender/editors/screen/screen_context.c | 64 +- source/blender/editors/screen/screen_draw.c | 2 +- source/blender/editors/screen/screen_edit.c | 274 ++--- source/blender/editors/screen/screen_ops.c | 774 ++++++------- source/blender/editors/screen/screendump.c | 92 +- source/blender/editors/sculpt_paint/paint_cursor.c | 4 +- source/blender/editors/sculpt_paint/paint_curve.c | 8 +- source/blender/editors/sculpt_paint/paint_hide.c | 16 +- source/blender/editors/sculpt_paint/paint_image.c | 46 +- .../blender/editors/sculpt_paint/paint_image_2d.c | 8 +- .../editors/sculpt_paint/paint_image_proj.c | 108 +- source/blender/editors/sculpt_paint/paint_ops.c | 24 +- source/blender/editors/sculpt_paint/paint_stroke.c | 24 +- source/blender/editors/sculpt_paint/paint_utils.c | 24 +- source/blender/editors/sculpt_paint/paint_vertex.c | 2 +- .../sculpt_paint/paint_vertex_weight_utils.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 68 +- .../blender/editors/sculpt_paint/sculpt_intern.h | 2 +- source/blender/editors/sculpt_paint/sculpt_undo.c | 26 +- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 +- .../blender/editors/space_action/action_buttons.c | 12 +- source/blender/editors/space_action/action_data.c | 208 ++-- source/blender/editors/space_action/action_draw.c | 110 +- source/blender/editors/space_action/action_edit.c | 508 ++++----- .../blender/editors/space_action/action_intern.h | 8 +- source/blender/editors/space_action/action_ops.c | 74 +- .../blender/editors/space_action/action_select.c | 464 ++++---- source/blender/editors/space_action/space_action.c | 146 +-- source/blender/editors/space_api/spacetypes.c | 38 +- .../editors/space_buttons/buttons_context.c | 16 +- .../blender/editors/space_buttons/buttons_intern.h | 2 +- source/blender/editors/space_buttons/buttons_ops.c | 10 +- .../editors/space_buttons/buttons_texture.c | 14 +- .../blender/editors/space_buttons/space_buttons.c | 28 +- source/blender/editors/space_clip/clip_editor.c | 2 +- .../editors/space_clip/tracking_ops_intern.h | 2 +- .../blender/editors/space_console/console_draw.c | 12 +- source/blender/editors/space_console/console_ops.c | 98 +- .../blender/editors/space_console/space_console.c | 76 +- source/blender/editors/space_file/file_draw.c | 26 +- source/blender/editors/space_file/file_ops.c | 160 +-- source/blender/editors/space_file/filelist.c | 32 +- source/blender/editors/space_file/filesel.c | 30 +- source/blender/editors/space_file/fsmenu.c | 26 +- source/blender/editors/space_file/fsmenu.h | 2 +- source/blender/editors/space_file/space_file.c | 44 +- source/blender/editors/space_graph/graph_buttons.c | 282 ++--- source/blender/editors/space_graph/graph_draw.c | 384 +++---- source/blender/editors/space_graph/graph_edit.c | 864 +++++++-------- source/blender/editors/space_graph/graph_intern.h | 6 +- source/blender/editors/space_graph/graph_ops.c | 206 ++-- source/blender/editors/space_graph/graph_select.c | 498 ++++----- source/blender/editors/space_graph/graph_utils.c | 64 +- source/blender/editors/space_graph/space_graph.c | 190 ++-- source/blender/editors/space_image/image_buttons.c | 72 +- source/blender/editors/space_image/image_draw.c | 48 +- source/blender/editors/space_image/image_edit.c | 4 +- source/blender/editors/space_image/image_ops.c | 194 ++-- source/blender/editors/space_image/space_image.c | 96 +- source/blender/editors/space_info/info_draw.c | 4 +- source/blender/editors/space_info/info_ops.c | 104 +- source/blender/editors/space_info/info_report.c | 2 +- source/blender/editors/space_info/info_stats.c | 22 +- source/blender/editors/space_info/space_info.c | 50 +- source/blender/editors/space_info/textview.c | 12 +- source/blender/editors/space_info/textview.h | 2 +- source/blender/editors/space_logic/logic_buttons.c | 18 +- source/blender/editors/space_logic/logic_ops.c | 152 +-- source/blender/editors/space_logic/logic_window.c | 264 ++--- source/blender/editors/space_logic/space_logic.c | 82 +- source/blender/editors/space_nla/nla_buttons.c | 126 +-- source/blender/editors/space_nla/nla_channels.c | 208 ++-- source/blender/editors/space_nla/nla_draw.c | 232 ++-- source/blender/editors/space_nla/nla_edit.c | 900 +++++++-------- source/blender/editors/space_nla/nla_ops.c | 130 +-- source/blender/editors/space_nla/nla_select.c | 196 ++-- source/blender/editors/space_nla/space_nla.c | 124 +-- source/blender/editors/space_node/drawnode.c | 404 +++---- source/blender/editors/space_node/node_add.c | 96 +- source/blender/editors/space_node/node_buttons.c | 36 +- source/blender/editors/space_node/node_draw.c | 292 ++--- source/blender/editors/space_node/node_edit.c | 358 +++--- source/blender/editors/space_node/node_group.c | 288 ++--- source/blender/editors/space_node/node_intern.h | 2 +- source/blender/editors/space_node/node_ops.c | 68 +- .../editors/space_node/node_relationships.c | 64 +- source/blender/editors/space_node/node_select.c | 182 ++-- source/blender/editors/space_node/node_templates.c | 52 +- source/blender/editors/space_node/node_toolbar.c | 6 +- source/blender/editors/space_node/node_view.c | 10 +- source/blender/editors/space_node/space_node.c | 70 +- .../blender/editors/space_outliner/outliner_draw.c | 292 ++--- .../blender/editors/space_outliner/outliner_edit.c | 352 +++--- .../editors/space_outliner/outliner_intern.h | 2 +- .../blender/editors/space_outliner/outliner_ops.c | 34 +- .../editors/space_outliner/outliner_select.c | 126 +-- .../editors/space_outliner/outliner_tools.c | 238 ++-- .../blender/editors/space_outliner/outliner_tree.c | 286 ++--- .../editors/space_outliner/space_outliner.c | 44 +- source/blender/editors/space_script/space_script.c | 52 +- .../editors/space_sequencer/sequencer_add.c | 96 +- .../editors/space_sequencer/sequencer_buttons.c | 8 +- .../editors/space_sequencer/sequencer_draw.c | 210 ++-- .../editors/space_sequencer/sequencer_edit.c | 324 +++--- .../editors/space_sequencer/sequencer_intern.h | 2 +- .../editors/space_sequencer/sequencer_ops.c | 6 +- .../editors/space_sequencer/sequencer_preview.c | 24 +- .../editors/space_sequencer/sequencer_scopes.c | 26 +- .../editors/space_sequencer/sequencer_select.c | 136 +-- .../editors/space_sequencer/sequencer_view.c | 4 +- .../editors/space_sequencer/space_sequencer.c | 46 +- source/blender/editors/space_text/space_text.c | 82 +- source/blender/editors/space_text/text_draw.c | 66 +- source/blender/editors/space_text/text_format.c | 2 +- .../blender/editors/space_text/text_format_lua.c | 4 +- .../blender/editors/space_text/text_format_osl.c | 2 +- source/blender/editors/space_text/text_header.c | 22 +- source/blender/editors/space_text/text_ops.c | 176 +-- source/blender/editors/space_time/space_time.c | 146 +-- source/blender/editors/space_time/time_ops.c | 38 +- .../editors/space_userpref/space_userpref.c | 8 +- source/blender/editors/space_view3d/drawanimviz.c | 86 +- source/blender/editors/space_view3d/drawarmature.c | 702 ++++++------ source/blender/editors/space_view3d/drawmesh.c | 36 +- source/blender/editors/space_view3d/drawobject.c | 376 +++---- source/blender/editors/space_view3d/drawsimdebug.c | 52 +- source/blender/editors/space_view3d/space_view3d.c | 138 +-- .../blender/editors/space_view3d/view3d_buttons.c | 4 +- source/blender/editors/space_view3d/view3d_draw.c | 278 ++--- source/blender/editors/space_view3d/view3d_fly.c | 8 +- .../blender/editors/space_view3d/view3d_header.c | 30 +- source/blender/editors/space_view3d/view3d_ops.c | 54 +- .../blender/editors/space_view3d/view3d_project.c | 16 +- source/blender/editors/space_view3d/view3d_ruler.c | 2 +- .../blender/editors/space_view3d/view3d_select.c | 180 +-- source/blender/editors/space_view3d/view3d_snap.c | 80 +- .../blender/editors/space_view3d/view3d_toolbar.c | 36 +- source/blender/editors/space_view3d/view3d_view.c | 120 +- source/blender/editors/util/ed_util.c | 6 +- source/blender/editors/uvedit/uvedit_buttons.c | 12 +- source/blender/editors/uvedit/uvedit_draw.c | 72 +- source/blender/editors/uvedit/uvedit_ops.c | 150 +-- .../blender/editors/uvedit/uvedit_parametrizer.c | 168 +-- .../blender/editors/uvedit/uvedit_parametrizer.h | 2 +- .../blender/editors/uvedit/uvedit_smart_stitch.c | 2 +- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 70 +- 261 files changed, 17343 insertions(+), 17343 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index dba060bfb29..304d548b01b 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -116,11 +116,11 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - + /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); glColor3fv(color); - + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ UI_draw_roundbox_corner_set((expanded) ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); UI_draw_roundbox_gl_mode(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); @@ -141,11 +141,11 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale View2D *v2d = &ac->ar->v2d; short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - + /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); glColor3fv(color); - + /* no rounded corner - just rectangular box */ glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } @@ -154,7 +154,7 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale static bool acf_show_channel_colors(bAnimContext *ac) { bool showGroupColors = false; - + if (ac->sl) { switch (ac->spacetype) { case SPACE_ACTION: @@ -173,7 +173,7 @@ static bool acf_show_channel_colors(bAnimContext *ac) } } } - + return showGroupColors; } @@ -184,19 +184,19 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa bActionGroup *grp = NULL; short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; bool showGroupColors = acf_show_channel_colors(ac); - + if (ale->type == ANIMTYPE_FCURVE) { FCurve *fcu = (FCurve *)ale->data; grp = fcu->grp; } - - /* set color for normal channels + + /* set color for normal channels * - use 3 shades of color group/standard color for 3 indention level * - only use group colors if allowed to, and if actually feasible */ if (showGroupColors && (grp) && (grp->customCol)) { unsigned char cp[3]; - + if (indent == 2) { copy_v3_v3_char((char *)cp, grp->cs.solid); } @@ -206,7 +206,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa else { copy_v3_v3_char((char *)cp, grp->cs.active); } - + /* copy the colors over, transforming from bytes to floats */ rgb_uchar_to_float(r_color, cp); } @@ -224,11 +224,11 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f View2D *v2d = &ac->ar->v2d; short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - + /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); glColor3fv(color); - + /* no rounded corners - just rectangular box */ glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } @@ -255,16 +255,16 @@ static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale) static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListElem *ale) { short indent = 0; - + /* grouped F-Curves need extra level of indention */ if (ale->type == ANIMTYPE_FCURVE) { FCurve *fcu = (FCurve *)ale->data; - + // TODO: we need some way of specifying that the indention color should be one less... if (fcu->grp) indent++; } - + /* no indention */ return indent; } @@ -273,7 +273,7 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + if (acf && acf->get_indent_level) return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE; else @@ -286,21 +286,21 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree) if (ntree) { switch (ntree->type) { case NTREE_SHADER: - /* 1 additional level (i.e. is indented one level in from material, - * so shift all right by one step) + /* 1 additional level (i.e. is indented one level in from material, + * so shift all right by one step) */ - return INDENT_STEP_SIZE; - + return INDENT_STEP_SIZE; + case NTREE_COMPOSIT: /* no additional levels needed */ - return 0; - + return 0; + case NTREE_TEXTURE: /* 2 additional levels */ return INDENT_STEP_SIZE * 2; } } - + /* unknown */ return 0; } @@ -309,7 +309,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree) static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) { short offset = acf_generic_basic_offset(ac, ale); - + if (ale->id) { /* texture animdata */ if (GS(ale->id->name) == ID_TE) { @@ -318,17 +318,17 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) /* materials and particles animdata */ else if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) offset += (short)(0.7f * U.widget_unit); - + /* if not in Action Editor mode, action-groups (and their children) must carry some offset too... */ else if (ac->datatype != ANIMCONT_ACTION) offset += (short)(0.7f * U.widget_unit); - + /* nodetree animdata */ if (GS(ale->id->name) == ID_NT) { offset += acf_nodetree_rootType_offset((bNodeTree *)ale->id); } } - + /* offset is just the normal type - i.e. based on indention */ return offset; } @@ -339,7 +339,7 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) static void acf_generic_idblock_name(bAnimListElem *ale, char *name) { ID *id = (ID *)ale->data; /* data pointed to should be an ID block */ - + /* just copy the name... */ if (id && name) BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE); @@ -350,7 +350,7 @@ static bool acf_generic_idblock_name_prop(bAnimListElem *ale, PointerRNA *ptr, P { RNA_id_pointer_create(ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } @@ -361,7 +361,7 @@ static bool acf_generic_idfill_name_prop(bAnimListElem *ale, PointerRNA *ptr, Pr /* actual ID we're representing is stored in ale->data not ale->id, as id gives the owner */ RNA_id_pointer_create(ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } @@ -382,11 +382,11 @@ static bool acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListElem /* expand is always supported */ case ACHANNEL_SETTING_EXPAND: return true; - + /* mute is only supported for NLA */ case ACHANNEL_SETTING_MUTE: return ((ac) && (ac->spacetype == SPACE_NLA)); - + /* select is ok for most "ds*" channels (e.g. dsmat) */ case ACHANNEL_SETTING_SELECT: return true; @@ -418,14 +418,14 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); View2D *v2d = &ac->ar->v2d; float color[3]; - + /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); glColor3fv(color); - - /* rounded corners on LHS only - * - top and bottom - * - special hack: make the top a bit higher, since we are first... + + /* rounded corners on LHS only + * - top and bottom + * - special hack: make the top a bit higher, since we are first... */ UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); UI_draw_roundbox_gl_mode(GL_POLYGON, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); @@ -470,14 +470,14 @@ static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti static void *acf_summary_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { bAnimContext *ac = (bAnimContext *)ale->data; - - /* if data is valid, return pointer to active dopesheet's relevant flag + + /* if data is valid, return pointer to active dopesheet's relevant flag * - this is restricted to DopeSheet/Action Editor only */ if ((ac->sl) && (ac->spacetype == SPACE_ACTION) && (setting == ACHANNEL_SETTING_EXPAND)) { SpaceAction *saction = (SpaceAction *)ac->sl; bDopeSheet *ads = &saction->ads; - + /* return pointer to DopeSheet's flag */ return GET_ACF_FLAG_PTR(ads->flag, type); } @@ -489,7 +489,7 @@ static void *acf_summary_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings s } /* all animation summary (DopeSheet only) type define */ -static bAnimChannelType ACF_SUMMARY = +static bAnimChannelType ACF_SUMMARY = { "Summary", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ @@ -521,13 +521,13 @@ static bool acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale) { switch (setting) { /* muted only in NLA */ - case ACHANNEL_SETTING_MUTE: + case ACHANNEL_SETTING_MUTE: return ((ac) && (ac->spacetype == SPACE_NLA)); - + /* visible only in Graph Editor */ - case ACHANNEL_SETTING_VISIBLE: + case ACHANNEL_SETTING_VISIBLE: return ((ac) && (ac->spacetype == SPACE_IPO)); - + /* only select and expand supported otherwise */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: @@ -546,18 +546,18 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return SCE_DS_SELECTED; - + case ACHANNEL_SETTING_EXPAND: /* expanded */ *neg = true; return SCE_DS_COLLAPSED; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; @@ -571,30 +571,30 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_scene_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Scene *scene = (Scene *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return GET_ACF_FLAG_PTR(scene->flag, type); - + case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(scene->flag, type); - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (scene->adt) return GET_ACF_FLAG_PTR(scene->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } } /* scene type define */ -static bAnimChannelType ACF_SCENE = +static bAnimChannelType ACF_SCENE = { "Scene", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ @@ -619,30 +619,30 @@ static int acf_object_icon(bAnimListElem *ale) { Base *base = (Base *)ale->data; Object *ob = base->object; - + /* icon depends on object-type */ switch (ob->type) { case OB_LAMP: return ICON_OUTLINER_OB_LAMP; - case OB_MESH: + case OB_MESH: return ICON_OUTLINER_OB_MESH; - case OB_CAMERA: + case OB_CAMERA: return ICON_OUTLINER_OB_CAMERA; - case OB_CURVE: + case OB_CURVE: return ICON_OUTLINER_OB_CURVE; - case OB_MBALL: + case OB_MBALL: return ICON_OUTLINER_OB_META; - case OB_LATTICE: + case OB_LATTICE: return ICON_OUTLINER_OB_LATTICE; case OB_SPEAKER: return ICON_OUTLINER_OB_SPEAKER; case OB_ARMATURE: return ICON_OUTLINER_OB_ARMATURE; - case OB_FONT: + case OB_FONT: return ICON_OUTLINER_OB_FONT; - case OB_SURF: + case OB_SURF: return ICON_OUTLINER_OB_SURFACE; - case OB_EMPTY: + case OB_EMPTY: return ICON_OUTLINER_OB_EMPTY; default: return ICON_OBJECT_DATA; @@ -654,7 +654,7 @@ static void acf_object_name(bAnimListElem *ale, char *name) { Base *base = (Base *)ale->data; Object *ob = base->object; - + /* just copy the name... */ if (ob && name) BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE); @@ -665,7 +665,7 @@ static bool acf_object_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN { RNA_id_pointer_create(ale->id, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } @@ -674,16 +674,16 @@ static bool acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnim { Base *base = (Base *)ale->data; Object *ob = base->object; - + switch (setting) { /* muted only in NLA */ - case ACHANNEL_SETTING_MUTE: + case ACHANNEL_SETTING_MUTE: return ((ac) && (ac->spacetype == SPACE_NLA)); - + /* visible only in Graph Editor */ - case ACHANNEL_SETTING_VISIBLE: + case ACHANNEL_SETTING_VISIBLE: return ((ac) && (ac->spacetype == SPACE_IPO) && (ob->adt)); - + /* only select and expand supported otherwise */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: @@ -702,18 +702,18 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return SELECT; - + case ACHANNEL_SETTING_EXPAND: /* expanded */ *neg = 1; return OB_ADS_COLLAPSED; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; @@ -731,17 +731,17 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se { Base *base = (Base *)ale->data; Object *ob = base->object; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return GET_ACF_FLAG_PTR(ob->flag, type); - + case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(ob->nlaflag, type); // xxx - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ case ACHANNEL_SETTING_ALWAYS_VISIBLE: @@ -755,11 +755,11 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings se } /* object type define */ -static bAnimChannelType ACF_OBJECT = +static bAnimChannelType ACF_OBJECT = { "Object", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_root_color, /* backdrop color */ acf_generic_root_backdrop, /* backdrop */ acf_generic_indention_0, /* indent level */ @@ -781,16 +781,16 @@ static void acf_group_color(bAnimContext *ac, bAnimListElem *ale, float r_color[ { bActionGroup *agrp = (bActionGroup *)ale->data; bool showGroupColors = acf_show_channel_colors(ac); - + if (showGroupColors && agrp->customCol) { unsigned char cp[3]; - + /* highlight only for active */ if (ale->flag & AGRP_ACTIVE) copy_v3_v3_char((char *)cp, agrp->cs.select); else copy_v3_v3_char((char *)cp, agrp->cs.solid); - + /* copy the colors over, transforming from bytes to floats */ rgb_uchar_to_float(r_color, cp); } @@ -811,11 +811,11 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - + /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); glColor3fv(color); - + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); UI_draw_roundbox_gl_mode(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); @@ -825,7 +825,7 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc static void acf_group_name(bAnimListElem *ale, char *name) { bActionGroup *agrp = (bActionGroup *)ale->data; - + /* just copy the name... */ if (agrp && name) BLI_strncpy(name, agrp->name, ANIM_CHAN_NAME_SIZE); @@ -836,7 +836,7 @@ static bool acf_group_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA { RNA_pointer_create(ale->id, &RNA_ActionGroup, ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } @@ -848,7 +848,7 @@ static bool acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale) /* unsupported */ case ACHANNEL_SETTING_SOLO: /* Only available in NLA Editor for tracks */ return false; - + /* conditionally supported */ case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ return (ac->spacetype == SPACE_IPO); @@ -866,22 +866,22 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return AGRP_SELECTED; - + case ACHANNEL_SETTING_EXPAND: /* expanded */ { /* NOTE: Graph Editor uses a different flag to everywhere else for this, * allowing different collapsing of groups there, since sharing the flag * proved to be a hazard for workflows... */ - return (ac->spacetype == SPACE_IPO) ? + return (ac->spacetype == SPACE_IPO) ? AGRP_EXPANDED_G : /* Graph Editor case */ AGRP_EXPANDED; /* DopeSheet and elsewhere */ } - + case ACHANNEL_SETTING_MUTE: /* muted */ return AGRP_MUTED; @@ -891,7 +891,7 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin case ACHANNEL_SETTING_PROTECT: /* protected */ return AGRP_PROTECTED; - + case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ *neg = 1; return AGRP_NOTVISIBLE; @@ -909,17 +909,17 @@ static int acf_group_setting_flag(bAnimContext *ac, eAnimChannel_Settings settin static void *acf_group_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) { bActionGroup *agrp = (bActionGroup *)ale->data; - + /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(agrp->flag, type); } /* group type define */ -static bAnimChannelType ACF_GROUP = +static bAnimChannelType ACF_GROUP = { "Group", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_group_color, /* backdrop color */ acf_group_backdrop, /* backdrop */ acf_generic_indention_0, /* indent level */ @@ -946,9 +946,9 @@ static void acf_fcurve_name(bAnimListElem *ale, char *name) static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { FCurve *fcu = (FCurve *)ale->data; - - /* Ctrl-Click Usability Convenience Hack: - * For disabled F-Curves, allow access to the RNA Path + + /* Ctrl-Click Usability Convenience Hack: + * For disabled F-Curves, allow access to the RNA Path * as our "name" so that user can perform quick fixes */ if (fcu->flag & FCURVE_DISABLED) { @@ -959,7 +959,7 @@ static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN /* for "normal" F-Curves - no editable name, but *prop may not be set properly yet... */ *prop = NULL; } - + return (*prop != NULL); } @@ -967,21 +967,21 @@ static bool acf_fcurve_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRN static bool acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting) { FCurve *fcu = (FCurve *)ale->data; - + switch (setting) { /* unsupported */ case ACHANNEL_SETTING_SOLO: /* Solo Flag is only for NLA */ case ACHANNEL_SETTING_EXPAND: /* F-Curves are not containers */ case ACHANNEL_SETTING_PINNED: /* This is only for NLA Actions */ return false; - + /* conditionally available */ case ACHANNEL_SETTING_PROTECT: /* Protection is only valid when there's keyframes */ if (fcu->bezt) return true; else return false; // NOTE: in this special case, we need to draw ICON_ZOOMOUT - + case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ return (ac->spacetype == SPACE_IPO); @@ -999,20 +999,20 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return FCURVE_SELECTED; - + case ACHANNEL_SETTING_MUTE: /* muted */ return FCURVE_MUTED; - + case ACHANNEL_SETTING_PROTECT: /* protected */ return FCURVE_PROTECTED; - + case ACHANNEL_SETTING_VISIBLE: /* visibility - graph editor */ return FCURVE_VISIBLE; - + case ACHANNEL_SETTING_MOD_OFF: *neg = 1; return FCURVE_MOD_OFF; @@ -1026,17 +1026,17 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin static void *acf_fcurve_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) { FCurve *fcu = (FCurve *)ale->data; - + /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(fcu->flag, type); } /* fcurve type define */ -static bAnimChannelType ACF_FCURVE = +static bAnimChannelType ACF_FCURVE = { "F-Curve", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_generic_channel_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? @@ -1068,11 +1068,11 @@ static void acf_nla_controls_backdrop(bAnimContext *ac, bAnimListElem *ale, floa short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; - + /* set backdrop drawing color */ acf->get_backdrop_color(ac, ale, color); glColor3fv(color); - + /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ UI_draw_roundbox_corner_set(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); UI_draw_roundbox_gl_mode(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 5); @@ -1092,9 +1092,9 @@ static bool acf_nla_controls_setting_valid(bAnimContext *UNUSED(ac), bAnimListEl /* supported */ case ACHANNEL_SETTING_EXPAND: return true; - + // TOOD: selected? - + default: /* unsupported */ return false; } @@ -1105,12 +1105,12 @@ static int acf_nla_controls_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_ { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ *neg = true; return ADT_NLA_SKEYS_COLLAPSED; - + default: /* this shouldn't happen */ return 0; @@ -1121,7 +1121,7 @@ static int acf_nla_controls_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_ static void *acf_nla_controls_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) { AnimData *adt = (AnimData *)ale->data; - + /* all flags are just in adt->flag for now... */ return GET_ACF_FLAG_PTR(adt->flag, type); } @@ -1132,11 +1132,11 @@ static int acf_nla_controls_icon(bAnimListElem *UNUSED(ale)) } /* NLA Control FCurves Expander type define */ -static bAnimChannelType ACF_NLACONTROLS = +static bAnimChannelType ACF_NLACONTROLS = { "NLA Controls Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_nla_controls_color, /* backdrop color */ acf_nla_controls_backdrop, /* backdrop */ acf_generic_indention_0, /* indent level */ @@ -1160,7 +1160,7 @@ static void acf_nla_curve_name(bAnimListElem *ale, char *name) NlaStrip *strip = ale->owner; FCurve *fcu = ale->data; PropertyRNA *prop; - + /* try to get RNA property that this shortened path (relative to the strip) refers to */ prop = RNA_struct_type_find_property(&RNA_NlaStrip, fcu->rna_path); if (prop) { @@ -1175,11 +1175,11 @@ static void acf_nla_curve_name(bAnimListElem *ale, char *name) /* NLA Control F-Curve type define */ -static bAnimChannelType ACF_NLACURVE = +static bAnimChannelType ACF_NLACURVE = { "NLA Control F-Curve", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_generic_channel_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1210,7 +1210,7 @@ static bool acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: return true; - + default: return false; } @@ -1221,15 +1221,15 @@ static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + case ACHANNEL_SETTING_EXPAND: /* expanded */ *neg = true; return ACT_COLLAPSED; - + default: /* unsupported */ return 0; } @@ -1240,10 +1240,10 @@ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings { bAction *act = (bAction *)ale->data; AnimData *adt = ale->adt; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ if (adt) { @@ -1253,18 +1253,18 @@ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(act->flag, type); - + default: /* unsupported */ return NULL; } } /* object action expander type define */ -static bAnimChannelType ACF_FILLACTD = +static bAnimChannelType ACF_FILLACTD = { "Ob-Action Filler", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1300,7 +1300,7 @@ static bool acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListEle /* only expand supported */ case ACHANNEL_SETTING_EXPAND: return true; - + default: return false; } @@ -1311,12 +1311,12 @@ static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ *neg = true; return ADT_DRIVERS_COLLAPSED; - + default: /* unsupported */ return 0; } @@ -1326,25 +1326,25 @@ static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { AnimData *adt = (AnimData *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(adt->flag, type); - + default: /* unsupported */ return NULL; } } /* drivers expander type define */ -static bAnimChannelType ACF_FILLDRIVERS = +static bAnimChannelType ACF_FILLDRIVERS = { "Drivers Filler", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1373,21 +1373,21 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return MA_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -1397,14 +1397,14 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dsmat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Material *ma = (Material *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(ma->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ @@ -1422,7 +1422,7 @@ static bAnimChannelType ACF_DSMAT = { "Material Data Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1450,21 +1450,21 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return LA_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -1474,21 +1474,21 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dslam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Lamp *la = (Lamp *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(la->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (la->adt) return GET_ACF_FLAG_PTR(la->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -1499,7 +1499,7 @@ static bAnimChannelType ACF_DSLAM = { "Lamp Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1534,21 +1534,21 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return TEX_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -1558,21 +1558,21 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dstex_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Tex *tex = (Tex *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(tex->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (tex->adt) return GET_ACF_FLAG_PTR(tex->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -1583,7 +1583,7 @@ static bAnimChannelType ACF_DSTEX = { "Texture Data Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1693,18 +1693,18 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return CAM_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; @@ -1720,14 +1720,14 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Camera *ca = (Camera *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(ca->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ @@ -1735,7 +1735,7 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings set if (ca->adt) return GET_ACF_FLAG_PTR(ca->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -1746,7 +1746,7 @@ static bAnimChannelType ACF_DSCAM = { "Camera Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1768,7 +1768,7 @@ static int acf_dscur_icon(bAnimListElem *ale) { Curve *cu = (Curve *)ale->data; short obtype = BKE_curve_type_get(cu); - + switch (obtype) { case OB_FONT: return ICON_FONT_DATA; @@ -1784,21 +1784,21 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return CU_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -1808,21 +1808,21 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dscur_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Curve *cu = (Curve *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(cu->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (cu->adt) return GET_ACF_FLAG_PTR(cu->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -1833,7 +1833,7 @@ static bAnimChannelType ACF_DSCUR = { "Curve Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1861,21 +1861,21 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return KEY_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -1885,21 +1885,21 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin static void *acf_dsskey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Key *key = (Key *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(key->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (key->adt) return GET_ACF_FLAG_PTR(key->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -1910,7 +1910,7 @@ static bAnimChannelType ACF_DSSKEY = { "Shape Key Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -1938,21 +1938,21 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return WO_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -1962,21 +1962,21 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dswor_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { World *wo = (World *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(wo->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (wo->adt) return GET_ACF_FLAG_PTR(wo->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -1987,7 +1987,7 @@ static bAnimChannelType ACF_DSWOR = { "World Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -2015,21 +2015,21 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return PART_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2039,21 +2039,21 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin static void *acf_dspart_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { ParticleSettings *part = (ParticleSettings *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(part->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (part->adt) return GET_ACF_FLAG_PTR(part->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2064,7 +2064,7 @@ static bAnimChannelType ACF_DSPART = { "Particle Data Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -2092,21 +2092,21 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return MB_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2116,21 +2116,21 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti static void *acf_dsmball_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { MetaBall *mb = (MetaBall *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(mb->flag2, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (mb->adt) return GET_ACF_FLAG_PTR(mb->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2141,7 +2141,7 @@ static bAnimChannelType ACF_DSMBALL = { "Metaball Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -2169,21 +2169,21 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return ARM_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2193,21 +2193,21 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dsarm_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { bArmature *arm = (bArmature *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(arm->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (arm->adt) return GET_ACF_FLAG_PTR(arm->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2218,7 +2218,7 @@ static bAnimChannelType ACF_DSARM = { "Armature Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -2246,9 +2246,9 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale) { bNodeTree *ntree = (bNodeTree *)ale->data; short offset = acf_generic_basic_offset(ac, ale); - - offset += acf_nodetree_rootType_offset(ntree); - + + offset += acf_nodetree_rootType_offset(ntree); + return offset; } @@ -2257,21 +2257,21 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return NTREE_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2281,21 +2281,21 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti static void *acf_dsntree_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { bNodeTree *ntree = (bNodeTree *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(ntree->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (ntree->adt) return GET_ACF_FLAG_PTR(ntree->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2306,7 +2306,7 @@ static bAnimChannelType ACF_DSNTREE = { "Node Tree Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -2334,21 +2334,21 @@ static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return LS_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2358,21 +2358,21 @@ static int acf_dslinestyle_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_S static void *acf_dslinestyle_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(linestyle->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (linestyle->adt) return GET_ACF_FLAG_PTR(linestyle->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2383,16 +2383,16 @@ static bAnimChannelType ACF_DSLINESTYLE = { "Line Style Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop,/* backdrop */ acf_generic_indention_1, /* indent level */ acf_generic_basic_offset, /* offset */ - + acf_generic_idblock_name, /* name */ acf_generic_idblock_name_prop, /* name prop */ acf_dslinestyle_icon, /* icon */ - + acf_generic_dataexpand_setting_valid, /* has setting */ acf_dslinestyle_setting_flag, /* flag for setting */ acf_dslinestyle_setting_ptr /* pointer for setting */ @@ -2411,21 +2411,21 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return ME_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2435,21 +2435,21 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settin static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Mesh *me = (Mesh *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(me->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (me->adt) return GET_ACF_FLAG_PTR(me->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2460,7 +2460,7 @@ static bAnimChannelType ACF_DSMESH = { "Mesh Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ // XXX this only works for compositing @@ -2488,21 +2488,21 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return LT_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2512,21 +2512,21 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dslat_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Lattice *lt = (Lattice *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(lt->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (lt->adt) return GET_ACF_FLAG_PTR(lt->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2537,7 +2537,7 @@ static bAnimChannelType ACF_DSLAT = { "Lattice Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ // XXX this only works for compositing @@ -2565,21 +2565,21 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return SPK_DS_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2589,21 +2589,21 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setting static void *acf_dsspk_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { Speaker *spk = (Speaker *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(spk->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (spk->adt) return GET_ACF_FLAG_PTR(spk->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2614,7 +2614,7 @@ static bAnimChannelType ACF_DSSPK = { "Speaker Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -2642,21 +2642,21 @@ static int acf_dsgpencil_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Set { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GP_DATA_EXPAND; - + case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; - + case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ *neg = true; return ADT_CURVES_NOT_VISIBLE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; - + default: /* unsupported */ return 0; } @@ -2666,21 +2666,21 @@ static int acf_dsgpencil_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Set static void *acf_dsgpencil_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { bGPdata *gpd = (bGPdata *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ return GET_ACF_FLAG_PTR(gpd->flag, type); - + case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted (for NLA only) */ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (gpd->adt) return GET_ACF_FLAG_PTR(gpd->adt->flag, type); return NULL; - + default: /* unsupported */ return NULL; } @@ -2691,7 +2691,7 @@ static bAnimChannelType ACF_DSGPENCIL = { "GPencil DS Expander", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_generic_dataexpand_color, /* backdrop color */ acf_generic_dataexpand_backdrop, /* backdrop */ acf_generic_indention_1, /* indent level */ @@ -2790,7 +2790,7 @@ static bAnimChannelType ACF_DSMCLIP = static void acf_shapekey_name(bAnimListElem *ale, char *name) { KeyBlock *kb = (KeyBlock *)ale->data; - + /* just copy the name... */ if (kb && name) { /* if the KeyBlock had a name, use it, otherwise use the index */ @@ -2805,15 +2805,15 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name) static bool acf_shapekey_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { KeyBlock *kb = (KeyBlock *)ale->data; - + /* if the KeyBlock had a name, use it, otherwise use the index */ if (kb && kb->name[0]) { RNA_pointer_create(ale->id, &RNA_ShapeKey, kb, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } - + return false; } @@ -2825,7 +2825,7 @@ static bool acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * case ACHANNEL_SETTING_MUTE: /* muted */ case ACHANNEL_SETTING_PROTECT: /* protected */ return true; - + /* nothing else is supported */ default: return false; @@ -2837,17 +2837,17 @@ static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_MUTE: /* mute */ return KEYBLOCK_MUTE; - + case ACHANNEL_SETTING_SELECT: /* selected */ return KEYBLOCK_SEL; - + case ACHANNEL_SETTING_PROTECT: /* locked */ return KEYBLOCK_LOCKED; - + default: /* unsupported */ return 0; } @@ -2857,16 +2857,16 @@ static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett static void *acf_shapekey_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings setting, short *type) { KeyBlock *kb = (KeyBlock *)ale->data; - + /* clear extra return data first */ *type = 0; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ case ACHANNEL_SETTING_MUTE: /* muted */ case ACHANNEL_SETTING_PROTECT: /* protected */ return GET_ACF_FLAG_PTR(kb->flag, type); - + default: /* unsupported */ return NULL; } @@ -2877,7 +2877,7 @@ static bAnimChannelType ACF_SHAPEKEY = { "Shape Key", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_generic_channel_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_0, /* indent level */ @@ -2915,7 +2915,7 @@ static bool acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: return true; - + default: return false; } @@ -2926,14 +2926,14 @@ static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return AGRP_SELECTED; - + case ACHANNEL_SETTING_EXPAND: /* expanded */ return GP_DATA_EXPAND; - + default: /* these shouldn't happen */ return 0; @@ -2944,17 +2944,17 @@ static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings static void *acf_gpd_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) { bGPdata *gpd = (bGPdata *)ale->data; - + /* all flags are just in gpd->flag for now... */ return GET_ACF_FLAG_PTR(gpd->flag, type); } /* gpencil datablock type define */ -static bAnimChannelType ACF_GPD = +static bAnimChannelType ACF_GPD = { "GPencil Datablock", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_gpd_color, /* backdrop color */ acf_group_backdrop, /* backdrop */ acf_generic_indention_0, /* indent level */ @@ -2975,7 +2975,7 @@ static bAnimChannelType ACF_GPD = static void acf_gpl_name(bAnimListElem *ale, char *name) { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + if (gpl && name) BLI_strncpy(name, gpl->info, ANIM_CHAN_NAME_SIZE); } @@ -2986,10 +2986,10 @@ static bool acf_gpl_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA * if (ale->data) { RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } - + return false; } @@ -3001,7 +3001,7 @@ static bool acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUSE case ACHANNEL_SETTING_EXPAND: /* gpencil layers are more like F-Curves than groups */ case ACHANNEL_SETTING_SOLO: /* nla editor only */ return false; - + /* always available */ default: return true; @@ -3013,21 +3013,21 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return GP_LAYER_SELECT; - + case ACHANNEL_SETTING_MUTE: /* animation muting - similar to frame lock... */ return GP_LAYER_FRAMELOCK; - + case ACHANNEL_SETTING_VISIBLE: /* visiblity of the layers (NOT muting) */ *neg = true; return GP_LAYER_HIDE; - + case ACHANNEL_SETTING_PROTECT: /* protected */ return GP_LAYER_LOCKED; - + default: /* unsupported */ return 0; } @@ -3037,26 +3037,26 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings static void *acf_gpl_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + /* all flags are just in gpl->flag for now... */ return GET_ACF_FLAG_PTR(gpl->flag, type); } /* grease pencil layer type define */ -static bAnimChannelType ACF_GPL = +static bAnimChannelType ACF_GPL = { "GPencil Layer", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_generic_channel_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ acf_generic_group_offset, /* offset */ - + acf_gpl_name, /* name */ acf_gpl_name_prop, /* name prop */ NULL, /* icon */ - + acf_gpl_setting_valid, /* has setting */ acf_gpl_setting_flag, /* flag for setting */ acf_gpl_setting_ptr /* pointer for setting */ @@ -3086,7 +3086,7 @@ static bool acf_mask_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_EXPAND: return true; - + default: return false; } @@ -3097,15 +3097,15 @@ static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return AGRP_SELECTED; - + case ACHANNEL_SETTING_EXPAND: /* expanded */ return MASK_ANIMF_EXPAND; - - default: + + default: /* this shouldn't happen */ return 0; } @@ -3115,7 +3115,7 @@ static int acf_mask_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Settings static void *acf_mask_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) { Mask *mask = (Mask *)ale->data; - + /* all flags are just in mask->flag for now... */ return GET_ACF_FLAG_PTR(mask->flag, type); } @@ -3125,16 +3125,16 @@ static bAnimChannelType ACF_MASKDATA = { "Mask Datablock", /* type name */ ACHANNEL_ROLE_EXPANDER, /* role */ - + acf_mask_color, /* backdrop color */ acf_group_backdrop, /* backdrop */ acf_generic_indention_0, /* indent level */ acf_generic_group_offset, /* offset */ - + acf_generic_idblock_name, /* name */ acf_generic_idfill_name_prop, /* name prop */ acf_mask_icon, /* icon */ - + acf_mask_setting_valid, /* has setting */ acf_mask_setting_flag, /* flag for setting */ acf_mask_setting_ptr /* pointer for setting */ @@ -3146,7 +3146,7 @@ static bAnimChannelType ACF_MASKDATA = static void acf_masklay_name(bAnimListElem *ale, char *name) { MaskLayer *masklay = (MaskLayer *)ale->data; - + if (masklay && name) BLI_strncpy(name, masklay->name, ANIM_CHAN_NAME_SIZE); } @@ -3157,7 +3157,7 @@ static bool acf_masklay_name_prop(bAnimListElem *ale, PointerRNA *ptr, PropertyR if (ale->data) { RNA_pointer_create(ale->id, &RNA_MaskLayer, ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } @@ -3173,7 +3173,7 @@ static bool acf_masklay_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *U case ACHANNEL_SETTING_VISIBLE: /* graph editor only */ case ACHANNEL_SETTING_SOLO: /* nla editor only */ return false; - + /* always available */ default: return true; @@ -3185,14 +3185,14 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return MASK_LAYERFLAG_SELECT; - + case ACHANNEL_SETTING_PROTECT: /* protected */ return MASK_LAYERFLAG_LOCKED; - + default: /* unsupported */ return 0; } @@ -3202,7 +3202,7 @@ static int acf_masklay_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Setti static void *acf_masklay_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings UNUSED(setting), short *type) { MaskLayer *masklay = (MaskLayer *)ale->data; - + /* all flags are just in masklay->flag for now... */ return GET_ACF_FLAG_PTR(masklay->flag, type); } @@ -3212,16 +3212,16 @@ static bAnimChannelType ACF_MASKLAYER = { "Mask Layer", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_generic_channel_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ acf_generic_group_offset, /* offset */ - + acf_masklay_name, /* name */ acf_masklay_name_prop, /* name prop */ NULL, /* icon */ - + acf_masklay_setting_valid, /* has setting */ acf_masklay_setting_flag, /* flag for setting */ acf_masklay_setting_ptr /* pointer for setting */ @@ -3235,7 +3235,7 @@ static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, flo NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; bool nonSolo = false; - + /* is track enabled for solo drawing? */ if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { if ((nlt->flag & NLATRACK_SOLO) == 0) { @@ -3243,7 +3243,7 @@ static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, flo nonSolo = true; } } - + /* set color for nla track */ UI_GetThemeColorShade3fv(TH_HEADER, ((nonSolo == false) ? 20 : -20), r_color); } @@ -3252,7 +3252,7 @@ static void acf_nlatrack_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, flo static void acf_nlatrack_name(bAnimListElem *ale, char *name) { NlaTrack *nlt = (NlaTrack *)ale->data; - + if (nlt && name) BLI_strncpy(name, nlt->name, ANIM_CHAN_NAME_SIZE); } @@ -3263,10 +3263,10 @@ static bool acf_nlatrack_name_prop(bAnimListElem *ale, PointerRNA *ptr, Property if (ale->data) { RNA_pointer_create(ale->id, &RNA_NlaTrack, ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } - + return false; } @@ -3275,14 +3275,14 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; - + /* visibility of settings depends on various states... */ switch (setting) { /* always supported */ case ACHANNEL_SETTING_SELECT: case ACHANNEL_SETTING_SOLO: return true; - + /* conditionally supported... */ case ACHANNEL_SETTING_PROTECT: case ACHANNEL_SETTING_MUTE: @@ -3299,8 +3299,8 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * return false; } } - - + + /* ok - no tracks are solo'd, and this isn't being tweaked */ return true; } @@ -3308,7 +3308,7 @@ static bool acf_nlatrack_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem * /* unsupported - this track is being tweaked */ return false; } - + /* unsupported */ default: return false; @@ -3320,20 +3320,20 @@ static int acf_nlatrack_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Sett { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return NLATRACK_SELECTED; - + case ACHANNEL_SETTING_MUTE: /* muted */ return NLATRACK_MUTED; - + case ACHANNEL_SETTING_PROTECT: /* protected */ return NLATRACK_PROTECTED; - + case ACHANNEL_SETTING_SOLO: /* solo */ return NLATRACK_SOLO; - + default: /* unsupported */ return 0; } @@ -3347,20 +3347,20 @@ static void *acf_nlatrack_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings } /* nla track type define */ -static bAnimChannelType ACF_NLATRACK = +static bAnimChannelType ACF_NLATRACK = { "NLA Track", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_nlatrack_color, /* backdrop color */ acf_generic_channel_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ acf_generic_group_offset, /* offset */ // XXX? - + acf_nlatrack_name, /* name */ acf_nlatrack_name_prop, /* name prop */ NULL, /* icon */ - + acf_nlatrack_setting_valid, /* has setting */ acf_nlatrack_setting_flag, /* flag for setting */ acf_nlatrack_setting_ptr /* pointer for setting */ @@ -3372,7 +3372,7 @@ static bAnimChannelType ACF_NLATRACK = static int acf_nlaaction_icon(bAnimListElem *ale) { AnimData *adt = ale->adt; - + /* indicate tweaking-action state by changing the icon... */ if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { return ICON_ACTION_TWEAK; @@ -3382,28 +3382,28 @@ static int acf_nlaaction_icon(bAnimListElem *ale) } } -/* Backdrop color for nla action channel +/* Backdrop color for nla action channel * Although this can't be used directly for NLA Action drawing, * it is still needed for use behind the RHS toggles */ static void acf_nlaaction_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float r_color[3]) { float color[4]; - + /* Action Line - * The alpha values action_get_color returns are only useful for drawing + * The alpha values action_get_color returns are only useful for drawing * strips backgrounds but here we're doing channel list backgrounds instead * so we ignore that and use our own when needed */ nla_action_get_color(ale->adt, (bAction *)ale->data, color); - + /* NOTE: since the return types only allow rgb, we cannot do the alpha-blending we'd * like for the solo-drawing case. Hence, this method isn't actually used for drawing * most of the channel... */ copy_v3_v3(r_color, color); } - + /* backdrop for nla action channel */ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { @@ -3412,14 +3412,14 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y AnimData *adt = ale->adt; short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[4]; - + /* Action Line - * The alpha values action_get_color returns are only useful for drawing + * The alpha values action_get_color returns are only useful for drawing * strips backgrounds but here we're doing channel list backgrounds instead * so we ignore that and use our own when needed */ nla_action_get_color(adt, (bAction *)ale->data, color); - + if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { /* Yes, the color vector has 4 components, BUT we only want to be using 3 of them! */ glColor3fv(color); @@ -3428,12 +3428,12 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f; glColor4f(color[0], color[1], color[2], alpha); } - - /* only on top left corner, to show that this channel sits on top of the preceding ones + + /* only on top left corner, to show that this channel sits on top of the preceding ones * while still linking into the action line strip to the right */ UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT); - + /* draw slightly shifted up vertically to look like it has more separation from other channels, * but we then need to slightly shorten it so that it doesn't look like it overlaps */ @@ -3444,7 +3444,7 @@ static void acf_nlaaction_backdrop(bAnimContext *ac, bAnimListElem *ale, float y static void acf_nlaaction_name(bAnimListElem *ale, char *name) { bAction *act = (bAction *)ale->data; - + if (name) { if (act) { // TODO: add special decoration when doing this in tweaking mode? @@ -3462,10 +3462,10 @@ static bool acf_nlaaction_name_prop(bAnimListElem *ale, PointerRNA *ptr, Propert if (ale->data) { RNA_pointer_create(ale->id, &RNA_Action, ale->data, ptr); *prop = RNA_struct_name_property(ptr->type); - + return (*prop != NULL); } - + return false; } @@ -3473,7 +3473,7 @@ static bool acf_nlaaction_name_prop(bAnimListElem *ale, PointerRNA *ptr, Propert static bool acf_nlaaction_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *ale, eAnimChannel_Settings setting) { AnimData *adt = ale->adt; - + /* visibility of settings depends on various states... */ switch (setting) { /* conditionally supported */ @@ -3485,7 +3485,7 @@ static bool acf_nlaaction_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem else { return false; } - + /* unsupported */ default: return false; @@ -3497,12 +3497,12 @@ static int acf_nlaaction_setting_flag(bAnimContext *UNUSED(ac), eAnimChannel_Set { /* clear extra return data first */ *neg = false; - + switch (setting) { case ACHANNEL_SETTING_PINNED: /* pinned - map/unmap */ *neg = true; // XXX return ADT_NLA_EDIT_NOMAP; - + default: /* unsupported */ return 0; } @@ -3516,20 +3516,20 @@ static void *acf_nlaaction_setting_ptr(bAnimListElem *ale, eAnimChannel_Settings } /* nla action type define */ -static bAnimChannelType ACF_NLAACTION = +static bAnimChannelType ACF_NLAACTION = { "NLA Active Action", /* type name */ ACHANNEL_ROLE_CHANNEL, /* role */ - + acf_nlaaction_color, /* backdrop color (NOTE: the backdrop handles this too, since it needs special hacks) */ acf_nlaaction_backdrop, /* backdrop */ acf_generic_indention_flexible, /* indent level */ acf_generic_group_offset, /* offset */ // XXX? - + acf_nlaaction_name, /* name */ acf_nlaaction_name_prop, /* name prop */ acf_nlaaction_icon, /* icon */ - + acf_nlaaction_setting_valid, /* has setting */ acf_nlaaction_setting_flag, /* flag for setting */ acf_nlaaction_setting_ptr /* pointer for setting */ @@ -3547,31 +3547,31 @@ static short ACF_INIT = 1; /* when non-zero, the list needs to be updated */ static void ANIM_init_channel_typeinfo_data(void) { int type = 0; - + /* start initializing if necessary... */ if (ACF_INIT) { ACF_INIT = 0; - + /* NOTE: need to keep the order of these synchronized with the definition of * channel types (eAnim_ChannelType) in ED_anim_api.h */ animchannelTypeInfo[type++] = NULL; /* None */ animchannelTypeInfo[type++] = NULL; /* AnimData */ animchannelTypeInfo[type++] = NULL; /* Special */ - + animchannelTypeInfo[type++] = &ACF_SUMMARY; /* Motion Summary */ - + animchannelTypeInfo[type++] = &ACF_SCENE; /* Scene */ animchannelTypeInfo[type++] = &ACF_OBJECT; /* Object */ animchannelTypeInfo[type++] = &ACF_GROUP; /* Group */ animchannelTypeInfo[type++] = &ACF_FCURVE; /* F-Curve */ - + animchannelTypeInfo[type++] = &ACF_NLACONTROLS; /* NLA Control FCurve Expander */ animchannelTypeInfo[type++] = &ACF_NLACURVE; /* NLA Control FCurve Channel */ - + animchannelTypeInfo[type++] = &ACF_FILLACTD; /* Object Action Expander */ animchannelTypeInfo[type++] = &ACF_FILLDRIVERS; /* Drivers Expander */ - + animchannelTypeInfo[type++] = &ACF_DSMAT; /* Material Channel */ animchannelTypeInfo[type++] = &ACF_DSLAM; /* Lamp Channel */ animchannelTypeInfo[type++] = &ACF_DSCAM; /* Camera Channel */ @@ -3590,19 +3590,19 @@ static void ANIM_init_channel_typeinfo_data(void) animchannelTypeInfo[type++] = &ACF_DSSPK; /* Speaker Channel */ animchannelTypeInfo[type++] = &ACF_DSGPENCIL; /* GreasePencil Channel */ animchannelTypeInfo[type++] = &ACF_DSMCLIP; /* MovieClip Channel */ - + animchannelTypeInfo[type++] = &ACF_SHAPEKEY; /* ShapeKey */ - + animchannelTypeInfo[type++] = &ACF_GPD; /* Grease Pencil Datablock */ animchannelTypeInfo[type++] = &ACF_GPL; /* Grease Pencil Layer */ - + animchannelTypeInfo[type++] = &ACF_MASKDATA; /* Mask Datablock */ animchannelTypeInfo[type++] = &ACF_MASKLAYER; /* Mask Layer */ - + animchannelTypeInfo[type++] = &ACF_NLATRACK; /* NLA Track */ animchannelTypeInfo[type++] = &ACF_NLAACTION; /* NLA Action */ } -} +} /* Get type info from given channel type */ const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale) @@ -3610,10 +3610,10 @@ const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale) /* santiy checks */ if (ale == NULL) return NULL; - + /* init the typeinfo if not available yet... */ ANIM_init_channel_typeinfo_data(); - + /* check if type is in bounds... */ if ((ale->type >= 0) && (ale->type < ANIMTYPE_NUM_TYPES)) return animchannelTypeInfo[ale->type]; @@ -3627,21 +3627,21 @@ const bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale) void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + /* print indents */ for (; indent_level > 0; indent_level--) printf(" "); - + /* print info */ if (acf) { char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */ - + /* get UI name */ if (acf->name) acf->name(ale, name); else BLI_strncpy(name, "", sizeof(name)); - + /* print type name + ui name */ printf("ChanType: <%s> Name: \"%s\"\n", acf->channel_type_name, name); } @@ -3653,13 +3653,13 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) /* --------------------------- */ -/* Check if some setting for a channel is enabled +/* Check if some setting for a channel is enabled * Returns: 1 = On, 0 = Off, -1 = Invalid */ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { /* 2) get pointer to check for flag in, and the flag to check for */ @@ -3667,17 +3667,17 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne bool negflag; int flag; void *ptr; - + flag = acf->setting_flag(ac, setting, &negflag); ptr = acf->setting_ptr(ale, setting, &ptrsize); - + /* check if flag is enabled */ if (ptr && flag) { switch (ptrsize) { case sizeof(int): /* integer pointer for setting */ { const int *val = (int *)ptr; - + if (negflag) return ((*val) & flag) == 0; else @@ -3686,7 +3686,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne case sizeof(short): /* short pointer for setting */ { const short *val = (short *)ptr; - + if (negflag) return ((*val) & flag) == 0; else @@ -3695,7 +3695,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne case sizeof(char): /* char pointer for setting */ { const char *val = (char *)ptr; - + if (negflag) return ((*val) & flag) == 0; else @@ -3704,10 +3704,10 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne } } } - + /* not found... */ return -1; -} +} /* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */ @@ -3725,14 +3725,14 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne } \ } (void)0 -/* Change value of some setting for a channel +/* Change value of some setting for a channel * - setting: eAnimChannel_Settings * - mode: eAnimChannels_SetFlag */ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { /* 2) get pointer to check for flag in, and the flag to check for */ @@ -3740,10 +3740,10 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, eAnimChannel bool negflag; int flag; void *ptr; - + flag = acf->setting_flag(ac, setting, &negflag); ptr = acf->setting_ptr(ale, setting, &ptrsize); - + /* check if flag is enabled */ if (ptr && flag) { switch (ptrsize) { @@ -3789,7 +3789,7 @@ static bool achannel_is_being_renamed(const bAnimContext *ac, const bAnimChannel return true; } } - + /* not being renamed */ return false; } @@ -3802,52 +3802,52 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float View2D *v2d = &ac->ar->v2d; short selected, offset; float y, ymid, ytext; - + /* sanity checks - don't draw anything */ if (ELEM(NULL, acf, ale)) return; - + /* get initial offset */ if (acf->get_offset) offset = acf->get_offset(ac, ale); else offset = 0; - + /* calculate appropriate y-coordinates for icon buttons */ y = (ymaxc - yminc) / 2 + yminc; ymid = y - 0.5f * ICON_WIDTH; /* y-coordinates for text is only 4 down from middle */ ytext = y - 0.2f * U.widget_unit; - + /* check if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); else selected = 0; - + /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + /* step 1) draw backdrop ........................................... */ if (acf->draw_backdrop) acf->draw_backdrop(ac, ale, yminc, ymaxc); - + /* step 2) draw expand widget ....................................... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { /* just skip - drawn as widget now */ - offset += ICON_WIDTH; + offset += ICON_WIDTH; } - + /* step 3) draw icon ............................................... */ if (acf->icon) { UI_icon_draw(offset, ymid, acf->icon(ale)); - offset += ICON_WIDTH; + offset += ICON_WIDTH; } - + /* turn off blending, since not needed anymore... */ glDisable(GL_BLEND); - + /* step 4) draw special toggles ................................. * - in Graph Editor, checkboxes for visibility in curves area * - in NLA Editor, glowing dots for solo/not solo... @@ -3861,12 +3861,12 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* for F-Curves, draw color-preview of curve behind checkbox */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = (FCurve *)ale->data; - - /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever - * color the curve has stored + + /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever + * color the curve has stored */ glColor3fv(fcu->color); - + /* just a solid color rect */ glRectf(offset, yminc, offset + ICON_WIDTH, ymaxc); @@ -3881,7 +3881,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float } else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { /* just skip - drawn as widget now */ - offset += ICON_WIDTH; + offset += ICON_WIDTH; } else if (ale->type == ANIMTYPE_GPLAYER) { /* just skip - drawn as a widget */ @@ -3890,24 +3890,24 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float } /* step 5) draw name ............................................... */ - /* Don't draw this if renaming... */ + /* Don't draw this if renaming... */ if (acf->name && !achannel_is_being_renamed(ac, acf, channel_index)) { const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; char name[ANIM_CHAN_NAME_SIZE]; /* hopefully this will be enough! */ - + /* set text color */ /* XXX: if active, highlight differently? */ if (selected) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); - + /* get name */ acf->name(ale, name); - + offset += 3; UI_fontstyle_draw_simple(fstyle, offset, ytext, name); - + /* draw red underline if channel is disabled */ if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE) && (ale->flag & FCURVE_DISABLED)) { /* FIXME: replace hardcoded color here, and check on extents! */ @@ -3928,11 +3928,11 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float short draw_sliders = 0; float ymin_ofs = 0.0f; float color[3]; - + /* get and set backdrop color */ acf->get_backdrop_color(ac, ale, color); glColor3fv(color); - + /* check if we need to show the sliders */ if ((ac->sl) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) { switch (ac->spacetype) { @@ -3956,24 +3956,24 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) offset += ICON_WIDTH; - + /* mute... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) offset += ICON_WIDTH; if (ale->type == ANIMTYPE_GPLAYER) offset += ICON_WIDTH; - + /* pinned... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) offset += ICON_WIDTH; - + /* NOTE: technically, NLA Action "pushdown" should be here too, but there are no sliders there */ - + /* NLA action channels have slightly different spacing requirements... */ if (ale->type == ANIMTYPE_NLAACTION) ymin_ofs = NLACHANNEL_SKIP; } - + /* draw slider * - even if we can draw sliders for this view, we must also check that the channel-type supports them * (only only F-Curves really can support them for now) @@ -3983,10 +3983,10 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* adjust offset */ offset += SLIDER_WIDTH; } - - + + /* finally draw a backdrop rect behind these - * - starts from the point where the first toggle/slider starts, + * - starts from the point where the first toggle/slider starts, * - ends past the space that might be reserved for a scroller */ glRectf(v2d->cur.xmax - (float)offset, yminc + ymin_ofs, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); @@ -4010,7 +4010,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void int filter; int setting = GET_INT_FROM_POINTER(setting_wrap); short on = 0; - + /* send notifiers before doing anything else... */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -4021,11 +4021,11 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void if (ale_setting->type == ANIMTYPE_GPLAYER) WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); - + /* verify animation context */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + /* check if the setting is on... */ on = ANIM_channel_setting_get(&ac, ale_setting, setting); @@ -4033,14 +4033,14 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void if (on == -1) { return; } - + /* get all channels that can possibly be chosen - but ignore hierarchy */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* call API method to flush the setting */ ANIM_flush_setting_anim_channels(&ac, &anim_data, ale_setting, setting, on); - + /* free temp data */ ANIM_animdata_freelist(&anim_data); } @@ -4050,7 +4050,7 @@ static void achannel_nlatrack_solo_widget_cb(bContext *C, void *adt_poin, void * { AnimData *adt = adt_poin; NlaTrack *nlt = nlt_poin; - + /* Toggle 'solo' mode. There are several complications here which need explaining: * - The method call is needed to perform a few additional validation operations * to ensure that the mode is applied properly @@ -4060,7 +4060,7 @@ static void achannel_nlatrack_solo_widget_cb(bContext *C, void *adt_poin, void * */ nlt->flag ^= NLATRACK_SOLO; BKE_nlatrack_solo_toggle(adt, nlt); - + /* send notifiers */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL); } @@ -4071,7 +4071,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi ID *id = (ID *)id_poin; AnimData *adt = BKE_animdata_from_id(id); FCurve *fcu = (FCurve *)fcu_poin; - + ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4080,25 +4080,25 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi short flag = 0; bool done = false; float cfra; - + /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - + /* get flags for keyframing */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* get RNA pointer, and resolve the path */ RNA_id_pointer_create(id, &id_ptr); - + /* try to resolve the path stored in the F-Curve */ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { /* set the special 'replace' flag if on a keyframe */ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) flag |= INSERTKEY_REPLACE; - + /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag); - + if (done) WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } @@ -4110,7 +4110,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi Key *key = (Key *)key_poin; KeyBlock *kb = (KeyBlock *)kb_poin; char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); - + ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4119,34 +4119,34 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi short flag = 0; bool done = false; float cfra; - + /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(key->adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - + /* get flags for keyframing */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* get RNA pointer, and resolve the path */ RNA_id_pointer_create((ID *)key, &id_ptr); - + /* try to resolve the path stored in the F-Curve */ if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) { /* find or create new F-Curve */ // XXX is the group name for this ok? bAction *act = verify_adt_action((ID *)key, 1); FCurve *fcu = verify_fcurve(act, NULL, &ptr, rna_path, 0, 1); - + /* set the special 'replace' flag if on a keyframe */ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) flag |= INSERTKEY_REPLACE; - + /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag); - + if (done) WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } - + /* free the path */ if (rna_path) MEM_freeN(rna_path); @@ -4157,35 +4157,35 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, void *UNUSED(id_po { /* ID *id = (ID *)id_poin; */ FCurve *fcu = (FCurve *)fcu_poin; - + PointerRNA ptr; PropertyRNA *prop; int index; - + ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; short flag = 0; bool done = false; float cfra; - + /* get current frame - *no* NLA mapping should be done */ cfra = (float)CFRA; - + /* get flags for keyframing */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* get pointer and property from the slider - this should all match up with the NlaStrip required... */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (fcu && prop) { /* set the special 'replace' flag if on a keyframe */ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) flag |= INSERTKEY_REPLACE; - + /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, flag); - + if (done) WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } @@ -4202,18 +4202,18 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni void *ptr; const char *tooltip; uiBut *but = NULL; - + /* get the flag and the pointer to that flag */ flag = acf->setting_flag(ac, setting, &negflag); ptr = acf->setting_ptr(ale, setting, &ptrsize); /* enabled = ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */ - + /* get the base icon for the setting */ switch (setting) { case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */ //icon = ((enabled) ? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF); icon = ICON_VISIBLE_IPO_OFF; - + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) tooltip = TIP_("F-Curve is visible in Graph Editor for editing"); else if (ale->type == ANIMTYPE_GPLAYER) @@ -4238,30 +4238,30 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni icon = ICON_TRIA_RIGHT; tooltip = TIP_("Make channels grouped under this channel visible"); break; - + case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ //icon = ((enabled) ? ICON_SOLO_OFF : ICON_SOLO_ON); icon = ICON_SOLO_OFF; tooltip = TIP_("NLA Track is the only one evaluated in this animation data-block, with all others muted"); break; - + /* --- */ - + case ACHANNEL_SETTING_PROTECT: /* protected lock */ // TODO: what about when there's no protect needed? //icon = ((enabled) ? ICON_LOCKED : ICON_UNLOCKED); icon = ICON_UNLOCKED; - + if (ale->datatype != ALE_NLASTRIP) tooltip = TIP_("Editability of keyframes for this channel"); else tooltip = TIP_("Editability of NLA Strips in this track"); break; - + case ACHANNEL_SETTING_MUTE: /* muted speaker */ //icon = ((enabled) ? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); icon = ICON_MUTE_IPO_OFF; - + if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { tooltip = TIP_("Does F-Curve contribute to result"); } @@ -4275,11 +4275,11 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni tooltip = TIP_("Do channels contribute to result (toggle channel muting)"); } break; - + case ACHANNEL_SETTING_PINNED: /* pin icon */ //icon = ((enabled) ? ICON_PINNED : ICON_UNPINNED); icon = ICON_UNPINNED; - + if (ale->type == ANIMTYPE_NLAACTION) { tooltip = TIP_("Display action without any time remapping (when unpinned)"); } @@ -4288,13 +4288,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni tooltip = NULL; } break; - + default: tooltip = NULL; icon = 0; break; } - + /* type of button */ if (usetoggle) { if (negflag) @@ -4312,21 +4312,21 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni if (ptr && flag) { switch (ptrsize) { case sizeof(int): /* integer pointer for setting */ - but = uiDefIconButBitI(block, butType, flag, 0, icon, + but = uiDefIconButBitI(block, butType, flag, 0, icon, xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; - + case sizeof(short): /* short pointer for setting */ - but = uiDefIconButBitS(block, butType, flag, 0, icon, + but = uiDefIconButBitS(block, butType, flag, 0, icon, xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; - + case sizeof(char): /* char pointer for setting */ - but = uiDefIconButBitC(block, butType, flag, 0, icon, + but = uiDefIconButBitC(block, butType, flag, 0, icon, xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; } - + /* set call to send relevant notifiers and/or perform type-specific updates */ if (but) { switch (setting) { @@ -4339,12 +4339,12 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, const bAni case ACHANNEL_SETTING_ALWAYS_VISIBLE: UI_but_funcN_set(but, achannel_setting_flush_widget_cb, MEM_dupallocN(ale), SET_INT_IN_POINTER(setting)); break; - + /* settings needing special attention */ case ACHANNEL_SETTING_SOLO: /* NLA Tracks - Solo toggle */ UI_but_func_set(but, achannel_nlatrack_solo_widget_cb, ale->adt, ale->data); break; - + /* no flushing */ case ACHANNEL_SETTING_EXPAND: /* expanding - cannot flush, otherwise all would open/close at once */ default: @@ -4363,37 +4363,37 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle float y, ymid /*, ytext*/; short offset; const bool is_being_renamed = achannel_is_being_renamed(ac, acf, channel_index); - + /* sanity checks - don't draw anything */ if (ELEM(NULL, acf, ale, block)) return; - + /* get initial offset */ if (acf->get_offset) offset = acf->get_offset(ac, ale); else offset = 0; - - /* calculate appropriate y-coordinates for icon buttons + + /* calculate appropriate y-coordinates for icon buttons */ y = (ymaxc - yminc) / 2 + yminc; ymid = y - 0.5f * ICON_WIDTH; - + /* no button backdrop behind icons */ UI_block_emboss_set(block, UI_EMBOSS_NONE); - + /* step 1) draw expand widget ....................................... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_EXPAND)) { draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_EXPAND); - offset += ICON_WIDTH; + offset += ICON_WIDTH; } - + /* step 2) draw icon ............................................... */ if (acf->icon) { /* icon is not drawn here (not a widget) */ - offset += ICON_WIDTH; + offset += ICON_WIDTH; } - + /* step 3) draw special toggles ................................. * - in Graph Editor, checkboxes for visibility in curves area * - in NLA Editor, glowing dots for solo/not solo... @@ -4418,7 +4418,7 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle else if ((ac->spacetype == SPACE_NLA) && acf->has_setting(ac, ale, ACHANNEL_SETTING_SOLO)) { /* 'solo' setting for NLA Tracks */ draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_SOLO); - offset += ICON_WIDTH; + offset += ICON_WIDTH; } else if (ale->type == ANIMTYPE_GPLAYER) { #if 0 @@ -4427,18 +4427,18 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle bGPDlayer *gpl = (bGPDlayer *)ale->data; PointerRNA ptr; float w = ICON_WIDTH / 2.0f; - + RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, &ptr); - + UI_block_align_begin(block); UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_stroke_visible") ? UI_EMBOSS : UI_EMBOSS_NONE); - uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, w, ICON_WIDTH, - &ptr, "color", -1, + uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, w, ICON_WIDTH, + &ptr, "color", -1, 0, 0, 0, 0, gpl->info); - + UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_fill_visible") ? UI_EMBOSS : UI_EMBOSS_NONE); - uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset + w, yminc, w, ICON_WIDTH, - &ptr, "fill_color", -1, + uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset + w, yminc, w, ICON_WIDTH, + &ptr, "fill_color", -1, 0, 0, 0, 0, gpl->info); UI_block_emboss_set(block, UI_EMBOSS_NONE); UI_block_align_end(block); @@ -4447,14 +4447,14 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle #endif } } - + /* step 4) draw text - check if renaming widget is in use... */ if (is_being_renamed) { PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; - - /* draw renaming widget if we can get RNA pointer for it - * NOTE: property may only be available in some cases, even if we have + + /* draw renaming widget if we can get RNA pointer for it + * NOTE: property may only be available in some cases, even if we have * a callback available (e.g. broken F-Curve rename) */ if (acf->name_prop(ale, &ptr, &prop)) { @@ -4462,21 +4462,21 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle const short channel_height = round_fl_to_int(ymaxc - yminc); const short width = ac->ar->winx - offset - (margin_x * 2); uiBut *but; - + UI_block_emboss_set(block, UI_EMBOSS); - + but = uiDefButR(block, UI_BTYPE_TEXT, 1, "", offset + margin_x, yminc, MAX2(width, RENAME_TEXT_MIN_WIDTH), channel_height, &ptr, RNA_property_identifier(prop), -1, 0, 0, -1, -1, NULL); - + /* copy what outliner does here, see outliner_buttons */ if (UI_but_active_only(C, ac->ar, block, but) == false) { ac->ads->renameIndex = 0; - + /* send notifiers */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL); } - + UI_block_emboss_set(block, UI_EMBOSS_NONE); } else { @@ -4487,15 +4487,15 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); } } - + /* step 5) draw mute+protection toggles + (sliders) ....................... */ /* reset offset - now goes from RHS of panel */ offset = 0; - + // TODO: when drawing sliders, make those draw instead of these toggles if not enough space if (v2d && !is_being_renamed) { short draw_sliders = 0; - + /* check if we need to show the sliders */ if ((ac->sl) && ELEM(ac->spacetype, SPACE_ACTION, SPACE_IPO)) { switch (ac->spacetype) { @@ -4513,12 +4513,12 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle } } } - + /* check if there's enough space for the toggles if the sliders are drawn too */ if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { - offset += ICON_WIDTH; + offset += ICON_WIDTH; draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PROTECT); } /* mute... */ @@ -4531,43 +4531,43 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle offset += ICON_WIDTH; draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_VISIBLE); } - + /* modifiers disable */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MOD_OFF)) { offset += ICON_WIDTH * 1.2f; /* hack: extra spacing, to avoid touching the mute toggle */ draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MOD_OFF); } - + /* ----------- */ - + /* pinned... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PINNED)) { offset += ICON_WIDTH; draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PINNED); } - + /* NLA Action "pushdown" */ if ((ale->type == ANIMTYPE_NLAACTION) && (ale->adt && ale->adt->action) && !(ale->adt->flag & ADT_NLA_EDIT_ON)) { uiBut *but; PointerRNA *opptr_b; - + UI_block_emboss_set(block, UI_EMBOSS); - + offset += UI_UNIT_X; - but = uiDefIconButO(block, UI_BTYPE_BUT, "NLA_OT_action_pushdown", WM_OP_INVOKE_DEFAULT, ICON_NLA_PUSHDOWN, + but = uiDefIconButO(block, UI_BTYPE_BUT, "NLA_OT_action_pushdown", WM_OP_INVOKE_DEFAULT, ICON_NLA_PUSHDOWN, (int)v2d->cur.xmax - offset, ymid, UI_UNIT_X, UI_UNIT_X, NULL); - + opptr_b = UI_but_operator_ptr_get(but); RNA_int_set(opptr_b, "channel_index", channel_index); - + UI_block_emboss_set(block, UI_EMBOSS_NONE); } } - + /* draw slider * - even if we can draw sliders for this view, we must also check that the channel-type supports them * (only only F-Curves really can support them for now) - * - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately, + * - to make things easier, we use RNA-autobuts for this so that changes are reflected immediately, * wherever they occurred. BUT, we don't use the layout engine, otherwise we'd get wrong alignment, * and wouldn't be able to auto-keyframe... * - slider should start before the toggles (if they're visible) to keep a clean line down the side @@ -4576,25 +4576,25 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle /* adjust offset */ // TODO: make slider width dynamic, so that they can be easier to use when the view is wide enough offset += SLIDER_WIDTH; - + /* need backdrop behind sliders... */ UI_block_emboss_set(block, UI_EMBOSS); - + if (ale->owner) { /* Slider using custom RNA Access ---------- */ if (ale->type == ANIMTYPE_NLACURVE) { NlaStrip *strip = (NlaStrip *)ale->owner; FCurve *fcu = (FCurve *)ale->data; PointerRNA ptr; PropertyRNA *prop; - + /* create RNA pointers */ RNA_pointer_create(ale->id, &RNA_NlaStrip, strip, &ptr); prop = RNA_struct_find_property(&ptr, fcu->rna_path); - + /* create property slider */ if (prop) { uiBut *but; - + /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */ but = uiDefAutoButR(block, &ptr, prop, fcu->array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc); UI_but_func_set(but, achannel_setting_slider_nla_curve_cb, ale->id, ale->data); @@ -4607,41 +4607,41 @@ void ANIM_channel_draw_widgets(const bContext *C, bAnimContext *ac, bAnimListEle char *rna_path = NULL; int array_index = 0; short free_path = 0; - + /* get destination info */ if (ale->type == ANIMTYPE_FCURVE) { FCurve *fcu = (FCurve *)ale->data; - + rna_path = fcu->rna_path; array_index = fcu->array_index; } else if (ale->type == ANIMTYPE_SHAPEKEY) { KeyBlock *kb = (KeyBlock *)ale->data; Key *key = (Key *)ale->id; - + rna_path = BKE_keyblock_curval_rnapath_get(key, kb); free_path = 1; } - + /* only if RNA-Path found */ if (rna_path) { /* get RNA pointer, and resolve the path */ RNA_id_pointer_create(ale->id, &id_ptr); - + /* try to resolve the path */ if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop)) { uiBut *but; - + /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */ but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc); - + /* assign keyframing function according to slider type */ if (ale->type == ANIMTYPE_SHAPEKEY) UI_but_func_set(but, achannel_setting_slider_shapekey_cb, ale->id, ale->data); else UI_but_func_set(but, achannel_setting_slider_cb, ale->id, ale->data); } - + /* free the path if necessary */ if (free_path) MEM_freeN(rna_path); diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index b32bbd4874d..1158145ad6b 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include "MEM_guardedalloc.h" @@ -80,24 +80,24 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - + /* try to build list of filtered items */ ANIM_animdata_filter(ac, &anim_data, filter, data, datatype); if (BLI_listbase_is_empty(&anim_data)) return; - + /* only clear the 'active' flag for the channels of the same type */ for (ale = anim_data.first; ale; ale = ale->next) { /* skip if types don't match */ if (channel_type != ale->type) continue; - + /* flag to set depends on type */ switch (ale->type) { case ANIMTYPE_GROUP: { bActionGroup *agrp = (bActionGroup *)ale->data; - + ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE); break; } @@ -105,14 +105,14 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)ale->data; - + ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE); break; } case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)ale->data; - + ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE); break; } @@ -144,13 +144,13 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + ACHANNEL_SET_FLAG(gpl, ACHANNEL_SETFLAG_CLEAR, GP_LAYER_ACTIVE); break; } } } - + /* set active flag */ if (channel_data) { switch (channel_type) { @@ -199,26 +199,26 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, eAnimCont_Types datat } break; } - + case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)channel_data; gpl->flag |= GP_LAYER_ACTIVE; break; } - + /* unhandled currently, but may be interesting */ case ANIMTYPE_MASKLAYER: case ANIMTYPE_SHAPEKEY: case ANIMTYPE_NLAACTION: break; - + /* other types */ default: break; } } - + /* clean up */ ANIM_animdata_freelist(&anim_data); } @@ -250,7 +250,7 @@ static void select_pchan_for_action_group(bAnimContext *ac, bActionGroup *agrp, } } -/* Deselect all animation channels +/* Deselect all animation channels * - data: pointer to datatype, as contained in bAnimContext * - datatype: the type of data that 'data' represents (eAnimCont_Types) * - test: check if deselecting instead of selecting @@ -261,18 +261,18 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ /* NOTE: no list visible, otherwise, we get dangling */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &anim_data, filter, data, datatype); - + /* See if we should be selecting or deselecting */ if (test) { for (ale = anim_data.first; ale; ale = ale->next) { - if (sel == 0) + if (sel == 0) break; - + switch (ale->type) { case ANIMTYPE_SCENE: if (ale->flag & SCE_DS_SELECTED) @@ -301,7 +301,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d if (ale->flag & NLATRACK_SELECTED) sel = ACHANNEL_SETFLAG_CLEAR; break; - + case ANIMTYPE_FILLACTD: /* Action Expander */ case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: @@ -337,16 +337,16 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d } } } - + /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_SCENE: { Scene *scene = (Scene *)ale->data; - + ACHANNEL_SET_FLAG(scene, sel, SCE_DS_SELECTED); - + if (scene->adt) { ACHANNEL_SET_FLAG(scene, sel, ADT_UI_SELECTED); } @@ -379,7 +379,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)ale->data; - + ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED); fcu->flag &= ~FCURVE_ACTIVE; break; @@ -387,14 +387,14 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d case ANIMTYPE_SHAPEKEY: { KeyBlock *kb = (KeyBlock *)ale->data; - + ACHANNEL_SET_FLAG(kb, sel, KEYBLOCK_SEL); break; } case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)ale->data; - + ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED); nlt->flag &= ~NLATRACK_ACTIVE; break; @@ -429,27 +429,27 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, eAnimCont_Types d case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + ACHANNEL_SET_FLAG(gpl, sel, GP_LAYER_SELECT); break; } case ANIMTYPE_MASKLAYER: { MaskLayer *masklay = (MaskLayer *)ale->data; - + ACHANNEL_SET_FLAG(masklay, sel, MASK_LAYERFLAG_SELECT); break; } } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } /* ---------------------------- Graph Editor ------------------------------------- */ -/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting +/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting * - anim_data: list of the all the anim channels that can be chosen * -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too, * then the channels under closed expanders get ignored... @@ -462,7 +462,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn { bAnimListElem *ale, *match = NULL; int prevLevel = 0, matchLevel = 0; - + /* sanity check */ if (ELEM(NULL, anim_data, anim_data->first)) return; @@ -489,23 +489,23 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn } else { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting); - + if (acf == NULL) { printf("ERROR: no channel info for the changed channel\n"); return; } - + /* get the level of the channel that was affected * - we define the level as simply being the offset for the start of the channel */ matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0; prevLevel = matchLevel; } - - /* flush up? + + /* flush up? * * For Visibility: - * - only flush up if the current state is now enabled (positive 'on' state is default) + * - only flush up if the current state is now enabled (positive 'on' state is default) * (otherwise, it's too much work to force the parents to be inactive too) * * For everything else: @@ -519,25 +519,25 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn for (ale = match->prev; ale; ale = ale->prev) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; - + /* if no channel info was found, skip, since this type might not have any useful info */ if (acf == NULL) continue; - - /* get the level of the current channel traversed + + /* get the level of the current channel traversed * - we define the level as simply being the offset for the start of the channel */ level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; - + /* if the level is 'less than' (i.e. more important) the level we're matching - * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, + * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, * when toggling visibility of F-Curves, gets flushed, which should happen if we don't let prevLevel * get updated below once the first 1st group is found)... */ if (level < prevLevel) { /* flush the new status... */ ANIM_channel_setting_set(ac, ale, setting, mode); - + /* store this level as the 'old' level now */ prevLevel = level; } @@ -549,31 +549,31 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn if (prevLevel == 0) break; /* otherwise, this level weaves into another sibling hierarchy to the previous one just - * finished, so skip until we get to the parent of this level + * finished, so skip until we get to the parent of this level */ else continue; } } } - + /* flush down (always) */ { /* go forwards in the list, until the lowest-ranking element (by indention has been covered) */ for (ale = match->next; ale; ale = ale->next) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; - + /* if no channel info was found, skip, since this type might not have any useful info */ if (acf == NULL) continue; - - /* get the level of the current channel traversed + + /* get the level of the current channel traversed * - we define the level as simply being the offset for the start of the channel */ level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; - - /* if the level is 'greater than' (i.e. less important) the channel that was changed, + + /* if the level is 'greater than' (i.e. less important) the channel that was changed, * flush the new status... */ if (level > matchLevel) @@ -584,7 +584,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn */ else break; - + /* store this level as the 'old' level now */ // prevLevel = level; // XXX: prevLevel is unused } @@ -596,13 +596,13 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* Delete the given F-Curve from its AnimData block */ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *fcu) { - /* - if no AnimData, we've got nowhere to remove the F-Curve from + /* - if no AnimData, we've got nowhere to remove the F-Curve from * (this doesn't guarantee that the F-Curve is in there, but at least we tried * - if no F-Curve, there is nothing to remove */ if (ELEM(NULL, adt, fcu)) return; - + /* remove from whatever list it came from * - Action Group * - Action @@ -615,15 +615,15 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f } else if (adt->action) { bAction *act = adt->action; - + /* remove from group or action, whichever one "owns" the F-Curve */ if (fcu->grp) { bActionGroup *agrp = fcu->grp; - + /* remove F-Curve from group+action */ action_groups_remove_channel(act, fcu); - - /* if group has no more channels, remove it too, + + /* if group has no more channels, remove it too, * otherwise can have many dangling groups [#33541] */ if (BLI_listbase_is_empty(&agrp->channels)) { @@ -633,7 +633,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f else { BLI_remlink(&act->curves, fcu); } - + /* if action has no more F-Curves as a result of this, unlink it from * AnimData if it did not come from a NLA Strip being tweaked. * @@ -646,7 +646,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f adt->action = NULL; } } - + /* free the F-Curve itself */ free_fcurve(fcu); } @@ -660,7 +660,7 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f static int animedit_poll_channels_active(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) @@ -685,13 +685,13 @@ static int animedit_poll_channels_nla_tweakmode_off(bContext *C) /* animation editor test */ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0) return 0; - + /* NLA TweakMode test */ if (sa->spacetype == SPACE_NLA) { if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) return 0; } - + return 1; } @@ -720,7 +720,7 @@ static const EnumPropertyItem prop_animchannel_rearrange_types[] = { /* Island definition - just a listbase container */ typedef struct tReorderChannelIsland { struct tReorderChannelIsland *next, *prev; - + ListBase channels; /* channels within this region with the same state */ int flag; /* eReorderIslandFlag */ } tReorderChannelIsland; @@ -741,7 +741,7 @@ static bool rearrange_island_ok(tReorderChannelIsland *island) /* island must not be untouchable */ if (island->flag & REORDER_ISLAND_UNTOUCHABLE) return 0; - + /* island should be selected to be moved */ return (island->flag & REORDER_ISLAND_SELECTED) && !(island->flag & REORDER_ISLAND_MOVED); } @@ -753,13 +753,13 @@ static bool rearrange_island_top(ListBase *list, tReorderChannelIsland *island) if (rearrange_island_ok(island)) { /* remove from current position */ BLI_remlink(list, island); - + /* make it first element */ BLI_insertlinkbefore(list, list->first, island); - + return 1; } - + return 0; } @@ -777,14 +777,14 @@ static bool rearrange_island_up(ListBase *list, tReorderChannelIsland *island) if (prev) { /* remove from current position */ BLI_remlink(list, island); - + /* push it up */ BLI_insertlinkbefore(list, prev, island); - + return 1; } } - + return 0; } @@ -804,16 +804,16 @@ static bool rearrange_island_down(ListBase *list, tReorderChannelIsland *island) if ((next->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* remove from current position */ BLI_remlink(list, island); - + /* push it down */ BLI_insertlinkafter(list, next, island); - + return true; } } /* else: no next channel, so we're at the bottom already, so can't move */ } - + return false; } @@ -821,10 +821,10 @@ static bool rearrange_island_bottom(ListBase *list, tReorderChannelIsland *islan { if (rearrange_island_ok(island)) { tReorderChannelIsland *last = list->last; - + /* remove island from current position */ BLI_remlink(list, island); - + /* add before or after the last channel? */ if ((last->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* can add after it */ @@ -833,12 +833,12 @@ static bool rearrange_island_bottom(ListBase *list, tReorderChannelIsland *islan else { /* can at most go just before it, since last cannot be moved */ BLI_insertlinkbefore(list, last, island); - + } - + return true; } - + return false; } @@ -879,13 +879,13 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr { tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */ bool is_sel = false, is_untouchable = false; - + /* get flags - selected and untouchable from the channel */ switch (type) { case ANIMTYPE_GROUP: { bActionGroup *agrp = (bActionGroup *)channel; - + is_sel = SEL_AGRP(agrp); is_untouchable = (agrp->flag & AGRP_TEMP) != 0; break; @@ -894,21 +894,21 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)channel; - + is_sel = SEL_FCU(fcu); break; } case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)channel; - + is_sel = SEL_NLT(nlt); break; } case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)channel; - + is_sel = SEL_GPL(gpl); break; } @@ -916,7 +916,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr printf("rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %u\n", type); return; } - + /* do we need to add to a new island? */ if (/* 1) no islands yet */ (island == NULL) || @@ -931,7 +931,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr /* create a new island now */ island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland"); BLI_addtail(islands, island); - + if (is_sel) island->flag |= REORDER_ISLAND_SELECTED; if (is_untouchable) @@ -949,14 +949,14 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *srcList) { tReorderChannelIsland *island, *isn = NULL; - + /* make sure srcList is empty now */ BLI_assert(BLI_listbase_is_empty(srcList)); - + /* go through merging islands */ for (island = islands->first; island; island = isn) { isn = island->next; - + /* merge island channels back to main list, then delete the island */ BLI_movelisttolist(srcList, &island->channels); BLI_freelinkN(islands, island); @@ -971,19 +971,19 @@ static void rearrange_animchannels_filter_visible(ListBase *anim_data_visible, b ListBase anim_data = {NULL, NULL}; bAnimListElem *ale, *ale_next; int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - + /* get all visible channels */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* now, only keep the ones that are of the types we are interested in */ for (ale = anim_data.first; ale; ale = ale_next) { ale_next = ale->next; - + if (ale->type != type) { BLI_freelinkN(&anim_data, ale); } } - + /* return cleaned up list */ *anim_data_visible = anim_data; } @@ -996,11 +996,11 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re ListBase islands = {NULL, NULL}; Link *channel, *chanNext = NULL; bool done = false; - + /* don't waste effort on an empty list */ if (BLI_listbase_is_empty(list)) return 0; - + /* group channels into islands */ for (channel = list->first; channel; channel = chanNext) { /* find out whether this channel is present in anim_data_visible or not! */ @@ -1008,18 +1008,18 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re chanNext = channel->next; rearrange_animchannel_add_to_islands(&islands, list, channel, type, is_hidden); } - - /* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen - * - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we + + /* perform moving of selected islands now, but only if there is more than one of 'em so that something will happen + * - scanning of the list is performed in the opposite direction to the direction we're moving things, so that we * shouldn't need to encounter items we've moved already */ if (islands.first != islands.last) { tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first; tReorderChannelIsland *island, *isn = NULL; - + for (island = first; island; island = isn) { isn = (mode > 0) ? island->prev : island->next; - + /* perform rearranging */ if (rearrange_func(&islands, island)) { island->flag |= REORDER_ISLAND_MOVED; @@ -1027,10 +1027,10 @@ static bool rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp re } } } - + /* ungroup islands */ rearrange_animchannel_flatten_islands(&islands, list); - + /* did we do anything? */ return done; } @@ -1045,21 +1045,21 @@ static void rearrange_nla_channels(bAnimContext *ac, AnimData *adt, eRearrangeAn { AnimChanRearrangeFp rearrange_func; ListBase anim_data_visible = {NULL, NULL}; - + /* hack: invert mode so that functions will work in right order */ mode *= -1; - + /* get rearranging function */ rearrange_func = rearrange_get_mode_func(mode); if (rearrange_func == NULL) return; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLATRACK); - + /* perform rearranging on tracks list */ rearrange_animchannel_islands(&adt->nla_tracks, rearrange_func, mode, ANIMTYPE_NLATRACK, &anim_data_visible); - + /* free temp data */ BLI_freelistN(&anim_data_visible); } @@ -1074,20 +1074,20 @@ static void rearrange_driver_channels(bAnimContext *ac, AnimData *adt, eRearrang /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); ListBase anim_data_visible = {NULL, NULL}; - + if (rearrange_func == NULL) return; - + /* only consider drivers if they're accessible */ if (EXPANDED_DRVD(adt) == 0) return; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE); - + /* perform rearranging on drivers list (drivers are really just F-Curves) */ rearrange_animchannel_islands(&adt->drivers, rearrange_func, mode, ANIMTYPE_FCURVE, &anim_data_visible); - + /* free temp data */ BLI_freelistN(&anim_data_visible); } @@ -1099,29 +1099,29 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) { bActionGroup *agrp; FCurve *fcu; - + if (act == NULL) return; - + /* Separate F-Curves into lists per group */ for (agrp = act->groups.first; agrp; agrp = agrp->next) { if (agrp->channels.first) { fcu = agrp->channels.last; act->curves.first = fcu->next; - + fcu = agrp->channels.first; fcu->prev = NULL; - + fcu = agrp->channels.last; fcu->next = NULL; } } - + /* Initialize memory for temp-group */ memset(tgrp, 0, sizeof(bActionGroup)); tgrp->flag |= (AGRP_EXPANDED | AGRP_TEMP); BLI_strncpy(tgrp->name, "#TempGroup", sizeof(tgrp->name)); - + /* Move any action-channels not already moved, to the temp group */ if (act->curves.first) { /* start of list */ @@ -1129,21 +1129,21 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) fcu->prev = NULL; tgrp->channels.first = fcu; act->curves.first = NULL; - + /* end of list */ fcu = act->curves.last; fcu->next = NULL; tgrp->channels.last = fcu; act->curves.last = NULL; - - /* ensure that all of these get their group set to this temp group + + /* ensure that all of these get their group set to this temp group * (so that visibility filtering works) */ for (fcu = tgrp->channels.first; fcu; fcu = fcu->next) { fcu->grp = tgrp; } } - + /* Add temp-group to list */ BLI_addtail(&act->groups, tgrp); } @@ -1152,36 +1152,36 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) static void join_groups_action_temp(bAction *act) { bActionGroup *agrp; - + for (agrp = act->groups.first; agrp; agrp = agrp->next) { ListBase tempGroup; - + /* add list of channels to action's channels */ tempGroup = agrp->channels; BLI_movelisttolist(&act->curves, &agrp->channels); agrp->channels = tempGroup; - + /* clear moved flag */ agrp->flag &= ~AGRP_MOVED; - + /* if group was temporary one: * - unassign all FCurves which were temporarily added to it * - remove from list (but don't free as it's on the stack!) */ if (agrp->flag & AGRP_TEMP) { FCurve *fcu; - + for (fcu = agrp->channels.first; fcu; fcu = fcu->next) { fcu->grp = NULL; } - + BLI_remlink(&act->groups, agrp); break; } } } -/* Change the order of anim-channels within action +/* Change the order of anim-channels within action * mode: REARRANGE_ANIMCHAN_* */ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrangeAnimChan_Mode mode) @@ -1189,35 +1189,35 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange bActionGroup tgrp; ListBase anim_data_visible = {NULL, NULL}; bool do_channels; - + /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - + if (rearrange_func == NULL) return; - + /* make sure we're only operating with groups (vs a mixture of groups+curves) */ split_groups_action_temp(act, &tgrp); - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GROUP); - - /* rearrange groups first + + /* rearrange groups first * - the group's channels will only get considered if nothing happened when rearranging the groups * i.e. the rearrange function returned 0 */ do_channels = (rearrange_animchannel_islands(&act->groups, rearrange_func, mode, ANIMTYPE_GROUP, &anim_data_visible) == 0); - + /* free temp data */ BLI_freelistN(&anim_data_visible); - + if (do_channels) { bActionGroup *agrp; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_FCURVE); - + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only consider F-Curves if they're visible (group expanded) */ if (EXPANDED_AGRP(ac, agrp)) { @@ -1225,11 +1225,11 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange &anim_data_visible); } } - + /* free temp data */ BLI_freelistN(&anim_data_visible); } - + /* assemble lists into one list (and clear moved tags) */ join_groups_action_temp(act); } @@ -1239,23 +1239,23 @@ static void rearrange_action_channels(bAnimContext *ac, bAction *act, eRearrange static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRearrangeAnimChan_Mode mode) { ListBase anim_data_visible = {NULL, NULL}; - + NlaTrack *nlt; NlaStrip *strip; - + /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - + if (rearrange_func == NULL) return; - + /* skip if these curves aren't being shown */ if (adt->flag & ADT_NLA_SKEYS_COLLAPSED) return; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_NLACURVE); - + /* we cannot rearrange between strips, but within each strip, we can rearrange those curves */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { for (strip = nlt->strips.first; strip; strip = strip->next) { @@ -1263,7 +1263,7 @@ static void rearrange_nla_control_channels(bAnimContext *ac, AnimData *adt, eRea &anim_data_visible); } } - + /* free temp data */ BLI_freelistN(&anim_data_visible); } @@ -1275,36 +1275,36 @@ static void rearrange_gpencil_channels(bAnimContext *ac, eRearrangeAnimChan_Mode ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); - + if (rearrange_func == NULL) return; - + /* get Grease Pencil datablocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { ListBase anim_data_visible = {NULL, NULL}; bGPdata *gpd = ale->data; - + /* only consider layers if this datablock is open */ BLI_assert(ale->type == ANIMTYPE_GPDATABLOCK); if ((gpd->flag & GP_DATA_EXPAND) == 0) continue; - + /* Filter visible data. */ rearrange_animchannels_filter_visible(&anim_data_visible, ac, ANIMTYPE_GPLAYER); - + /* rearrange datablock's layers */ rearrange_animchannel_islands(&gpd->layers, rearrange_func, mode, ANIMTYPE_GPLAYER, &anim_data_visible); - + /* free visible layers data */ BLI_freelistN(&anim_data_visible); } - + /* free GPD channel data */ ANIM_animdata_freelist(&anim_data); } @@ -1315,14 +1315,14 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) { bAnimContext ac; eRearrangeAnimChan_Mode mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get mode */ mode = RNA_enum_get(op->ptr, "direction"); - + /* method to move channels depends on the editor */ if (ac.datatype == ANIMCONT_GPENCIL) { /* Grease Pencil channels */ @@ -1340,23 +1340,23 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get animdata blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ale->data; - + switch (ac.datatype) { case ANIMCONT_NLA: /* NLA-tracks only */ rearrange_nla_channels(&ac, adt, mode); break; - + case ANIMCONT_DRIVERS: /* Drivers list only */ rearrange_driver_channels(&ac, adt, mode); break; - + case ANIMCONT_ACTION: /* Single Action only... */ case ANIMCONT_SHAPEKEY: // DOUBLE CHECK ME... { @@ -1366,13 +1366,13 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) printf("Animdata has no action\n"); break; } - + default: /* DopeSheet/Graph Editor - Some Actions + NLA Control Curves */ { /* NLA Control Curves */ if (adt->nla_tracks.first) rearrange_nla_control_channels(&ac, adt, mode); - + /* Action */ if (adt->action) rearrange_action_channels(&ac, adt->action, mode); @@ -1382,14 +1382,14 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); } - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1399,14 +1399,14 @@ static void ANIM_OT_channels_move(wmOperatorType *ot) ot->name = "Move Channels"; ot->idname = "ANIM_OT_channels_move"; ot->description = "Rearrange selected animation channels"; - + /* api callbacks */ ot->exec = animchannels_rearrange_exec; ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "direction", prop_animchannel_rearrange_types, REARRANGE_ANIMCHAN_DOWN, "Direction", ""); } @@ -1422,16 +1422,16 @@ static int animchannels_grouping_poll(bContext *C) /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; - + /* animation editor test - must be suitable modes only */ sl = CTX_wm_space_data(C); - + switch (sa->spacetype) { /* supported... */ case SPACE_ACTION: { SpaceAction *saction = (SpaceAction *)sl; - + /* dopesheet and action only - all others are for other datatypes or have no groups */ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0) return 0; @@ -1441,7 +1441,7 @@ static int animchannels_grouping_poll(bContext *C) case SPACE_IPO: { SpaceIpo *sipo = (SpaceIpo *)sl; - + /* drivers can't have groups... */ if (sipo->mode != SIPO_MODE_ANIMATION) return 0; @@ -1452,50 +1452,50 @@ static int animchannels_grouping_poll(bContext *C) default: return 0; } - + return 1; } /* ----------------------------------------------------------- */ static void animchannels_group_channels(bAnimContext *ac, bAnimListElem *adt_ref, const char name[]) -{ +{ AnimData *adt = adt_ref->adt; bAction *act = adt->action; - + if (act) { ListBase anim_data = {NULL, NULL}; int filter; - + /* find selected F-Curves to re-group */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(ac, &anim_data, filter, adt_ref, ANIMCONT_CHANNEL); - + if (anim_data.first) { bActionGroup *agrp; bAnimListElem *ale; - + /* create new group, which should now be part of the action */ agrp = action_groups_add_new(act, name); BLI_assert(agrp != NULL); - + /* transfer selected F-Curves across to new group */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; bActionGroup *grp = fcu->grp; - + /* remove F-Curve from group, then group too if it is now empty */ action_groups_remove_channel(act, fcu); - + if ((grp) && BLI_listbase_is_empty(&grp->channels)) { BLI_freelinkN(&act->groups, grp); } - + /* add F-Curve to group */ action_groups_add_channel(act, agrp, fcu); } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -1505,35 +1505,35 @@ static int animchannels_group_exec(bContext *C, wmOperator *op) { bAnimContext ac; char name[MAX_NAME]; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get name for new group */ RNA_string_get(op->ptr, "name", name); - + /* XXX: name for group should never be empty... */ if (name[0]) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* handle each animdata block separately, so that the regrouping doesn't flow into blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { animchannels_group_channels(&ac, ale, name); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* updatss */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } - + return OPERATOR_FINISHED; } @@ -1543,18 +1543,18 @@ static void ANIM_OT_channels_group(wmOperatorType *ot) ot->name = "Group Channels"; ot->idname = "ANIM_OT_channels_group"; ot->description = "Add selected F-Curves to a new group"; - + /* callbacks */ ot->invoke = WM_operator_props_popup; ot->exec = animchannels_group_exec; ot->poll = animchannels_grouping_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ - ot->prop = RNA_def_string(ot->srna, "name", "New Group", - sizeof(((bActionGroup *)NULL)->name), + ot->prop = RNA_def_string(ot->srna, "name", "New Group", + sizeof(((bActionGroup *)NULL)->name), "Name", "Name of newly created group"); /* RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); */ /* XXX: still not too sure about this - keeping same text is confusing... */ } @@ -1564,33 +1564,33 @@ static void ANIM_OT_channels_group(wmOperatorType *ot) static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* just selected F-Curves... */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { /* find action for this F-Curve... */ if (ale->adt && ale->adt->action) { FCurve *fcu = (FCurve *)ale->data; bAction *act = ale->adt->action; - + /* only proceed to remove if F-Curve is in a group... */ - if (fcu->grp) { + if (fcu->grp) { bActionGroup *agrp = fcu->grp; - + /* remove F-Curve from group and add at tail (ungrouped) */ action_groups_remove_channel(act, fcu); BLI_addtail(&act->curves, fcu); - + /* delete group if it is now empty */ if (BLI_listbase_is_empty(&agrp->channels)) { BLI_freelinkN(&act->groups, agrp); @@ -1598,13 +1598,13 @@ static int animchannels_ungroup_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); - + /* updates */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1614,11 +1614,11 @@ static void ANIM_OT_channels_ungroup(wmOperatorType *ot) ot->name = "Ungroup Channels"; ot->idname = "ANIM_OT_channels_ungroup"; ot->description = "Remove selected F-Curves from their current groups"; - + /* callbacks */ ot->exec = animchannels_ungroup_exec; ot->poll = animchannels_grouping_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1631,22 +1631,22 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* cannot delete in shapekey */ - if (ac.datatype == ANIMCONT_SHAPEKEY) + if (ac.datatype == ANIMCONT_SHAPEKEY) return OPERATOR_CANCELLED; - - + + /* do groups only first (unless in Drivers mode, where there are none) */ if (ac.datatype != ANIMCONT_DRIVERS) { /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* delete selected groups and their associated channels */ for (ale = anim_data.first; ale; ale = ale->next) { /* only groups - don't check other types yet, since they may no-longer exist */ @@ -1654,20 +1654,20 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) bActionGroup *agrp = (bActionGroup *)ale->data; AnimData *adt = ale->adt; FCurve *fcu, *fcn; - + /* skip this group if no AnimData available, as we can't safely remove the F-Curves */ if (adt == NULL) continue; - + /* delete all of the Group's F-Curves, but no others */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) { fcn = fcu->next; - + /* remove from group and action, then free */ action_groups_remove_channel(adt->action, fcu); free_fcurve(fcu); } - + /* free the group itself */ if (adt->action) BLI_freelinkN(&adt->action->groups, agrp); @@ -1675,24 +1675,24 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(agrp); } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* delete selected data channels */ for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { - case ANIMTYPE_FCURVE: + case ANIMTYPE_FCURVE: { /* F-Curves if we can identify its parent */ AnimData *adt = ale->adt; FCurve *fcu = (FCurve *)ale->data; - + /* try to free F-Curve */ ANIM_fcurve_delete_from_animdata(&ac, adt, fcu); break; @@ -1702,7 +1702,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* NLA Control Curve - Deleting it should disable the corresponding setting... */ NlaStrip *strip = (NlaStrip *)ale->owner; FCurve *fcu = (FCurve *)ale->data; - + if (STREQ(fcu->rna_path, "strip_time")) { strip->flag &= ~NLASTRIP_FLAG_USR_TIME; } @@ -1712,7 +1712,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) else { printf("ERROR: Trying to delete NLA Control Curve for unknown property '%s'\n", fcu->rna_path); } - + /* unlink and free the F-Curve */ BLI_remlink(&strip->fcurves, fcu); free_fcurve(fcu); @@ -1723,7 +1723,7 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* Grease Pencil layer */ bGPdata *gpd = (bGPdata *)ale->id; bGPDlayer *gpl = (bGPDlayer *)ale->data; - + /* try to delete the layer's data and the layer itself */ BKE_gpencil_free_frames(gpl); BLI_freelinkN(&gpd->layers, gpl); @@ -1734,35 +1734,35 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* Mask layer */ Mask *mask = (Mask *)ale->id; MaskLayer *masklay = (MaskLayer *)ale->data; - + /* try to delete the layer's data and the layer itself */ BKE_mask_layer_remove(mask, masklay); break; } } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); DAG_relations_tag_update(CTX_data_main(C)); return OPERATOR_FINISHED; } - + static void ANIM_OT_channels_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Channels"; ot->idname = "ANIM_OT_channels_delete"; ot->description = "Delete all selected animation channels"; - + /* api callbacks */ ot->exec = animchannels_delete_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1789,7 +1789,7 @@ static const EnumPropertyItem prop_animchannel_settings_types[] = { /* ------------------- */ -/* Set/clear a particular flag (setting) for all selected + visible channels +/* Set/clear a particular flag (setting) for all selected + visible channels * setting: the setting to modify * mode: eAnimChannels_SetFlag * onlysel: only selected channels get the flag set @@ -1801,20 +1801,20 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin ListBase all_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data that we need if flush is on */ if (flush) { - /* get list of all channels that selection may need to be flushed to + /* get list of all channels that selection may need to be flushed to * - hierarchy visibility needs to be ignored so that settings can get flushed * "down" inside closed containers */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype); } - - /* filter data that we're working on + + /* filter data that we're working on * - hierarchy matters if we're doing this from the channels region - * since we only want to apply this to channels we can "see", + * since we only want to apply this to channels we can "see", * and have these affect their relatives * - but for Graph Editor, this gets used also from main region * where hierarchy doesn't apply [#21276] @@ -1829,12 +1829,12 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin } if (onlysel) filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* if toggling, check if disable or enable */ if (mode == ACHANNEL_SETFLAG_TOGGLE) { /* default to turn all on, unless we encounter one that's on... */ mode = ACHANNEL_SETFLAG_ADD; - + /* see if we should turn off instead... */ for (ale = anim_data.first; ale; ale = ale->next) { /* set the setting in the appropriate way (if available) */ @@ -1844,21 +1844,21 @@ static void setflag_anim_channels(bAnimContext *ac, eAnimChannel_Settings settin } } } - + /* apply the setting */ for (ale = anim_data.first; ale; ale = ale->next) { /* skip channel if setting is not available */ if (ANIM_channel_setting_get(ac, ale, setting) == -1) continue; - + /* set the setting in the appropriate way */ ANIM_channel_setting_set(ac, ale, setting, mode); - + /* if flush status... */ if (flush) ANIM_flush_setting_anim_channels(ac, &all_data, ale, setting, mode); } - + ANIM_animdata_freelist(&anim_data); BLI_freelistN(&all_data); } @@ -1871,27 +1871,27 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) eAnimChannel_Settings setting; eAnimChannels_SetFlag mode; bool flush = true; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */ mode = RNA_enum_get(op->ptr, "mode"); setting = RNA_enum_get(op->ptr, "type"); - + /* check if setting is flushable */ if (setting == ACHANNEL_SETTING_EXPAND) flush = false; - - /* modify setting + + /* modify setting * - only selected channels are affected */ setflag_anim_channels(&ac, setting, mode, true, flush); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1899,20 +1899,20 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Enable Channel Setting"; ot->idname = "ANIM_OT_channels_setting_enable"; ot->description = "Enable specified setting on all selected animation channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", ""); @@ -1924,20 +1924,20 @@ static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Disable Channel Setting"; ot->idname = "ANIM_OT_channels_setting_disable"; ot->description = "Disable specified setting on all selected animation channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", ""); @@ -1949,20 +1949,20 @@ static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Toggle Channel Setting"; ot->idname = "ANIM_OT_channels_setting_toggle"; ot->description = "Toggle specified setting on all selected animation channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ prop = RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); @@ -1974,19 +1974,19 @@ static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Toggle Channel Editability"; ot->idname = "ANIM_OT_channels_editable_toggle"; ot->description = "Toggle editability of selected channels"; - + /* api callbacks */ ot->exec = animchannels_setflag_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); @@ -2001,21 +2001,21 @@ static int animchannels_expand_exec(bContext *C, wmOperator *op) { bAnimContext ac; bool onlysel = true; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) onlysel = false; - + /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, false); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2025,14 +2025,14 @@ static void ANIM_OT_channels_expand(wmOperatorType *ot) ot->name = "Expand Channels"; ot->idname = "ANIM_OT_channels_expand"; ot->description = "Expand (i.e. open) all selected expandable animation channels"; - + /* api callbacks */ ot->exec = animchannels_expand_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); } @@ -2043,21 +2043,21 @@ static int animchannels_collapse_exec(bContext *C, wmOperator *op) { bAnimContext ac; bool onlysel = true; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) onlysel = false; - + /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, false); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2067,14 +2067,14 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) ot->name = "Collapse Channels"; ot->idname = "ANIM_OT_channels_collapse"; ot->description = "Collapse (i.e. close) all selected expandable animation channels"; - + /* api callbacks */ ot->exec = animchannels_collapse_exec; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", true, "All", "Collapse all channels (not just selected ones)"); } @@ -2090,37 +2090,37 @@ static void ANIM_OT_channels_collapse(wmOperatorType *ot) * or are no longer wanted * 3) No drivers */ - + static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get animdata blocks */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { ID *id = ale->id; AnimData *adt = ale->data; - + bool action_empty = false; bool nla_empty = false; bool drivers_empty = false; - + /* sanity checks */ BLI_assert((id != NULL) && (adt != NULL)); - + /* check if this is "empty" and can be deleted */ /* (For now, there are only these 3 criteria) */ - + /* 1) Active Action is missing or empty */ if (ELEM(NULL, adt->action, adt->action->curves.first)) { action_empty = true; @@ -2128,18 +2128,18 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) else { /* TODO: check for keyframe + fmodifier data on these too */ } - + /* 2) No NLA Tracks and/or NLA Strips */ if (adt->nla_tracks.first == NULL) { nla_empty = true; } else { NlaTrack *nlt; - + /* empty tracks? */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { if (nlt->strips.first) { - /* stop searching, as we found one that actually had stuff we don't want lost + /* stop searching, as we found one that actually had stuff we don't want lost * NOTE: nla_empty gets reset to false, as a previous track may have been empty */ nla_empty = false; @@ -2151,23 +2151,23 @@ static int animchannels_clean_empty_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + /* 3) Drivers */ drivers_empty = (adt->drivers.first == NULL); - - + + /* remove AnimData? */ if (action_empty && nla_empty && drivers_empty) { BKE_animdata_free(id, true); } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2177,11 +2177,11 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) ot->name = "Remove Empty Animation Data"; ot->idname = "ANIM_OT_channels_clean_empty"; ot->description = "Delete all empty animation data containers from visible data-blocks"; - + /* api callbacks */ ot->exec = animchannels_clean_empty_exec; ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2191,56 +2191,56 @@ static void ANIM_OT_channels_clean_empty(wmOperatorType *ot) static int animchannels_enable_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + /* channels region test */ /* TODO: could enhance with actually testing if channels region? */ if (ELEM(NULL, sa, CTX_wm_region(C))) return 0; - + /* animation editor test - Action/Dopesheet/etc. and Graph only */ if (ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO) == 0) return 0; - + return 1; } static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop through filtered data and clean curves */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - + /* remove disabled flags from F-Curves */ fcu->flag &= ~FCURVE_DISABLED; - + /* for drivers, let's do the same too */ if (fcu->driver) fcu->driver->flag &= ~DRIVER_FLAG_INVALID; - + /* tag everything for updates - in particular, this is needed to get drivers working again */ ale->update |= ANIM_UPDATE_DEPS; } - + ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2250,11 +2250,11 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) ot->name = "Revive Disabled F-Curves"; ot->idname = "ANIM_OT_channels_fcurves_enable"; ot->description = "Clears 'disabled' tag from all F-Curves to get broken F-Curves working again"; - + /* api callbacks */ ot->exec = animchannels_enable_exec; ot->poll = animchannels_enable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2265,10 +2265,10 @@ static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) static int animchannels_find_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + if (sa == NULL) return 0; - + /* animation editor with dopesheet */ return ELEM(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA); } @@ -2277,14 +2277,14 @@ static int animchannels_find_poll(bContext *C) static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent *evt) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* set initial filter text, and enable filter */ RNA_string_set(op->ptr, "query", ac.ads->searchstr); - + /* defer to popup */ return WM_operator_props_popup(C, op, evt); } @@ -2293,26 +2293,26 @@ static int animchannels_find_invoke(bContext *C, wmOperator *op, const wmEvent * static int animchannels_find_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* update filter text, and ensure that filter is enabled if there's something there * NOTE: we turn the filter off if there's nothing (this is a quick shortcut for dismissing) */ RNA_string_get(op->ptr, "query", ac.ads->searchstr); - + if (ac.ads->searchstr[0]) { ac.ads->filterflag |= ADS_FILTER_BY_FCU_NAME; } else { ac.ads->filterflag &= ~ADS_FILTER_BY_FCU_NAME; } - + /* redraw */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2322,15 +2322,15 @@ static void ANIM_OT_channels_find(wmOperatorType *ot) ot->name = "Find Channels"; ot->idname = "ANIM_OT_channels_find"; ot->description = "Filter the set of channels shown to only include those with matching names"; - + /* callbacks */ ot->invoke = animchannels_find_invoke; ot->exec = animchannels_find_exec; ot->poll = animchannels_find_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_string(ot->srna, "query", "Query", sizeof(((bDopeSheet *)NULL)->searchstr), "", "Text to search for in channel names"); } @@ -2340,37 +2340,37 @@ static void ANIM_OT_channels_find(wmOperatorType *ot) static int animchannels_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* 'standard' behavior - check if selected, then apply relevant selection */ if (RNA_boolean_get(op->ptr, "invert")) ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, false, ACHANNEL_SETFLAG_INVERT); else ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, true, ACHANNEL_SETFLAG_ADD); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "ANIM_OT_channels_select_all_toggle"; ot->description = "Toggle selection of all animation channels"; - + /* api callbacks */ ot->exec = animchannels_deselectall_exec; ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", ""); } @@ -2382,12 +2382,12 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ac->ar->v2d; rctf rectf; float ymin, ymax; - + /* set initial y extents */ if (ac->datatype == ANIMCONT_NLA) { ymin = (float)(-NLACHANNEL_HEIGHT(snla)); @@ -2397,27 +2397,27 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec ymin = 0.0f; ymax = (float)(-ACHANNEL_HEIGHT(ac)); } - + /* convert border-region to view coordinates */ UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax - 2, &rectf.xmax, &rectf.ymax); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { if (ac->datatype == ANIMCONT_NLA) ymin = ymax - NLACHANNEL_STEP(snla); else ymin = ymax - ACHANNEL_STEP(ac); - + /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { /* set selection flags only */ ANIM_channel_setting_set(ac, ale, ACHANNEL_SETTING_SELECT, selectmode); - + /* type specific actions */ switch (ale->type) { case ANIMTYPE_GROUP: @@ -2431,20 +2431,20 @@ static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selec case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)ale->data; - - /* for now, it's easier just to do this here manually, as defining a new type - * currently adds complications when doing other stuff + + /* for now, it's easier just to do this here manually, as defining a new type + * currently adds complications when doing other stuff */ ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); break; } } } - + /* set minimum extent to be the maximum of the next channel */ ymax = ymin; } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -2458,11 +2458,11 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) short selectmode = 0; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); @@ -2476,15 +2476,15 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) else { selectmode = ACHANNEL_SETFLAG_CLEAR; } - + /* apply borderselect animation channels */ borderselect_anim_channels(&ac, &rect, selectmode); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; -} +} static void ANIM_OT_channels_select_border(wmOperatorType *ot) { @@ -2492,18 +2492,18 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "ANIM_OT_channels_select_border"; ot->description = "Select all animation channels within the specified region"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = animchannels_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = animedit_poll_channels_nla_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); } @@ -2518,33 +2518,33 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) bAnimListElem *ale; int filter; bool success = false; - + /* get the channel that was clicked on */ /* filter channels */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get channel from index */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) printf("Error: animation channel (index = %d) not found in rename_anim_channels()\n", channel_index); - + ANIM_animdata_freelist(&anim_data); return false; } - + /* check that channel can be renamed */ acf = ANIM_channel_get_typeinfo(ale); if (acf && acf->name_prop) { PointerRNA ptr; PropertyRNA *prop; - + /* ok if we can get name property to edit from this channel */ if (acf->name_prop(ale, &ptr, &prop)) { /* actually showing the rename textfield is done on redraw, - * so here we just store the index of this channel in the + * so here we just store the index of this channel in the * dopesheet data, which will get utilized when drawing the * channel... * @@ -2556,7 +2556,7 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index) } } } - + /* free temp data and tag for refresh */ ANIM_animdata_freelist(&anim_data); ED_region_tag_redraw(ac->ar); @@ -2569,18 +2569,18 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2]) View2D *v2d; int channel_index; float x, y; - + /* get useful pointers from animation context data */ ar = ac->ar; v2d = &ar->v2d; - - /* figure out which channel user clicked in + + /* figure out which channel user clicked in * Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height * so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use * ACHANNEL_HEIGHT_HALF. */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); - + if (ac->datatype == ANIMCONT_NLA) { SpaceNla *snla = (SpaceNla *)ac->sl; UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); @@ -2617,7 +2617,7 @@ static void ANIM_OT_channels_rename(wmOperatorType *ot) ot->name = "Rename Channels"; ot->idname = "ANIM_OT_channels_rename"; ot->description = "Rename animation channel under mouse"; - + /* api callbacks */ ot->invoke = animchannels_rename_invoke; ot->poll = animedit_poll_channels_active; @@ -2632,19 +2632,19 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, bAnimListElem *ale; int filter; int notifierFlags = 0; - + /* get the channel that was clicked on */ /* filter channels */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get channel from index */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", channel_index); - + ANIM_animdata_freelist(&anim_data); return 0; } @@ -2664,7 +2664,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, { Scene *sce = (Scene *)ale->data; AnimData *adt = sce->adt; - + /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ @@ -2675,7 +2675,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, sce->flag |= SCE_DS_SELECTED; if (adt) adt->flag |= ADT_UI_SELECTED; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } @@ -2686,7 +2686,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, Base *base = (Base *)ale->data; Object *ob = base->object; AnimData *adt = ob->adt; - + /* set selection status */ if ((ob->restrictflag & OB_RESTRICT_SELECT) == 0) { if (selectmode == SELECT_INVERT) { @@ -2760,28 +2760,28 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); ale->adt->flag |= ADT_UI_SELECTED; } - + /* set active? */ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) ale->adt->flag |= ADT_UI_ACTIVE; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } - case ANIMTYPE_GROUP: + case ANIMTYPE_GROUP: { bActionGroup *agrp = (bActionGroup *)ale->data; - + Object *ob = NULL; bPoseChannel *pchan = NULL; - - + + /* Armatures-Specific Feature: * Since groups are used to collect F-Curves of the same Bone by default * (via Keying Sets) so that they can be managed better, we try to make * things here easier for animators by mapping group selection to bone - * selection. + * selection. * * Only do this if "Only Selected" dopesheet filter is not active, or else it * becomes too unpredictable/tricky to manage @@ -2789,7 +2789,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, if ((ac->ads->filterflag & ADS_FILTER_ONLYSEL) == 0) { if ((ale->id) && (GS(ale->id->name) == ID_OB)) { ob = (Object *)ale->id; - + if (ob->type == OB_ARMATURE) { /* Assume for now that any group with corresponding name is what we want * (i.e. for an armature whose location is animated, things would break @@ -2798,10 +2798,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, * TODO: check the first F-Curve or so to be sure... */ pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); - } + } } } - + /* select/deselect group */ if (selectmode == SELECT_INVERT) { /* inverse selection status of this group only */ @@ -2810,11 +2810,11 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, else if (selectmode == -1) { /* select all in group (and deselect everthing else) */ FCurve *fcu; - + /* deselect all other channels */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false); - + /* only select channels in group and group itself */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) fcu->flag |= FCURVE_SELECTED; @@ -2824,10 +2824,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, /* select group by itself */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); if (pchan) ED_pose_deselect_all(ob, SEL_DESELECT, false); - + agrp->flag |= AGRP_SELECTED; } - + /* if group is selected now, make group the 'active' one in the visible list */ if (agrp->flag & AGRP_SELECTED) { ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); @@ -2837,7 +2837,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, NULL, ANIMTYPE_GROUP); if (pchan) ED_pose_bone_select(ob, pchan, false); } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } @@ -2845,7 +2845,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, case ANIMTYPE_NLACURVE: { FCurve *fcu = (FCurve *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* inverse selection status of this F-Curve only */ @@ -2856,18 +2856,18 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); fcu->flag |= FCURVE_SELECTED; } - + /* if F-Curve is selected now, make F-Curve the 'active' one in the visible list */ if (fcu->flag & FCURVE_SELECTED) ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type); - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } - case ANIMTYPE_SHAPEKEY: + case ANIMTYPE_SHAPEKEY: { KeyBlock *kb = (KeyBlock *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* inverse selection status of this ShapeKey only */ @@ -2878,39 +2878,39 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); kb->flag |= KEYBLOCK_SEL; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } case ANIMTYPE_NLACONTROLS: { AnimData *adt = (AnimData *)ale->data; - + /* toggle expand * - Although the triangle widget already allows this, since there's nothing else that can be done here now, * let's just use it for easier expand/collapse for now */ adt->flag ^= ADT_NLA_SKEYS_COLLAPSED; - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } case ANIMTYPE_GPDATABLOCK: { bGPdata *gpd = (bGPdata *)ale->data; - - /* toggle expand + + /* toggle expand * - although the triangle widget already allows this, the whole channel can also be used for this purpose */ gpd->flag ^= GP_DATA_EXPAND; - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* invert selection status of this layer only */ @@ -2921,12 +2921,12 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); gpl->flag |= GP_LAYER_SELECT; } - + /* change active layer, if this is selected (since we must always have an active layer) */ if (gpl->flag & GP_LAYER_SELECT) { ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, gpl, ANIMTYPE_GPLAYER); } - + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* Grease Pencil updates */ notifierFlags |= (ND_ANIMCHAN | NA_EDITED); /* Animation Ediotrs updates */ break; @@ -2934,19 +2934,19 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, case ANIMTYPE_MASKDATABLOCK: { Mask *mask = (Mask *)ale->data; - + /* toggle expand * - although the triangle widget already allows this, the whole channel can also be used for this purpose */ mask->flag ^= MASK_ANIMF_EXPAND; - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } case ANIMTYPE_MASKLAYER: { MaskLayer *masklay = (MaskLayer *)ale->data; - + /* select/deselect */ if (selectmode == SELECT_INVERT) { /* invert selection status of this layer only */ @@ -2957,7 +2957,7 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, false, ACHANNEL_SETFLAG_CLEAR); masklay->flag |= MASK_LAYERFLAG_SELECT; } - + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); break; } @@ -2966,10 +2966,10 @@ static int mouse_anim_channels(bContext *C, bAnimContext *ac, int channel_index, printf("Error: Invalid channel type in mouse_anim_channels()\n"); break; } - + /* free channels */ ANIM_animdata_freelist(&anim_data); - + /* return notifier flags */ return notifierFlags; } @@ -2986,16 +2986,16 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE int notifierFlags = 0; short selectmode; float x, y; - - + + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get useful pointers from animation context data */ ar = ac.ar; v2d = &ar->v2d; - + /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) selectmode = SELECT_INVERT; @@ -3003,45 +3003,45 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE selectmode = -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */ else selectmode = SELECT_REPLACE; - - /* figure out which channel user clicked in + + /* figure out which channel user clicked in * Note: although channels technically start at (y = ACHANNEL_FIRST), we need to adjust by half a channel's height * so that the tops of channels get caught ok. Since ACHANNEL_FIRST is really ACHANNEL_HEIGHT, we simply use * ACHANNEL_HEIGHT_HALF. */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP(&ac), 0, (float)ACHANNEL_HEIGHT_HALF(&ac), x, y, NULL, &channel_index); - + /* handle mouse-click in the relevant channel then */ notifierFlags = mouse_anim_channels(C, &ac, channel_index, selectmode); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); - + return OPERATOR_FINISHED; } - + static void ANIM_OT_channels_click(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Mouse Click on Channels"; ot->idname = "ANIM_OT_channels_click"; ot->description = "Handle mouse-clicks over animation channels"; - + /* api callbacks */ ot->invoke = animchannels_mouseclick_invoke; ot->poll = animedit_poll_channels_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ /* NOTE: don't save settings, otherwise, can end up with some weird behaviour (sticky extend) */ prop = RNA_def_boolean(ot->srna, "extend", false, "Extend Select", ""); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - + prop = RNA_def_boolean(ot->srna, "children_only", false, "Select Children Only", ""); // CTRLKEY|SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -3152,13 +3152,13 @@ void ED_operatortypes_animchannels(void) { WM_operatortype_append(ANIM_OT_channels_select_all_toggle); WM_operatortype_append(ANIM_OT_channels_select_border); - + WM_operatortype_append(ANIM_OT_channels_click); WM_operatortype_append(ANIM_OT_channel_select_keys); WM_operatortype_append(ANIM_OT_channels_rename); WM_operatortype_append(ANIM_OT_channels_find); - + WM_operatortype_append(ANIM_OT_channels_setting_enable); WM_operatortype_append(ANIM_OT_channels_setting_disable); WM_operatortype_append(ANIM_OT_channels_setting_toggle); @@ -3167,16 +3167,16 @@ void ED_operatortypes_animchannels(void) /* XXX does this need to be a separate operator? */ WM_operatortype_append(ANIM_OT_channels_editable_toggle); - + WM_operatortype_append(ANIM_OT_channels_move); - + WM_operatortype_append(ANIM_OT_channels_expand); WM_operatortype_append(ANIM_OT_channels_collapse); - + WM_operatortype_append(ANIM_OT_channels_fcurves_enable); - + WM_operatortype_append(ANIM_OT_channels_clean_empty); - + WM_operatortype_append(ANIM_OT_channels_group); WM_operatortype_append(ANIM_OT_channels_ungroup); } @@ -3186,7 +3186,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation Channels", 0, 0); wmKeyMapItem *kmi; - + /* click-select */ /* XXX for now, only leftmouse.... */ WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); @@ -3201,31 +3201,31 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* find (i.e. a shortcut for setting the name filter) */ WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); - + /* deselect all */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", true); - + /* borderselect */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", EVT_TWEAK_L, KM_ANY, 0, 0); - + /* delete */ WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_delete", DELKEY, KM_PRESS, 0, 0); - + /* settings */ WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_disable", WKEY, KM_PRESS, KM_ALT, 0); - + /* settings - specialized hotkeys */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); - + /* expand/collapse */ WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_expand", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "all", false); kmi = WM_keymap_add_item(keymap, "ANIM_OT_channels_collapse", PADMINUS, KM_PRESS, KM_CTRL, 0); @@ -3236,7 +3236,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "direction", REARRANGE_ANIMCHAN_DOWN); RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEUPKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_TOP); RNA_enum_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_move", PAGEDOWNKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "direction", REARRANGE_ANIMCHAN_BOTTOM); - + /* grouping */ WM_keymap_add_item(keymap, "ANIM_OT_channels_group", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_ungroup", GKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index b362efccc9b..7eddb3bc3b2 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -72,7 +72,7 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) id = ale->id; if (!id) return; - + /* tag AnimData for refresh so that other views will update in realtime with these changes */ adt = BKE_animdata_from_id(id); if (adt) { @@ -82,16 +82,16 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) /* update data */ fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL; - + if (fcu && fcu->rna_path) { /* if we have an fcurve, call the update for the property we * are editing, this is then expected to do the proper redraws * and depsgraph updates */ PointerRNA id_ptr, ptr; PropertyRNA *prop; - + RNA_id_pointer_create(id, &id_ptr); - + if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) RNA_property_update_main(G.main, scene, &ptr, prop); } @@ -102,17 +102,17 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) } } -/* tags the given ID block for refreshes (if applicable) due to +/* tags the given ID block for refreshes (if applicable) due to * Animation Editor editing */ void ANIM_id_update(Scene *UNUSED(scene), ID *id) { if (id) { AnimData *adt = BKE_animdata_from_id(id); - + /* tag AnimData for refresh so that other views will update in realtime with these changes */ if (adt) adt->recalc |= ADT_RECALC_ANIM; - + /* set recalc flags */ DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive? } @@ -133,33 +133,33 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro { bActionGroup *agrp = (bActionGroup *)ale->data; ID *owner_id = ale->id; - + /* major priority is selection status * so we need both a group and an owner */ if (ELEM(NULL, agrp, owner_id)) return; - + /* for standard Objects, check if group is the name of some bone */ if (GS(owner_id->name) == ID_OB) { Object *ob = (Object *)owner_id; - - /* check if there are bones, and whether the name matches any + + /* check if there are bones, and whether the name matches any * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone */ if (ob->pose) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); bArmature *arm = ob->data; - + if (pchan) { bActionGroup *bgrp; - + /* if one matches, sync the selection status */ if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) agrp->flag |= AGRP_SELECTED; else agrp->flag &= ~AGRP_SELECTED; - + /* also sync active group status */ if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) { /* if no previous F-Curve has active flag, then we're the first and only one to get it */ @@ -176,7 +176,7 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro /* this can't possibly be active now */ agrp->flag &= ~AGRP_ACTIVE; } - + /* sync group colors */ bgrp = (bActionGroup *)BLI_findlink(&ob->pose->agroups, (pchan->agrp_index - 1)); if (bgrp) { @@ -187,33 +187,33 @@ static void animchan_sync_group(bAnimContext *ac, bAnimListElem *ale, bActionGro } } } - + /* perform syncing updates for F-Curves */ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve **active_fcurve) { FCurve *fcu = (FCurve *)ale->data; ID *owner_id = ale->id; - - /* major priority is selection status, so refer to the checks done in anim_filter.c + + /* major priority is selection status, so refer to the checks done in anim_filter.c * skip_fcurve_selected_data() for reference about what's going on here... */ if (ELEM(NULL, fcu, fcu->rna_path, owner_id)) return; - + if (GS(owner_id->name) == ID_OB) { Object *ob = (Object *)owner_id; - + /* only affect if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { bArmature *arm = (bArmature *)ob->data; bPoseChannel *pchan; char *bone_name; - + /* get bone-name, and check if this bone is selected */ bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); - + /* F-Curve selection depends on whether the bone is selected */ if ((pchan) && (pchan->bone)) { /* F-Curve selection */ @@ -221,8 +221,8 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve ** fcu->flag |= FCURVE_SELECTED; else fcu->flag &= ~FCURVE_SELECTED; - - /* Active F-Curve - it should be the first one for this bone on the + + /* Active F-Curve - it should be the first one for this bone on the * active object to be considered as active */ if ((ob == ac->obact) && (pchan->bone == arm->act_bone)) { @@ -245,18 +245,18 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve ** } else if (GS(owner_id->name) == ID_SCE) { Scene *scene = (Scene *)owner_id; - + /* only affect if F-Curve involves sequence_editor.sequences */ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq; char *seq_name; - + /* get strip name, and check if this strip is selected */ seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false); if (seq_name) MEM_freeN(seq_name); - + /* update selection status */ if (seq) { if (seq->flag & SELECT) @@ -268,17 +268,17 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve ** } else if (GS(owner_id->name) == ID_NT) { bNodeTree *ntree = (bNodeTree *)owner_id; - + /* check for selected nodes */ if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) { bNode *node; char *node_name; - + /* get strip name, and check if this strip is selected */ node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); - + /* update selection/active status */ if (node) { /* update selection status */ @@ -286,7 +286,7 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve ** fcu->flag |= FCURVE_SELECTED; else fcu->flag &= ~FCURVE_SELECTED; - + /* update active status */ /* XXX: this may interfere with setting bones as active if both exist at once; * then again, if that's the case, production setups aren't likely to be animating @@ -313,7 +313,7 @@ static void animchan_sync_fcurve(bAnimContext *ac, bAnimListElem *ale, FCurve ** static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale) { bGPDlayer *gpl = (bGPDlayer *)ale->data; - + /* Make sure the selection flags agree with the "active" flag. * The selection flags are used in the Dopesheet only, whereas * the active flag is used everywhere else. Hence, we try to @@ -332,7 +332,7 @@ static void animchan_sync_gplayer(bAnimContext *UNUSED(ac), bAnimListElem *ale) } /* ---------------- */ - + /* Main call to be exported to animation editors */ void ANIM_sync_animchannels_to_data(const bContext *C) { @@ -340,38 +340,38 @@ void ANIM_sync_animchannels_to_data(const bContext *C) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + bActionGroup *active_agrp = NULL; FCurve *active_fcurve = NULL; - + /* get animation context info for filtering the channels */ if (ANIM_animdata_get_context(C, &ac) == 0) return; - + /* filter data */ - /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed + /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed * However, don't include duplicates so that selection statuses don't override each other */ filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* flush settings as appropriate depending on the types of the channels */ for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_GROUP: animchan_sync_group(&ac, ale, &active_agrp); break; - + case ANIMTYPE_FCURVE: animchan_sync_fcurve(&ac, ale, &active_fcurve); break; - + case ANIMTYPE_GPLAYER: animchan_sync_gplayer(&ac, ale); break; } } - + ANIM_animdata_freelist(&anim_data); } @@ -392,14 +392,14 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) for (ale = anim_data->first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { bGPDlayer *gpl = ale->data; - + if (ale->update & ANIM_UPDATE_ORDER) { ale->update &= ~ANIM_UPDATE_ORDER; if (gpl) { //gpencil_sort_frames(gpl); } } - + if (ale->update & ANIM_UPDATE_DEPS) { ale->update &= ~ANIM_UPDATE_DEPS; ANIM_list_elem_update(ac->scene, ale); @@ -407,19 +407,19 @@ void ANIM_animdata_update(bAnimContext *ac, ListBase *anim_data) } else if (ale->datatype == ALE_FCURVE) { FCurve *fcu = ale->key_data; - + if (ale->update & ANIM_UPDATE_ORDER) { ale->update &= ~ANIM_UPDATE_ORDER; if (fcu) sort_time_fcurve(fcu); } - + if (ale->update & ANIM_UPDATE_HANDLES) { ale->update &= ~ANIM_UPDATE_HANDLES; if (fcu) calchandles_fcurve(fcu); } - + if (ale->update & ANIM_UPDATE_DEPS) { ale->update &= ~ANIM_UPDATE_DEPS; ANIM_list_elem_update(ac->scene, ale); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 109987bf46a..3feb14cd0f1 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -74,12 +74,12 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const float xscale, yscale, x, y; char numstr[32] = " t"; /* t is the character to start replacing from */ int slen; - + /* because the frame number text is subject to the same scaling as the contents of the view */ UI_view2d_scale_get(v2d, &xscale, &yscale); glScalef(1.0f / xscale, 1.0f, 1.0f); - - /* get timecode string + + /* get timecode string * - padding on str-buf passed so that it doesn't sit on the frame indicator * - power = 0, gives 'standard' behavior for time * but power = 1 is required for frames (to get integer frames) @@ -92,19 +92,19 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const } slen = UI_fontstyle_string_width(fstyle, numstr) - 1; - + /* get starting coordinates for drawing */ x = cfra * xscale; y = 0.9f * U.widget_unit; - + /* draw green box around/behind text */ UI_ThemeColorShade(TH_CFRAME, 0); glRectf(x, y, x + slen, y + 0.75f * U.widget_unit); - + /* draw current frame number - black text */ UI_ThemeColor(TH_TEXT); UI_fontstyle_draw_simple(fstyle, x - 0.25f * U.widget_unit, y + 0.15f * U.widget_unit, numstr); - + /* restore view transform */ glScalef(xscale, 1.0, 1.0); } @@ -142,13 +142,13 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) { Scene *scene = CTX_data_scene(C); - + /* only draw this if preview range is set */ if (PRVRANGEON) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - + /* only draw two separate 'curtains' if there's no overlap between them */ if (PSFRA < PEFRA + end_frame_width) { glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); @@ -157,7 +157,7 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d, int end_frame_width) else { glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); } - + glDisable(GL_BLEND); } } @@ -172,10 +172,10 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) /* sanity checks */ if (ac == NULL) return NULL; - + /* abort if rendering - we may get some race condition issues... */ if (G.is_rendering) return NULL; - + /* apart from strictly keyframe-related contexts, this shouldn't even happen */ // XXX: nla and channel here may not be necessary... if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_SHAPEKEY, ANIMCONT_DOPESHEET, @@ -188,7 +188,7 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) return ale->adt; } } - + /* cannot handle... */ return NULL; } @@ -201,15 +201,15 @@ static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt) /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ AnimData *adt = (AnimData *)ked->data; short only_keys = (short)ked->i1; - + /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP); bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP); } - + bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP); - + return 0; } @@ -219,20 +219,20 @@ static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt) /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ AnimData *adt = (AnimData *)ked->data; short only_keys = (short)ked->i1; - + /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_MAP); bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_MAP); } - + bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_MAP); - + return 0; } -/* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve +/* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve * - restore = whether to map points back to non-mapped time * - only_keys = whether to only adjust the location of the center point of beztriples */ @@ -240,20 +240,20 @@ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, bool restore, boo { KeyframeEditData ked = {{NULL}}; KeyframeEditFunc map_cb; - - /* init edit data + + /* init edit data * - AnimData is stored in 'data' * - only_keys is stored in 'i1' */ ked.data = (void *)adt; ked.i1 = (int)only_keys; - + /* get editing callback */ if (restore) map_cb = bezt_nlamapping_restore; else map_cb = bezt_nlamapping_apply; - + /* apply to F-Curve */ ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL); } @@ -432,7 +432,7 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag if (id && fcu && fcu->rna_path) { PointerRNA ptr, id_ptr; PropertyRNA *prop; - + /* get RNA property that F-Curve affects */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { @@ -446,7 +446,7 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag return RAD2DEGF(1.0f); /* radians to degrees */ } } - + /* TODO: other rotation types here as necessary */ } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index fcb1399be30..b41302f4706 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -111,13 +111,13 @@ static void animedit_get_yscale_factor(bAnimContext *ac) { bTheme *btheme = UI_GetTheme(); - + /* grab scale factor directly from action editor setting * NOTE: This theme setting doesn't have an ID, as it cannot be accessed normally * since it is a float, and the theme settings methods can only handle chars. */ ac->yscale_fac = btheme->tact.keyframe_scale_fac; - + /* clamp to avoid problems with uninitialised values... */ if (ac->yscale_fac < 0.1f) ac->yscale_fac = 1.0f; @@ -133,22 +133,22 @@ static Key *actedit_get_shapekeys(bAnimContext *ac) Scene *scene = ac->scene; Object *ob; Key *key; - + ob = OBACT; - if (ob == NULL) + if (ob == NULL) return NULL; - + /* XXX pinning is not available in 'ShapeKey' mode... */ //if (saction->pin) return NULL; - + /* shapekey data is stored with geometry data */ key = BKE_key_from_object(ob); - + if (key) { if (key->type == KEY_RELATIVE) return key; } - + return NULL; } @@ -157,7 +157,7 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction) { /* get dopesheet */ ac->ads = &saction->ads; - + /* sync settings with current view status, then return appropriate data */ switch (saction->mode) { case SACTCONT_ACTION: /* 'Action Editor' */ @@ -168,37 +168,37 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction) else saction->action = NULL; } - + ac->datatype = ANIMCONT_ACTION; ac->data = saction->action; - + ac->mode = saction->mode; return true; - + case SACTCONT_SHAPEKEY: /* 'ShapeKey Editor' */ ac->datatype = ANIMCONT_SHAPEKEY; ac->data = actedit_get_shapekeys(ac); - + /* if not pinned, sync with active object */ if (/*saction->pin == 0*/ true) { Key *key = (Key *)ac->data; - + if (key && key->adt) saction->action = key->adt->action; else saction->action = NULL; } - + ac->mode = saction->mode; return true; - + case SACTCONT_GPENCIL: /* Grease Pencil */ /* XXX review how this mode is handled... */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; - + ac->datatype = ANIMCONT_GPENCIL; ac->data = &saction->ads; - + ac->mode = saction->mode; return true; @@ -211,37 +211,37 @@ static bool actedit_get_context(bAnimContext *ac, SpaceAction *saction) ac->mode = saction->mode; return true; - + case SACTCONT_MASK: /* Mask */ /* XXX review how this mode is handled... */ { /* TODO, other methods to get the mask */ // Sequence *seq = BKE_sequencer_active_get(ac->scene); //MovieClip *clip = ac->scene->clip; // struct Mask *mask = seq ? seq->mask : NULL; - + /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; - + ac->datatype = ANIMCONT_MASK; ac->data = &saction->ads; - + ac->mode = saction->mode; return true; } case SACTCONT_DOPESHEET: /* DopeSheet */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ saction->ads.source = (ID *)ac->scene; - + ac->datatype = ANIMCONT_DOPESHEET; ac->data = &saction->ads; - + ac->mode = saction->mode; return true; - + default: /* unhandled yet */ ac->datatype = ANIMCONT_NONE; ac->data = NULL; - + ac->mode = -1; return false; } @@ -258,41 +258,41 @@ static bool graphedit_get_context(bAnimContext *ac, SpaceIpo *sipo) sipo->ads->source = (ID *)ac->scene; } ac->ads = sipo->ads; - + /* set settings for Graph Editor - "Selected = Editable" */ if (sipo->flag & SIPO_SELCUVERTSONLY) sipo->ads->filterflag |= ADS_FILTER_SELEDIT; else sipo->ads->filterflag &= ~ADS_FILTER_SELEDIT; - + /* sync settings with current view status, then return appropriate data */ switch (sipo->mode) { case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ sipo->ads->source = (ID *)ac->scene; sipo->ads->filterflag &= ~ADS_FILTER_ONLYDRIVERS; - + ac->datatype = ANIMCONT_FCURVES; ac->data = sipo->ads; - + ac->mode = sipo->mode; return true; - + case SIPO_MODE_DRIVERS: /* Driver F-Curve Editor */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ sipo->ads->source = (ID *)ac->scene; sipo->ads->filterflag |= ADS_FILTER_ONLYDRIVERS; - + ac->datatype = ANIMCONT_DRIVERS; ac->data = sipo->ads; - + ac->mode = sipo->mode; return true; - + default: /* unhandled yet */ ac->datatype = ANIMCONT_NONE; ac->data = NULL; - + ac->mode = -1; return false; } @@ -307,21 +307,21 @@ static bool nlaedit_get_context(bAnimContext *ac, SpaceNla *snla) if (snla->ads == NULL) snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); ac->ads = snla->ads; - + /* sync settings with current view status, then return appropriate data */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ snla->ads->source = (ID *)ac->scene; snla->ads->filterflag |= ADS_FILTER_ONLYNLA; - + ac->datatype = ANIMCONT_NLA; ac->data = snla->ads; - + return true; } /* ----------- Public API --------------- */ -/* Obtain current anim-data context, given that context info from Blender context has already been set +/* Obtain current anim-data context, given that context info from Blender context has already been set * - AnimContext to write to is provided as pointer to var on stack so that we don't have * allocation/freeing costs (which are not that avoidable with channels). */ @@ -329,7 +329,7 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac) { SpaceLink *sl = ac->sl; bool ok = false; - + /* context depends on editor we are currently in */ if (sl) { switch (ac->spacetype) { @@ -353,12 +353,12 @@ bool ANIM_animdata_context_getdata(bAnimContext *ac) } } } - + /* check if there's any valid data */ return (ok && ac->data); } -/* Obtain current anim-data context from Blender Context info +/* Obtain current anim-data context from Blender Context info * - AnimContext to write to is provided as pointer to var on stack so that we don't have * allocation/freeing costs (which are not that avoidable with channels). * - Clears data and sets the information from Blender Context which is useful @@ -369,11 +369,11 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) ARegion *ar = CTX_wm_region(C); SpaceLink *sl = CTX_wm_space_data(C); Scene *scene = CTX_data_scene(C); - + /* clear old context info */ if (ac == NULL) return false; memset(ac, 0, sizeof(bAnimContext)); - + /* get useful default context settings from context */ ac->scene = scene; if (scene) { @@ -385,10 +385,10 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) ac->sl = sl; ac->spacetype = (sa) ? sa->spacetype : 0; ac->regiontype = (ar) ? ar->regiontype : 0; - + /* initialise default y-scale factor */ animedit_get_yscale_factor(ac); - + /* get data context info */ // XXX: if the below fails, try to grab this info from context instead... (to allow for scripting) return ANIM_animdata_context_getdata(ac); @@ -446,7 +446,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) /* quick macro to test if AnimData is usable for NLA */ #define ANIMDATA_HAS_NLA(id) ((id)->adt && (id)->adt->nla_tracks.first) -/* Quick macro to test for all three above usability tests, performing the appropriate provided +/* Quick macro to test for all three above usability tests, performing the appropriate provided * action for each when the AnimData context is appropriate. * * Priority order for this goes (most important, to least): AnimData blocks, NLA, Drivers, Keyframes. @@ -510,7 +510,7 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) /* ............................... */ -/* Add a new animation channel, taking into account the "peek" flag, which is used to just check +/* Add a new animation channel, taking into account the "peek" flag, which is used to just check * whether any channels will be added (but without needing them to actually get created). * * ! This causes the calling function to return early if we're only "peeking" for channels @@ -527,12 +527,12 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) ale_statement \ } \ } (void)0 - + #define ANIMCHANNEL_NEW_CHANNEL(channel_data, channel_type, owner_id) \ ANIMCHANNEL_NEW_CHANNEL_FULL(channel_data, channel_type, owner_id, {}) - + /* ............................... */ - + /* quick macro to test if an anim-channel representing an AnimData block is suitably active */ #define ANIMCHANNEL_ACTIVEOK(ale) \ (!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE) ) @@ -542,8 +542,8 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) (!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \ ((filter_mode & ANIMFILTER_SEL) && test_func) || \ ((filter_mode & ANIMFILTER_UNSEL) && test_func == 0) ) - -/* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes + +/* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes * - _SELEDIT means that only selected curves will have visible+editable keyframes * * checks here work as follows: @@ -558,29 +558,29 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) /* ----------- 'Private' Stuff --------------- */ -/* this function allocates memory for a new bAnimListElem struct for the +/* this function allocates memory for a new bAnimListElem struct for the * provided animation channel-data. */ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owner_id) { bAnimListElem *ale = NULL; - + /* only allocate memory if there is data to convert */ if (data) { /* allocate and set generic data */ ale = MEM_callocN(sizeof(bAnimListElem), "bAnimListElem"); - + ale->data = data; ale->type = datatype; - + ale->id = owner_id; ale->adt = BKE_animdata_from_id(owner_id); - + /* do specifics */ switch (datatype) { case ANIMTYPE_SUMMARY: { - /* nothing to include for now... this is just a dummy wrappy around all the other channels + /* nothing to include for now... this is just a dummy wrappy around all the other channels * in the DopeSheet, and gets included at the start of the list */ ale->key_data = NULL; @@ -590,12 +590,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_SCENE: { Scene *sce = (Scene *)data; - + ale->flag = sce->flag; - + ale->key_data = sce; ale->datatype = ALE_SCE; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -603,21 +603,21 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Base *base = (Base *)data; Object *ob = base->object; - + ale->flag = ob->flag; - + ale->key_data = ob; ale->datatype = ALE_OB; - + ale->adt = BKE_animdata_from_id(&ob->id); break; } case ANIMTYPE_FILLACTD: { bAction *act = (bAction *)data; - + ale->flag = act->flag; - + ale->key_data = act; ale->datatype = ALE_ACT; break; @@ -625,9 +625,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_FILLDRIVERS: { AnimData *adt = (AnimData *)data; - + ale->flag = adt->flag; - + // XXX... drivers don't show summary for now ale->key_data = NULL; ale->datatype = ALE_NONE; @@ -637,12 +637,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Material *ma = (Material *)data; AnimData *adt = ma->adt; - + ale->flag = FILTER_MAT_OBJD(ma); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -650,12 +650,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Lamp *la = (Lamp *)data; AnimData *adt = la->adt; - + ale->flag = FILTER_LAM_OBJD(la); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -663,12 +663,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Camera *ca = (Camera *)data; AnimData *adt = ca->adt; - + ale->flag = FILTER_CAM_OBJD(ca); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -689,12 +689,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Curve *cu = (Curve *)data; AnimData *adt = cu->adt; - + ale->flag = FILTER_CUR_OBJD(cu); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -702,12 +702,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { bArmature *arm = (bArmature *)data; AnimData *adt = arm->adt; - + ale->flag = FILTER_ARM_OBJD(arm); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -715,12 +715,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Mesh *me = (Mesh *)data; AnimData *adt = me->adt; - + ale->flag = FILTER_MESH_OBJD(me); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -728,12 +728,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Lattice *lt = (Lattice *)data; AnimData *adt = lt->adt; - + ale->flag = FILTER_LATTICE_OBJD(lt); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -741,12 +741,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Speaker *spk = (Speaker *)data; AnimData *adt = spk->adt; - + ale->flag = FILTER_SPK_OBJD(spk); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -754,12 +754,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Key *key = (Key *)data; AnimData *adt = key->adt; - + ale->flag = FILTER_SKE_OBJD(key); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -767,12 +767,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { World *wo = (World *)data; AnimData *adt = wo->adt; - + ale->flag = FILTER_WOR_SCED(wo); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -780,12 +780,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { bNodeTree *ntree = (bNodeTree *)data; AnimData *adt = ntree->adt; - + ale->flag = FILTER_NTREE_DATA(ntree); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -793,12 +793,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { FreestyleLineStyle *linestyle = (FreestyleLineStyle *)data; AnimData *adt = linestyle->adt; - - ale->flag = FILTER_LS_SCED(linestyle); - + + ale->flag = FILTER_LS_SCED(linestyle); + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -806,12 +806,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { ParticleSettings *part = (ParticleSettings *)ale->data; AnimData *adt = part->adt; - + ale->flag = FILTER_PART_OBJD(part); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -819,12 +819,12 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { Tex *tex = (Tex *)data; AnimData *adt = tex->adt; - + ale->flag = FILTER_TEX_DATA(tex); - + ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -832,14 +832,14 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { bGPdata *gpd = (bGPdata *)data; AnimData *adt = gpd->adt; - + /* NOTE: we just reuse the same expand filter for this case */ ale->flag = EXPANDED_GPD(gpd); - + // XXX: currently, this is only used for access to its animation data ale->key_data = (adt) ? adt->action : NULL; ale->datatype = ALE_ACT; - + ale->adt = BKE_animdata_from_id(data); break; } @@ -859,9 +859,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_NLACONTROLS: { AnimData *adt = (AnimData *)data; - + ale->flag = adt->flag; - + ale->key_data = NULL; ale->datatype = ALE_NONE; break; @@ -869,9 +869,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_GROUP: { bActionGroup *agrp = (bActionGroup *)data; - + ale->flag = agrp->flag; - + ale->key_data = NULL; ale->datatype = ALE_GROUP; break; @@ -880,9 +880,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_NLACURVE: /* practically the same as ANIMTYPE_FCURVE. Differences are applied post-creation */ { FCurve *fcu = (FCurve *)data; - + ale->flag = fcu->flag; - + ale->key_data = fcu; ale->datatype = ALE_FCURVE; break; @@ -891,19 +891,19 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne { KeyBlock *kb = (KeyBlock *)data; Key *key = (Key *)ale->id; - + ale->flag = kb->flag; - + /* whether we have keyframes depends on whether there is a Key block to find it from */ if (key) { /* index of shapekey is defined by place in key's list */ ale->index = BLI_findindex(&key->block, kb); - + /* the corresponding keyframes are from the animdata */ if (ale->adt && ale->adt->action) { bAction *act = ale->adt->action; char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); - + /* try to find the F-Curve which corresponds to this exactly, * then free the MEM_alloc'd string */ @@ -919,9 +919,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_GPLAYER: { bGPDlayer *gpl = (bGPDlayer *)data; - + ale->flag = gpl->flag; - + ale->key_data = NULL; ale->datatype = ALE_GPFRAME; break; @@ -929,9 +929,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_MASKLAYER: { MaskLayer *masklay = (MaskLayer *)data; - + ale->flag = masklay->flag; - + ale->key_data = NULL; ale->datatype = ALE_MASKLAY; break; @@ -939,9 +939,9 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne case ANIMTYPE_NLATRACK: { NlaTrack *nlt = (NlaTrack *)data; - + ale->flag = nlt->flag; - + ale->key_data = &nlt->strips; ale->datatype = ALE_NLASTRIP; break; @@ -955,11 +955,11 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne } } } - + /* return created datatype */ return ale; } - + /* ----------------------------------------- */ /* 'Only Selected' selected data and/or 'Include Hidden' filtering @@ -972,26 +972,26 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id } /* hidden items should be skipped if we only care about visible data, but we aren't interested in hidden stuff */ const bool skip_hidden = (filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN); - + if (GS(owner_id->name) == ID_OB) { Object *ob = (Object *)owner_id; - + /* only consider if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { bPoseChannel *pchan; char *bone_name; - + /* get bone-name, and check if this bone is selected */ bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); - + /* check whether to continue or skip */ if ((pchan) && (pchan->bone)) { /* if only visible channels, skip if bone not visible unless user wants channels from hidden data too */ if (skip_hidden) { bArmature *arm = (bArmature *)ob->data; - + /* skipping - not visible on currently visible layers */ if ((arm->layer & pchan->bone->layer) == 0) return true; @@ -999,7 +999,7 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id if (pchan->bone->flag & BONE_HIDDEN_P) return true; } - + /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { if ((pchan->bone->flag & BONE_SELECTED) == 0) @@ -1010,20 +1010,20 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id } else if (GS(owner_id->name) == ID_SCE) { Scene *scene = (Scene *)owner_id; - + /* only consider if F-Curve involves sequence_editor.sequences */ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq = NULL; char *seq_name; - + if (ed) { /* get strip name, and check if this strip is selected */ seq_name = BLI_str_quoted_substrN(fcu->rna_path, "sequences_all["); seq = BKE_sequence_get_by_name(ed->seqbasep, seq_name, false); if (seq_name) MEM_freeN(seq_name); } - + /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { if ((seq == NULL) || (seq->flag & SELECT) == 0) @@ -1033,17 +1033,17 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id } else if (GS(owner_id->name) == ID_NT) { bNodeTree *ntree = (bNodeTree *)owner_id; - + /* check for selected nodes */ if ((fcu->rna_path) && strstr(fcu->rna_path, "nodes")) { bNode *node; char *node_name; - + /* get strip name, and check if this strip is selected */ node_name = BLI_str_quoted_substrN(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); - + /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { if ((node) && (node->flag & NODE_SELECT) == 0) @@ -1051,7 +1051,7 @@ static bool skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id } } } - + return false; } @@ -1062,11 +1062,11 @@ static bool name_matches_dopesheet_filter(bDopeSheet *ads, char *name) /* full fuzzy, multi-word, case insensitive matches */ const size_t str_len = strlen(ads->searchstr); const int words_max = (str_len / 2) + 1; - + int (*words)[2] = BLI_array_alloca(words, words_max); const int words_len = BLI_string_find_split_words(ads->searchstr, str_len, ' ', words, words_max); bool found = false; - + /* match name against all search words */ for (int index = 0; index < words_len; index++) { if (BLI_strncasestr(name, ads->searchstr + words[index][0], words[index][1])) { @@ -1074,7 +1074,7 @@ static bool name_matches_dopesheet_filter(bDopeSheet *ads, char *name) break; } } - + /* if we have a match somewhere, this returns true */ return found; } @@ -1091,27 +1091,27 @@ static bool skip_fcurve_with_name(bDopeSheet *ads, FCurve *fcu, eAnim_ChannelTyp { bAnimListElem ale_dummy = {NULL}; const bAnimChannelType *acf; - + /* create a dummy wrapper for the F-Curve, so we can get typeinfo for it */ ale_dummy.type = channel_type; ale_dummy.owner = owner; ale_dummy.id = owner_id; ale_dummy.data = fcu; - + /* get type info for channel */ acf = ANIM_channel_get_typeinfo(&ale_dummy); if (acf && acf->name) { char name[256]; /* hopefully this will be enough! */ - + /* get name */ acf->name(&ale_dummy, name); - - /* check for partial match with the match string, assuming case insensitive filtering + + /* check for partial match with the match string, assuming case insensitive filtering * if match, this channel shouldn't be ignored! */ return !name_matches_dopesheet_filter(ads, name); } - + /* just let this go... */ return true; } @@ -1127,19 +1127,19 @@ static bool fcurve_has_errors(FCurve *fcu) if (fcu->flag & FCURVE_DISABLED) { return true; } - + /* driver? */ if (fcu->driver) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + /* error flag on driver usually means that there is an error * BUT this may not hold with PyDrivers as this flag gets cleared * if no critical errors prevent the driver from working... */ if (driver->flag & DRIVER_FLAG_INVALID) return true; - + /* check variables for other things that need linting... */ // TODO: maybe it would be more efficient just to have a quick flag for this? for (dvar = driver->variables.first; dvar; dvar = dvar->next) { @@ -1151,7 +1151,7 @@ static bool fcurve_has_errors(FCurve *fcu) DRIVER_TARGETS_LOOPER_END } } - + /* no errors found */ return false; } @@ -1161,8 +1161,8 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan { bActionGroup *grp = (channel_type == ANIMTYPE_FCURVE) ? owner : NULL; FCurve *fcu = NULL; - - /* loop over F-Curves - assume that the caller of this has already checked that these should be included + + /* loop over F-Curves - assume that the caller of this has already checked that these should be included * NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too... */ for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) { @@ -1182,7 +1182,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan } } } - + /* only include if visible (Graph Editor check, not channels check) */ if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || (fcu->flag & FCURVE_VISIBLE)) { /* only work with this channel and its subchannels if it is editable */ @@ -1196,14 +1196,14 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan if (skip_fcurve_with_name(ads, fcu, channel_type, owner, owner_id)) continue; } - + /* error-based filtering... */ if ((ads) && (ads->filterflag & ADS_FILTER_ONLY_ERRORS)) { /* skip if no errors... */ if (fcurve_has_errors(fcu) == false) continue; } - + /* this F-Curve can be used, so return it */ return fcu; } @@ -1211,7 +1211,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, eAnim_Chan } } } - + /* no (more) F-Curves from the list are suitable... */ return NULL; } @@ -1223,14 +1223,14 @@ static size_t animfilter_fcurves(ListBase *anim_data, bDopeSheet *ads, { FCurve *fcu; size_t items = 0; - - /* loop over every F-Curve able to be included - * - this for-loop works like this: + + /* loop over every F-Curve able to be included + * - this for-loop works like this: * 1) the starting F-Curve is assigned to the fcu pointer so that we have a starting point to search from - * 2) the first valid F-Curve to start from (which may include the one given as 'first') in the remaining + * 2) the first valid F-Curve to start from (which may include the one given as 'first') in the remaining * list of F-Curves is found, and verified to be non-null * 3) the F-Curve referenced by fcu pointer is added to the list - * 4) the fcu pointer is set to the F-Curve after the one we just added, so that we can keep going through + * 4) the fcu pointer is set to the F-Curve after the one we just added, so that we can keep going through * the rest of the F-Curve list without an eternal loop. Back to step 2 :) */ for (fcu = first; ( (fcu = animfilter_fcurve_next(ads, fcu, fcurve_type, filter_mode, owner, owner_id)) ); fcu = fcu->next) { @@ -1246,7 +1246,7 @@ static size_t animfilter_fcurves(ListBase *anim_data, bDopeSheet *ads, ANIMCHANNEL_NEW_CHANNEL(fcu, ANIMTYPE_FCURVE, owner_id); } } - + /* return the number of items added to the list */ return items; } @@ -1257,8 +1257,8 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS size_t tmp_items = 0; size_t items = 0; //int ofilter = filter_mode; - - /* if we care about the selection status of the channels, + + /* if we care about the selection status of the channels, * but the group isn't expanded (1)... * (1) this only matters if we actually care about the hierarchy though. * - Hierarchy matters: this hack should be applied @@ -1270,7 +1270,7 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS /* if the group itself isn't selected appropriately, we shouldn't consider it's children either */ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) return 0; - + /* if we're still here, then the selection status of the curves within this group should not matter, * since this creates too much overhead for animators (i.e. making a slow workflow) * @@ -1281,14 +1281,14 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS */ filter_mode &= ~(ANIMFILTER_SEL | ANIMFILTER_UNSEL | ANIMFILTER_LIST_VISIBLE); } - + /* add grouped F-Curves */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_AGRP(ac, agrp)) { /* special filter so that we can get just the F-Curves within the active group */ if (!(filter_mode & ANIMFILTER_ACTGROUPED) || (agrp->flag & AGRP_ACTIVE)) { /* for the Graph Editor, curves may be set to not be visible in the view to lessen clutter, - * but to do this, we need to check that the group doesn't have it's not-visible flag set preventing + * but to do this, we need to check that the group doesn't have it's not-visible flag set preventing * all its sub-curves to be shown */ if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !(agrp->flag & AGRP_NOTVISIBLE)) { @@ -1296,7 +1296,7 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_AGRP(agrp)) { /* get first F-Curve which can be used here */ FCurve *first_fcu = animfilter_fcurve_next(ads, agrp->channels.first, ANIMTYPE_FCURVE, filter_mode, agrp, owner_id); - + /* filter list, starting from this F-Curve */ tmp_items += animfilter_fcurves(&tmp_data, ads, first_fcu, ANIMTYPE_FCURVE, filter_mode, agrp, owner_id); } @@ -1304,26 +1304,26 @@ static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeS } } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* add this group as a channel first */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { /* restore original filter mode so that this next step works ok... */ //filter_mode = ofilter; - + /* filter selection of channel specially here again, since may be open and not subject to previous test */ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) { ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -1333,30 +1333,30 @@ static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeShee bActionGroup *agrp; FCurve *lastchan = NULL; size_t items = 0; - + /* don't include anything from this action if it is linked in from another file, * and we're getting stuff for editing... */ if ((filter_mode & ANIMFILTER_FOREDIT) && ID_IS_LINKED(act)) return 0; - + /* do groups */ // TODO: do nested groups? for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* store reference to last channel of group */ - if (agrp->channels.last) + if (agrp->channels.last) lastchan = agrp->channels.last; - + /* action group's channels */ items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id); } - + /* un-grouped F-Curves (only if we're not only considering those channels in the active group) */ if (!(filter_mode & ANIMFILTER_ACTGROUPED)) { FCurve *firstfcu = (lastchan) ? (lastchan->next) : (act->curves.first); items += animfilter_fcurves(anim_data, ads, firstfcu, ANIMTYPE_FCURVE, filter_mode, NULL, owner_id); } - + /* return the number of items added to the list */ return items; } @@ -1374,10 +1374,10 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop NlaTrack *nlt; NlaTrack *first = NULL, *next = NULL; size_t items = 0; - + /* if showing channels, include active action */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { - /* if NLA action-line filtering is off, don't show unless there are keyframes, + /* if NLA action-line filtering is off, don't show unless there are keyframes, * in order to keep things more compact for doing transforms */ if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) || (adt->action)) { @@ -1387,13 +1387,13 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop * - as AnimData may not have an action, we pass a dummy pointer just to get the list elem created, then * overwrite this with the real value - REVIEW THIS... */ - ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, + ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, { - ale->data = adt->action ? adt->action : NULL; + ale->data = adt->action ? adt->action : NULL; }); } } - + /* first track to include will be the last one if we're filtering by channels */ first = adt->nla_tracks.last; } @@ -1401,22 +1401,22 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop /* first track to include will the first one (as per normal) */ first = adt->nla_tracks.first; } - + /* loop over NLA Tracks - assume that the caller of this has already checked that these should be included */ for (nlt = first; nlt; nlt = next) { /* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */ - if (filter_mode & ANIMFILTER_LIST_CHANNELS) + if (filter_mode & ANIMFILTER_LIST_CHANNELS) next = nlt->prev; else next = nlt->next; - - /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now + + /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now * - active track should still get shown though (even though it has disabled flag set) */ // FIXME: the channels after should still get drawn, just 'differently', and after an active-action channel if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED) && (adt->act_track != nlt)) continue; - + /* only work with this channel and its subchannels if it is editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_NLT(nlt)) { /* only include this track if selected in a way consistent with the filtering requirements */ @@ -1426,10 +1426,10 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop /* name based filtering... */ if (((ads) && (ads->filterflag & ADS_FILTER_BY_FCU_NAME)) && (owner_id)) { bool track_ok = false, strip_ok = false; - + /* check if the name of the track, or the strips it has are ok... */ track_ok = name_matches_dopesheet_filter(ads, nlt->name); - + if (track_ok == false) { NlaStrip *strip; for (strip = nlt->strips.first; strip; strip = strip->next) { @@ -1439,20 +1439,20 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop } } } - + /* skip if both fail this test... */ if (!track_ok && !strip_ok) { continue; } } - + /* add the track now that it has passed all our tests */ ANIMCHANNEL_NEW_CHANNEL(nlt, ANIMTYPE_NLATRACK, owner_id); } } } } - + /* return the number of items added to the list */ return items; } @@ -1465,14 +1465,14 @@ static size_t animfilter_nla_controls(ListBase *anim_data, bDopeSheet *ads, Anim ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* add control curves from each NLA strip... */ /* NOTE: ANIMTYPE_FCURVES are created here, to avoid duplicating the code needed */ BEGIN_ANIMFILTER_SUBCHANNELS(((adt->flag & ADT_NLA_SKEYS_COLLAPSED) == 0)) { NlaTrack *nlt; NlaStrip *strip; - + /* for now, we only go one level deep - so controls on grouped FCurves are not handled */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { for (strip = nlt->strips.first; strip; strip = strip->next) { @@ -1482,7 +1482,7 @@ static size_t animfilter_nla_controls(ListBase *anim_data, bDopeSheet *ads, Anim } } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* add the expander as a channel first */ @@ -1492,13 +1492,13 @@ static size_t animfilter_nla_controls(ListBase *anim_data, bDopeSheet *ads, Anim ANIMCHANNEL_NEW_CHANNEL(adt, ANIMTYPE_NLACONTROLS, owner_id); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the numebr of items added to the list */ return items; } @@ -1508,11 +1508,11 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope { AnimData *adt = BKE_animdata_from_id(id); size_t items = 0; - + /* image object datablocks have no anim-data so check for NULL */ if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - + /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed * in a few places in the rest of the code still - notably for the few cases where special mode-based * different types of data expanders are required. @@ -1538,7 +1538,7 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope } ); } - + return items; } @@ -1548,22 +1548,22 @@ static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDope static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Key *key, int filter_mode) { size_t items = 0; - + /* check if channels or only F-Curves */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) { KeyBlock *kb; - + /* loop through the channels adding ShapeKeys as appropriate */ for (kb = key->block.first; kb; kb = kb->next) { /* skip the first one, since that's the non-animatable basis */ if (kb == key->block.first) continue; - + /* only work with this channel and its subchannels if it is editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(kb)) { /* only include this track if selected in a way consistent with the filtering requirements */ if (ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb)) ) { // TODO: consider 'active' too? - + /* owner-id here must be key so that the F-Curve can be resolved... */ ANIMCHANNEL_NEW_CHANNEL(kb, ANIMTYPE_SHAPEKEY, key); } @@ -1584,7 +1584,7 @@ static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Ke } } } - + /* return the number of items added to the list */ return items; } @@ -1594,7 +1594,7 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee { bGPDlayer *gpl; size_t items = 0; - + /* loop over layers as the conditions are acceptable */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only if selected */ @@ -1608,15 +1608,15 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee if (name_matches_dopesheet_filter(ads, gpl->info) == false) continue; } - - + + /* add to list */ ANIMCHANNEL_NEW_CHANNEL(gpl, ANIMTYPE_GPLAYER, gpd); } } } } - + return items; } @@ -1624,7 +1624,7 @@ static size_t animdata_filter_gpencil_layers_data(ListBase *anim_data, bDopeShee static size_t animdata_filter_gpencil_data(ListBase *anim_data, bDopeSheet *ads, bGPdata *gpd, int filter_mode) { size_t items = 0; - + /* When asked from "AnimData" blocks (i.e. the top-level containers for normal animation), * for convenience, this will return GP Datablocks instead. This may cause issues down * the track, but for now, this will do... @@ -1636,14 +1636,14 @@ static size_t animdata_filter_gpencil_data(ListBase *anim_data, bDopeSheet *ads, else { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; - + /* add gpencil animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd)) { tmp_items += animdata_filter_gpencil_layers_data(&tmp_data, ads, gpd, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include data-expand widget first */ @@ -1651,14 +1651,14 @@ static size_t animdata_filter_gpencil_data(ListBase *anim_data, bDopeSheet *ads, /* add gpd as channel too (if for drawing, and it has layers) */ ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_GPDATABLOCK, NULL); } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } } - + return items; } @@ -1668,46 +1668,46 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi { bDopeSheet *ads = ac->ads; size_t items = 0; - + if (ads->filterflag & ADS_FILTER_GP_3DONLY) { Scene *scene = (Scene *)ads->source; Base *base; - + /* Active scene's GPencil block first - No parent item needed... */ if (scene->gpd) { items += animdata_filter_gpencil_data(anim_data, ads, scene->gpd, filter_mode); } - + /* Objects in the scene */ for (base = scene->base.first; base; base = base->next) { /* Only consider this object if it has got some GP data (saving on all the other tests) */ if (base->object && base->object->gpd) { Object *ob = base->object; - + /* firstly, check if object can be included, by the following factors: * - if only visible, must check for layer and also viewport visibility * --> while tools may demand only visible, user setting takes priority * as user option controls whether sets of channels get included while * tool-flag takes into account collapsed/open channels too - * - if only selected, must check if object is selected - * - there must be animation data to edit (this is done recursively as we + * - if only selected, must check if object is selected + * - there must be animation data to edit (this is done recursively as we * try to add the channels) */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ if ((scene->lay & (ob->lay | base->lay)) == 0) continue; - + /* outliner restrict-flag */ if (ob->restrictflag & OB_RESTRICT_VIEW) continue; } - + /* check selection and object type filters */ if ( (ads->filterflag & ADS_FILTER_ONLYSEL) && !((base->flag & SELECT) /*|| (base == scene->basact)*/) ) { /* only selected should be shown */ continue; } - - /* check if object belongs to the filtering group if option to filter + + /* check if object belongs to the filtering group if option to filter * objects by the grouped status is on * - used to ease the process of doing multiple-character choreographies */ @@ -1715,7 +1715,7 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi if (BKE_group_object_exists(ads->filter_grp, ob) == 0) continue; } - + /* finally, include this object's grease pencil datablock */ /* XXX: Should we store these under expanders per item? */ items += animdata_filter_gpencil_data(anim_data, ads, ob->gpd, filter_mode); @@ -1724,18 +1724,18 @@ static size_t animdata_filter_gpencil(bAnimContext *ac, ListBase *anim_data, voi } else { bGPdata *gpd; - + /* Grab all Grease Pencil datablocks directly from main, but only those that seem to be useful somewhere */ for (gpd = G.main->gpencil.first; gpd; gpd = gpd->id.next) { /* only show if gpd is used by something... */ if (ID_REAL_USERS(gpd) < 1) continue; - + /* add GP frames from this datablock */ items += animdata_filter_gpencil_data(anim_data, ads, gpd, filter_mode); } } - + /* return the number of items added to the list */ return items; } @@ -1746,19 +1746,19 @@ static size_t animdata_filter_ds_gpencil(bAnimContext *ac, ListBase *anim_data, ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* add relevant animation channels for Grease Pencil */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_GPD(gpd)) { /* add animation channels */ tmp_items += animfilter_block_data(ac, &tmp_data, ads, &gpd->id, filter_mode); - + /* add Grease Pencil layers */ // TODO: do these need a separate expander? // XXX: what order should these go in? } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include data-expand widget first */ @@ -1769,13 +1769,13 @@ static size_t animdata_filter_ds_gpencil(bAnimContext *ac, ListBase *anim_data, ANIMCHANNEL_NEW_CHANNEL(gpd, ANIMTYPE_DSGPENCIL, gpd); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -1846,24 +1846,24 @@ static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int { Mask *mask; size_t items = 0; - + /* for now, grab mask datablocks directly from main */ // XXX: this is not good... for (mask = G.main->mask.first; mask; mask = mask->id.next) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; - + /* only show if mask is used by something... */ if (ID_REAL_USERS(mask) < 1) continue; - + /* add mask animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_MASK(mask)) { tmp_items += animdata_filter_mask_data(&tmp_data, mask, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include data-expand widget first */ @@ -1871,14 +1871,14 @@ static size_t animdata_filter_mask(ListBase *anim_data, void *UNUSED(data), int /* add gpd as channel too (if for drawing, and it has layers) */ ANIMCHANNEL_NEW_CHANNEL(mask, ANIMTYPE_MASKDATABLOCK, NULL); } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } } - + /* return the number of items added to the list */ return items; } @@ -1889,7 +1889,7 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* add nodetree animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_NTREE_DATA(ntree)) { @@ -1897,7 +1897,7 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ntree, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include data-expand widget first */ @@ -1907,13 +1907,13 @@ static size_t animdata_filter_ds_nodetree_group(bAnimContext *ac, ListBase *anim ANIMCHANNEL_NEW_CHANNEL(ntree, ANIMTYPE_DSNTREE, owner_id); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -1922,9 +1922,9 @@ static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, { bNode *node; size_t items = 0; - + items += animdata_filter_ds_nodetree_group(ac, anim_data, ads, owner_id, ntree, filter_mode); - + for (node = ntree->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP) { if (node->id) { @@ -1945,7 +1945,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data SceneRenderLayer *srl; FreestyleLineSet *lineset; size_t items = 0; - + for (srl = sce->r.layers.first; srl; srl = srl->next) { for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) { if (lineset->linestyle) { @@ -1953,12 +1953,12 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data } } } - + for (srl = sce->r.layers.first; srl; srl = srl->next) { /* skip render layers without Freestyle enabled */ if (!(srl->layflag & SCE_LAY_FRS)) continue; - + /* loop over linesets defined in the render layer */ for (lineset = srl->freestyleConfig.linesets.first; lineset; lineset = lineset->next) { FreestyleLineStyle *linestyle = lineset->linestyle; @@ -1971,7 +1971,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data continue; } linestyle->id.tag &= ~LIB_TAG_DOIT; - + /* add scene-level animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_LS_SCED(linestyle)) { @@ -1979,7 +1979,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)linestyle, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include anim-expand widget first */ @@ -1989,7 +1989,7 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data ANIMCHANNEL_NEW_CHANNEL(linestyle, ANIMTYPE_DSLINESTYLE, sce); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); @@ -1997,24 +1997,24 @@ static size_t animdata_filter_ds_linestyle(bAnimContext *ac, ListBase *anim_data } } } - + /* return the number of items added to the list */ return items; } -static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, +static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Tex *tex, ID *owner_id, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* add texture's animation data to temp collection */ - BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_TEX_DATA(tex)) + BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_TEX_DATA(tex)) { /* texture animdata */ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)tex, filter_mode); - + /* nodes */ if ((tex->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) { /* owner_id as id instead of texture, since it'll otherwise be impossible to track the depth */ @@ -2024,7 +2024,7 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data, } } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include texture-expand widget? */ @@ -2034,13 +2034,13 @@ static size_t animdata_filter_ds_texture(bAnimContext *ac, ListBase *anim_data, ANIMCHANNEL_NEW_CHANNEL(tex, ANIMTYPE_DSTEX, owner_id); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -2051,11 +2051,11 @@ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data, MTex **mtex = NULL; size_t items = 0; int a = 0; - + /* get datatype specific data first */ if (owner_id == NULL) return 0; - + switch (GS(owner_id->name)) { case ID_MA: { @@ -2081,7 +2081,7 @@ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data, mtex = (MTex **)(&part->mtex); break; } - default: + default: { /* invalid/unsupported option */ if (G.debug & G_DEBUG) @@ -2089,19 +2089,19 @@ static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data, return 0; } } - + /* firstly check that we actuallly have some textures, by gathering all textures in a temp list */ for (a = 0; a < MAX_MTEX; a++) { Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL; - + /* for now, if no texture returned, skip (this shouldn't confuse the user I hope) */ - if (tex == NULL) + if (tex == NULL) continue; - + /* add texture's anim channels */ items += animdata_filter_ds_texture(ac, anim_data, ads, tex, owner_id, filter_mode); } - + /* return the number of items added to the list */ return items; } @@ -2112,23 +2112,23 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data, ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* add material's animation data to temp collection */ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma)) { /* material's animation data */ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); - + /* textures */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); - + /* nodes */ - if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) + if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include material-expand widget first */ @@ -2138,13 +2138,13 @@ static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data, ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + return items; } @@ -2153,23 +2153,23 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data bool has_nested = false; size_t items = 0; int a = 0; - + /* first pass: take the materials referenced via the Material slots of the object */ for (a = 1; a <= ob->totcol; a++) { Material *ma = give_current_material(ob, a); - + /* if material is valid, try to add relevant contents from here */ if (ma) { /* add channels */ items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); - + /* for optimising second pass - check if there's a nested material here to come back for */ if (has_nested == false) { has_nested = (give_node_material(ma) != NULL); } } } - + /* second pass: go through a second time looking for "nested" materials (material.material references) * * NOTE: here we ignore the expanded status of the parent, as it could be too confusing as to why these are @@ -2179,7 +2179,7 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data for (a = 1; a <= ob->totcol; a++) { Material *base = give_current_material(ob, a); Material *ma = give_node_material(base); - + /* add channels from the nested material if it exists * - skip if the same material is referenced in its node tree * (which is common for BI materials) as that results in @@ -2190,7 +2190,7 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data } } } - + /* return the number of items added to the list */ return items; } @@ -2202,10 +2202,10 @@ static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data typedef struct tAnimFilterModifiersContext { bAnimContext *ac; /* anim editor context */ bDopeSheet *ads; /* dopesheet filtering settings */ - + ListBase tmp_data; /* list of channels created (but not yet added to the main list) */ size_t items; /* number of channels created */ - + int filter_mode; /* flags for stuff we want to filter */ } tAnimFilterModifiersContext; @@ -2216,31 +2216,31 @@ static void animfilter_modifier_idpoin_cb(void *afm_ptr, Object *ob, ID **idpoin tAnimFilterModifiersContext *afm = (tAnimFilterModifiersContext *)afm_ptr; ID *owner_id = &ob->id; ID *id = *idpoin; - - /* NOTE: the walker only guarantees to give us all the ID-ptr *slots*, + + /* NOTE: the walker only guarantees to give us all the ID-ptr *slots*, * not just the ones which are actually used, so be careful! */ if (id == NULL) return; - + /* check if this is something we're interested in... */ switch (GS(id->name)) { case ID_TE: /* Textures */ { Tex *tex = (Tex *)id; - if (!(afm->ads->filterflag & ADS_FILTER_NOTEX)) { + if (!(afm->ads->filterflag & ADS_FILTER_NOTEX)) { afm->items += animdata_filter_ds_texture(afm->ac, &afm->tmp_data, afm->ads, tex, owner_id, afm->filter_mode); } break; } - + /* TODO: images? */ default: break; } } -/* animation linked to data used by modifiers +/* animation linked to data used by modifiers * NOTE: strictly speaking, modifier animation is already included under Object level * but for some modifiers (e.g. Displace), there can be linked data that has settings * which would be nice to animate (i.e. texture parameters) but which are not actually @@ -2251,8 +2251,8 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data { tAnimFilterModifiersContext afm = {NULL}; size_t items = 0; - - /* 1) create a temporary "context" containing all the info we have here to pass to the callback + + /* 1) create a temporary "context" containing all the info we have here to pass to the callback * use to walk through the dependencies of the modifiers * * ! Assumes that all other unspecified values (i.e. accumulation buffers) are zero'd out properly @@ -2260,10 +2260,10 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data afm.ac = ac; afm.ads = ads; afm.filter_mode = filter_mode; - + /* 2) walk over dependencies */ modifiers_foreachIDLink(ob, animfilter_modifier_idpoin_cb, &afm); - + /* 3) extract data from the context, merging it back into the standard list */ if (afm.items) { /* now add the list of collected channels */ @@ -2271,7 +2271,7 @@ static size_t animdata_filter_ds_modifiers(bAnimContext *ac, ListBase *anim_data BLI_assert(BLI_listbase_is_empty(&afm.tmp_data)); items += afm.items; } - + return items; } @@ -2286,23 +2286,23 @@ static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data for (psys = ob->particlesystem.first; psys; psys = psys->next) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; - + /* if no material returned, skip - so that we don't get weird blank entries... */ if (ELEM(NULL, psys->part, psys->part->adt)) continue; - + /* add particle-system's animation data to temp collection */ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_PART_OBJD(psys->part)) { /* particle system's animation data */ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)psys->part, filter_mode); - + /* textures */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)psys->part, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include particle-expand widget first */ @@ -2312,14 +2312,14 @@ static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data ANIMCHANNEL_NEW_CHANNEL(psys->part, ANIMTYPE_DSPART, psys->part); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } } - + /* return the number of items added to the list */ return items; } @@ -2330,19 +2330,19 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + IdAdtTemplate *iat = ob->data; short type = 0, expanded = 0; - + /* get settings based on data type */ switch (ob->type) { case OB_CAMERA: /* ------- Camera ------------ */ { Camera *ca = (Camera *)ob->data; - + if (ads->filterflag & ADS_FILTER_NOCAM) return 0; - + type = ANIMTYPE_DSCAM; expanded = FILTER_CAM_OBJD(ca); break; @@ -2350,10 +2350,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b case OB_LAMP: /* ---------- Lamp ----------- */ { Lamp *la = (Lamp *)ob->data; - + if (ads->filterflag & ADS_FILTER_NOLAM) return 0; - + type = ANIMTYPE_DSLAM; expanded = FILTER_LAM_OBJD(la); break; @@ -2363,10 +2363,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b case OB_FONT: /* ------- Text Curve ---------- */ { Curve *cu = (Curve *)ob->data; - + if (ads->filterflag & ADS_FILTER_NOCUR) return 0; - + type = ANIMTYPE_DSCUR; expanded = FILTER_CUR_OBJD(cu); break; @@ -2374,10 +2374,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b case OB_MBALL: /* ------- MetaBall ---------- */ { MetaBall *mb = (MetaBall *)ob->data; - + if (ads->filterflag & ADS_FILTER_NOMBA) return 0; - + type = ANIMTYPE_DSMBALL; expanded = FILTER_MBALL_OBJD(mb); break; @@ -2385,10 +2385,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b case OB_ARMATURE: /* ------- Armature ---------- */ { bArmature *arm = (bArmature *)ob->data; - + if (ads->filterflag & ADS_FILTER_NOARM) return 0; - + type = ANIMTYPE_DSARM; expanded = FILTER_ARM_OBJD(arm); break; @@ -2396,10 +2396,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b case OB_MESH: /* ------- Mesh ---------- */ { Mesh *me = (Mesh *)ob->data; - + if (ads->filterflag & ADS_FILTER_NOMESH) return 0; - + type = ANIMTYPE_DSMESH; expanded = FILTER_MESH_OBJD(me); break; @@ -2407,10 +2407,10 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b case OB_LATTICE: /* ---- Lattice ---- */ { Lattice *lt = (Lattice *)ob->data; - + if (ads->filterflag & ADS_FILTER_NOLAT) return 0; - + type = ANIMTYPE_DSLAT; expanded = FILTER_LATTICE_OBJD(lt); break; @@ -2418,30 +2418,30 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b case OB_SPEAKER: /* ---------- Speaker ----------- */ { Speaker *spk = (Speaker *)ob->data; - + type = ANIMTYPE_DSSPK; expanded = FILTER_SPK_OBJD(spk); break; } } - + /* add object data animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(expanded) { /* animation data filtering */ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)iat, filter_mode); - + /* sub-data filtering... */ switch (ob->type) { case OB_LAMP: /* lamp - textures + nodetree */ { Lamp *la = ob->data; bNodeTree *ntree = la->nodetree; - + /* nodetree */ if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, &la->id, ntree, filter_mode); - + /* textures */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, &la->id, filter_mode); @@ -2450,7 +2450,7 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b } } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include data-expand widget first */ @@ -2460,13 +2460,13 @@ static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, b ANIMCHANNEL_NEW_CHANNEL(iat, type, iat); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -2477,7 +2477,7 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data, ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* add shapekey-level animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_SKE_OBJD(key)) { @@ -2485,7 +2485,7 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data, tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)key, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include key-expand widget first */ @@ -2494,13 +2494,13 @@ static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data, ANIMCHANNEL_NEW_CHANNEL(key, ANIMTYPE_DSSKEY, ob); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -2512,7 +2512,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + AnimData *adt = ob->adt; short type = 0, expanded = 1; void *cdata = NULL; @@ -2533,7 +2533,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b cdata = adt->action; expanded = EXPANDED_ACTC(adt->action); }); - + /* add object-level animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(expanded) { @@ -2541,7 +2541,7 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ob, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include anim-expand widget first */ @@ -2551,13 +2551,13 @@ static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, b ANIMCHANNEL_NEW_CHANNEL(cdata, type, ob); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -2569,50 +2569,50 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data Object *ob = base->object; size_t tmp_items = 0; size_t items = 0; - + /* filter data contained under object first */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob)) { Key *key = BKE_key_from_object(ob); - + /* object-level animation */ if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) { tmp_items += animdata_filter_ds_obanim(ac, &tmp_data, ads, ob, filter_mode); } - + /* shape-key */ if ((key && key->adt) && !(ads->filterflag & ADS_FILTER_NOSHAPEKEYS)) { tmp_items += animdata_filter_ds_keyanim(ac, &tmp_data, ads, ob, key, filter_mode); } - + /* modifiers */ if ((ob->modifiers.first) && !(ads->filterflag & ADS_FILTER_NOMODIFIERS)) { tmp_items += animdata_filter_ds_modifiers(ac, &tmp_data, ads, ob, filter_mode); } - + /* materials */ if ((ob->totcol) && !(ads->filterflag & ADS_FILTER_NOMAT)) { tmp_items += animdata_filter_ds_materials(ac, &tmp_data, ads, ob, filter_mode); } - + /* object data */ if (ob->data) { tmp_items += animdata_filter_ds_obdata(ac, &tmp_data, ads, ob, filter_mode); } - + /* particles */ if ((ob->particlesystem.first) && !(ads->filterflag & ADS_FILTER_NOPART)) { tmp_items += animdata_filter_ds_particles(ac, &tmp_data, ads, ob, filter_mode); } - + /* grease pencil */ if ((ob->gpd) && !(ads->filterflag & ADS_FILTER_NOGPENCIL)) { tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, ob->gpd, filter_mode); } } END_ANIMFILTER_SUBCHANNELS; - - + + /* if we collected some channels, add these to the new list... */ if (tmp_items) { /* firstly add object expander if required */ @@ -2626,13 +2626,13 @@ static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data } } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added */ return items; } @@ -2642,23 +2642,23 @@ static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bD ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* add world animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_WOR_SCED(wo)) { /* animation data filtering */ tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)wo, filter_mode); - + /* textures for world */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)wo, filter_mode); - + /* nodes */ - if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) + if ((wo->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)wo, wo->nodetree, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include data-expand widget first */ @@ -2668,13 +2668,13 @@ static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bD ANIMCHANNEL_NEW_CHANNEL(wo, ANIMTYPE_DSWOR, sce); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -2684,11 +2684,11 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + AnimData *adt = sce->adt; short type = 0, expanded = 1; void *cdata = NULL; - + /* determine the type of expander channels to use */ // this is the best way to do this for now... ANIMDATA_FILTER_CASES(sce, @@ -2705,7 +2705,7 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD cdata = adt->action; expanded = EXPANDED_ACTC(adt->action); }); - + /* add scene-level animation channels */ BEGIN_ANIMFILTER_SUBCHANNELS(expanded) { @@ -2713,7 +2713,7 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)sce, filter_mode); } END_ANIMFILTER_SUBCHANNELS; - + /* did we find anything? */ if (tmp_items) { /* include anim-expand widget first */ @@ -2723,13 +2723,13 @@ static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bD ANIMCHANNEL_NEW_CHANNEL(cdata, type, sce); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added to the list */ return items; } @@ -2739,39 +2739,39 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; - + /* filter data contained under object first */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_SCEC(sce)) { bNodeTree *ntree = sce->nodetree; bGPdata *gpd = sce->gpd; World *wo = sce->world; - + /* Action, Drivers, or NLA for Scene */ if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) { tmp_items += animdata_filter_ds_scene(ac, &tmp_data, ads, sce, filter_mode); } - + /* world */ if ((wo) && !(ads->filterflag & ADS_FILTER_NOWOR)) { tmp_items += animdata_filter_ds_world(ac, &tmp_data, ads, sce, wo, filter_mode); } - + /* nodetree */ if ((ntree) && !(ads->filterflag & ADS_FILTER_NONTREE)) { tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)sce, ntree, filter_mode); } - + /* line styles */ if ((ads->filterflag & ADS_FILTER_NOLINESTYLE) == 0) { tmp_items += animdata_filter_ds_linestyle(ac, &tmp_data, ads, sce, filter_mode); } - + /* grease pencil */ if ((gpd) && !(ads->filterflag & ADS_FILTER_NOGPENCIL)) { tmp_items += animdata_filter_ds_gpencil(ac, &tmp_data, ads, gpd, filter_mode); } - + /* TODO: one day, when sequencer becomes its own datatype, perhaps it should be included here */ } END_ANIMFILTER_SUBCHANNELS; @@ -2786,13 +2786,13 @@ static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_d ANIMCHANNEL_NEW_CHANNEL(sce, ANIMTYPE_SCENE, sce); } } - + /* now add the list of collected channels */ BLI_movelisttolist(anim_data, &tmp_data); BLI_assert(BLI_listbase_is_empty(&tmp_data)); items += tmp_items; } - + /* return the number of items added */ return items; } @@ -2846,31 +2846,31 @@ static size_t animdata_filter_dopesheet_movieclips(bAnimContext *ac, ListBase *a static bool animdata_filter_base_is_ok(bDopeSheet *ads, Scene *scene, Base *base, int filter_mode) { Object *ob = base->object; - + if (base->object == NULL) return false; - + /* firstly, check if object can be included, by the following factors: * - if only visible, must check for layer and also viewport visibility * --> while tools may demand only visible, user setting takes priority * as user option controls whether sets of channels get included while * tool-flag takes into account collapsed/open channels too - * - if only selected, must check if object is selected - * - there must be animation data to edit (this is done recursively as we + * - if only selected, must check if object is selected + * - there must be animation data to edit (this is done recursively as we * try to add the channels) */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ if ((scene->lay & (ob->lay | base->lay)) == 0) return false; - + /* outliner restrict-flag */ if (ob->restrictflag & OB_RESTRICT_VIEW) return false; } - - /* if only F-Curves with visible flags set can be shown, check that - * datablock hasn't been set to invisible + + /* if only F-Curves with visible flags set can be shown, check that + * datablock hasn't been set to invisible */ if (filter_mode & ANIMFILTER_CURVE_VISIBLE) { if ((ob->adt) && (ob->adt->flag & ADT_CURVES_NOT_VISIBLE)) @@ -2900,8 +2900,8 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Scene *scene, Base *base /* only selected should be shown */ return false; } - - /* check if object belongs to the filtering group if option to filter + + /* check if object belongs to the filtering group if option to filter * objects by the grouped status is on * - used to ease the process of doing multiple-character choreographies */ @@ -2909,7 +2909,7 @@ static bool animdata_filter_base_is_ok(bDopeSheet *ads, Scene *scene, Base *base if (BKE_group_object_exists(ads->filter_grp, ob) == 0) return false; } - + /* no reason to exclude this object... */ return true; } @@ -2919,7 +2919,7 @@ static int ds_base_sorting_cmp(const void *base1_ptr, const void *base2_ptr) { const Base *b1 = *((const Base **)base1_ptr); const Base *b2 = *((const Base **)base2_ptr); - + return strcmp(b1->object->id.name + 2, b2->object->id.name + 2); } @@ -2929,17 +2929,17 @@ static Base **animdata_filter_ds_sorted_bases(bDopeSheet *ads, Scene *scene, int /* Create an array with space for all the bases, but only containing the usable ones */ size_t tot_bases = BLI_listbase_count(&scene->base); size_t num_bases = 0; - + Base **sorted_bases = MEM_mallocN(sizeof(Base *) * tot_bases, "Dopesheet Usable Sorted Bases"); for (Base *base = scene->base.first; base; base = base->next) { if (animdata_filter_base_is_ok(ads, scene, base, filter_mode)) { sorted_bases[num_bases++] = base; } } - + /* Sort this list of pointers (based on the names) */ qsort(sorted_bases, num_bases, sizeof(Base *), ds_base_sorting_cmp); - + /* Return list of sorted bases */ *r_usable_bases = num_bases; return sorted_bases; @@ -2951,7 +2951,7 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b { Scene *scene = (Scene *)ads->source; size_t items = 0; - + /* check that we do indeed have a scene */ if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) { printf("Dope Sheet Error: No scene!\n"); @@ -2959,15 +2959,15 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source) ? ads->source->name : NULL); return 0; } - - /* augment the filter-flags with settings based on the dopesheet filterflags + + /* augment the filter-flags with settings based on the dopesheet filterflags * so that some temp settings can get added automagically... */ if (ads->filterflag & ADS_FILTER_SELEDIT) { /* only selected F-Curves should get their keyframes considered for editability */ filter_mode |= ANIMFILTER_SELEDIT; } - + /* Cache files level animations (frame duration and such). */ CacheFile *cache_file = G.main->cachefiles.first; for (; cache_file; cache_file = cache_file->id.next) { @@ -2994,16 +2994,16 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b // TODO: Cache the old sorted order - if the set of bases hasn't changed, don't re-sort... Base **sorted_bases; size_t num_bases; - + sorted_bases = animdata_filter_ds_sorted_bases(ads, scene, filter_mode, &num_bases); if (sorted_bases) { /* Add the necessary channels for these bases... */ for (size_t i = 0; i < num_bases; i++) { items += animdata_filter_dopesheet_ob(ac, anim_data, ads, sorted_bases[i], filter_mode); } - + // TODO: store something to validate whether any changes are needed? - + /* free temporary data */ MEM_freeN(sorted_bases); } @@ -3019,20 +3019,20 @@ static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, b } } } - + /* return the number of items in the list */ return items; } -/* Summary track for DopeSheet/Action Editor +/* Summary track for DopeSheet/Action Editor * - return code is whether the summary lets the other channels get drawn */ static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_data, int filter_mode, size_t *items) { bDopeSheet *ads = NULL; - - /* get the DopeSheet information to use - * - we should only need to deal with the DopeSheet/Action Editor, + + /* get the DopeSheet information to use + * - we should only need to deal with the DopeSheet/Action Editor, * since all the other Animation Editors won't have this concept * being applicable. */ @@ -3044,9 +3044,9 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_ /* invalid space type - skip this summary channels */ return 1; } - - /* dopesheet summary - * - only for drawing and/or selecting keyframes in channels, but not for real editing + + /* dopesheet summary + * - only for drawing and/or selecting keyframes in channels, but not for real editing * - only useful for DopeSheet/Action/etc. editors where it is actually useful */ if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && (ads->filterflag & ADS_FILTER_SUMMARY)) { @@ -3055,17 +3055,17 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_ BLI_addtail(anim_data, ale); (*items)++; } - - /* if summary is collapsed, don't show other channels beneath this + + /* if summary is collapsed, don't show other channels beneath this * - this check is put inside the summary check so that it doesn't interfere with normal operation - */ + */ if (ads->flag & ADS_FLAG_SUMMARY_COLLAPSED) return 0; } - + /* the other channels beneath this can be shown */ return 1; -} +} /* ......................... */ @@ -3073,18 +3073,18 @@ static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode) { size_t items = 0; - + /* data to filter depends on channel type */ /* NOTE: only common channel-types have been handled for now. More can be added as necessary */ switch (channel->type) { case ANIMTYPE_SUMMARY: items += animdata_filter_dopesheet(ac, anim_data, ads, filter_mode); break; - + case ANIMTYPE_SCENE: items += animdata_filter_dopesheet_scene(ac, anim_data, ads, channel->data, filter_mode); break; - + case ANIMTYPE_OBJECT: items += animdata_filter_dopesheet_ob(ac, anim_data, ads, channel->data, filter_mode); break; @@ -3096,12 +3096,12 @@ static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bD case ANIMTYPE_ANIMDATA: items += animfilter_block_data(ac, anim_data, ads, channel->id, filter_mode); break; - + default: printf("ERROR: Unsupported channel type (%d) in animdata_filter_animchan()\n", channel->type); break; } - + return items; } @@ -3112,17 +3112,17 @@ static size_t animdata_filter_remove_invalid(ListBase *anim_data) { bAnimListElem *ale, *next; size_t items = 0; - + /* only keep entries with valid types */ for (ale = anim_data->first; ale; ale = next) { next = ale->next; - + if (ale->type == ANIMTYPE_NONE) BLI_freelinkN(anim_data, ale); else items++; } - + return items; } @@ -3132,18 +3132,18 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data) bAnimListElem *ale, *next; GSet *gs; size_t items = 0; - - /* build new hashtable to efficiently store and retrieve which entries have been + + /* build new hashtable to efficiently store and retrieve which entries have been * encountered already while searching */ gs = BLI_gset_ptr_new(__func__); - + /* loop through items, removing them from the list if a similar item occurs already */ for (ale = anim_data->first; ale; ale = next) { next = ale->next; - - /* check if hash has any record of an entry like this - * - just use ale->data for now, though it would be nicer to involve + + /* check if hash has any record of an entry like this + * - just use ale->data for now, though it would be nicer to involve * ale->type in combination too to capture corner cases (where same data performs differently) */ if (BLI_gset_add(gs, ale->data)) { @@ -3155,10 +3155,10 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data) BLI_freelinkN(anim_data, ale); } } - + /* free the hash... */ BLI_gset_free(gs, NULL); - + /* return the number of items still in the list */ return items; } @@ -3175,7 +3175,7 @@ static size_t animdata_filter_remove_duplis(ListBase *anim_data) size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_Flags filter_mode, void *data, eAnimCont_Types datatype) { size_t items = 0; - + /* only filter data if there's somewhere to put it */ if (data && anim_data) { /* firstly filter the data */ @@ -3186,7 +3186,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F Object *obact = ac->obact; SpaceAction *saction = (SpaceAction *)ac->sl; bDopeSheet *ads = (saction) ? &saction->ads : NULL; - + /* specially check for AnimData filter... [#36687] */ if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { /* all channels here are within the same AnimData block, hence this special case */ @@ -3199,13 +3199,13 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact); } - + break; } case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */ { Key *key = (Key *)data; - + /* specially check for AnimData filter... [#36687] */ if (UNLIKELY(filter_mode & ANIMFILTER_ANIMDATA)) { /* all channels here are within the same AnimData block, hence this special case */ @@ -3218,11 +3218,11 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) items = animdata_filter_shapekey(ac, anim_data, key, filter_mode); } - + break; } - - + + /* Modes for Specialty Data Types (i.e. not keyframes) */ case ANIMCONT_GPENCIL: { @@ -3236,8 +3236,8 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F items = animdata_filter_mask(anim_data, data, filter_mode); break; } - - + + /* DopeSheet Based Modes */ case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */ { @@ -3254,18 +3254,18 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode); break; } - - + + /* Special/Internal Use */ case ANIMCONT_CHANNEL: /* animation channel */ { bDopeSheet *ads = ac->ads; - + /* based on the channel type, filter relevant data for this */ items = animdata_filter_animchan(ac, anim_data, ads, data, filter_mode); break; } - + /* unhandled */ default: { @@ -3276,12 +3276,12 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F /* remove any 'weedy' entries */ items = animdata_filter_remove_invalid(anim_data); - + /* remove duplicates (if required) */ if (filter_mode & ANIMFILTER_NODUPLIS) items = animdata_filter_remove_duplis(anim_data); } - + /* return the number of items in the list */ return items; } diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h index d8c629bc143..8c4e2acd48d 100644 --- a/source/blender/editors/animation/anim_intern.h +++ b/source/blender/editors/animation/anim_intern.h @@ -27,7 +27,7 @@ * \ingroup edanimation */ - + #ifndef __ANIM_INTERN_H__ #define __ANIM_INTERN_H__ @@ -38,14 +38,14 @@ extern ListBase builtin_keyingsets; /* Operator Define Prototypes ------------------- */ -/* Main Keyframe Management operators: +/* Main Keyframe Management operators: * These handle keyframes management from various spaces. They only make use of * Keying Sets. */ void ANIM_OT_keyframe_insert(struct wmOperatorType *ot); void ANIM_OT_keyframe_delete(struct wmOperatorType *ot); -/* Main Keyframe Management operators: +/* Main Keyframe Management operators: * These handle keyframes management from various spaces. They will handle the menus * required for each space. */ diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 6b219a4f13a..4e0993152f7 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -59,7 +59,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) { int icon = 0; - + /* sanity checks */ if (name == NULL) return icon; @@ -74,17 +74,17 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) else { PointerRNA id_ptr, ptr; PropertyRNA *prop; - + /* get RNA pointer, and resolve the path */ RNA_id_pointer_create(id, &id_ptr); - + /* try to resolve the path */ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { const char *structname = NULL, *propname = NULL; char arrayindbuf[16]; const char *arrayname = NULL; short free_structname = 0; - + /* For now, name will consist of 3 parts: struct-name, property name, array index * There are several options possible: * 1) .. @@ -93,12 +93,12 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) * i.e. X Location (Bone1), or X Location (Object) * * Currently, option 2 is in use, to try and make it easier to quickly identify F-Curves (it does have - * problems with looking rather odd though). Option 1 is better in terms of revealing a consistent sense of + * problems with looking rather odd though). Option 1 is better in terms of revealing a consistent sense of * hierarchy though, which isn't so clear with option 2. */ - + /* for structname - * - as base, we use a custom name from the structs if one is available + * - as base, we use a custom name from the structs if one is available * - however, if we're showing subdata of bones (probably there will be other exceptions later) * need to include that info too since it gets confusing otherwise * - if a pointer just refers to the ID-block, then don't repeat this info @@ -108,11 +108,11 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* perform string 'chopping' to get "Bone Name : Constraint Name" */ char *pchanName = BLI_str_quoted_substrN(fcu->rna_path, "bones["); char *constName = BLI_str_quoted_substrN(fcu->rna_path, "constraints["); - + /* assemble the string to display in the UI... */ structname = BLI_sprintfN("%s : %s", pchanName, constName); free_structname = 1; - + /* free the temp names */ if (pchanName) MEM_freeN(pchanName); if (constName) MEM_freeN(constName); @@ -127,25 +127,25 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) else structname = RNA_struct_ui_name(ptr.type); } - + /* Property Name is straightforward */ propname = RNA_property_ui_name(prop); - + /* Array Index - only if applicable */ if (RNA_property_array_check(prop)) { char c = RNA_property_array_item_char(prop, fcu->array_index); - + /* we need to write the index to a temp buffer (in py syntax) */ if (c) BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c); else BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index); - + arrayname = &arrayindbuf[0]; } else { /* no array index */ arrayname = ""; } - + /* putting this all together into the buffer */ /* XXX we need to check for invalid names... * XXX the name length limit needs to be passed in or as some define */ @@ -153,17 +153,17 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname); else BLI_snprintf(name, 256, "%s%s", arrayname, propname); - + /* free temp name if nameprop is set */ if (free_structname) MEM_freeN((void *)structname); - - + + /* Icon for this property's owner: * use the struct's icon if it is set */ icon = RNA_struct_ui_icon(ptr.type); - + /* valid path - remove the invalid tag since we now know how to use it saving * users manual effort to reenable using "Revive Disabled FCurves" [#29629] */ @@ -172,16 +172,16 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) else { /* invalid path */ BLI_snprintf(name, 256, "\"%s[%d]\"", fcu->rna_path, fcu->array_index); - + /* icon for this should be the icon for the base ID */ /* TODO: or should we just use the error icon? */ icon = RNA_struct_ui_icon(id_ptr.type); - + /* tag F-Curve as disabled - as not usable path */ fcu->flag |= FCURVE_DISABLED; } } - + /* return the icon that the active data had */ return icon; } @@ -197,7 +197,7 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3]) { float hsv[3], fac; int grouping; - + /* we try to divide the color into groupings of n colors, * where n is: * 3 - for 'odd' numbers of curves - there should be a majority of triplets of curves @@ -206,24 +206,24 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3]) */ grouping = (4 - (tot % 2)); hsv[0] = HSV_BANDWIDTH * (float)(cur % grouping); - - /* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be + + /* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be * 'darker' (i.e. smaller value), so that they don't look that similar to previous ones. * However, only a range of 0.3 to 1.0 is really usable to avoid clashing - * with some other stuff + * with some other stuff */ fac = ((float)cur / (float)tot) * 0.7f; - + /* the base color can get offset a bit so that the colors aren't so identical */ hsv[0] += fac * HSV_BANDWIDTH; if (hsv[0] > 1.0f) hsv[0] = fmod(hsv[0], 1.0f); - + /* saturation adjustments for more visible range */ hsv[1] = ((hsv[0] > 0.5f) && (hsv[0] < 0.8f)) ? 0.5f : 0.6f; - + /* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */ hsv[2] = 1.0f; - + /* finally, conver this to RGB colors */ hsv_to_rgb_v(hsv, out); } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index c6a97186bbc..2450d0740f2 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -82,8 +82,8 @@ static ListBase *context_get_markers(Scene *scene, ScrArea *sa) if (sa) { if (sa->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - - /* local markers can only be shown when there's only a single active action to grab them from + + /* local markers can only be shown when there's only a single active action to grab them from * - flag only takes effect when there's an action, otherwise it can get too confusing? */ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && (saction->action)) { @@ -93,7 +93,7 @@ static ListBase *context_get_markers(Scene *scene, ScrArea *sa) } } } - + /* default to using the scene's markers */ return &scene->markers; } @@ -132,7 +132,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f TimeMarker *marker; float cfra = (float)CFRA; int changed_tot = 0; - + /* sanity check - no markers, or locked markers */ if ((scene->toolsettings->lock_markers) || (markers == NULL)) @@ -167,7 +167,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f } } } - + return changed_tot; } @@ -179,18 +179,18 @@ TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x) { TimeMarker *marker, *nearest = NULL; float dist, min_dist = 1000000; - + if (markers) { for (marker = markers->first; marker; marker = marker->next) { dist = fabsf((float)marker->frame - x); - + if (dist < min_dist) { min_dist = dist; nearest = marker; } } } - + return nearest; } @@ -206,7 +206,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la { TimeMarker *marker; float min, max; - + /* sanity check */ //printf("markers = %p - %p, %p\n", markers, markers->first, markers->last); if (ELEM(NULL, markers, markers->first, markers->last)) { @@ -225,7 +225,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la max = (float)marker->frame; } } - + /* set the min/max values */ *first = min; *last = max; @@ -237,16 +237,16 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only_sel) { CfraElem *ce, *cen; - + /* should this one only be considered if it is selected? */ if ((only_sel) && ((marker->flag & SELECT) == 0)) return; - + /* insertion sort - try to find a previous cfra elem */ for (ce = lb->first; ce; ce = ce->next) { if (ce->cfra == marker->frame) { /* do because of double keys */ - if (marker->flag & SELECT) + if (marker->flag & SELECT) ce->sel = marker->flag; return; } @@ -254,7 +254,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only break; } } - + cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); if (ce) BLI_insertlinkbefore(lb, ce, cen); else BLI_addtail(lb, cen); @@ -270,7 +270,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel) { TimeMarker *marker; - + if (lb) { /* Clear the list first, since callers have no way of knowing * whether this terminated early otherwise. This may lead @@ -281,11 +281,11 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel) else { return; } - + if (markers == NULL) { return; } - + for (marker = markers->first; marker; marker = marker->next) add_marker_to_cfra_elem(lb, marker, only_sel); } @@ -296,37 +296,37 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel) TimeMarker *ED_markers_get_first_selected(ListBase *markers) { TimeMarker *marker; - + if (markers) { for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) return marker; } } - + return NULL; } /* --------------------------------- */ -/* Print debugging prints of list of markers +/* Print debugging prints of list of markers * BSI's: do NOT make static or put in if-defs as "unused code". That's too much trouble when we need to use for quick debugging! */ void debug_markers_print_list(ListBase *markers) { TimeMarker *marker; - + if (markers == NULL) { printf("No markers list to print debug for\n"); return; } - + printf("List of markers follows: -----\n"); - + for (marker = markers->first; marker; marker = marker->next) { printf("\t'%s' on %d at %p with %u\n", marker->name, marker->frame, (void *)marker, marker->flag); } - + printf("End of list ------------------\n"); } @@ -343,7 +343,7 @@ static void draw_marker( glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + /* vertical line - dotted */ #ifdef DURIAN_CAMERA_SWITCH if ((marker->camera) || (flag & DRAW_MARKERS_LINES)) @@ -352,20 +352,20 @@ static void draw_marker( #endif { setlinestyle(3); - + if (marker->flag & SELECT) glColor4ub(255, 255, 255, 96); else glColor4ub(0, 0, 0, 96); - + glBegin(GL_LINES); glVertex2f(xpos + 0.5f, 12.0f); glVertex2f(xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); glEnd(); - + setlinestyle(0); } - + /* 5 px to offset icon to align properly, space / pixels corrects for zoom */ if (flag & DRAW_MARKERS_LOCAL) { icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : @@ -376,18 +376,18 @@ static void draw_marker( icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER; } - + UI_icon_draw(xpos - 0.45f * UI_DPI_ICON_SIZE, UI_DPI_ICON_SIZE, icon_id); - + glDisable(GL_BLEND); - + /* and the marker name too, shifted slightly to the top-right */ if (marker->name[0]) { float x, y; /* minimal y coordinate which wouldn't be occluded by scroll */ int min_y = 17.0f * UI_DPI_FAC; - + if (marker->flag & SELECT) { UI_ThemeColor(TH_TEXT_HI); x = xpos + 4.0f * UI_DPI_FAC; @@ -484,7 +484,7 @@ void ED_markers_draw(const bContext *C, int flag) } /* ************************ Marker Wrappers API ********************* */ -/* These wrappers allow marker operators to function within the confines +/* These wrappers allow marker operators to function within the confines * of standard animation editors, such that they can coexist with the * primary operations of those editors. */ @@ -495,11 +495,11 @@ void ED_markers_draw(const bContext *C, int flag) static int ed_markers_poll_selected_markers(bContext *C) { ListBase *markers = ED_context_get_markers(C); - + /* first things first: markers can only exist in timeline views */ if (ED_operator_animview_active(C) == 0) return 0; - + /* check if some marker is selected */ return ED_markers_get_first_selected(markers) != NULL; } @@ -526,19 +526,19 @@ static int ed_markers_poll_markers_exist(bContext *C) { ListBase *markers = ED_context_get_markers(C); ToolSettings *ts = CTX_data_tool_settings(C); - + if (ts->lock_markers) return 0; /* first things first: markers can only exist in timeline views */ if (ED_operator_animview_active(C) == 0) return 0; - + /* list of markers must exist, as well as some markers in it! */ return (markers && markers->first); } - -/* ------------------------ */ + +/* ------------------------ */ /** * Second-tier invoke() callback that performs context validation before running the @@ -554,9 +554,9 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wm { ScrArea *sa = CTX_wm_area(C); int retval = OPERATOR_PASS_THROUGH; - + /* removed check for Y coord of event, keymap has bounbox now */ - + /* allow operator to run now */ if (invoke_func) retval = invoke_func(C, op, event); @@ -564,7 +564,7 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wm retval = op->type->exec(C, op); else BKE_report(op->reports, RPT_ERROR, "Programming error: operator does not actually have code to do anything!"); - + /* return status modifications - for now, make this spacetype dependent as above */ if (sa->spacetype != SPACE_TIME) { /* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */ @@ -572,7 +572,7 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wm retval |= OPERATOR_PASS_THROUGH; } } - + return retval; } @@ -594,30 +594,30 @@ static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; int frame = CTX_data_scene(C)->r.cfra; - + if (markers == NULL) return OPERATOR_CANCELLED; - + /* prefer not having 2 markers at the same place, * though the user can move them to overlap once added */ for (marker = markers->first; marker; marker = marker->next) { - if (marker->frame == frame) + if (marker->frame == frame) return OPERATOR_CANCELLED; } - + /* deselect all */ for (marker = markers->first; marker; marker = marker->next) marker->flag &= ~SELECT; - + marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag = SELECT; marker->frame = frame; BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); // XXX - temp code only BLI_addtail(markers, marker); - + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); - + return OPERATOR_FINISHED; } @@ -627,19 +627,19 @@ static void MARKER_OT_add(wmOperatorType *ot) ot->name = "Add Time Marker"; ot->description = "Add a new time marker"; ot->idname = "MARKER_OT_add"; - + /* api callbacks */ ot->exec = ed_marker_add_exec; ot->invoke = ed_markers_opwrap_invoke; ot->poll = ED_operator_animview_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** transform markers *************************** */ -/* operator state vars used: +/* operator state vars used: * frs: delta movement * * functions: @@ -778,12 +778,12 @@ static bool ed_marker_move_init(bContext *C, wmOperator *op) static void ed_marker_move_exit(bContext *C, wmOperator *op) { MarkerMove *mm = op->customdata; - + /* free data */ MEM_freeN(mm->oldframe); MEM_freeN(op->customdata); op->customdata = NULL; - + /* clear custom header prints */ ED_area_headerprint(CTX_wm_area(C), NULL); } @@ -792,14 +792,14 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve { if (ed_marker_move_init(C, op)) { MarkerMove *mm = op->customdata; - + mm->evtx = event->x; mm->firstx = event->x; mm->event_type = event->type; - + /* add temp handler */ WM_event_add_modal_handler(C, op); - + /* reset frs delta */ RNA_int_set(op->ptr, "frames", 0); @@ -807,7 +807,7 @@ static int ed_marker_move_invoke(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_RUNNING_MODAL; } - + return OPERATOR_CANCELLED; } @@ -827,7 +827,7 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op) MarkerMove *mm = op->customdata; TimeMarker *marker; int a, offs; - + offs = RNA_int_get(op->ptr, "frames"); for (a = 0, marker = mm->markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { @@ -838,7 +838,7 @@ static void ed_marker_move_apply(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); - + #ifdef DURIAN_CAMERA_SWITCH /* so we get view3d redraws */ BKE_scene_camera_switch_update(scene); @@ -963,17 +963,17 @@ static void MARKER_OT_move(wmOperatorType *ot) ot->name = "Move Time Marker"; ot->description = "Move selected time marker(s)"; ot->idname = "MARKER_OT_move"; - + /* api callbacks */ ot->exec = ed_marker_move_exec; ot->invoke = ed_marker_move_invoke_wrapper; ot->modal = ed_marker_move_modal; ot->poll = ed_markers_poll_selected_no_locked_markers; ot->cancel = ed_marker_move_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR; - + /* rna storage */ RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX); } @@ -1001,8 +1001,8 @@ static void ed_marker_duplicate_apply(bContext *C) { ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *newmarker; - - if (markers == NULL) + + if (markers == NULL) return; /* go through the list of markers, duplicate selected markers and add duplicated copies @@ -1012,13 +1012,13 @@ static void ed_marker_duplicate_apply(bContext *C) if (marker->flag & SELECT) { /* unselect selected marker */ marker->flag &= ~SELECT; - + /* create and set up new marker */ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); newmarker->flag = SELECT; newmarker->frame = marker->frame; BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name)); - + #ifdef DURIAN_CAMERA_SWITCH newmarker->camera = marker->camera; #endif @@ -1034,9 +1034,9 @@ static int ed_marker_duplicate_exec(bContext *C, wmOperator *op) { ed_marker_duplicate_apply(C); ed_marker_move_exec(C, op); /* assumes frs delta set */ - + return OPERATOR_FINISHED; - + } static int ed_marker_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *event) @@ -1056,17 +1056,17 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Time Marker"; ot->description = "Duplicate selected time marker(s)"; ot->idname = "MARKER_OT_duplicate"; - + /* api callbacks */ ot->exec = ed_marker_duplicate_exec; ot->invoke = ed_marker_duplicate_invoke_wrapper; ot->modal = ed_marker_move_modal; ot->poll = ed_markers_poll_selected_no_locked_markers; ot->cancel = ed_marker_move_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna storage */ RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX); } @@ -1113,18 +1113,18 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool View2D *v2d = UI_view2d_fromcontext(C); float viewx; int x, cfra; - + if (markers == NULL) return OPERATOR_PASS_THROUGH; x = event->x - ar->winrct.xmin; - + viewx = UI_view2d_region_to_view_x(v2d, x); - + cfra = ED_markers_find_nearest_marker_time(markers, viewx); - + select_timeline_marker_frame(markers, cfra, extend); - + #ifdef DURIAN_CAMERA_SWITCH if (camera) { @@ -1132,17 +1132,17 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool Base *base; TimeMarker *marker; int sel = 0; - + if (!extend) BKE_scene_base_deselect_all(scene); - + for (marker = markers->first; marker; marker = marker->next) { if (marker->frame == cfra) { sel = (marker->flag & SELECT); break; } } - + for (marker = markers->first; marker; marker = marker->next) { if (marker->camera) { if (marker->frame == cfra) { @@ -1155,7 +1155,7 @@ static int ed_marker_select(bContext *C, const wmEvent *event, bool extend, bool } } } - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } #else @@ -1192,11 +1192,11 @@ static void MARKER_OT_select(wmOperatorType *ot) ot->name = "Select Time Marker"; ot->description = "Select time marker(s)"; ot->idname = "MARKER_OT_select"; - + /* api callbacks */ ot->invoke = ed_marker_select_invoke_wrapper; ot->poll = ed_markers_poll_markers_exist; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1210,7 +1210,7 @@ static void MARKER_OT_select(wmOperatorType *ot) /* *************************** border select markers **************** */ -/* operator state vars used: (added by default WM callbacks) +/* operator state vars used: (added by default WM callbacks) * xmin, ymin * xmax, ymax * @@ -1237,13 +1237,13 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) bool select = !RNA_boolean_get(op->ptr, "deselect"); bool extend = RNA_boolean_get(op->ptr, "extend"); rctf rect; - + WM_operator_properties_border_to_rctf(op, &rect); UI_view2d_region_to_view_rctf(v2d, &rect, &rect); - + if (markers == NULL) return 0; - + /* XXX marker context */ for (marker = markers->first; marker; marker = marker->next) { if (BLI_rctf_isect_x(&rect, marker->frame)) { @@ -1258,7 +1258,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) marker->flag &= ~SELECT; } } - + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); @@ -1276,18 +1276,18 @@ static void MARKER_OT_select_border(wmOperatorType *ot) ot->name = "Marker Border Select"; ot->description = "Select all time markers using border selection"; ot->idname = "MARKER_OT_select_border"; - + /* api callbacks */ ot->exec = ed_marker_border_select_exec; ot->invoke = ed_marker_select_border_invoke_wrapper; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ed_markers_poll_markers_exist; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); } @@ -1306,7 +1306,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT; } - + for (marker = markers->first; marker; marker = marker->next) { switch (action) { case SEL_SELECT: @@ -1320,7 +1320,7 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) break; } } - + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); @@ -1333,15 +1333,15 @@ static void MARKER_OT_select_all(wmOperatorType *ot) ot->name = "(De)select all Markers"; ot->description = "Change selection of all time markers"; ot->idname = "MARKER_OT_select_all"; - + /* api callbacks */ ot->exec = ed_marker_select_all_exec; ot->invoke = ed_markers_opwrap_invoke; ot->poll = ed_markers_poll_markers_exist; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_select_all(ot); } @@ -1354,10 +1354,10 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *nmarker; bool changed = false; - + if (markers == NULL) return OPERATOR_CANCELLED; - + for (marker = markers->first; marker; marker = nmarker) { nmarker = marker->next; if (marker->flag & SELECT) { @@ -1365,12 +1365,12 @@ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) changed = true; } } - + if (changed) { WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); } - + return OPERATOR_FINISHED; } @@ -1386,12 +1386,12 @@ static void MARKER_OT_delete(wmOperatorType *ot) ot->name = "Delete Markers"; ot->description = "Delete selected time marker(s)"; ot->idname = "MARKER_OT_delete"; - + /* api callbacks */ ot->invoke = ed_marker_delete_invoke_wrapper; ot->exec = ed_marker_delete_exec; ot->poll = ed_markers_poll_selected_no_locked_markers; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1406,10 +1406,10 @@ static int ed_marker_rename_exec(bContext *C, wmOperator *op) if (marker) { RNA_string_get(op->ptr, "name", marker->name); - + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); - + return OPERATOR_FINISHED; } else { @@ -1423,7 +1423,7 @@ static int ed_marker_rename_invoke_wrapper(bContext *C, wmOperator *op, const wm TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C)); if (marker) RNA_string_set(op->ptr, "name", marker->name); - + /* now see if the operator is usable */ return ed_markers_opwrap_invoke_custom(C, op, event, WM_operator_props_popup_confirm); } @@ -1434,15 +1434,15 @@ static void MARKER_OT_rename(wmOperatorType *ot) ot->name = "Rename Marker"; ot->description = "Rename first selected time marker"; ot->idname = "MARKER_OT_rename"; - + /* api callbacks */ ot->invoke = ed_marker_rename_invoke_wrapper; ot->exec = ed_marker_rename_exec; ot->poll = ed_markers_poll_selected_no_locked_markers; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", sizeof(((TimeMarker *)NULL)->name), "Name", "New name for marker"); //RNA_def_boolean(ot->srna, "ensure_unique", 0, "Ensure Unique", "Ensure that new name is unique within collection of markers"); @@ -1476,7 +1476,7 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) if (marker->flag & SELECT) { marker_new = MEM_dupallocN(marker); marker_new->prev = marker_new->next = NULL; - + BLI_addtail(&scene_to->markers, marker_new); } } @@ -1583,7 +1583,7 @@ void ED_keymap_marker(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Markers", 0, 0); wmKeyMapItem *kmi; - + WM_keymap_verify_item(keymap, "MARKER_OT_add", MKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "MARKER_OT_move", EVT_TWEAK_S, KM_ANY, 0, 0); WM_keymap_verify_item(keymap, "MARKER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); @@ -1602,13 +1602,13 @@ void ED_keymap_marker(wmKeyConfig *keyconf) #else (void)kmi; #endif - + WM_keymap_verify_item(keymap, "MARKER_OT_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "MARKER_OT_select_all", AKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MARKER_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MARKER_OT_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "MARKER_OT_rename", MKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "MARKER_OT_move", GKEY, KM_PRESS, 0, 0); #ifdef DURIAN_CAMERA_SWITCH WM_keymap_add_item(keymap, "MARKER_OT_camera_bind", BKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index b0630175f93..d817433bcb1 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -67,10 +67,10 @@ static int change_frame_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); - + /* XXX temp? prevent changes during render */ if (G.is_rendering) return false; - + /* although it's only included in keymaps for regions using ED_KEYMAP_ANIMATION, * this shouldn't show up in 3D editor (or others without 2D timeline view) via search */ @@ -85,7 +85,7 @@ static int change_frame_poll(bContext *C) return false; } } - + CTX_wm_operator_poll_msg_set(C, "Expected an timeline/animation area to be active"); return false; } @@ -139,12 +139,12 @@ static float frame_from_event(bContext *C, const wmEvent *event) /* convert from region coordinates to View2D 'tot' space */ frame = UI_view2d_region_to_view_x(®ion->v2d, event->mval[0]); - + /* respect preview range restrictions (if only allowed to move around within that range) */ if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) { CLAMP(frame, PSFRA, PEFRA); } - + return frame; } @@ -195,7 +195,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event change_frame_seq_preview_begin(C, event); change_frame_apply(C, op); - + /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -221,11 +221,11 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) RNA_float_set(op->ptr, "frame", frame_from_event(C, event)); change_frame_apply(C, op); break; - - case LEFTMOUSE: + + case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: - /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init + /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ if (event->val == KM_RELEASE) @@ -258,14 +258,14 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) ot->name = "Change Frame"; ot->idname = "ANIM_OT_change_frame"; ot->description = "Interactively change the current frame number"; - + /* api callbacks */ ot->exec = change_frame_exec; ot->invoke = change_frame_invoke; ot->cancel = change_frame_cancel; ot->modal = change_frame_modal; ot->poll = change_frame_poll; - + /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_UNDO_GROUPED; ot->undo_group = "FRAME_CHANGE"; @@ -284,31 +284,31 @@ static int previewrange_define_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); float sfra, efra; rcti rect; - + /* get min/max values from border select rect (already in region coordinates, not screen) */ WM_operator_properties_border_to_rcti(op, &rect); - + /* convert min/max values to frames (i.e. region to 'tot' rect) */ sfra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmin); efra = UI_view2d_region_to_view_x(&ar->v2d, rect.xmax); - - /* set start/end frames for preview-range + + /* set start/end frames for preview-range * - must clamp within allowable limits * - end must not be before start (though this won't occur most of the time) */ FRAMENUMBER_MIN_CLAMP(sfra); FRAMENUMBER_MIN_CLAMP(efra); if (efra < sfra) efra = sfra; - + scene->r.flag |= SCER_PRV_RANGE; scene->r.psfra = round_fl_to_int(sfra); scene->r.pefra = round_fl_to_int(efra); - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); - + return OPERATOR_FINISHED; -} +} static void ANIM_OT_previewrange_set(wmOperatorType *ot) { @@ -316,18 +316,18 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot) ot->name = "Set Preview Range"; ot->idname = "ANIM_OT_previewrange_set"; ot->description = "Interactively define frame range used for playback"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = previewrange_define_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ED_operator_animview_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ /* used to define frame range. * @@ -342,23 +342,23 @@ static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); ScrArea *curarea = CTX_wm_area(C); - + /* sanity checks */ if (ELEM(NULL, scene, curarea)) return OPERATOR_CANCELLED; - + /* simply clear values */ scene->r.flag &= ~SCER_PRV_RANGE; scene->r.psfra = 0; scene->r.pefra = 0; - + ED_area_tag_redraw(curarea); - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); - + return OPERATOR_FINISHED; -} +} static void ANIM_OT_previewrange_clear(wmOperatorType *ot) { @@ -366,12 +366,12 @@ static void ANIM_OT_previewrange_clear(wmOperatorType *ot) ot->name = "Clear Preview Range"; ot->idname = "ANIM_OT_previewrange_clear"; ot->description = "Clear Preview Range"; - + /* api callbacks */ ot->exec = previewrange_clear_exec; - + ot->poll = ED_operator_animview_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -382,10 +382,10 @@ void ED_operatortypes_anim(void) { /* Animation Editors only -------------------------- */ WM_operatortype_append(ANIM_OT_change_frame); - + WM_operatortype_append(ANIM_OT_previewrange_set); WM_operatortype_append(ANIM_OT_previewrange_clear); - + /* Entire UI --------------------------------------- */ WM_operatortype_append(ANIM_OT_keyframe_insert); WM_operatortype_append(ANIM_OT_keyframe_delete); @@ -395,22 +395,22 @@ void ED_operatortypes_anim(void) WM_operatortype_append(ANIM_OT_keyframe_insert_button); WM_operatortype_append(ANIM_OT_keyframe_delete_button); WM_operatortype_append(ANIM_OT_keyframe_clear_button); - - + + WM_operatortype_append(ANIM_OT_driver_button_add); WM_operatortype_append(ANIM_OT_driver_button_remove); WM_operatortype_append(ANIM_OT_copy_driver_button); WM_operatortype_append(ANIM_OT_paste_driver_button); - + WM_operatortype_append(ANIM_OT_keyingset_button_add); WM_operatortype_append(ANIM_OT_keyingset_button_remove); - + WM_operatortype_append(ANIM_OT_keying_set_add); WM_operatortype_append(ANIM_OT_keying_set_remove); WM_operatortype_append(ANIM_OT_keying_set_path_add); WM_operatortype_append(ANIM_OT_keying_set_path_remove); - + WM_operatortype_append(ANIM_OT_keying_set_active_set); } @@ -418,14 +418,14 @@ void ED_keymap_anim(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Animation", 0, 0); wmKeyMapItem *kmi; - + /* frame management */ /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */ WM_keymap_add_item(keymap, "ANIM_OT_change_frame", ACTIONMOUSE, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.show_seconds"); - + /* preview range */ WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_set", PKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_clear", PKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 7dae825c92f..be9875ef95a 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -29,7 +29,7 @@ * \ingroup edanimation */ - + #include #include @@ -65,7 +65,7 @@ /* ************************************************** */ /* Animation Data Validation */ -/* Get (or add relevant data to be able to do so) F-Curve from the driver stack, +/* Get (or add relevant data to be able to do so) F-Curve from the driver stack, * for the given Animation Data block. This assumes that all the destinations are valid. * * - add: 0 - don't add anything if not found, @@ -77,11 +77,11 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde { AnimData *adt; FCurve *fcu; - + /* sanity checks */ if (ELEM(NULL, id, rna_path)) return NULL; - + /* init animdata if none available yet */ adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) @@ -90,33 +90,33 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ return NULL; } - - /* try to find f-curve matching for this setting + + /* try to find f-curve matching for this setting * - add if not found and allowed to add one * TODO: add auto-grouping support? how this works will need to be resolved */ fcu = list_find_fcurve(&adt->drivers, rna_path, array_index); - + if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL; - + /* store path - make copy, and store that */ fcu->rna_path = BLI_strdup(rna_path); fcu->array_index = array_index; - + /* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */ if (add > 0) { BezTriple *bezt; size_t i; - + /* add some new driver data */ fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); fcu->driver->flag |= DRIVER_FLAG_SHOWDEBUG; - + /* F-Modifier or Keyframes? */ // FIXME: replace these magic numbers with defines if (add == 2) { @@ -127,27 +127,27 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); } else { - /* add 2 keyframes so that user has something to work with + /* add 2 keyframes so that user has something to work with * - These are configured to 0,0 and 1,1 to give a 1-1 mapping * which can be easily tweaked from there. */ insert_vert_fcurve(fcu, 0.0f, 0.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); insert_vert_fcurve(fcu, 1.0f, 1.0f, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); - + /* configure this curve to extrapolate */ for (i = 0, bezt = fcu->bezt; (i < fcu->totvert) && bezt; i++, bezt++) { bezt->h1 = bezt->h2 = HD_VECT; } - + fcu->extend = FCURVE_EXTRAPOLATE_LINEAR; calchandles_fcurve(fcu); } } - + /* just add F-Curve to end of driver list */ BLI_addtail(&adt->drivers, fcu); } - + /* return the F-Curve */ return fcu; } @@ -167,17 +167,17 @@ static int add_driver_with_target( FCurve *fcu; short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1; const char *prop_name = RNA_property_identifier(src_prop); - + /* Create F-Curve with Driver */ fcu = verify_driver_fcurve(dst_id, dst_path, dst_index, add_mode); - + if (fcu && fcu->driver) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + /* Set the type of the driver */ driver->type = driver_type; - + /* Set driver expression, so that the driver works out of the box * * The following checks define a bit of "autodetection magic" we use @@ -185,7 +185,7 @@ static int add_driver_with_target( * when faced with properties with different units. */ /* XXX: if we have N-1 mapping, should we include all those in the expression? */ - if ((RNA_property_unit(dst_prop) == PROP_UNIT_ROTATION) && + if ((RNA_property_unit(dst_prop) == PROP_UNIT_ROTATION) && (RNA_property_unit(src_prop) != PROP_UNIT_ROTATION)) { /* Rotation Destination: normal -> radians, so convert src to radians @@ -205,7 +205,7 @@ static int add_driver_with_target( /* Just a normal property without any unit problems */ BLI_strncpy(driver->expression, "var", sizeof(driver->expression)); } - + /* Create a driver variable for the target * - For transform properties, we want to automatically use "transform channel" instead * (The only issue is with quat rotations vs euler channels...) @@ -214,25 +214,25 @@ static int add_driver_with_target( * when both the source and destinations are in same places. */ dvar = driver_add_new_variable(driver); - - if (ELEM(src_ptr->type, &RNA_Object, &RNA_PoseBone) && + + if (ELEM(src_ptr->type, &RNA_Object, &RNA_PoseBone) && (STREQ(prop_name, "location") || STREQ(prop_name, "scale") || STRPREFIX(prop_name, "rotation_")) && (src_ptr->data != dst_ptr->data)) { /* Transform Channel */ DriverTarget *dtar; - + driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); dtar = &dvar->targets[0]; - + /* Bone or Object target? */ dtar->id = src_id; dtar->idtype = GS(src_id->name); - + if (src_ptr->type == &RNA_PoseBone) { RNA_string_get(src_ptr, "name", dtar->pchan_name); } - + /* Transform channel depends on type */ if (STREQ(prop_name, "location")) { if (src_index == 2) @@ -265,11 +265,11 @@ static int add_driver_with_target( else { /* Single RNA Property */ DriverTarget *dtar = &dvar->targets[0]; - + /* ID is as-is */ dtar->id = src_id; dtar->idtype = GS(src_id->name); - + /* Need to make a copy of the path (or build one with array index built in) */ if (RNA_property_array_check(src_prop)) { dtar->rna_path = BLI_sprintfN("%s[%d]", src_path, src_index); @@ -279,7 +279,7 @@ static int add_driver_with_target( } } } - + /* set the done status */ return (fcu != NULL); } @@ -296,35 +296,35 @@ static int add_driver_with_target( * - mapping_type: eCreateDriver_MappingTypes */ int ANIM_add_driver_with_target( - ReportList *reports, + ReportList *reports, ID *dst_id, const char dst_path[], int dst_index, ID *src_id, const char src_path[], int src_index, short flag, int driver_type, short mapping_type) { PointerRNA id_ptr, ptr; PropertyRNA *prop; - + PointerRNA id_ptr2, ptr2; PropertyRNA *prop2; int done_tot = 0; - + /* validate pointers first - exit if failure */ RNA_id_pointer_create(dst_id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, dst_path, &ptr, &prop) == false) { - BKE_reportf(reports, RPT_ERROR, + BKE_reportf(reports, RPT_ERROR, "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)", dst_id->name, dst_path); return 0; } - + RNA_id_pointer_create(src_id, &id_ptr2); - if ((RNA_path_resolve_property(&id_ptr2, src_path, &ptr2, &prop2) == false) || + if ((RNA_path_resolve_property(&id_ptr2, src_path, &ptr2, &prop2) == false) || (mapping_type == CREATEDRIVER_MAPPING_NONE)) { /* No target - So, fall back to default method for adding a "simple" driver normally */ return ANIM_add_driver(reports, dst_id, dst_path, dst_index, flag | CREATEDRIVER_WITH_DEFAULT_DVAR, driver_type); } - + /* handle curve-property mappings based on mapping_type */ switch (mapping_type) { case CREATEDRIVER_MAPPING_N_N: /* N-N - Try to match as much as possible, then use the first one */ @@ -332,35 +332,35 @@ int ANIM_add_driver_with_target( /* Use the shorter of the two (to avoid out of bounds access) */ int dst_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1; int src_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr2, prop2) : 1; - + int len = MIN2(dst_len, src_len); int i; - + for (i = 0; i < len; i++) { done_tot += add_driver_with_target(reports, dst_id, dst_path, i, src_id, src_path, i, &ptr, prop, &ptr2, prop2, flag, driver_type); } break; } - + case CREATEDRIVER_MAPPING_1_N: /* 1-N - Specified target index for all */ default: { int len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1; int i; - + for (i = 0; i < len; i++) { done_tot += add_driver_with_target(reports, dst_id, dst_path, i, src_id, src_path, src_index, &ptr, prop, &ptr2, prop2, flag, driver_type); } break; } - + case CREATEDRIVER_MAPPING_1_1: /* 1-1 - Use the specified index (unless -1) */ { done_tot = add_driver_with_target(reports, dst_id, dst_path, dst_index, src_id, src_path, src_index, &ptr, prop, &ptr2, prop2, flag, driver_type); break; } } - + /* done */ return done_tot; } @@ -371,22 +371,22 @@ int ANIM_add_driver_with_target( * Add a new driver for the specified property on the given ID block */ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type) -{ +{ PointerRNA id_ptr, ptr; PropertyRNA *prop; FCurve *fcu; int array_index_max; int done_tot = 0; - + /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { - BKE_reportf(reports, RPT_ERROR, + BKE_reportf(reports, RPT_ERROR, "Could not add driver, as RNA path is invalid for the given ID (ID = %s, path = %s)", id->name, rna_path); return 0; } - + /* key entire array convenience method */ if (array_index == -1) { array_index_max = RNA_property_array_length(&ptr, prop); @@ -394,25 +394,25 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra } else array_index_max = array_index; - + /* maximum index should be greater than the start index */ if (array_index == array_index_max) array_index_max += 1; - + /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { short add_mode = (flag & CREATEDRIVER_WITH_FMODIFIER) ? 2 : 1; - + /* create F-Curve with Driver */ fcu = verify_driver_fcurve(id, rna_path, array_index, add_mode); - + if (fcu && fcu->driver) { ChannelDriver *driver = fcu->driver; - + /* set the type of the driver */ driver->type = type; - - /* creating drivers for buttons will create the driver(s) with type + + /* creating drivers for buttons will create the driver(s) with type * "scripted expression" so that their values won't be lost immediately, * so here we copy those values over to the driver's expression */ @@ -422,28 +422,28 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra char *expression = driver->expression; int val, maxlen = sizeof(driver->expression); float fval; - + if (proptype == PROP_BOOLEAN) { if (!array) val = RNA_property_boolean_get(&ptr, prop); else val = RNA_property_boolean_get_index(&ptr, prop, array_index); - + BLI_strncpy(expression, (val) ? "True" : "False", maxlen); } else if (proptype == PROP_INT) { if (!array) val = RNA_property_int_get(&ptr, prop); else val = RNA_property_int_get_index(&ptr, prop, array_index); - + BLI_snprintf(expression, maxlen, "%d", val); } else if (proptype == PROP_FLOAT) { if (!array) fval = RNA_property_float_get(&ptr, prop); else fval = RNA_property_float_get_index(&ptr, prop, array_index); - + BLI_snprintf(expression, maxlen, "%.3f", fval); } } - - /* for easier setup of drivers from UI, a driver variable should be + + /* for easier setup of drivers from UI, a driver variable should be * added if flag is set (UI calls only) */ if (flag & CREATEDRIVER_WITH_DEFAULT_DVAR) { @@ -454,11 +454,11 @@ int ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int arra driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); } } - + /* set the done status */ done_tot += (fcu != NULL); } - + /* done */ return done_tot; } @@ -471,29 +471,29 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path AnimData *adt; FCurve *fcu; bool success = false; - + /* we don't check the validity of the path here yet, but it should be ok... */ adt = BKE_animdata_from_id(id); - + if (adt) { if (array_index == -1) { /* step through all drivers, removing all of those with the same base path */ FCurve *fcu_iter = adt->drivers.first; - + while ((fcu = iter_step_fcurve(fcu_iter, rna_path)) != NULL) { /* store the next fcurve for looping */ fcu_iter = fcu->next; - + /* remove F-Curve from driver stack, then free it */ BLI_remlink(&adt->drivers, fcu); free_fcurve(fcu); - + /* done successfully */ success = true; } } else { - /* find the matching driver and remove it only + /* find the matching driver and remove it only * Note: here is one of the places where we don't want new F-Curve + Driver added! * so 'add' var must be 0 */ @@ -501,7 +501,7 @@ bool ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path if (fcu) { BLI_remlink(&adt->drivers, fcu); free_fcurve(fcu); - + success = true; } } @@ -541,7 +541,7 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar PointerRNA id_ptr, ptr; PropertyRNA *prop; FCurve *fcu; - + /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { @@ -550,13 +550,13 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar id->name, rna_path); return 0; } - + /* try to get F-Curve with Driver */ fcu = verify_driver_fcurve(id, rna_path, array_index, 0); - + /* clear copy/paste buffer first (for consistency with other copy/paste buffers) */ ANIM_drivers_copybuf_free(); - + /* copy this to the copy/paste buf if it exists */ if (fcu && fcu->driver) { /* make copies of some info such as the rna_path, then clear this info from the F-Curve temporarily @@ -564,17 +564,17 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar */ char *tmp_path = fcu->rna_path; fcu->rna_path = NULL; - + /* make a copy of the F-Curve with */ channeldriver_copypaste_buf = copy_fcurve(fcu); - + /* restore the path */ fcu->rna_path = tmp_path; - + /* copied... */ return 1; } - + /* done */ return 0; } @@ -584,11 +584,11 @@ bool ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int ar * with the driver + driver-curve data from the buffer */ bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) -{ +{ PointerRNA id_ptr, ptr; PropertyRNA *prop; FCurve *fcu; - + /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { @@ -597,35 +597,35 @@ bool ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int a id->name, rna_path); return 0; } - + /* if the buffer is empty, cannot paste... */ if (channeldriver_copypaste_buf == NULL) { BKE_report(reports, RPT_ERROR, "Paste driver: no driver to paste"); return 0; } - + /* create Driver F-Curve, but without data which will be copied across... */ fcu = verify_driver_fcurve(id, rna_path, array_index, -1); - + if (fcu) { - /* copy across the curve data from the buffer curve + /* copy across the curve data from the buffer curve * NOTE: this step needs care to not miss new settings */ /* keyframes/samples */ fcu->bezt = MEM_dupallocN(channeldriver_copypaste_buf->bezt); fcu->fpt = MEM_dupallocN(channeldriver_copypaste_buf->fpt); fcu->totvert = channeldriver_copypaste_buf->totvert; - + /* modifiers */ copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers); - + /* extrapolation mode */ fcu->extend = channeldriver_copypaste_buf->extend; - + /* the 'juicy' stuff - the driver */ fcu->driver = fcurve_copy_driver(channeldriver_copypaste_buf->driver); } - + /* done */ return (fcu != NULL); } @@ -642,14 +642,14 @@ void ANIM_driver_vars_copybuf_free(void) /* Free the driver variables kept in the buffer */ if (driver_vars_copybuf.first) { DriverVar *dvar, *dvarn; - + /* Free variables (and any data they use) */ for (dvar = driver_vars_copybuf.first; dvar; dvar = dvarn) { dvarn = dvar->next; driver_free_variable(&driver_vars_copybuf, dvar); } } - + BLI_listbase_clear(&driver_vars_copybuf); } @@ -669,18 +669,18 @@ bool ANIM_driver_vars_copy(ReportList *reports, FCurve *fcu) BKE_report(reports, RPT_ERROR, "No driver to copy variables from"); return false; } - + if (BLI_listbase_is_empty(&fcu->driver->variables)) { BKE_report(reports, RPT_ERROR, "Driver has no variables to copy"); return false; } - + /* clear buffer */ ANIM_driver_vars_copybuf_free(); - + /* copy over the variables */ driver_variables_copy(&driver_vars_copybuf, &fcu->driver->variables); - + return (BLI_listbase_is_empty(&driver_vars_copybuf) == false); } @@ -689,55 +689,55 @@ bool ANIM_driver_vars_paste(ReportList *reports, FCurve *fcu, bool replace) { ChannelDriver *driver = (fcu) ? fcu->driver : NULL; ListBase tmp_list = {NULL, NULL}; - + /* sanity checks */ if (BLI_listbase_is_empty(&driver_vars_copybuf)) { BKE_report(reports, RPT_ERROR, "No driver variables in clipboard to paste"); return false; } - + if (ELEM(NULL, fcu, fcu->driver)) { BKE_report(reports, RPT_ERROR, "Cannot paste driver variables without a driver"); return false; } - + /* 1) Make a new copy of the variables in the buffer - these will get pasted later... */ driver_variables_copy(&tmp_list, &driver_vars_copybuf); - + /* 2) Prepare destination array */ if (replace) { DriverVar *dvar, *dvarn; - + /* Free all existing vars first - We aren't retaining anything */ for (dvar = driver->variables.first; dvar; dvar = dvarn) { dvarn = dvar->next; driver_free_variable_ex(driver, dvar); } - + BLI_listbase_clear(&driver->variables); } - + /* 3) Add new vars */ if (driver->variables.last) { DriverVar *last = driver->variables.last; DriverVar *first = tmp_list.first; - + last->next = first; first->prev = last; - + driver->variables.last = tmp_list.last; } else { driver->variables.first = tmp_list.first; driver->variables.last = tmp_list.last; } - + #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ if (driver->type == DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; #endif - + return true; } @@ -754,10 +754,10 @@ EnumPropertyItem prop_driver_create_mapping_types[] = { "Drive all components of this property using the target picked"}, {CREATEDRIVER_MAPPING_1_1, "DIRECT", 0, "Single from Target", "Drive this component of this property using the target picked"}, - + {CREATEDRIVER_MAPPING_N_N, "MATCH", ICON_COLOR, "Match Indices", "Create drivers for each pair of corresponding elements"}, - + {CREATEDRIVER_MAPPING_NONE_ALL, "NONE_ALL", ICON_HAND, "Manually Create Later", "Create drivers for all properties without assigning any targets yet"}, {CREATEDRIVER_MAPPING_NONE, "NONE_SINGLE", 0, "Manually Create Later (Single)", @@ -770,21 +770,21 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN { EnumPropertyItem *input = prop_driver_create_mapping_types; EnumPropertyItem *item = NULL; - + PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; int index; - + int totitem = 0; - + if (!C) /* needed for docs */ return prop_driver_create_mapping_types; - + UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { const bool is_array = RNA_property_array_check(prop); - + while (input->identifier) { if (ELEM(input->value, CREATEDRIVER_MAPPING_1_1, CREATEDRIVER_MAPPING_NONE) || (is_array)) { RNA_enum_item_add(&item, &totitem, input); @@ -796,9 +796,9 @@ static const EnumPropertyItem *driver_mapping_type_itemsf(bContext *C, PointerRN /* We need at least this one! */ RNA_enum_items_add_value(&item, &totitem, input, CREATEDRIVER_MAPPING_NONE); } - + RNA_enum_item_end(&item, &totitem); - + *r_free = true; return item; } @@ -811,7 +811,7 @@ static int add_driver_button_poll(bContext *C) PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; int index; - + /* this operator can only run if there's a property button active, and it can be animated */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); return (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)); @@ -824,28 +824,28 @@ static int add_driver_button_none(bContext *C, wmOperator *op, short mapping_typ PropertyRNA *prop = NULL; int index; int success = 0; - + UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (mapping_type == CREATEDRIVER_MAPPING_NONE_ALL) index = -1; - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; - + if (path) { success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); MEM_freeN(path); } } - + if (success) { /* send updates */ UI_context_update_anim_flag(C); DAG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX - + return OPERATOR_FINISHED; } else { @@ -863,10 +863,10 @@ static int add_driver_button_exec(bContext *C, wmOperator *op) else { /* Create Driver using Eyedropper */ wmOperatorType *ot = WM_operatortype_find("UI_OT_eyedropper_driver", true); - + /* XXX: We assume that it's fine to use the same set of properties, since they're actually the same... */ WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, op->ptr); - + return OPERATOR_FINISHED; } } @@ -875,7 +875,7 @@ static int add_driver_button_exec(bContext *C, wmOperator *op) static int add_driver_button_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { PropertyRNA *prop; - + if ((prop = RNA_struct_find_property(op->ptr, "mapping_type")) && RNA_property_is_set(op->ptr, prop)) { /* Mapping Type is Set - Directly go into creating drivers */ return add_driver_button_exec(C, op); @@ -894,18 +894,18 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) ot->name = "Add Driver"; ot->idname = "ANIM_OT_driver_button_add"; ot->description = "Add driver(s) for the property(s) represented by the highlighted button"; - + /* callbacks */ /* NOTE: No exec, as we need all these to use the current context info * (especially the eyedropper, which is interactive) */ ot->invoke = add_driver_button_invoke; - ot->exec = add_driver_button_exec; + ot->exec = add_driver_button_exec; ot->poll = add_driver_button_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "mapping_type", prop_driver_create_mapping_types, 0, "Mapping Type", "Method used to match target and driven properties"); @@ -921,30 +921,30 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op) short success = 0; int index; const bool all = RNA_boolean_get(op->ptr, "all"); - + /* try to find driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (all) index = -1; - + if (ptr.id.data && ptr.data && prop) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); - + if (path) { success = ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0); MEM_freeN(path); } } - + if (success) { /* send updates */ UI_context_update_anim_flag(C); DAG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } - + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -954,11 +954,11 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) ot->name = "Remove Driver"; ot->idname = "ANIM_OT_driver_button_remove"; ot->description = "Remove the driver(s) for the property(s) connected represented by the highlighted button"; - + /* callbacks */ - ot->exec = remove_driver_button_exec; + ot->exec = remove_driver_button_exec; //op->poll = ??? // TODO: need to have some driver to be able to do this... - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -974,23 +974,23 @@ static int copy_driver_button_exec(bContext *C, wmOperator *op) PropertyRNA *prop = NULL; short success = 0; int index; - + /* try to create driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); - + if (path) { /* only copy the driver for the button that this was involved for */ success = ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0); - + UI_context_update_anim_flag(C); - + MEM_freeN(path); } } - + /* since we're just copying, we don't really need to do anything else...*/ return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1001,11 +1001,11 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot) ot->name = "Copy Driver"; ot->idname = "ANIM_OT_copy_driver_button"; ot->description = "Copy the driver for the highlighted button"; - + /* callbacks */ - ot->exec = copy_driver_button_exec; + ot->exec = copy_driver_button_exec; //op->poll = ??? // TODO: need to have some driver to be able to do this... - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; } @@ -1018,28 +1018,28 @@ static int paste_driver_button_exec(bContext *C, wmOperator *op) PropertyRNA *prop = NULL; short success = 0; int index; - + /* try to create driver using property retrieved from UI */ UI_context_active_but_prop_get(C, &ptr, &prop, &index); - + if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { char *path = BKE_animdata_driver_path_hack(C, &ptr, prop, NULL); - + if (path) { /* only copy the driver for the button that this was involved for */ success = ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0); - + UI_context_update_anim_flag(C); - + DAG_relations_tag_update(CTX_data_main(C)); DAG_id_tag_update(ptr.id.data, OB_RECALC_OB | OB_RECALC_DATA); - + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); // XXX - + MEM_freeN(path); } } - + /* since we're just copying, we don't really need to do anything else...*/ return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1050,11 +1050,11 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot) ot->name = "Paste Driver"; ot->idname = "ANIM_OT_paste_driver_button"; ot->description = "Paste the driver in the copy/paste buffer for the highlighted button"; - + /* callbacks */ - ot->exec = paste_driver_button_exec; + ot->exec = paste_driver_button_exec; //op->poll = ??? // TODO: need to have some driver to be able to do this... - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; } diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index fba18d148c8..951dcc2dddf 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -37,7 +37,7 @@ * Copy/Paste Buffer for F-Modifiers: * For now, this is also defined in this file so that it can be shared between the */ - + #include #include "DNA_anim_types.h" @@ -79,7 +79,7 @@ static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED { FModifier *fcm = (FModifier *)fcm_v; const FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); - + /* call the verify callback on the modifier if applicable */ if (fmi && fmi->verify_data) fmi->verify_data(fcm); @@ -90,19 +90,19 @@ static void delete_fmodifier_cb(bContext *C, void *fmods_v, void *fcm_v) { ListBase *modifiers = (ListBase *)fmods_v; FModifier *fcm = (FModifier *)fcm_v; - + /* remove the given F-Modifier from the active modifier-stack */ remove_fmodifier(modifiers, fcm); ED_undo_push(C, "Delete F-Curve Modifier"); - + /* send notifiers */ - // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case + // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* --------------- */ - + /* draw settings for generator modifier */ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width) { @@ -112,20 +112,20 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiBut *but; PointerRNA ptr; short bwidth = width - 1.5 * UI_UNIT_X; /* max button width */ - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); - + /* basic settings (backdrop + mode selector + some padding) */ /* col = uiLayoutColumn(layout, true); */ /* UNUSED */ block = uiLayoutGetBlock(layout); UI_block_align_begin(block); but = uiDefButR(block, UI_BTYPE_MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL); - + uiDefButR(block, UI_BTYPE_TOGGLE, B_FMODIFIER_REDRAW, NULL, 0, 0, bwidth, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL); UI_block_align_end(block); - + /* now add settings for individual modes */ switch (data->mode) { case FCM_GENERATOR_POLYNOMIAL: /* polynomial expression */ @@ -135,7 +135,7 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s char xval[32]; unsigned int i; int maxXWidth; - + /* draw polynomial order selector */ row = uiLayoutRow(layout, false); block = uiLayoutGetBlock(row); @@ -143,8 +143,8 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s &data->poly_order, 1, 100, 0, 0, TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL); - - + + /* calculate maximum width of label for "x^n" labels */ if (data->arraysize > 2) { BLI_snprintf(xval, sizeof(xval), "x^%u", data->arraysize); @@ -155,11 +155,11 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* basic size (just "x") */ maxXWidth = UI_fontstyle_string_width(fstyle, "x") + 0.5 * UI_UNIT_X; } - + /* draw controls for each coefficient and a + sign at end of row */ row = uiLayoutRow(layout, true); block = uiLayoutGetBlock(row); - + cp = data->coefficients; for (i = 0; (i < data->arraysize) && (cp); i++, cp++) { /* To align with first line... */ @@ -167,11 +167,11 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, UI_BTYPE_LABEL, 1, " ", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); else uiDefBut(block, UI_BTYPE_LABEL, 1, "y =", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - + /* coefficient */ uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, "", 0, 0, bwidth / 2, UI_UNIT_Y, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, TIP_("Coefficient for polynomial")); - + /* 'x' param (and '+' if necessary) */ if (i == 0) BLI_strncpy(xval, "", sizeof(xval)); @@ -180,10 +180,10 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s else BLI_snprintf(xval, sizeof(xval), "x^%u", i); uiDefBut(block, UI_BTYPE_LABEL, 1, xval, 0, 0, maxXWidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Power of x")); - + if ( (i != (data->arraysize - 1)) || ((i == 0) && data->arraysize == 2) ) { uiDefBut(block, UI_BTYPE_LABEL, 1, "+", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - + /* next coefficient on a new row */ row = uiLayoutRow(layout, true); block = uiLayoutGetBlock(row); @@ -195,12 +195,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s } break; } - + case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial expression */ { float *cp = NULL; unsigned int i; - + /* draw polynomial order selector */ row = uiLayoutRow(layout, false); block = uiLayoutGetBlock(row); @@ -208,12 +208,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s &data->poly_order, 1, 100, 0, 0, TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL); - - + + /* draw controls for each pair of coefficients */ row = uiLayoutRow(layout, true); block = uiLayoutGetBlock(row); - + cp = data->coefficients; for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) { /* To align with first line */ @@ -223,25 +223,25 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, UI_BTYPE_LABEL, 1, "y =", 0, 0, 2.5 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); /* opening bracket */ uiDefBut(block, UI_BTYPE_LABEL, 1, "(", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - + /* coefficients */ uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, "", 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y, cp, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, TIP_("Coefficient of x")); - + uiDefBut(block, UI_BTYPE_LABEL, 1, "x +", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - + uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, "", 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y, cp + 1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, TIP_("Second coefficient")); - + /* closing bracket and multiplication sign */ if ( (i != (data->poly_order - 1)) || ((i == 0) && data->poly_order == 2) ) { uiDefBut(block, UI_BTYPE_LABEL, 1, ") \xc3\x97", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - + /* set up new row for the next pair of coefficients */ row = uiLayoutRow(layout, true); block = uiLayoutGetBlock(row); } - else + else uiDefBut(block, UI_BTYPE_LABEL, 1, ") ", 0, 0, 2 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); } break; @@ -256,10 +256,10 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm { uiLayout *col; PointerRNA ptr; - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); - + /* add the settings */ col = uiLayoutColumn(layout, true); uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); @@ -279,21 +279,21 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor { uiLayout *split, *col; PointerRNA ptr; - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifierCycles, fcm, &ptr); - - /* split into 2 columns + + /* split into 2 columns * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room */ split = uiLayoutSplit(layout, 0.5f, false); - + /* before range */ col = uiLayoutColumn(split, true); uiItemL(col, IFACE_("Before:"), ICON_NONE); uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); - + /* after range */ col = uiLayoutColumn(split, true); uiItemL(col, IFACE_("After:"), ICON_NONE); @@ -308,22 +308,22 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short { uiLayout *split, *col; PointerRNA ptr; - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifierNoise, fcm, &ptr); - + /* blending mode */ uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE); - + /* split into 2 columns */ split = uiLayoutSplit(layout, 0.5f, false); - + /* col 1 */ col = uiLayoutColumn(split, false); uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "offset", 0, NULL, ICON_NONE); - + /* col 2 */ col = uiLayoutColumn(split, false); uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); @@ -337,46 +337,46 @@ static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(ar FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; FCM_EnvelopeData fed; - + /* init template data */ fed.min = -1.0f; fed.max = 1.0f; fed.time = (float)scene->r.cfra; // XXX make this int for ease of use? fed.f1 = fed.f2 = 0; - + /* check that no data exists for the current frame... */ if (env->data) { bool exists; int i = BKE_fcm_envelope_find_index(env->data, (float)(scene->r.cfra), env->totvert, &exists); - + /* binarysearch_...() will set exists by default to 0, so if it is non-zero, that means that the point exists already */ if (exists) return; - + /* add new */ fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); - + /* add the points that should occur before the point to be pasted */ if (i > 0) memcpy(fedn, env->data, i * sizeof(FCM_EnvelopeData)); - + /* add point to paste at index i */ *(fedn + i) = fed; - + /* add the points that occur after the point to be pasted */ - if (i < env->totvert) + if (i < env->totvert) memcpy(fedn + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData)); - + /* replace (+ free) old with new */ MEM_freeN(env->data); env->data = fedn; - + env->totvert++; } else { env->data = MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); *(env->data) = fed; - + env->totvert = 1; } } @@ -388,7 +388,7 @@ static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; int index = GET_INT_FROM_POINTER(ind_v); - + /* check that no data exists for the current frame... */ if (env->totvert > 1) { /* allocate a new smaller array */ @@ -396,7 +396,7 @@ static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void memcpy(fedn, env->data, sizeof(FCM_EnvelopeData) * (index)); memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData) * ((env->totvert - index) - 1)); - + /* free old array, and set the new */ MEM_freeN(env->data); env->data = fedn; @@ -422,10 +422,10 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh uiBut *but; PointerRNA ptr; int i; - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr); - + /* general settings */ col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Envelope:"), ICON_NONE); @@ -440,24 +440,24 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh * the current way is far too cramped */ row = uiLayoutRow(layout, false); block = uiLayoutGetBlock(row); - + uiDefBut(block, UI_BTYPE_LABEL, 1, IFACE_("Control Points:"), 0, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); - + but = uiDefBut(block, UI_BTYPE_BUT, B_FMODIFIER_REDRAW, IFACE_("Add Point"), 0, 0, 7.5 * UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame")); UI_but_func_set(but, fmod_envelope_addpoint_cb, env, NULL); - + /* control points list */ for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* get a new row to operate on */ row = uiLayoutRow(layout, true); block = uiLayoutGetBlock(row); - + UI_block_align_begin(block); but = uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, IFACE_("Fra:"), 0, 0, 4.5 * UI_UNIT_X, UI_UNIT_Y, &fed->time, -MAXFRAMEF, MAXFRAMEF, 10, 1, TIP_("Frame that envelope point occurs")); UI_but_func_set(but, validate_fmodifier_cb, fcm, NULL); - + uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, IFACE_("Min:"), 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y, &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Minimum bound of envelope at this point")); uiDefButF(block, UI_BTYPE_NUM, B_FMODIFIER_REDRAW, IFACE_("Max:"), 0, 0, 5 * UI_UNIT_X, UI_UNIT_Y, @@ -477,40 +477,40 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor { uiLayout *split, *col /* , *row */ /* UNUSED */; PointerRNA ptr; - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifierLimits, fcm, &ptr); - + /* row 1: minimum */ { /* row = uiLayoutRow(layout, false); */ /* UNUSED */ - + /* split into 2 columns */ split = uiLayoutSplit(layout, 0.5f, false); - + /* x-minimum */ col = uiLayoutColumn(split, true); uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); - + /* y-minimum*/ col = uiLayoutColumn(split, true); uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); } - + /* row 2: maximum */ { /* row = uiLayoutRow(layout, false); */ /* UNUSED */ - + /* split into 2 columns */ split = uiLayoutSplit(layout, 0.5f, false); - + /* x-minimum */ col = uiLayoutColumn(split, true); uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); - + /* y-minimum*/ col = uiLayoutColumn(split, true); uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); @@ -525,27 +525,27 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho { uiLayout *col, *sub; PointerRNA ptr; - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifierStepped, fcm, &ptr); - + /* block 1: "stepping" settings */ col = uiLayoutColumn(layout, false); uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); - + /* block 2: start range settings */ col = uiLayoutColumn(layout, true); uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); - + sub = uiLayoutColumn(col, true); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); - + /* block 3: end range settings */ col = uiLayoutColumn(layout, true); uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); - + sub = uiLayoutColumn(col, true); uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); @@ -561,125 +561,125 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier uiBut *but; short width = 314; PointerRNA ptr; - + /* init the RNA-pointer */ RNA_pointer_create(id, &RNA_FModifier, fcm, &ptr); - + /* draw header */ { /* get layout-row + UI-block for this */ box = uiLayoutBox(layout); - + row = uiLayoutRow(box, false); block = uiLayoutGetBlock(row); // err... - + /* left-align -------------------------------------------- */ sub = uiLayoutRow(row, true); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); - + UI_block_emboss_set(block, UI_EMBOSS_NONE); - + /* expand */ uiItemR(sub, &ptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - + /* checkbox for 'active' status (for now) */ uiItemR(sub, &ptr, "active", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - + /* name */ if (fmi) uiItemL(sub, IFACE_(fmi->name), ICON_NONE); else uiItemL(sub, IFACE_(""), ICON_NONE); - + /* right-align ------------------------------------------- */ sub = uiLayoutRow(row, true); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); - - + + /* 'mute' button */ uiItemR(sub, &ptr, "mute", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - + UI_block_emboss_set(block, UI_EMBOSS_NONE); - + /* delete button */ but = uiDefIconBut(block, UI_BTYPE_BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier")); UI_but_func_set(but, delete_fmodifier_cb, modifiers, fcm); - + UI_block_emboss_set(block, UI_EMBOSS); } - + /* when modifier is expanded, draw settings */ if (fcm->flag & FMODIFIER_FLAG_EXPANDED) { /* set up the flexible-box layout which acts as the backdrop for the modifier settings */ box = uiLayoutBox(layout); - + /* draw settings for individual modifiers */ switch (fcm->type) { case FMODIFIER_TYPE_GENERATOR: /* Generator */ draw_modifier__generator(box, id, fcm, width); break; - + case FMODIFIER_TYPE_FN_GENERATOR: /* Built-In Function Generator */ draw_modifier__fn_generator(box, id, fcm, width); break; - + case FMODIFIER_TYPE_CYCLES: /* Cycles */ draw_modifier__cycles(box, id, fcm, width); break; - + case FMODIFIER_TYPE_ENVELOPE: /* Envelope */ draw_modifier__envelope(box, id, fcm, width); break; - + case FMODIFIER_TYPE_LIMITS: /* Limits */ draw_modifier__limits(box, id, fcm, width); break; - + case FMODIFIER_TYPE_NOISE: /* Noise */ draw_modifier__noise(box, id, fcm, width); break; - + case FMODIFIER_TYPE_STEPPED: /* Stepped */ draw_modifier__stepped(box, id, fcm, width); break; - + default: /* unknown type */ break; } - + /* one last panel below this: FModifier range */ // TODO: experiment with placement of this { box = uiLayoutBox(layout); - + /* restricted range ----------------------------------------------------- */ col = uiLayoutColumn(box, true); - + /* top row: use restricted range */ row = uiLayoutRow(col, true); uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE); - + if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { /* second row: settings */ row = uiLayoutRow(col, true); - + uiItemR(row, &ptr, "frame_start", 0, IFACE_("Start"), ICON_NONE); uiItemR(row, &ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); - + /* third row: blending influence */ row = uiLayoutRow(col, true); - + uiItemR(row, &ptr, "blend_in", 0, IFACE_("In"), ICON_NONE); uiItemR(row, &ptr, "blend_out", 0, IFACE_("Out"), ICON_NONE); } - + /* influence -------------------------------------------------------------- */ col = uiLayoutColumn(box, true); - + /* top row: use influence */ uiItemR(col, &ptr, "use_influence", 0, NULL, ICON_NONE); - + if (fcm->flag & FMODIFIER_FLAG_USEINFLUENCE) { /* second row: influence value */ uiItemR(col, &ptr, "influence", 0, NULL, ICON_NONE); @@ -710,15 +710,15 @@ void ANIM_fmodifiers_copybuf_free(void) bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active) { bool ok = true; - + /* sanity checks */ if (ELEM(NULL, modifiers, modifiers->first)) return 0; - + /* copy the whole list, or just the active one? */ if (active) { FModifier *fcm = find_active_fmodifier(modifiers); - + if (fcm) { FModifier *fcmN = copy_fmodifier(fcm); BLI_addtail(&fmodifier_copypaste_buf, fcmN); @@ -728,44 +728,44 @@ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active) } else copy_fmodifiers(&fmodifier_copypaste_buf, modifiers); - + /* did we succeed? */ return ok; } -/* 'Paste' the F-Modifier(s) from the buffer to the specified list +/* 'Paste' the F-Modifier(s) from the buffer to the specified list * - replace: free all the existing modifiers to leave only the pasted ones */ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, FCurve *curve) { FModifier *fcm; bool ok = false; - + /* sanity checks */ if (modifiers == NULL) return 0; - + bool was_cyclic = curve && BKE_fcurve_is_cyclic(curve); /* if replacing the list, free the existing modifiers */ if (replace) free_fmodifiers(modifiers); - + /* now copy over all the modifiers in the buffer to the end of the list */ for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) { /* make a copy of it */ FModifier *fcmN = copy_fmodifier(fcm); fcmN->curve = curve; - + /* make sure the new one isn't active, otherwise the list may get several actives */ fcmN->flag &= ~FMODIFIER_FLAG_ACTIVE; - + /* now add it to the end of the list */ BLI_addtail(modifiers, fcmN); ok = 1; } - + /* adding or removing the Cycles modifier requires an update to handles */ if (curve && BKE_fcurve_is_cyclic(curve) != was_cyclic) calchandles_fcurve(curve); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index f25dbf2381c..6e786873950 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -71,10 +71,10 @@ short compare_ak_cfraPtr(void *node, void *data) ActKeyColumn *ak = (ActKeyColumn *)node; const float *cframe = data; float val = *cframe; - + if (IS_EQT(val, ak->cfra, BEZT_BINARYSEARCH_THRESH)) return 0; - + if (val < ak->cfra) return -1; else if (val > ak->cfra) @@ -90,7 +90,7 @@ static short compare_ak_bezt(void *node, void *data) { ActKeyColumn *ak = (ActKeyColumn *)node; BezTriple *bezt = (BezTriple *)data; - + if (bezt->vec[1][0] < ak->cfra) return -1; else if (bezt->vec[1][0] > ak->cfra) @@ -104,15 +104,15 @@ static DLRBT_Node *nalloc_ak_bezt(void *data) { ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn"); BezTriple *bezt = (BezTriple *)data; - + /* store settings based on state of BezTriple */ ak->cfra = bezt->vec[1][0]; ak->sel = BEZT_ISSEL_ANY(bezt) ? SELECT : 0; ak->key_type = BEZKEYTYPE(bezt); - + /* set 'modified', since this is used to identify long keyframes */ ak->modified = 1; - + return (DLRBT_Node *)ak; } @@ -121,11 +121,11 @@ static void nupdate_ak_bezt(void *node, void *data) { ActKeyColumn *ak = (ActKeyColumn *)node; BezTriple *bezt = (BezTriple *)data; - + /* set selection status and 'touched' status */ if (BEZT_ISSEL_ANY(bezt)) ak->sel = SELECT; ak->modified += 1; - + /* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */ if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) ak->key_type = BEZT_KEYTYPE_KEYFRAME; @@ -138,7 +138,7 @@ static short compare_ak_gpframe(void *node, void *data) { ActKeyColumn *ak = (ActKeyColumn *)node; bGPDframe *gpf = (bGPDframe *)data; - + if (gpf->framenum < ak->cfra) return -1; else if (gpf->framenum > ak->cfra) @@ -152,15 +152,15 @@ static DLRBT_Node *nalloc_ak_gpframe(void *data) { ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF"); bGPDframe *gpf = (bGPDframe *)data; - + /* store settings based on state of BezTriple */ ak->cfra = gpf->framenum; ak->sel = (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0; ak->key_type = gpf->key_type; - + /* set 'modified', since this is used to identify long keyframes */ ak->modified = 1; - + return (DLRBT_Node *)ak; } @@ -169,11 +169,11 @@ static void nupdate_ak_gpframe(void *node, void *data) { ActKeyColumn *ak = (ActKeyColumn *)node; bGPDframe *gpf = (bGPDframe *)data; - + /* set selection status and 'touched' status */ if (gpf->flag & GP_FRAME_SELECT) ak->sel = SELECT; ak->modified += 1; - + /* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */ if (gpf->key_type == BEZT_KEYTYPE_KEYFRAME) ak->key_type = BEZT_KEYTYPE_KEYFRAME; @@ -261,7 +261,7 @@ short compare_ab_cfraPtr(void *node, void *data) ActKeyBlock *ab = (ActKeyBlock *)node; const float *cframe = data; float val = *cframe; - + if (val < ab->start) return -1; else if (val > ab->start) @@ -276,17 +276,17 @@ short compare_ab_cfraPtr(void *node, void *data) static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn) { ActKeyBlock *ab = MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock"); - + ab->start = prev->vec[1][0]; ab->end = beztn->vec[1][0]; ab->val = beztn->vec[1][1]; - + ab->sel = (BEZT_ISSEL_ANY(prev) || BEZT_ISSEL_ANY(beztn)) ? SELECT : 0; ab->modified = 1; - + if (BEZKEYTYPE(beztn) == BEZT_KEYTYPE_MOVEHOLD) ab->flag |= ACTKEYBLOCK_FLAG_MOVING_HOLD; - + return ab; } @@ -294,25 +294,25 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt { ActKeyBlock *new_ab = NULL; BezTriple *prev = NULL; - + /* get the BezTriple immediately before the given one which has the same value */ if (beztn != first_bezt) { - /* XXX: Unless I'm overlooking some details from the past, this should be sufficient? + /* XXX: Unless I'm overlooking some details from the past, this should be sufficient? * The old code did some elaborate stuff trying to find keyframe columns for * the given BezTriple, then step backwards to the column before that, and find * an appropriate BezTriple with matching values there. Maybe that was warranted - * in the past, but now, that list is only ever filled with keyframes from the + * in the past, but now, that list is only ever filled with keyframes from the * current FCurve. * * -- Aligorith (20140415) */ prev = beztn - 1; } - - + + /* check if block needed */ if (prev == NULL) return; - + if (BEZKEYTYPE(beztn) == BEZT_KEYTYPE_MOVEHOLD) { /* Animator tagged a "moving hold" * - Previous key must also be tagged as a moving hold, otherwise @@ -328,11 +328,11 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt * - Handles which control that section of the curve must be constant */ if (IS_EQF(beztn->vec[1][1], prev->vec[1][1]) == 0) return; - + if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1]) == 0) return; if (IS_EQF(prev->vec[1][1], prev->vec[2][1]) == 0) return; } - + /* if there are no blocks already, just add as root */ if (blocks->root == NULL) { /* just add this as the root, then call the tree-balancing functions to validate */ @@ -341,7 +341,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt } else { ActKeyBlock *ab, *abn = NULL; - + /* try to find a keyblock that starts on the previous beztriple, and add a new one if none start there * Note: we perform a tree traversal here NOT a standard linked-list traversal... * Note: we can't search from end to try to optimize this as it causes errors there's @@ -352,32 +352,32 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt // A|------------------------------------------------|A // A|----|A|---|A|-----------------------------------|A for (ab = blocks->root; ab; ab = abn) { - /* check if this is a match, or whether we go left or right + /* check if this is a match, or whether we go left or right * NOTE: we now use a float threshold to prevent precision errors causing problems with summaries */ if (IS_EQT(ab->start, prev->vec[1][0], BEZT_BINARYSEARCH_THRESH)) { /* set selection status and 'touched' status */ if (BEZT_ISSEL_ANY(beztn)) ab->sel = SELECT; - + /* XXX: only when the first one was a moving hold? */ if (BEZKEYTYPE(beztn) == BEZT_KEYTYPE_MOVEHOLD) ab->flag |= ACTKEYBLOCK_FLAG_MOVING_HOLD; - + ab->modified++; - + /* done... no need to insert */ return; } else { ActKeyBlock **abnp = NULL; /* branch to go down - used to hook new blocks to parents */ - + /* check if go left or right, but if not available, add new node */ - if (ab->start < prev->vec[1][0]) + if (ab->start < prev->vec[1][0]) abnp = &ab->right; else abnp = &ab->left; - + /* if this does not exist, add a new node, otherwise continue... */ if (*abnp == NULL) { /* add a new node representing this, and attach it to the relevant place */ @@ -391,7 +391,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, BezTriple *first_bezt } } } - + /* now, balance the tree taking into account this newly added node */ BLI_dlrbTree_insert(blocks, (DLRBT_Node *)new_ab); } @@ -404,13 +404,13 @@ static void set_touched_actkeycolumn(ActKeyColumn *ak) /* sanity check */ if (ak == NULL) return; - + /* deal with self first */ if (ak->modified) { ak->modified = 0; ak->totcurve++; } - + /* children */ set_touched_actkeycolumn(ak->left); set_touched_actkeycolumn(ak->right); @@ -422,13 +422,13 @@ static void set_touched_actkeyblock(ActKeyBlock *ab) /* sanity check */ if (ab == NULL) return; - + /* deal with self first */ if (ab->modified) { ab->modified = 0; ab->totcurve++; } - + /* children */ set_touched_actkeyblock(ab->left); set_touched_actkeyblock(ab->right); @@ -441,22 +441,22 @@ bool actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys) { ActKeyColumn *ak; short startCurves, endCurves, totCurves; - + /* check that block is valid */ if (ab == NULL) return 0; - + /* find out how many curves occur at each keyframe */ ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); startCurves = (ak) ? ak->totcurve : 0; - + ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); endCurves = (ak) ? ak->totcurve : 0; - + /* only draw keyblock if it appears in at all of the keyframes at lowest end */ - if (!startCurves && !endCurves) + if (!startCurves && !endCurves) return 0; - + totCurves = (startCurves > endCurves) ? endCurves : startCurves; return (ab->totcurve >= totCurves); } @@ -469,19 +469,19 @@ static const float _unit_diamond_shape[4][2] = { {1.0f, 0.0f}, /* mid-right */ {0.0f, -1.0f}, /* bottom vert */ {-1.0f, 0.0f} /* mid-left */ -}; +}; /* draw a simple diamond shape with OpenGL */ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha) { static GLuint displist1 = 0; static GLuint displist2 = 0; - + /* initialize 2 display lists for diamond shape - one empty, one filled */ if (displist1 == 0) { displist1 = glGenLists(1); glNewList(displist1, GL_COMPILE); - + glBegin(GL_LINE_LOOP); glVertex2fv(_unit_diamond_shape[0]); glVertex2fv(_unit_diamond_shape[1]); @@ -494,7 +494,7 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, if (displist2 == 0) { displist2 = glGenLists(1); glNewList(displist2, GL_COMPILE); - + glBegin(GL_QUADS); glVertex2fv(_unit_diamond_shape[0]); glVertex2fv(_unit_diamond_shape[1]); @@ -504,43 +504,43 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, glEndList(); } - - /* tweak size of keyframe shape according to type of keyframe + + /* tweak size of keyframe shape according to type of keyframe * - 'proper' keyframes have key_type = 0, so get drawn at full size */ switch (key_type) { case BEZT_KEYTYPE_KEYFRAME: /* must be full size */ break; - + case BEZT_KEYTYPE_BREAKDOWN: /* slightly smaller than normal keyframe */ hsize *= 0.85f; break; - + case BEZT_KEYTYPE_MOVEHOLD: /* slightly smaller than normal keyframes (but by less than for breakdowns) */ //hsize *= 0.72f; hsize *= 0.95f; break; - + case BEZT_KEYTYPE_EXTREME: /* slightly larger */ hsize *= 1.2f; break; - + default: hsize -= 0.5f * key_type; break; } - + /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); glScalef(1.0f / xscale * hsize, hsize, 1.0f); - + /* anti-aliased lines for more consistent appearance */ glEnable(GL_LINE_SMOOTH); - + /* draw! */ if (ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH)) { float inner_col[4]; - + /* get interior colors from theme (for selected and unselected only) */ switch (key_type) { case BEZT_KEYTYPE_BREAKDOWN: /* bluish frames (default theme) */ @@ -566,7 +566,7 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, /* XXX: Should these get their own theme options instead? */ if (sel) UI_GetThemeColorShade4fv(TH_STRIP_SELECT, 35, inner_col); else UI_GetThemeColorShade4fv(TH_STRIP, 50, inner_col); - + inner_col[3] = 1.0f; /* full opacity, to avoid problems with visual glitches */ break; } @@ -578,32 +578,32 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, break; } } - - /* NOTE: we don't use the straight alpha from the theme, or else effects such as + + /* NOTE: we don't use the straight alpha from the theme, or else effects such as * graying out protected/muted channels doesn't work correctly! */ inner_col[3] *= alpha; glColor4fv(inner_col); - + /* draw the "filled in" interior poly now */ glCallList(displist2); } - + if (ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH)) { float border_col[4]; - + /* exterior - black frame */ if (sel) UI_GetThemeColor4fv(TH_KEYBORDER_SELECT, border_col); else UI_GetThemeColor4fv(TH_KEYBORDER, border_col); - + border_col[3] *= alpha; glColor4fv(border_col); - + glCallList(displist1); } - + glDisable(GL_LINE_SMOOTH); - + /* restore view transform */ glScalef(xscale / hsize, 1.0f / hsize, 1.0f); glTranslatef(-x, -y, 0.0f); @@ -615,36 +615,36 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa ActKeyBlock *ab; float alpha; float xscale; - + const float iconsize = (U.widget_unit / 4.0f) * yscale_fac; const float mhsize = iconsize * 0.7f; - + glEnable(GL_BLEND); - + /* get View2D scaling factor */ UI_view2d_scale_get(v2d, &xscale, NULL); - + /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */ /* TODO: allow this opacity factor to be themed? */ alpha = (channelLocked) ? 0.25f : 1.0f; - + /* draw keyblocks */ if (blocks) { float sel_color[4], unsel_color[4]; float sel_mhcol[4], unsel_mhcol[4]; - + /* cache colours first */ UI_GetThemeColor4fv(TH_STRIP_SELECT, sel_color); UI_GetThemeColor4fv(TH_STRIP, unsel_color); - + sel_color[3] *= alpha; unsel_color[3] *= alpha; - + copy_v4_v4(sel_mhcol, sel_color); sel_mhcol[3] *= 0.8f; copy_v4_v4(unsel_mhcol, unsel_color); unsel_mhcol[3] *= 0.8f; - + /* NOTE: the tradeoff for changing colors between each draw is dwarfed by the cost of checking validity */ for (ab = blocks->first; ab; ab = ab->next) { if (actkeyblock_is_valid(ab, keys)) { @@ -654,7 +654,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa glColor4fv(sel_mhcol); else glColor4fv(unsel_mhcol); - + glRectf(ab->start, ypos - mhsize, ab->end, ypos + mhsize); } else { @@ -663,13 +663,13 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa glColor4fv(sel_color); else glColor4fv(unsel_color); - + glRectf(ab->start, ypos - iconsize, ab->end, ypos + iconsize); } } } } - + /* draw keys */ if (keys) { for (ak = keys->first; ak; ak = ak->next) { @@ -678,7 +678,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa */ if (IN_RANGE_INCL(ak->cfra, v2d->cur.xmin, v2d->cur.xmax) == 0) continue; - + /* draw using OpenGL - uglier but faster */ /* NOTE1: a previous version of this didn't work nice for some intel cards * NOTE2: if we wanted to go back to icons, these are icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3; */ @@ -694,17 +694,17 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos, float yscale_fac) { DLRBT_Tree keys, blocks; - + BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - + summary_to_keylist(ac, &keys, &blocks); - + BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - + draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, false); - + BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); } @@ -712,17 +712,17 @@ void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos, float yscal void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos, float yscale_fac) { DLRBT_Tree keys, blocks; - + BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - + scene_to_keylist(ads, sce, &keys, &blocks); - + BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - + draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, false); - + BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); } @@ -730,17 +730,17 @@ void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos, fl void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos, float yscale_fac) { DLRBT_Tree keys, blocks; - + BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - + ob_to_keylist(ads, ob, &keys, &blocks); - + BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - + draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, false); - + BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); } @@ -748,21 +748,21 @@ void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos, f void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos, float yscale_fac) { DLRBT_Tree keys, blocks; - + bool locked = (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || ((adt && adt->action) && ID_IS_LINKED(adt->action)); - + BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - + fcurve_to_keylist(adt, fcu, &keys, &blocks); - + BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - + draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, locked); - + BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); } @@ -770,20 +770,20 @@ void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos, fl void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float ypos, float yscale_fac) { DLRBT_Tree keys, blocks; - + bool locked = (agrp->flag & AGRP_PROTECTED) || ((adt && adt->action) && ID_IS_LINKED(adt->action)); - + BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - + agroup_to_keylist(adt, agrp, &keys, &blocks); - + BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - + draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, locked); - + BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); } @@ -791,19 +791,19 @@ void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float y void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos, float yscale_fac) { DLRBT_Tree keys, blocks; - + bool locked = (act && ID_IS_LINKED(act)); - + BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - + action_to_keylist(adt, act, &keys, &blocks); - + BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - + draw_keylist(v2d, &keys, &blocks, ypos, yscale_fac, locked); - + BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); } @@ -811,49 +811,49 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos, f void draw_gpencil_channel(View2D *v2d, bDopeSheet *ads, bGPdata *gpd, float ypos, float yscale_fac) { DLRBT_Tree keys; - + BLI_dlrbTree_init(&keys); - + gpencil_to_keylist(ads, gpd, &keys); - + BLI_dlrbTree_linkedlist_sync(&keys); - + draw_keylist(v2d, &keys, NULL, ypos, yscale_fac, false); - + BLI_dlrbTree_free(&keys); } void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos, float yscale_fac) { DLRBT_Tree keys; - + bool locked = (gpl->flag & GP_LAYER_LOCKED) != 0; - + BLI_dlrbTree_init(&keys); - + gpl_to_keylist(ads, gpl, &keys); - + BLI_dlrbTree_linkedlist_sync(&keys); - + draw_keylist(v2d, &keys, NULL, ypos, yscale_fac, locked); - + BLI_dlrbTree_free(&keys); } void draw_masklay_channel(View2D *v2d, bDopeSheet *ads, MaskLayer *masklay, float ypos, float yscale_fac) { DLRBT_Tree keys; - + bool locked = (masklay->flag & MASK_LAYERFLAG_LOCKED) != 0; - + BLI_dlrbTree_init(&keys); - + mask_to_keylist(ads, masklay, &keys); - + BLI_dlrbTree_linkedlist_sync(&keys); - + draw_keylist(v2d, &keys, NULL, ypos, yscale_fac, locked); - + BLI_dlrbTree_free(&keys); } @@ -865,11 +865,11 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get F-Curves to take keyframes from */ filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through each F-Curve, grabbing the keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { /* Why not use all #eAnim_KeyType here? @@ -892,7 +892,7 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) break; } } - + ANIM_animdata_freelist(&anim_data); } } @@ -903,66 +903,66 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + bAnimListElem dummychan = {NULL}; - + if (sce == NULL) return; - + /* create a dummy wrapper data to work with */ dummychan.type = ANIMTYPE_SCENE; dummychan.data = sce; dummychan.id = &sce->id; dummychan.adt = sce->adt; - + ac.ads = ads; ac.data = &dummychan; ac.datatype = ANIMCONT_CHANNEL; - + /* get F-Curves to take keyframes from */ filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop through each F-Curve, grabbing the keyframes */ for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); - + ANIM_animdata_freelist(&anim_data); } void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *blocks) -{ +{ bAnimContext ac = {NULL}; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + bAnimListElem dummychan = {NULL}; Base dummybase = {NULL}; - + if (ob == NULL) return; - + /* create a dummy wrapper data to work with */ dummybase.object = ob; - + dummychan.type = ANIMTYPE_OBJECT; dummychan.data = &dummybase; dummychan.id = &ob->id; dummychan.adt = ob->adt; - + ac.ads = ads; ac.data = &dummychan; ac.datatype = ANIMCONT_CHANNEL; - + /* get F-Curves to take keyframes from */ filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop through each F-Curve, grabbing the keyframes */ for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); - + ANIM_animdata_freelist(&anim_data); } @@ -1006,19 +1006,19 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree /* apply NLA-mapping (if applicable) */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0); - + /* loop through beztriples, making ActKeysColumns and ActKeyBlocks */ for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++) { add_bezt_to_keycolumns_list(keys, bezt); if (blocks) add_bezt_to_keyblocks_list(blocks, fcu->bezt, bezt); } - + /* update the number of curves that elements have appeared in */ if (keys) set_touched_actkeycolumn(keys->root); if (blocks) set_touched_actkeyblock(blocks->root); - + /* unapply NLA-mapping if applicable */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 0); @@ -1053,7 +1053,7 @@ void action_to_keylist(AnimData *adt, bAction *act, DLRBT_Tree *keys, DLRBT_Tree void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, DLRBT_Tree *keys) { bGPDlayer *gpl; - + if (gpd && keys) { /* for now, just aggregate out all the frames, but only for visible layers */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { @@ -1067,7 +1067,7 @@ void gpencil_to_keylist(bDopeSheet *ads, bGPdata *gpd, DLRBT_Tree *keys) void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys) { bGPDframe *gpf; - + if (gpl && keys) { /* although the frames should already be in an ordered list, they are not suitable for displaying yet */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 4e42229e50d..6b24008c4d8 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -73,11 +73,11 @@ /* --------------------------- Base Functions ------------------------------------ */ -/* This function is used to loop over BezTriples in the given F-Curve, applying a given +/* This function is used to loop over BezTriples in the given F-Curve, applying a given * operation on them, and optionally applies an F-Curve validation function afterwards. */ // TODO: make this function work on samples too... -short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb) +short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb) { BezTriple *bezt; short ok = 0; @@ -96,7 +96,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi /* if function to apply to bezier curves is set, then loop through executing it on beztriples */ if (key_cb) { - /* if there's a validation func, include that check in the loop + /* if there's a validation func, include that check in the loop * (this is should be more efficient than checking for it in every loop) */ if (key_ok) { @@ -106,11 +106,11 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi ked->curIndex = i; ked->curflags = 0; } - + /* Only operate on this BezTriple if it fullfills the criteria of the validation func */ if ((ok = key_ok(ked, bezt))) { if (ked) ked->curflags = ok; - + /* Exit with return-code '1' if function returns positive * This is useful if finding if some BezTriple satisfies a condition. */ @@ -121,7 +121,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi else { for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { if (ked) ked->curIndex = i; - + /* Exit with return-code '1' if function returns positive * This is useful if finding if some BezTriple satisfies a condition. */ @@ -129,7 +129,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi } } } - + /* unset the F-Curve from the editdata now that it's done */ if (ked) { ked->fcu = NULL; @@ -140,7 +140,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi /* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */ if (fcu_cb) fcu_cb(fcu); - + /* done */ return 0; } @@ -151,17 +151,17 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb) { FCurve *fcu; - + /* sanity check */ if (agrp == NULL) return 0; - + /* only iterate over the F-Curves that are in this group */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) { if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) return 1; } - + return 0; } @@ -169,17 +169,17 @@ static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, Keyf static short act_keyframes_loop(KeyframeEditData *ked, bAction *act, KeyframeEditFunc key_ok, KeyframeEditFunc key_cb, FcuEditFunc fcu_cb) { FCurve *fcu; - + /* sanity check */ if (act == NULL) return 0; - + /* just loop through all F-Curves */ for (fcu = act->curves.first; fcu; fcu = fcu->next) { if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) return 1; } - + return 0; } @@ -191,29 +191,29 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o bAnimListElem *ale; int filter; int ret = 0; - + bAnimListElem dummychan = {NULL}; Base dummybase = {NULL}; - + if (ob == NULL) return 0; - + /* create a dummy wrapper data to work with */ dummybase.object = ob; - + dummychan.type = ANIMTYPE_OBJECT; dummychan.data = &dummybase; dummychan.id = &ob->id; dummychan.adt = ob->adt; - + ac.ads = ads; ac.data = &dummychan; ac.datatype = ANIMCONT_CHANNEL; - + /* get F-Curves to take keyframes from */ filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ for (ale = anim_data.first; ale; ale = ale->next) { if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { @@ -221,9 +221,9 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o break; } } - + ANIM_animdata_freelist(&anim_data); - + /* return return code - defaults to zero if nothing happened */ return ret; } @@ -236,26 +236,26 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene bAnimListElem *ale; int filter; int ret = 0; - + bAnimListElem dummychan = {NULL}; - + if (sce == NULL) return 0; - + /* create a dummy wrapper data to work with */ dummychan.type = ANIMTYPE_SCENE; dummychan.data = sce; dummychan.id = &sce->id; dummychan.adt = sce->adt; - + ac.ads = ads; ac.data = &dummychan; ac.datatype = ANIMCONT_CHANNEL; - + /* get F-Curves to take keyframes from */ filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ for (ale = anim_data.first; ale; ale = ale->next) { if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { @@ -263,9 +263,9 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene break; } } - + ANIM_animdata_freelist(&anim_data); - + /* return return code - defaults to zero if nothing happened */ return ret; } @@ -276,22 +276,22 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter, ret_code = 0; - + /* sanity check */ if (ac == NULL) return 0; - + /* get F-Curves to take keyframes from */ filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through each F-Curve, working on the keyframes until the first curve aborts */ for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->datatype) { case ALE_MASKLAY: case ALE_GPFRAME: break; - + case ALE_FCURVE: default: { @@ -301,19 +301,19 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key */ float f1 = ked->f1; float f2 = ked->f2; - + if (ked->iterflags & (KED_F1_NLA_UNMAP | KED_F2_NLA_UNMAP)) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (ked->iterflags & KED_F1_NLA_UNMAP) ked->f1 = BKE_nla_tweakedit_remap(adt, f1, NLATIME_CONVERT_UNMAP); if (ked->iterflags & KED_F2_NLA_UNMAP) ked->f2 = BKE_nla_tweakedit_remap(adt, f2, NLATIME_CONVERT_UNMAP); } - + /* now operate on the channel as per normal */ ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb); - + /* reset */ ked->f1 = f1; ked->f2 = f2; @@ -325,13 +325,13 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key break; } } - + if (ret_code) break; } - + ANIM_animdata_freelist(&anim_data); - + return ret_code; } @@ -343,21 +343,21 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bA /* sanity checks */ if (ale == NULL) return 0; - + /* method to use depends on the type of keyframe data */ switch (ale->datatype) { /* direct keyframe data (these loops are exposed) */ case ALE_FCURVE: /* F-Curve */ return ANIM_fcurve_keyframes_loop(ked, ale->key_data, key_ok, key_cb, fcu_cb); - - /* indirect 'summaries' (these are not exposed directly) + + /* indirect 'summaries' (these are not exposed directly) * NOTE: must keep this code in sync with the drawing code and also the filtering code! */ case ALE_GROUP: /* action group */ return agrp_keyframes_loop(ked, (bActionGroup *)ale->data, key_ok, key_cb, fcu_cb); case ALE_ACT: /* action */ return act_keyframes_loop(ked, (bAction *)ale->key_data, key_ok, key_cb, fcu_cb); - + case ALE_OB: /* object */ return ob_keyframes_loop(ked, ads, (Object *)ale->key_data, key_ok, key_cb, fcu_cb); case ALE_SCE: /* scene */ @@ -365,7 +365,7 @@ short ANIM_animchannel_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, bA case ALE_ALL: /* 'all' (DopeSheet summary) */ return summary_keyframes_loop(ked, (bAnimContext *)ale->data, key_ok, key_cb, fcu_cb); } - + return 0; } @@ -375,21 +375,21 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads /* sanity checks */ if (data == NULL) return 0; - + /* method to use depends on the type of keyframe data */ switch (keytype) { /* direct keyframe data (these loops are exposed) */ case ALE_FCURVE: /* F-Curve */ return ANIM_fcurve_keyframes_loop(ked, data, key_ok, key_cb, fcu_cb); - - /* indirect 'summaries' (these are not exposed directly) + + /* indirect 'summaries' (these are not exposed directly) * NOTE: must keep this code in sync with the drawing code and also the filtering code! */ case ALE_GROUP: /* action group */ return agrp_keyframes_loop(ked, (bActionGroup *)data, key_ok, key_cb, fcu_cb); case ALE_ACT: /* action */ return act_keyframes_loop(ked, (bAction *)data, key_ok, key_cb, fcu_cb); - + case ALE_OB: /* object */ return ob_keyframes_loop(ked, ads, (Object *)data, key_ok, key_cb, fcu_cb); case ALE_SCE: /* scene */ @@ -397,7 +397,7 @@ short ANIM_animchanneldata_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads case ALE_ALL: /* 'all' (DopeSheet summary) */ return summary_keyframes_loop(ked, (bAnimContext *)data, key_ok, key_cb, fcu_cb); } - + return 0; } @@ -411,20 +411,20 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter animation data */ filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop over F-Curves that are likely to have been edited, and check them */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = ale->key_data; - + /* make sure keyframes in F-Curve are all in order, and handles are in valid positions */ sort_time_fcurve(fcu); calchandles_fcurve(fcu); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); } @@ -435,7 +435,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) /* ------------------------ */ /* Some macros to make this easier... */ -/* run the given check on the 3 handles +/* run the given check on the 3 handles * - check should be a macro, which takes the handle index as its single arg, which it substitutes later * - requires that a var, of type short, is named 'ok', and has been initialized to 0 */ @@ -454,16 +454,16 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) } (void)0 /* ------------------------ */ - + static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt) { short ok = 0; - + /* frame is stored in f1 property (this float accuracy check may need to be dropped?) */ #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][0], ked->f1) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK - + /* return ok flags */ return ok; } @@ -471,19 +471,19 @@ static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt) static short ok_bezier_framerange(KeyframeEditData *ked, BezTriple *bezt) { short ok = 0; - + /* frame range is stored in float properties */ #define KEY_CHECK_OK(_index) ((bezt->vec[_index][0] > ked->f1) && (bezt->vec[_index][0] < ked->f2)) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK - + /* return ok flags */ return ok; } static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - /* this macro checks all beztriple handles for selection... + /* this macro checks all beztriple handles for selection... * only one of the verts has to be selected for this to be ok... */ if (BEZT_ISSEL_ANY(bezt)) @@ -493,17 +493,17 @@ static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt) } static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt) -{ +{ short ok = 0; - - /* value is stored in f1 property + + /* value is stored in f1 property * - this float accuracy check may need to be dropped? * - should value be stored in f2 instead so that we won't have conflicts when using f1 for frames too? */ #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][1], ked->f1) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK - + /* return ok flags */ return ok; } @@ -511,12 +511,12 @@ static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt) static short ok_bezier_valuerange(KeyframeEditData *ked, BezTriple *bezt) { short ok = 0; - + /* value range is stored in float properties */ #define KEY_CHECK_OK(_index) ((bezt->vec[_index][1] > ked->f1) && (bezt->vec[_index][1] < ked->f2)) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK - + /* return ok flags */ return ok; } @@ -526,15 +526,15 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) /* rect is stored in data property (it's of type rectf, but may not be set) */ if (ked->data) { short ok = 0; - + #define KEY_CHECK_OK(_index) BLI_rctf_isect_pt_v(ked->data, bezt->vec[_index]) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK - + /* return ok flags */ return ok; } - else + else return 0; } @@ -547,9 +547,9 @@ bool keyframe_region_lasso_test( { if (BLI_rctf_isect_pt_v(data_lasso->rectf_scaled, xy)) { float xy_view[2]; - + BLI_rctf_transform_pt_v(data_lasso->rectf_view, data_lasso->rectf_scaled, xy_view, xy); - + if (BLI_lasso_is_point_inside(data_lasso->mcords, data_lasso->mcords_tot, xy_view[0], xy_view[1], INT_MAX)) { return true; } @@ -563,11 +563,11 @@ static short ok_bezier_region_lasso(KeyframeEditData *ked, BezTriple *bezt) /* check for lasso customdata (KeyframeEdit_LassoData) */ if (ked->data) { short ok = 0; - + #define KEY_CHECK_OK(_index) keyframe_region_lasso_test(ked->data, bezt->vec[_index]) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK - + /* return ok flags */ return ok; } @@ -581,7 +581,7 @@ static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt) if (ked->data) { KeyframeEdit_LassoData *data = ked->data; float pt[2]; - + /* late-binding remap of the x values (for summary channels) */ /* XXX: Ideally we reset, but it should be fine just leaving it as-is * as the next channel will reset it properly, while the next summary-channel @@ -591,11 +591,11 @@ static short ok_bezier_channel_lasso(KeyframeEditData *ked, BezTriple *bezt) data->rectf_scaled->xmin = ked->f1; data->rectf_scaled->xmax = ked->f2; } - + /* only use the x-coordinate of the point; the y is the channel range... */ pt[0] = bezt->vec[1][0]; pt[1] = ked->channel_y; - + if (keyframe_region_lasso_test(data, pt)) return KEYFRAME_OK_KEY; } @@ -611,14 +611,14 @@ bool keyframe_region_circle_test( { if (BLI_rctf_isect_pt_v(data_circle->rectf_scaled, xy)) { float xy_view[2]; - + BLI_rctf_transform_pt_v(data_circle->rectf_view, data_circle->rectf_scaled, xy_view, xy); - + xy_view[0] = xy_view[0] - data_circle->mval[0]; xy_view[1] = xy_view[1] - data_circle->mval[1]; return len_squared_v2(xy_view) < data_circle->radius_squared; } - + return false; } @@ -628,11 +628,11 @@ static short ok_bezier_region_circle(KeyframeEditData *ked, BezTriple *bezt) /* check for circle select customdata (KeyframeEdit_CircleData) */ if (ked->data) { short ok = 0; - + #define KEY_CHECK_OK(_index) keyframe_region_circle_test(ked->data, bezt->vec[_index]) KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK - + /* return ok flags */ return ok; } @@ -646,7 +646,7 @@ static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt) if (ked->data) { KeyframeEdit_CircleData *data = ked->data; float pt[2]; - + /* late-binding remap of the x values (for summary channels) */ /* XXX: Ideally we reset, but it should be fine just leaving it as-is * as the next channel will reset it properly, while the next summary-channel @@ -656,11 +656,11 @@ static short ok_bezier_channel_circle(KeyframeEditData *ked, BezTriple *bezt) data->rectf_scaled->xmin = ked->f1; data->rectf_scaled->xmax = ked->f2; } - + /* only use the x-coordinate of the point; the y is the channel range... */ pt[0] = bezt->vec[1][0]; pt[1] = ked->channel_y; - + if (keyframe_region_circle_test(data, pt)) return KEYFRAME_OK_KEY; } @@ -707,16 +707,16 @@ short bezt_calc_average(KeyframeEditData *ked, BezTriple *bezt) if (bezt->f2 & SELECT) { /* store average time in float 1 (only do rounding at last step) */ ked->f1 += bezt->vec[1][0]; - - /* store average value in float 2 (only do rounding at last step) + + /* store average value in float 2 (only do rounding at last step) * - this isn't always needed, but some operators may also require this */ ked->f2 += bezt->vec[1][1]; - + /* increment number of items */ ked->i1++; } - + return 0; } @@ -727,10 +727,10 @@ short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt) if (bezt->f2 & SELECT) { CfraElem *ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked->list, ce); - + ce->cfra = bezt->vec[1][0]; } - + return 0; } @@ -741,10 +741,10 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt) { KeyframeEditCD_Remap *rmap = (KeyframeEditCD_Remap *)ked->data; const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin); - + /* perform transform on all three handles unless indicated otherwise */ // TODO: need to include some checks for that - + bezt->vec[0][0] = scale * (bezt->vec[0][0] - rmap->oldMin) + rmap->newMin; bezt->vec[1][0] = scale * (bezt->vec[1][0] - rmap->oldMin) + rmap->newMin; bezt->vec[2][0] = scale * (bezt->vec[2][0] - rmap->oldMin) + rmap->newMin; @@ -766,7 +766,7 @@ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt) { const Scene *scene = ked->scene; const float secf = (float)FPS; - + if (bezt->f2 & SELECT) bezt->vec[1][0] = (floorf(bezt->vec[1][0] / secf + 0.5f) * secf); return 0; @@ -794,7 +794,7 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be { if (bezt->f2 & SELECT) { bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1]; - + if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1 = HD_ALIGN; if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2 = HD_ALIGN; } @@ -871,11 +871,11 @@ static void mirror_bezier_yaxis_ex(BezTriple *bezt, const float center) static short mirror_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) { const Scene *scene = ked->scene; - + if (bezt->f2 & SELECT) { mirror_bezier_xaxis_ex(bezt, CFRA); } - + return 0; } @@ -885,7 +885,7 @@ static short mirror_bezier_yaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) /* Yes, names are inverted, we are mirroring accross y axis, hence along x axis... */ mirror_bezier_xaxis_ex(bezt, 0.0f); } - + return 0; } @@ -895,7 +895,7 @@ static short mirror_bezier_xaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) /* Yes, names are inverted, we are mirroring accross x axis, hence along y axis... */ mirror_bezier_yaxis_ex(bezt, 0.0f); } - + return 0; } @@ -905,7 +905,7 @@ static short mirror_bezier_marker(KeyframeEditData *ked, BezTriple *bezt) if (bezt->f2 & SELECT) { mirror_bezier_xaxis_ex(bezt, ked->f1); } - + return 0; } @@ -915,7 +915,7 @@ static short mirror_bezier_time(KeyframeEditData *ked, BezTriple *bezt) if (bezt->f2 & SELECT) { mirror_bezier_xaxis_ex(bezt, ked->f1); } - + return 0; } @@ -925,7 +925,7 @@ static short mirror_bezier_value(KeyframeEditData *ked, BezTriple *bezt) if (bezt->f2 & SELECT) { mirror_bezier_yaxis_ex(bezt, ked->f1); } - + return 0; } @@ -941,7 +941,7 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type) case MIRROR_KEYS_XAXIS: /* mirror over value 0 */ return mirror_bezier_xaxis; case MIRROR_KEYS_MARKER: /* mirror over marker */ - return mirror_bezier_marker; + return mirror_bezier_marker; case MIRROR_KEYS_TIME: /* mirror over frame/time */ return mirror_bezier_time; case MIRROR_KEYS_VALUE: /* mirror over given value */ @@ -966,12 +966,12 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type) } (void)0 /* Sets the selected bezier handles to type 'auto' */ -static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO; if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO; - + ENSURE_HANDLES_MATCH(bezt); } return 0; @@ -980,19 +980,19 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) /* Sets the selected bezier handles to type 'auto-clamped' * NOTE: this is like auto above, but they're handled a bit different */ -static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO_ANIM; if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO_ANIM; - + ENSURE_HANDLES_MATCH(bezt); } return 0; } /* Sets the selected bezier handles to type 'vector' */ -static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f1 & SELECT) bezt->h1 = HD_VECT; if (bezt->f3 & SELECT) bezt->h2 = HD_VECT; @@ -1002,7 +1002,7 @@ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) /* Queries if the handle should be set to 'free' or 'align' */ // NOTE: this was used for the 'toggle free/align' option // currently this isn't used, but may be restored later -static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if ((bezt->f1 & SELECT) && (bezt->h1)) return 1; if ((bezt->f3 & SELECT) && (bezt->h2)) return 1; @@ -1010,15 +1010,15 @@ static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt) } /* Sets selected bezier handles to type 'align' */ -static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt) -{ +static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +{ if (bezt->f1 & SELECT) bezt->h1 = HD_ALIGN; if (bezt->f3 & SELECT) bezt->h2 = HD_ALIGN; return 0; } /* Sets selected bezier handles to type 'free' */ -static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f1 & SELECT) bezt->h1 = HD_FREE; if (bezt->f3 & SELECT) bezt->h2 = HD_FREE; @@ -1034,14 +1034,14 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code) return set_bezier_auto; case HD_AUTO_ANIM: /* auto clamped */ return set_bezier_auto_clamped; - + case HD_VECT: /* vector */ return set_bezier_vector; case HD_FREE: /* free */ return set_bezier_free; case HD_ALIGN: /* align */ return set_bezier_align; - + default: /* check for toggle free or align? */ return bezier_isfree; } @@ -1049,23 +1049,23 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code) /* ------- */ -static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) bezt->ipo = BEZT_IPO_CONST; return 0; } -static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) bezt->ipo = BEZT_IPO_LIN; return 0; } -static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) bezt->ipo = BEZT_IPO_BEZ; return 0; } @@ -1150,7 +1150,7 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code) return set_bezt_constant; case BEZT_IPO_LIN: /* linear */ return set_bezt_linear; - + /* easing */ case BEZT_IPO_BACK: return set_bezt_back; @@ -1172,7 +1172,7 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code) return set_bezt_quint; case BEZT_IPO_SINE: return set_bezt_sine; - + default: /* bezier */ return set_bezt_bezier; } @@ -1180,37 +1180,37 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code) /* ------- */ -static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME; return 0; } -static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN; return 0; } -static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME; return 0; } -static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER; return 0; } -static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short set_keytype_moving_hold(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f2 & SELECT) + if (bezt->f2 & SELECT) BEZKEYTYPE(bezt) = BEZT_KEYTYPE_MOVEHOLD; return 0; } @@ -1221,16 +1221,16 @@ KeyframeEditFunc ANIM_editkeyframes_keytype(short code) switch (code) { case BEZT_KEYTYPE_BREAKDOWN: /* breakdown */ return set_keytype_breakdown; - + case BEZT_KEYTYPE_EXTREME: /* extreme keyframe */ return set_keytype_extreme; - + case BEZT_KEYTYPE_JITTER: /* jitter keyframe */ return set_keytype_jitter; - + case BEZT_KEYTYPE_MOVEHOLD: /* moving hold */ return set_keytype_moving_hold; - + case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */ default: return set_keytype_keyframe; @@ -1273,13 +1273,13 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode) switch (mode) { case BEZT_IPO_EASE_IN: /* ease in */ return set_easingtype_easein; - + case BEZT_IPO_EASE_OUT: /* ease out */ return set_easingtype_easeout; - + case BEZT_IPO_EASE_IN_OUT: /* both */ return set_easingtype_easeinout; - + default: /* auto */ return set_easingtype_easeauto; } @@ -1288,7 +1288,7 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode) /* ******************************************* */ /* Selection */ -static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt) +static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt) { /* if we've got info on what to select, use it, otherwise select all */ if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { @@ -1302,11 +1302,11 @@ static short select_bezier_add(KeyframeEditData *ked, BezTriple *bezt) else { BEZT_SEL_ALL(bezt); } - + return 0; } -static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt) +static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt) { /* if we've got info on what to deselect, use it, otherwise deselect all */ if ((ked) && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { @@ -1320,11 +1320,11 @@ static short select_bezier_subtract(KeyframeEditData *ked, BezTriple *bezt) else { BEZT_DESEL_ALL(bezt); } - + return 0; } -static short select_bezier_invert(KeyframeEditData *UNUSED(ked), BezTriple *bezt) +static short select_bezier_invert(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { /* Invert the selection for the whole bezier triple */ bezt->f2 ^= SELECT; @@ -1369,33 +1369,33 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt) FCurve *fcu = ked->fcu; char *map = ked->data; int i = ked->curIndex; - + /* if current is selected, just make sure it stays this way */ if (BEZT_ISSEL_ANY(bezt)) { map[i] = 1; return 0; } - + /* if previous is selected, that means that selection should extend across */ if (i > 0) { BezTriple *prev = bezt - 1; - + if (BEZT_ISSEL_ANY(prev)) { map[i] = 1; return 0; } } - + /* if next is selected, that means that selection should extend across */ if (i < (fcu->totvert - 1)) { BezTriple *next = bezt + 1; - + if (BEZT_ISSEL_ANY(next)) { map[i] = 1; return 0; } } - + return 0; } @@ -1404,7 +1404,7 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) FCurve *fcu = ked->fcu; char *map = ked->data; int i = ked->curIndex; - + /* if current is selected, check the left/right keyframes * since it might need to be deselected (but otherwise no) */ @@ -1412,7 +1412,7 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) /* if previous is not selected, we're on the tip of an iceberg */ if (i > 0) { BezTriple *prev = bezt - 1; - + if (BEZT_ISSEL_ANY(prev) == 0) return 0; } @@ -1420,11 +1420,11 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) /* current keyframe is selected at an endpoint, so should get deselected */ return 0; } - + /* if next is not selected, we're on the tip of an iceberg */ if (i < (fcu->totvert - 1)) { BezTriple *next = bezt + 1; - + if (BEZT_ISSEL_ANY(next) == 0) return 0; } @@ -1432,11 +1432,11 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) /* current keyframe is selected at an endpoint, so should get deselected */ return 0; } - + /* if we're still here, that means that keyframe should remain untouched */ map[i] = 1; } - + return 0; } @@ -1446,7 +1446,7 @@ KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode) switch (mode) { case SELMAP_LESS: /* less */ return selmap_build_bezier_less; - + case SELMAP_MORE: /* more */ default: return selmap_build_bezier_more; @@ -1460,7 +1460,7 @@ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt) { const char *map = ked->data; short on = map[ked->curIndex]; - + /* select or deselect based on whether the map allows it or not */ if (on) { BEZT_SEL_ALL(bezt); @@ -1468,7 +1468,7 @@ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt) else { BEZT_DESEL_ALL(bezt); } - + return 0; } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 7d5fbeb7e3b..f8af504f1ed 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -68,19 +68,19 @@ * * - Joshua Leung, Dec 2008 */ - + /* **************************************************** */ -/* Only delete the nominated keyframe from provided F-Curve. +/* Only delete the nominated keyframe from provided F-Curve. * Not recommended to be used many times successively. For that * there is delete_fcurve_keys(). */ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc) { /* sanity check */ - if (fcu == NULL) + if (fcu == NULL) return; - + /* verify the index: * 1) cannot be greater than the number of available keyframes * 2) negative indices are for specifying a value from the end of the array @@ -89,7 +89,7 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc) return; else if (index < 0) index += fcu->totvert; - + /* Delete this keyframe */ memmove(&fcu->bezt[index], &fcu->bezt[index + 1], sizeof(BezTriple) * (fcu->totvert - index - 1)); fcu->totvert--; @@ -99,7 +99,7 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc) MEM_freeN(fcu->bezt); fcu->bezt = NULL; } - + /* recalc handles - only if it won't cause problems */ if (do_recalc) calchandles_fcurve(fcu); @@ -110,7 +110,7 @@ bool delete_fcurve_keys(FCurve *fcu) { int i; bool changed = false; - + if (fcu->bezt == NULL) /* ignore baked curves */ return false; @@ -123,7 +123,7 @@ bool delete_fcurve_keys(FCurve *fcu) changed = true; } } - + /* Free the array of BezTriples if there are not keyframes */ if (fcu->totvert == 0) clear_fcurve_keys(fcu); @@ -148,30 +148,30 @@ void duplicate_fcurve_keys(FCurve *fcu) { BezTriple *newbezt; int i; - + /* this can only work when there is an F-Curve, and also when there are some BezTriples */ if (ELEM(NULL, fcu, fcu->bezt)) return; - + for (i = 0; i < fcu->totvert; i++) { /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { /* Expand the list */ newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple"); - + memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof(BezTriple) * (fcu->totvert - (i + 1))); fcu->totvert++; - + /* reassign pointers... (free old, and add new) */ MEM_freeN(fcu->bezt); fcu->bezt = newbezt; - + /* Unselect the current key */ BEZT_DESEL_ALL(&fcu->bezt[i]); i++; - + /* Select the copied key */ BEZT_SEL_ALL(&fcu->bezt[i]); } @@ -189,7 +189,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo BezTriple *old_bezts, *bezt, *beztn; BezTriple *lastb; int totCount, i; - + /* check if any points */ if ((fcu == NULL) || (fcu->bezt == NULL) || (fcu->totvert == 0) || (!cleardefault && fcu->totvert == 1)) @@ -202,7 +202,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo totCount = fcu->totvert; fcu->bezt = NULL; fcu->totvert = 0; - + /* now insert first keyframe, as it should be ok */ bezt = old_bezts; insert_vert_fcurve(fcu, bezt->vec[1][0], bezt->vec[1][1], BEZKEYTYPE(bezt), 0); @@ -210,8 +210,8 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo lastb = fcu->bezt; lastb->f1 = lastb->f2 = lastb->f3 = 0; } - - /* Loop through BezTriples, comparing them. Skip any that do + + /* Loop through BezTriples, comparing them. Skip any that do * not fit the criteria for "ok" points. */ for (i = 1; i < totCount; i++) { @@ -228,22 +228,22 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo } lastb = (fcu->bezt + (fcu->totvert - 1)); bezt = (old_bezts + i); - + /* get references for quicker access */ prev[0] = lastb->vec[1][0]; prev[1] = lastb->vec[1][1]; cur[0] = bezt->vec[1][0]; cur[1] = bezt->vec[1][1]; - + if (!(bezt->f2 & SELECT)) { insert_vert_fcurve(fcu, cur[0], cur[1], BEZKEYTYPE(bezt), 0); lastb = (fcu->bezt + (fcu->totvert - 1)); lastb->f1 = lastb->f2 = lastb->f3 = 0; continue; } - + /* check if current bezt occurs at same time as last ok */ if (IS_EQT(cur[0], prev[0], thresh)) { - /* If there is a next beztriple, and if occurs at the same time, only insert - * if there is a considerable distance between the points, and also if the + /* If there is a next beztriple, and if occurs at the same time, only insert + * if there is a considerable distance between the points, and also if the * current is further away than the next one is to the previous. */ if (beztn && (IS_EQT(cur[0], next[0], thresh)) && @@ -287,7 +287,7 @@ void clean_fcurve(struct bAnimContext *ac, bAnimListElem *ale, float thresh, boo } } } - + /* now free the memory used by the old BezTriples */ if (old_bezts) MEM_freeN(old_bezts); @@ -346,14 +346,14 @@ void smooth_fcurve(FCurve *fcu) if (BEZT_ISSEL_ANY(bezt)) totSel++; } - + /* if any points were selected, allocate tSmooth_Bezt points to work on */ if (totSel >= 3) { tSmooth_Bezt *tarray, *tsb; - + /* allocate memory in one go */ tsb = tarray = MEM_callocN(totSel * sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); - + /* populate tarray with data of selected points */ bezt = fcu->bezt; for (i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { @@ -362,7 +362,7 @@ void smooth_fcurve(FCurve *fcu) tsb->h1 = &bezt->vec[0][1]; tsb->h2 = &bezt->vec[1][1]; tsb->h3 = &bezt->vec[2][1]; - + /* advance to the next tsb to populate */ if (x < totSel - 1) tsb++; @@ -370,15 +370,15 @@ void smooth_fcurve(FCurve *fcu) break; } } - + /* calculate the new smoothed F-Curve's with weighted averages: * - this is done with two passes to avoid progressive corruption errors * - uses 5 points for each operation (which stores in the relevant handles) * - previous: w/a ratio = 3:5:2:1:1 * - next: w/a ratio = 1:1:2:5:3 */ - - /* round 1: calculate smoothing deltas and new values */ + + /* round 1: calculate smoothing deltas and new values */ tsb = tarray; for (i = 0; i < totSel; i++, tsb++) { /* don't touch end points (otherwise, curves slowly explode, as we don't have enough data there) */ @@ -387,21 +387,21 @@ void smooth_fcurve(FCurve *fcu) const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (NULL); const tSmooth_Bezt *tN1 = tsb + 1; const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (NULL); - + const float p1 = *tP1->h2; const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); const float c1 = *tsb->h2; const float n1 = *tN1->h2; const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); - + /* calculate previous and next, then new position by averaging these */ tsb->y1 = (3 * p2 + 5 * p1 + 2 * c1 + n1 + n2) / 12; tsb->y3 = (p2 + p1 + 2 * c1 + 5 * n1 + 3 * n2) / 12; - + tsb->y2 = (tsb->y1 + tsb->y3) / 2; } } - + /* round 2: apply new values */ tsb = tarray; for (i = 0; i < totSel; i++, tsb++) { @@ -409,17 +409,17 @@ void smooth_fcurve(FCurve *fcu) if (ELEM(i, 0, (totSel - 1)) == 0) { /* y2 takes the average of the 2 points */ *tsb->h2 = tsb->y2; - + /* handles are weighted between their original values and the averaged values */ - *tsb->h1 = ((*tsb->h1) * 0.7f) + (tsb->y1 * 0.3f); + *tsb->h1 = ((*tsb->h1) * 0.7f) + (tsb->y1 * 0.3f); *tsb->h3 = ((*tsb->h3) * 0.7f) + (tsb->y3 * 0.3f); } } - + /* free memory required for tarray */ MEM_freeN(tarray); } - + /* recalculate handles */ calchandles_fcurve(fcu); } @@ -442,7 +442,7 @@ void sample_fcurve(FCurve *fcu) if (fcu->bezt == NULL) /* ignore baked */ return; - + /* find selected keyframes... once pair has been found, add keyframes */ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if selected, and which end this is */ @@ -459,39 +459,39 @@ void sample_fcurve(FCurve *fcu) continue; } } - + /* set end */ end = bezt; - + /* cache values then add keyframes using these values, as adding * keyframes while sampling will affect the outcome... * - only start sampling+adding from index=1, so that we don't overwrite original keyframe */ range = (int)(ceil(end->vec[1][0] - start->vec[1][0])); sfra = (int)(floor(start->vec[1][0])); - + if (range) { value_cache = MEM_callocN(sizeof(TempFrameValCache) * range, "IcuFrameValCache"); - + /* sample values */ for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { fp->frame = (float)(sfra + n); fp->val = evaluate_fcurve(fcu, fp->frame); } - + /* add keyframes with these, tagging as 'breakdowns' */ for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { insert_vert_fcurve(fcu, fp->frame, fp->val, BEZT_KEYTYPE_BREAKDOWN, 1); } - + /* free temp cache */ MEM_freeN(value_cache); - + /* as we added keyframes, we need to compensate so that bezt is at the right place */ bezt = fcu->bezt + i + range - 1; i += (range - 1); } - + /* the current selection island has ended, so start again from scratch */ start = NULL; end = NULL; @@ -503,14 +503,14 @@ void sample_fcurve(FCurve *fcu) } } } - + /* recalculate channel's handles? */ calchandles_fcurve(fcu); } /* **************************************************** */ /* Copy/Paste Tools */ -/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes +/* - The copy/paste buffer currently stores a set of temporary F-Curves containing only the keyframes * that were selected in each of the original F-Curves * - All pasted frames are offset by the same amount. This is calculated as the difference in the times of * the current frame and the 'first keyframe' (i.e. the earliest one in all channels). @@ -526,12 +526,12 @@ static float animcopy_cfra = 0.0; /* datatype for use in copy/paste buffer */ typedef struct tAnimCopybufItem { struct tAnimCopybufItem *next, *prev; - + ID *id; /* ID which owns the curve */ bActionGroup *grp; /* Action Group */ char *rna_path; /* RNA-Path */ int array_index; /* array index */ - + int totvert; /* number of keyframes stored for this channel */ BezTriple *bezt; /* keyframes in buffer */ @@ -544,23 +544,23 @@ typedef struct tAnimCopybufItem { void ANIM_fcurves_copybuf_free(void) { tAnimCopybufItem *aci, *acn; - + /* free each buffer element */ for (aci = animcopybuf.first; aci; aci = acn) { acn = aci->next; - + /* free keyframes */ - if (aci->bezt) + if (aci->bezt) MEM_freeN(aci->bezt); - + /* free RNA-path */ if (aci->rna_path) MEM_freeN(aci->rna_path); - + /* free ourself */ BLI_freelinkN(&animcopybuf, aci); } - + /* restore initial state */ BLI_listbase_clear(&animcopybuf); animcopy_firstframe = 999999999.0f; @@ -571,27 +571,27 @@ void ANIM_fcurves_copybuf_free(void) /* This function adds data to the keyframes copy/paste buffer, freeing existing data first */ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) -{ +{ bAnimListElem *ale; Scene *scene = ac->scene; - + /* clear buffer first */ ANIM_fcurves_copybuf_free(); - + /* assume that each of these is an F-Curve */ for (ale = anim_data->first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; tAnimCopybufItem *aci; BezTriple *bezt, *nbezt, *newbuf; int i; - + /* firstly, check if F-Curve has any selected keyframes * - skip if no selected keyframes found (so no need to create unnecessary copy-buffer data) * - this check should also eliminate any problems associated with using sample-data */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ANIM_editkeyframes_ok(BEZT_OK_SELECTED), NULL) == 0) continue; - + /* init copybuf item info */ aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem"); aci->id = ale->id; @@ -599,7 +599,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) aci->grp = fcu->grp; aci->rna_path = MEM_dupallocN(fcu->rna_path); aci->array_index = fcu->array_index; - + /* detect if this is a bone. We do that here rather than during pasting because ID pointers will get invalidated if we undo. * storing the relevant information here helps avoiding crashes if we undo-repaste */ if ((aci->id_type == ID_OB) && (((Object *)aci->id)->type == OB_ARMATURE) && aci->rna_path) { @@ -614,9 +614,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) } if (bone_name) MEM_freeN(bone_name); } - + BLI_addtail(&animcopybuf, aci); - + /* add selected keyframes to buffer */ /* TODO: currently, we resize array every time we add a new vert - * this works ok as long as it is assumed only a few keys are copied */ @@ -624,23 +624,23 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) if (BEZT_ISSEL_ANY(bezt)) { /* add to buffer */ newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple"); - + /* assume that since we are just re-sizing the array, just copy all existing data across */ if (aci->bezt) memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert)); - + /* copy current beztriple across too */ nbezt = &newbuf[aci->totvert]; *nbezt = *bezt; - + /* ensure copy buffer is selected so pasted keys are selected */ BEZT_SEL_ALL(nbezt); - + /* free old array and set the new */ if (aci->bezt) MEM_freeN(aci->bezt); aci->bezt = newbuf; aci->totvert++; - + /* check if this is the earliest frame encountered so far */ if (bezt->vec[1][0] < animcopy_firstframe) animcopy_firstframe = bezt->vec[1][0]; @@ -648,9 +648,9 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) animcopy_lastframe = bezt->vec[1][0]; } } - + } - + /* check if anything ended up in the buffer */ if (ELEM(NULL, animcopybuf.first, animcopybuf.last)) return -1; @@ -740,7 +740,7 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f * more involved since it needs to to path lookups. * This is not 100% reliable since the user could be editing the curves on a path that wont * resolve, or a bone could be renamed after copying for eg. but in normal copy & paste - * this should work out ok. + * this should work out ok. */ if (BLI_findindex(which_libbase(G.main, aci->id_type), aci->id) == -1) { /* pedantic but the ID could have been removed, and beats crashing! */ @@ -749,9 +749,9 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f else { PointerRNA id_ptr, rptr; PropertyRNA *prop; - + RNA_id_pointer_create(aci->id, &id_ptr); - + if (RNA_path_resolve_property(&id_ptr, aci->rna_path, &rptr, &prop)) { const char *identifier = RNA_property_identifier(prop); int len_id = strlen(identifier); @@ -804,7 +804,7 @@ static void do_curve_mirror_flippping(tAnimCopybufItem *aci, BezTriple *bezt) flip = true; else if (BLI_strn_endswith(aci->rna_path, "rotation_axis_angle", slength) && ELEM(aci->array_index, 2, 3)) flip = true; - + if (flip) { bezt->vec[0][1] = -bezt->vec[0][1]; bezt->vec[1][1] = -bezt->vec[1][1]; @@ -829,18 +829,18 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float case KEYFRAME_PASTE_MERGE_MIX: /* do-nothing */ break; - + case KEYFRAME_PASTE_MERGE_OVER: /* remove all keys */ clear_fcurve_keys(fcu); break; - + case KEYFRAME_PASTE_MERGE_OVER_RANGE: case KEYFRAME_PASTE_MERGE_OVER_RANGE_ALL: { float f_min; float f_max; - + if (merge_mode == KEYFRAME_PASTE_MERGE_OVER_RANGE) { f_min = aci->bezt[0].vec[1][0] + offset; f_max = aci->bezt[aci->totvert - 1].vec[1][0] + offset; @@ -849,7 +849,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float f_min = animcopy_firstframe + offset; f_max = animcopy_lastframe + offset; } - + /* remove keys in range */ if (f_min < f_max) { /* select verts in range for removal */ @@ -858,39 +858,39 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float bezt->f2 |= SELECT; } } - + /* remove frames in the range */ delete_fcurve_keys(fcu); } break; } } - + /* just start pasting, with the first keyframe on the current frame, and so on */ for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) { /* temporarily apply offset to src beztriple while copying */ if (flip) do_curve_mirror_flippping(aci, bezt); - + bezt->vec[0][0] += offset; bezt->vec[1][0] += offset; bezt->vec[2][0] += offset; - + /* insert the keyframe * NOTE: we do not want to inherit handles from existing keyframes in this case! */ - + insert_bezt_fcurve(fcu, bezt, INSERTKEY_OVERWRITE_FULL); - + /* un-apply offset from src beztriple after copying */ bezt->vec[0][0] -= offset; bezt->vec[1][0] -= offset; bezt->vec[2][0] -= offset; - + if (flip) do_curve_mirror_flippping(aci, bezt); } - + /* recalculate F-Curve's handles? */ calchandles_fcurve(fcu); } @@ -921,12 +921,12 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip) { bAnimListElem *ale; - + const Scene *scene = (ac->scene); - + const bool from_single = BLI_listbase_is_single(&animcopybuf); const bool to_simple = BLI_listbase_is_single(anim_data); - + float offset = 0.0f; int pass; @@ -940,7 +940,7 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, BKE_report(ac->reports, RPT_ERROR, "No selected F-Curves to paste into"); return -1; } - + /* methods of offset */ switch (offset_mode) { case KEYFRAME_PASTE_OFFSET_CFRA_START: @@ -961,25 +961,25 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, /* 1:1 match, no tricky checking, just paste */ FCurve *fcu; tAnimCopybufItem *aci; - + ale = anim_data->first; fcu = (FCurve *)ale->data; /* destination F-Curve */ aci = animcopybuf.first; - + paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, false); ale->update |= ANIM_UPDATE_DEFAULT; } else { - /* from selected channels + /* from selected channels * This "passes" system aims to try to find "matching" channels to paste keyframes * into with increasingly loose matching heuristics. The process finishes when at least * one F-Curve has been pasted into. */ for (pass = 0; pass < 3; pass++) { unsigned int totmatch = 0; - + for (ale = anim_data->first; ale; ale = ale->next) { - /* find buffer item to paste from + /* find buffer item to paste from * - if names don't matter (i.e. only 1 channel in buffer), don't check id/group * - if names do matter, only check if id-type is ok for now (group check is not that important) * - most importantly, rna-paths should match (array indices are unimportant for now) @@ -987,28 +987,28 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */ tAnimCopybufItem *aci = NULL; - + switch (pass) { case 0: /* most strict, must be exact path match data_path & index */ aci = pastebuf_match_path_full(fcu, from_single, to_simple, flip); break; - + case 1: /* less strict, just compare property names */ aci = pastebuf_match_path_property(fcu, from_single, to_simple); break; - + case 2: /* Comparing properties gave no results, so just do index comparisons */ aci = pastebuf_match_index_only(fcu, from_single, to_simple); break; } - + /* copy the relevant data from the matching buffer curve */ if (aci) { totmatch++; - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, flip); @@ -1018,16 +1018,16 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode, flip); } } - + ale->update |= ANIM_UPDATE_DEFAULT; } - + /* don't continue if some fcurves were pasted */ if (totmatch) break; } } - + ANIM_animdata_update(ac, anim_data); return 0; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 7fb540e2c1b..0bb35dcbf3e 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -29,7 +29,7 @@ * \ingroup edanimation */ - + #include #include #include @@ -91,42 +91,42 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode) { eInsertKeyFlags flag = INSERTKEY_NOFLAGS; - + /* standard flags */ { /* visual keying */ - if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY)) + if (IS_AUTOKEY_FLAG(scene, AUTOMATKEY)) flag |= INSERTKEY_MATRIX; - + /* only needed */ - if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) + if (IS_AUTOKEY_FLAG(scene, INSERTNEEDED)) flag |= INSERTKEY_NEEDED; - + /* default F-Curve color mode - RGB from XYZ indices */ - if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) + if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) flag |= INSERTKEY_XYZ2RGB; } - + /* only if including settings from the autokeying mode... */ if (incl_mode) { /* keyframing mode - only replace existing keyframes */ - if (IS_AUTOKEY_MODE(scene, EDITKEYS)) + if (IS_AUTOKEY_MODE(scene, EDITKEYS)) flag |= INSERTKEY_REPLACE; } - + return flag; } /* ******************************************* */ /* Animation Data Validation */ -/* Get (or add relevant data to be able to do so) the Active Action for the given +/* Get (or add relevant data to be able to do so) the Active Action for the given * Animation Data block, given an ID block where the Animation Data should reside. */ bAction *verify_adt_action(ID *id, short add) { AnimData *adt; - + /* init animdata if none available yet */ adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) @@ -143,10 +143,10 @@ bAction *verify_adt_action(ID *id, short add) /* init action name from name of ID block */ char actname[sizeof(id->name) - 2]; BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); - + /* create action */ adt->action = BKE_action_add(G.main, actname); - + /* set ID-type from ID-block that this is going to be assigned to * so that users can't accidentally break actions by assigning them * to the wrong places @@ -157,59 +157,59 @@ bAction *verify_adt_action(ID *id, short add) /* XXX: we probably should have bmain passed down, but that involves altering too many API's */ DAG_relations_tag_update(G.main); } - + /* return the action */ return adt->action; } -/* Get (or add relevant data to be able to do so) F-Curve from the Active Action, +/* Get (or add relevant data to be able to do so) F-Curve from the Active Action, * for the given Animation Data block. This assumes that all the destinations are valid. */ -FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, +FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, const char rna_path[], const int array_index, short add) { bActionGroup *agrp; FCurve *fcu; - + /* sanity checks */ if (ELEM(NULL, act, rna_path)) return NULL; - - /* try to find f-curve matching for this setting + + /* try to find f-curve matching for this setting * - add if not found and allowed to add one * TODO: add auto-grouping support? how this works will need to be resolved */ fcu = list_find_fcurve(&act->curves, rna_path, array_index); - + if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); fcu->auto_smoothing = FCURVE_SMOOTH_CONT_ACCEL; if (BLI_listbase_is_empty(&act->curves)) fcu->flag |= FCURVE_ACTIVE; /* first one added active */ - + /* store path - make copy, and store that */ fcu->rna_path = BLI_strdup(rna_path); fcu->array_index = array_index; - + /* if a group name has been provided, try to add or find a group, then add F-Curve to it */ if (group) { /* try to find group */ agrp = BKE_action_group_find_name(act, group); - + /* no matching groups, so add one */ if (agrp == NULL) { agrp = action_groups_add_new(act, group); - + /* sync bone group colors if applicable */ if (ptr && (ptr->type == &RNA_PoseBone)) { Object *ob = (Object *)ptr->id.data; bPoseChannel *pchan = (bPoseChannel *)ptr->data; bPose *pose = ob->pose; bActionGroup *grp; - + /* find bone group (if present), and use the color from that */ grp = (bActionGroup *)BLI_findlink(&pose->agroups, (pchan->agrp_index - 1)); if (grp) { @@ -218,7 +218,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, } } } - + /* add F-Curve to group */ action_groups_add_channel(act, agrp, fcu); } @@ -227,7 +227,7 @@ FCurve *verify_fcurve(bAction *act, const char group[], PointerRNA *ptr, BLI_addtail(&act->curves, fcu); } } - + /* return the F-Curve */ return fcu; } @@ -280,10 +280,10 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin idname, fcu->rna_path); return; } - + /* update F-Curve flags */ update_autoflags_fcurve_direct(fcu, prop); - + if (old_flag != fcu->flag) { /* Same as if keyframes had been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); @@ -295,7 +295,7 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin /* -------------- BezTriple Insertion -------------------- */ -/* This function adds a given BezTriple to an F-Curve. It will allocate +/* This function adds a given BezTriple to an F-Curve. It will allocate * memory for the array if needed, and will insert the BezTriple into a * suitable place in chronological order. * @@ -305,12 +305,12 @@ void update_autoflags_fcurve(FCurve *fcu, bContext *C, ReportList *reports, Poin int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) { int i = 0; - + /* are there already keyframes? */ if (fcu->bezt) { bool replace; i = binarysearch_bezt_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace); - + /* replace an existing keyframe? */ if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ @@ -322,16 +322,16 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) /* just change the values when replacing, so as to not overwrite handles */ BezTriple *dst = (fcu->bezt + i); float dy = bezt->vec[1][1] - dst->vec[1][1]; - + /* just apply delta value change to the handle values */ dst->vec[0][1] += dy; dst->vec[1][1] += dy; dst->vec[2][1] += dy; - + dst->f1 = bezt->f1; dst->f2 = bezt->f2; dst->f3 = bezt->f3; - + /* TODO: perform some other operations? */ } } @@ -340,29 +340,29 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) else if ((flag & INSERTKEY_REPLACE) == 0) { /* insert new - if we're not restricted to replacing keyframes only */ BezTriple *newb = MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple"); - + /* add the beztriples that should occur before the beztriple to be pasted (originally in fcu) */ if (i > 0) memcpy(newb, fcu->bezt, i * sizeof(BezTriple)); - + /* add beztriple to paste at index i */ *(newb + i) = *bezt; - + /* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */ - if (i < fcu->totvert) + if (i < fcu->totvert) memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple)); - + /* replace (+ free) old with new, only if necessary to do so */ MEM_freeN(fcu->bezt); fcu->bezt = newb; - + fcu->totvert++; } } /* no keyframes already, but can only add if... * 1) keyframing modes say that keyframes can only be replaced, so adding new ones won't know * 2) there are no samples on the curve - * // NOTE: maybe we may want to allow this later when doing samples -> bezt conversions, + * // NOTE: maybe we may want to allow this later when doing samples -> bezt conversions, * // but for now, having both is asking for trouble */ else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == NULL)) { @@ -376,9 +376,9 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) /* return error code -1 to prevent any misunderstandings */ return -1; } - - - /* we need to return the index, so that some tools which do post-processing can + + + /* we need to return the index, so that some tools which do post-processing can * detect where we added the BezTriple in the array */ return i; @@ -398,8 +398,8 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke BezTriple beztr = {{{0}}}; unsigned int oldTot = fcu->totvert; int a; - - /* set all three points, for nicer start position + + /* set all three points, for nicer start position * NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok... */ beztr.vec[0][0] = x - 1.0f; @@ -409,7 +409,7 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke beztr.vec[2][0] = x + 1.0f; beztr.vec[2][1] = y; beztr.f1 = beztr.f2 = beztr.f3 = SELECT; - + /* set default handle types and interpolation mode */ if (flag & INSERTKEY_NO_USERPREF) { /* for Py-API, we want scripts to have predictable behaviour, @@ -421,11 +421,11 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke else { /* for UI usage - defaults should come from the userprefs and/or toolsettings */ beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */ - + /* use default interpolation mode, with exceptions for int/discrete values */ beztr.ipo = U.ipo_new; } - + /* interpolation type used is constrained by the type of values the curve can take */ if (fcu->flag & FCURVE_DISCRETE_VALUES) { beztr.ipo = BEZT_IPO_CONST; @@ -433,10 +433,10 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke else if ((beztr.ipo == BEZT_IPO_BEZ) && (fcu->flag & FCURVE_INT_VALUES)) { beztr.ipo = BEZT_IPO_LIN; } - + /* set keyframe type value (supplied), which should come from the scene settings in most cases */ BEZKEYTYPE(&beztr) = keyframe_type; - + /* set default values for "easing" interpolation mode settings * NOTE: Even if these modes aren't currently used, if users switch * to these later, we want these to work in a sane way out of @@ -444,48 +444,48 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, eBezTriple_KeyframeType ke */ beztr.back = 1.70158f; /* "back" easing - this value used to be used when overshoot=0, but that */ /* introduced discontinuities in how the param worked */ - + beztr.amplitude = 0.8f; /* "elastic" easing - values here were hand-optimised for a default duration of */ beztr.period = 4.1f; /* ~10 frames (typical mograph motion length) */ - + /* add temp beztriple to keyframes */ a = insert_bezt_fcurve(fcu, &beztr, flag); - - /* what if 'a' is a negative index? + + /* what if 'a' is a negative index? * for now, just exit to prevent any segfaults */ if (a < 0) return -1; - + /* don't recalculate handles if fast is set * - this is a hack to make importers faster * - we may calculate twice (due to autohandle needing to be calculated twice) */ - if ((flag & INSERTKEY_FAST) == 0) + if ((flag & INSERTKEY_FAST) == 0) calchandles_fcurve(fcu); - + /* set handletype and interpolation */ if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) { BezTriple *bezt = (fcu->bezt + a); - - /* set interpolation from previous (if available), but only if we didn't just replace some keyframe + + /* set interpolation from previous (if available), but only if we didn't just replace some keyframe * - replacement is indicated by no-change in number of verts * - when replacing, the user may have specified some interpolation that should be kept */ if (fcu->totvert > oldTot) { - if (a > 0) + if (a > 0) bezt->ipo = (bezt - 1)->ipo; else if (a < fcu->totvert - 1) bezt->ipo = (bezt + 1)->ipo; } - + /* don't recalculate handles if fast is set * - this is a hack to make importers faster * - we may calculate twice (due to autohandle needing to be calculated twice) */ - if ((flag & INSERTKEY_FAST) == 0) + if ((flag & INSERTKEY_FAST) == 0) calchandles_fcurve(fcu); } - + /* return the index at which the keyframe was added */ return a; } @@ -510,34 +510,34 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) BezTriple *bezt = NULL, *prev = NULL; int totCount, i; float valA = 0.0f, valB = 0.0f; - + /* safety checking */ if (fcu == NULL) return KEYNEEDED_JUSTADD; totCount = fcu->totvert; if (totCount == 0) return KEYNEEDED_JUSTADD; - + /* loop through checking if any are the same */ bezt = fcu->bezt; for (i = 0; i < totCount; i++) { float prevPosi = 0.0f, prevVal = 0.0f; float beztPosi = 0.0f, beztVal = 0.0f; - + /* get current time+value */ beztPosi = bezt->vec[1][0]; beztVal = bezt->vec[1][1]; - + if (prev) { /* there is a keyframe before the one currently being examined */ - + /* get previous time+value */ prevPosi = prev->vec[1][0]; prevVal = prev->vec[1][1]; - + /* keyframe to be added at point where there are already two similar points? */ if (IS_EQF(prevPosi, cFrame) && IS_EQF(beztPosi, cFrame) && IS_EQF(beztPosi, prevPosi)) { return KEYNEEDED_DONTADD; } - + /* keyframe between prev+current points ? */ if ((prevPosi <= cFrame) && (cFrame <= beztPosi)) { /* is the value of keyframe to be added the same as keyframes on either side ? */ @@ -546,18 +546,18 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) } else { float realVal; - + /* get real value of curve at that point */ realVal = evaluate_fcurve(fcu, cFrame); - + /* compare whether it's the same as proposed */ if (IS_EQF(realVal, nValue)) return KEYNEEDED_DONTADD; - else + else return KEYNEEDED_JUSTADD; } } - + /* new keyframe before prev beztriple? */ if (cFrame < prevPosi) { /* A new keyframe will be added. However, whether the previous beztriple @@ -566,18 +566,18 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) */ if (IS_EQF(prevVal, nValue) && IS_EQF(beztVal, nValue) && IS_EQF(prevVal, beztVal)) return KEYNEEDED_DELNEXT; - else + else return KEYNEEDED_JUSTADD; } } else { - /* just add a keyframe if there's only one keyframe + /* just add a keyframe if there's only one keyframe * and the new one occurs before the existing one does. */ if ((cFrame < beztPosi) && (totCount == 1)) return KEYNEEDED_JUSTADD; } - + /* continue. frame to do not yet passed (or other conditions not met) */ if (i < (totCount - 1)) { prev = bezt; @@ -586,7 +586,7 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) else break; } - + /* Frame in which to add a new-keyframe occurs after all other keys * -> If there are at least two existing keyframes, then if the values of the * last two keyframes and the new-keyframe match, the last existing keyframe @@ -596,15 +596,15 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) */ bezt = (fcu->bezt + (fcu->totvert - 1)); valA = bezt->vec[1][1]; - + if (prev) valB = prev->vec[1][1]; - else + else valB = bezt->vec[1][1] + 1.0f; - + if (IS_EQF(valA, nValue) && IS_EQF(valA, valB)) return KEYNEEDED_DELPREV; - else + else return KEYNEEDED_JUSTADD; } @@ -614,7 +614,7 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) static float setting_get_rna_value(PointerRNA *ptr, PropertyRNA *prop, int index) { float value = 0.0f; - + switch (RNA_property_type(prop)) { case PROP_BOOLEAN: if (RNA_property_array_check(prop)) @@ -640,7 +640,7 @@ static float setting_get_rna_value(PointerRNA *ptr, PropertyRNA *prop, int index default: break; } - + return value; } @@ -654,7 +654,7 @@ enum { VISUALKEY_SCA, }; -/* This helper function determines if visual-keyframing should be used when +/* This helper function determines if visual-keyframing should be used when * inserting keyframes for the given channel. As visual-keyframing only works * on Object and Pose-Channel blocks, this should only get called for those * blocktypes, when using "standard" keying but 'Visual Keying' option in Auto-Keying @@ -667,12 +667,12 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) bool has_rigidbody = false; bool has_parent = false; const char *identifier = NULL; - + /* validate data */ if (ELEM(NULL, ptr, ptr->data, prop)) return false; - - /* get first constraint and determine type of keyframe constraints to check for + + /* get first constraint and determine type of keyframe constraints to check for * - constraints can be on either Objects or PoseChannels, so we only check if the * ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for * those structs, allowing us to identify the owner of the data @@ -681,27 +681,27 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) /* Object */ Object *ob = (Object *)ptr->data; RigidBodyOb *rbo = ob->rigidbody_object; - + con = ob->constraints.first; identifier = RNA_property_identifier(prop); has_parent = (ob->parent != NULL); - + /* active rigidbody objects only, as only those are affected by sim */ has_rigidbody = ((rbo) && (rbo->type == RBO_TYPE_ACTIVE)); } else if (ptr->type == &RNA_PoseBone) { /* Pose Channel */ bPoseChannel *pchan = (bPoseChannel *)ptr->data; - + con = pchan->constraints.first; identifier = RNA_property_identifier(prop); has_parent = (pchan->parent != NULL); } - + /* check if any data to search using */ if (ELEM(NULL, con, identifier) && (has_parent == false) && (has_rigidbody == false)) return false; - + /* location or rotation identifiers only... */ if (identifier == NULL) { printf("%s failed: NULL identifier\n", __func__); @@ -720,20 +720,20 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) printf("%s failed: identifier - '%s'\n", __func__, identifier); return false; } - - + + /* only search if a searchtype and initial constraint are available */ if (searchtype) { /* parent or rigidbody are always matching */ if (has_parent || has_rigidbody) return true; - + /* constraints */ for (; con; con = con->next) { /* only consider constraint if it is not disabled, and has influence */ if (con->flag & CONSTRAINT_DISABLE) continue; if (con->enforce == 0.0f) continue; - + /* some constraints may alter these transforms */ switch (con->type) { /* multi-transform constraints */ @@ -746,7 +746,7 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) return true; case CONSTRAINT_TYPE_KINEMATIC: return true; - + /* single-transform constraits */ case CONSTRAINT_TYPE_TRACKTO: if (searchtype == VISUALKEY_ROT) return true; @@ -781,18 +781,18 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) case CONSTRAINT_TYPE_MINMAX: if (searchtype == VISUALKEY_LOC) return true; break; - + default: break; } } } - + /* when some condition is met, this function returns, so that means we've got nothing */ return false; } -/* This helper function extracts the value to use for visual-keyframing +/* This helper function extracts the value to use for visual-keyframing * In the event that it is not possible to perform visual keying, try to fall-back * to using the default method. Assumes that all data it has been passed is valid. */ @@ -801,8 +801,8 @@ static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_i const char *identifier = RNA_property_identifier(prop); float tmat[4][4]; int rotmode; - - /* handle for Objects or PoseChannels only + + /* handle for Objects or PoseChannels only * - only Location, Rotation or Scale keyframes are supported currently * - constraints can be on either Objects or PoseChannels, so we only check if the * ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for @@ -811,21 +811,21 @@ static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_i */ if (ptr->type == &RNA_Object) { Object *ob = (Object *)ptr->data; - + /* Loc code is specific... */ if (strstr(identifier, "location")) { return ob->obmat[3][array_index]; } - + copy_m4_m4(tmat, ob->obmat); rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { bPoseChannel *pchan = (bPoseChannel *)ptr->data; - + BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, tmat); rotmode = pchan->rotmode; - + /* Loc code is specific... */ if (strstr(identifier, "location")) { /* only use for non-connected bones */ @@ -836,27 +836,27 @@ static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_i else { return setting_get_rna_value(ptr, prop, array_index); } - + /* Rot/Scale code are common! */ if (strstr(identifier, "rotation_euler")) { float eul[3]; - + mat4_to_eulO(eul, rotmode, tmat); return eul[array_index]; } else if (strstr(identifier, "rotation_quaternion")) { float mat3[3][3], quat[4]; - + copy_m3_m4(mat3, tmat); mat3_to_quat_is_ok(quat, mat3); - + return quat[array_index]; } else if (strstr(identifier, "rotation_axis_angle")) { float axis[3], angle; - + mat4_to_axis_angle(axis, &angle, tmat); - + /* w = 0, x,y,z = 1,2,3 */ if (array_index == 0) return angle; @@ -865,19 +865,19 @@ static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_i } else if (strstr(identifier, "scale")) { float scale[3]; - + mat4_to_size(scale, tmat); - + return scale[array_index]; } - + /* as the function hasn't returned yet, read value from system in the default way */ return setting_get_rna_value(ptr, prop, array_index); } /* ------------------------- Insert Key API ------------------------- */ -/* Secondary Keyframing API call: +/* Secondary Keyframing API call: * Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary * data being keyframed, and a pointer to the F-Curve to use have both been provided. * @@ -890,7 +890,7 @@ static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_i bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag) { float curval = 0.0f; - + /* no F-Curve to add keyframe to? */ if (fcu == NULL) { BKE_report(reports, RPT_ERROR, "No F-Curve to add keyframes to"); @@ -898,13 +898,13 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr } /* F-Curve not editable? */ if (fcurve_is_keyframable(fcu) == 0) { - BKE_reportf(reports, RPT_ERROR, + BKE_reportf(reports, RPT_ERROR, "F-Curve with path '%s[%d]' cannot be keyframed, ensure that it is not locked or sampled, " "and try removing F-Modifiers", fcu->rna_path, fcu->array_index); return false; } - + /* if no property given yet, try to validate from F-Curve info */ if ((ptr.id.data == NULL) && (ptr.data == NULL)) { BKE_report(reports, RPT_ERROR, "No RNA pointer available to retrieve values for keyframing from"); @@ -912,12 +912,12 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr } if (prop == NULL) { PointerRNA tmp_ptr; - + /* try to get property we should be affecting */ if (RNA_path_resolve_property(&ptr, fcu->rna_path, &tmp_ptr, &prop) == false) { /* property not found... */ const char *idname = (ptr.id.data) ? ((ID *)ptr.id.data)->name : TIP_(""); - + BKE_reportf(reports, RPT_ERROR, "Could not insert keyframe, as RNA path is invalid for the given ID (ID = %s, path = %s)", idname, fcu->rna_path); @@ -928,7 +928,7 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr ptr = tmp_ptr; } } - + /* update F-Curve flags to ensure proper behaviour for property type */ update_autoflags_fcurve_direct(fcu, prop); @@ -944,13 +944,13 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr cfra = 0.0f; } } - + /* obtain value to give keyframe */ - if ( (flag & INSERTKEY_MATRIX) && + if ( (flag & INSERTKEY_MATRIX) && (visualkey_can_use(&ptr, prop)) ) { - /* visual-keying is only available for object and pchan datablocks, as - * it works by keyframing using a value extracted from the final matrix + /* visual-keying is only available for object and pchan datablocks, as + * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. */ curval = visualkey_get_value(&ptr, prop, fcu->array_index); @@ -959,18 +959,18 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr /* read value from system */ curval = setting_get_rna_value(&ptr, prop, fcu->array_index); } - + /* only insert keyframes where they are needed */ if (flag & INSERTKEY_NEEDED) { short insert_mode; - + /* check whether this curve really needs a new keyframe */ insert_mode = new_key_needed(fcu, cfra, curval); - + /* insert new keyframe at current frame */ if (insert_mode) insert_vert_fcurve(fcu, cfra, curval, keytype, flag); - + /* delete keyframe immediately before/after newly added */ switch (insert_mode) { case KEYNEEDED_DELPREV: @@ -980,7 +980,7 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr delete_fcurve_key(fcu, 1, 1); break; } - + /* only return success if keyframe added */ if (insert_mode) return true; @@ -988,11 +988,11 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr else { /* just insert keyframe */ insert_vert_fcurve(fcu, cfra, curval, keytype, flag); - + /* return success */ return true; } - + /* failed */ return false; } @@ -1007,20 +1007,20 @@ bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *pr * index of -1 keys all array indices */ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag) -{ +{ PointerRNA id_ptr, ptr; PropertyRNA *prop = NULL; AnimData *adt; FCurve *fcu; int array_index_max = array_index + 1; int ret = 0; - + /* validate pointer first - exit if failure */ if (id == NULL) { BKE_reportf(reports, RPT_ERROR, "No ID block to insert keyframe in (path = %s)", rna_path); return 0; } - + RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { BKE_reportf(reports, RPT_ERROR, @@ -1028,45 +1028,45 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou (id) ? id->name : TIP_(""), rna_path); return 0; } - + /* if no action is provided, keyframe to the default one attached to this ID-block */ if (act == NULL) { /* get action to add F-Curve+keyframe to */ act = verify_adt_action(id, 1); - + if (act == NULL) { - BKE_reportf(reports, RPT_ERROR, + BKE_reportf(reports, RPT_ERROR, "Could not insert keyframe, as this type does not support animation data (ID = %s, path = %s)", id->name, rna_path); return 0; } } - + /* apply NLA-mapping to frame to use (if applicable) */ adt = BKE_animdata_from_id(id); cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); - + /* key entire array convenience method */ if (array_index == -1) { array_index = 0; array_index_max = RNA_property_array_length(&ptr, prop); - + /* for single properties, increase max_index so that the property itself gets included, - * but don't do this for standard arrays since that can cause corruption issues + * but don't do this for standard arrays since that can cause corruption issues * (extra unused curves) */ if (array_index_max == array_index) array_index_max++; } - + /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { - /* make sure the F-Curve exists + /* make sure the F-Curve exists * - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet * but still try to get the F-Curve if it exists... */ fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0); - + /* we may not have a F-Curve when we're replacing only... */ if (fcu) { /* set color mode if the F-Curve is new (i.e. without any keyframes) */ @@ -1082,12 +1082,12 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou fcu->color_mode = FCURVE_COLOR_AUTO_YRGB; } } - + /* insert keyframe */ ret += insert_keyframe_direct(reports, ptr, prop, fcu, cfra, keytype, flag); } } - + return ret; } @@ -1136,13 +1136,13 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou PropertyRNA *prop; int array_index_max = array_index + 1; int ret = 0; - + /* sanity checks */ if (ELEM(NULL, id, adt)) { BKE_report(reports, RPT_ERROR, "No ID block and/or AnimData to delete keyframe from"); return 0; } - + /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, rna_path, &ptr, &prop) == false) { @@ -1151,18 +1151,18 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou id->name, rna_path); return 0; } - + /* get F-Curve * Note: here is one of the places where we don't want new Action + F-Curve added! * so 'add' var must be 0 */ if (act == NULL) { - /* if no action is provided, use the default one attached to this ID-block + /* if no action is provided, use the default one attached to this ID-block * - if it doesn't exist, then we're out of options... */ if (adt->action) { act = adt->action; - + /* apply NLA-mapping to frame to use (if applicable) */ cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } @@ -1171,20 +1171,20 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou return 0; } } - + /* key entire array convenience method */ if (array_index == -1) { array_index = 0; array_index_max = RNA_property_array_length(&ptr, prop); - + /* for single properties, increase max_index so that the property itself gets included, - * but don't do this for standard arrays since that can cause corruption issues + * but don't do this for standard arrays since that can cause corruption issues * (extra unused curves) */ if (array_index_max == array_index) array_index_max++; } - + /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { FCurve *fcu = verify_fcurve(act, group, &ptr, rna_path, array_index, 0); @@ -1203,7 +1203,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou ret += delete_keyframe_fcurve(adt, fcu, cfra); } - + /* return success/failure */ return ret; } @@ -1313,11 +1313,11 @@ static int modify_key_op_poll(bContext *C) { ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); - + /* if no area or active scene */ - if (ELEM(NULL, sa, scene)) + if (ELEM(NULL, sa, scene)) return false; - + /* should be fine */ return true; } @@ -1333,19 +1333,19 @@ static int insert_key_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; - + /* type is the Keying Set the user specified to use when calling the operator: * - type == 0: use scene's active Keying Set * - type > 0: use a user-defined Keying Set from the active scene * - type < 0: use a builtin Keying Set */ - if (type == 0) + if (type == 0) type = scene->active_keyingset; if (type > 0) ks = BLI_findlink(&scene->keyingsets, type - 1); else ks = BLI_findlink(&builtin_keyingsets, -type - 1); - + /* report failures */ if (ks == NULL) { BKE_report(op->reports, RPT_ERROR, "No active keying set"); @@ -1359,12 +1359,12 @@ static int insert_key_exec(bContext *C, wmOperator *op) ED_object_mode_toggle(C, OB_MODE_EDIT); ob_edit_mode = true; } - + /* try to insert keyframes for the channels specified by KeyingSet */ success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); if (G.debug & G_DEBUG) BKE_reportf(op->reports, RPT_INFO, "Keying set '%s' - successfully added %d keyframes", ks->name, success); - + /* restore the edit mode if necessary */ if (ob_edit_mode) { ED_object_mode_toggle(C, OB_MODE_EDIT); @@ -1379,39 +1379,39 @@ static int insert_key_exec(bContext *C, wmOperator *op) /* if the appropriate properties have been set, make a note that we've inserted something */ if (RNA_boolean_get(op->ptr, "confirm_success")) BKE_reportf(op->reports, RPT_INFO, "Successfully added %d keyframes for keying set '%s'", success, ks->name); - + /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); } else BKE_report(op->reports, RPT_WARNING, "Keying set failed to insert any keyframes"); - + return OPERATOR_FINISHED; } void ANIM_OT_keyframe_insert(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Insert Keyframe"; ot->idname = "ANIM_OT_keyframe_insert"; ot->description = "Insert keyframes on the current frame for all properties in the specified Keying Set"; - + /* callbacks */ - ot->exec = insert_key_exec; + ot->exec = insert_key_exec; ot->poll = modify_key_op_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* keyingset to use (dynamic enum) */ prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; - - /* confirm whether a keyframe was added by showing a popup + + /* confirm whether a keyframe was added by showing a popup * - by default, this is enabled, since this operator is assumed to be called independently */ prop = RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert", @@ -1420,68 +1420,68 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot) } /* Insert Key Operator (With Menu) ------------------------ */ -/* This operator checks if a menu should be shown for choosing the KeyingSet to use, +/* This operator checks if a menu should be shown for choosing the KeyingSet to use, * then calls the menu if necessary before */ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); - + /* if prompting or no active Keying Set, show the menu */ if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) { uiPopupMenu *pup; uiLayout *layout; - + /* call the menu, which will call this operator again, hence the canceled */ pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); layout = UI_popup_menu_layout(pup); uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type"); UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } else { /* just call the exec() on the active keyingset */ RNA_enum_set(op->ptr, "type", 0); RNA_boolean_set(op->ptr, "confirm_success", true); - + return op->type->exec(C, op); } } - + void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Insert Keyframe Menu"; ot->idname = "ANIM_OT_keyframe_insert_menu"; ot->description = "Insert Keyframes for specified Keying Set, with menu of available Keying Sets if undefined"; - + /* callbacks */ ot->invoke = insert_key_menu_invoke; - ot->exec = insert_key_exec; + ot->exec = insert_key_exec; ot->poll = ED_operator_areaactive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* keyingset to use (dynamic enum) */ prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; - - /* confirm whether a keyframe was added by showing a popup + + /* confirm whether a keyframe was added by showing a popup * - by default, this is disabled so that if a menu is shown, this doesn't come up too */ // XXX should this just be always on? prop = RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert", "Show a popup when the keyframes get successfully added"); RNA_def_property_flag(prop, PROP_HIDDEN); - - /* whether the menu should always be shown + + /* whether the menu should always be shown * - by default, the menu should only be shown when there is no active Keying Set (2.5 behavior), * although in some cases it might be useful to always shown (pre 2.5 behavior) */ @@ -1498,30 +1498,30 @@ static int delete_key_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; - + /* type is the Keying Set the user specified to use when calling the operator: * - type == 0: use scene's active Keying Set * - type > 0: use a user-defined Keying Set from the active scene * - type < 0: use a builtin Keying Set */ - if (type == 0) + if (type == 0) type = scene->active_keyingset; if (type > 0) ks = BLI_findlink(&scene->keyingsets, type - 1); else ks = BLI_findlink(&builtin_keyingsets, -type - 1); - + /* report failure */ if (ks == NULL) { BKE_report(op->reports, RPT_ERROR, "No active Keying Set"); return OPERATOR_CANCELLED; } - + /* try to delete keyframes for the channels specified by KeyingSet */ success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); if (G.debug & G_DEBUG) printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success); - + /* report failure or do updates? */ if (success == MODIFYKEY_INVALID_CONTEXT) { BKE_report(op->reports, RPT_ERROR, "No suitable context info for active keying set"); @@ -1531,39 +1531,39 @@ static int delete_key_exec(bContext *C, wmOperator *op) /* if the appropriate properties have been set, make a note that we've inserted something */ if (RNA_boolean_get(op->ptr, "confirm_success")) BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d keyframes for keying set '%s'", success, ks->name); - + /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); } else BKE_report(op->reports, RPT_WARNING, "Keying set failed to remove any keyframes"); - + return OPERATOR_FINISHED; } void ANIM_OT_keyframe_delete(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Delete Keying-Set Keyframe"; ot->idname = "ANIM_OT_keyframe_delete"; ot->description = "Delete keyframes on the current frame for all properties in the specified Keying Set"; - + /* callbacks */ - ot->exec = delete_key_exec; + ot->exec = delete_key_exec; ot->poll = modify_key_op_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* keyingset to use (dynamic enum) */ prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; - - /* confirm whether a keyframe was added by showing a popup + + /* confirm whether a keyframe was added by showing a popup * - by default, this is enabled, since this operator is assumed to be called independently */ RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Delete", @@ -1574,7 +1574,7 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot) /* NOTE: Although this version is simpler than the more generic version for KeyingSets, * it is more useful for animators working in the 3D view. */ - + static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) { bool changed = false; @@ -1586,23 +1586,23 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) AnimData *adt = ob->adt; bAction *act = adt->action; FCurve *fcu, *fcn; - + for (fcu = act->curves.first; fcu; fcu = fcn) { bool can_delete = false; - + fcn = fcu->next; - + /* in pose mode, only delete the F-Curve if it belongs to a selected bone */ if (ob->mode & OB_MODE_POSE) { if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones[")) { bPoseChannel *pchan; char *bone_name; - + /* get bone-name, and check if this bone is selected */ bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); - + /* delete if bone is selected*/ if ((pchan) && (pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) @@ -1614,7 +1614,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) /* object mode - all of Object's F-Curves are affected */ can_delete = true; } - + /* delete F-Curve completely */ if (can_delete) { ANIM_fcurve_delete_from_animdata(NULL, adt, fcu); @@ -1632,7 +1632,7 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) /* send updates */ WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); - + return OPERATOR_FINISHED; } @@ -1642,13 +1642,13 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot) ot->name = "Remove Animation"; ot->description = "Remove all keyframe animation for selected objects"; ot->idname = "ANIM_OT_keyframe_clear_v3d"; - + /* callbacks */ ot->invoke = WM_operator_confirm; - ot->exec = clear_anim_v3d_exec; - + ot->exec = clear_anim_v3d_exec; + ot->poll = ED_operator_areaactive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1658,22 +1658,22 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); float cfra = (float)CFRA; - + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { ID *id = &ob->id; int success = 0; - + /* just those in active action... */ if ((ob->adt) && (ob->adt->action)) { AnimData *adt = ob->adt; bAction *act = adt->action; FCurve *fcu, *fcn; const float cfra_unmap = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); - + for (fcu = act->curves.first; fcu; fcu = fcn) { fcn = fcu->next; - + /* don't touch protected F-Curves */ if (BKE_fcurve_is_protected(fcu)) { BKE_reportf(op->reports, RPT_WARNING, @@ -1681,57 +1681,57 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) fcu->rna_path, id->name + 2); continue; } - + /* special exception for bones, as this makes this operator more convenient to use * NOTE: This is only done in pose mode. In object mode, we're dealign with the entire object. */ if ((ob->mode & OB_MODE_POSE) && strstr(fcu->rna_path, "pose.bones[\"")) { bPoseChannel *pchan; char *bone_name; - + /* get bone-name, and check if this bone is selected */ bone_name = BLI_str_quoted_substrN(fcu->rna_path, "pose.bones["); pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); - + /* skip if bone is not selected */ if ((pchan) && (pchan->bone)) { /* bones are only selected/editable if visible... */ bArmature *arm = (bArmature *)ob->data; - + /* skipping - not visible on currently visible layers */ if ((arm->layer & pchan->bone->layer) == 0) continue; /* skipping - is currently hidden */ if (pchan->bone->flag & BONE_HIDDEN_P) continue; - + /* selection flag... */ if ((pchan->bone->flag & BONE_SELECTED) == 0) continue; } } - - /* delete keyframes on current frame + + /* delete keyframes on current frame * WARNING: this can delete the next F-Curve, hence the "fcn" copying */ success += delete_keyframe_fcurve(adt, fcu, cfra_unmap); } } - + /* report success (or failure) */ if (success) BKE_reportf(op->reports, RPT_INFO, "Object '%s' successfully had %d keyframes removed", id->name + 2, success); else BKE_reportf(op->reports, RPT_ERROR, "No keyframes removed from Object '%s'", id->name + 2); - + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; - + /* send updates */ WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); - + return OPERATOR_FINISHED; } @@ -1741,13 +1741,13 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) ot->name = "Delete Keyframe"; ot->description = "Remove keyframes on current frame for selected objects and bones"; ot->idname = "ANIM_OT_keyframe_delete_v3d"; - + /* callbacks */ ot->invoke = WM_operator_confirm; - ot->exec = delete_key_v3d_exec; - + ot->exec = delete_key_v3d_exec; + ot->poll = ED_operator_areaactive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1769,16 +1769,16 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) const bool all = RNA_boolean_get(op->ptr, "all"); eInsertKeyFlags flag = INSERTKEY_NOFLAGS; - + /* flags for inserting keyframes */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* try to insert keyframe using property retrieved from UI */ if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) { /* pass event on if no active button found */ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } - + if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { if (ptr.type == &RNA_NlaStrip) { /* Handle special properties for NLA Strips, whose F-Curves are stored on the @@ -1787,7 +1787,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) */ NlaStrip *strip = (NlaStrip *)ptr.data; FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), index); - + if (fcu) { success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, 0); } @@ -1800,9 +1800,9 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) /* Driven property - Find driver */ FCurve *fcu; bool driven, special; - + fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); - + if (fcu && driven) { success = insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, INSERTKEY_DRIVER); } @@ -1810,19 +1810,19 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) else { /* standard properties */ path = RNA_path_from_ID_to_property(&ptr, prop); - + if (path) { if (all) { /* -1 indicates operating on the entire array (or the property itself otherwise) */ index = -1; } - + success = insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, ts->keyframe_type, flag); - + MEM_freeN(path); } else { - BKE_report(op->reports, RPT_WARNING, + BKE_report(op->reports, RPT_WARNING, "Failed to resolve path to property, " "try manually specifying this using a Keying Set instead"); } @@ -1830,7 +1830,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) } else { if (prop && !RNA_property_animateable(&ptr, prop)) { - BKE_reportf(op->reports, RPT_WARNING, + BKE_reportf(op->reports, RPT_WARNING, "\"%s\" property cannot be animated", RNA_property_identifier(prop)); } @@ -1840,15 +1840,15 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) (void *)ptr.data, (void *)prop); } } - + if (success) { /* send updates */ UI_context_update_anim_flag(C); - + /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); } - + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1858,11 +1858,11 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) ot->name = "Insert Keyframe (Buttons)"; ot->idname = "ANIM_OT_keyframe_insert_button"; ot->description = "Insert a keyframe for current UI-active property"; - + /* callbacks */ - ot->exec = insert_key_button_exec; + ot->exec = insert_key_button_exec; ot->poll = modify_key_op_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1882,7 +1882,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) short success = 0; int index; const bool all = RNA_boolean_get(op->ptr, "all"); - + /* try to insert keyframe using property retrieved from UI */ if (!UI_context_active_but_prop_get(C, &ptr, &prop, &index)) { /* pass event on if no active button found */ @@ -1898,7 +1898,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) ID *id = ptr.id.data; NlaStrip *strip = (NlaStrip *)ptr.data; FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), 0); - + if (fcu) { if (BKE_fcurve_is_protected(fcu)) { BKE_reportf(op->reports, RPT_WARNING, @@ -1912,7 +1912,7 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) */ bool found = false; int i; - + /* try to find index of beztriple to get rid of */ i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found); if (found) { @@ -1926,13 +1926,13 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) else { /* standard properties */ path = RNA_path_from_ID_to_property(&ptr, prop); - + if (path) { if (all) { /* -1 indicates operating on the entire array (or the property itself otherwise) */ index = -1; } - + success = delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, cfra, 0); MEM_freeN(path); } @@ -1943,16 +1943,16 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) else if (G.debug & G_DEBUG) { printf("ptr.data = %p, prop = %p\n", (void *)ptr.data, (void *)prop); } - - + + if (success) { /* send updates */ UI_context_update_anim_flag(C); - + /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); } - + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1962,11 +1962,11 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) ot->name = "Delete Keyframe (Buttons)"; ot->idname = "ANIM_OT_keyframe_delete_button"; ot->description = "Delete current keyframe of current UI-active property"; - + /* callbacks */ - ot->exec = delete_key_button_exec; + ot->exec = delete_key_button_exec; ot->poll = modify_key_op_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1994,13 +1994,13 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) if (ptr.id.data && ptr.data && prop) { path = RNA_path_from_ID_to_property(&ptr, prop); - + if (path) { if (all) { /* -1 indicates operating on the entire array (or the property itself otherwise) */ index = -1; } - + success += clear_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index, 0); MEM_freeN(path); } @@ -2015,7 +2015,7 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) if (success) { /* send updates */ UI_context_update_anim_flag(C); - + /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); } @@ -2047,11 +2047,11 @@ void ANIM_OT_keyframe_clear_button(wmOperatorType *ot) bool autokeyframe_cfra_can_key(Scene *scene, ID *id) { float cfra = (float)CFRA; // XXX for now, this will do - + /* only filter if auto-key mode requires this */ if (IS_AUTOKEY_ON(scene) == 0) return false; - + if (IS_AUTOKEY_MODE(scene, EDITKEYS)) { /* Replace Mode: * For whole block, only key if there's a keyframe on that frame already @@ -2066,7 +2066,7 @@ bool autokeyframe_cfra_can_key(Scene *scene, ID *id) * let's set the "normal" flag too, so that it will all be sane everywhere... */ scene->toolsettings->autokey_mode = AUTOKEY_MODE_NORMAL; - + /* Can insert anytime we like... */ return true; } @@ -2083,12 +2083,12 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter) /* quick sanity check */ if (ELEM(NULL, fcu, fcu->bezt)) return false; - + /* we either include all regardless of muting, or only non-muted */ if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) { bool replace; int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace); - + /* binarysearch_bezt_index will set replace to be 0 or 1 * - obviously, 1 represents a match */ @@ -2098,26 +2098,26 @@ bool fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter) return true; } } - + return false; } -/* Checks whether an Action has a keyframe for a given frame +/* Checks whether an Action has a keyframe for a given frame * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... */ static bool action_frame_has_keyframe(bAction *act, float frame, short filter) { FCurve *fcu; - + /* can only find if there is data */ if (act == NULL) return false; - + /* if only check non-muted, check if muted */ if ((filter & ANIMFILTER_KEYS_MUTED) || (act->flag & ACT_MUTED)) return false; - - /* loop over F-Curves, using binary-search to try to find matches + + /* loop over F-Curves, using binary-search to try to find matches * - this assumes that keyframes are only beztriples */ for (fcu = act->curves.first; fcu; fcu = fcu->next) { @@ -2127,7 +2127,7 @@ static bool action_frame_has_keyframe(bAction *act, float frame, short filter) return true; } } - + /* nothing found */ return false; } @@ -2138,27 +2138,27 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter) /* error checking */ if (ob == NULL) return false; - + /* check own animation data - specifically, the action it contains */ if ((ob->adt) && (ob->adt->action)) { - /* T41525 - When the active action is a NLA strip being edited, + /* T41525 - When the active action is a NLA strip being edited, * we need to correct the frame number to "look inside" the * remapped action */ float ob_frame = BKE_nla_tweakedit_remap(ob->adt, frame, NLATIME_CONVERT_UNMAP); - + if (action_frame_has_keyframe(ob->adt->action, ob_frame, filter)) return true; } - + /* try shapekey keyframes (if available, and allowed by filter) */ if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY)) { Key *key = BKE_key_from_object(ob); - - /* shapekeys can have keyframes ('Relative Shape Keys') - * or depend on time (old 'Absolute Shape Keys') + + /* shapekeys can have keyframes ('Relative Shape Keys') + * or depend on time (old 'Absolute Shape Keys') */ - + /* 1. test for relative (with keyframes) */ if (id_frame_has_keyframe((ID *)key, frame, filter)) return true; @@ -2172,24 +2172,24 @@ static bool object_frame_has_keyframe(Object *ob, float frame, short filter) /* if only active, then we can skip a lot of looping */ if (filter & ANIMFILTER_KEYS_ACTIVE) { Material *ma = give_current_material(ob, (ob->actcol + 1)); - + /* we only retrieve the active material... */ if (id_frame_has_keyframe((ID *)ma, frame, filter)) return true; } else { int a; - + /* loop over materials */ for (a = 0; a < ob->totcol; a++) { Material *ma = give_current_material(ob, a + 1); - + if (id_frame_has_keyframe((ID *)ma, frame, filter)) return true; } } } - + /* nothing found */ return false; } @@ -2202,7 +2202,7 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter) /* sanity checks */ if (id == NULL) return false; - + /* perform special checks for 'macro' types */ switch (GS(id->name)) { case ID_OB: /* object */ @@ -2215,15 +2215,15 @@ bool id_frame_has_keyframe(ID *id, float frame, short filter) default: /* 'normal type' */ { AnimData *adt = BKE_animdata_from_id(id); - + /* only check keyframes in active action */ if (adt) return action_frame_has_keyframe(adt->action, frame, filter); break; } } - - + + /* no keyframe found */ return false; } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index cfab41944eb..3e491ce3ade 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -29,7 +29,7 @@ * \ingroup edanimation */ - + #include #include #include @@ -83,10 +83,10 @@ static int keyingset_poll_default_add(bContext *C) static int keyingset_poll_active_edit(bContext *C) { Scene *scene = CTX_data_scene(C); - + if (scene == NULL) return 0; - + /* there must be an active KeyingSet (and KeyingSets) */ return ((scene->active_keyingset > 0) && (scene->keyingsets.first)); } @@ -96,42 +96,42 @@ static int keyingset_poll_activePath_edit(bContext *C) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; - + if (scene == NULL) return 0; if (scene->active_keyingset <= 0) return 0; else ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); - + /* there must be an active KeyingSet and an active path */ return ((ks) && (ks->paths.first) && (ks->active_path > 0)); } - + /* Add a Default (Empty) Keying Set ------------------------- */ static int add_default_keyingset_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); short flag = 0, keyingflag = 0; - - /* validate flags + + /* validate flags * - absolute KeyingSets should be created by default */ flag |= KEYINGSET_ABSOLUTE; - + /* 2nd arg is 0 to indicate that we don't want to include autokeying mode related settings */ keyingflag = ANIM_get_keyframing_flags(scene, 0); - + /* call the API func, and set the active keyingset index */ BKE_keyingset_add(&scene->keyingsets, NULL, NULL, flag, keyingflag); - + scene->active_keyingset = BLI_listbase_count(&scene->keyingsets); - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + return OPERATOR_FINISHED; } @@ -141,7 +141,7 @@ void ANIM_OT_keying_set_add(wmOperatorType *ot) ot->name = "Add Empty Keying Set"; ot->idname = "ANIM_OT_keying_set_add"; ot->description = "Add a new (empty) Keying Set to the active Scene"; - + /* callbacks */ ot->exec = add_default_keyingset_exec; ot->poll = keyingset_poll_default_add; @@ -153,7 +153,7 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; - + /* verify the Keying Set to use: * - use the active one * - return error if it doesn't exist @@ -168,17 +168,17 @@ static int remove_active_keyingset_exec(bContext *C, wmOperator *op) } else ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); - + /* free KeyingSet's data, then remove it from the scene */ BKE_keyingset_free(ks); BLI_freelinkN(&scene->keyingsets, ks); - + /* the active one should now be the previously second-to-last one */ scene->active_keyingset--; - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + return OPERATOR_FINISHED; } @@ -188,7 +188,7 @@ void ANIM_OT_keying_set_remove(wmOperatorType *ot) ot->name = "Remove Active Keying Set"; ot->idname = "ANIM_OT_keying_set_remove"; ot->description = "Remove the active Keying Set"; - + /* callbacks */ ot->exec = remove_active_keyingset_exec; ot->poll = keyingset_poll_active_edit; @@ -201,7 +201,7 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); KeyingSet *ks; KS_Path *ksp; - + /* verify the Keying Set to use: * - use the active one * - return error if it doesn't exist @@ -212,16 +212,16 @@ static int add_empty_ks_path_exec(bContext *C, wmOperator *op) } else ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); - + /* don't use the API method for this, since that checks on values... */ ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty"); BLI_addtail(&ks->paths, ksp); ks->active_path = BLI_listbase_count(&ks->paths); - + ksp->groupmode = KSP_GROUP_KSNAME; // XXX? ksp->idtype = ID_OB; ksp->flag = KSP_FLAG_WHOLE_ARRAY; - + return OPERATOR_FINISHED; } @@ -231,7 +231,7 @@ void ANIM_OT_keying_set_path_add(wmOperatorType *ot) ot->name = "Add Empty Keying Set Path"; ot->idname = "ANIM_OT_keying_set_path_add"; ot->description = "Add empty path to active Keying Set"; - + /* callbacks */ ot->exec = add_empty_ks_path_exec; ot->poll = keyingset_poll_active_edit; @@ -243,15 +243,15 @@ static int remove_active_ks_path_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); KeyingSet *ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); - + /* if there is a KeyingSet, find the nominated path to remove */ if (ks) { KS_Path *ksp = BLI_findlink(&ks->paths, ks->active_path - 1); - + if (ksp) { /* remove the active path from the KeyingSet */ BKE_keyingset_free_path(ks, ksp); - + /* the active path should now be the previously second-to-last active one */ ks->active_path--; } @@ -264,7 +264,7 @@ static int remove_active_ks_path_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active keying set to remove a path from"); return OPERATOR_CANCELLED; } - + return OPERATOR_FINISHED; } @@ -274,7 +274,7 @@ void ANIM_OT_keying_set_path_remove(wmOperatorType *ot) ot->name = "Remove Active Keying Set Path"; ot->idname = "ANIM_OT_keying_set_path_remove"; ot->description = "Remove active Path from active Keying Set"; - + /* callbacks */ ot->exec = remove_active_ks_path_exec; ot->poll = keyingset_poll_activePath_edit; @@ -295,33 +295,33 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) short success = 0; int index = 0, pflag = 0; const bool all = RNA_boolean_get(op->ptr, "all"); - + /* try to add to keyingset using property retrieved from UI */ if (!UI_context_active_but_prop_get(C, &ptr, &prop, &index)) { /* pass event on if no active button found */ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } - + /* verify the Keying Set to use: * - use the active one for now (more control over this can be added later) - * - add a new one if it doesn't exist + * - add a new one if it doesn't exist */ if (scene->active_keyingset == 0) { short flag = 0, keyingflag = 0; - - /* validate flags + + /* validate flags * - absolute KeyingSets should be created by default */ flag |= KEYINGSET_ABSOLUTE; - + keyingflag |= ANIM_get_keyframing_flags(scene, 0); - - if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) + + if (IS_AUTOKEY_FLAG(scene, XYZ2RGB)) keyingflag |= INSERTKEY_XYZ2RGB; - + /* call the API func, and set the active keyingset index */ ks = BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag); - + scene->active_keyingset = BLI_listbase_count(&scene->keyingsets); } else if (scene->active_keyingset < 0) { @@ -331,41 +331,41 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) else { ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); } - + /* check if property is able to be added */ if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { path = RNA_path_from_ID_to_property(&ptr, prop); - + if (path) { /* set flags */ if (all) { pflag |= KSP_FLAG_WHOLE_ARRAY; - - /* we need to set the index for this to 0, even though it may break in some cases, this is + + /* we need to set the index for this to 0, even though it may break in some cases, this is * necessary if we want the entire array for most cases to get included without the user * having to worry about where they clicked */ index = 0; } - + /* add path to this setting */ BKE_keyingset_add_path(ks, ptr.id.data, NULL, path, index, pflag, KSP_GROUP_KSNAME); ks->active_path = BLI_listbase_count(&ks->paths); success = 1; - + /* free the temp path created */ MEM_freeN(path); } } - + if (success) { /* send updates */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + /* show notification/report header, so that users notice that something changed */ BKE_reportf(op->reports, RPT_INFO, "Property added to Keying Set: '%s'", ks->name); } - + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -375,11 +375,11 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) ot->name = "Add to Keying Set"; ot->idname = "ANIM_OT_keyingset_button_add"; ot->description = "Add current UI-active property to current keying set"; - + /* callbacks */ - ot->exec = add_keyingset_button_exec; + ot->exec = add_keyingset_button_exec; //op->poll = ??? - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -398,13 +398,13 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) char *path = NULL; short success = 0; int index = 0; - + /* try to add to keyingset using property retrieved from UI */ if (UI_context_active_but_prop_get(C, &ptr, &prop, &index)) { /* pass event on if no active button found */ return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH); } - + /* verify the Keying Set to use: * - use the active one for now (more control over this can be added later) * - return error if it doesn't exist @@ -420,35 +420,35 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) else { ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); } - + if (ptr.id.data && ptr.data && prop) { path = RNA_path_from_ID_to_property(&ptr, prop); - + if (path) { KS_Path *ksp; - + /* try to find a path matching this description */ ksp = BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME); - + if (ksp) { BKE_keyingset_free_path(ks, ksp); success = 1; } - + /* free temp path used */ MEM_freeN(path); } } - - + + if (success) { /* send updates */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + /* show warning */ BKE_report(op->reports, RPT_INFO, "Property removed from Keying Set"); } - + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -458,11 +458,11 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) ot->name = "Remove from Keying Set"; ot->idname = "ANIM_OT_keyingset_button_remove"; ot->description = "Remove current UI-active property from current keying set"; - + /* callbacks */ - ot->exec = remove_keyingset_button_exec; + ot->exec = remove_keyingset_button_exec; //op->poll = ??? - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -476,13 +476,13 @@ static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEve { uiPopupMenu *pup; uiLayout *layout; - + /* call the menu, which will call this operator again, hence the canceled */ pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); layout = UI_popup_menu_layout(pup); uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type"); UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -490,33 +490,33 @@ static int keyingset_active_menu_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); int type = RNA_enum_get(op->ptr, "type"); - + /* If type == 0, it will deselect any active keying set. */ scene->active_keyingset = type; - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + return OPERATOR_FINISHED; } - + void ANIM_OT_keying_set_active_set(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Set Active Keying Set"; ot->idname = "ANIM_OT_keying_set_active_set"; ot->description = "Select a new keying set as the active one"; - + /* callbacks */ ot->invoke = keyingset_active_menu_invoke; - ot->exec = keyingset_active_menu_exec; + ot->exec = keyingset_active_menu_exec; ot->poll = ED_operator_areaactive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* keyingset to use (dynamic enum) */ prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); @@ -540,7 +540,7 @@ KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]) /* sanity checks */ if ((name == NULL) || (name[0] == 0)) return NULL; - + /* search by comparing names */ return BLI_findstring(&keyingset_type_infos, name, offsetof(KeyingSetInfo, idname)); } @@ -549,17 +549,17 @@ KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]) KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]) { KeyingSet *ks, *first = NULL; - + /* sanity checks any name to check? */ if (name[0] == 0) return NULL; - + /* get first KeyingSet to use */ if (prevKS && prevKS->next) first = prevKS->next; else first = builtin_keyingsets.first; - + /* loop over KeyingSets checking names */ for (ks = first; ks; ks = ks->next) { if (STREQ(name, ks->idname)) @@ -581,18 +581,18 @@ KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[] void ANIM_keyingset_info_register(KeyingSetInfo *ksi) { KeyingSet *ks; - - /* create a new KeyingSet + + /* create a new KeyingSet * - inherit name and keyframing settings from the typeinfo */ ks = BKE_keyingset_add(&builtin_keyingsets, ksi->idname, ksi->name, 1, ksi->keyingflag); - + /* link this KeyingSet with its typeinfo */ memcpy(&ks->typeinfo, ksi->idname, sizeof(ks->typeinfo)); - + /* Copy description... */ BLI_strncpy(ks->description, ksi->description, sizeof(ks->description)); - + /* add type-info to the list */ BLI_addtail(&keyingset_type_infos, ksi); } @@ -620,7 +620,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) MEM_freeN(ks); } } - + /* free the type info */ BLI_freelinkN(&keyingset_type_infos, ksi); } @@ -630,17 +630,17 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) void ANIM_keyingset_infos_exit(void) { KeyingSetInfo *ksi, *next; - + /* free type infos */ for (ksi = keyingset_type_infos.first; ksi; ksi = next) { next = ksi->next; - + /* free extra RNA data, and remove from list */ if (ksi->ext.free) ksi->ext.free(ksi->ext.data); BLI_freelinkN(&keyingset_type_infos, ksi); } - + /* free builtin sets */ BKE_keyingsets_free(&builtin_keyingsets); } @@ -666,7 +666,7 @@ KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene) /* if no scene, we've got no hope of finding the Keying Set */ if (scene == NULL) return NULL; - + /* currently, there are several possibilities here: * - 0: no active keying set * - > 0: one of the user-defined Keying Sets, but indices start from 0 (hence the -1) @@ -682,22 +682,22 @@ KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene) int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks) { int index; - + /* if no KeyingSet provided, have none */ if (ks == NULL) return 0; - + /* check if the KeyingSet exists in scene list */ if (scene) { - /* get index and if valid, return + /* get index and if valid, return * - (absolute) Scene KeyingSets are from (>= 1) */ index = BLI_findindex(&scene->keyingsets, ks); if (index != -1) return (index + 1); } - - /* still here, so try builtins list too + + /* still here, so try builtins list too * - builtins are from (<= -1) * - none/invalid is (= 0) */ @@ -711,15 +711,15 @@ int ANIM_scene_get_keyingset_index(Scene *scene, KeyingSet *ks) /* Get Keying Set to use for Auto-Keyframing some transforms */ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformKSName) { - /* get KeyingSet to use - * - use the active KeyingSet if defined (and user wants to use it for all autokeying), + /* get KeyingSet to use + * - use the active KeyingSet if defined (and user wants to use it for all autokeying), * or otherwise key transforms only */ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset)) return ANIM_scene_get_active_keyingset(scene); else if (IS_AUTOKEY_FLAG(scene, INSERTAVAIL)) return ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_AVAILABLE_ID); - else + else return ANIM_builtin_keyingset_get_named(NULL, tranformKSName); } @@ -737,8 +737,8 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNU if (C == NULL) { return DummyRNA_DEFAULT_items; } - - /* active Keying Set + + /* active Keying Set * - only include entry if it exists */ if (scene->active_keyingset) { @@ -747,14 +747,14 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNU item_tmp.name = "Active Keying Set"; item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); - + /* separator */ RNA_enum_item_add_separator(&item, &totitem); } - + i++; - - /* user-defined Keying Sets + + /* user-defined Keying Sets * - these are listed in the order in which they were defined for the active scene */ if (scene->keyingsets.first) { @@ -767,11 +767,11 @@ const EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNU RNA_enum_item_add(&item, &totitem, &item_tmp); } } - + /* separator */ RNA_enum_item_add_separator(&item, &totitem); } - + /* builtin Keying Sets */ i = -1; for (ks = builtin_keyingsets.first; ks; ks = ks->next, i--) { @@ -801,7 +801,7 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); - + /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) return 0; @@ -810,13 +810,13 @@ bool ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) /* check if it can be used in the current context */ return (ksi->poll(ksi, C)); } - + return true; } /* Special 'Overrides' Iterator for Relative KeyingSets ------ */ -/* 'Data Sources' for relative Keying Set 'overrides' +/* 'Data Sources' for relative Keying Set 'overrides' * - this is basically a wrapper for PointerRNA's in a linked list * - do not allow this to be accessed from outside for now */ @@ -826,14 +826,14 @@ typedef struct tRKS_DSource { } tRKS_DSource; -/* Iterator used for overriding the behavior of iterators defined for +/* Iterator used for overriding the behavior of iterators defined for * relative Keying Sets, with the main usage of this being operators * requiring Auto Keyframing. Internal Use Only! */ static void RKS_ITER_overrides_list(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, ListBase *dsources) { tRKS_DSource *ds; - + for (ds = dsources->first; ds; ds = ds->next) { /* run generate callback on this data */ ksi->generate(ksi, C, ks, &ds->ptr); @@ -844,8 +844,8 @@ static void RKS_ITER_overrides_list(KeyingSetInfo *ksi, bContext *C, KeyingSet * void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *srna, void *data) { tRKS_DSource *ds; - - /* sanity checks + + /* sanity checks * - we must have somewhere to output the data * - we must have both srna+data (and with id too optionally), or id by itself only */ @@ -853,11 +853,11 @@ void ANIM_relative_keyingset_add_source(ListBase *dsources, ID *id, StructRNA *s return; if (ELEM(NULL, srna, data) && (id == NULL)) return; - + /* allocate new elem, and add to the list */ ds = MEM_callocN(sizeof(tRKS_DSource), "tRKS_DSource"); BLI_addtail(dsources, ds); - + /* depending on what data we have, create using ID or full pointer call */ if (srna && data) RNA_pointer_create(id, srna, data, &ds->ptr); @@ -879,31 +879,31 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) /* sanity check */ if (ks == NULL) return 0; - + /* if relative Keying Sets, poll and build up the paths */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); - - /* clear all existing paths + + /* clear all existing paths * NOTE: BKE_keyingset_free() frees all of the paths for the KeyingSet, but not the set itself */ BKE_keyingset_free(ks); - + /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) return MODIFYKEY_MISSING_TYPEINFO; /* TODO: check for missing callbacks! */ - + /* check if it can be used in the current context */ if (ksi->poll(ksi, C)) { /* if a list of data sources are provided, run a special iterator over them, * otherwise, just continue per normal */ - if (dsources) + if (dsources) RKS_ITER_overrides_list(ksi, C, ks, dsources); else ksi->iter(ksi, C, ks); - + /* if we don't have any paths now, then this still qualifies as invalid context */ // FIXME: we need some error conditions (to be retrieved from the iterator why this failed!) if (BLI_listbase_is_empty(&ks->paths)) @@ -915,16 +915,16 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) return MODIFYKEY_INVALID_CONTEXT; } } - + /* succeeded; return 0 to tag error free */ return 0; -} +} /* Determine which keying flags apply based on the override flags */ static short keyingset_apply_keying_flags(const short base_flags, const short overrides, const short own_flags) { short result = 0; - + /* The logic for whether a keying flag applies is as follows: * - If the flag in question is set in "overrides", that means that the * status of that flag in "own_flags" is used @@ -938,14 +938,14 @@ static short keyingset_apply_keying_flags(const short base_flags, const short ov else { \ result |= (base_flags & kflag); \ } - - /* Apply the flags one by one... + + /* Apply the flags one by one... * (See rna_def_common_keying_flags() for the supported flags) */ APPLY_KEYINGFLAG_OVERRIDE(INSERTKEY_NEEDED) APPLY_KEYINGFLAG_OVERRIDE(INSERTKEY_MATRIX) APPLY_KEYINGFLAG_OVERRIDE(INSERTKEY_XYZ2RGB) - + #undef APPLY_KEYINGFLAG_OVERRIDE return result; @@ -964,11 +964,11 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe const char *groupname = NULL; short kflag = 0, success = 0; char keytype = scene->toolsettings->keyframe_type; - + /* sanity checks */ if (ks == NULL) return 0; - + /* get flags to use */ if (mode == MODIFYKEY_MODE_INSERT) { /* use context settings as base */ @@ -976,20 +976,20 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe } else if (mode == MODIFYKEY_MODE_DELETE) kflag = 0; - + /* if relative Keying Sets, poll and build up the paths */ success = ANIM_validate_keyingset(C, dsources, ks); - + if (success != 0) { /* return error code if failed */ return success; } - + /* apply the paths as specified in the KeyingSet now */ for (ksp = ks->paths.first; ksp; ksp = ksp->next) { int arraylen, i; short kflag2; - + /* skip path if no ID pointer is specified */ if (ksp->id == NULL) { BKE_reportf(reports, RPT_WARNING, @@ -997,10 +997,10 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe ks->name, ksp->rna_path, ksp->array_index); continue; } - + /* since keying settings can be defined on the paths too, apply the settings for this path first */ kflag2 = keyingset_apply_keying_flags(kflag, ksp->keyingoverride, ksp->keyingflag); - + /* get pointer to name of group to add channels to */ if (ksp->groupmode == KSP_GROUP_NONE) groupname = NULL; @@ -1008,30 +1008,30 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe groupname = ks->name; else groupname = ksp->group; - + /* init arraylen and i - arraylen should be greater than i so that * normal non-array entries get keyframed correctly */ i = ksp->array_index; arraylen = i; - + /* get length of array if whole array option is enabled */ if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) { PointerRNA id_ptr, ptr; PropertyRNA *prop; - + RNA_id_pointer_create(ksp->id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, ksp->rna_path, &ptr, &prop)) { arraylen = RNA_property_array_length(&ptr, prop); i = 0; /* start from start of array, instead of the previously specified index - T48020 */ } } - + /* we should do at least one step */ if (arraylen == i) arraylen++; - - /* for each possible index, perform operation + + /* for each possible index, perform operation * - assume that arraylen is greater than index */ for (; i < arraylen; i++) { @@ -1041,13 +1041,13 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe else if (mode == MODIFYKEY_MODE_DELETE) success += delete_keyframe(reports, ksp->id, act, groupname, ksp->rna_path, i, cfra, kflag2); } - + /* set recalc-flags */ switch (GS(ksp->id->name)) { case ID_OB: /* Object (or Object-Related) Keyframes */ { Object *ob = (Object *)ksp->id; - + // XXX: only object transforms? DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); break; @@ -1055,11 +1055,11 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe default: break; } - + /* send notifiers for updates (this doesn't require context to work!) */ WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); } - + /* return the number of channels successfully affected */ return success; } diff --git a/source/blender/editors/armature/BIF_generate.h b/source/blender/editors/armature/BIF_generate.h index 71109574fe0..e229b0f342a 100644 --- a/source/blender/editors/armature/BIF_generate.h +++ b/source/blender/editors/armature/BIF_generate.h @@ -22,7 +22,7 @@ * \ingroup edarmature */ - + #ifndef __BIF_GENERATE_H__ #define __BIF_GENERATE_H__ @@ -33,7 +33,7 @@ struct bArmature; struct ListBase; typedef int (NextSubdivisionFunc)(struct ToolSettings *, struct BArcIterator *, int, int, float[3], float[3]); - + float calcArcCorrelation(struct BArcIterator *iter, int start, int end, float v0[3], float n[3]); int nextFixedSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]); @@ -44,6 +44,6 @@ struct EditBone *subdivideArcBy(struct ToolSettings *toolsettings, struct bArmat float invmat[4][4], float tmat[3][3], NextSubdivisionFunc next_subdividion); void setBoneRollFromNormal(struct EditBone *bone, const float no[3], float invmat[4][4], float tmat[3][3]); - + #endif /* __BIF_GENERATE_H__ */ diff --git a/source/blender/editors/armature/BIF_retarget.h b/source/blender/editors/armature/BIF_retarget.h index aa56f847f00..2bd2b80190b 100644 --- a/source/blender/editors/armature/BIF_retarget.h +++ b/source/blender/editors/armature/BIF_retarget.h @@ -52,28 +52,28 @@ typedef struct RigGraph { ListBase nodes; float length; - + FreeArc free_arc; FreeNode free_node; RadialSymmetry radial_symmetry; AxialSymmetry axial_symmetry; /*********************************/ - + int flag; ListBase controls; ListBase *editbones; - + struct RigNode *head; ReebGraph *link_mesh; - - + + TaskScheduler *task_scheduler; TaskPool *task_pool; - + GHash *bones_map; /* map of editbones by name */ GHash *controls_map; /* map of rigcontrols by bone pointer */ - + struct Object *ob; } RigGraph; @@ -106,7 +106,7 @@ typedef struct RigArc { int symmetry_group; int symmetry_flag; /*********************************/ - + ListBase edges; int count; ReebArc *link_mesh; diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index c8939380bd9..b268baf0f97 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -66,12 +66,12 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) { EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); - + BLI_strncpy(bone->name, name, sizeof(bone->name)); ED_armature_ebone_unique_name(arm->edbo, bone->name, NULL); - + BLI_addtail(arm->edbo, bone); - + bone->flag |= BONE_TIPSEL; bone->weight = 1.0f; bone->dist = 0.25f; @@ -81,7 +81,7 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) bone->rad_tail = 0.05f; bone->segments = 1; bone->layer = arm->layer; - + /* Bendy-Bone parameters */ bone->roll1 = 0.0f; bone->roll2 = 0.0f; @@ -103,7 +103,7 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool EditBone *bone; ED_armature_edit_deselect_all(obedit_arm); - + /* Create a bone */ bone = ED_armature_ebone_add(arm, "Bone"); @@ -135,7 +135,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) v3d = CTX_wm_view3d(C); obedit = CTX_data_edit_object(C); arm = obedit->data; - + /* find the active or selected bone */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { @@ -143,7 +143,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + if (ebone == NULL) { for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { @@ -151,14 +151,14 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - if (ebone == NULL) + if (ebone == NULL) return OPERATOR_CANCELLED; - + to_root = 1; } - + ED_armature_edit_deselect_all(obedit); - + /* we re-use code for mirror editing... */ flipbone = NULL; if (arm->flag & ARM_MIRROR_EDIT) @@ -172,10 +172,10 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) SWAP(EditBone *, flipbone, ebone); } } - + newbone = ED_armature_ebone_add(arm, ebone->name); arm->act_edbone = newbone; - + if (to_root) { copy_v3_v3(newbone->head, ebone->head); newbone->rad_head = ebone->rad_tail; @@ -187,28 +187,28 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) newbone->parent = ebone; newbone->flag |= BONE_CONNECTED; } - + curs = ED_view3d_cursor3d_get(scene, v3d); copy_v3_v3(newbone->tail, curs); sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]); - + if (a == 1) newbone->tail[0] = -newbone->tail[0]; - + copy_m3_m4(mat, obedit->obmat); invert_m3_m3(imat, mat); mul_m3_v3(imat, newbone->tail); - + newbone->length = len_v3v3(newbone->head, newbone->tail); newbone->rad_tail = newbone->length * 0.05f; newbone->dist = newbone->length * 0.25f; - + } - + ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); - + return OPERATOR_FINISHED; } @@ -227,9 +227,9 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, const wmEv scene = CTX_data_scene(C); ar = CTX_wm_region(C); v3d = CTX_wm_view3d(C); - + fp = ED_view3d_cursor3d_get(scene, v3d); - + copy_v3_v3(oldcurs, fp); VECCOPY2D(mval_f, event->mval); @@ -251,12 +251,12 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot) ot->name = "Click-Extrude"; ot->idname = "ARMATURE_OT_click_extrude"; ot->description = "Create a new bone going from the last selected joint to the mouse position"; - + /* api callbacks */ ot->invoke = armature_click_extrude_invoke; ot->exec = armature_click_extrude_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -267,12 +267,12 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot) EditBone *add_points_bone(Object *obedit, float head[3], float tail[3]) { EditBone *ebo; - + ebo = ED_armature_ebone_add(obedit->data, "Bone"); - + copy_v3_v3(ebo->head, head); copy_v3_v3(ebo->tail, tail); - + return ebo; } @@ -378,7 +378,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj bPoseChannel *pchan; bConstraint *curcon; ListBase *conlist; - + if ((pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name))) { if ((conlist = &pchan->constraints)) { for (curcon = conlist->first; curcon; curcon = curcon->next) { @@ -388,17 +388,17 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - + if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(curcon, &targets); - + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == src_ob) && (ct->subtarget[0])) { - ct->tar = dst_ob; /* update target */ + ct->tar = dst_ob; /* update target */ oldtarget = get_named_editbone(editbones, ct->subtarget); if (oldtarget) { /* was the subtarget bone duplicated too? If - * so, update the constraint to point at the + * so, update the constraint to point at the * duplicate of the old subtarget. */ if (oldtarget->temp.ebone) { @@ -408,7 +408,7 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj } } } - + if (cti->flush_constraint_targets) cti->flush_constraint_targets(curcon, &targets, 0); } @@ -427,20 +427,20 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase Object *src_ob, Object *dst_ob) { EditBone *eBone = MEM_mallocN(sizeof(EditBone), "addup_editbone"); - + /* Copy data from old bone to new bone */ memcpy(eBone, curBone, sizeof(EditBone)); - + curBone->temp.ebone = eBone; eBone->temp.ebone = curBone; - + if (name != NULL) { BLI_strncpy(eBone->name, name, sizeof(eBone->name)); } ED_armature_ebone_unique_name(editbones, eBone->name, NULL); BLI_addtail(editbones, eBone); - + /* copy the ID property */ if (curBone->prop) eBone->prop = IDP_CopyProperty(curBone->prop); @@ -450,7 +450,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase */ if (src_ob->pose) { bPoseChannel *chanold, *channew; - + chanold = BKE_pose_channel_verify(src_ob->pose, curBone->name); if (chanold) { /* WARNING: this creates a new posechannel, but there will not be an attached bone @@ -463,7 +463,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase } } } - + return eBone; } @@ -507,7 +507,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) } } - + /* Find the selected bones and duplicate them as needed */ for (ebone_iter = arm->edbo->first; ebone_iter && ebone_iter != ebone_first_dupe; ebone_iter = ebone_iter->next) { if (EBONE_VISIBLE(arm, ebone_iter) && @@ -568,7 +568,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) updateDuplicateSubtarget(ebone, arm->edbo, obedit); } } - + /* correct the active bone */ if (arm->act_edbone && arm->act_edbone->temp.ebone) { arm->act_edbone = arm->act_edbone->temp.ebone; @@ -586,7 +586,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *op) ED_armature_edit_validate_active(arm); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); - + return OPERATOR_FINISHED; } @@ -597,11 +597,11 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Selected Bone(s)"; ot->idname = "ARMATURE_OT_duplicate"; ot->description = "Make copies of the selected bones within the same armature"; - + /* api callbacks */ ot->exec = armature_duplicate_selected_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -847,7 +847,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) } } } - + /* Duplicate the necessary bones */ for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { @@ -865,7 +865,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) do_extrude = 2; } } - + if (do_extrude) { /* we re-use code for mirror editing... */ flipbone = NULL; @@ -880,7 +880,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) if ((flipbone == NULL) && (forked)) flipbone = ebone; } - + for (a = 0; a < 2; a++) { if (a == 1) { if (flipbone == NULL) @@ -889,31 +889,31 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) SWAP(EditBone *, flipbone, ebone); } } - + totbone++; newbone = MEM_callocN(sizeof(EditBone), "extrudebone"); - + if (do_extrude == true) { copy_v3_v3(newbone->head, ebone->tail); copy_v3_v3(newbone->tail, newbone->head); newbone->parent = ebone; - + newbone->flag = ebone->flag & (BONE_TIPSEL | BONE_RELATIVE_PARENTING); // copies it, in case mirrored bone - + if (newbone->parent) newbone->flag |= BONE_CONNECTED; } else { copy_v3_v3(newbone->head, ebone->head); copy_v3_v3(newbone->tail, ebone->head); newbone->parent = ebone->parent; - + newbone->flag = BONE_TIPSEL; - + if (newbone->parent && (ebone->flag & BONE_CONNECTED)) { newbone->flag |= BONE_CONNECTED; } } - + newbone->weight = ebone->weight; newbone->dist = ebone->dist; newbone->xwidth = ebone->xwidth; @@ -922,7 +922,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) newbone->rad_tail = ebone->rad_tail; newbone->segments = 1; newbone->layer = ebone->layer; - + /* Bendy-Bone parameters */ newbone->roll1 = ebone->roll1; newbone->roll2 = ebone->roll2; @@ -937,7 +937,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name)); - + if (flipbone && forked) { // only set if mirror edit if (strlen(newbone->name) < (MAXBONENAME - 2)) { if (a == 0) strcat(newbone->name, "_L"); @@ -945,18 +945,18 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) } } ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL); - + /* Add the new bone to the list */ BLI_addtail(arm->edbo, newbone); if (!first) first = newbone; - + /* restore ebone if we were flipping */ if (a == 1 && flipbone) SWAP(EditBone *, flipbone, ebone); } } - + /* Deselect the old bone */ ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); } @@ -987,14 +987,14 @@ void ARMATURE_OT_extrude(wmOperatorType *ot) ot->name = "Extrude"; ot->idname = "ARMATURE_OT_extrude"; ot->description = "Create new bones from the selected joints"; - + /* api callbacks */ ot->exec = armature_extrude_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "forked", 0, "Forked", ""); } @@ -1003,16 +1003,16 @@ void ARMATURE_OT_extrude(wmOperatorType *ot) /*op makes a new bone and returns it with its tip selected */ -static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) +static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) { RegionView3D *rv3d = CTX_wm_region_view3d(C); Object *obedit = CTX_data_edit_object(C); EditBone *bone; float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; char name[MAXBONENAME]; - + RNA_string_get(op->ptr, "name", name); - + copy_v3_v3(curs, ED_view3d_cursor3d_get(CTX_data_scene(C), CTX_wm_view3d(C))); /* Get inverse point for head and orientation for tail */ @@ -1022,18 +1022,18 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) copy_m3_m4(obmat, rv3d->viewmat); else unit_m3(obmat); - + copy_m3_m4(viewmat, obedit->obmat); mul_m3_m3m3(totmat, obmat, viewmat); invert_m3_m3(imat, totmat); - + ED_armature_edit_deselect_all(obedit); - + /* Create a bone */ bone = ED_armature_ebone_add(obedit->data, name); copy_v3_v3(bone->head, curs); - + if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else @@ -1051,16 +1051,16 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) ot->name = "Add Bone"; ot->idname = "ARMATURE_OT_bone_primitive_add"; ot->description = "Add a new bone located at the 3D-Cursor"; - + /* api callbacks */ ot->exec = armature_bone_primitive_add_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone"); - + } /* ********************** Subdivide *******************************/ @@ -1077,10 +1077,10 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) bArmature *arm = obedit->data; EditBone *newbone, *tbone; int cuts, i; - + /* there may not be a number_cuts property defined (for 'simple' subdivide) */ cuts = RNA_int_get(op->ptr, "number_cuts"); - + /* loop over all editable bones */ // XXX the old code did this in reverse order though! CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) @@ -1089,37 +1089,37 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) /* compute cut ratio first */ float cutratio = 1.0f / (float)i; float cutratioI = 1.0f - cutratio; - + float val1[3]; float val2[3]; float val3[3]; - + newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv"); *newbone = *ebone; BLI_addtail(arm->edbo, newbone); - + /* calculate location of newbone->head */ copy_v3_v3(val1, ebone->head); copy_v3_v3(val2, ebone->tail); copy_v3_v3(val3, newbone->head); - + val3[0] = val1[0] * cutratio + val2[0] * cutratioI; val3[1] = val1[1] * cutratio + val2[1] * cutratioI; val3[2] = val1[2] * cutratio + val2[2] * cutratioI; - + copy_v3_v3(newbone->head, val3); copy_v3_v3(newbone->tail, ebone->tail); copy_v3_v3(ebone->tail, newbone->head); - + newbone->rad_head = ((ebone->rad_head * cutratio) + (ebone->rad_tail * cutratioI)); ebone->rad_tail = newbone->rad_head; - + newbone->flag |= BONE_CONNECTED; newbone->prop = NULL; ED_armature_ebone_unique_name(arm->edbo, newbone->name, NULL); - + /* correct parent bones */ for (tbone = arm->edbo->first; tbone; tbone = tbone->next) { if (tbone->parent == ebone) @@ -1129,10 +1129,10 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); - + return OPERATOR_FINISHED; } @@ -1144,14 +1144,14 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot) ot->name = "Subdivide Multi"; ot->idname = "ARMATURE_OT_subdivide"; ot->description = "Break selected bones into chains of smaller bones"; - + /* api callbacks */ ot->exec = armature_subdivide_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* Properties */ prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, 1000, "Number of Cuts", "", 1, 10); /* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */ diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 4562329706f..539d56a4ede 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -29,7 +29,7 @@ * \ingroup edarmature */ -#include +#include #include "DNA_armature_types.h" #include "DNA_constraint_types.h" @@ -92,20 +92,20 @@ void ED_armature_transform_bones(struct bArmature *arm, float mat[4][4], const b /* Do the rotations */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { float tmat[3][3]; - + /* find the current bone's roll matrix */ ED_armature_ebone_to_mat3(ebone, tmat); - + /* transform the roll matrix */ mul_m3_m3m3(tmat, mat3, tmat); - + /* transform the bone */ mul_m4_v3(mat, ebone->head); mul_m4_v3(mat, ebone->tail); /* apply the transformed roll back */ mat3_to_vec_roll(tmat, NULL, &ebone->roll); - + if (do_props) { ebone->rad_head *= scale; ebone->rad_tail *= scale; @@ -180,13 +180,13 @@ void ED_armature_origin_set(Scene *scene, Object *ob, float cursor[3], int cente mid_v3_v3v3(cent, min, max); } } - + /* Do the adjustments */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { sub_v3_v3(ebone->head, cent); sub_v3_v3(ebone->tail, cent); } - + /* Turn the list into an armature */ if (obedit == NULL) { ED_armature_from_edit(arm); @@ -291,7 +291,7 @@ static const EnumPropertyItem prop_calc_roll_types[] = { }; -static int armature_calc_roll_exec(bContext *C, wmOperator *op) +static int armature_calc_roll_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); eCalcRollTypes type = RNA_enum_get(op->ptr, "type"); @@ -318,12 +318,12 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ float cursor_local[3]; const float *cursor = ED_view3d_cursor3d_get(scene, v3d); - + invert_m4_m4(ob->imat, ob->obmat); copy_v3_v3(cursor_local, cursor); mul_m4_v3(ob->imat, cursor_local); - + /* cursor */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { @@ -392,7 +392,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No region view3d available"); return OPERATOR_CANCELLED; } - + copy_v3_v3(vec, rv3d->viewinv[2]); mul_m3_v3(imat, vec); } @@ -403,7 +403,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active bone set"); return OPERATOR_CANCELLED; } - + ED_armature_ebone_to_mat3(ebone, mat); copy_v3_v3(vec, mat[2]); } @@ -414,9 +414,9 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) mul_m3_v3(imat, vec); normalize_v3(vec); } - + if (axis_flip) negate_v3(vec); - + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* roll func is a callback which assumes that all is well */ @@ -424,7 +424,7 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } } } - + if (arm->flag & ARM_MIRROR_EDIT) { for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { @@ -435,10 +435,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } } } - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -448,12 +448,12 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot) ot->name = "Recalculate Roll"; ot->idname = "ARMATURE_OT_calculate_roll"; ot->description = "Automatically fix alignment of select bones' axes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = armature_calc_roll_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -520,10 +520,10 @@ void ARMATURE_OT_roll_clear(wmOperatorType *ot) /* temporary data-structure for merge/fill bones */ typedef struct EditBonePoint { struct EditBonePoint *next, *prev; - + EditBone *head_owner; /* EditBone which uses this point as a 'head' point */ EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */ - + float vec[3]; /* the actual location of the point in local/EditMode space */ } EditBonePoint; @@ -532,11 +532,11 @@ static void chains_find_tips(ListBase *edbo, ListBase *list) { EditBone *curBone, *ebo; LinkData *ld; - + /* note: this is potentially very slow ... there's got to be a better way */ for (curBone = edbo->first; curBone; curBone = curBone->next) { short stop = 0; - + /* is this bone contained within any existing chain? (skip if so) */ for (ld = list->first; ld; ld = ld->next) { for (ebo = ld->data; ebo; ebo = ebo->parent) { @@ -545,12 +545,12 @@ static void chains_find_tips(ListBase *edbo, ListBase *list) break; } } - + if (stop) break; } /* skip current bone if it is part of an existing chain */ if (stop) continue; - + /* is any existing chain part of the chain formed by this bone? */ stop = 0; for (ebo = curBone->parent; ebo; ebo = ebo->parent) { @@ -561,12 +561,12 @@ static void chains_find_tips(ListBase *edbo, ListBase *list) break; } } - + if (stop) break; } /* current bone has already been added to a chain? */ if (stop) continue; - + /* add current bone to a new chain */ ld = MEM_callocN(sizeof(LinkData), "BoneChain"); ld->data = curBone; @@ -581,14 +581,14 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) EditBonePoint *ebp; float vec[3]; short found = 0; - + if (eb_tail) { copy_v3_v3(vec, ebo->tail); } else { copy_v3_v3(vec, ebo->head); } - + for (ebp = points->first; ebp; ebp = ebp->next) { if (equals_v3v3(ebp->vec, vec)) { if (eb_tail) { @@ -609,11 +609,11 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) } } } - + /* allocate a new point if no existing point was related */ if (found == 0) { ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint"); - + if (eb_tail) { copy_v3_v3(ebp->vec, ebo->tail); ebp->tail_owner = ebo; @@ -622,7 +622,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) copy_v3_v3(ebp->vec, ebo->head); ebp->head_owner = ebo; } - + BLI_addtail(points, ebp); } } @@ -647,18 +647,18 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) { if (!(ebone->flag & BONE_CONNECTED) && (ebone->flag & BONE_ROOTSEL)) fill_add_joint(ebone, 0, &points); - if (ebone->flag & BONE_TIPSEL) + if (ebone->flag & BONE_TIPSEL) fill_add_joint(ebone, 1, &points); } CTX_DATA_END; - + /* the number of joints determines how we fill: * 1) between joint and cursor (joint=head, cursor=tail) * 2) between the two joints (order is dependent on active-bone/hierarchy) * 3+) error (a smarter method involving finding chains needs to be worked out */ count = BLI_listbase_count(&points); - + if (count == 0) { BKE_report(op->reports, RPT_ERROR, "No joints selected"); return OPERATOR_CANCELLED; @@ -666,14 +666,14 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) else if (count == 1) { EditBonePoint *ebp; float curs[3]; - + /* Get Points - selected joint */ ebp = points.first; - + /* Get points - cursor (tail) */ invert_m4_m4(obedit->imat, obedit->obmat); mul_v3_m4v3(curs, obedit->imat, ED_view3d_cursor3d_get(scene, v3d)); - + /* Create a bone */ newbone = add_points_bone(obedit, ebp->vec, curs); } @@ -681,11 +681,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) EditBonePoint *ebp_a, *ebp_b; float head[3], tail[3]; short headtail = 0; - + /* check that the points don't belong to the same bone */ ebp_a = (EditBonePoint *)points.first; ebp_b = ebp_a->next; - + if (((ebp_a->head_owner == ebp_b->tail_owner) && (ebp_a->head_owner != NULL)) || ((ebp_a->tail_owner == ebp_b->head_owner) && (ebp_a->tail_owner != NULL))) { @@ -693,7 +693,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) BLI_freelistN(&points); return OPERATOR_CANCELLED; } - + /* find which one should be the 'head' */ if ((ebp_a->head_owner && ebp_b->head_owner) || (ebp_a->tail_owner && ebp_b->tail_owner)) { /* use active, nice predictable */ @@ -726,7 +726,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) else if (ebp_b->head_owner) { headtail = 2; } - + /* assign head/tail combinations */ if (headtail == 2) { copy_v3_v3(head, ebp_a->vec); @@ -736,11 +736,11 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) copy_v3_v3(head, ebp_b->vec); copy_v3_v3(tail, ebp_a->vec); } - + /* add new bone and parent it to the appropriate end */ if (headtail) { newbone = add_points_bone(obedit, head, tail); - + /* do parenting (will need to set connected flag too) */ if (headtail == 2) { /* ebp tail or head - tail gets priority */ @@ -775,13 +775,13 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) arm->act_edbone = newbone; newbone->flag |= BONE_TIPSEL; } - + /* updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); - + /* free points */ BLI_freelistN(&points); - + return OPERATOR_FINISHED; } @@ -791,18 +791,18 @@ void ARMATURE_OT_fill(wmOperatorType *ot) ot->name = "Fill Between Joints"; ot->idname = "ARMATURE_OT_fill"; ot->description = "Add bone between selected joint(s) and/or 3D-Cursor"; - + /* callbacks */ ot->exec = armature_fill_bones_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------------------- */ -/* this function merges between two bones, removes them and those in-between, +/* this function merges between two bones, removes them and those in-between, * and adjusts the parent relationships for those in-between */ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone *endchild, ListBase *chains) @@ -811,7 +811,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone EditBone *ebo, *ebone, *newbone; LinkData *chain; float head[3], tail[3]; - + /* check if same bone */ if (start == end) { if (G.debug & G_DEBUG) { @@ -819,7 +819,7 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone printf("\tstart = %s, end = %s\n", start->name, end->name); } } - + /* step 1: add a new bone * - head = head/tail of start (default head) * - tail = head/tail of end (default tail) @@ -843,17 +843,17 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone /* TODO, copy more things to the new bone */ newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE); - - /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge + + /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge * - potentially several tips for side chains leading to some tree exist... */ for (chain = chains->first; chain; chain = chain->next) { - /* traverse down chain until we hit the bottom or if we run into the tip of the chain of bones we're - * merging (need to stop in this case to avoid corrupting this chain too!) + /* traverse down chain until we hit the bottom or if we run into the tip of the chain of bones we're + * merging (need to stop in this case to avoid corrupting this chain too!) */ for (ebone = chain->data; (ebone) && (ebone != end); ebone = ebone->parent) { short found = 0; - + /* check if this bone is parented to one in the merging chain * ! WATCHIT: must only go check until end of checking chain */ @@ -865,23 +865,23 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone break; } } - + /* carry on to the next tip now */ - if (found) + if (found) break; } } - + /* step 2b: parent child of end to newbone (child from this chain) */ if (endchild) endchild->parent = newbone; - + /* step 3: delete all bones between and including start and end */ for (ebo = end; ebo; ebo = ebone) { ebone = (ebo == start) ? (NULL) : (ebo->parent); bone_free(arm, ebo); } - + newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); ED_armature_edit_sync_selection(arm->edbo); } @@ -892,33 +892,33 @@ static int armature_merge_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); bArmature *arm = (obedit) ? obedit->data : NULL; short type = RNA_enum_get(op->ptr, "type"); - + /* sanity checks */ if (ELEM(NULL, obedit, arm)) return OPERATOR_CANCELLED; - + /* for now, there's only really one type of merging that's performed... */ if (type == 1) { /* go down chains, merging bones */ ListBase chains = {NULL, NULL}; LinkData *chain, *nchain; EditBone *ebo; - + armature_tag_select_mirrored(arm); - + /* get chains (ends on chains) */ chains_find_tips(arm->edbo, &chains); if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED; - + /* each 'chain' is the last bone in the chain (with no children) */ for (chain = chains.first; chain; chain = nchain) { EditBone *bstart = NULL, *bend = NULL; EditBone *bchild = NULL, *child = NULL; - + /* temporarily remove chain from list of chains */ nchain = chain->next; BLI_remlink(&chains, chain); - + /* only consider bones that are visible and selected */ for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) { /* check if visible + selected */ @@ -931,37 +931,37 @@ static int armature_merge_exec(bContext *C, wmOperator *op) bend = ebo; bchild = child; } - else + else bstart = ebo; } else { /* chain is broken... merge any continous segments then clear */ if (bstart && bend) bones_merge(obedit, bstart, bend, bchild, &chains); - + bstart = NULL; bend = NULL; bchild = NULL; } } - + /* merge from bstart to bend if something not merged */ if (bstart && bend) bones_merge(obedit, bstart, bend, bchild, &chains); - + /* put back link */ BLI_insertlinkbefore(&chains, nchain, chain); } - + armature_tag_unselect(arm); - + BLI_freelistN(&chains); } - + /* updates */ ED_armature_edit_sync_selection(arm->edbo); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); - + return OPERATOR_FINISHED; } @@ -976,15 +976,15 @@ void ARMATURE_OT_merge(wmOperatorType *ot) ot->name = "Merge Bones"; ot->idname = "ARMATURE_OT_merge"; ot->description = "Merge continuous chains of selected bones"; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = armature_merge_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", ""); } @@ -996,41 +996,41 @@ void ARMATURE_OT_merge(wmOperatorType *ot) * easy to retrieve any hierarchical/chain relationships which are necessary for * this to be done easily. */ - + /* helper to clear BONE_TRANSFORM flags */ static void armature_clear_swap_done_flags(bArmature *arm) { EditBone *ebone; - + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { ebone->flag &= ~BONE_TRANSFORM; } } -static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) +static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_edit_object(C); bArmature *arm = (bArmature *)ob->data; ListBase chains = {NULL, NULL}; LinkData *chain; - + /* get chains of bones (ends on chains) */ chains_find_tips(arm->edbo, &chains); if (BLI_listbase_is_empty(&chains)) return OPERATOR_CANCELLED; - + /* ensure that mirror bones will also be operated on */ armature_tag_select_mirrored(arm); - - /* clear BONE_TRANSFORM flags + + /* clear BONE_TRANSFORM flags * - used to prevent duplicate/canceling operations from occurring [#34123] * - BONE_DONE cannot be used here as that's already used for mirroring */ armature_clear_swap_done_flags(arm); - + /* loop over chains, only considering selected and visible bones */ for (chain = chains.first; chain; chain = chain->next) { EditBone *ebo, *child = NULL, *parent = NULL; - + /* loop over bones in chain */ for (ebo = chain->data; ebo; ebo = parent) { /* parent is this bone's original parent @@ -1038,14 +1038,14 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) * but the value of ebo->parent may change here... */ parent = ebo->parent; - + /* skip bone if already handled... [#34123] */ if ((ebo->flag & BONE_TRANSFORM) == 0) { /* only if selected and editable */ if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { /* swap head and tail coordinates */ swap_v3_v3(ebo->head, ebo->tail); - + /* do parent swapping: * - use 'child' as new parent * - connected flag is only set if points are coincidental @@ -1055,44 +1055,44 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) ebo->flag |= BONE_CONNECTED; else ebo->flag &= ~BONE_CONNECTED; - - /* get next bones + + /* get next bones * - child will become the new parent of next bone */ child = ebo; } else { - /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it + /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it * as it will be facing in opposite direction */ if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) { ebo->parent = NULL; ebo->flag &= ~BONE_CONNECTED; } - + /* get next bones - * - child will become new parent of next bone (not swapping occurred, + * - child will become new parent of next bone (not swapping occurred, * so set to NULL to prevent infinite-loop) */ child = NULL; } - + /* tag as done (to prevent double-swaps) */ ebo->flag |= BONE_TRANSFORM; } } } - + /* free chains */ BLI_freelistN(&chains); - + /* clear temp flags */ armature_clear_swap_done_flags(arm); armature_tag_unselect(arm); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -1102,11 +1102,11 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot) ot->name = "Switch Direction"; ot->idname = "ARMATURE_OT_switch_direction"; ot->description = "Change the direction that a chain of bones points in (head <-> tail swap)"; - + /* api callbacks */ ot->exec = armature_switch_direction_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1117,10 +1117,10 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot) static void fix_connected_bone(EditBone *ebone) { float diff[3]; - + if (!(ebone->parent) || !(ebone->flag & BONE_CONNECTED) || equals_v3v3(ebone->parent->tail, ebone->head)) return; - + /* if the parent has moved we translate child's head and tail accordingly */ sub_v3_v3v3(diff, ebone->parent->tail, ebone->head); add_v3_v3(ebone->head, diff); @@ -1131,14 +1131,14 @@ static void fix_connected_bone(EditBone *ebone) static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone) { EditBone *selbone; - + for (selbone = edbo->first; selbone; selbone = selbone->next) { if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) { fix_connected_bone(selbone); fix_editbone_connected_children(edbo, selbone); } } -} +} static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actbone) { @@ -1153,21 +1153,21 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb mul_v3_fl(actboneaxis, length); add_v3_v3v3(selbone->tail, selbone->head, actboneaxis); selbone->roll = actbone->roll; - + /* if the bone being aligned has connected descendants they must be moved * according to their parent new position, otherwise they would be left * in an inconsistent state: connected but away from the parent*/ fix_editbone_connected_children(edbo, selbone); } -static int armature_align_bones_exec(bContext *C, wmOperator *op) +static int armature_align_bones_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); bArmature *arm = (bArmature *)ob->data; EditBone *actbone = CTX_data_active_bone(C); EditBone *actmirb = NULL; int num_selected_bones; - + /* there must be an active bone */ if (actbone == NULL) { BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone"); @@ -1175,28 +1175,28 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) } else if (arm->flag & ARM_MIRROR_EDIT) { /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone - * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone + * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone * (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R"). * This is useful for arm-chains, for example parenting lower arm to upper arm * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); - if (actmirb == NULL) + if (actmirb == NULL) actmirb = actbone; } - - /* if there is only 1 selected bone, we assume that that is the active bone, + + /* if there is only 1 selected bone, we assume that that is the active bone, * since a user will need to have clicked on a bone (thus selecting it) to make it active */ num_selected_bones = CTX_DATA_COUNT(C, selected_editable_bones); if (num_selected_bones <= 1) { /* When only the active bone is selected, and it has a parent, - * align it to the parent, as that is the only possible outcome. + * align it to the parent, as that is the only possible outcome. */ if (actbone->parent) { bone_align_to_bone(arm->edbo, actbone, actbone->parent); - + if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) bone_align_to_bone(arm->edbo, actmirb, actmirb->parent); @@ -1207,11 +1207,11 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) /* Align 'selected' bones to the active one * - the context iterator contains both selected bones and their mirrored copies, * so we assume that unselected bones are mirrored copies of some selected bone - * - since the active one (and/or its mirror) will also be selected, we also need + * - since the active one (and/or its mirror) will also be selected, we also need * to check that we are not trying to operate on them, since such an operation * would cause errors */ - + /* align selected bones to the active one */ CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { @@ -1229,7 +1229,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -1239,11 +1239,11 @@ void ARMATURE_OT_align(wmOperatorType *ot) ot->name = "Align Bones"; ot->idname = "ARMATURE_OT_align"; ot->description = "Align selected bones to the active bone (or to their parent)"; - + /* api callbacks */ ot->exec = armature_align_bones_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1310,9 +1310,9 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* cancel if nothing selected */ if (CTX_DATA_COUNT(C, selected_bones) == 0) return OPERATOR_CANCELLED; - + armature_select_mirrored(arm); - + BKE_pose_channels_remove(obedit, armature_delete_ebone_cb, arm); for (curBone = arm->edbo->first; curBone; curBone = ebone_next) { @@ -1325,10 +1325,10 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + if (!changed) return OPERATOR_CANCELLED; - + ED_armature_edit_sync_selection(arm->edbo); BKE_pose_tag_recalc(CTX_data_main(C), obedit->pose); @@ -1343,12 +1343,12 @@ void ARMATURE_OT_delete(wmOperatorType *ot) ot->name = "Delete Selected Bone(s)"; ot->idname = "ARMATURE_OT_delete"; ot->description = "Remove selected bones from the armature"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = armature_delete_selected_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1552,11 +1552,11 @@ void ARMATURE_OT_hide(wmOperatorType *ot) ot->name = "Hide Selected Bones"; ot->idname = "ARMATURE_OT_hide"; ot->description = "Tag selected bones to not be visible in Edit Mode"; - + /* api callbacks */ ot->exec = armature_hide_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1570,7 +1570,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *op) bArmature *arm = obedit->data; EditBone *ebone; const bool select = RNA_boolean_get(op->ptr, "select"); - + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { @@ -1595,11 +1595,11 @@ void ARMATURE_OT_reveal(wmOperatorType *ot) ot->name = "Reveal Bones"; ot->idname = "ARMATURE_OT_reveal"; ot->description = "Reveal all bones hidden in Edit Mode"; - + /* api callbacks */ ot->exec = armature_reveal_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 36d571e1be8..288d9f0f86b 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -157,25 +157,25 @@ void SKETCH_OT_select(struct wmOperatorType *ot); /* Temporary data linking PoseChannels with the F-Curves they affect */ typedef struct tPChanFCurveLink { struct tPChanFCurveLink *next, *prev; - + ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */ struct bPoseChannel *pchan; /* Pose Channel which data is attached to */ - + char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */ - + float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */ float oldrot[3]; float oldscale[3]; float oldquat[4]; float oldangle; float oldaxis[3]; - + float roll1, roll2; /* old bbone values (to be restored along with the transform properties) */ float curveInX, curveInY; /* (NOTE: we haven't renamed these this time, as their names are already long enough) */ float curveOutX, curveOutY; float ease1, ease2; float scaleIn, scaleOut; - + struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */ } tPChanFCurveLink; diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index d5ed1380a7e..c49e9a2b820 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -104,15 +104,15 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char * { bConstraint *curcon; bConstraintTarget *ct; - + for (curcon = conlist->first; curcon; curcon = curcon->next) { const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon); ListBase targets = {NULL, NULL}; - + /* constraint targets */ if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(curcon, &targets); - + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { if (STREQ(ct->subtarget, oldname)) { @@ -120,11 +120,11 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, const char * } } } - + if (cti->flush_constraint_targets) cti->flush_constraint_targets(curcon, &targets, 0); } - + /* action constraints */ if (curcon->type == CONSTRAINT_TYPE_ACTION) { bActionConstraint *actcon = (bActionConstraint *)curcon->data; @@ -141,19 +141,19 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n Object *ob; char newname[MAXBONENAME]; char oldname[MAXBONENAME]; - + /* names better differ! */ if (!STREQLEN(oldnamep, newnamep, MAXBONENAME)) { - + /* we alter newname string... so make copy */ BLI_strncpy(newname, newnamep, MAXBONENAME); /* we use oldname for search... so make copy */ BLI_strncpy(oldname, oldnamep, MAXBONENAME); - + /* now check if we're in editmode, we need to find the unique name */ if (arm->edbo) { EditBone *eBone = ED_armature_ebone_find_name(arm->edbo, oldname); - + if (eBone) { ED_armature_ebone_unique_name(arm->edbo, newname, NULL); BLI_strncpy(eBone->name, newname, MAXBONENAME); @@ -164,7 +164,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } else { Bone *bone = BKE_armature_find_bone_name(arm, oldname); - + if (bone) { unique_bone_name(arm, newname); BLI_strncpy(bone->name, newname, MAXBONENAME); @@ -173,15 +173,15 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n return; } } - + /* do entire dbase - objects */ for (ob = G.main->object.first; ob; ob = ob->id.next) { ModifierData *md; - + /* we have the object using the armature */ if (arm == ob->data) { Object *cob; - + /* Rename the pose channel, if it exists */ if (ob->pose) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname); @@ -203,7 +203,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n BLI_assert(BKE_pose_channels_is_valid(ob->pose) == true); } - + /* Update any object constraints to use the new bone name */ for (cob = G.main->object.first; cob; cob = cob->id.next) { if (cob->constraints.first) @@ -216,7 +216,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } } } - + /* See if an object is parented to this armature */ if (ob->parent && (ob->parent->data == arm)) { if (ob->partype == PARBONE) { @@ -225,14 +225,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n BLI_strncpy(ob->parsubstr, newname, MAXBONENAME); } } - + if (modifiers_usesArmature(ob, arm)) { bDeformGroup *dg = defgroup_find_name(ob, oldname); if (dg) { BLI_strncpy(dg->name, newname, MAXBONENAME); } } - + /* fix modifiers that might be using this name */ for (md = ob->modifiers.first; md; md = md->next) { switch (md->type) { @@ -265,16 +265,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } } } - + /* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since * other ID-blocks may have drivers referring to this bone [#29822] */ // XXX: the ID here is for armatures, but most bone drivers are actually on the object instead... { - + BKE_animdata_fix_paths_rename_all(&arm->id, "pose.bones", oldname, newname); } - + /* correct view locking */ { bScreen *screen; @@ -376,7 +376,7 @@ static int armature_flip_names_exec(bContext *C, wmOperator *op) ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers); BLI_freelistN(&bones_names); - + /* since we renamed stuff... */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -396,11 +396,11 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot) ot->name = "Flip Names"; ot->idname = "ARMATURE_OT_flip_names"; ot->description = "Flips (and corrects) the axis suffixes of the names of selected bones"; - + /* api callbacks */ ot->exec = armature_flip_names_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -416,12 +416,12 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) bArmature *arm; char newname[MAXBONENAME]; short axis = RNA_enum_get(op->ptr, "type"); - + /* paranoia checks */ - if (ELEM(NULL, ob, ob->pose)) + if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; arm = ob->data; - + /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { @@ -430,13 +430,13 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) ED_armature_bone_rename(arm, ebone->name, newname); } CTX_DATA_END; - + /* since we renamed stuff... */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -448,20 +448,20 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "AutoName by Axis"; ot->idname = "ARMATURE_OT_autoside_names"; ot->description = "Automatically renames the selected bones according to which side of the target axis they fall on"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = armature_autoside_names_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* settings */ ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with"); } diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index e63d197ca15..31a22b41f54 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -46,16 +46,16 @@ void ED_operatortypes_armature(void) { /* EDIT ARMATURE */ WM_operatortype_append(ARMATURE_OT_bone_primitive_add); - + WM_operatortype_append(ARMATURE_OT_align); WM_operatortype_append(ARMATURE_OT_calculate_roll); WM_operatortype_append(ARMATURE_OT_roll_clear); WM_operatortype_append(ARMATURE_OT_switch_direction); WM_operatortype_append(ARMATURE_OT_subdivide); - + WM_operatortype_append(ARMATURE_OT_parent_set); WM_operatortype_append(ARMATURE_OT_parent_clear); - + WM_operatortype_append(ARMATURE_OT_select_all); WM_operatortype_append(ARMATURE_OT_select_mirror); WM_operatortype_append(ARMATURE_OT_select_more); @@ -77,10 +77,10 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_merge); WM_operatortype_append(ARMATURE_OT_separate); WM_operatortype_append(ARMATURE_OT_split); - + WM_operatortype_append(ARMATURE_OT_autoside_names); WM_operatortype_append(ARMATURE_OT_flip_names); - + WM_operatortype_append(ARMATURE_OT_layers_show_all); WM_operatortype_append(ARMATURE_OT_armature_layers); WM_operatortype_append(ARMATURE_OT_bone_layers); @@ -98,19 +98,19 @@ void ED_operatortypes_armature(void) /* POSE */ WM_operatortype_append(POSE_OT_hide); WM_operatortype_append(POSE_OT_reveal); - + WM_operatortype_append(POSE_OT_armature_apply); WM_operatortype_append(POSE_OT_visual_transform_apply); - + WM_operatortype_append(POSE_OT_rot_clear); WM_operatortype_append(POSE_OT_loc_clear); WM_operatortype_append(POSE_OT_scale_clear); WM_operatortype_append(POSE_OT_transforms_clear); WM_operatortype_append(POSE_OT_user_transforms_clear); - + WM_operatortype_append(POSE_OT_copy); WM_operatortype_append(POSE_OT_paste); - + WM_operatortype_append(POSE_OT_select_all); WM_operatortype_append(POSE_OT_select_parent); @@ -119,7 +119,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_select_constraint_target); WM_operatortype_append(POSE_OT_select_grouped); WM_operatortype_append(POSE_OT_select_mirror); - + WM_operatortype_append(POSE_OT_group_add); WM_operatortype_append(POSE_OT_group_remove); WM_operatortype_append(POSE_OT_group_move); @@ -128,36 +128,36 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_group_unassign); WM_operatortype_append(POSE_OT_group_select); WM_operatortype_append(POSE_OT_group_deselect); - + WM_operatortype_append(POSE_OT_paths_calculate); WM_operatortype_append(POSE_OT_paths_update); WM_operatortype_append(POSE_OT_paths_clear); - + WM_operatortype_append(POSE_OT_autoside_names); WM_operatortype_append(POSE_OT_flip_names); - + WM_operatortype_append(POSE_OT_rotation_mode_set); WM_operatortype_append(POSE_OT_quaternions_flip); - + WM_operatortype_append(POSE_OT_bone_layers); - + WM_operatortype_append(POSE_OT_propagate); - + /* POSELIB */ WM_operatortype_append(POSELIB_OT_browse_interactive); WM_operatortype_append(POSELIB_OT_apply_pose); - + WM_operatortype_append(POSELIB_OT_pose_add); WM_operatortype_append(POSELIB_OT_pose_remove); WM_operatortype_append(POSELIB_OT_pose_rename); WM_operatortype_append(POSELIB_OT_pose_move); - + WM_operatortype_append(POSELIB_OT_new); WM_operatortype_append(POSELIB_OT_unlink); - + WM_operatortype_append(POSELIB_OT_action_sanitize); - + /* POSE SLIDING */ WM_operatortype_append(POSE_OT_push); WM_operatortype_append(POSE_OT_relax); @@ -199,11 +199,11 @@ void ED_keymap_armature(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + /* Armature ------------------------ */ keymap = WM_keymap_find(keyconf, "Armature", 0, 0); keymap->poll = ED_operator_editarmature; - + /* Armature -> Etch-A-Ton ------------------------ */ WM_keymap_add_item(keymap, "SKETCH_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0); @@ -231,14 +231,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_roll_clear", RKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "ARMATURE_OT_bone_primitive_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "ARMATURE_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); - + kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); @@ -246,14 +246,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", false); - + kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); RNA_boolean_set(kmi->ptr, "extend", false); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); RNA_boolean_set(kmi->ptr, "extend", true); - + kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); RNA_boolean_set(kmi->ptr, "extend", false); @@ -269,7 +269,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_select_linked", LKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_shortest_path_pick", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_armature_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0); @@ -280,19 +280,19 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_split", YKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, 0, 0); - + /* set flags */ WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0); - + /* armature/bone layers */ WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_bone_layers", MKEY, KM_PRESS, 0, 0); - + /* special transforms: */ /* 1) envelope/b-bone size */ kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); @@ -303,7 +303,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) /* 3) set roll */ kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", RKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL); - + /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_armature_specials", WKEY, KM_PRESS, 0, 0); @@ -311,36 +311,36 @@ void ED_keymap_armature(wmKeyConfig *keyconf) /* only set in posemode, by space_view3d listener */ keymap = WM_keymap_find(keyconf, "Pose", 0, 0); keymap->poll = ED_operator_posemode; - + /* set parent and add object are object-based operators, but we make them * available here because it's useful to do in pose mode too */ WM_keymap_add_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "INFO_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + kmi = WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); kmi = WM_keymap_add_item(keymap, "POSE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "unselected", true); WM_keymap_add_item(keymap, "POSE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_apply", AKEY, KM_PRESS, KM_CTRL, 0); - + /* TODO: clear pose */ WM_keymap_add_item(keymap, "POSE_OT_rot_clear", RKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_loc_clear", GKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "POSE_OT_quaternions_flip", FKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "POSE_OT_rotation_mode_set", RKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "flipped", false); kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "flipped", true); - + #ifdef __APPLE__ WM_keymap_add_item(keymap, "POSE_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); @@ -362,7 +362,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); RNA_boolean_set(kmi->ptr, "extend", true); - + kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); RNA_boolean_set(kmi->ptr, "extend", false); @@ -373,14 +373,14 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_select_mirror", FKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - + WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/ KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_group", GKEY, KM_PRESS, KM_CTRL, 0); - + /* set flags */ WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); @@ -390,25 +390,25 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0); - + /* special transforms: */ /* 1) envelope/b-bone size */ kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); - + /* keyframes management */ WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0); - + /* Pose -> PoseLib ------------- */ /* only set in posemode, by space_view3d listener */ WM_keymap_add_item(keymap, "POSELIB_OT_browse_interactive", LKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSELIB_OT_pose_remove", LKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - + /* Pose -> Pose Sliding ------------- */ /* only set in posemode, by space_view3d listener */ WM_keymap_add_item(keymap, "POSE_OT_push", EKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 3c272d52d1c..95c8b1d5460 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -107,7 +107,7 @@ static void joined_armature_fix_links_constraints( bActionConstraint *data = con->data; if (data->act) { - BKE_action_fix_paths_rename(&tarArm->id, data->act, "pose.bones[", + BKE_action_fix_paths_rename(&tarArm->id, data->act, "pose.bones[", pchan->name, curbone->name, 0, 0, false); } } @@ -119,7 +119,7 @@ static void joined_armature_fix_links_constraints( typedef struct tJoinArmature_AdtFixData { Object *srcArm; Object *tarArm; - + GHash *names_map; } tJoinArmature_AdtFixData; @@ -132,34 +132,34 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data tJoinArmature_AdtFixData *afd = (tJoinArmature_AdtFixData *)user_data; ID *src_id = &afd->srcArm->id; ID *dst_id = &afd->tarArm->id; - + GHashIterator gh_iter; - + /* Fix paths - If this is the target object, it will have some "dirty" paths */ if ((id == src_id) && strstr(fcu->rna_path, "pose.bones[")) { GHASH_ITER(gh_iter, afd->names_map) { const char *old_name = BLI_ghashIterator_getKey(&gh_iter); const char *new_name = BLI_ghashIterator_getValue(&gh_iter); - + /* only remap if changed; this still means there will be some waste if there aren't many drivers/keys */ if (!STREQ(old_name, new_name) && strstr(fcu->rna_path, old_name)) { fcu->rna_path = BKE_animsys_fix_rna_path_rename(id, fcu->rna_path, "pose.bones", old_name, new_name, 0, 0, false); - - /* we don't want to apply a second remapping on this driver now, + + /* we don't want to apply a second remapping on this driver now, * so stop trying names, but keep fixing drivers */ break; } } } - - + + /* Driver targets */ if (fcu->driver) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + /* Fix driver references to invalid ID's */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* only change the used targets, since the others will need fixing manually anyway */ @@ -168,7 +168,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data /* change the ID's used... */ if (dtar->id == src_id) { dtar->id = dst_id; - + /* also check on the subtarget... * XXX: We duplicate the logic from drivers_path_rename_fix() here, with our own * little twists so that we know that it isn't going to clobber the wrong data @@ -177,7 +177,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data GHASH_ITER(gh_iter, afd->names_map) { const char *old_name = BLI_ghashIterator_getKey(&gh_iter); const char *new_name = BLI_ghashIterator_getValue(&gh_iter); - + /* only remap if changed */ if (!STREQ(old_name, new_name)) { if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) { @@ -207,7 +207,7 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr Object *ob; bPose *pose; bPoseChannel *pchant; - + /* let's go through all objects in database */ for (ob = bmain->object.first; ob; ob = ob->id.next) { /* do some object-type specific things */ @@ -217,12 +217,12 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr joined_armature_fix_links_constraints(tarArm, srcArm, pchan, curbone, &pchant->constraints); } } - + /* fix object-level constraints */ if (ob != srcArm) { joined_armature_fix_links_constraints(tarArm, srcArm, pchan, curbone, &ob->constraints); } - + /* See if an object is parented to this armature */ if (ob->parent && (ob->parent == srcArm)) { /* Is object parented to a bone of this src armature? */ @@ -232,7 +232,7 @@ static void joined_armature_fix_links(Main *bmain, Object *tarArm, Object *srcAr BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr)); } } - + /* make tar armature be new parent */ ob->parent = tarArm; } @@ -251,13 +251,13 @@ int join_armature_exec(bContext *C, wmOperator *op) EditBone *curbone; float mat[4][4], oimat[4][4]; bool ok = false; - + /* Ensure we're not in editmode and that the active object is an armature*/ if (!ob || ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; if (!arm || arm->edbo) return OPERATOR_CANCELLED; - + CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases) { if (base->object == ob) { @@ -275,7 +275,7 @@ int join_armature_exec(bContext *C, wmOperator *op) /* Get editbones of active armature to add editbones to */ ED_armature_to_edit(arm); - + /* get pose of active object and move it out of posemode */ pose = ob->pose; ob->mode &= ~OB_MODE_POSE; @@ -285,36 +285,36 @@ int join_armature_exec(bContext *C, wmOperator *op) if ((base->object->type == OB_ARMATURE) && (base->object != ob)) { tJoinArmature_AdtFixData afd = {NULL}; bArmature *curarm = base->object->data; - + /* we assume that each armature datablock is only used in a single place */ BLI_assert(ob->data != base->object->data); - + /* init callback data for fixing up AnimData links later */ afd.srcArm = base->object; afd.tarArm = ob; afd.names_map = BLI_ghash_str_new("join_armature_adt_fix"); - + /* Make a list of editbones in current armature */ ED_armature_to_edit(base->object->data); - + /* Get Pose of current armature */ opose = base->object->pose; base->object->mode &= ~OB_MODE_POSE; //BASACT->flag &= ~OB_MODE_POSE; - + /* Find the difference matrix */ invert_m4_m4(oimat, ob->obmat); mul_m4_m4m4(mat, oimat, base->object->obmat); - + /* Copy bones and posechannels from the object to the edit armature */ for (pchan = opose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; curbone = ED_armature_ebone_find_name(curarm->edbo, pchan->name); - + /* Get new name */ ED_armature_ebone_unique_name(arm->edbo, curbone->name, NULL); BLI_ghash_insert(afd.names_map, BLI_strdup(pchan->name), curbone->name); - + /* Transform the bone */ { float premat[4][4]; @@ -322,48 +322,48 @@ int join_armature_exec(bContext *C, wmOperator *op) float difmat[4][4]; float imat[4][4]; float temp[3][3]; - + /* Get the premat */ ED_armature_ebone_to_mat3(curbone, temp); - + unit_m4(premat); /* mul_m4_m3m4 only sets 3x3 part */ mul_m4_m3m4(premat, temp, mat); - + mul_m4_v3(mat, curbone->head); mul_m4_v3(mat, curbone->tail); - + /* Get the postmat */ ED_armature_ebone_to_mat3(curbone, temp); copy_m4_m3(postmat, temp); - + /* Find the roll */ invert_m4_m4(imat, premat); mul_m4_m4m4(difmat, imat, postmat); - + curbone->roll -= atan2f(difmat[2][0], difmat[2][2]); } - + /* Fix Constraints and Other Links to this Bone and Armature */ joined_armature_fix_links(bmain, ob, base->object, pchan, curbone); - + /* Rename pchan */ BLI_strncpy(pchan->name, curbone->name, sizeof(pchan->name)); - + /* Jump Ship! */ BLI_remlink(curarm->edbo, curbone); BLI_addtail(arm->edbo, curbone); - + BLI_remlink(&opose->chanbase, pchan); BLI_addtail(&pose->chanbase, pchan); BKE_pose_channels_hash_free(opose); BKE_pose_channels_hash_free(pose); } - + /* Fix all the drivers (and animation data) */ BKE_fcurves_main_cb(bmain, joined_armature_fix_animdata_cb, &afd); BLI_ghash_free(afd.names_map, MEM_freeN, NULL); - - /* Only copy over animdata now, after all the remapping has been done, + + /* Only copy over animdata now, after all the remapping has been done, * so that we don't have to worry about ambiguities re which armature * a bone came from! */ @@ -377,7 +377,7 @@ int join_armature_exec(bContext *C, wmOperator *op) BKE_animdata_merge_copy(&ob->id, &base->object->id, ADT_MERGECOPY_KEEP_DST, false); } } - + if (curarm->adt) { if (arm->adt == NULL) { /* no animdata, so just use a copy of the whole thing */ @@ -388,20 +388,20 @@ int join_armature_exec(bContext *C, wmOperator *op) BKE_animdata_merge_copy(&arm->id, &curarm->id, ADT_MERGECOPY_KEEP_DST, false); } } - + /* Free the old object data */ ED_base_object_free_and_unlink(bmain, scene, base); } } CTX_DATA_END; - + DAG_relations_tag_update(bmain); /* because we removed object(s) */ ED_armature_from_edit(arm); ED_armature_edit_free(arm); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); - + return OPERATOR_FINISHED; } @@ -414,11 +414,11 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) bPoseChannel *pchan; bConstraint *con; ListBase *opchans, *npchans; - + /* get reference to list of bones in original and new armatures */ opchans = &origArm->pose->chanbase; npchans = &newArm->pose->chanbase; - + /* let's go through all objects in database */ for (ob = G.main->object.first; ob; ob = ob->id.next) { /* do some object-type specific things */ @@ -428,11 +428,11 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - + /* constraint targets */ if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - + for (ct = targets.first; ct; ct = ct->next) { /* any targets which point to original armature are redirected to the new one only if: * - the target isn't origArm/newArm itself @@ -459,18 +459,18 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) } } } - + /* fix object-level constraints */ if (ob != origArm) { for (con = ob->constraints.first; con; con = con->next) { const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - + /* constraint targets */ if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - + for (ct = targets.first; ct; ct = ct->next) { /* any targets which point to original armature are redirected to the new one only if: * - the target isn't origArm/newArm itself @@ -489,14 +489,14 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) } } } - + if (cti->flush_constraint_targets) { cti->flush_constraint_targets(con, &targets, 0); } } } } - + /* See if an object is parented to this armature */ if (ob->parent && (ob->parent == origArm)) { /* Is object parented to a bone of this src armature? */ @@ -509,31 +509,31 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) } } -/* Helper function for armature separating - remove certain bones from the given armature +/* Helper function for armature separating - remove certain bones from the given armature * sel: remove selected bones from the armature, otherwise the unselected bones are removed * (ob is not in editmode) */ -static void separate_armature_bones(Object *ob, short sel) +static void separate_armature_bones(Object *ob, short sel) { bArmature *arm = (bArmature *)ob->data; bPoseChannel *pchan, *pchann; EditBone *curbone; - + /* make local set of editbones to manipulate here */ ED_armature_to_edit(arm); - + /* go through pose-channels, checking if a bone should be removed */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) { pchann = pchan->next; curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name); - + /* check if bone needs to be removed */ if ( (sel && (curbone->flag & BONE_SELECTED)) || (!sel && !(curbone->flag & BONE_SELECTED)) ) { EditBone *ebo; bPoseChannel *pchn; - + /* clear the bone->parent var of any bone that had this as its parent */ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { if (ebo->parent == curbone) { @@ -542,23 +542,23 @@ static void separate_armature_bones(Object *ob, short sel) ebo->flag &= ~BONE_CONNECTED; } } - + /* clear the pchan->parent var of any pchan that had this as its parent */ for (pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) { if (pchn->parent == pchan) pchn->parent = NULL; } - + /* free any of the extra-data this pchan might have */ BKE_pose_channel_free(pchan); BKE_pose_channels_hash_free(ob->pose); - + /* get rid of unneeded bone */ bone_free(arm, curbone); BLI_freelinkN(&ob->pose->chanbase, pchan); } } - + /* exit editmode (recalculates pchans too) */ ED_armature_from_edit(ob->data); ED_armature_edit_free(ob->data); @@ -572,14 +572,14 @@ static int separate_armature_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); Object *oldob, *newob; Base *oldbase, *newbase; - + /* sanity checks */ if (obedit == NULL) return OPERATOR_CANCELLED; - + /* set wait cursor in case this takes a while */ WM_cursor_wait(1); - + /* we are going to do this as follows (unlike every other instance of separate): * 1. exit editmode +posemode for active armature/base. Take note of what this is. * 2. duplicate base - BASACT is the new one now @@ -596,41 +596,41 @@ static int separate_armature_exec(bContext *C, wmOperator *op) else base->flag &= ~SELECT; } CTX_DATA_END; - + /* 1) store starting settings and exit editmode */ oldob = obedit; oldbase = BASACT; oldob->mode &= ~OB_MODE_POSE; //oldbase->flag &= ~OB_POSEMODE; - + ED_armature_from_edit(obedit->data); ED_armature_edit_free(obedit->data); - + /* 2) duplicate base */ newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ DAG_relations_tag_update(bmain); newob = newbase->object; newbase->flag &= ~SELECT; - - + + /* 3) remove bones that shouldn't still be around on both armatures */ separate_armature_bones(oldob, 1); separate_armature_bones(newob, 0); - - + + /* 4) fix links before depsgraph flushes */ // err... or after? separated_armature_fix_links(oldob, newob); - + DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ - - + + /* 5) restore original conditions */ obedit = oldob; - + ED_armature_to_edit(obedit->data); - + /* parents tips remain selected when connected children are removed. */ ED_armature_edit_deselect_all(obedit); @@ -638,10 +638,10 @@ static int separate_armature_exec(bContext *C, wmOperator *op) /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); - + /* recalc/redraw + cleanup */ WM_cursor_wait(0); - + return OPERATOR_FINISHED; } @@ -651,12 +651,12 @@ void ARMATURE_OT_separate(wmOperatorType *ot) ot->name = "Separate Bones"; ot->idname = "ARMATURE_OT_separate"; ot->description = "Isolate selected bones into a separate armature"; - + /* callbacks */ ot->invoke = WM_operator_confirm; ot->exec = separate_armature_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -680,13 +680,13 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo { EditBone *ebone; float offset[3]; - + if ((selbone->parent) && (selbone->flag & BONE_CONNECTED)) selbone->parent->flag &= ~(BONE_TIPSEL); - + /* make actbone the parent of selbone */ selbone->parent = actbone; - + /* in actbone tree we cannot have a loop */ for (ebone = actbone->parent; ebone; ebone = ebone->parent) { if (ebone->parent == selbone) { @@ -694,21 +694,21 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo ebone->flag &= ~BONE_CONNECTED; } } - + if (mode == ARM_PAR_CONNECT) { /* Connected: Child bones will be moved to the parent tip */ selbone->flag |= BONE_CONNECTED; sub_v3_v3v3(offset, actbone->tail, selbone->head); - + copy_v3_v3(selbone->head, actbone->tail); selbone->rad_head = actbone->rad_tail; - + add_v3_v3(selbone->tail, offset); - + /* offset for all its children */ for (ebone = edbo->first; ebone; ebone = ebone->next) { EditBone *par; - + for (par = ebone->parent; par; par = par->parent) { if (par == selbone) { add_v3_v3(ebone->head, offset); @@ -731,14 +731,14 @@ static const EnumPropertyItem prop_editarm_make_parent_types[] = { {0, NULL, 0, NULL, NULL} }; -static int armature_parent_set_exec(bContext *C, wmOperator *op) +static int armature_parent_set_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); bArmature *arm = (bArmature *)ob->data; EditBone *actbone = CTX_data_active_bone(C); EditBone *actmirb = NULL; short val = RNA_enum_get(op->ptr, "type"); - + /* there must be an active bone */ if (actbone == NULL) { BKE_report(op->reports, RPT_ERROR, "Operation requires an active bone"); @@ -746,27 +746,27 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) } else if (arm->flag & ARM_MIRROR_EDIT) { /* For X-Axis Mirror Editing option, we may need a mirror copy of actbone - * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone + * - if there's a mirrored copy of selbone, try to find a mirrored copy of actbone * (i.e. selbone="child.L" and actbone="parent.L", find "child.R" and "parent.R"). * This is useful for arm-chains, for example parenting lower arm to upper arm * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ actmirb = ED_armature_ebone_get_mirrored(arm->edbo, actbone); - if (actmirb == NULL) + if (actmirb == NULL) actmirb = actbone; } - - /* if there is only 1 selected bone, we assume that that is the active bone, + + /* if there is only 1 selected bone, we assume that that is the active bone, * since a user will need to have clicked on a bone (thus selecting it) to make it active */ if (CTX_DATA_COUNT(C, selected_editable_bones) <= 1) { /* When only the active bone is selected, and it has a parent, - * connect it to the parent, as that is the only possible outcome. + * connect it to the parent, as that is the only possible outcome. */ if (actbone->parent) { bone_connect_to_existing_parent(actbone); - + if ((arm->flag & ARM_MIRROR_EDIT) && (actmirb->parent)) bone_connect_to_existing_parent(actmirb); } @@ -775,16 +775,16 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) /* Parent 'selected' bones to the active one * - the context iterator contains both selected bones and their mirrored copies, * so we assume that unselected bones are mirrored copies of some selected bone - * - since the active one (and/or its mirror) will also be selected, we also need + * - since the active one (and/or its mirror) will also be selected, we also need * to check that we are not trying to operate on them, since such an operation * would cause errors */ - + /* parent selected bones to the active one */ CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { if (ELEM(ebone, actbone, actmirb) == 0) { - if (ebone->flag & BONE_SELECTED) + if (ebone->flag & BONE_SELECTED) bone_connect_to_new_parent(arm->edbo, ebone, actbone, val); else bone_connect_to_new_parent(arm->edbo, ebone, actmirb, val); @@ -792,11 +792,11 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -806,7 +806,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Make Parent"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); int allchildbones = 0; - + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { if (ebone != actbone) { @@ -816,13 +816,13 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const CTX_DATA_END; uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_CONNECT); - + /* ob becomes parent, make the associated menus */ if (allchildbones) uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET); - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -832,15 +832,15 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot) ot->name = "Make Parent"; ot->idname = "ARMATURE_OT_parent_set"; ot->description = "Set the active bone as the parent of the selected bones"; - + /* api callbacks */ ot->invoke = armature_parent_set_invoke; ot->exec = armature_parent_set_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "type", prop_editarm_make_parent_types, 0, "ParentType", "Type of parenting"); } @@ -858,28 +858,28 @@ static void editbone_clear_parent(EditBone *ebone, int mode) /* for nice selection */ ebone->parent->flag &= ~(BONE_TIPSEL); } - + if (mode == 1) ebone->parent = NULL; ebone->flag &= ~BONE_CONNECTED; } -static int armature_parent_clear_exec(bContext *C, wmOperator *op) +static int armature_parent_clear_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_edit_object(C); bArmature *arm = (bArmature *)ob->data; int val = RNA_enum_get(op->ptr, "type"); - + CTX_DATA_BEGIN(C, EditBone *, ebone, selected_editable_bones) { editbone_clear_parent(ebone, val); } CTX_DATA_END; - + ED_armature_edit_sync_selection(arm->edbo); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -889,15 +889,15 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot) ot->name = "Clear Parent"; ot->idname = "ARMATURE_OT_parent_clear"; ot->description = "Remove the parent-child relationship between selected bones and their parents"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = armature_parent_clear_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); } diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index ba856d4e964..a4e916b8e63 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -67,7 +67,7 @@ Bone *ED_armature_bone_find_index(Object *ob, int index) bPoseChannel *pchan; if (ob->pose == NULL) return NULL; index >>= 16; // bone selection codes use left 2 bytes - + pchan = BLI_findlink(&ob->pose->chanbase, index); return pchan ? pchan->bone : NULL; } @@ -86,21 +86,21 @@ void *get_bone_from_selectbuffer( short i; bool takeNext = false; int minsel = 0xffffffff, minunsel = 0xffffffff; - + for (i = 0; i < hits; i++) { hitresult = buffer[3 + (i * 4)]; - + if (!(hitresult & BONESEL_NOSEL)) { if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */ bool sel; - + hitresult &= ~(BONESEL_ANY); /* Determine what the current bone is */ if (obedit == NULL || base->object != obedit) { /* no singular posemode, so check for correct object */ if (base->selcol == (hitresult & 0xFFFF)) { bone = ED_armature_bone_find_index(base->object, hitresult); - + if (findunsel) sel = (bone->flag & BONE_SELECTED); else @@ -115,16 +115,16 @@ void *get_bone_from_selectbuffer( } else { bArmature *arm = obedit->data; - + ebone = BLI_findlink(arm->edbo, hitresult); if (findunsel) sel = (ebone->flag & BONE_SELECTED); else sel = !(ebone->flag & BONE_SELECTED); - + data = ebone; } - + if (data) { if (sel) { if (do_nearest) { @@ -154,10 +154,10 @@ void *get_bone_from_selectbuffer( } } } - + if (firstunSel) return firstunSel; - else + else return firstSel; } @@ -170,18 +170,18 @@ void *get_nearest_bone(bContext *C, const int xy[2], bool findunsel) rcti rect; unsigned int buffer[MAXPICKBUF]; short hits; - + ED_view3d_viewcontext_init(C, &vc); - + // rect.xmin = ... mouseco! rect.xmin = rect.xmax = xy[0]; rect.ymin = rect.ymax = xy[1]; - + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect, VIEW3D_SELECT_PICK_NEAREST); if (hits > 0) return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel, true); - + return NULL; } @@ -214,7 +214,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } - + if (curBone->flag & BONE_CONNECTED) next = curBone->parent; else @@ -243,11 +243,11 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, const wmEv if (!curBone) bone = NULL; } - + ED_armature_edit_sync_selection(arm->edbo); - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); - + return OPERATOR_FINISHED; } @@ -262,15 +262,15 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) ot->name = "Select Connected"; ot->idname = "ARMATURE_OT_select_linked"; ot->description = "Select bones related to selected ones by parent/child relationships"; - + /* api callbacks */ /* leave 'exec' unset */ ot->invoke = armature_select_linked_invoke; ot->poll = armature_select_linked_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); } @@ -380,9 +380,9 @@ cache_end: hitresult = buffer[3 + (i * 4)]; if (!(hitresult & BONESEL_NOSEL)) { int dep; - + ebone = BLI_findlink(arm->edbo, hitresult & ~BONESEL_ANY); - + /* clicks on bone points get advantage */ if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) { /* but also the unselected one */ @@ -391,7 +391,7 @@ cache_end: dep = 1; else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0) dep = 1; - else + else dep = 2; } else { @@ -422,11 +422,11 @@ cache_end: } } } - + if (!(besthitresult & BONESEL_NOSEL)) { - + ebone = BLI_findlink(arm->edbo, besthitresult & ~BONESEL_ANY); - + *r_selmask = 0; if (besthitresult & BONESEL_ROOT) *r_selmask |= BONE_ROOTSEL; @@ -500,10 +500,10 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b if (!extend && !deselect && !toggle) { ED_armature_edit_deselect_all(obedit); } - + /* by definition the non-root connected bones have no root point drawn, * so a root selection needs to be delivered to the parent tip */ - + if (selmask & BONE_SELECTED) { if (nearBone->parent && (nearBone->flag & BONE_CONNECTED)) { /* click in a chain */ @@ -568,16 +568,16 @@ bool ED_armature_edit_select_pick(bContext *C, const int mval[2], bool extend, b else nearBone->flag |= selmask; } - + ED_armature_edit_sync_selection(arm->edbo); - + if (nearBone) { /* then now check for active status */ if (ebone_select_flag(nearBone)) { arm->act_edbone = nearBone; } } - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit); return true; } @@ -605,7 +605,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + /* Set the flags */ CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) { @@ -640,7 +640,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) CTX_DATA_END; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); - + return OPERATOR_FINISHED; } @@ -650,14 +650,14 @@ void ARMATURE_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All"; ot->idname = "ARMATURE_OT_select_all"; ot->description = "Toggle selection status of all bones"; - + /* api callbacks */ ot->exec = armature_de_select_all_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + WM_operator_properties_select_all(ot); } @@ -1085,7 +1085,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) int direction = RNA_enum_get(op->ptr, "direction"); const bool add_to_sel = RNA_boolean_get(op->ptr, "extend"); bool changed = false; - + ob = obedit; arm = (bArmature *)ob->data; @@ -1143,15 +1143,15 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) changed = true; } } - + if (changed == false) { return OPERATOR_CANCELLED; } ED_armature_edit_sync_selection(arm->edbo); - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -1162,16 +1162,16 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Select Hierarchy"; ot->idname = "ARMATURE_OT_select_hierarchy"; ot->description = "Select immediate parent/children of selected bones"; - + /* api callbacks */ ot->exec = armature_select_hierarchy_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index 0458fc4ed1b..8ab8d60af75 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -72,7 +72,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) * This function performs 2 functions: * * a) It returns 1 if the bone is skinnable. - * If we loop over all bones with this + * If we loop over all bones with this * function, we can count the number of * skinnable bones. * b) If the pointer data is non null, @@ -97,10 +97,10 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) segments = bone->segments; else segments = 1; - + if (data->list != NULL) { hbone = (Bone ***) &data->list; - + for (a = 0; a < segments; a++) { **hbone = bone; ++*hbone; @@ -112,10 +112,10 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) return 0; } -static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) +static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { /* This group creates a vertex group to ob that has the - * same name as bone (provided the bone is skinnable). + * same name as bone (provided the bone is skinnable). * If such a vertex group already exist the routine exits. */ if (!(bone->flag & BONE_NO_DEFORM)) { @@ -127,7 +127,7 @@ static int vgroup_add_unique_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) return 0; } -static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) +static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) { /* Bones that are deforming * are regarded to be "skinnable" and are eligible for @@ -135,16 +135,16 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) * * This function performs 2 functions: * - * a) If the bone is skinnable, it creates + * a) If the bone is skinnable, it creates * a vertex group for ob that has * the name of the skinnable bone * (if one doesn't exist already). * b) If the pointer data is non null, * it is treated like a handle to a - * bDeformGroup pointer -- the + * bDeformGroup pointer -- the * bDeformGroup pointer is set to point * to the deform group with the bone's - * name, and the pointer the handle + * name, and the pointer the handle * points to is incremented to point to the * next member of an array of pointers * to bDeformGroups. This way we can loop using @@ -164,7 +164,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) segments = bone->segments; else segments = 1; - + if (!wpmode || ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED))) { if (!(defgroup = defgroup_find_name(ob, bone->name))) { defgroup = BKE_object_defgroup_add_name(ob, bone->name); @@ -174,10 +174,10 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) defgroup = NULL; } } - + if (data->list != NULL) { hgroup = (bDeformGroup ***) &data->list; - + for (a = 0; a < segments; a++) { **hgroup = defgroup; ++*hgroup; @@ -216,25 +216,25 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i } iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, NULL, i, use_topology) : -1; - + /* for each skinnable bone */ for (j = 0; j < numbones; ++j) { if (!selected[j]) continue; - + bone = bonelist[j]; dgroup = dgrouplist[j]; - + /* store the distance-factor from the vertex to the bone */ distance = distfactor_to_bone(verts[i], root[j], tip[j], bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); - + /* add the vert to the deform group if (weight != 0.0) */ if (distance != 0.0f) ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE); else ED_vgroup_vert_remove(ob, dgroup, i); - + /* do same for mirror */ if (dgroupflip && dgroupflip[j] && iflip != -1) { if (distance != 0.0f) @@ -281,10 +281,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* count the number of skinnable bones */ numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); - + if (numbones == 0) return; - + if (BKE_object_defgroup_data_create(ob->data) == NULL) return; @@ -312,13 +312,13 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, for (j = 0; j < numbones; ++j) { bone = bonelist[j]; dgroup = dgrouplist[j]; - + /* handle bbone */ if (heat) { if (segments == 0) { segments = 1; bbone = NULL; - + if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) { if (bone->segments > 1) { segments = bone->segments; @@ -327,10 +327,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } } } - + segments--; } - + /* compute root and tip */ if (bbone) { mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]); @@ -345,10 +345,10 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, copy_v3_v3(root[j], bone->arm_head); copy_v3_v3(tip[j], bone->arm_tail); } - + mul_m4_v3(par->obmat, root[j]); mul_m4_v3(par->obmat, tip[j]); - + /* set selected */ if (wpmode) { if ((arm->layer & bone->layer) && (bone->flag & BONE_SELECTED)) @@ -356,7 +356,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } else selected[j] = 1; - + /* find flipped group */ if (dgroup && mirror) { char name_flip[MAXBONENAME]; @@ -373,12 +373,12 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, if (wpmode) { /* if in weight paint mode, use final verts from derivedmesh */ DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); - + if (dm->foreachMappedVert) { mesh_get_mapped_verts_coords(dm, verts, mesh->totvert); vertsfilled = 1; } - + dm->release(dm); } else if (modifiers_findByType(ob, eModifierType_Subsurf)) { @@ -427,7 +427,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, void ED_object_vgroup_calc_from_armature(ReportList *reports, Scene *scene, Object *ob, Object *par, const int mode, const bool mirror) { - /* Lets try to create some vertex groups + /* Lets try to create some vertex groups * based on the bones of the parent armature. */ bArmature *arm = par->data; @@ -435,7 +435,7 @@ void ED_object_vgroup_calc_from_armature(ReportList *reports, Scene *scene, Obje if (mode == ARM_GROUPS_NAME) { const int defbase_tot = BLI_listbase_count(&ob->defbase); int defbase_add; - /* Traverse the bone list, trying to create empty vertex + /* Traverse the bone list, trying to create empty vertex * groups corresponding to the bone. */ defbase_add = bone_looper(ob, arm->bonebase.first, NULL, vgroup_add_unique_bone_cb); @@ -447,7 +447,7 @@ void ED_object_vgroup_calc_from_armature(ReportList *reports, Scene *scene, Obje } } else if (ELEM(mode, ARM_GROUPS_ENVELOPE, ARM_GROUPS_AUTO)) { - /* Traverse the bone list, trying to create vertex groups + /* Traverse the bone list, trying to create vertex groups * that are populated with the vertices for which the * bone is closest. */ diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 8867189baef..f0e4d5e1102 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -56,7 +56,7 @@ void ED_armature_edit_sync_selection(ListBase *edbo) { EditBone *ebo; - + for (ebo = edbo->first; ebo; ebo = ebo->next) { /* if bone is not selectable, we shouldn't alter this setting... */ if ((ebo->flag & BONE_UNSELECTABLE) == 0) { @@ -66,7 +66,7 @@ void ED_armature_edit_sync_selection(ListBase *edbo) else ebo->flag &= ~BONE_ROOTSEL; } - + if ((ebo->flag & BONE_TIPSEL) && (ebo->flag & BONE_ROOTSEL)) ebo->flag |= BONE_SELECTED; else @@ -93,27 +93,27 @@ void ED_armature_edit_validate_active(struct bArmature *arm) int bone_looper(Object *ob, Bone *bone, void *data, int (*bone_func)(Object *, Bone *, void *)) { - /* We want to apply the function bone_func to every bone - * in an armature -- feed bone_looper the first bone and - * a pointer to the bone_func and watch it go!. The int count + /* We want to apply the function bone_func to every bone + * in an armature -- feed bone_looper the first bone and + * a pointer to the bone_func and watch it go!. The int count * can be useful for counting bones with a certain property * (e.g. skinnable) */ int count = 0; - + if (bone) { /* only do bone_func if the bone is non null */ count += bone_func(ob, bone, data); - + /* try to execute bone_func for the first child */ count += bone_looper(ob, bone->childbase.first, data, bone_func); - + /* try to execute bone_func for the next bone at this * depth of the recursion. */ count += bone_looper(ob, bone->next, data, bone_func); } - + return count; } @@ -272,13 +272,13 @@ EditBone *ED_armature_ebone_get_mirrored(const ListBase *edbo, EditBone *ebo) if (ebo == NULL) return NULL; - + BLI_string_flip_side_name(name_flip, ebo->name, false, sizeof(name_flip)); - + if (!STREQ(name_flip, ebo->name)) { return ED_armature_ebone_find_name(edbo, name_flip); } - + return NULL; } @@ -292,7 +292,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag) /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { EditBone *curBone, *ebone_mirr; - + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { if (curBone->flag & flag) { @@ -303,7 +303,7 @@ void armature_select_mirrored_ex(bArmature *arm, const int flag) } } } - + } void armature_select_mirrored(bArmature *arm) @@ -332,7 +332,7 @@ void armature_tag_select_mirrored(bArmature *arm) } } } - + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { EditBone *ebone_mirr = ED_armature_ebone_get_mirrored(arm->edbo, curBone); @@ -362,17 +362,17 @@ void ED_armature_edit_transform_mirror_update(Object *obedit) { bArmature *arm = obedit->data; EditBone *ebo, *eboflip; - + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { /* no layer check, correct mirror is more important */ if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { eboflip = ED_armature_ebone_get_mirrored(arm->edbo, ebo); - + if (eboflip) { /* we assume X-axis flipping for now */ if (ebo->flag & BONE_TIPSEL) { EditBone *children; - + eboflip->tail[0] = -ebo->tail[0]; eboflip->tail[1] = ebo->tail[1]; eboflip->tail[2] = ebo->tail[2]; @@ -380,7 +380,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit) eboflip->roll = -ebo->roll; eboflip->curveOutX = -ebo->curveOutX; eboflip->roll2 = -ebo->roll2; - + /* Also move connected children, in case children's name aren't mirrored properly */ for (children = arm->edbo->first; children; children = children->next) { if (children->parent == eboflip && children->flag & BONE_CONNECTED) { @@ -397,7 +397,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit) eboflip->roll = -ebo->roll; eboflip->curveInX = -ebo->curveInX; eboflip->roll1 = -ebo->roll1; - + /* Also move connected parent, in case parent's name isn't mirrored properly */ if (eboflip->parent && eboflip->flag & BONE_CONNECTED) { EditBone *parent = eboflip->parent; @@ -410,7 +410,7 @@ void ED_armature_edit_transform_mirror_update(Object *obedit) eboflip->roll = -ebo->roll; eboflip->xwidth = ebo->xwidth; eboflip->zwidth = ebo->zwidth; - + eboflip->curveInX = -ebo->curveInX; eboflip->curveOutX = -ebo->curveOutX; eboflip->roll1 = -ebo->roll1; @@ -431,17 +431,17 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone EditBone *eBoneAct = NULL; EditBone *eBoneTest = NULL; Bone *curBone; - + for (curBone = bones->first; curBone; curBone = curBone->next) { eBone = MEM_callocN(sizeof(EditBone), "make_editbone"); - + /* Copy relevant data from bone to eBone * Keep selection logic in sync with ED_armature_edit_sync_selection. */ eBone->parent = parent; BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name)); eBone->flag = curBone->flag; - + /* fix selection flags */ if (eBone->flag & BONE_SELECTED) { /* if the bone is selected the copy its root selection to the parents tip */ @@ -461,11 +461,11 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->flag &= ~BONE_ROOTSEL; } } - + copy_v3_v3(eBone->head, curBone->arm_head); copy_v3_v3(eBone->tail, curBone->arm_tail); eBone->roll = curBone->arm_roll; - + /* rest of stuff copy */ eBone->length = curBone->length; eBone->dist = curBone->dist; @@ -491,20 +491,20 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone if (curBone->prop) eBone->prop = IDP_CopyProperty(curBone->prop); - + BLI_addtail(edbo, eBone); - + /* Add children if necessary */ if (curBone->childbase.first) { eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone); if (eBoneTest) eBoneAct = eBoneTest; } - + if (curBone == actBone) eBoneAct = eBone; } - + return eBoneAct; } @@ -589,18 +589,18 @@ void ED_armature_from_edit(bArmature *arm) EditBone *eBone, *neBone; Bone *newBone; Object *obt; - + /* armature bones */ BKE_armature_bonelist_free(&arm->bonebase); arm->act_bone = NULL; - + /* remove zero sized bones, this gives unstable restposes */ for (eBone = arm->edbo->first; eBone; eBone = neBone) { float len_sq = len_squared_v3v3(eBone->head, eBone->tail); neBone = eBone->next; if (len_sq <= SQUARE(0.000001f)) { /* FLT_EPSILON is too large? */ EditBone *fBone; - + /* Find any bones that refer to this bone */ for (fBone = arm->edbo->first; fBone; fBone = fBone->next) { if (fBone->parent == eBone) @@ -611,19 +611,19 @@ void ED_armature_from_edit(bArmature *arm) bone_free(arm, eBone); } } - + /* Copy the bones from the editData into the armature */ for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { newBone = MEM_callocN(sizeof(Bone), "bone"); eBone->temp.bone = newBone; /* Associate the real Bones with the EditBones */ - + BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name)); copy_v3_v3(newBone->arm_head, eBone->head); copy_v3_v3(newBone->arm_tail, eBone->tail); newBone->arm_roll = eBone->roll; - + newBone->flag = eBone->flag; - + if (eBone == arm->act_edbone) { /* don't change active selection, this messes up separate which uses * editmode toggle and can separate active bone which is de-selected originally */ @@ -631,10 +631,10 @@ void ED_armature_from_edit(bArmature *arm) arm->act_bone = newBone; } newBone->roll = 0.0f; - + newBone->weight = eBone->weight; newBone->dist = eBone->dist; - + newBone->xwidth = eBone->xwidth; newBone->zwidth = eBone->zwidth; newBone->rad_head = eBone->rad_head; @@ -658,7 +658,7 @@ void ED_armature_from_edit(bArmature *arm) if (eBone->prop) newBone->prop = IDP_CopyProperty(eBone->prop); } - + /* Fix parenting in a separate pass to ensure ebone->bone connections are valid at this point. * Do not set bone->head/tail here anymore, using EditBone data for that is not OK since our later fiddling * with parent's arm_mat (for roll conversion) may have some small but visible impact on locations (T46010). */ @@ -673,24 +673,24 @@ void ED_armature_from_edit(bArmature *arm) BLI_addtail(&arm->bonebase, newBone); } } - + /* Finalize definition of restpose data (roll, bone_mat, arm_mat, head/tail...). */ armature_finalize_restpose(&arm->bonebase, arm->edbo); - + /* so all users of this armature should get rebuilt */ for (obt = G.main->object.first; obt; obt = obt->id.next) { if (obt->data == arm) { BKE_pose_rebuild(obt, arm); } } - + DAG_id_tag_update(&arm->id, 0); } void ED_armature_edit_free(struct bArmature *arm) { EditBone *eBone; - + /* Clear the editbones list */ if (arm->edbo) { if (arm->edbo->first) { @@ -700,7 +700,7 @@ void ED_armature_edit_free(struct bArmature *arm) MEM_freeN(eBone->prop); } } - + BLI_freelistN(arm->edbo); } MEM_freeN(arm->edbo); diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 57843265496..f0135676523 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -38,7 +38,7 @@ void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invma copy_v3_v3(normal, no); mul_m3_v3(tmat, normal); - + bone->roll = ED_armature_ebone_roll_to_vector(bone, normal, false); } } @@ -46,46 +46,46 @@ void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invma float calcArcCorrelation(BArcIterator *iter, int start, int end, float v0[3], float n[3]) { int len = 2 + abs(end - start); - + if (len > 2) { float avg_t = 0.0f; float s_t = 0.0f; float s_xyz = 0.0f; int i; - + /* First pass, calculate average */ for (i = start; i <= end; i++) { float v[3]; - + IT_peek(iter, i); sub_v3_v3v3(v, iter->p, v0); avg_t += dot_v3v3(v, n); } - + avg_t /= dot_v3v3(n, n); avg_t += 1.0f; /* adding start (0) and end (1) values */ avg_t /= len; - + /* Second pass, calculate s_xyz and s_t */ for (i = start; i <= end; i++) { float v[3], d[3]; float dt; - + IT_peek(iter, i); sub_v3_v3v3(v, iter->p, v0); project_v3_v3v3(d, v, n); sub_v3_v3(v, d); - + dt = len_v3(d) - avg_t; - + s_t += dt * dt; s_xyz += dot_v3v3(v, v); } - + /* adding start(0) and end(1) values to s_t */ s_t += (avg_t * avg_t) + (1 - avg_t) * (1 - avg_t); - - return 1.0f - s_xyz / s_t; + + return 1.0f - s_xyz / s_t; } else { return 1.0f; @@ -100,30 +100,30 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta float *v1, *v2; float length_threshold; int i; - + if (stroke_length == 0) { current_length = 0; IT_peek(iter, start); v1 = iter->p; - + for (i = start + 1; i <= end; i++) { IT_peek(iter, i); v2 = iter->p; stroke_length += len_v3v3(v1, v2); - + v1 = v2; } - + n = 0; current_length = 0; } - + n++; - + length_threshold = n * stroke_length / toolsettings->skgen_subdivision_number; - + IT_peek(iter, start); v1 = iter->p; @@ -138,12 +138,12 @@ int nextFixedSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int sta copy_v3_v3(p, v2); return i; } - + v1 = v2; } - + stroke_length = 0; - + return -1; } int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int start, int end, float head[3], float p[3]) @@ -152,7 +152,7 @@ int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, in float *start_p; float n[3]; int i; - + IT_peek(iter, start); start_p = iter->p; @@ -167,7 +167,7 @@ int nextAdaptativeSubdivision(ToolSettings *toolsettings, BArcIterator *iter, in return i - 1; } } - + return -1; } @@ -176,37 +176,37 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st float lengthLimit = toolsettings->skgen_length_limit; int same = 1; int i; - + i = start + 1; while (i <= end) { float *vec0; float *vec1; - + IT_peek(iter, i - 1); vec0 = iter->p; IT_peek(iter, i); vec1 = iter->p; - + /* If lengthLimit hits the current segment */ if (len_v3v3(vec1, head) > lengthLimit) { if (same == 0) { float dv[3], off[3]; float a, b, c, f; - + /* Solve quadratic distance equation */ sub_v3_v3v3(dv, vec1, vec0); a = dot_v3v3(dv, dv); - + sub_v3_v3v3(off, vec0, head); b = 2 * dot_v3v3(dv, off); - + c = dot_v3v3(off, off) - (lengthLimit * lengthLimit); - + f = (-b + sqrtf(b * b - 4 * a * c)) / (2 * a); - + //printf("a %f, b %f, c %f, f %f\n", a, b, c, f); - + if (isnan(f) == 0 && f < 1.0f) { copy_v3_v3(p, dv); mul_v3_fl(p, f); @@ -218,15 +218,15 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st } else { float dv[3]; - + sub_v3_v3v3(dv, vec1, vec0); normalize_v3(dv); - + copy_v3_v3(p, dv); mul_v3_fl(p, lengthLimit); add_v3_v3(p, head); } - + return i - 1; /* restart at lower bound */ } else { @@ -234,7 +234,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st same = 0; // Reset same } } - + return -1; } @@ -249,18 +249,18 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U int bone_start = 0; int end = iter->length; int index; - + IT_head(iter); - + parent = ED_armature_ebone_add(arm, "Bone"); copy_v3_v3(parent->head, iter->p); - + if (iter->size > FLT_EPSILON) { parent->rad_head = iter->size * size_buffer; } - + normal = iter->no; - + index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail); while (index != -1) { IT_peek(iter, index); @@ -269,7 +269,7 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U copy_v3_v3(child->head, parent->tail); child->parent = parent; child->flag |= BONE_CONNECTED; - + if (iter->size > FLT_EPSILON) { child->rad_head = iter->size * size_buffer; parent->rad_tail = iter->size * size_buffer; @@ -287,19 +287,19 @@ EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *U index = next_subdividion(toolsettings, iter, bone_start, end, parent->head, parent->tail); } - + iter->tail(iter); copy_v3_v3(parent->tail, iter->p); if (iter->size > FLT_EPSILON) { parent->rad_tail = iter->size * size_buffer; } - + /* fix last bone */ mul_m4_v3(invmat, parent->tail); mul_m4_v3(invmat, parent->head); setBoneRollFromNormal(parent, iter->no, invmat, tmat); lastBone = parent; - + return lastBone; } diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 6b2893780d7..ad0025955c2 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -65,7 +65,7 @@ typedef struct RetargetParam { typedef enum { RETARGET_LENGTH, RETARGET_AGGRESSIVE -} RetargetMode; +} RetargetMode; typedef enum { METHOD_BRUTE_FORCE = 0, @@ -88,7 +88,7 @@ static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second); float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]); /* two levels */ -#define SHAPE_LEVELS (SHAPE_RADIX * SHAPE_RADIX) +#define SHAPE_LEVELS (SHAPE_RADIX * SHAPE_RADIX) /*********************************** EDITBONE UTILS ****************************************************/ @@ -96,20 +96,20 @@ static int countEditBoneChildren(ListBase *list, EditBone *parent) { EditBone *ebone; int count = 0; - + for (ebone = list->first; ebone; ebone = ebone->next) { if (ebone->parent == parent) { count++; } } - + return count; } static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n) { EditBone *ebone; - + for (ebone = list->first; ebone; ebone = ebone->next) { if (ebone->parent == parent) { if (n == 0) { @@ -118,7 +118,7 @@ static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n) n--; } } - + return NULL; } @@ -127,7 +127,7 @@ static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3]) float mat[3][3], nor[3]; sub_v3_v3v3(nor, bone->tail, bone->head); - + vec_roll_to_mat3(nor, roll, mat); copy_v3_v3(up_axis, mat[2]); } @@ -135,27 +135,27 @@ static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3]) static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3]) { float nor[3], new_up_axis[3], x_axis[3], z_axis[3]; - + copy_v3_v3(new_up_axis, old_up_axis); mul_qt_v3(qrot, new_up_axis); - + sub_v3_v3v3(nor, bone->tail, bone->head); - + cross_v3_v3v3(x_axis, nor, aligned_axis); cross_v3_v3v3(z_axis, x_axis, nor); - + normalize_v3(new_up_axis); normalize_v3(x_axis); normalize_v3(z_axis); - + if (dot_v3v3(new_up_axis, x_axis) < 0) { negate_v3(x_axis); } - + if (dot_v3v3(new_up_axis, z_axis) < 0) { negate_v3(z_axis); } - + if (angle_normalized_v3v3(x_axis, new_up_axis) < angle_normalized_v3v3(z_axis, new_up_axis)) { rotation_between_vecs_to_quat(qroll, new_up_axis, x_axis); /* set roll rotation quat */ return ED_armature_ebone_roll_to_vector(bone, x_axis, false); @@ -175,7 +175,7 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4] else { float new_up_axis[3]; float vec_first[3], vec_second[3], normal[3]; - + if (previous->bone) { sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head); } @@ -186,24 +186,24 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4] /* default to up_axis if first bone in the chain is an offset */ return rollBoneByQuatAligned(edge->bone, edge->up_axis, qrot, qroll, up_axis); } - + sub_v3_v3v3(vec_second, edge->bone->tail, edge->bone->head); - + normalize_v3(vec_first); normalize_v3(vec_second); - + cross_v3_v3v3(normal, vec_first, vec_second); normalize_v3(normal); - + axis_angle_to_quat(qroll, vec_second, edge->up_angle); - + mul_qt_v3(qroll, normal); - + copy_v3_v3(new_up_axis, edge->up_axis); mul_qt_v3(qrot, new_up_axis); - + normalize_v3(new_up_axis); - + /* real qroll between normal and up_axis */ rotation_between_vecs_to_quat(qroll, new_up_axis, normal); @@ -214,10 +214,10 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4] float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]) { float new_up_axis[3]; - + copy_v3_v3(new_up_axis, old_up_axis); mul_qt_v3(qrot, new_up_axis); - + return ED_armature_ebone_roll_to_vector(bone, new_up_axis, false); } @@ -233,34 +233,34 @@ void RIG_freeRigGraph(BGraph *rg) RigGraph *rigg = (RigGraph *)rg; BNode *node; BArc *arc; - + BLI_task_pool_free(rigg->task_pool); BLI_task_scheduler_free(rigg->task_scheduler); - + if (rigg->link_mesh) { REEB_freeGraph(rigg->link_mesh); } - + for (arc = rg->arcs.first; arc; arc = arc->next) { RIG_freeRigArc(arc); } BLI_freelistN(&rg->arcs); - + for (node = rg->nodes.first; node; node = node->next) { BLI_freeNode(rg, (BNode *)node); } BLI_freelistN(&rg->nodes); - + BLI_freelistN(&rigg->controls); BLI_ghash_free(rigg->bones_map, NULL, NULL); BLI_ghash_free(rigg->controls_map, NULL, NULL); - + if (rigg->flag & RIG_FREE_BONELIST) { BLI_freelistN(rigg->editbones); MEM_freeN(rigg->editbones); } - + MEM_freeN(rg); } @@ -270,17 +270,17 @@ static RigGraph *newRigGraph(void) { RigGraph *rg; int totthread; - + rg = MEM_callocN(sizeof(RigGraph), "rig graph"); - + rg->head = NULL; - + rg->bones_map = BLI_ghash_str_new("newRigGraph bones gh"); rg->controls_map = BLI_ghash_str_new("newRigGraph cont gh"); - + rg->free_arc = RIG_freeRigArc; rg->free_node = NULL; - + #ifdef USE_THREADS totthread = TASK_SCHEDULER_AUTO_THREADS; #else @@ -296,22 +296,22 @@ static RigGraph *newRigGraph(void) static RigArc *newRigArc(RigGraph *rg) { RigArc *arc; - + arc = MEM_callocN(sizeof(RigArc), "rig arc"); arc->count = 0; BLI_addtail(&rg->arcs, arc); - + return arc; } static RigControl *newRigControl(RigGraph *rg) { RigControl *ctrl; - + ctrl = MEM_callocN(sizeof(RigControl), "rig control"); - + BLI_addtail(&rg->controls, ctrl); - + return ctrl; } @@ -324,9 +324,9 @@ static RigNode *newRigNodeHead(RigGraph *rg, RigArc *arc, float p[3]) copy_v3_v3(node->p, p); node->degree = 1; node->arcs = NULL; - + arc->head = node; - + return node; } @@ -346,14 +346,14 @@ static RigNode *newRigNode(RigGraph *rg, float p[3]) copy_v3_v3(node->p, p); node->degree = 0; node->arcs = NULL; - + return node; } static RigNode *newRigNodeTail(RigGraph *rg, RigArc *arc, float p[3]) { RigNode *node = newRigNode(rg, p); - + node->degree = 1; arc->tail = node; @@ -372,11 +372,11 @@ static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge) copy_v3_v3(edge->head, last_edge->tail); RIG_calculateEdgeAngles(last_edge, edge); } - + edge->length = len_v3v3(edge->head, edge->tail); - + arc->length += edge->length; - + arc->count += 1; } @@ -388,11 +388,11 @@ static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone) copy_v3_v3(edge->tail, tail); edge->bone = bone; - + if (bone) { getEditBoneRollUpAxis(bone, bone->roll, edge->up_axis); } - + RIG_appendEdgeToArc(arc, edge); } /************************************** CLONING TEMPLATES **********************************************/ @@ -400,7 +400,7 @@ static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone) static void renameTemplateBone(char *name, char *template_name, ListBase *editbones, char *side_string, char *num_string) { int i, j; - + for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) { if (template_name[i] == '&') { if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') { @@ -421,9 +421,9 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo j++; } } - + name[j] = '\0'; - + ED_armature_ebone_unique_name(editbones, name, NULL); } @@ -431,14 +431,14 @@ static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ { RigControl *ctrl; char name[MAXBONENAME]; - + ctrl = newRigControl(rg); - + copy_v3_v3(ctrl->head, src_ctrl->head); copy_v3_v3(ctrl->tail, src_ctrl->tail); copy_v3_v3(ctrl->up_axis, src_ctrl->up_axis); copy_v3_v3(ctrl->offset, src_ctrl->offset); - + ctrl->tail_mode = src_ctrl->tail_mode; ctrl->flag = src_ctrl->flag; @@ -446,10 +446,10 @@ static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob); ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone); - + ctrl->link = src_ctrl->link; ctrl->link_tail = src_ctrl->link_tail; - + return ctrl; } @@ -457,32 +457,32 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * { RigEdge *src_edge; RigArc *arc; - + arc = newRigArc(rg); - + arc->head = BLI_ghash_lookup(ptr_hash, src_arc->head); arc->tail = BLI_ghash_lookup(ptr_hash, src_arc->tail); - + arc->head->degree++; arc->tail->degree++; - + arc->length = src_arc->length; arc->count = src_arc->count; - + for (src_edge = src_arc->edges.first; src_edge; src_edge = src_edge->next) { RigEdge *edge; - + edge = MEM_callocN(sizeof(RigEdge), "rig edge"); copy_v3_v3(edge->head, src_edge->head); copy_v3_v3(edge->tail, src_edge->tail); copy_v3_v3(edge->up_axis, src_edge->up_axis); - + edge->length = src_edge->length; edge->angle = src_edge->angle; edge->up_angle = src_edge->up_angle; - + if (src_edge->bone != NULL) { char name[MAXBONENAME]; renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string); @@ -493,7 +493,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * BLI_addtail(&arc->edges, edge); } - + return arc; } @@ -504,54 +504,54 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c RigArc *arc; RigControl *ctrl; RigGraph *rg; - + ptr_hash = BLI_ghash_ptr_new("cloneRigGraph gh"); rg = newRigGraph(); - + rg->ob = ob; rg->editbones = editbones; - + preEditBoneDuplicate(rg->editbones); /* prime bones for duplication */ preEditBoneDuplicate(src->editbones); /* prime bones for duplication */ - + /* Clone nodes */ for (node = src->nodes.first; node; node = node->next) { RigNode *cloned_node = newRigNode(rg, node->p); BLI_ghash_insert(ptr_hash, node, cloned_node); } - + rg->head = BLI_ghash_lookup(ptr_hash, src->head); - + /* Clone arcs */ for (arc = src->arcs.first; arc; arc = arc->next) { cloneArc(rg, src, arc, ptr_hash, side_string, num_string); } - + /* Clone controls */ for (ctrl = src->controls.first; ctrl; ctrl = ctrl->next) { cloneControl(rg, src, ctrl, ptr_hash, side_string, num_string); } - + /* Relink bones properly */ for (arc = rg->arcs.first; arc; arc = arc->next) { RigEdge *edge; - + for (edge = arc->edges.first; edge; edge = edge->next) { if (edge->bone != NULL) { EditBone *bone; - + updateDuplicateSubtargetObjects(edge->bone, src->editbones, src->ob, rg->ob); if (edge->bone->parent) { bone = BLI_ghash_lookup(ptr_hash, edge->bone->parent); - + if (bone != NULL) { edge->bone->parent = bone; } else { /* disconnect since parent isn't cloned - * this will only happen when cloning from selected bones + * this will only happen when cloning from selected bones * */ edge->bone->flag &= ~BONE_CONNECTED; } @@ -559,21 +559,21 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c } } } - + for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) { EditBone *bone; - + updateDuplicateSubtargetObjects(ctrl->bone, src->editbones, src->ob, rg->ob); if (ctrl->bone->parent) { bone = BLI_ghash_lookup(ptr_hash, ctrl->bone->parent); - + if (bone != NULL) { ctrl->bone->parent = bone; } else { /* disconnect since parent isn't cloned - * this will only happen when cloning from selected bones + * this will only happen when cloning from selected bones * */ ctrl->bone->flag &= ~BONE_CONNECTED; } @@ -582,9 +582,9 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c ctrl->link = BLI_ghash_lookup(ptr_hash, ctrl->link); ctrl->link_tail = BLI_ghash_lookup(ptr_hash, ctrl->link_tail); } - + BLI_ghash_free(ptr_hash, NULL, NULL); - + return rg; } @@ -594,15 +594,15 @@ static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, c static void RIG_calculateEdgeAngles(RigEdge *edge_first, RigEdge *edge_second) { float vec_first[3], vec_second[3]; - - sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head); + + sub_v3_v3v3(vec_first, edge_first->tail, edge_first->head); sub_v3_v3v3(vec_second, edge_second->tail, edge_second->head); normalize_v3(vec_first); normalize_v3(vec_second); - + edge_first->angle = angle_normalized_v3v3(vec_first, vec_second); - + if (edge_second->bone != NULL) { float normal[3]; @@ -623,7 +623,7 @@ static void RIG_addControlBone(RigGraph *rg, EditBone *bone) copy_v3_v3(ctrl->tail, bone->tail); getEditBoneRollUpAxis(bone, bone->roll, ctrl->up_axis); ctrl->tail_mode = TL_NONE; - + BLI_ghash_insert(rg->controls_map, bone->name, ctrl); } @@ -632,64 +632,64 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link) if (link) { float offset[3]; int flag = 0; - + sub_v3_v3v3(offset, ctrl->bone->head, link->head); /* if root matches, check for direction too */ if (dot_v3v3(offset, offset) < 0.0001f) { float vbone[3], vparent[3]; - + flag |= RIG_CTRL_FIT_ROOT; - + sub_v3_v3v3(vbone, ctrl->bone->tail, ctrl->bone->head); sub_v3_v3v3(vparent, link->tail, link->head); - + /* test for opposite direction */ if (dot_v3v3(vbone, vparent) > 0) { float nor[3]; float len; - + cross_v3_v3v3(nor, vbone, vparent); - + len = dot_v3v3(nor, nor); if (len < 0.0001f) { flag |= RIG_CTRL_FIT_BONE; } } } - + /* Bail out if old one is automatically better */ if (flag < ctrl->flag) { return 0; } - + /* if there's already a link * overwrite only if new link is higher in the chain */ if (ctrl->link && flag == ctrl->flag) { EditBone *bone = NULL; - + for (bone = ctrl->link; bone; bone = bone->parent) { /* if link is in the chain, break and use that one */ if (bone == link) { break; } } - + /* not in chain, don't update link */ if (bone == NULL) { return 0; } } - - + + ctrl->link = link; ctrl->flag = flag; - + copy_v3_v3(ctrl->offset, offset); - + return 1; } - + return 0; } @@ -697,31 +697,31 @@ static void RIG_reconnectControlBones(RigGraph *rg) { RigControl *ctrl; bool changed = true; - + /* first pass, link to deform bones */ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) { bPoseChannel *pchan; bConstraint *con; int found = 0; - + /* DO SOME MAGIC HERE */ for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) { for (con = pchan->constraints.first; con; con = con->next) { const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - + /* constraint targets */ if (cti && cti->get_constraint_targets) { int target_index; - + cti->get_constraint_targets(con, &targets); - + for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) { if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) { /* SET bone link to bone corresponding to pchan */ EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name); - + /* Making sure bone is in this armature */ if (link != NULL) { /* for pole targets, link to parent bone instead, if possible */ @@ -730,12 +730,12 @@ static void RIG_reconnectControlBones(RigGraph *rg) link = link->parent; } } - + found = RIG_parentControl(ctrl, link); } } } - + if (cti->flush_constraint_targets) cti->flush_constraint_targets(con, &targets, 0); } @@ -749,25 +749,25 @@ static void RIG_reconnectControlBones(RigGraph *rg) * NULL if not * */ EditBone *link = BLI_ghash_lookup(rg->bones_map, ctrl->bone->parent->name); - + found = RIG_parentControl(ctrl, link); } - + /* check if bone is not superposed on another one */ { RigArc *arc; RigArc *best_arc = NULL; EditBone *link = NULL; - + for (arc = rg->arcs.first; arc; arc = arc->next) { RigEdge *edge; for (edge = arc->edges.first; edge; edge = edge->next) { if (edge->bone) { int fit = 0; - + fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001f; fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001f; - + if (fit) { /* pick the bone on the arc with the lowest symmetry level * means you connect control to the trunk of the skeleton */ @@ -779,17 +779,17 @@ static void RIG_reconnectControlBones(RigGraph *rg) } } } - + found = RIG_parentControl(ctrl, link); } } - + /* if not found yet, check child */ if (found == 0) { RigArc *arc; RigArc *best_arc = NULL; EditBone *link = NULL; - + for (arc = rg->arcs.first; arc; arc = arc->next) { RigEdge *edge; for (edge = arc->edges.first; edge; edge = edge->next) { @@ -803,17 +803,17 @@ static void RIG_reconnectControlBones(RigGraph *rg) } } } - + found = RIG_parentControl(ctrl, link); } } - - + + /* second pass, make chains in control bones */ while (changed) { changed = false; - + for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) { /* if control is not linked yet */ if (ctrl->link == NULL) { @@ -828,18 +828,18 @@ static void RIG_reconnectControlBones(RigGraph *rg) } /* check constraints first */ - + /* DO SOME MAGIC HERE */ for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) { for (con = pchan->constraints.first; con; con = con->next) { const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - + /* constraint targets */ if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == rg->ob) && STREQ(ct->subtarget, ctrl->bone->name)) { /* SET bone link to ctrl corresponding to pchan */ @@ -853,7 +853,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) } } } - + if (cti->flush_constraint_targets) cti->flush_constraint_targets(con, &targets, 0); } @@ -881,19 +881,19 @@ static void RIG_reconnectControlBones(RigGraph *rg) } } } - + /* third pass, link control tails */ for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) { /* fit bone already means full match, so skip those */ if ((ctrl->flag & RIG_CTRL_FIT_BONE) == 0) { GHashIterator ghi; - + /* look on deform bones first */ BLI_ghashIterator_init(&ghi, rg->bones_map); - + for (; !BLI_ghashIterator_done(&ghi); BLI_ghashIterator_step(&ghi)) { EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi); - + /* don't link with parent */ if (bone->parent != ctrl->bone) { if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f) { @@ -908,14 +908,14 @@ static void RIG_reconnectControlBones(RigGraph *rg) } } } - + /* if we haven't found one yet, look in control bones */ if (ctrl->tail_mode == TL_NONE) { /* pass */ } } } - + } /*******************************************************************************************************/ @@ -923,44 +923,44 @@ static void RIG_reconnectControlBones(RigGraph *rg) static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigArc *joined_arc2) { RigEdge *edge, *next_edge; - + /* ignore cases where joint is at start or end */ if (joined_arc1->head == joined_arc2->head || joined_arc1->tail == joined_arc2->tail) { return; } - + /* swap arcs to make sure arc1 is before arc2 */ if (joined_arc1->head == joined_arc2->tail) { RigArc *tmp = joined_arc1; joined_arc1 = joined_arc2; joined_arc2 = tmp; } - + for (edge = joined_arc2->edges.first; edge; edge = next_edge) { next_edge = edge->next; - + RIG_appendEdgeToArc(joined_arc1, edge); } - + joined_arc1->tail = joined_arc2->tail; - + BLI_listbase_clear(&joined_arc2->edges); - + BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2); - + BLI_removeNode((BGraph *)rg, (BNode *)node); } static void RIG_removeNormalNodes(RigGraph *rg) { RigNode *node, *next_node; - + for (node = rg->nodes.first; node; node = next_node) { next_node = node->next; - + if (node->degree == 2) { RigArc *arc, *joined_arc1 = NULL, *joined_arc2 = NULL; - + for (arc = rg->arcs.first; arc; arc = arc->next) { if (arc->head == node || arc->tail == node) { if (joined_arc1 == NULL) { @@ -972,7 +972,7 @@ static void RIG_removeNormalNodes(RigGraph *rg) } } } - + RIG_joinArcs(rg, node, joined_arc1, joined_arc2); } } @@ -981,13 +981,13 @@ static void RIG_removeNormalNodes(RigGraph *rg) static void RIG_removeUneededOffsets(RigGraph *rg) { RigArc *arc; - + for (arc = rg->arcs.first; arc; arc = arc->next) { RigEdge *first_edge, *last_edge; - + first_edge = arc->edges.first; last_edge = arc->edges.last; - + if (first_edge->bone == NULL) { if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f) { BLI_remlink(&arc->edges, first_edge); @@ -995,7 +995,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } else if (arc->head->degree == 1) { RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f); - + if (new_node) { BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); @@ -1003,11 +1003,11 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } else { RigEdge *next_edge = first_edge->next; - + if (next_edge) { BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); - + copy_v3_v3(arc->head->p, next_edge->head); } } @@ -1020,24 +1020,24 @@ static void RIG_removeUneededOffsets(RigGraph *rg) RigEdge *test_edge; if (other_arc->head == arc->head) { test_edge = other_arc->edges.first; - + if (test_edge->bone != NULL) { break; } } else if (other_arc->tail == arc->head) { test_edge = other_arc->edges.last; - + if (test_edge->bone != NULL) { break; } } } } - + if (other_arc == NULL) { RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001); - + if (new_node) { /* remove null edge in other arcs too */ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) { @@ -1057,20 +1057,20 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } } } - + BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head); } else { RigEdge *next_edge = first_edge->next; - + if (next_edge) { BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); - + copy_v3_v3(arc->head->p, next_edge->head); - + /* remove null edge in other arcs too */ for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next) { if (other_arc != arc) { @@ -1092,7 +1092,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } } } - + if (last_edge->bone == NULL) { if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f) { BLI_remlink(&arc->edges, last_edge); @@ -1100,14 +1100,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } else if (arc->tail->degree == 1) { RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f); - + if (new_node) { RigEdge *previous_edge = last_edge->prev; - + BLI_remlink(&arc->edges, last_edge); MEM_freeN(last_edge); BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail); - + /* set previous angle to 0, since there's no following edges */ if (previous_edge) { previous_edge->angle = 0; @@ -1115,11 +1115,11 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } else { RigEdge *previous_edge = last_edge->prev; - + if (previous_edge) { BLI_remlink(&arc->edges, last_edge); MEM_freeN(last_edge); - + copy_v3_v3(arc->tail->p, previous_edge->tail); previous_edge->angle = 0; } @@ -1134,17 +1134,17 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo EditBone *bone, *last_bone = root_bone; RigArc *arc = NULL; int contain_head = 0; - + for (bone = root_bone; bone; bone = nextEditBoneChild(list, bone, 0)) { int nb_children; - + if (selected == 0 || (bone->flag & BONE_SELECTED)) { if ((bone->flag & BONE_NO_DEFORM) == 0) { BLI_ghash_insert(rg->bones_map, bone->name, bone); - + if (arc == NULL) { arc = newRigArc(rg); - + if (starting_node == NULL) { starting_node = newRigNodeHead(rg, arc, root_bone->head); } @@ -1152,15 +1152,15 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo addRigNodeHead(rg, arc, starting_node); } } - + if (bone->parent && (bone->flag & BONE_CONNECTED) == 0) { RIG_addEdgeToArc(arc, bone->head, NULL); } - + RIG_addEdgeToArc(arc, bone->tail, bone); - + last_bone = bone; - + if (STREQ(bone->name, "head")) { contain_head = 1; } @@ -1169,12 +1169,12 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo RIG_addControlBone(rg, bone); } } - + nb_children = countEditBoneChildren(list, bone); if (nb_children > 1) { RigNode *end_node = NULL; int i; - + if (arc != NULL) { end_node = newRigNodeTail(rg, arc, bone->tail); } @@ -1186,12 +1186,12 @@ static void RIG_arcFromBoneChain(RigGraph *rg, ListBase *list, EditBone *root_bo root_bone = nextEditBoneChild(list, bone, i); RIG_arcFromBoneChain(rg, list, root_bone, end_node, selected); } - + /* arc ends here, break */ break; } } - + /* If the loop exited without forking */ if (arc != NULL && bone == NULL) { newRigNodeTail(rg, arc, last_bone->tail); @@ -1208,22 +1208,22 @@ static void RIG_findHead(RigGraph *rg) if (rg->head == NULL) { if (BLI_listbase_is_single(&rg->arcs)) { RigArc *arc = rg->arcs.first; - + rg->head = (RigNode *)arc->head; } else { RigArc *arc; - + for (arc = rg->arcs.first; arc; arc = arc->next) { RigEdge *edge = arc->edges.last; - + if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) { rg->head = arc->tail; break; } } } - + if (rg->head == NULL) { rg->head = rg->nodes.first; } @@ -1235,13 +1235,13 @@ static void RIG_findHead(RigGraph *rg) static void RIG_printNode(RigNode *node, const char name[]) { printf("%s %p %i <%0.3f, %0.3f, %0.3f>\n", name, (void *)node, node->degree, node->p[0], node->p[1], node->p[2]); - + if (node->symmetry_flag & SYM_TOPOLOGICAL) { if (node->symmetry_flag & SYM_AXIAL) printf("Symmetry AXIAL\n"); else if (node->symmetry_flag & SYM_RADIAL) printf("Symmetry RADIAL\n"); - + print_v3("symmetry axis", node->symmetry_axis); } } @@ -1262,13 +1262,13 @@ void RIG_printArcBones(RigArc *arc) static void RIG_printCtrl(RigControl *ctrl, char *indent) { char text[128]; - + printf("%sBone: %s\n", indent, ctrl->bone->name); printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!"); - + BLI_snprintf(text, sizeof(text), "%soffset", indent); print_v3(text, ctrl->offset); - + printf("%sFlag: %i\n", indent, ctrl->flag); } @@ -1278,13 +1278,13 @@ static void RIG_printLinkedCtrl(RigGraph *rg, EditBone *bone, int tabs) char indent[64]; char *s = indent; int i; - + for (i = 0; i < tabs; i++) { s[0] = '\t'; s++; } s[0] = 0; - + for (ctrl = rg->controls.first; ctrl; ctrl = ctrl->next) { if (ctrl->link == bone) { RIG_printCtrl(ctrl, indent); @@ -1341,7 +1341,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm) RigGraph *rg; rg = newRigGraph(); - + if (obedit == ob) { rg->editbones = ((bArmature *)obedit->data)->edbo; } @@ -1350,7 +1350,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm) make_boneList(rg->editbones, &arm->bonebase, NULL, NULL); rg->flag |= RIG_FREE_BONELIST; } - + rg->ob = ob; /* Do the rotations */ @@ -1359,25 +1359,25 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm) RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0); } } - + BLI_removeDoubleNodes((BGraph *)rg, 0.001); - + RIG_removeNormalNodes(rg); - + RIG_removeUneededOffsets(rg); - + BLI_buildAdjacencyList((BGraph *)rg); - + RIG_findHead(rg); BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit); - + RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */ - + if (BLI_isGraphCyclic((BGraph *)rg)) { printf("armature cyclic\n"); } - + return rg; } @@ -1389,7 +1389,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm RigGraph *rg; rg = newRigGraph(); - + if (obedit == ob) { rg->editbones = arm->edbo; } @@ -1407,25 +1407,25 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1); } } - + BLI_removeDoubleNodes((BGraph *)rg, 0.001); - + RIG_removeNormalNodes(rg); - + RIG_removeUneededOffsets(rg); - + BLI_buildAdjacencyList((BGraph *)rg); - + RIG_findHead(rg); BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit); - + RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */ - + if (BLI_isGraphCyclic((BGraph *)rg)) { printf("armature cyclic\n"); } - + return rg; } /************************************ GENERATING *****************************************************/ @@ -1434,12 +1434,12 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm static EditBone *add_editbonetolist(char *name, ListBase *list) { EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); - + BLI_strncpy(bone->name, name, sizeof(bone->name)); ED_armature_ebone_unique_name(list, bone->name, NULL); - + BLI_addtail(list, bone); - + bone->flag |= BONE_TIPSEL; bone->weight = 1.0F; bone->dist = 0.25F; @@ -1449,7 +1449,7 @@ static EditBone *add_editbonetolist(char *name, ListBase *list) bone->rad_tail = 0.05; bone->segments = 1; bone->layer = 1; //arm->layer; - + /* Bendy-Bone parameters */ bone->roll1 = 0.0f; bone->roll2 = 0.0f; @@ -1473,26 +1473,26 @@ static void generateMissingArcsFromNode(RigGraph *rigg, ReebNode *node, int mult { node = node->link_up; } - + while (node->multi_level < multi_level_limit && node->link_down) { node = node->link_down; } - + if (node->multi_level == multi_level_limit) { int i; - + for (i = 0; i < node->degree; i++) { ReebArc *earc = node->arcs[i]; - + if (earc->flag == ARC_FREE && earc->head == node) { ReebNode *other = BIF_otherNodeFromIndex(earc, node); - + earc->flag = ARC_USED; - + //generateBonesForArc(rigg, earc, node, other); generateMissingArcsFromNode(rigg, other, multi_level_limit); } @@ -1504,11 +1504,11 @@ static void generateMissingArcs(RigGraph *rigg) { ReebGraph *reebg; int multi_level_limit = 5; - + for (reebg = rigg->link_mesh; reebg; reebg = reebg->link_up) { ReebArc *earc; - + for (earc = reebg->arcs.first; earc; earc = earc->next) { if (earc->flag == ARC_USED) @@ -1532,42 +1532,42 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize) if ((ctrl->flag & RIG_CTRL_DONE) == RIG_CTRL_DONE) { RigControl *ctrl_child; -#if 0 +#if 0 printf("CTRL: %s LINK: %s", ctrl->bone->name, ctrl->link->name); - + if (ctrl->link_tail) { printf(" TAIL: %s", ctrl->link_tail->name); } - + printf("\n"); #endif - + /* if there was a tail link: apply link, recalc resize factor and qrot */ if (ctrl->tail_mode != TL_NONE) { float *tail_vec = NULL; float v1[3], v2[3], qtail[4]; - + if (ctrl->tail_mode == TL_TAIL) { tail_vec = ctrl->link_tail->tail; } else if (ctrl->tail_mode == TL_HEAD) { tail_vec = ctrl->link_tail->head; } - + sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head); sub_v3_v3v3(v2, tail_vec, ctrl->bone->head); - + copy_v3_v3(ctrl->bone->tail, tail_vec); - + rotation_between_vecs_to_quat(qtail, v1, v2); mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot); - + resize = len_v3(v2) / len_v3v3(ctrl->head, ctrl->tail); } - + ctrl->bone->roll = rollBoneByQuat(ctrl->bone, ctrl->up_axis, ctrl->qrot); - + /* Cascade to connected control bones */ for (ctrl_child = rigg->controls.first; ctrl_child; ctrl_child = ctrl_child->next) { if (ctrl_child->link == ctrl->bone) { @@ -1590,12 +1590,12 @@ static void repositionTailControl(RigGraph *rigg, RigControl *ctrl) static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], float UNUSED(tail[3]), float qrot[4], float resize) { float parent_offset[3], tail_offset[3]; - + copy_v3_v3(parent_offset, ctrl->offset); mul_v3_fl(parent_offset, resize); mul_qt_v3(qrot, parent_offset); - - add_v3_v3v3(ctrl->bone->head, head, parent_offset); + + add_v3_v3v3(ctrl->bone->head, head, parent_offset); ctrl->flag |= RIG_CTRL_HEAD_DONE; @@ -1607,7 +1607,7 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f mul_qt_v3(qrot, tail_offset); add_v3_v3v3(ctrl->bone->tail, ctrl->bone->head, tail_offset); - + ctrl->flag |= RIG_CTRL_TAIL_DONE; } @@ -1622,22 +1622,22 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec float qrot[4], resize; float v1[3], v2[3]; float l1, l2; - + bone = edge->bone; - + sub_v3_v3v3(v1, edge->tail, edge->head); sub_v3_v3v3(v2, vec1, vec0); - + l1 = normalize_v3(v1); l2 = normalize_v3(v2); resize = l2 / l1; - + rotation_between_vecs_to_quat(qrot, v1, v2); - + copy_v3_v3(bone->head, vec0); copy_v3_v3(bone->tail, vec1); - + if (!is_zero_v3(up_axis)) { float qroll[4]; @@ -1650,7 +1650,7 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec else { unit_qt(qroll); } - + mul_qt_qtqt(qrot, qroll, qrot); } else { @@ -1680,18 +1680,18 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc) float avg_angle = 0; /* float avg_length = 0; */ /* UNUSED */ int nb_edges = 0; - - + + for (edge = iarc->edges.first; edge; edge = edge->next) { avg_angle += edge->angle; nb_edges++; } - + avg_angle /= nb_edges - 1; /* -1 because last edge doesn't have an angle */ /* avg_length = iarc->length / nb_edges; */ /* UNUSED */ - - + + if (nb_edges > 2) { for (edge = iarc->edges.first; edge; edge = edge->next) { if (fabsf(edge->angle - avg_angle) > (float)(M_PI / 6)) { @@ -1702,16 +1702,16 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc) else if (nb_edges == 2 && avg_angle > 0) { large_angle = 1; } - - + + if (large_angle == 0) { mode = RETARGET_LENGTH; } - + if (earc->bcount <= (iarc->count - 1)) { mode = RETARGET_LENGTH; } - + return mode; } @@ -1720,18 +1720,18 @@ static void printMovesNeeded(int *positions, int nb_positions) { int moves = 0; int i; - + for (i = 0; i < nb_positions; i++) { moves += positions[i] - (i + 1); } - + printf("%i moves needed\n", moves); } static void printPositions(int *positions, int nb_positions) { int i; - + for (i = 0; i < nb_positions; i++) { printf("%i ", positions[i]); } @@ -1750,25 +1750,25 @@ static float costDistance(BArcIterator *iter, float *vec0, float *vec1, int i0, if (distance_weight > 0) { sub_v3_v3v3(v1, vec0, vec1); - + v1_inpf = dot_v3v3(v1, v1); - + if (v1_inpf > 0) { int j; for (j = i0 + 1; j < i1 - 1; j++) { float dist; - + bucket = IT_peek(iter, j); - + sub_v3_v3v3(v2, bucket->p, vec1); - + cross_v3_v3v3(c, v1, v2); - + dist = dot_v3v3(c, c) / v1_inpf; - + max_dist = dist > max_dist ? dist : max_dist; } - + return distance_weight * max_dist; } else { @@ -1784,7 +1784,7 @@ static float costAngle(float original_angle, float vec_first[3], float vec_secon { if (angle_weight > 0) { float current_angle; - + if (!is_zero_v3(vec_first) && !is_zero_v3(vec_second)) { current_angle = saacos(dot_v3v3(vec_first, vec_second)); @@ -1837,9 +1837,9 @@ static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_ /* Angle cost */ if (edge->prev) { - sub_v3_v3v3(vec_first, vec1, vec0); + sub_v3_v3v3(vec_first, vec1, vec0); normalize_v3(vec_first); - + new_cost += costAngle(edge->prev->angle, vec_first, vec_second, angle_weight); } @@ -1861,13 +1861,13 @@ static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions, { int previous = 0, current = 0; int i = 0; - + for (i = 0; joints_left > 0; joints_left--, i++) { MemoNode *node; node = table + indexMemoNode(nb_positions, previous, current, joints_left); - + positions[i] = node->next; - + previous = current; current = node->next; } @@ -1879,9 +1879,9 @@ static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_ca { MemoNode *node; int index = indexMemoNode(nb_positions, previous, current, joints_left); - + node = table + index; - + if (node->weight != 0) { return node; } @@ -1901,30 +1901,30 @@ static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_ca float min_weight = 0.0f; int min_next = 0; int next; - + for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) { MemoNode *next_node; float *vec2 = vec_cache[next]; float weight = 0.0f; - + /* ADD WEIGHT OF PREVIOUS - CURRENT - NEXT triple */ weight = calcCostAngleLengthDistance(iter, vec_cache, edge, vec0, vec1, vec2, current, next, angle_weight, length_weight, distance_weight); - + if (weight >= MAX_COST) { continue; } - + /* add node weight */ next_node = solveJoints(table, iter, vec_cache, nb_joints, nb_positions, current, next, edge->next, joints_left - 1, angle_weight, length_weight, distance_weight); weight += next_node->weight; - + if (min_node == NULL || weight < min_weight) { min_weight = weight; min_node = next_node; min_next = next; } } - + if (min_node) { node->weight = min_weight; node->next = min_next; @@ -1935,14 +1935,14 @@ static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_ca return node; } } - + } static int testFlipArc(RigArc *iarc, RigNode *inode_start) { ReebArc *earc = iarc->link_mesh; ReebNode *enode_start = BIF_NodeFromIndex(earc, inode_start->link_mesh); - + /* no flip needed if both nodes are the same */ if ((enode_start == earc->head && inode_start == iarc->head) || (enode_start == earc->tail && inode_start == iarc->tail)) @@ -1973,14 +1973,14 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, int nb_joints = nb_edges - 1; RetargetMethod method = METHOD_MEMOIZE; int i; - + if (nb_joints > earc->bcount) { printf("NOT ENOUGH BUCKETS!\n"); return; } best_positions = MEM_callocN(sizeof(int) * nb_joints, "Best positions"); - + if (testFlipArc(iarc, inode_start)) { node_start = earc->tail; node_end = earc->head; @@ -2005,10 +2005,10 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, MemoNode *result; #endif float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache"); - + positions_cache[0] = node_start->p; positions_cache[nb_positions + 1] = node_end->p; - + initArcIterator(iter, earc, node_start); for (i = 1; i <= nb_positions; i++) { @@ -2031,7 +2031,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, vec0 = node_start->p; initArcIterator(iter, earc, node_start); - + #ifndef USE_THREADS printPositions(best_positions, nb_joints); printMovesNeeded(best_positions, nb_joints); @@ -2054,11 +2054,11 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, vec1 = node_end->p; no = node_end->no; } - + if (edge->bone) { repositionBone(C, rigg, edge, vec0, vec1, no); } - + vec0 = vec1; } @@ -2078,7 +2078,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri float *vec1 = NULL; float *previous_vec = NULL; - + if (testFlipArc(iarc, inode_start)) { node_start = (ReebNode *)earc->tail; node_end = (ReebNode *)earc->head; @@ -2087,24 +2087,24 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri node_start = (ReebNode *)earc->head; node_end = (ReebNode *)earc->tail; } - + initArcIterator(iter, earc, node_start); bucket = IT_next(iter); - + vec0 = node_start->p; - + while (bucket != NULL) { vec1 = bucket->p; - + embedding_length += len_v3v3(vec0, vec1); - + vec0 = vec1; bucket = IT_next(iter); } - + embedding_length += len_v3v3(node_end->p, vec1); - + /* fit bones */ initArcIterator(iter, earc, node_start); @@ -2113,7 +2113,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri vec0 = node_start->p; previous_vec = vec0; vec1 = bucket->p; - + for (edge = iarc->edges.first; edge; edge = edge->next) { float new_bone_length = edge->length / iarc->length * embedding_length; float *no = NULL; @@ -2126,7 +2126,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri vec1 = bucket->p; no = bucket->no; } - + if (bucket == NULL) { vec1 = node_end->p; no = node_end->no; @@ -2136,7 +2136,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri if (edge->bone) { repositionBone(C, rigg, edge, vec0, vec1, no); } - + vec0 = vec1; previous_vec = vec1; } @@ -2145,12 +2145,12 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start) { RetargetParam *p = MEM_callocN(sizeof(RetargetParam), "RetargetParam"); - + p->rigg = rigg; p->iarc = iarc; p->inode_start = inode_start; p->context = C; - + BLI_task_pool_push(rigg->task_pool, exec_retargetArctoArc, p, true, TASK_PRIORITY_HIGH); } @@ -2162,7 +2162,7 @@ void exec_retargetArctoArc(TaskPool * __restrict UNUSED(pool), void *taskdata, i bContext *C = p->context; RigNode *inode_start = p->inode_start; ReebArc *earc = iarc->link_mesh; - + if (BLI_listbase_is_single(&iarc->edges)) { RigEdge *edge = iarc->edges.first; @@ -2175,7 +2175,7 @@ void exec_retargetArctoArc(TaskPool * __restrict UNUSED(pool), void *taskdata, i } else { RetargetMode mode = detectArcRetargetMode(iarc); - + if (mode == RETARGET_AGGRESSIVE) { retargetArctoArcAggresive(C, rigg, iarc, inode_start); } @@ -2190,10 +2190,10 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t ReebNode *enode = top_node; ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); int ishape, eshape; - + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS; eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; - + inode->link_mesh = enode; while (ishape == eshape && enode->link_down) { @@ -2208,13 +2208,13 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode) { int i; - + for (i = 0; i < enode->degree; i++) { ReebArc *earc = (ReebArc *)enode->arcs[i]; - + if (earc->flag == ARC_FREE) { earc->flag = ARC_TAKEN; - + if (earc->tail->degree > 1 && earc->tail != end_enode) { markMultiResolutionChildArc(end_enode, earc->tail); } @@ -2229,7 +2229,7 @@ static void markMultiResolutionArc(ReebArc *start_earc) ReebArc *earc; for (earc = start_earc->link_up; earc; earc = earc->link_up) { earc->flag = ARC_TAKEN; - + if (earc->tail->index != start_earc->tail->index) { markMultiResolutionChildArc(earc->tail, earc->tail); } @@ -2245,10 +2245,10 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS; eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS; - + while (ishape != eshape && next_earc->link_up) { next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels - + next_earc = next_earc->link_up; reebg = reebg->link_up; enode = next_earc->head; @@ -2257,7 +2257,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc next_earc->flag = ARC_USED; next_iarc->link_mesh = next_earc; - + /* mark all higher levels as taken too */ markMultiResolutionArc(next_earc); // while (next_earc->link_up) @@ -2271,17 +2271,17 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R { ReebNode *enode; int ishape, eshape; - + enode = reebg->nodes.first; - + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS; eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; - + while (ishape != eshape && reebg->link_up) { reebg = reebg->link_up; - + enode = reebg->nodes.first; - + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; } @@ -2296,27 +2296,27 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta int symmetry_group = next_iarc->symmetry_group; int symmetry_flag = next_iarc->symmetry_flag; int i; - + next_iarc->link_mesh = NULL; - + // if (root) // { // printf("-----------------------\n"); // printf("MATCHING LIMB\n"); // RIG_printArcBones(next_iarc); // } - + for (i = 0; i < enode->degree; i++) { next_earc = (ReebArc *)enode->arcs[i]; - + // if (next_earc->flag == ARC_FREE) // { // printf("candidate (level %i ?= %i) (flag %i ?= %i) (group %i ?= %i)\n", // symmetry_level, next_earc->symmetry_level, -// symmetry_flag, next_earc->symmetry_flag, +// symmetry_flag, next_earc->symmetry_flag, // symmetry_group, next_earc->symmetry_flag); // } - + if (next_earc->flag == ARC_FREE && next_earc->symmetry_flag == symmetry_flag && next_earc->symmetry_group == symmetry_group && @@ -2324,16 +2324,16 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta { // printf("CORRESPONDING ARC FOUND\n"); // printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group); - + matchMultiResolutionArc(rigg, start_node, next_iarc, next_earc); break; } } - + /* not found, try at higher nodes (lower node might have filtered internal arcs, messing shape of tree */ if (next_iarc->link_mesh == NULL) { // printf("NO CORRESPONDING ARC FOUND - GOING TO HIGHER LEVELS\n"); - + if (enode->link_up) { start_node->link_mesh = enode->link_up; findCorrespondingArc(rigg, start_arc, start_node, next_iarc, 0); @@ -2343,26 +2343,26 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta /* still not found, print debug info */ if (root && next_iarc->link_mesh == NULL) { start_node->link_mesh = enode; /* linking back with root node */ - + // printf("NO CORRESPONDING ARC FOUND\n"); // RIG_printArcBones(next_iarc); -// +// // printf("ON NODE %i, multilevel %i\n", enode->index, enode->multi_level); -// +// // printf("LOOKING FOR\n"); // printf("flag %i -- level %i -- flag %i -- group %i\n", ARC_FREE, symmetry_level, symmetry_flag, symmetry_group); -// +// // printf("CANDIDATES\n"); // for (i = 0; i < enode->degree; i++) // { // next_earc = (ReebArc *)enode->arcs[i]; // printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group); // } - + /* Emergency matching */ for (i = 0; i < enode->degree; i++) { next_earc = (ReebArc *)enode->arcs[i]; - + if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) { // printf("USING:\n"); // printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group); @@ -2383,19 +2383,19 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig if (start_arc) { ReebNode *enode = start_node->link_mesh; ReebArc *earc = start_arc->link_mesh; - + retargetArctoArc(C, rigg, start_arc, start_node); - + enode = BIF_otherNodeFromIndex(earc, enode); inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode); - + /* match with lowest node with correct shape */ matchMultiResolutionNode(rigg, inode, enode); } - + for (i = 0; i < inode->degree; i++) { RigArc *next_iarc = (RigArc *)inode->arcs[i]; - + /* no back tracking */ if (next_iarc != start_arc) { findCorrespondingArc(rigg, start_arc, inode, next_iarc, 1); @@ -2415,7 +2415,7 @@ static void adjustGraphs(bContext *C, RigGraph *rigg) { bArmature *arm = rigg->ob->data; RigArc *arc; - + for (arc = rigg->arcs.first; arc; arc = arc->next) { if (arc->link_mesh) { retargetArctoArc(C, rigg, arc, arc->head); @@ -2427,7 +2427,7 @@ static void adjustGraphs(bContext *C, RigGraph *rigg) /* Turn the list into an armature */ arm->edbo = rigg->editbones; ED_armature_from_edit(arm); - + ED_undo_push(C, "Retarget Skeleton"); } @@ -2436,19 +2436,19 @@ static void retargetGraphs(bContext *C, RigGraph *rigg) bArmature *arm = rigg->ob->data; ReebGraph *reebg = rigg->link_mesh; RigNode *inode; - + /* flag all ReebArcs as free */ BIF_flagMultiArcs(reebg, ARC_FREE); - + /* return to first level */ inode = rigg->head; - + matchMultiResolutionStartingNode(rigg, reebg, inode); retargetSubgraph(C, rigg, NULL, inode); - + //generateMissingArcs(rigg); - + finishRetarget(rigg); /* Turn the list into an armature */ @@ -2464,21 +2464,21 @@ const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index) if (arc == NULL) { return "None"; } - + if (bone_index == BLI_listbase_count(&arc->edges)) { return "Last joint"; } iedge = BLI_findlink(&arc->edges, bone_index); - + if (iedge == NULL) { return "Done"; } - + if (iedge->bone == NULL) { return "Bone offset"; } - + return iedge->bone->name; } @@ -2486,13 +2486,13 @@ int RIG_nbJoints(RigGraph *rg) { RigArc *arc; int total = 0; - + total += BLI_listbase_count(&rg->nodes); - + for (arc = rg->arcs.first; arc; arc = arc->next) { total += BLI_listbase_count(&arc->edges) - 1; /* -1 because end nodes are already counted */ } - + return total; } @@ -2510,14 +2510,14 @@ void BIF_retargetArmature(bContext *C) double start_time, end_time; double gstart_time, gend_time; double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time; - + gstart_time = start_time = PIL_check_seconds_timer(); - + reebg = BIF_ReebGraphMultiFromEditMesh(C); - + end_time = PIL_check_seconds_timer(); reeb_time = end_time - start_time; - + printf("Reeb Graph created\n"); CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) @@ -2529,42 +2529,42 @@ void BIF_retargetArmature(bContext *C) bArmature *arm; arm = ob->data; - + /* Put the armature into editmode */ - - + + start_time = PIL_check_seconds_timer(); rigg = RIG_graphFromArmature(C, ob, arm); - + end_time = PIL_check_seconds_timer(); rig_time = end_time - start_time; printf("Armature graph created\n"); - + //RIG_printGraph(rigg); - + rigg->link_mesh = reebg; - + printf("retargetting %s\n", ob->id.name); - + start_time = PIL_check_seconds_timer(); retargetGraphs(C, rigg); - + end_time = PIL_check_seconds_timer(); retarget_time = end_time - start_time; BIF_freeRetarget(); - + GLOBAL_RIGG = rigg; - + break; /* only one armature at a time */ } } CTX_DATA_END; - + gend_time = PIL_check_seconds_timer(); total_time = gend_time - gstart_time; @@ -2575,7 +2575,7 @@ void BIF_retargetArmature(bContext *C) printf("rig: \t\t%.3f (%.1f%%)\n", rig_time, rig_time / total_time * 100); printf("retarget: \t%.3f (%.1f%%)\n", retarget_time, retarget_time / total_time * 100); printf("-----------\n"); - + ED_undo_push(C, "Retarget Skeleton"); // XXX @@ -2593,7 +2593,7 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg) char *side_string = scene->toolsettings->skgen_side_string; char *num_string = scene->toolsettings->skgen_num_string; int free_template = 0; - + if (template_rigg) { ob = template_rigg->ob; } @@ -2602,31 +2602,31 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg) ob = obedit; template_rigg = armatureSelectedToGraph(C, ob, ob->data); } - + if (BLI_listbase_is_empty(&template_rigg->arcs)) { // XXX // error("No Template and no deforming bones selected"); return; } - + rigg = cloneRigGraph(template_rigg, armedit->edbo, obedit, side_string, num_string); - + iarc = rigg->arcs.first; - + iarc->link_mesh = earc; iarc->head->link_mesh = earc->head; iarc->tail->link_mesh = earc->tail; - + retargetArctoArc(C, rigg, iarc, iarc->head); - + finishRetarget(rigg); - + /* free template if it comes from the edit armature */ if (free_template) { RIG_freeRigGraph((BGraph *)template_rigg); } RIG_freeRigGraph((BGraph *)rigg); - + ED_armature_edit_validate_active(armedit); // XXX diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index a08898a37f6..84eb780b56b 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -465,7 +465,7 @@ static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float heig { float vec2[3] = {0, 0, 1}, axis[3]; float angle; - + glPushMatrix(); cross_v3_v3v3(axis, vec2, pt->no); @@ -2126,7 +2126,7 @@ static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra sk_addStrokePoint(C, sketch, stk, dd, snap); sk_updateDrawData(dd); sk_updateNextPoint(sketch, stk); - + return 1; } @@ -2246,7 +2246,7 @@ SK_Sketch *contextSketch(const bContext *C, int create) if (obedit && obedit->type == OB_ARMATURE) { bArmature *arm = obedit->data; - + if (arm->sketch == NULL && create) { arm->sketch = createSketch(); } @@ -2263,7 +2263,7 @@ SK_Sketch *viewcontextSketch(ViewContext *vc, int create) if (obedit && obedit->type == OB_ARMATURE) { bArmature *arm = obedit->data; - + if (arm->sketch == NULL && create) { arm->sketch = createSketch(); } diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index c0177d41d4a..4e31fcc7a11 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -94,7 +94,7 @@ struct LaplacianSystem { float *H; /* diagonal H matrix */ float *p; /* values from all p vectors */ float *mindist; /* minimum distance to a bone for all vertices */ - + BVHTree *bvhtree; /* ray tracing acceleration structure */ const MLoopTri **vltree; /* a looptri that the vertex belongs to */ } heat; @@ -259,7 +259,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) if (sys->areaweights) for (a = 0, face = sys->faces; a < sys->totface; a++, face++) laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]); - + for (a = 0; a < totvert; a++) { if (sys->areaweights) { if (sys->varea[a] != 0.0f) @@ -275,7 +275,7 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) if (sys->storeweights) sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight"); - + for (a = 0, face = sys->faces; a < totface; a++, face++) laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]); @@ -403,7 +403,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) const MLoopTri *lt = &looptri[a]; float bb[6]; int vtri[3]; - + vtri[0] = mloop[lt->tri[0]].v; vtri[1] = mloop[lt->tri[1]].v; vtri[2] = mloop[lt->tri[2]].v; @@ -414,14 +414,14 @@ static void heat_ray_tree_create(LaplacianSystem *sys) minmax_v3v3_v3(bb, bb + 3, verts[vtri[2]]); BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2); - + //Setup inverse pointers to use on isect.orig sys->heat.vltree[vtri[0]] = lt; sys->heat.vltree[vtri[1]] = lt; sys->heat.vltree[vtri[2]] = lt; } - BLI_bvhtree_balance(sys->heat.bvhtree); + BLI_bvhtree_balance(sys->heat.bvhtree); } static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) @@ -457,7 +457,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) static float heat_source_distance(LaplacianSystem *sys, int vertex, int source) { float closest[3], d[3], dist, cosine; - + /* compute euclidian distance */ closest_to_line_segment_v3(closest, sys->heat.verts[vertex], sys->heat.root[source], sys->heat.tip[source]); @@ -479,7 +479,7 @@ static int heat_source_closest(LaplacianSystem *sys, int vertex, int source) if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON)) if (heat_ray_source_visible(sys, vertex, source)) return 1; - + return 0; } @@ -514,7 +514,7 @@ static void heat_set_H(LaplacianSystem *sys, int vertex) } else h = 0.0f; - + sys->heat.H[vertex] = h; } @@ -531,7 +531,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys) v3 = (*face)[2]; normal_tri_v3(fnor, sys->verts[v1], sys->verts[v2], sys->verts[v3]); - + add_v3_v3(sys->heat.vnors[v1], fnor); add_v3_v3(sys->heat.vnors[v2], fnor); add_v3_v3(sys->heat.vnors[v3], fnor); @@ -677,7 +677,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, for (a = 0; a < me->totvert; a++) vertsflipped[a] = mesh_get_x_mirror_vert(ob, NULL, a, use_topology); } - + /* compute weights per bone */ for (j = 0; j < numsource; j++) { if (!selected[j]) @@ -715,7 +715,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, continue; solution = laplacian_system_get_solution(sys, a); - + if (bbone) { if (solution > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, @@ -850,7 +850,7 @@ typedef struct MeshDeformBind { /* direct solver */ int *varidx; - + BVHTree *bvhtree; BVHTreeFromMesh bvhdata; @@ -871,7 +871,7 @@ typedef struct MeshDeformIsect { bool isect; float u, v; - + } MeshDeformIsect; /* ray intersection */ @@ -891,9 +891,9 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r MeshDeformIsect *isec = data->isec; float no[3], co[3], dist; float *face[3]; - + lt = &looptri[index]; - + face[0] = mdb->cagecos[mloop[lt->tri[0]].v]; face[1] = mdb->cagecos[mloop[lt->tri[1]].v]; face[2] = mdb->cagecos[mloop[lt->tri[2]].v]; @@ -917,7 +917,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r hit->index = index; hit->dist = dist; copy_v3_v3(hit->co, co); - + isec->isect = (dot_v3v3(no, ray->direction) <= 0.0f); isec->lambda = dist; } @@ -1000,7 +1000,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) copy_v3_v3(start, co); sub_v3_v3v3(dir, outside, start); normalize_v3(dir); - + isect = meshdeform_ray_tree_intersect(mdb, start, outside); if (isect && !isect->facing) return 1; @@ -1014,7 +1014,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) BLI_INLINE int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) { int size = mdb->size; - + x += MESHDEFORM_OFFSET[n][0]; y += MESHDEFORM_OFFSET[n][1]; z += MESHDEFORM_OFFSET[n][2]; @@ -1118,7 +1118,7 @@ static void meshdeform_bind_floodfill(MeshDeformBind *mdb) if (mdb->semibound[a]) ts++; } - + printf("interior %d exterior %d boundary %d semi-boundary %d\n", ti, te, tb, ts); } #endif @@ -1227,7 +1227,7 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, LinearSolver *contex return; EIG_linear_solver_matrix_add(context, mdb->varidx[acenter], mdb->varidx[acenter], 1.0f); - + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); for (i = 1; i <= 6; i++) { a = meshdeform_index(mdb, x, y, z, i); @@ -1277,7 +1277,7 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int a = meshdeform_index(mdb, x, y, z, 0); if (!mdb->semibound[a]) return; - + mdb->phi[a] = 0.0f; totweight = meshdeform_boundary_total_weight(mdb, x, y, z); @@ -1415,7 +1415,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind printf("totalphi deficiency [%s|%d] %d: %.10f\n", (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); #endif - + /* free */ MEM_freeN(mdb->varidx); @@ -1501,7 +1501,7 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* start with all cells untyped */ for (a = 0; a < mdb->size3; a++) mdb->tag[a] = MESHDEFORM_TAG_UNTYPED; - + /* detect intersections and tag boundary cells */ for (z = 0; z < mdb->size; z++) for (y = 0; y < mdb->size; y++) @@ -1588,7 +1588,7 @@ void ED_mesh_deform_bind_callback( /* get mesh and cage mesh */ mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos"); mdb.totvert = totvert; - + mdb.cagedm = cagedm; mdb.totcagevert = mdb.cagedm->getNumVerts(mdb.cagedm); mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos"); diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 01ff436fa1e..da328ee485f 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -85,7 +85,7 @@ bool ED_object_posemode_enter_ex(Object *ob) { BLI_assert(!ID_IS_LINKED(ob)); bool ok = false; - + switch (ob->type) { case OB_ARMATURE: ob->restore_mode = ob->mode; @@ -170,11 +170,11 @@ static bool pose_has_protected_selected(Object *ob, short warn) void ED_pose_recalculate_paths(Scene *scene, Object *ob) { ListBase targets = {NULL, NULL}; - + /* set flag to force recalc, then grab the relevant bones to target */ ob->pose->avs.recalc |= ANIMVIZ_RECALC_PATHS; animviz_get_object_motionpaths(ob, &targets); - + /* recalculate paths, then free */ animviz_calc_motionpaths(scene, &targets); BLI_freelistN(&targets); @@ -183,52 +183,52 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob) /* show popup to determine settings */ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ +{ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + /* set default settings from existing/stored settings */ { bAnimVizSettings *avs = &ob->pose->avs; PointerRNA avs_ptr; - + RNA_int_set(op->ptr, "start_frame", avs->path_sf); RNA_int_set(op->ptr, "end_frame", avs->path_ef); - + RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr); RNA_enum_set(op->ptr, "bake_location", RNA_enum_get(&avs_ptr, "bake_location")); } - + /* show popup dialog to allow editing of range... */ // FIXME: hardcoded dimensions here are just arbitrary return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y); } -/* For the object with pose/action: create path curves for selected bones +/* For the object with pose/action: create path curves for selected bones * This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range */ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); Scene *scene = CTX_data_scene(C); - + if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + /* grab baking settings from operator settings */ { bAnimVizSettings *avs = &ob->pose->avs; PointerRNA avs_ptr; - + avs->path_sf = RNA_int_get(op->ptr, "start_frame"); avs->path_ef = RNA_int_get(op->ptr, "end_frame"); - + RNA_pointer_create(NULL, &RNA_AnimVizMotionPaths, avs, &avs_ptr); RNA_enum_set(&avs_ptr, "bake_location", RNA_enum_get(op->ptr, "bake_location")); } - + /* set up path data for bones being calculated */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { @@ -244,7 +244,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } void POSE_OT_paths_calculate(wmOperatorType *ot) @@ -253,23 +253,23 @@ void POSE_OT_paths_calculate(wmOperatorType *ot) ot->name = "Calculate Bone Paths"; ot->idname = "POSE_OT_paths_calculate"; ot->description = "Calculate paths for the selected bones"; - + /* api callbacks */ ot->invoke = pose_calculate_paths_invoke; ot->exec = pose_calculate_paths_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", + RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", "First frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0); - RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", + RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", "Last frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0); - - RNA_def_enum(ot->srna, "bake_location", rna_enum_motionpath_bake_location_items, 0, - "Bake Location", + + RNA_def_enum(ot->srna, "bake_location", rna_enum_motionpath_bake_location_items, 0, + "Bake Location", "Which point on the bones is used when calculating paths"); } @@ -281,7 +281,7 @@ static int pose_update_paths_poll(bContext *C) Object *ob = CTX_data_active_object(C); return (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0; } - + return false; } @@ -289,17 +289,17 @@ static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); Scene *scene = CTX_data_scene(C); - + if (ELEM(NULL, ob, scene)) return OPERATOR_CANCELLED; /* calculate the bones that now have motionpaths... */ /* TODO: only make for the selected bones? */ ED_pose_recalculate_paths(scene, ob); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -309,11 +309,11 @@ void POSE_OT_paths_update(wmOperatorType *ot) ot->name = "Update Bone Paths"; ot->idname = "POSE_OT_paths_update"; ot->description = "Recalculate paths for bones that already have them"; - + /* api callbakcs */ ot->exec = pose_update_paths_exec; ot->poll = pose_update_paths_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -325,10 +325,10 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected) { bPoseChannel *pchan; bool skipped = false; - + if (ELEM(NULL, ob, ob->pose)) return; - + /* free the motionpath blocks for all bones - This is easier for users to quickly clear all */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->mpath) { @@ -341,7 +341,7 @@ static void ED_pose_clear_paths(Object *ob, bool only_selected) } } } - + /* if nothing was skipped, there should be no paths left! */ if (skipped == false) ob->pose->avs.path_bakeflag &= ~MOTIONPATH_BAKE_HAS_PATHS; @@ -352,18 +352,18 @@ static int pose_clear_paths_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bool only_selected = RNA_boolean_get(op->ptr, "only_selected"); - + /* only continue if there's an object */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + /* use the backend function for this */ ED_pose_clear_paths(ob, only_selected); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - - return OPERATOR_FINISHED; + + return OPERATOR_FINISHED; } /* operator callback/wrapper */ @@ -381,17 +381,17 @@ void POSE_OT_paths_clear(wmOperatorType *ot) ot->name = "Clear Bone Paths"; ot->idname = "POSE_OT_paths_clear"; ot->description = "Clear path caches for all bones, hold Shift key for selected bones only"; - + /* api callbacks */ ot->invoke = pose_clear_paths_invoke; ot->exec = pose_clear_paths_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", + ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", "Only clear paths from selected bones"); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); } @@ -406,13 +406,13 @@ static void pose_copy_menu(Scene *scene) bPoseChannel *pchan, *pchanact; short nr = 0; int i = 0; - + /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return; if ((ob == obedit) || (ob->mode & OB_MODE_POSE) == 0) return; - + pchan = BKE_pose_channel_active(ob); - + if (pchan == NULL) return; pchanact = pchan; arm = ob->data; @@ -434,10 +434,10 @@ static void pose_copy_menu(Scene *scene) else nr = pupmenu("Copy Pose Attributes %t|Local Location %x1|Local Rotation %x2|Local Size %x3|%l|Visual Location %x9|Visual Rotation %x10|Visual Size %x11|%l|Constraints (All) %x4|%l|Transform Locks %x6|IK Limits %x7|Bone Shape %x8"); } - - if (nr <= 0) + + if (nr <= 0) return; - + if (nr != 5) { for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((arm->layer & pchan->bone->layer) && @@ -458,23 +458,23 @@ static void pose_copy_menu(Scene *scene) case 4: /* All Constraints */ { ListBase tmp_constraints = {NULL, NULL}; - - /* copy constraints to tmpbase and apply 'local' tags before + + /* copy constraints to tmpbase and apply 'local' tags before * appending to list of constraints for this channel */ BKE_constraints_copy(&tmp_constraints, &pchanact->constraints, true); if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) { bConstraint *con; - + /* add proxy-local tags */ for (con = tmp_constraints.first; con; con = con->next) con->flag |= CONSTRAINT_PROXY_LOCAL; } BLI_movelisttolist(&pchan->constraints, &tmp_constraints); - + /* update flags (need to add here, not just copy) */ pchan->constflag |= pchanact->constflag; - + if (ob->pose) BKE_pose_tag_recalc(bmain, ob->pose); } @@ -505,12 +505,12 @@ static void pose_copy_menu(Scene *scene) case 10: /* Visual Rotation */ { float delta_mat[4][4]; - + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); - + if (pchan->rotmode == ROT_MODE_AXISANGLE) { float tmp_quat[4]; - + /* need to convert to quat first (in temp var)... */ mat4_to_quat(tmp_quat, delta_mat); quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, tmp_quat); @@ -524,7 +524,7 @@ static void pose_copy_menu(Scene *scene) case 11: /* Visual Size */ { float delta_mat[4][4], size[4]; - + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); mat4_to_size(size, delta_mat); copy_v3_v3(pchan->size, size); @@ -537,20 +537,20 @@ static void pose_copy_menu(Scene *scene) bConstraint *con, *con_back; int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */ ListBase const_copy = {NULL, NULL}; - + BLI_duplicatelist(&const_copy, &(pchanact->constraints)); - + /* build the puplist of constraints */ for (con = pchanact->constraints.first, i = 0; con; con = con->next, i++) { const_toggle[i] = 1; // add_numbut(i, UI_BTYPE_TOGGLE|INT, con->name, 0, 0, &(const_toggle[i]), ""); } - + // if (!do_clever_numbuts("Select Constraints", i, REDRAW)) { // BLI_freelistN(&const_copy); // return; // } - + /* now build a new listbase from the options selected */ for (i = 0, con = const_copy.first; con; i++) { /* if not selected, free/remove it from the list */ @@ -562,7 +562,7 @@ static void pose_copy_menu(Scene *scene) else con = con->next; } - + /* Copy the temo listbase to the selected posebones */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((arm->layer & pchan->bone->layer) && @@ -570,8 +570,8 @@ static void pose_copy_menu(Scene *scene) (pchan != pchanact) ) { ListBase tmp_constraints = {NULL, NULL}; - - /* copy constraints to tmpbase and apply 'local' tags before + + /* copy constraints to tmpbase and apply 'local' tags before * appending to list of constraints for this channel */ BKE_constraints_copy(&tmp_constraints, &const_copy, true); @@ -581,22 +581,22 @@ static void pose_copy_menu(Scene *scene) con->flag |= CONSTRAINT_PROXY_LOCAL; } BLI_movelisttolist(&pchan->constraints, &tmp_constraints); - + /* update flags (need to add here, not just copy) */ pchan->constflag |= pchanact->constflag; } } BLI_freelistN(&const_copy); BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */ - + if (ob->pose) BKE_pose_tag_recalc(bmain, ob->pose); } - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations - + BIF_undo_push("Copy Pose Attributes"); - + } #endif @@ -608,7 +608,7 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op) bArmature *arm; /* paranoia checks */ - if (ELEM(NULL, ob, ob->pose)) + if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; const bool do_strip_numbers = RNA_boolean_get(op->ptr, "do_strip_numbers"); @@ -626,13 +626,13 @@ static int pose_flip_names_exec(bContext *C, wmOperator *op) ED_armature_bones_flip_names(arm, &bones_names, do_strip_numbers); BLI_freelistN(&bones_names); - + /* since we renamed stuff... */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -642,11 +642,11 @@ void POSE_OT_flip_names(wmOperatorType *ot) ot->name = "Flip Names"; ot->idname = "POSE_OT_flip_names"; ot->description = "Flips (and corrects) the axis suffixes of the names of selected bones"; - + /* api callbacks */ ot->exec = pose_flip_names_exec; ot->poll = ED_operator_posemode_local; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -663,12 +663,12 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op) bArmature *arm; char newname[MAXBONENAME]; short axis = RNA_enum_get(op->ptr, "axis"); - + /* paranoia checks */ - if (ELEM(NULL, ob, ob->pose)) + if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; arm = ob->data; - + /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { @@ -677,13 +677,13 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op) ED_armature_bone_rename(arm, pchan->name, newname); } CTX_DATA_END; - + /* since we renamed stuff... */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -695,20 +695,20 @@ void POSE_OT_autoside_names(wmOperatorType *ot) {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "AutoName by Axis"; ot->idname = "POSE_OT_autoside_names"; ot->description = "Automatically renames the selected bones according to which side of the target axis they fall on"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = pose_autoside_names_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* settings */ ot->prop = RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with"); } @@ -719,18 +719,18 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); int mode = RNA_enum_get(op->ptr, "type"); - + /* set rotation mode of selected bones */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { pchan->rotmode = mode; } CTX_DATA_END; - + /* notifiers and updates */ DAG_id_tag_update((ID *)ob, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); - + return OPERATOR_FINISHED; } @@ -740,15 +740,15 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot) ot->name = "Set Rotation Mode"; ot->idname = "POSE_OT_rotation_mode_set"; ot->description = "Set the rotation representation used by selected bones"; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = pose_bone_rotmode_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_posebone_rotmode_items, 0, "Rotation Mode", ""); } @@ -790,25 +790,25 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16; int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ int i; - + /* sanity checking */ if (arm == NULL) return OPERATOR_CANCELLED; - + /* use RNA to set the layers * although it would be faster to just set directly using bitflags, we still * need to setup a RNA pointer so that we get the "update" callbacks for free... */ RNA_id_pointer_create(&arm->id, &ptr); - + for (i = 0; i < maxLayers; i++) layers[i] = 1; - + RNA_boolean_set_array(&ptr, "layers", layers); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + /* done */ return OPERATOR_FINISHED; } @@ -819,14 +819,14 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot) ot->name = "Show All Layers"; ot->idname = "ARMATURE_OT_layers_show_all"; ot->description = "Make all armature layers visible"; - + /* callbacks */ ot->exec = pose_armature_layers_showall_exec; ot->poll = armature_layers_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)"); } @@ -840,16 +840,16 @@ static int armature_layers_invoke(bContext *C, wmOperator *op, const wmEvent *ev bArmature *arm = armature_layers_get_data(&ob); PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - + /* sanity checking */ if (arm == NULL) return OPERATOR_CANCELLED; - + /* get RNA pointer to armature data to use that to retrieve the layers as ints to init the operator */ RNA_id_pointer_create((ID *)arm, &ptr); RNA_boolean_get_array(&ptr, "layers", layers); RNA_boolean_set_array(op->ptr, "layers", layers); - + /* part to sync with other similar operators... */ return WM_operator_props_popup(C, op, event); } @@ -885,15 +885,15 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) ot->name = "Change Armature Layers"; ot->idname = "ARMATURE_OT_armature_layers"; ot->description = "Change the visible armature layers"; - + /* callbacks */ ot->invoke = armature_layers_invoke; ot->exec = armature_layers_exec; ot->poll = armature_layers_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible"); } @@ -904,22 +904,22 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) static int pose_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - + /* 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); } @@ -959,15 +959,15 @@ void POSE_OT_bone_layers(wmOperatorType *ot) 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, NULL, "Layer", "Armature layers that bone belongs to"); } @@ -978,12 +978,12 @@ void POSE_OT_bone_layers(wmOperatorType *ot) static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEvent *event) { int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - + /* get layers that are active already */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { short bit; - + /* loop over the bits for this pchan's layers, adding layers where they're needed */ for (bit = 0; bit < 32; bit++) { if (ebone->layer & (1u << bit)) { @@ -992,10 +992,10 @@ static int armature_bone_layers_invoke(bContext *C, wmOperator *op, const wmEven } } 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); } @@ -1007,10 +1007,10 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op) bArmature *arm = (ob) ? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - + /* get the values set in the operator properties */ RNA_boolean_get_array(op->ptr, "layers", layers); - + /* set layers of pchans based on the values set in the operator props */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { @@ -1019,10 +1019,10 @@ static int armature_bone_layers_exec(bContext *C, wmOperator *op) RNA_boolean_set_array(&ptr, "layers", layers); } CTX_DATA_END; - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -1032,15 +1032,15 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) ot->name = "Change Bone Layers"; ot->idname = "ARMATURE_OT_bone_layers"; ot->description = "Change the layers that the selected bones belong to"; - + /* callbacks */ ot->invoke = armature_bone_layers_invoke; ot->exec = armature_bone_layers_exec; ot->poll = ED_operator_editarmature; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to"); } @@ -1048,10 +1048,10 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) /* ********************************************** */ /* Show/Hide Bones */ -static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) +static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { bArmature *arm = ob->data; - + if (arm->layer & bone->layer) { if (bone->flag & BONE_SELECTED) { bone->flag |= BONE_HIDDEN_P; @@ -1063,10 +1063,10 @@ static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) return 0; } -static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) +static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { bArmature *arm = ob->data; - + if (arm->layer & bone->layer) { /* hrm... typo here? */ if ((bone->flag & BONE_SELECTED) == 0) { @@ -1079,7 +1079,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr } /* active object is armature in posemode, poll checked */ -static int pose_hide_exec(bContext *C, wmOperator *op) +static int pose_hide_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm = ob->data; @@ -1092,10 +1092,10 @@ static int pose_hide_exec(bContext *C, wmOperator *op) bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb); else bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + return OPERATOR_FINISHED; } @@ -1105,24 +1105,24 @@ void POSE_OT_hide(wmOperatorType *ot) ot->name = "Hide Selected"; ot->idname = "POSE_OT_hide"; ot->description = "Tag selected bones to not be visible in Pose Mode"; - + /* api callbacks */ ot->exec = pose_hide_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", ""); } -static int show_pose_bone_cb(Object *ob, Bone *bone, void *data) +static int show_pose_bone_cb(Object *ob, Bone *bone, void *data) { const bool select = GET_INT_FROM_POINTER(data); bArmature *arm = ob->data; - + if (arm->layer & bone->layer) { if (bone->flag & BONE_HIDDEN_P) { if (!(bone->flag & BONE_UNSELECTABLE)) { @@ -1131,19 +1131,19 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *data) bone->flag &= ~BONE_HIDDEN_P; } } - + return 0; } /* active object is armature in posemode, poll checked */ -static int pose_reveal_exec(bContext *C, wmOperator *op) +static int pose_reveal_exec(bContext *C, wmOperator *op) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm = ob->data; const bool select = RNA_boolean_get(op->ptr, "select"); - + bone_looper(ob, arm->bonebase.first, SET_INT_IN_POINTER(select), show_pose_bone_cb); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); @@ -1156,11 +1156,11 @@ void POSE_OT_reveal(wmOperatorType *ot) ot->name = "Reveal Selected"; ot->idname = "POSE_OT_reveal"; ot->description = "Reveal all bones hidden in Pose Mode"; - + /* api callbacks */ ot->exec = pose_reveal_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1175,7 +1175,7 @@ static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); - + /* loop through all selected pchans, flipping and keying (as needed) */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { @@ -1188,11 +1188,11 @@ static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + /* notifiers and updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); - + return OPERATOR_FINISHED; } @@ -1202,11 +1202,11 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot) ot->name = "Flip Quats"; ot->idname = "POSE_OT_quaternions_flip"; ot->description = "Flip quaternion values to achieve desired rotations, while maintaining the same orientations"; - + /* callbacks */ ot->exec = pose_flip_quats_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index 3463cf856a2..9648bb99c05 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -65,13 +65,13 @@ static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) /* only continue if there's an object and pose */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + /* for now, just call the API function for this */ BKE_pose_add_group(ob->pose, NULL); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -81,11 +81,11 @@ void POSE_OT_group_add(wmOperatorType *ot) ot->name = "Add Bone Group"; ot->idname = "POSE_OT_group_add"; ot->description = "Add a new bone group"; - + /* api callbacks */ ot->exec = pose_group_add_exec; ot->poll = ED_operator_posemode_context; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -94,17 +94,17 @@ void POSE_OT_group_add(wmOperatorType *ot) static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_pose_object_from_context(C); - + /* only continue if there's an object and pose */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + /* for now, just call the API function for this */ BKE_pose_remove_group_index(ob->pose, ob->pose->active_group); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -114,11 +114,11 @@ void POSE_OT_group_remove(wmOperatorType *ot) ot->name = "Remove Bone Group"; ot->idname = "POSE_OT_group_remove"; ot->description = "Remove the active bone group"; - + /* api callbacks */ ot->exec = pose_group_remove_exec; ot->poll = ED_operator_posemode_context; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -131,14 +131,14 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U Object *ob = ED_pose_object_from_context(C); bPose *pose; PropertyRNA *prop = RNA_struct_find_property(op->ptr, "type"); - + uiPopupMenu *pup; uiLayout *layout; bActionGroup *grp; int i; - + /* only continue if there's an object, and a pose there too */ - if (ELEM(NULL, ob, ob->pose)) + if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; pose = ob->pose; @@ -152,28 +152,28 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U return op->type->exec(C, op); } } - + /* if there's no active group (or active is invalid), create a new menu to find it */ if (pose->active_group <= 0) { /* create a new menu, and start populating it with group names */ pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); layout = UI_popup_menu_layout(pup); - - /* special entry - allow to create new group, then use that + + /* special entry - allow to create new group, then use that * (not to be used for removing though) */ if (strstr(op->idname, "assign")) { uiItemIntO(layout, "New Group", ICON_NONE, op->idname, "type", 0); uiItemS(layout); } - + /* add entries for each group */ for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i); - + /* finish building the menu, and process it (should result in calling self again) */ UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } else { @@ -195,14 +195,14 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; pose = ob->pose; - - /* set the active group number to the one from operator props + + /* set the active group number to the one from operator props * - if 0 after this, make a new group... */ pose->active_group = RNA_int_get(op->ptr, "type"); if (pose->active_group == 0) BKE_pose_add_group(ob->pose, NULL); - + /* add selected bones to group then */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { @@ -213,7 +213,7 @@ static int pose_group_assign_exec(bContext *C, wmOperator *op) /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + /* report done status */ if (done) return OPERATOR_FINISHED; @@ -227,15 +227,15 @@ void POSE_OT_group_assign(wmOperatorType *ot) ot->name = "Add Selected to Bone Group"; ot->idname = "POSE_OT_group_assign"; ot->description = "Add selected bones to the chosen bone group"; - + /* api callbacks */ ot->invoke = pose_groups_menu_invoke; ot->exec = pose_group_assign_exec; ot->poll = ED_operator_posemode_context; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_int(ot->srna, "type", 0, 0, INT_MAX, "Bone Group Index", "", 0, 10); } @@ -245,11 +245,11 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_pose_object_from_context(C); bool done = false; - + /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + /* find selected bones to remove from all bone groups */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { @@ -259,10 +259,10 @@ static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + /* report done status */ if (done) return OPERATOR_FINISHED; @@ -276,11 +276,11 @@ void POSE_OT_group_unassign(wmOperatorType *ot) ot->name = "Remove Selected from Bone Groups"; ot->idname = "POSE_OT_group_unassign"; ot->description = "Remove selected bones from all bone groups"; - + /* api callbacks */ ot->exec = pose_group_unassign_exec; ot->poll = ED_operator_posemode_context; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -435,16 +435,16 @@ void POSE_OT_group_sort(wmOperatorType *ot) static void pose_group_select(bContext *C, Object *ob, bool select) { bPose *pose = ob->pose; - + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { if (select) { - if (pchan->agrp_index == pose->active_group) + if (pchan->agrp_index == pose->active_group) pchan->bone->flag |= BONE_SELECTED; } else { - if (pchan->agrp_index == pose->active_group) + if (pchan->agrp_index == pose->active_group) pchan->bone->flag &= ~BONE_SELECTED; } } @@ -455,16 +455,16 @@ static void pose_group_select(bContext *C, Object *ob, bool select) static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_pose_object_from_context(C); - + /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + pose_group_select(C, ob, 1); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -474,11 +474,11 @@ void POSE_OT_group_select(wmOperatorType *ot) ot->name = "Select Bones of Bone Group"; ot->idname = "POSE_OT_group_select"; ot->description = "Select bones in active Bone Group"; - + /* api callbacks */ ot->exec = pose_group_select_exec; ot->poll = ED_operator_posemode_context; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -486,16 +486,16 @@ void POSE_OT_group_select(wmOperatorType *ot) static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_pose_object_from_context(C); - + /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - + pose_group_select(C, ob, 0); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -505,11 +505,11 @@ void POSE_OT_group_deselect(wmOperatorType *ot) ot->name = "Deselect Bone Group"; ot->idname = "POSE_OT_group_deselect"; ot->description = "Deselect bones of active Bone Group"; - + /* api callbacks */ ot->exec = pose_group_deselect_exec; ot->poll = ED_operator_posemode_context; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index e77561234c5..fd5db84873b 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -80,7 +80,7 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUSED(c)) {} /* ************************************************************* */ -/* == POSE-LIBRARY TOOL FOR BLENDER == +/* == POSE-LIBRARY TOOL FOR BLENDER == * * Overview: * This tool allows animators to store a set of frequently used poses to dump into @@ -99,7 +99,7 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS /* ************************************************************* */ -/* gets the first available frame in poselib to store a pose on +/* gets the first available frame in poselib to store a pose on * - frames start from 1, and a pose should occur on every frame... 0 is error! */ static int poselib_get_free_index(bAction *act) @@ -107,17 +107,17 @@ static int poselib_get_free_index(bAction *act) TimeMarker *marker; int low = 0, high = 0; bool changed = false; - + /* sanity checks */ if (ELEM(NULL, act, act->markers.first)) return 1; - - /* As poses are not stored in chronological order, we must iterate over this list + + /* As poses are not stored in chronological order, we must iterate over this list * a few times until we don't make any new discoveries (mostly about the lower bound). * Prevents problems with deleting then trying to add new poses [#27412] */ do { changed = false; - + for (marker = act->markers.first; marker; marker = marker->next) { /* only increase low if value is 1 greater than low, to find "gaps" where * poses were removed from the poselib @@ -126,7 +126,7 @@ static int poselib_get_free_index(bAction *act) low++; changed = true; } - + /* value replaces high if it is the highest value encountered yet */ if (marker->frame > high) { high = marker->frame; @@ -134,19 +134,19 @@ static int poselib_get_free_index(bAction *act) } } } while (changed != 0); - - /* - if low is not equal to high, then low+1 is a gap - * - if low is equal to high, then high+1 is the next index (add at end) + + /* - if low is not equal to high, then low+1 is a gap + * - if low is equal to high, then high+1 is the next index (add at end) */ - if (low < high) + if (low < high) return (low + 1); - else + else return (high + 1); } /* returns the active pose for a poselib */ static TimeMarker *poselib_get_active_pose(bAction *act) -{ +{ if ((act) && (act->active_marker)) return BLI_findlink(&act->markers, act->active_marker - 1); else @@ -158,14 +158,14 @@ static TimeMarker *poselib_get_active_pose(bAction *act) static Object *get_poselib_object(bContext *C) { ScrArea *sa; - + /* sanity check */ if (C == NULL) return NULL; - + sa = CTX_wm_area(C); - - if (sa && (sa->spacetype == SPACE_BUTS)) + + if (sa && (sa->spacetype == SPACE_BUTS)) return ED_object_context(C); else return BKE_object_pose_armature_get(CTX_data_active_object(C)); @@ -195,14 +195,14 @@ static bAction *poselib_init_new(Object *ob) /* sanity checks - only for armatures */ if (ELEM(NULL, ob, ob->pose)) return NULL; - + /* init object's poselib action (unlink old one if there) */ if (ob->poselib) id_us_min(&ob->poselib->id); - + ob->poselib = BKE_action_add(G.main, "PoseLib"); ob->poselib->idroot = ID_OB; - + return ob->poselib; } @@ -223,17 +223,17 @@ static bAction *poselib_validate(Object *ob) static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); - + /* sanity checks */ if (ob == NULL) return OPERATOR_CANCELLED; - + /* new method here deals with the rest... */ poselib_init_new(ob); - + /* notifier here might evolve? */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); - + return OPERATOR_FINISHED; } @@ -243,11 +243,11 @@ void POSELIB_OT_new(wmOperatorType *ot) ot->name = "New Pose Library"; ot->idname = "POSELIB_OT_new"; ot->description = "Add New Pose Library to active Object"; - + /* callbacks */ ot->exec = poselib_new_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -257,18 +257,18 @@ void POSELIB_OT_new(wmOperatorType *ot) static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); - + /* sanity checks */ if (ELEM(NULL, ob, ob->poselib)) return OPERATOR_CANCELLED; - + /* there should be a poselib (we just checked above!), so just lower its user count and remove */ id_us_min(&ob->poselib->id); ob->poselib = NULL; - + /* notifier here might evolve? */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); - + return OPERATOR_FINISHED; } @@ -278,11 +278,11 @@ void POSELIB_OT_unlink(wmOperatorType *ot) ot->name = "Unlink Pose Library"; ot->idname = "POSELIB_OT_unlink"; ot->description = "Remove Pose Library from active Object"; - + /* callbacks */ ot->exec = poselib_unlink_exec; ot->poll = has_poselib_pose_data_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -290,7 +290,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot) /* ************************************************************* */ /* Pose Editing Operators */ -/* This tool automagically generates/validates poselib data so that it corresponds to the data +/* This tool automagically generates/validates poselib data so that it corresponds to the data * in the action. This is for use in making existing actions usable as poselibs. */ static int poselib_sanitize_exec(bContext *C, wmOperator *op) @@ -300,13 +300,13 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op) DLRBT_Tree keys; ActKeyColumn *ak; TimeMarker *marker, *markern; - + /* validate action */ if (act == NULL) { BKE_report(op->reports, RPT_WARNING, "No action to validate"); return OPERATOR_CANCELLED; } - + /* determine which frames have keys */ BLI_dlrbTree_init(&keys); action_to_keylist(NULL, act, &keys, NULL); @@ -322,39 +322,39 @@ static int poselib_sanitize_exec(bContext *C, wmOperator *op) break; } } - + /* add new if none found */ if (marker == NULL) { /* add pose to poselib */ marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); - + BLI_snprintf(marker->name, sizeof(marker->name), "F%d Pose", (int)ak->cfra); - + marker->frame = (int)ak->cfra; marker->flag = -1; - + BLI_addtail(&act->markers, marker); } } - + /* remove all untagged poses (unused), and remove all tags */ for (marker = act->markers.first; marker; marker = markern) { markern = marker->next; - + if (marker->flag != -1) BLI_freelinkN(&act->markers, marker); else marker->flag = 0; } - + /* free temp memory */ BLI_dlrbTree_free(&keys); - - /* send notifiers for this - using keyframe editing notifiers, since action - * may be being shown in anim editors as active action + + /* send notifiers for this - using keyframe editing notifiers, since action + * may be being shown in anim editors as active action */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -364,11 +364,11 @@ void POSELIB_OT_action_sanitize(wmOperatorType *ot) ot->name = "Sanitize Pose Library Action"; ot->idname = "POSELIB_OT_action_sanitize"; ot->description = "Make action suitable for use as a Pose Library"; - + /* callbacks */ ot->exec = poselib_sanitize_exec; ot->poll = has_poselib_pose_data_for_editing_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -399,14 +399,14 @@ static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout, Object *ob = get_poselib_object(C); bAction *act = ob->poselib; /* never NULL */ TimeMarker *marker; - + wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1); BLI_assert(ot != NULL); /* set the operator execution context correctly */ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); - + /* add each marker to this menu */ for (marker = act->markers.first; marker; marker = marker->next) { PointerRNA props_ptr; @@ -426,30 +426,30 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U bPose *pose = (ob) ? ob->pose : NULL; uiPopupMenu *pup; uiLayout *layout; - + /* sanity check */ - if (ELEM(NULL, ob, pose)) + if (ELEM(NULL, ob, pose)) return OPERATOR_CANCELLED; - + /* start building */ pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); layout = UI_popup_menu_layout(pup); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); - + /* add new (adds to the first unoccupied frame) */ uiItemIntO(layout, IFACE_("Add New"), ICON_NONE, "POSELIB_OT_pose_add", "frame", poselib_get_free_index(ob->poselib)); - + /* check if we have any choices to add a new pose in any other way */ if ((ob->poselib) && (ob->poselib->markers.first)) { /* add new (on current frame) */ uiItemIntO(layout, IFACE_("Add New (Current Frame)"), ICON_NONE, "POSELIB_OT_pose_add", "frame", CFRA); - + /* replace existing - submenu */ uiItemMenuF(layout, IFACE_("Replace Existing..."), 0, poselib_add_menu_invoke__replacemenu, NULL); } - + UI_popup_menu_end(C, pup); - + /* this operator is only for a menu, not used further */ return OPERATOR_INTERFACE; } @@ -464,14 +464,14 @@ static int poselib_add_exec(bContext *C, wmOperator *op) KeyingSet *ks; int frame = RNA_int_get(op->ptr, "frame"); char name[64]; - + /* sanity check (invoke should have checked this anyway) */ - if (ELEM(NULL, ob, pose)) + if (ELEM(NULL, ob, pose)) return OPERATOR_CANCELLED; - + /* get name to give to pose */ RNA_string_get(op->ptr, "name", name); - + /* add pose to poselib - replaces any existing pose there * - for the 'replace' option, this should end up finding the appropriate marker, * so no new one will be added @@ -484,23 +484,23 @@ static int poselib_add_exec(bContext *C, wmOperator *op) } if (marker == NULL) { marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); - + BLI_strncpy(marker->name, name, sizeof(marker->name)); marker->frame = frame; - + BLI_addtail(&act->markers, marker); } - + /* validate name */ BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name)); - + /* use Keying Set to determine what to store for the pose */ ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_SELECTED_ID); /* this includes custom props :)*/ ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); - + /* store new 'active' pose number */ act->active_marker = BLI_listbase_count(&act->markers); - + /* done */ return OPERATOR_FINISHED; } @@ -511,15 +511,15 @@ void POSELIB_OT_pose_add(wmOperatorType *ot) ot->name = "PoseLib Add Pose"; ot->idname = "POSELIB_OT_pose_add"; ot->description = "Add the current Pose to the active Pose Library"; - + /* api callbacks */ ot->invoke = poselib_add_menu_invoke; ot->exec = poselib_add_exec; ot->poll = poselib_add_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX); RNA_def_string(ot->srna, "name", "Pose", 64, "Pose Name", "Name of newly added Pose"); @@ -540,7 +540,7 @@ static const EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA if (C == NULL) { return DummyRNA_NULL_items; } - + /* check that the action exists */ if (act) { /* add each marker to the list */ @@ -587,12 +587,12 @@ static int poselib_remove_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_ERROR, "Invalid pose specified %d", marker_index); return OPERATOR_CANCELLED; } - + /* remove relevant keyframes */ for (fcu = act->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt; unsigned int i; - + if (fcu->bezt) { for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if remove */ @@ -603,18 +603,18 @@ static int poselib_remove_exec(bContext *C, wmOperator *op) } } } - + /* remove poselib from list */ BLI_freelinkN(&act->markers, marker); - + /* fix active pose number */ act->active_marker = 0; - - /* send notifiers for this - using keyframe editing notifiers, since action - * may be being shown in anim editors as active action + + /* send notifiers for this - using keyframe editing notifiers, since action + * may be being shown in anim editors as active action */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -622,20 +622,20 @@ static int poselib_remove_exec(bContext *C, wmOperator *op) void POSELIB_OT_pose_remove(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "PoseLib Remove Pose"; ot->idname = "POSELIB_OT_pose_remove"; ot->description = "Remove nth pose from the active Pose Library"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = poselib_remove_exec; ot->poll = has_poselib_pose_data_for_editing_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove"); RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); @@ -648,13 +648,13 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; - + /* check if valid poselib */ if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data"); return OPERATOR_CANCELLED; } - + /* get index (and pointer) of pose to remove */ marker = BLI_findlink(&act->markers, act->active_marker - 1); if (marker == NULL) { @@ -666,7 +666,7 @@ static int poselib_rename_invoke(bContext *C, wmOperator *op, const wmEvent *eve RNA_enum_set(op->ptr, "pose", act->active_marker - 1); RNA_string_set(op->ptr, "name", marker->name); } - + /* part to sync with other similar operators... */ return WM_operator_props_popup_confirm(C, op, event); } @@ -677,32 +677,32 @@ static int poselib_rename_exec(bContext *C, wmOperator *op) bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; char newname[64]; - + /* check if valid poselib */ if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "Object does not have pose lib data"); return OPERATOR_CANCELLED; } - + /* get index (and pointer) of pose to remove */ marker = BLI_findlink(&act->markers, RNA_enum_get(op->ptr, "pose")); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for pose"); return OPERATOR_CANCELLED; } - + /* get new name */ RNA_string_get(op->ptr, "name", newname); - + /* copy name and validate it */ BLI_strncpy(marker->name, newname, sizeof(marker->name)); BLI_uniquename(&act->markers, marker, DATA_("Pose"), '.', offsetof(TimeMarker, name), sizeof(marker->name)); - - /* send notifiers for this - using keyframe editing notifiers, since action - * may be being shown in anim editors as active action + + /* send notifiers for this - using keyframe editing notifiers, since action + * may be being shown in anim editors as active action */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -710,20 +710,20 @@ static int poselib_rename_exec(bContext *C, wmOperator *op) void POSELIB_OT_pose_rename(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "PoseLib Rename Pose"; ot->idname = "POSELIB_OT_pose_rename"; ot->description = "Rename specified pose from the active Pose Library"; - + /* api callbacks */ ot->invoke = poselib_rename_invoke; ot->exec = poselib_rename_exec; ot->poll = has_poselib_pose_data_for_editing_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose"); @@ -822,10 +822,10 @@ void POSELIB_OT_pose_move(wmOperatorType *ot) typedef struct tPoseLib_PreviewData { ListBase backups; /* tPoseLib_Backup structs for restoring poses */ ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ - + Scene *scene; /* active scene */ ScrArea *sa; /* active area */ - + PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ Object *ob; /* object to work on */ bArmature *arm; /* object's armature data */ @@ -842,7 +842,7 @@ typedef struct tPoseLib_PreviewData { short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ - + char headerstr[UI_MAX_DRAW_STR]; /* Info-text to print in header */ } tPoseLib_PreviewData; @@ -852,7 +852,7 @@ enum { PL_PREVIEW_RUNNING, PL_PREVIEW_CONFIRM, PL_PREVIEW_CANCEL, - PL_PREVIEW_RUNONCE + PL_PREVIEW_RUNONCE }; /* defines for tPoseLib_PreviewData->redraw values */ @@ -874,9 +874,9 @@ enum { /* simple struct for storing backup info */ typedef struct tPoseLib_Backup { struct tPoseLib_Backup *next, *prev; - + bPoseChannel *pchan; /* pose channel backups are for */ - + bPoseChannel olddata; /* copy of pose channel's old data (at start) */ IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */ } tPoseLib_Backup; @@ -904,22 +904,22 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld) for (agrp = pld->act->groups.first; agrp; agrp = agrp->next) { /* try to find posechannel */ pchan = BKE_pose_channel_find_name(pld->pose, agrp->name); - + /* backup data if available */ if (pchan) { tPoseLib_Backup *plb; - + /* store backup */ plb = MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup"); - + plb->pchan = pchan; memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel)); - + if (pchan->prop) plb->oldprops = IDP_CopyProperty(pchan->prop); - + BLI_addtail(&pld->backups, plb); - + /* mark as being affected */ pld->totcount++; } @@ -930,7 +930,7 @@ static void poselib_backup_posecopy(tPoseLib_PreviewData *pld) static void poselib_backup_restore(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb; - + for (plb = pld->backups.first; plb; plb = plb->next) { /* copy most of data straight back */ memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel)); @@ -956,7 +956,7 @@ static void poselib_backup_free_data(tPoseLib_PreviewData *pld) IDP_FreeProperty(plb->oldprops); MEM_freeN(plb->oldprops); } - + /* free backup element now */ BLI_freelinkN(&pld->backups, plb); } @@ -977,19 +977,19 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld) bPoseChannel *pchan; bAction *act = pld->act; bActionGroup *agrp; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc group_ok_cb; int frame = 1; const bool any_bone_selected = pld->flag & PL_PREVIEW_ANY_BONE_SELECTED; - + /* get the frame */ if (pld->marker) frame = pld->marker->frame; else return; - - + + /* init settings for testing groups for keyframes */ group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); ked.f1 = ((float)frame) - 0.5f; @@ -1001,10 +1001,10 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld) if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) { /* has keyframe on this frame, so try to get a PoseChannel with this name */ pchan = BKE_pose_channel_find_name(pose, agrp->name); - + if (pchan) { bool ok = 0; - + /* check if this bone should get any animation applied */ if (!any_bone_selected) { /* if no bones are selected, then any bone is ok */ @@ -1020,7 +1020,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld) } } - if (ok) + if (ok) animsys_evaluate_action_group(ptr, act, agrp, NULL, (float)frame); } } @@ -1034,7 +1034,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData bPoseChannel *pchan; bAction *act = pld->act; bActionGroup *agrp; - + KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); ListBase dsources = {NULL, NULL}; bool autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id); @@ -1044,13 +1044,13 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only for selected bones unless there aren't any selected, in which case all are included */ pchan = BKE_pose_channel_find_name(pose, agrp->name); - + if (pchan) { if (!any_bone_selected || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED))) { if (autokey) { /* add datasource override for the PoseChannel, to be used later */ - ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan); - + ANIM_relative_keyingset_add_source(&dsources, &pld->ob->id, &RNA_PoseBone, pchan); + /* clear any unkeyed tags */ if (pchan->bone) pchan->bone->flag &= ~BONE_UNKEYED; @@ -1063,14 +1063,14 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData } } } - + /* perform actual auto-keying now */ if (autokey) { /* insert keyframes for all relevant bones in one go */ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); BLI_freelistN(&dsources); } - + /* send notifiers for this */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } @@ -1079,7 +1079,7 @@ static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData static void poselib_preview_apply(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata; - + /* only recalc pose (and its dependencies) if pose has changed */ if (pld->redraw == PL_PREVIEW_REDRAWALL) { /* don't clear pose if firsttime */ @@ -1087,7 +1087,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) poselib_backup_restore(pld); else pld->flag &= ~PL_PREVIEW_FIRSTTIME; - + /* pose should be the right one to draw (unless we're temporarily not showing it) */ if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) { RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker)); @@ -1095,8 +1095,8 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) } else RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */ - - /* old optimize trick... this enforces to bypass the depgraph + + /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ // FIXME: shouldn't this use the builtin stuff? @@ -1105,7 +1105,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) else BKE_pose_where_is(pld->scene, pld->ob); } - + /* do header print - if interactively previewing */ if (pld->state == PL_PREVIEW_RUNNING) { if (pld->flag & PL_PREVIEW_SHOWORIGINAL) { @@ -1118,10 +1118,10 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) char tempstr[65]; char markern[64]; short index; - + /* get search-string */ index = pld->search_cursor; - + if (index >= 0 && index < sizeof(tempstr) - 1) { memcpy(&tempstr[0], &pld->searchstr[0], index); tempstr[index] = '|'; @@ -1130,7 +1130,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) else { BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr)); } - + /* get marker name */ BLI_strncpy(markern, pld->marker ? pld->marker->name : "No Matches", sizeof(markern)); @@ -1149,7 +1149,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) ED_area_headerprint(pld->sa, pld->headerstr); } } - + /* request drawing of view + clear redraw flag */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob); pld->redraw = PL_PREVIEW_NOREDRAW; @@ -1157,7 +1157,7 @@ static void poselib_preview_apply(bContext *C, wmOperator *op) /* ---------------------------- */ -/* This helper function is called during poselib_preview_poses to find the +/* This helper function is called during poselib_preview_poses to find the * pose to preview next (after a change event) */ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) @@ -1165,20 +1165,20 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) /* stop if not going anywhere, as we assume that there is a direction to move in */ if (step == 0) return; - + /* search-string dictates a special approach */ if (pld->searchstr[0]) { TimeMarker *marker; LinkData *ld, *ldn, *ldc; - + /* free and rebuild if needed (i.e. if search-str changed) */ if (!STREQ(pld->searchstr, pld->searchold)) { /* free list of temporary search matches */ BLI_freelistN(&pld->searchp); - + /* generate a new list of search matches */ for (marker = pld->act->markers.first; marker; marker = marker->next) { - /* does the name partially match? + /* does the name partially match? * - don't worry about case, to make it easier for users to quickly input a name (or * part of one), which is the whole point of this feature */ @@ -1189,17 +1189,17 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) BLI_addtail(&pld->searchp, ld); } } - + /* set current marker to NULL (so that we start from first) */ pld->marker = NULL; } - + /* check if any matches */ if (BLI_listbase_is_empty(&pld->searchp)) { pld->marker = NULL; return; } - + /* find first match */ for (ldc = pld->searchp.first; ldc; ldc = ldc->next) { if (ldc->data == pld->marker) @@ -1207,8 +1207,8 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) } if (ldc == NULL) ldc = pld->searchp.first; - - /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate + + /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { @@ -1219,19 +1219,19 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) for (ld = ldc; ld && step; ld = ldn, step++) ldn = (ld->prev) ? ld->prev : pld->searchp.last; } - + /* set marker */ if (ld) pld->marker = ld->data; } else { TimeMarker *marker, *next; - + /* if no marker, because we just ended searching, then set that to the start of the list */ if (pld->marker == NULL) pld->marker = pld->act->markers.first; - - /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate + + /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { @@ -1242,7 +1242,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) for (marker = pld->marker; marker && step; marker = next, step++) next = (marker->prev) ? marker->prev : pld->act->markers.last; } - + /* it should be fairly impossible for marker to be NULL */ if (marker) pld->marker = marker; @@ -1259,28 +1259,28 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh short len = strlen(pld->searchstr); short index = pld->search_cursor; short i; - - for (i = index; i <= len; i++) + + for (i = index; i <= len; i++) pld->searchstr[i - 1] = pld->searchstr[i]; - + pld->search_cursor--; - + poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; return; } break; - + case DELKEY: if (pld->searchstr[0] && pld->searchstr[1]) { short len = strlen(pld->searchstr); short index = pld->search_cursor; int i; - + if (index < len) { - for (i = index; i < len; i++) + for (i = index; i < len; i++) pld->searchstr[i] = pld->searchstr[i + 1]; - + poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; return; @@ -1288,23 +1288,23 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh } break; } - + if (ascii) { /* character to add to the string */ short index = pld->search_cursor; short len = (pld->searchstr[0]) ? strlen(pld->searchstr) : 0; short i; - + if (len) { - for (i = len; i > index; i--) + for (i = len; i > index; i--) pld->searchstr[i] = pld->searchstr[i - 1]; } else pld->searchstr[1] = 0; - + pld->searchstr[index] = ascii; pld->search_cursor++; - + poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; } @@ -1315,18 +1315,18 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con { tPoseLib_PreviewData *pld = op->customdata; int ret = OPERATOR_RUNNING_MODAL; - + /* only accept 'press' event, and ignore 'release', so that we don't get double actions */ if (ELEM(event->val, KM_PRESS, KM_NOTHING) == 0) { //printf("PoseLib: skipping event with type '%s' and val %d\n", WM_key_event_string(event->type, false), event->val); - return ret; + return ret; } - + /* backup stuff that needs to occur before every operation * - make a copy of searchstr, so that we know if cache needs to be rebuilt */ BLI_strncpy(pld->searchold, pld->searchstr, sizeof(pld->searchold)); - + /* if we're currently showing the original pose, only certain events are handled */ if (pld->flag & PL_PREVIEW_SHOWORIGINAL) { switch (event->type) { @@ -1335,7 +1335,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con case RIGHTMOUSE: pld->state = PL_PREVIEW_CANCEL; break; - + /* exit - confirm */ case LEFTMOUSE: case RETKEY: @@ -1343,30 +1343,30 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con case SPACEKEY: pld->state = PL_PREVIEW_CONFIRM; break; - + /* view manipulation */ - /* we add pass through here, so that the operators responsible for these can still run, + /* we add pass through here, so that the operators responsible for these can still run, * even though we still maintain control (as RUNNING_MODAL flag is still set too) */ case PAD0: case PAD1: case PAD2: case PAD3: case PAD4: case PAD5: case PAD6: case PAD7: case PAD8: case PAD9: - case PADPLUSKEY: case PADMINUS: + case PADPLUSKEY: case PADMINUS: case MIDDLEMOUSE: case MOUSEMOVE: //pld->redraw = PL_PREVIEW_REDRAWHEADER; ret = OPERATOR_PASS_THROUGH; break; - + /* quicky compare to original */ case TABKEY: pld->flag &= ~PL_PREVIEW_SHOWORIGINAL; pld->redraw = PL_PREVIEW_REDRAWALL; break; } - + /* EXITS HERE... */ return ret; } - + /* NORMAL EVENT HANDLING... */ /* searching takes priority over normal activity */ switch (event->type) { @@ -1375,7 +1375,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con case RIGHTMOUSE: pld->state = PL_PREVIEW_CANCEL; break; - + /* exit - confirm */ case LEFTMOUSE: case RETKEY: @@ -1383,39 +1383,39 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con case SPACEKEY: pld->state = PL_PREVIEW_CONFIRM; break; - + /* toggle between original pose and poselib pose*/ case TABKEY: pld->flag |= PL_PREVIEW_SHOWORIGINAL; pld->redraw = PL_PREVIEW_REDRAWALL; break; - + /* change to previous pose (cyclic) */ case PAGEUPKEY: case WHEELUPMOUSE: poselib_preview_get_next(pld, -1); pld->redraw = PL_PREVIEW_REDRAWALL; break; - + /* change to next pose (cyclic) */ case PAGEDOWNKEY: case WHEELDOWNMOUSE: poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; break; - + /* jump 5 poses (cyclic, back) */ case DOWNARROWKEY: poselib_preview_get_next(pld, -5); pld->redraw = PL_PREVIEW_REDRAWALL; break; - + /* jump 5 poses (cyclic, forward) */ case UPARROWKEY: poselib_preview_get_next(pld, 5); pld->redraw = PL_PREVIEW_REDRAWALL; break; - + /* change to next pose or searching cursor control */ case RIGHTARROWKEY: if (pld->searchstr[0]) { @@ -1430,7 +1430,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con pld->redraw = PL_PREVIEW_REDRAWALL; } break; - + /* change to next pose or searching cursor control */ case LEFTARROWKEY: if (pld->searchstr[0]) { @@ -1445,7 +1445,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con pld->redraw = PL_PREVIEW_REDRAWALL; } break; - + /* change to first pose or start of searching string */ case HOMEKEY: if (pld->searchstr[0]) { @@ -1456,11 +1456,11 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con /* change to first pose */ pld->marker = pld->act->markers.first; pld->act->active_marker = 1; - + pld->redraw = PL_PREVIEW_REDRAWALL; } break; - + /* change to last pose or start of searching string */ case ENDKEY: if (pld->searchstr[0]) { @@ -1471,20 +1471,20 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con /* change to last pose */ pld->marker = pld->act->markers.last; pld->act->active_marker = BLI_listbase_count(&pld->act->markers); - + pld->redraw = PL_PREVIEW_REDRAWALL; } break; - + /* view manipulation */ - /* we add pass through here, so that the operators responsible for these can still run, + /* we add pass through here, so that the operators responsible for these can still run, * even though we still maintain control (as RUNNING_MODAL flag is still set too) */ case MIDDLEMOUSE: case MOUSEMOVE: //pld->redraw = PL_PREVIEW_REDRAWHEADER; ret = OPERATOR_PASS_THROUGH; break; - + /* view manipulation, or searching */ case PAD0: case PAD1: case PAD2: case PAD3: case PAD4: case PAD5: case PAD6: case PAD7: case PAD8: case PAD9: @@ -1499,13 +1499,13 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con ret = OPERATOR_PASS_THROUGH; } break; - + /* otherwise, assume that searching might be able to handle it */ default: poselib_preview_handle_search(pld, event->type, event->ascii); break; } - + return ret; } @@ -1517,19 +1517,19 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op) tPoseLib_PreviewData *pld; Object *ob = get_poselib_object(C); int pose_index = RNA_int_get(op->ptr, "pose_index"); - + /* set up preview state info */ op->customdata = pld = MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data"); - + /* get basic data */ pld->ob = ob; pld->arm = (ob) ? (ob->data) : NULL; pld->pose = (ob) ? (ob->pose) : NULL; pld->act = (ob) ? (ob->poselib) : NULL; - + pld->scene = CTX_data_scene(C); pld->sa = CTX_wm_area(C); - + /* get starting pose based on RNA-props for this operator */ if (pose_index == -1) pld->marker = poselib_get_active_pose(pld->act); @@ -1537,7 +1537,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op) pld->flag |= PL_PREVIEW_SHOWORIGINAL; else pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL; - + /* check if valid poselib */ if (ELEM(NULL, pld->ob, pld->pose, pld->arm)) { BKE_report(op->reports, RPT_ERROR, "Pose lib is only for armatures in pose mode"); @@ -1553,7 +1553,7 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op) if (pld->act->markers.first) { /* just use first one then... */ pld->marker = pld->act->markers.first; - if (pose_index > -2) + if (pose_index > -2) BKE_report(op->reports, RPT_WARNING, "Pose lib had no active pose"); } else { @@ -1562,23 +1562,23 @@ static void poselib_preview_init_data(bContext *C, wmOperator *op) return; } } - + /* get ID pointer for applying poses */ RNA_id_pointer_create(&ob->id, &pld->rna_ptr); - + /* make backups for restoring pose */ poselib_backup_posecopy(pld); - + /* set flags for running */ pld->state = PL_PREVIEW_RUNNING; pld->redraw = PL_PREVIEW_REDRAWALL; pld->flag |= PL_PREVIEW_FIRSTTIME; - + /* set depsgraph flags */ /* make sure the lock is set OK, unlock can be accidentally saved? */ pld->pose->flag |= POSE_LOCKED; pld->pose->flag &= ~POSE_DO_UNLOCK; - + /* clear strings + search */ pld->headerstr[0] = pld->searchstr[0] = pld->searchold[0] = '\0'; pld->search_cursor = 0; @@ -1594,18 +1594,18 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) bArmature *arm = pld->arm; bAction *act = pld->act; TimeMarker *marker = pld->marker; - + /* redraw the header so that it doesn't show any of our stuff anymore */ ED_area_headerprint(pld->sa, NULL); - + /* this signal does one recalc on pose, then unlocks, so ESC or edit will work */ pose->flag |= POSE_DO_UNLOCK; - + /* clear pose if canceled */ if (pld->state == PL_PREVIEW_CANCEL) { poselib_backup_restore(pld); - - /* old optimize trick... this enforces to bypass the depgraph + + /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ if ((arm->flag & ARM_DELAYDEFORM) == 0) @@ -1616,14 +1616,14 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) else if (pld->state == PL_PREVIEW_CONFIRM) { /* tag poses as appropriate */ poselib_keytag_pose(C, scene, pld); - + /* change active pose setting */ act->active_marker = BLI_findindex(&act->markers, marker) + 1; action_set_activemarker(act, marker, NULL); - + /* Update event for pose and deformation children */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - + /* updates */ if (IS_AUTOKEY_MODE(scene, NORMAL)) { //remake_action_ipos(ob->action); @@ -1631,14 +1631,14 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) else BKE_pose_where_is(scene, ob); } - + /* Request final redraw of the view. */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob); - + /* free memory used for backups and searching */ poselib_backup_free_data(pld); BLI_freelistN(&pld->searchp); - + /* free temp data for operator */ MEM_freeN(pld); op->customdata = NULL; @@ -1649,10 +1649,10 @@ static int poselib_preview_exit(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld = op->customdata; int exit_state = pld->state; - + /* finish up */ poselib_preview_cleanup(C, op); - + if (ELEM(exit_state, PL_PREVIEW_CANCEL, PL_PREVIEW_ERROR)) return OPERATOR_CANCELLED; else @@ -1670,18 +1670,18 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve { tPoseLib_PreviewData *pld = op->customdata; int ret; - + /* 1) check state to see if we're still running */ if (pld->state != PL_PREVIEW_RUNNING) return poselib_preview_exit(C, op); - + /* 2) handle events */ ret = poselib_preview_handle_event(C, op, event); - + /* 3) apply changes and redraw, otherwise, confirming goes wrong */ if (pld->redraw) poselib_preview_apply(C, op); - + return ret; } @@ -1689,20 +1689,20 @@ static int poselib_preview_modal(bContext *C, wmOperator *op, const wmEvent *eve static int poselib_preview_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { tPoseLib_PreviewData *pld; - + /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); pld = (tPoseLib_PreviewData *)op->customdata; - + if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ poselib_preview_cleanup(C, op); return OPERATOR_CANCELLED; } - + /* do initial apply to have something to look at */ poselib_preview_apply(C, op); - + /* add temp handler if we're running as a modal operator */ WM_event_add_modal_handler(C, op); @@ -1713,28 +1713,28 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, const wmEvent *UN static int poselib_preview_exec(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld; - + /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); pld = (tPoseLib_PreviewData *)op->customdata; - + if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ poselib_preview_cleanup(C, op); return OPERATOR_CANCELLED; } - + /* the exec() callback is effectively a 'run-once' scenario, so set the state to that * so that everything draws correctly */ pld->state = PL_PREVIEW_RUNONCE; - + /* apply the active pose */ poselib_preview_apply(C, op); - + /* now, set the status to exit */ pld->state = PL_PREVIEW_CONFIRM; - + /* cleanup */ return poselib_preview_exit(C, op); } @@ -1745,21 +1745,21 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot) ot->name = "PoseLib Browse Poses"; ot->idname = "POSELIB_OT_browse_interactive"; ot->description = "Interactively browse poses in 3D-View"; - + /* callbacks */ ot->invoke = poselib_preview_invoke; ot->modal = poselib_preview_modal; ot->cancel = poselib_preview_cancel; ot->exec = poselib_preview_exec; ot->poll = has_poselib_pose_data_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; - + /* properties */ // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); - + // XXX: percentage vs factor? /* not used yet */ /* RNA_def_float_factor(ot->srna, "blend_factor", 1.0f, 0.0f, 1.0f, "Blend Factor", "Amount that the pose is applied on top of the existing poses", 0.0f, 1.0f); */ @@ -1771,7 +1771,7 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot) ot->name = "Apply Pose Library Pose"; ot->idname = "POSELIB_OT_apply_pose"; ot->description = "Apply specified Pose Library pose to the rig"; - + /* callbacks */ ot->exec = poselib_preview_exec; ot->poll = has_poselib_pose_data_poll; diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c index 4b62fd15c04..1389b26a1e1 100644 --- a/source/blender/editors/armature/pose_select.c +++ b/source/blender/editors/armature/pose_select.c @@ -101,9 +101,9 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) // XXX: actually, we can probably still get away with no object - at most we have no updates if (ELEM(NULL, ob, ob->pose, pchan, pchan->bone)) return; - + arm = ob->data; - + /* can only change selection state if bone can be modified */ if (PBONE_SELECTABLE(arm, pchan->bone)) { /* change selection state - activate too if selected */ @@ -115,16 +115,16 @@ void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select) pchan->bone->flag &= ~BONE_SELECTED; arm->act_bone = NULL; } - + // TODO: select and activate corresponding vgroup? - - /* tag necessary depsgraph updates + + /* tag necessary depsgraph updates * (see rna_Bone_select_update() in rna_armature.c for details) */ if (arm->flag & ARM_HAS_VIZ_DEPS) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } - + /* send necessary notifiers */ WM_main_add_notifier(NC_GEOM | ND_DATA, ob); } @@ -138,16 +138,16 @@ bool ED_armature_pose_select_pick_with_buffer( { Object *ob = base->object; Bone *nearBone; - + if (!ob || !ob->pose) return 0; nearBone = get_bone_from_selectbuffer(scene, base, buffer, hits, 1, do_nearest); - + /* if the bone cannot be affected, don't do anything */ if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) { Object *ob_act = OBACT; bArmature *arm = ob->data; - + /* since we do unified select, we don't shift+select a bone if the * armature object was not active yet. * note, special exception for armature mode so we can do multi-select @@ -191,7 +191,7 @@ bool ED_armature_pose_select_pick_with_buffer( } } } - + if (ob_act) { /* in weightpaint we select the associated vertex group too */ if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { @@ -200,18 +200,18 @@ bool ED_armature_pose_select_pick_with_buffer( DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } } - /* if there are some dependencies for visualizing armature state - * (e.g. Mask Modifier in 'Armature' mode), force update + /* if there are some dependencies for visualizing armature state + * (e.g. Mask Modifier in 'Armature' mode), force update */ else if (arm->flag & ARM_HAS_VIZ_DEPS) { - /* NOTE: ob not ob_act here is intentional - it's the source of the + /* NOTE: ob not ob_act here is intentional - it's the source of the * bones being selected [T37247] */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } } } - + return nearBone != NULL; } @@ -221,12 +221,12 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil { bArmature *arm = ob->data; bPoseChannel *pchan; - + /* we call this from outliner too */ if (ob->pose == NULL) { return; } - + /* Determine if we're selecting or deselecting */ if (select_mode == SEL_TOGGLE) { select_mode = SEL_SELECT; @@ -239,7 +239,7 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil } } } - + /* Set the flags accordingly */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* ignore the pchan if it isn't visible or if its selection cannot be changed */ @@ -254,19 +254,19 @@ void ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibil static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) { Bone *curBone; - + /* stop when unconnected child is encountered, or when unselectable bone is encountered */ if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) return; - + /* XXX old cruft! use notifiers instead */ //select_actionchannel_by_name (ob->action, bone->name, !(shift)); - + if (extend) bone->flag &= ~BONE_SELECTED; else bone->flag |= BONE_SELECTED; - + for (curBone = bone->childbase.first; curBone; curBone = curBone->next) selectconnected_posebonechildren(ob, curBone, extend); } @@ -286,7 +286,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve if (!bone) return OPERATOR_CANCELLED; - + /* Select parents */ for (curBone = bone; curBone; curBone = next) { /* ignore bone if cannot be selected */ @@ -295,7 +295,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve curBone->flag &= ~BONE_SELECTED; else curBone->flag |= BONE_SELECTED; - + if (curBone->flag & BONE_CONNECTED) next = curBone->parent; else @@ -304,14 +304,14 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve else next = NULL; } - + /* Select children */ for (curBone = bone->childbase.first; curBone; curBone = next) selectconnected_posebonechildren(ob, curBone, extend); - + /* updates */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + if (arm->flag & ARM_HAS_VIZ_DEPS) { /* mask modifier ('armature' mode), etc. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -331,15 +331,15 @@ void POSE_OT_select_linked(wmOperatorType *ot) ot->name = "Select Connected"; ot->idname = "POSE_OT_select_linked"; ot->description = "Select bones related to selected ones by parent/child relationships"; - + /* api callbacks */ /* leave 'exec' unset */ ot->invoke = pose_select_connected_invoke; ot->poll = pose_select_linked_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); } @@ -349,7 +349,7 @@ void POSE_OT_select_linked(wmOperatorType *ot) static int pose_de_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); - + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_context(C); bArmature *arm = ob->data; @@ -358,7 +358,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) if (action == SEL_TOGGLE) { action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT; } - + /* Set the flags */ CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) { @@ -367,7 +367,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) CTX_DATA_END; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); - + /* weightpaint or mask modifiers need depsgraph updates */ if (multipaint || (arm->flag & ARM_HAS_VIZ_DEPS)) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -382,14 +382,14 @@ void POSE_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All"; ot->idname = "POSE_OT_select_all"; ot->description = "Toggle selection status of all bones"; - + /* api callbacks */ ot->exec = pose_de_select_all_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + WM_operator_properties_select_all(ot); } @@ -416,15 +416,15 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) else { return OPERATOR_CANCELLED; } - + /* updates */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + if (arm->flag & ARM_HAS_VIZ_DEPS) { /* mask modifier ('armature' mode), etc. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } - + return OPERATOR_FINISHED; } @@ -451,7 +451,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op bArmature *arm = (bArmature *)ob->data; bConstraint *con; int found = 0; - + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { if (pchan->bone->flag & BONE_SELECTED) { @@ -459,10 +459,10 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - + if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == ob) && (ct->subtarget[0])) { bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget); @@ -472,7 +472,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op } } } - + if (cti->flush_constraint_targets) cti->flush_constraint_targets(con, &targets, 1); } @@ -480,18 +480,18 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op } } CTX_DATA_END; - + if (!found) return OPERATOR_CANCELLED; - + /* updates */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + if (arm->flag & ARM_HAS_VIZ_DEPS) { /* mask modifier ('armature' mode), etc. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } - + return OPERATOR_FINISHED; } @@ -501,11 +501,11 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot) ot->name = "Select Constraint Target"; ot->idname = "POSE_OT_select_constraint_target"; ot->description = "Select bones used as targets for the currently selected bones"; - + /* api callbacks */ ot->exec = pose_select_constraint_target_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -520,7 +520,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) int direction = RNA_enum_get(op->ptr, "direction"); const bool add_to_sel = RNA_boolean_get(op->ptr, "extend"); bool changed = false; - + pchan_act = BKE_pose_channel_active(ob); if (pchan_act == NULL) { return OPERATOR_CANCELLED; @@ -577,15 +577,15 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) if (changed == false) { return OPERATOR_CANCELLED; } - + /* updates */ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); - + if (arm->flag & ARM_HAS_VIZ_DEPS) { /* mask modifier ('armature' mode), etc. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } - + return OPERATOR_FINISHED; } @@ -596,19 +596,19 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot) {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Select Hierarchy"; ot->idname = "POSE_OT_select_hierarchy"; ot->description = "Select immediate parent/children of selected bones"; - + /* api callbacks */ ot->exec = pose_select_hierarchy_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", ""); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection"); @@ -630,22 +630,22 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend) char *group_flags; int numGroups = 0; bool changed = false, tagged = false; - + /* sanity checks */ if (ELEM(NULL, ob, pose, arm)) return 0; - + /* count the number of groups */ numGroups = BLI_listbase_count(&pose->agroups); if (numGroups == 0) return 0; - - /* alloc a small array to keep track of the groups to use + + /* alloc a small array to keep track of the groups to use * - each cell stores on/off state for whether group should be used * - size is (numGroups + 1), since (index = 0) is used for no-group */ group_flags = MEM_callocN(numGroups + 1, "pose_select_same_group"); - + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { /* keep track of group as group to use later? */ @@ -653,13 +653,13 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend) group_flags[pchan->agrp_index] = 1; tagged = true; } - + /* deselect all bones before selecting new ones? */ if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; - + /* small optimization: only loop through bones a second time if there are any groups tagged */ if (tagged) { /* only if group matches (and is not selected or current bone) */ @@ -675,10 +675,10 @@ static bool pose_select_same_group(bContext *C, Object *ob, bool extend) } CTX_DATA_END; } - + /* free temp info */ MEM_freeN(group_flags); - + return changed; } @@ -688,25 +688,25 @@ static bool pose_select_same_layer(bContext *C, Object *ob, bool extend) bArmature *arm = (ob) ? ob->data : NULL; bool changed = false; int layers = 0; - + if (ELEM(NULL, ob, pose, arm)) return 0; - + /* figure out what bones are selected */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { /* keep track of layers to use later? */ if (pchan->bone->flag & BONE_SELECTED) layers |= pchan->bone->layer; - + /* deselect all bones before selecting new ones? */ if ((extend == false) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; - if (layers == 0) + if (layers == 0) return 0; - + /* select bones that are on same layers as layers flag */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { @@ -717,7 +717,7 @@ static bool pose_select_same_layer(bContext *C, Object *ob, bool extend) } } CTX_DATA_END; - + return changed; } @@ -725,11 +725,11 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object { KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); KS_Path *ksp; - + bArmature *arm = (ob) ? ob->data : NULL; bPose *pose = (ob) ? ob->pose : NULL; bool changed = false; - + /* sanity checks: validate Keying Set and object */ if (ks == NULL) { BKE_report(reports, RPT_ERROR, "No active Keying Set to use"); @@ -738,7 +738,7 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object else if (ANIM_validate_keyingset(C, NULL, ks) != 0) { if (ks->paths.first == NULL) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - BKE_report(reports, RPT_ERROR, + BKE_report(reports, RPT_ERROR, "Use another Keying Set, as the active one depends on the currently " "selected items or cannot find any targets due to unsuitable context"); } @@ -748,10 +748,10 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object } return false; } - + if (ELEM(NULL, ob, pose, arm)) return false; - + /* if not extending selection, deselect all selected first */ if (extend == false) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) @@ -761,8 +761,8 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object } CTX_DATA_END; } - - /* iterate over elements in the Keying Set, setting selection depending on whether + + /* iterate over elements in the Keying Set, setting selection depending on whether * that bone is visible or not... */ for (ksp = ks->paths.first; ksp; ksp = ksp->next) { @@ -770,10 +770,10 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object if ((ksp->id == &ob->id) && (ksp->rna_path != NULL)) { if (strstr(ksp->rna_path, "bones")) { char *boneName = BLI_str_quoted_substrN(ksp->rna_path, "bones["); - + if (boneName) { bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName); - + if (pchan) { /* select if bone is visible and can be affected */ if (PBONE_SELECTABLE(arm, pchan->bone)) { @@ -781,14 +781,14 @@ static bool pose_select_same_keyingset(bContext *C, ReportList *reports, Object changed = true; } } - + /* free temp memory */ MEM_freeN(boneName); } } } } - + return changed; } @@ -799,38 +799,38 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op) const ePose_SelectSame_Mode type = RNA_enum_get(op->ptr, "type"); const bool extend = RNA_boolean_get(op->ptr, "extend"); bool changed = false; - + /* sanity check */ if (ob->pose == NULL) return OPERATOR_CANCELLED; - + /* selection types */ switch (type) { case POSE_SEL_SAME_LAYER: /* layer */ changed = pose_select_same_layer(C, ob, extend); break; - + case POSE_SEL_SAME_GROUP: /* group */ changed = pose_select_same_group(C, ob, extend); break; - + case POSE_SEL_SAME_KEYINGSET: /* Keying Set */ changed = pose_select_same_keyingset(C, op->reports, ob, extend); break; - + default: printf("pose_select_grouped() - Unknown selection type %u\n", type); break; } - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + if (arm->flag & ARM_HAS_VIZ_DEPS) { /* mask modifier ('armature' mode), etc. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } - + /* report done status */ if (changed) return OPERATOR_FINISHED; @@ -851,15 +851,15 @@ void POSE_OT_select_grouped(wmOperatorType *ot) ot->name = "Select Grouped"; ot->description = "Select all visible bones grouped by similar properties"; ot->idname = "POSE_OT_select_grouped"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = pose_select_grouped_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", ""); @@ -936,11 +936,11 @@ void POSE_OT_select_mirror(wmOperatorType *ot) ot->name = "Flip Active/Selected Bone"; ot->idname = "POSE_OT_select_mirror"; ot->description = "Mirror the bone selection"; - + /* api callbacks */ ot->exec = pose_select_mirror_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 88203474d03..b82535f013b 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -63,7 +63,7 @@ #include "armature_intern.h" /* **************************************************** */ -/* == POSE 'SLIDING' TOOLS == +/* == POSE 'SLIDING' TOOLS == * * A) Push & Relax, Breakdowner * These tools provide the animator with various capabilities @@ -96,21 +96,21 @@ typedef struct tPoseSlideOp { DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */ int cframe; /* current frame number - global time */ - + int prevFrame; /* frame before current frame (blend-from) - global time */ int nextFrame; /* frame after current frame (blend-to) - global time */ - + float prevFrameF; /* prevFrame, but in local action time (for F-Curve lookups to work) */ float nextFrameF; /* nextFrame, but in local action time (for F-Curve lookups to work) */ - + short mode; /* sliding mode (ePoseSlide_Modes) */ short flag; /* unused for now, but can later get used for storing runtime settings.... */ - + short channels; /* which transforms/channels are affected (ePoseSlide_Channels) */ short axislock; /* axis-limits for transforms (ePoseSlide_AxisLock) */ - + float percentage; /* 0-1 value for determining the influence of whatever is relevant */ - + NumInput num; /* numeric input */ } tPoseSlideOp; @@ -125,19 +125,19 @@ typedef enum ePoseSlide_Modes { /* Transforms/Channels to Affect */ typedef enum ePoseSlide_Channels { PS_TFM_ALL = 0, /* All transforms and properties */ - + PS_TFM_LOC, /* Loc/Rot/Scale */ PS_TFM_ROT, PS_TFM_SIZE, - + PS_TFM_BBONE_SHAPE, /* Bendy Bones */ - + PS_TFM_PROPS /* Custom Properties */ } ePoseSlide_Channels; /* Property enum for ePoseSlide_Channels */ static const EnumPropertyItem prop_channels_types[] = { - {PS_TFM_ALL, "ALL", 0, "All Properties", + {PS_TFM_ALL, "ALL", 0, "All Properties", "All properties, including transforms, bendy bone shape, and custom properties"}, {PS_TFM_LOC, "LOC", 0, "Location", "Location only"}, {PS_TFM_ROT, "ROT", 0, "Rotation", "Rotation only"}, @@ -171,60 +171,60 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode) { tPoseSlideOp *pso; bAction *act = NULL; - + /* init slide-op data */ pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); - + /* get info from context */ pso->scene = CTX_data_scene(C); pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); pso->arm = (pso->ob) ? pso->ob->data : NULL; pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */ pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */ - + pso->cframe = pso->scene->r.cfra; pso->mode = mode; - + /* set range info from property values - these may get overridden for the invoke() */ pso->percentage = RNA_float_get(op->ptr, "percentage"); pso->prevFrame = RNA_int_get(op->ptr, "prev_frame"); pso->nextFrame = RNA_int_get(op->ptr, "next_frame"); - + /* get the set of properties/axes that can be operated on */ pso->channels = RNA_enum_get(op->ptr, "channels"); pso->axislock = RNA_enum_get(op->ptr, "axis_lock"); - + /* ensure validity of the settings from the context */ if (ELEM(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action)) return 0; - + act = pso->ob->adt->action; - + /* apply NLA mapping corrections so the frame lookups work */ pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP); pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP); - - /* for each Pose-Channel which gets affected, get the F-Curves for that channel + + /* for each Pose-Channel which gets affected, get the F-Curves for that channel * and set the relevant transform flags... */ poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act); - + /* set depsgraph flags */ /* make sure the lock is set OK, unlock can be accidentally saved? */ pso->ob->pose->flag |= POSE_LOCKED; pso->ob->pose->flag &= ~POSE_DO_UNLOCK; - - /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up + + /* do basic initialize of RB-BST used for finding keyframes, but leave the filling of it up * to the caller of this (usually only invoke() will do it, to make things more efficient). */ BLI_dlrbTree_init(&pso->keys); - + /* initialise numeric input */ initNumInput(&pso->num); pso->num.idx_max = 0; /* one axis */ pso->num.val_flag[0] |= NUM_NO_NEGATIVE; pso->num.unit_type[0] = B_UNIT_NONE; /* percentages don't have any units... */ - + /* return status is whether we've got all the data we were requested to get */ return 1; } @@ -233,19 +233,19 @@ static int pose_slide_init(bContext *C, wmOperator *op, short mode) static void pose_slide_exit(wmOperator *op) { tPoseSlideOp *pso = op->customdata; - + /* if data exists, clear its data and exit */ if (pso) { /* free the temp pchan links and their data */ poseAnim_mapping_free(&pso->pfLinks); - + /* free RB-BST for keyframes (if it contained data) */ BLI_dlrbTree_free(&pso->keys); - + /* free data itself */ MEM_freeN(pso); } - + /* cleanup */ op->customdata = NULL; } @@ -265,19 +265,19 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) float cframe = (float)pso->cframe; float sVal, eVal; float w1, w2; - + /* get keyframe values for endpoint poses to blend with */ /* previous/start */ sVal = evaluate_fcurve(fcu, pso->prevFrameF); /* next/end */ eVal = evaluate_fcurve(fcu, pso->nextFrameF); - + /* if both values are equal, don't do anything */ if (IS_EQF(sVal, eVal)) { (*val) = sVal; return; } - + /* calculate the relative weights of the endpoints */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* get weights from the percentage control */ @@ -285,20 +285,20 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) w2 = 1.0f - w1; /* this must come first */ } else { - /* - these weights are derived from the relative distance of these + /* - these weights are derived from the relative distance of these * poses from the current frame * - they then get normalized so that they only sum up to 1 */ - float wtot; - + float wtot; + w1 = cframe - (float)pso->prevFrame; w2 = (float)pso->nextFrame - cframe; - + wtot = w1 + w2; w1 = (w1 / wtot); w2 = (w2 / wtot); } - + /* depending on the mode, calculate the new value * - in all of these, the start+end values are multiplied by w2 and w1 (respectively), * since multiplication in another order would decrease the value the current frame is closer to @@ -311,7 +311,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) * - perform this weighting a number of times given by the percentage... */ int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ - + while (iters-- > 0) { (*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f; } @@ -324,7 +324,7 @@ static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) * - perform this weighting a number of times given by the percentage... */ int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ - + while (iters-- > 0) { (*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f; } @@ -345,19 +345,19 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa { LinkData *ld = NULL; char *path = NULL; - + /* get the path to use... */ path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName); - + /* using this path, find each matching F-Curve for the variables we're interested in */ while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { FCurve *fcu = (FCurve *)ld->data; const int idx = fcu->array_index; const int lock = pso->axislock; - + /* check if this F-Curve is ok given the current axis locks */ BLI_assert(fcu->array_index < 3); - + if ((lock == 0) || ((lock & PS_LOCK_X) && (idx == 0)) || ((lock & PS_LOCK_Y) && (idx == 1)) || @@ -367,7 +367,7 @@ static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, floa pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]); } } - + /* free the temp path we got */ MEM_freeN(path); } @@ -378,11 +378,11 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con PointerRNA ptr = {{NULL}}; LinkData *ld; int len = strlen(pfl->pchan_path); - + /* setup pointer RNA for resolving paths */ RNA_pointer_create(NULL, &RNA_PoseBone, pfl->pchan, &ptr); - - /* - custom properties are just denoted using ["..."][etc.] after the end of the base path, + + /* - custom properties are just denoted using ["..."][etc.] after the end of the base path, * so just check for opening pair after the end of the path * - bbone properties are similar, but they always start with a prefix "bbone_*", * so a similar method should work here for those too @@ -390,23 +390,23 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con for (ld = pfl->fcurves.first; ld; ld = ld->next) { FCurve *fcu = (FCurve *)ld->data; const char *bPtr, *pPtr; - + if (fcu->rna_path == NULL) continue; - - /* do we have a match? + + /* do we have a match? * - bPtr is the RNA Path with the standard part chopped off * - pPtr is the chunk of the path which is left over */ bPtr = strstr(fcu->rna_path, pfl->pchan_path) + len; pPtr = strstr(bPtr, prop_prefix); - + if (pPtr) { /* use RNA to try and get a handle on this property, then, assuming that it is just * numerical, try and grab the value as a float for temp editing before setting back */ PropertyRNA *prop = RNA_struct_find_property(&ptr, pPtr); - + if (prop) { switch (RNA_property_type(prop)) { /* continuous values that can be smoothly interpolated... */ @@ -424,7 +424,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con RNA_property_int_set(&ptr, prop, (int)tval); break; } - + /* values which can only take discrete values */ case PROP_BOOLEAN: { @@ -440,7 +440,7 @@ static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl, con */ break; } - + default: /* cannot handle */ //printf("Cannot Pose Slide non-numerical property\n"); @@ -459,17 +459,17 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) LinkData *ld = NULL; char *path = NULL; float cframe; - + /* get the path to use - this should be quaternion rotations only (needs care) */ path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion"); - + /* get the current frame number */ cframe = (float)pso->cframe; - + /* using this path, find each matching F-Curve for the variables we're interested in */ while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { FCurve *fcu = (FCurve *)ld->data; - + /* assign this F-Curve to one of the relevant pointers... */ switch (fcu->array_index) { case 3: /* z */ @@ -486,22 +486,22 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) break; } } - + /* only if all channels exist, proceed */ if (fcu_w && fcu_x && fcu_y && fcu_z) { float quat_prev[4], quat_next[4]; - + /* get 2 quats */ quat_prev[0] = evaluate_fcurve(fcu_w, pso->prevFrameF); quat_prev[1] = evaluate_fcurve(fcu_x, pso->prevFrameF); quat_prev[2] = evaluate_fcurve(fcu_y, pso->prevFrameF); quat_prev[3] = evaluate_fcurve(fcu_z, pso->prevFrameF); - + quat_next[0] = evaluate_fcurve(fcu_w, pso->nextFrameF); quat_next[1] = evaluate_fcurve(fcu_x, pso->nextFrameF); quat_next[2] = evaluate_fcurve(fcu_y, pso->nextFrameF); quat_next[3] = evaluate_fcurve(fcu_z, pso->nextFrameF); - + /* perform blending */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* just perform the interpol between quat_prev and quat_next using pso->percentage as a guide */ @@ -509,35 +509,35 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) } else if (pso->mode == POSESLIDE_PUSH) { float quat_diff[4], quat_orig[4]; - + /* calculate the delta transform from the previous to the current */ /* TODO: investigate ways to favour one transform more? */ sub_qt_qtqt(quat_diff, pchan->quat, quat_prev); - + /* make a copy of the original rotation */ copy_qt_qt(quat_orig, pchan->quat); - + /* increase the original by the delta transform, by an amount determined by percentage */ add_qt_qtqt(pchan->quat, quat_orig, quat_diff, pso->percentage); } else { float quat_interp[4], quat_orig[4]; int iters = (int)ceil(10.0f * pso->percentage); /* TODO: maybe a sensitivity ctrl on top of this is needed */ - + /* perform this blending several times until a satisfactory result is reached */ while (iters-- > 0) { /* calculate the interpolation between the endpoints */ interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame)); - + /* make a copy of the original rotation */ copy_qt_qt(quat_orig, pchan->quat); - + /* tricky interpolations - blending between original and new */ interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f); } } } - + /* free the path now */ MEM_freeN(path); } @@ -546,37 +546,37 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) { tPChanFCurveLink *pfl; - + /* sanitise the frame ranges */ if (pso->prevFrame == pso->nextFrame) { /* move out one step either side */ pso->prevFrame--; pso->nextFrame++; - + /* apply NLA mapping corrections so the frame lookups work */ pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP); pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP); } - + /* for each link, handle each set of transforms */ for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { - /* valid transforms for each PoseChannel should have been noted already - * - sliding the pose should be a straightforward exercise for location+rotation, - * but rotations get more complicated since we may want to use quaternion blending + /* valid transforms for each PoseChannel should have been noted already + * - sliding the pose should be a straightforward exercise for location+rotation, + * but rotations get more complicated since we may want to use quaternion blending * for quaternions instead... */ bPoseChannel *pchan = pfl->pchan; - + if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_LOC) && (pchan->flag & POSE_LOC)) { /* calculate these for the 'location' vector, and use location curves */ pose_slide_apply_vec3(pso, pfl, pchan->loc, "location"); } - + if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_SIZE) && (pchan->flag & POSE_SIZE)) { /* calculate these for the 'scale' vector, and use scale curves */ pose_slide_apply_vec3(pso, pfl, pchan->size, "scale"); } - + if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_ROT) && (pchan->flag & POSE_ROT)) { /* everything depends on the rotation mode */ if (pchan->rotmode > 0) { @@ -591,12 +591,12 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) pose_slide_apply_quat(pso, pfl); } } - + if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_BBONE_SHAPE) && (pchan->flag & POSE_BBONE_SHAPE)) { /* bbone properties - they all start a "bbone_" prefix */ - pose_slide_apply_props(pso, pfl, "bbone_"); + pose_slide_apply_props(pso, pfl, "bbone_"); } - + if (ELEM(pso->channels, PS_TFM_ALL, PS_TFM_PROPS) && (pfl->oldprops)) { /* not strictly a transform, but custom properties contribute to the pose produced in many rigs * (e.g. the facial rigs used in Sintel) @@ -604,7 +604,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) pose_slide_apply_props(pso, pfl, "[\""); /* dummy " for texteditor bugs */ } } - + /* depsgraph updates + redraws */ pose_slide_refresh(C, pso); } @@ -633,7 +633,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) char limits_str[UI_MAX_DRAW_STR]; char axis_str[50]; char mode_str[32]; - + switch (pso->mode) { case POSESLIDE_PUSH: strcpy(mode_str, "Push Pose"); @@ -644,13 +644,13 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) case POSESLIDE_BREAKDOWN: strcpy(mode_str, "Breakdown"); break; - + default: /* unknown */ strcpy(mode_str, "Sliding-Tool"); break; } - + switch (pso->axislock) { case PS_LOCK_X: BLI_strncpy(axis_str, "[X]/Y/Z axis only (X to clear)", sizeof(axis_str)); @@ -661,7 +661,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) case PS_LOCK_Z: BLI_strncpy(axis_str, "X/Y/[Z] axis only (Z to clear)", sizeof(axis_str)); break; - + default: if (ELEM(pso->channels, PS_TFM_LOC, PS_TFM_ROT, PS_TFM_SIZE)) { BLI_strncpy(axis_str, "X/Y/Z = Axis Constraint", sizeof(axis_str)); @@ -671,7 +671,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) } break; } - + switch (pso->channels) { case PS_TFM_LOC: BLI_snprintf(limits_str, sizeof(limits_str), "[G]/R/S/B/C - Location only (G to clear) | %s", axis_str); @@ -692,19 +692,19 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) BLI_strncpy(limits_str, "G/R/S/B/C - Limit to Transform/Property Set", sizeof(limits_str)); break; } - + if (hasNumInput(&pso->num)) { Scene *scene = pso->scene; char str_offs[NUM_STR_REP_LEN]; - + outputNumInput(&pso->num, str_offs, &scene->unit); - + BLI_snprintf(status_str, sizeof(status_str), "%s: %s | %s", mode_str, str_offs, limits_str); } else { BLI_snprintf(status_str, sizeof(status_str), "%s: %d %% | %s", mode_str, (int)(pso->percentage * 100.0f), limits_str); } - + ED_area_headerprint(pso->sa, status_str); } @@ -714,34 +714,34 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p tPChanFCurveLink *pfl; AnimData *adt = pso->ob->adt; wmWindow *win = CTX_wm_window(C); - + /* for each link, add all its keyframes to the search tree */ for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { LinkData *ld; - + /* do this for each F-Curve */ for (ld = pfl->fcurves.first; ld; ld = ld->next) { FCurve *fcu = (FCurve *)ld->data; fcurve_to_keylist(adt, fcu, &pso->keys, NULL); } } - + /* consolidate these keyframes, and figure out the nearest ones */ BLI_dlrbTree_linkedlist_sync(&pso->keys); - + /* cancel if no keyframes found... */ if (pso->keys.root) { ActKeyColumn *ak; float cframe = (float)pso->cframe; - + /* firstly, check if the current frame is a keyframe... */ ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe); - + if (ak == NULL) { /* current frame is not a keyframe, so search */ ActKeyColumn *pk = (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe); ActKeyColumn *nk = (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe); - + /* new set the frames */ /* prev frame */ pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1); @@ -759,7 +759,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1); RNA_int_set(op->ptr, "next_frame", pso->nextFrame); } - + /* apply NLA mapping corrections so the frame lookups work */ pso->prevFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->prevFrame, NLATIME_CONVERT_UNMAP); pso->nextFrameF = BKE_nla_tweakedit_remap(pso->ob->adt, pso->nextFrame, NLATIME_CONVERT_UNMAP); @@ -769,20 +769,20 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p pose_slide_exit(op); return OPERATOR_CANCELLED; } - + /* initial apply for operator... */ /* TODO: need to calculate percentage for initial round too... */ pose_slide_apply(C, pso); - + /* depsgraph updates + redraws */ pose_slide_refresh(C, pso); - + /* set cursor to indicate modal */ WM_cursor_modal_set(win, BC_EW_SCROLLCURSOR); - + /* header print */ pose_slide_draw_status(pso); - + /* add a modal handler for this operator */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -810,8 +810,8 @@ static void pose_slide_toggle_channels_mode(wmOperator *op, tPoseSlideOp *pso, e pso->channels = channel; } RNA_enum_set(op->ptr, "channels", pso->channels); - - + + /* Reset axis limits too for good measure */ pso->axislock = 0; RNA_enum_set(op->ptr, "axis_lock", pso->axislock); @@ -826,7 +826,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos RNA_enum_set(op->ptr, "axis_lock", pso->axislock); return false; } - + /* Turn on or off? */ if (pso->axislock == axis) { /* Already limiting on this axis, so turn off */ @@ -837,7 +837,7 @@ static bool pose_slide_toggle_axis_locks(wmOperator *op, tPoseSlideOp *pso, ePos pso->axislock = axis; } RNA_enum_set(op->ptr, "axis_lock", pso->axislock); - + /* Setting changed, so pose update is needed */ return true; } @@ -848,9 +848,9 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) tPoseSlideOp *pso = op->customdata; wmWindow *win = CTX_wm_window(C); bool do_pose_update = false; - + const bool has_numinput = hasNumInput(&pso->num); - + switch (event->type) { case LEFTMOUSE: /* confirm */ case RETKEY: @@ -859,35 +859,35 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) /* return to normal cursor and header status */ ED_area_headerprint(pso->sa, NULL); WM_cursor_modal_restore(win); - + /* insert keyframes as required... */ pose_slide_autoKeyframe(C, pso); pose_slide_exit(op); - + /* done! */ return OPERATOR_FINISHED; } - + case ESCKEY: /* cancel */ - case RIGHTMOUSE: + case RIGHTMOUSE: { /* return to normal cursor and header status */ ED_area_headerprint(pso->sa, NULL); WM_cursor_modal_restore(win); - + /* reset transforms back to original state */ pose_slide_reset(pso); - + /* depsgraph updates + redraws */ pose_slide_refresh(C, pso); - + /* clean up temp data */ pose_slide_exit(op); - + /* canceled! */ return OPERATOR_CANCELLED; } - + /* Percentage Chane... */ case MOUSEMOVE: /* calculate new position */ { @@ -895,7 +895,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) if (has_numinput == false) { /* update percentage based on position of mouse */ pose_slide_mouse_update_percentage(pso, op, event); - + /* update pose to reflect the new values (see below) */ do_pose_update = true; } @@ -905,17 +905,17 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) { if ((event->val == KM_PRESS) && handleNumInput(C, &pso->num, event)) { float value; - - /* Grab percentage from numeric input, and store this new value for redo + + /* Grab percentage from numeric input, and store this new value for redo * NOTE: users see ints, while internally we use a 0-1 float */ value = pso->percentage * 100.0f; applyNumInput(&pso->num, &value); - + pso->percentage = value / 100.0f; CLAMP(pso->percentage, 0.0f, 1.0f); RNA_float_set(op->ptr, "percentage", pso->percentage); - + /* Update pose to reflect the new values (see below) */ do_pose_update = true; break; @@ -954,8 +954,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) do_pose_update = true; break; } - - + + /* Axis Locks */ /* XXX: Hardcoded... */ case XKEY: @@ -979,8 +979,8 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) } break; } - - + + default: /* Some other unhandled key... */ break; } @@ -992,20 +992,20 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) } } } - - + + /* perform pose updates - in response to some user action (e.g. pressing a key or moving the mouse) */ if (do_pose_update) { /* update percentage indicator in header */ pose_slide_draw_status(pso); - + /* reset transforms (to avoid accumulation errors) */ pose_slide_reset(pso); - + /* apply... */ pose_slide_apply(C, pso); } - + /* still running... */ return OPERATOR_RUNNING_MODAL; } @@ -1022,13 +1022,13 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso { /* settings should have been set up ok for applying, so just apply! */ pose_slide_apply(C, pso); - + /* insert keyframes if needed */ pose_slide_autoKeyframe(C, pso); - + /* cleanup and done */ pose_slide_exit(op); - + return OPERATOR_FINISHED; } @@ -1037,10 +1037,10 @@ static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso static void pose_slide_opdef_properties(wmOperatorType *ot) { RNA_def_float_percentage(ot->srna, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Weighting factor for which keyframe is favored more", 0.3, 0.7); - + RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame", 0, 50); RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame", 0, 50); - + RNA_def_enum(ot->srna, "channels", prop_channels_types, PS_TFM_ALL, "Channels", "Set of properties that are affected"); RNA_def_enum(ot->srna, "axis_lock", prop_axis_lock_types, 0, "Axis Lock", "Transform axis to restrict effects to"); } @@ -1051,7 +1051,7 @@ static void pose_slide_opdef_properties(wmOperatorType *ot) static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tPoseSlideOp *pso; - + /* initialize data */ if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) { pose_slide_exit(op); @@ -1059,10 +1059,10 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev } else pso = op->customdata; - + /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); - + /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } @@ -1071,7 +1071,7 @@ static int pose_slide_push_invoke(bContext *C, wmOperator *op, const wmEvent *ev static int pose_slide_push_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; - + /* initialize data (from RNA-props) */ if (pose_slide_init(C, op, POSESLIDE_PUSH) == 0) { pose_slide_exit(op); @@ -1079,7 +1079,7 @@ static int pose_slide_push_exec(bContext *C, wmOperator *op) } else pso = op->customdata; - + /* do common exec work */ return pose_slide_exec_common(C, op, pso); } @@ -1090,17 +1090,17 @@ void POSE_OT_push(wmOperatorType *ot) ot->name = "Push Pose"; ot->idname = "POSE_OT_push"; ot->description = "Exaggerate the current pose"; - + /* callbacks */ ot->exec = pose_slide_push_exec; ot->invoke = pose_slide_push_invoke; ot->modal = pose_slide_modal; ot->cancel = pose_slide_cancel; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; - + /* Properties */ pose_slide_opdef_properties(ot); } @@ -1111,7 +1111,7 @@ void POSE_OT_push(wmOperatorType *ot) static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tPoseSlideOp *pso; - + /* initialize data */ if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) { pose_slide_exit(op); @@ -1119,10 +1119,10 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e } else pso = op->customdata; - + /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); - + /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } @@ -1131,7 +1131,7 @@ static int pose_slide_relax_invoke(bContext *C, wmOperator *op, const wmEvent *e static int pose_slide_relax_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; - + /* initialize data (from RNA-props) */ if (pose_slide_init(C, op, POSESLIDE_RELAX) == 0) { pose_slide_exit(op); @@ -1139,7 +1139,7 @@ static int pose_slide_relax_exec(bContext *C, wmOperator *op) } else pso = op->customdata; - + /* do common exec work */ return pose_slide_exec_common(C, op, pso); } @@ -1150,17 +1150,17 @@ void POSE_OT_relax(wmOperatorType *ot) ot->name = "Relax Pose"; ot->idname = "POSE_OT_relax"; ot->description = "Make the current pose more similar to its surrounding ones"; - + /* callbacks */ ot->exec = pose_slide_relax_exec; ot->invoke = pose_slide_relax_invoke; ot->modal = pose_slide_modal; ot->cancel = pose_slide_cancel; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; - + /* Properties */ pose_slide_opdef_properties(ot); } @@ -1171,7 +1171,7 @@ void POSE_OT_relax(wmOperatorType *ot) static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tPoseSlideOp *pso; - + /* initialize data */ if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) { pose_slide_exit(op); @@ -1179,10 +1179,10 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven } else pso = op->customdata; - + /* initialise percentage so that it won't pop on first mouse move */ pose_slide_mouse_update_percentage(pso, op, event); - + /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } @@ -1191,7 +1191,7 @@ static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, const wmEven static int pose_slide_breakdown_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; - + /* initialize data (from RNA-props) */ if (pose_slide_init(C, op, POSESLIDE_BREAKDOWN) == 0) { pose_slide_exit(op); @@ -1199,7 +1199,7 @@ static int pose_slide_breakdown_exec(bContext *C, wmOperator *op) } else pso = op->customdata; - + /* do common exec work */ return pose_slide_exec_common(C, op, pso); } @@ -1210,17 +1210,17 @@ void POSE_OT_breakdown(wmOperatorType *ot) ot->name = "Pose Breakdowner"; ot->idname = "POSE_OT_breakdown"; ot->description = "Create a suitable breakdown pose on the current frame"; - + /* callbacks */ ot->exec = pose_slide_breakdown_exec; ot->invoke = pose_slide_breakdown_invoke; ot->modal = pose_slide_modal; ot->cancel = pose_slide_cancel; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; - + /* Properties */ pose_slide_opdef_properties(ot); } @@ -1240,7 +1240,7 @@ typedef enum ePosePropagate_Termination { POSE_PROPAGATE_BEFORE_FRAME, /* stop when we run out of keyframes */ POSE_PROPAGATE_BEFORE_END, - + /* only do on keyframes that are selected */ POSE_PROPAGATE_SELECTED_KEYS, /* only do on the frames where markers are selected */ @@ -1251,14 +1251,14 @@ typedef enum ePosePropagate_Termination { typedef union tPosePropagate_ModeData { /* smart holds + before frame: frame number to stop on */ float end_frame; - + /* selected markers: listbase for CfraElem's marking these frames */ ListBase sel_markers; } tPosePropagate_ModeData; /* --------------------------------- */ -/* get frame on which the "hold" for the bone ends +/* get frame on which the "hold" for the bone ends * XXX: this may not really work that well if a bone moves on some channels and not others * if this happens to be a major issue, scrap this, and just make this happen * independently per F-Curve @@ -1267,47 +1267,47 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p { DLRBT_Tree keys, blocks; ActKeyBlock *ab; - + AnimData *adt = ob->adt; LinkData *ld; float endFrame = startFrame; - + /* set up optimized data-structures for searching for relevant keyframes + holds */ BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - + for (ld = pfl->fcurves.first; ld; ld = ld->next) { FCurve *fcu = (FCurve *)ld->data; fcurve_to_keylist(adt, fcu, &keys, &blocks); } - + BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - - /* find the long keyframe (i.e. hold), and hence obtain the endFrame value + + /* find the long keyframe (i.e. hold), and hence obtain the endFrame value * - the best case would be one that starts on the frame itself */ ab = (ActKeyBlock *)BLI_dlrbTree_search_exact(&blocks, compare_ab_cfraPtr, &startFrame); - + if (actkeyblock_is_valid(ab, &keys) == 0) { /* There are only two cases for no-exact match: * 1) the current frame is just before another key but not on a key itself * 2) the current frame is on a key, but that key doesn't link to the next * - * If we've got the first case, then we can search for another block, + * If we've got the first case, then we can search for another block, * otherwise forget it, as we'd be overwriting some valid data. */ if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &startFrame) == NULL) { /* we've got case 1, so try the one after */ ab = (ActKeyBlock *)BLI_dlrbTree_search_next(&blocks, compare_ab_cfraPtr, &startFrame); - + if (actkeyblock_is_valid(ab, &keys) == 0) { /* try the block before this frame then as last resort */ ab = (ActKeyBlock *)BLI_dlrbTree_search_prev(&blocks, compare_ab_cfraPtr, &startFrame); - + /* whatever happens, stop searching now... */ if (actkeyblock_is_valid(ab, &keys) == 0) { - /* restrict range to just the frame itself + /* restrict range to just the frame itself * i.e. everything is in motion, so no holds to safely overwrite */ ab = NULL; @@ -1319,13 +1319,13 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p ab = NULL; } } - + /* check if we can go any further than we've already gone */ if (ab) { /* go to next if it is also valid and meets "extension" criteria */ while (ab->next) { ActKeyBlock *abn = (ActKeyBlock *)ab->next; - + /* must be valid */ if (actkeyblock_is_valid(abn, &keys) == 0) break; @@ -1335,24 +1335,24 @@ static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *p /* should have the same number of curves */ if (ab->totcurve != abn->totcurve) break; - /* should have the same value + /* should have the same value * XXX: this may be a bit fuzzy on larger data sets, so be careful */ if (ab->val != abn->val) break; - + /* we can extend the bounds to the end of this "next" block now */ ab = abn; } - + /* end frame can now take the value of the end of the block */ endFrame = ab->end; } - + /* free temp memory */ BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); - + /* return the end frame we've found */ return endFrame; } @@ -1363,10 +1363,10 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value) PointerRNA id_ptr, ptr; PropertyRNA *prop; bool found = false; - + /* base pointer is always the object -> id_ptr */ RNA_id_pointer_create(&ob->id, &id_ptr); - + /* resolve the property... */ if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &ptr, &prop)) { if (RNA_property_array_check(prop)) { @@ -1411,7 +1411,7 @@ static bool pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value) } } } - + return found; } @@ -1420,25 +1420,25 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, float startFrame, tPosePropagate_ModeData modeData) { const int mode = RNA_enum_get(op->ptr, "mode"); - + BezTriple *bezt; float refVal = 0.0f; bool keyExists; int i, match; short first = 1; - + /* skip if no keyframes to edit */ if ((fcu->bezt == NULL) || (fcu->totvert < 2)) return; - + /* find the reference value from bones directly, which means that the user - * doesn't need to firstly keyframe the pose (though this doesn't mean that + * doesn't need to firstly keyframe the pose (though this doesn't mean that * they can't either) */ if (!pose_propagate_get_refVal(ob, fcu, &refVal)) return; - - /* find the first keyframe to start propagating from + + /* find the first keyframe to start propagating from * - if there's a keyframe on the current frame, we probably want to save this value there too * since it may be as of yet unkeyed * - if starting before the starting frame, don't touch the key, as it may have had some valid @@ -1447,7 +1447,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, */ if (mode != POSE_PROPAGATE_SELECTED_KEYS) { match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists); - + if (fcu->bezt[match].vec[1][0] < startFrame) i = match + 1; else @@ -1457,13 +1457,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, /* selected - start from first keyframe */ i = 0; } - + for (bezt = &fcu->bezt[i]; i < fcu->totvert; i++, bezt++) { /* additional termination conditions based on the operator 'mode' property go here... */ if (ELEM(mode, POSE_PROPAGATE_BEFORE_FRAME, POSE_PROPAGATE_SMART_HOLDS)) { /* stop if keyframe is outside the accepted range */ if (bezt->vec[1][0] > modeData.end_frame) - break; + break; } else if (mode == POSE_PROPAGATE_NEXT_KEY) { /* stop after the first keyframe has been processed */ @@ -1478,13 +1478,13 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) { /* only allow if there's a marker on this frame */ CfraElem *ce = NULL; - + /* stop on matching marker if there is one */ for (ce = modeData.sel_markers.first; ce; ce = ce->next) { if (ce->cfra == round_fl_to_int(bezt->vec[1][0])) break; } - + /* skip this keyframe if no marker */ if (ce == NULL) continue; @@ -1494,11 +1494,11 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, if (BEZT_ISSEL_ANY(bezt) == 0) continue; } - + /* just flatten handles, since values will now be the same either side... */ /* TODO: perhaps a fade-out modulation of the value is required here (optional once again)? */ bezt->vec[0][1] = bezt->vec[1][1] = bezt->vec[2][1] = refVal; - + /* select keyframe to indicate that it's been changed */ bezt->f2 |= SELECT; first = 0; @@ -1512,13 +1512,13 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bAction *act = (ob && ob->adt) ? ob->adt->action : NULL; - + ListBase pflinks = {NULL, NULL}; tPChanFCurveLink *pfl; - + tPosePropagate_ModeData modeData; const int mode = RNA_enum_get(op->ptr, "mode"); - + /* sanity checks */ if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No object to propagate poses for"); @@ -1528,10 +1528,10 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No keyframed poses to propagate to"); return OPERATOR_CANCELLED; } - + /* isolate F-Curves related to the selected bones */ poseAnim_mapping_get(C, &pflinks, ob, act); - + /* mode-specific data preprocessing (requiring no access to curves) */ if (mode == POSE_PROPAGATE_SELECTED_MARKERS) { /* get a list of selected markers */ @@ -1541,11 +1541,11 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) /* assume everything else wants endFrame */ modeData.end_frame = RNA_float_get(op->ptr, "end_frame"); } - + /* for each bone, perform the copying required */ for (pfl = pflinks.first; pfl; pfl = pfl->next) { LinkData *ld; - + /* mode-specific data preprocessing (requiring access to all curves) */ if (mode == POSE_PROPAGATE_SMART_HOLDS) { /* we store in endFrame the end frame of the "long keyframe" (i.e. a held value) starting @@ -1553,21 +1553,21 @@ static int pose_propagate_exec(bContext *C, wmOperator *op) */ modeData.end_frame = pose_propagate_get_boneHoldEndFrame(ob, pfl, (float)CFRA); } - + /* go through propagating pose to keyframes, curve by curve */ for (ld = pfl->fcurves.first; ld; ld = ld->next) pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData); } - + /* free temp data */ poseAnim_mapping_free(&pflinks); - + if (mode == POSE_PROPAGATE_SELECTED_MARKERS) BLI_freelistN(&modeData.sel_markers); - + /* updates + notifiers */ poseAnim_mapping_refresh(C, scene, ob); - + return OPERATOR_FINISHED; } @@ -1591,19 +1591,19 @@ void POSE_OT_propagate(wmOperatorType *ot) {POSE_PROPAGATE_SELECTED_MARKERS, "SELECTED_MARKERS", 0, "On Selected Markers", "Propagate pose to all keyframes occurring on frames with Scene Markers after the current frame"}, {0, NULL, 0, NULL, NULL}}; - + /* identifiers */ ot->name = "Propagate Pose"; ot->idname = "POSE_OT_propagate"; ot->description = "Copy selected aspects of the current pose to subsequent poses already keyframed"; - + /* callbacks */ ot->exec = pose_propagate_exec; ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */ - + /* flag */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ /* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */ ot->prop = RNA_def_enum(ot->srna, "mode", terminate_items, POSE_PROPAGATE_SMART_HOLDS, "Terminate Mode", "Method used to determine when to stop propagating pose to keyframes"); diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 446bab00b70..1fc623eb6af 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -73,16 +73,16 @@ static void applyarmature_fix_boneparents(Scene *scene, Object *armob) { Object workob, *ob; - + /* go through all objects in database */ for (ob = G.main->object.first; ob; ob = ob->id.next) { /* if parent is bone in this armature, apply corrections */ if ((ob->parent == armob) && (ob->partype == PARBONE)) { - /* apply current transform from parent (not yet destroyed), + /* apply current transform from parent (not yet destroyed), * then calculate new parent inverse matrix */ BKE_object_apply_mat4(ob, ob->obmat, false, false); - + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } @@ -98,7 +98,7 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) bPose *pose; bPoseChannel *pchan; EditBone *curbone; - + /* don't check if editmode (should be done by caller) */ if (ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; @@ -116,17 +116,17 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) /* Get editbones of active armature to alter */ ED_armature_to_edit(arm); - + /* get pose of active object and move it out of posemode */ pose = ob->pose; - + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { curbone = ED_armature_ebone_find_name(arm->edbo, pchan->name); - + /* simply copy the head/tail values from pchan over to curbone */ copy_v3_v3(curbone->head, pchan->pose_head); copy_v3_v3(curbone->tail, pchan->pose_tail); - + /* fix roll: * 1. find auto-calculated roll value for this bone now * 2. remove this from the 'visual' y-rotation @@ -134,23 +134,23 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) { float premat[3][3], imat[3][3], pmat[3][3], tmat[3][3]; float delta[3], eul[3]; - + /* obtain new auto y-rotation */ sub_v3_v3v3(delta, curbone->tail, curbone->head); vec_roll_to_mat3(delta, 0.0f, premat); invert_m3_m3(imat, premat); - + /* get pchan 'visual' matrix */ copy_m3_m4(pmat, pchan->pose_mat); - + /* remove auto from visual and get euler rotation */ mul_m3_m3m3(tmat, imat, pmat); mat3_to_eul(eul, tmat); - + /* just use this euler-y as new roll value */ curbone->roll = eul[1]; } - + /* combine pose and rest values for bendy bone settings, * then clear the pchan values (so we don't get a double-up) */ @@ -165,38 +165,38 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) curbone->ease2 += pchan->ease2; curbone->scaleIn += pchan->scaleIn; curbone->scaleOut += pchan->scaleOut; - + pchan->curveInX = pchan->curveOutX = 0.0f; pchan->curveInY = pchan->curveOutY = 0.0f; pchan->roll1 = pchan->roll2 = 0.0f; pchan->ease1 = pchan->ease2 = 0.0f; pchan->scaleIn = pchan->scaleOut = 1.0f; } - + /* clear transform values for pchan */ zero_v3(pchan->loc); zero_v3(pchan->eul); unit_qt(pchan->quat); unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f; - + /* set anim lock */ curbone->flag |= BONE_UNKEYED; } - + /* convert editbones back to bones, and then free the edit-data */ ED_armature_from_edit(arm); ED_armature_edit_free(arm); - + /* flush positions of posebones */ BKE_pose_where_is(scene, ob); - + /* fix parenting of objects which are bone-parented */ applyarmature_fix_boneparents(scene, ob); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); - + return OPERATOR_FINISHED; } @@ -206,11 +206,11 @@ void POSE_OT_armature_apply(wmOperatorType *ot) ot->name = "Apply Pose as Rest Pose"; ot->idname = "POSE_OT_armature_apply"; ot->description = "Apply the current pose as the new rest pose"; - + /* callbacks */ ot->exec = apply_armature_pose2bones_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -232,21 +232,21 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) { float delta_mat[4][4]; - + /* chan_mat already contains the delta transform from rest pose to pose-mode pose * as that is baked into there so that B-Bones will work. Once we've set this as the - * new raw-transform components, don't recalc the poses yet, otherwise IK result will + * new raw-transform components, don't recalc the poses yet, otherwise IK result will * change, thus changing the result we may be trying to record. */ /* XXX For some reason, we can't use pchan->chan_mat here, gives odd rotation/offset (see T38251). * Using pchan->pose_mat and bringing it back in bone space seems to work as expected! */ BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, delta_mat); - + BKE_pchan_apply_mat4(pchan, delta_mat, true); } CTX_DATA_END; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ @@ -261,11 +261,11 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot) ot->name = "Apply Visual Transform to Pose"; ot->idname = "POSE_OT_visual_transform_apply"; ot->description = "Apply final constrained position of pose bones to their transform"; - + /* callbacks */ ot->exec = pose_visual_transform_apply_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -273,7 +273,7 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot) /* ********************************************** */ /* Copy/Paste */ -/* This function is used to indicate that a bone is selected +/* This function is used to indicate that a bone is selected * and needs to be included in copy buffer (used to be for inserting keys) */ static void set_pose_keys(Object *ob) @@ -306,33 +306,33 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo bPoseChannel *pchan; char name[MAXBONENAME]; short paste_ok; - + /* get the name - if flipping, we must flip this first */ if (flip) BLI_string_flip_side_name(name, chan->name, false, sizeof(name)); else BLI_strncpy(name, chan->name, sizeof(name)); - + /* only copy when: * 1) channel exists - poses are not meant to add random channels to anymore * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical */ pchan = BKE_pose_channel_find_name(ob->pose, name); - + if (selOnly) paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED)); else paste_ok = (pchan != NULL); - + /* continue? */ if (paste_ok) { - /* only loc rot size - * - only copies transform info for the pose + /* only loc rot size + * - only copies transform info for the pose */ copy_v3_v3(pchan->loc, chan->loc); copy_v3_v3(pchan->size, chan->size); pchan->flag = chan->flag; - + /* check if rotation modes are compatible (i.e. do they need any conversions) */ if (pchan->rotmode == chan->rotmode) { /* copy the type of rotation in use */ @@ -368,29 +368,29 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo else axis_angle_to_quat(pchan->quat, chan->rotAxis, pchan->rotAngle); } - + /* B-Bone posing options should also be included... */ pchan->curveInX = chan->curveInX; pchan->curveInY = chan->curveInY; pchan->curveOutX = chan->curveOutX; pchan->curveOutY = chan->curveOutY; - + pchan->roll1 = chan->roll1; pchan->roll2 = chan->roll2; pchan->ease1 = chan->ease1; pchan->ease2 = chan->ease2; pchan->scaleIn = chan->scaleIn; pchan->scaleOut = chan->scaleOut; - + /* paste flipped pose? */ if (flip) { pchan->loc[0] *= -1; - + pchan->curveInX *= -1; pchan->curveOutX *= -1; pchan->roll1 *= -1; // XXX? pchan->roll2 *= -1; // XXX? - + /* has to be done as eulers... */ if (pchan->rotmode > 0) { pchan->eul[1] *= -1; @@ -398,7 +398,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { float eul[3]; - + axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle); eul[1] *= -1; eul[2] *= -1; @@ -406,7 +406,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo } else { float eul[3]; - + normalize_qt(pchan->quat); quat_to_eul(eul, pchan->quat); eul[1] *= -1; @@ -414,12 +414,12 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo eul_to_quat(pchan->quat, eul); } } - + /* ID properties */ if (chan->prop) { if (pchan->prop) { - /* if we have existing properties on a bone, just copy over the values of - * matching properties (i.e. ones which will have some impact) on to the + /* if we have existing properties on a bone, just copy over the values of + * matching properties (i.e. ones which will have some impact) on to the * target instead of just blinding replacing all [ */ IDP_SyncGroupValues(pchan->prop, chan->prop); @@ -430,7 +430,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, const bo } } } - + /* return whether paste went ahead */ return pchan; } @@ -488,11 +488,11 @@ void POSE_OT_copy(wmOperatorType *ot) ot->name = "Copy Pose"; ot->idname = "POSE_OT_copy"; ot->description = "Copies the current pose of the selected bones to copy/paste buffer"; - + /* api callbacks */ ot->exec = pose_copy_exec; ot->poll = ED_operator_posemode; - + /* flag */ ot->flag = OPTYPE_REGISTER; } @@ -506,15 +506,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op) bPoseChannel *chan; const bool flip = RNA_boolean_get(op->ptr, "flipped"); bool selOnly = RNA_boolean_get(op->ptr, "selected_mask"); - + /* Get KeyingSet to use. */ KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); - + /* Sanity checks. */ if (ELEM(NULL, ob, ob->pose)) { return OPERATOR_CANCELLED; } - + /* Read copy buffer .blend file. */ char str[FILE_MAX]; Main *tmp_bmain = BKE_main_new(); @@ -530,7 +530,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op) BKE_main_free(tmp_bmain); return OPERATOR_CANCELLED; } - + Object *object_from = tmp_bmain->object.first; bPose *pose_from = object_from->pose; if (pose_from == NULL) { @@ -538,7 +538,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op) BKE_main_free(tmp_bmain); return OPERATOR_CANCELLED; } - + /* If selOnly option is enabled, if user hasn't selected any bones, * just go back to default behavior to be more in line with other * pose tools. @@ -548,7 +548,7 @@ static int pose_paste_exec(bContext *C, wmOperator *op) selOnly = false; } } - + /* Safely merge all of the channels in the buffer pose into any * existing pose. */ @@ -563,15 +563,15 @@ static int pose_paste_exec(bContext *C, wmOperator *op) } } BKE_main_free(tmp_bmain); - + /* Update event for pose and deformation children. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - + /* Recalculate paths if any of the bones have paths... */ if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) { ED_pose_recalculate_paths(scene, ob); } - + /* Notifiers for updates, */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); @@ -586,14 +586,14 @@ void POSE_OT_paste(wmOperatorType *ot) ot->name = "Paste Pose"; ot->idname = "POSE_OT_paste"; ot->description = "Paste the stored pose on to the current pose"; - + /* api callbacks */ ot->exec = pose_paste_exec; ot->poll = ED_operator_posemode; - + /* flag */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_boolean(ot->srna, "flipped", false, "Flipped on X-Axis", "Paste the stored pose flipped on to current pose"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -613,9 +613,9 @@ static void pchan_clear_scale(bPoseChannel *pchan) pchan->size[1] = 1.0f; if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0) pchan->size[2] = 1.0f; - + pchan->ease1 = 0.0f; - pchan->ease2 = 0.0f; + pchan->ease2 = 0.0f; pchan->scaleIn = 1.0f; pchan->scaleOut = 1.0f; } @@ -647,7 +647,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) pchan->rotAxis[1] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) pchan->rotAxis[2] = 0.0f; - + /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2])) pchan->rotAxis[1] = 1.0f; @@ -676,7 +676,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) /* perform clamping using euler form (3-components) */ float eul[3], oldeul[3], quat1[4] = {0}; float qlen = 0.0f; - + if (pchan->rotmode == ROT_MODE_QUAT) { qlen = normalize_qt_qt(quat1, pchan->quat); quat_to_eul(oldeul, quat1); @@ -687,22 +687,22 @@ static void pchan_clear_rot(bPoseChannel *pchan) else { copy_v3_v3(oldeul, pchan->eul); } - + eul[0] = eul[1] = eul[2] = 0.0f; - + if (pchan->protectflag & OB_LOCK_ROTX) eul[0] = oldeul[0]; if (pchan->protectflag & OB_LOCK_ROTY) eul[1] = oldeul[1]; if (pchan->protectflag & OB_LOCK_ROTZ) eul[2] = oldeul[2]; - + if (pchan->rotmode == ROT_MODE_QUAT) { eul_to_quat(pchan->quat, eul); - + /* restore original quat size */ mul_qt_fl(pchan->quat, qlen); - + /* quaternions flip w sign to accumulate rotations correctly */ if ((quat1[0] < 0.0f && pchan->quat[0] > 0.0f) || (quat1[0] > 0.0f && pchan->quat[0] < 0.0f)) { mul_qt_fl(pchan->quat, -1.0f); @@ -728,11 +728,11 @@ static void pchan_clear_rot(bPoseChannel *pchan) zero_v3(pchan->eul); } } - + /* Clear also Bendy Bone stuff - Roll is obvious, but Curve X/Y stuff is also kindof rotational in nature... */ pchan->roll1 = 0.0f; pchan->roll2 = 0.0f; - + pchan->curveInX = 0.0f; pchan->curveInY = 0.0f; pchan->curveOutX = 0.0f; @@ -750,25 +750,25 @@ static void pchan_clear_transforms(bPoseChannel *pchan) /* --------------- */ /* generic exec for clear-pose operators */ -static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, +static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, void (*clear_func)(bPoseChannel *), const char default_ksName[]) { Scene *scene = CTX_data_scene(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); short autokey = 0; - + /* sanity checks */ if (ELEM(NULL, clear_func, default_ksName)) { BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name"); return OPERATOR_CANCELLED; } - + /* only clear relevant transforms for selected bones */ CTX_DATA_BEGIN(C, bPoseChannel *, pchan, selected_pose_bones) { /* run provided clearing function */ clear_func(pchan); - + /* do auto-keyframing as appropriate */ if (autokeyframe_cfra_can_key(scene, &ob->id)) { /* clear any unkeyed tags */ @@ -785,31 +785,31 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, } } CTX_DATA_END; - + /* perform autokeying on the bones if needed */ if (autokey) { /* get KeyingSet to use */ KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName); - + /* insert keyframes */ ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, (float)CFRA); - + /* now recalculate paths */ if ((ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) ED_pose_recalculate_paths(scene, ob); } - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); - + return OPERATOR_FINISHED; } /* --------------- */ -static int pose_clear_scale_exec(bContext *C, wmOperator *op) +static int pose_clear_scale_exec(bContext *C, wmOperator *op) { return pose_clear_transform_generic_exec(C, op, pchan_clear_scale, ANIM_KS_SCALING_ID); } @@ -820,17 +820,17 @@ void POSE_OT_scale_clear(wmOperatorType *ot) ot->name = "Clear Pose Scale"; ot->idname = "POSE_OT_scale_clear"; ot->description = "Reset scaling of selected bones to their default values"; - + /* api callbacks */ ot->exec = pose_clear_scale_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_clear_rot_exec(bContext *C, wmOperator *op) +static int pose_clear_rot_exec(bContext *C, wmOperator *op) { return pose_clear_transform_generic_exec(C, op, pchan_clear_rot, ANIM_KS_ROTATION_ID); } @@ -841,17 +841,17 @@ void POSE_OT_rot_clear(wmOperatorType *ot) ot->name = "Clear Pose Rotation"; ot->idname = "POSE_OT_rot_clear"; ot->description = "Reset rotations of selected bones to their default values"; - + /* api callbacks */ ot->exec = pose_clear_rot_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_clear_loc_exec(bContext *C, wmOperator *op) +static int pose_clear_loc_exec(bContext *C, wmOperator *op) { return pose_clear_transform_generic_exec(C, op, pchan_clear_loc, ANIM_KS_LOCATION_ID); } @@ -862,17 +862,17 @@ void POSE_OT_loc_clear(wmOperatorType *ot) ot->name = "Clear Pose Location"; ot->idname = "POSE_OT_loc_clear"; ot->description = "Reset locations of selected bones to their default values"; - + /* api callbacks */ ot->exec = pose_clear_loc_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_clear_transforms_exec(bContext *C, wmOperator *op) +static int pose_clear_transforms_exec(bContext *C, wmOperator *op) { return pose_clear_transform_generic_exec(C, op, pchan_clear_transforms, ANIM_KS_LOC_ROT_SCALE_ID); } @@ -883,11 +883,11 @@ void POSE_OT_transforms_clear(wmOperatorType *ot) ot->name = "Clear Pose Transforms"; ot->idname = "POSE_OT_transforms_clear"; ot->description = "Reset location, rotation, and scaling of selected bones to their default values"; - + /* api callbacks */ ot->exec = pose_clear_transforms_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -901,31 +901,31 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); float cframe = (float)CFRA; const bool only_select = RNA_boolean_get(op->ptr, "only_selected"); - + if ((ob->adt) && (ob->adt->action)) { - /* XXX: this is just like this to avoid contaminating anything else; - * just pose values should change, so this should be fine + /* XXX: this is just like this to avoid contaminating anything else; + * just pose values should change, so this should be fine */ bPose *dummyPose = NULL; Object workob = {{NULL}}; bPoseChannel *pchan; - + /* execute animation step for current frame using a dummy copy of the pose */ BKE_pose_copy_data(&dummyPose, ob->pose, 0); - + BLI_strncpy(workob.id.name, "OB", sizeof(workob.id.name)); workob.type = OB_ARMATURE; workob.data = ob->data; workob.adt = ob->adt; workob.pose = dummyPose; - + BKE_animsys_evaluate_animdata(scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM); - + /* copy back values, but on selected bones only */ for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { pose_bone_do_paste(ob, pchan, only_select, 0); } - + /* free temp data - free manually as was copied without constraints */ for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->prop) { @@ -933,22 +933,22 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) MEM_freeN(pchan->prop); } } - + /* was copied without constraints */ BLI_freelistN(&dummyPose->chanbase); MEM_freeN(dummyPose); } else { - /* no animation, so just reset whole pose to rest pose + /* no animation, so just reset whole pose to rest pose * (cannot just restore for selected though) */ BKE_pose_rest(ob->pose); } - + /* notifiers and updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); - + return OPERATOR_FINISHED; } @@ -958,11 +958,11 @@ void POSE_OT_user_transforms_clear(wmOperatorType *ot) ot->name = "Clear User Transforms"; ot->idname = "POSE_OT_user_transforms_clear"; ot->description = "Reset pose on selected bones to keyframed state"; - + /* callbacks */ ot->exec = pose_clear_user_transforms_exec; ot->poll = ED_operator_posemode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/armature/pose_utils.c b/source/blender/editors/armature/pose_utils.c index 93d00addd02..84eaa5b02bd 100644 --- a/source/blender/editors/armature/pose_utils.c +++ b/source/blender/editors/armature/pose_utils.c @@ -62,7 +62,7 @@ * convenience functions, such as applying/getting pose values * and/or inserting keyframes for these. */ -/* *********************************************** */ +/* *********************************************** */ /* FCurves <-> PoseChannels Links */ /* helper for poseAnim_mapping_get() -> get the relevant F-Curves per PoseChannel */ @@ -70,25 +70,25 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a { ListBase curves = {NULL, NULL}; int transFlags = action_get_item_transforms(act, ob, pchan, &curves); - + pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE | POSE_BBONE_SHAPE); - + /* check if any transforms found... */ if (transFlags) { /* make new linkage data */ tPChanFCurveLink *pfl = MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink"); PointerRNA ptr; - + pfl->fcurves = curves; pfl->pchan = pchan; - + /* get the RNA path to this pchan - this needs to be freed! */ RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr); pfl->pchan_path = RNA_path_from_ID_to_struct(&ptr); - + /* add linkage data to operator data */ BLI_addtail(pfLinks, pfl); - + /* set pchan's transform flags */ if (transFlags & ACT_TRANS_LOC) pchan->flag |= POSE_LOC; @@ -98,7 +98,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a pchan->flag |= POSE_SIZE; if (transFlags & ACT_TRANS_BBONE) pchan->flag |= POSE_BBONE_SHAPE; - + /* store current transforms */ copy_v3_v3(pfl->oldloc, pchan->loc); copy_v3_v3(pfl->oldrot, pchan->eul); @@ -106,7 +106,7 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a copy_qt_qt(pfl->oldquat, pchan->quat); copy_v3_v3(pfl->oldaxis, pchan->rotAxis); pfl->oldangle = pchan->rotAngle; - + /* store current bbone values */ pfl->roll1 = pchan->roll1; pfl->roll2 = pchan->roll2; @@ -118,18 +118,18 @@ static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *a pfl->ease2 = pchan->ease2; pfl->scaleIn = pchan->scaleIn; pfl->scaleOut = pchan->scaleOut; - + /* make copy of custom properties */ if (pchan->prop && (transFlags & ACT_TRANS_PROP)) pfl->oldprops = IDP_CopyProperty(pchan->prop); } -} +} /* get sets of F-Curves providing transforms for the bones in the Pose */ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *act) -{ - /* for each Pose-Channel which gets affected, get the F-Curves for that channel +{ + /* for each Pose-Channel which gets affected, get the F-Curves for that channel * and set the relevant transform flags... */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -137,7 +137,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); } CTX_DATA_END; - + /* if no PoseChannels were found, try a second pass, doing visible ones instead * i.e. if nothing selected, do whole pose */ @@ -147,7 +147,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); } CTX_DATA_END; - + } } @@ -155,23 +155,23 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a void poseAnim_mapping_free(ListBase *pfLinks) { tPChanFCurveLink *pfl, *pfln = NULL; - + /* free the temp pchan links and their data */ for (pfl = pfLinks->first; pfl; pfl = pfln) { pfln = pfl->next; - + /* free custom properties */ if (pfl->oldprops) { IDP_FreeProperty(pfl->oldprops); MEM_freeN(pfl->oldprops); } - + /* free list of F-Curve reference links */ BLI_freelistN(&pfl->fcurves); - + /* free pchan RNA Path */ MEM_freeN(pfl->pchan_path); - + /* free link itself */ BLI_freelinkN(pfLinks, pfl); } @@ -183,8 +183,8 @@ void poseAnim_mapping_free(ListBase *pfLinks) void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) { bArmature *arm = (bArmature *)ob->data; - - /* old optimize trick... this enforces to bypass the depgraph + + /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ /* FIXME: shouldn't this use the builtin stuff? */ @@ -192,7 +192,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else BKE_pose_where_is(scene, ob); - + /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } @@ -201,11 +201,11 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) void poseAnim_mapping_reset(ListBase *pfLinks) { tPChanFCurveLink *pfl; - + /* iterate over each pose-channel affected, restoring all channels to their original values */ for (pfl = pfLinks->first; pfl; pfl = pfl->next) { bPoseChannel *pchan = pfl->pchan; - + /* just copy all the values over regardless of whether they changed or not */ copy_v3_v3(pchan->loc, pfl->oldloc); copy_v3_v3(pchan->eul, pfl->oldrot); @@ -213,7 +213,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks) copy_qt_qt(pchan->quat, pfl->oldquat); copy_v3_v3(pchan->rotAxis, pfl->oldaxis); pchan->rotAngle = pfl->oldangle; - + /* store current bbone values */ pchan->roll1 = pfl->roll1; pchan->roll2 = pfl->roll2; @@ -225,7 +225,7 @@ void poseAnim_mapping_reset(ListBase *pfLinks) pchan->ease2 = pfl->ease2; pchan->scaleIn = pfl->scaleIn; pchan->scaleOut = pfl->scaleOut; - + /* just overwrite values of properties from the stored copies (there should be some) */ if (pfl->oldprops) IDP_SyncGroupValues(pfl->pchan->prop, pfl->oldprops); @@ -240,26 +240,26 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); ListBase dsources = {NULL, NULL}; tPChanFCurveLink *pfl; - + /* iterate over each pose-channel affected, tagging bones to be keyed */ - /* XXX: here we already have the information about what transforms exist, though + /* XXX: here we already have the information about what transforms exist, though * it might be easier to just overwrite all using normal mechanisms */ for (pfl = pfLinks->first; pfl; pfl = pfl->next) { bPoseChannel *pchan = pfl->pchan; - + /* add datasource override for the PoseChannel, to be used later */ - ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan); - + ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan); + /* clear any unkeyed tags */ if (pchan->bone) pchan->bone->flag &= ~BONE_UNKEYED; } - + /* insert keyframes for all relevant bones in one go */ ANIM_apply_keyingset(C, &dsources, NULL, ks, MODIFYKEY_MODE_INSERT, cframe); BLI_freelistN(&dsources); - + /* do the bone paths * - only do this if keyframes should have been added * - do not calculate unless there are paths already to update... @@ -273,25 +273,25 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa /* ------------------------- */ -/* find the next F-Curve for a PoseChannel with matching path... +/* find the next F-Curve for a PoseChannel with matching path... * - path is not just the pfl rna_path, since that path doesn't have property info yet */ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path) { LinkData *first = (prev) ? prev->next : (fcuLinks) ? fcuLinks->first : NULL; LinkData *ld; - + /* check each link to see if the linked F-Curve has a matching path */ for (ld = first; ld; ld = ld->next) { FCurve *fcu = (FCurve *)ld->data; - + /* check if paths match */ if (STREQ(path, fcu->rna_path)) return ld; } - + /* none found */ return NULL; } -/* *********************************************** */ +/* *********************************************** */ diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 938e840a451..d837c702cb7 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -106,9 +106,9 @@ static VertexData *allocVertexData(EditMesh *em) VertexData *data; EditVert *eve; int totvert, index; - + totvert = BLI_listbase_count(&em->verts); - + data = MEM_callocN(sizeof(VertexData) * totvert, "VertexData"); for (index = 0, eve = em->verts.first; eve; index++, eve = eve->next) @@ -117,7 +117,7 @@ static VertexData *allocVertexData(EditMesh *em) data[index].w = 0; eve->tmp.p = data + index; } - + return data; } @@ -152,13 +152,13 @@ void REEB_freeArc(BArc *barc) { ReebArc *arc = (ReebArc *)barc; BLI_freelistN(&arc->edges); - + if (arc->buckets) MEM_freeN(arc->buckets); - + if (arc->faces) BLI_ghash_free(arc->faces, NULL, NULL); - + MEM_freeN(arc); } @@ -166,13 +166,13 @@ void REEB_freeGraph(ReebGraph *rg) { ReebArc *arc; ReebNode *node; - + // free nodes for (node = rg->nodes.first; node; node = node->next) { BLI_freeNode((BGraph *)rg, (BNode *)node); } BLI_freelistN(&rg->nodes); - + // free arcs arc = rg->arcs.first; while (arc) { @@ -180,15 +180,15 @@ void REEB_freeGraph(ReebGraph *rg) REEB_freeArc((BArc *)arc); arc = next; } - + // free edge map BLI_edgehash_free(rg->emap, NULL); - + /* free linked graph */ if (rg->link_up) { REEB_freeGraph(rg->link_up); } - + MEM_freeN(rg); } @@ -196,16 +196,16 @@ ReebGraph *newReebGraph(void) { ReebGraph *rg; rg = MEM_callocN(sizeof(ReebGraph), "reeb graph"); - + rg->totnodes = 0; rg->emap = BLI_edgehash_new(__func__); - - + + rg->free_arc = REEB_freeArc; rg->free_node = NULL; rg->radial_symmetry = REEB_RadialSymmetry; rg->axial_symmetry = REEB_AxialSymmetry; - + return rg; } @@ -221,11 +221,11 @@ static ReebNode *addNode(ReebGraph *rg, EditVert *eve) { float weight; ReebNode *node = NULL; - + weight = weightData(eve); - + node = MEM_callocN(sizeof(ReebNode), "reeb node"); - + node->flag = 0; // clear flag on init node->symmetry_level = 0; node->arcs = NULL; @@ -233,45 +233,45 @@ static ReebNode *addNode(ReebGraph *rg, EditVert *eve) node->weight = weight; node->index = rg->totnodes; copy_v3_v3(node->p, eve->co); - + BLI_addtail(&rg->nodes, node); rg->totnodes++; - + nodeSetData(eve, node); - + return node; } static ReebNode *copyNode(ReebGraph *rg, ReebNode *node) { ReebNode *cp_node = NULL; - + cp_node = MEM_callocN(sizeof(ReebNode), "reeb node copy"); - + memcpy(cp_node, node, sizeof(ReebNode)); - + cp_node->prev = NULL; cp_node->next = NULL; cp_node->arcs = NULL; - + cp_node->link_up = NULL; cp_node->link_down = NULL; - + BLI_addtail(&rg->nodes, cp_node); rg->totnodes++; - - return cp_node; + + return cp_node; } static void relinkNodes(ReebGraph *low_rg, ReebGraph *high_rg) { ReebNode *low_node, *high_node; - + if (low_rg == NULL || high_rg == NULL) { return; } - + for (low_node = low_rg->nodes.first; low_node; low_node = low_node->next) { for (high_node = high_rg->nodes.first; high_node; high_node = high_node->next) @@ -285,7 +285,7 @@ static void relinkNodes(ReebGraph *low_rg, ReebGraph *high_rg) } } } -#endif +#endif ReebNode *BIF_otherNodeFromIndex(ReebArc *arc, ReebNode *node) { @@ -302,7 +302,7 @@ ReebNode *BIF_lowestLevelNode(ReebNode *node) while (node->link_down) { node = node->link_down; } - + return node; } @@ -311,13 +311,13 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc) { ReebArc *cp_arc; ReebNode *node; - + cp_arc = MEM_callocN(sizeof(ReebArc), "reeb arc copy"); memcpy(cp_arc, arc, sizeof(ReebArc)); - + cp_arc->link_up = arc; - + cp_arc->head = NULL; cp_arc->tail = NULL; @@ -330,11 +330,11 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc) /* copy buckets */ cp_arc->buckets = MEM_callocN(sizeof(EmbedBucket) * cp_arc->bcount, "embed bucket"); memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount); - + /* copy faces map */ cp_arc->faces = BLI_ghash_ptr_new("copyArc gh"); mergeArcFaces(rg, cp_arc, arc); - + /* find corresponding head and tail */ for (node = rg->nodes.first; node && (cp_arc->head == NULL || cp_arc->tail == NULL); node = node->next) { @@ -347,9 +347,9 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc) cp_arc->tail = node; } } - + BLI_addtail(&rg->arcs, cp_arc); - + return cp_arc; } @@ -358,7 +358,7 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level) ReebNode *node; ReebArc *arc; ReebGraph *cp_rg = newReebGraph(); - + cp_rg->resolution = rg->resolution; cp_rg->length = rg->length; cp_rg->link_up = rg; @@ -370,15 +370,15 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level) ReebNode *cp_node = copyNode(cp_rg, node); cp_node->multi_level = level; } - + /* Copy arcs */ for (arc = rg->arcs.first; arc; arc = arc->next) { copyArc(cp_rg, arc); } - + BLI_buildAdjacencyList((BGraph *)cp_rg); - + return cp_rg; } #endif @@ -386,11 +386,11 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level) ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node) { ReebGraph *multi_rg = rg; - + while (multi_rg && multi_rg->multi_level != node->multi_level) { multi_rg = multi_rg->link_up; } - + return multi_rg; } @@ -398,13 +398,13 @@ ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node) static ReebEdge *copyEdge(ReebEdge *edge) { ReebEdge *newEdge = NULL; - + newEdge = MEM_callocN(sizeof(ReebEdge), "reeb edge"); memcpy(newEdge, edge, sizeof(ReebEdge)); - + newEdge->next = NULL; newEdge->prev = NULL; - + return newEdge; } @@ -414,7 +414,7 @@ static void printArc(ReebArc *arc) ReebNode *head = (ReebNode *)arc->head; ReebNode *tail = (ReebNode *)arc->tail; printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight); - + for (edge = arc->edges.first; edge; edge = edge->next) { printf("\tedge (%i, %i)\n", edge->v1->index, edge->v2->index); @@ -427,7 +427,7 @@ static void flipArc(ReebArc *arc) tmp = arc->head; arc->head = arc->tail; arc->tail = tmp; - + flipArcBuckets(arc); } @@ -461,20 +461,20 @@ void repositionNodes(ReebGraph *rg) { BArc *arc = NULL; BNode *node = NULL; - + // Reset node positions for (node = rg->nodes.first; node; node = node->next) { node->p[0] = node->p[1] = node->p[2] = 0; } - + for (arc = rg->arcs.first; arc; arc = arc->next) { if (((ReebArc *)arc)->bcount > 0) { float p[3]; - + copy_v3_v3(p, ((ReebArc *)arc)->buckets[0].p); mul_v3_fl(p, 1.0f / arc->head->degree); add_v3_v3(arc->head->p, p); - + copy_v3_v3(p, ((ReebArc *)arc)->buckets[((ReebArc *)arc)->bcount - 1].p); mul_v3_fl(p, 1.0f / arc->tail->degree); add_v3_v3(arc->tail->p, p); @@ -518,7 +518,7 @@ static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc) printf("count error in bucket %i/%i\n", i + 1, arc->bcount); } } - + if (ceilf(head->weight) != arc->buckets[0].val) { printArc(arc); printf("alloc error in first bucket: %f should be %f\n", arc->buckets[0].val, ceil(head->weight)); @@ -548,14 +548,14 @@ void verifyFaces(ReebGraph *rg) for (arc = rg->arcs.first; arc; arc = arc->next) { total += BLI_ghash_len(arc->faces); } - + #endif } void verifyArcs(ReebGraph *rg) { ReebArc *arc; - + for (arc = rg->arcs.first; arc; arc = arc->next) { if (arc->head->weight > arc->tail->weight) { printf("FLIPPED ARC!\n"); @@ -567,10 +567,10 @@ static void verifyMultiResolutionLinks(ReebGraph *rg, int level) { #ifdef DEBUG_REEB ReebGraph *lower_rg = rg->link_up; - + if (lower_rg) { ReebArc *arc; - + for (arc = rg->arcs.first; arc; arc = arc->next) { if (BLI_findindex(&lower_rg->arcs, arc->link_up) == -1) { printf("missing arc %p for level %i\n", (void *)arc->link_up, level); @@ -580,8 +580,8 @@ static void verifyMultiResolutionLinks(ReebGraph *rg, int level) arc->link_up = NULL; } } - - + + verifyMultiResolutionLinks(lower_rg, level + 1); } #endif @@ -620,9 +620,9 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end { if (aDst->bcount > 0 && aSrc->bcount > 0) { int indexDst = 0, indexSrc = 0; - + start = max_fff(start, aDst->buckets[0].val, aSrc->buckets[0].val); - + while (indexDst < aDst->bcount && aDst->buckets[indexDst].val < start) { indexDst++; } @@ -630,12 +630,12 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end while (indexSrc < aSrc->bcount && aSrc->buckets[indexSrc].val < start) { indexSrc++; } - + for (; indexDst < aDst->bcount && indexSrc < aSrc->bcount && aDst->buckets[indexDst].val <= end && aSrc->buckets[indexSrc].val <= end - + ; indexDst++, indexSrc++) { mergeBuckets(aDst->buckets + indexDst, aSrc->buckets + indexSrc); @@ -646,10 +646,10 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end void flipArcBuckets(ReebArc *arc) { int i, j; - + for (i = 0, j = arc->bcount - 1; i < j; i++, j--) { EmbedBucket tmp; - + tmp = arc->buckets[i]; arc->buckets[i] = arc->buckets[j]; arc->buckets[j] = tmp; @@ -666,10 +666,10 @@ static void allocArcBuckets(ReebArc *arc) int i; float start = ceil(arc->head->weight); arc->bcount = countArcBuckets(arc); - + if (arc->bcount > 0) { arc->buckets = MEM_callocN(sizeof(EmbedBucket) * arc->bcount, "embed bucket"); - + for (i = 0; i < arc->bcount; i++) { arc->buckets[i].val = start + i; } @@ -683,13 +683,13 @@ static void resizeArcBuckets(ReebArc *arc) { EmbedBucket *oldBuckets = arc->buckets; int oldBCount = arc->bcount; - + if (countArcBuckets(arc) == oldBCount) { return; } - + allocArcBuckets(arc); - + if (oldBCount != 0 && arc->bcount != 0) { int oldStart = (int)oldBuckets[0].val; int oldEnd = (int)oldBuckets[oldBCount - 1].val; @@ -698,17 +698,17 @@ static void resizeArcBuckets(ReebArc *arc) int oldOffset = 0; int newOffset = 0; int len; - + if (oldStart < newStart) { oldOffset = newStart - oldStart; } else { newOffset = oldStart - newStart; } - + len = MIN2(oldEnd - (oldStart + oldOffset) + 1, newEnd - (newStart - newOffset) + 1); - - memcpy(arc->buckets + newOffset, oldBuckets + oldOffset, len * sizeof(EmbedBucket)); + + memcpy(arc->buckets + newOffset, oldBuckets + oldOffset, len * sizeof(EmbedBucket)); } if (oldBuckets != NULL) { @@ -720,7 +720,7 @@ static void reweightBuckets(ReebArc *arc) { int i; float start = ceil((arc->head)->weight); - + if (arc->bcount > 0) { for (i = 0; i < arc->bcount; i++) { arc->buckets[i].val = start + i; @@ -732,9 +732,9 @@ static void interpolateBuckets(ReebArc *arc, float *start_p, float *end_p, int s { int total; int j; - + total = end_index - start_index + 2; - + for (j = start_index; j <= end_index; j++) { EmbedBucket *empty = arc->buckets + j; empty->nv = 1; @@ -748,26 +748,26 @@ static void fillArcEmptyBuckets(ReebArc *arc) int start_index = 0, end_index = 0; int missing = 0; int i; - + start_p = arc->head->p; - + for (i = 0; i < arc->bcount; i++) { EmbedBucket *bucket = arc->buckets + i; - + if (missing) { if (bucket->nv > 0) { missing = 0; - + end_p = bucket->p; end_index = i - 1; - + interpolateBuckets(arc, start_p, end_p, start_index, end_index); } } else { if (bucket->nv == 0) { missing = 1; - + if (i > 0) { start_p = arc->buckets[i - 1].p; } @@ -775,11 +775,11 @@ static void fillArcEmptyBuckets(ReebArc *arc) } } } - + if (missing) { end_p = arc->tail->p; end_index = arc->bcount - 1; - + interpolateBuckets(arc, start_p, end_p, start_index, end_index); } } @@ -792,15 +792,15 @@ static void ExtendArcBuckets(ReebArc *arc) float *previous = NULL; float average_length = 0, length; int padding_head = 0, padding_tail = 0; - + if (arc->bcount == 0) { return; /* failsafe, shouldn't happen */ } - + initArcIterator(iter, arc, arc->head); IT_next(iter); previous = iter->p; - + for (IT_next(iter); IT_stopped(iter) == 0; previous = iter->p, IT_next(iter) @@ -809,10 +809,10 @@ static void ExtendArcBuckets(ReebArc *arc) average_length += len_v3v3(previous, iter->p); } average_length /= (arc->bcount - 1); - + first_bucket = arc->buckets; last_bucket = arc->buckets + (arc->bcount - 1); - + length = len_v3v3(first_bucket->p, arc->head->p); if (length > 2 * average_length) { padding_head = (int)floor(length / average_length); @@ -822,22 +822,22 @@ static void ExtendArcBuckets(ReebArc *arc) if (length > 2 * average_length) { padding_tail = (int)floor(length / average_length); } - + if (padding_head + padding_tail > 0) { EmbedBucket *old_buckets = arc->buckets; - + arc->buckets = MEM_callocN(sizeof(EmbedBucket) * (padding_head + arc->bcount + padding_tail), "embed bucket"); memcpy(arc->buckets + padding_head, old_buckets, arc->bcount * sizeof(EmbedBucket)); - + arc->bcount = padding_head + arc->bcount + padding_tail; - + MEM_freeN(old_buckets); } - + if (padding_head > 0) { interpolateBuckets(arc, arc->head->p, first_bucket->p, 0, padding_head); } - + if (padding_tail > 0) { interpolateBuckets(arc, last_bucket->p, arc->tail->p, arc->bcount - padding_tail, arc->bcount - 1); } @@ -847,7 +847,7 @@ static void ExtendArcBuckets(ReebArc *arc) static void extendGraphBuckets(ReebGraph *rg) { ReebArc *arc; - + for (arc = rg->arcs.first; arc; arc = arc->next) { ExtendArcBuckets(arc); } @@ -862,7 +862,7 @@ static void calculateArcLength(ReebArc *arc) float *vec0, *vec1; arc->length = 0; - + initArcIterator(iter, arc, arc->head); vec0 = arc->head->p; @@ -870,19 +870,19 @@ static void calculateArcLength(ReebArc *arc) while (IT_next(iter)) { vec1 = iter->p; - + arc->length += len_v3v3(vec0, vec1); - + vec0 = vec1; } - + arc->length += len_v3v3(arc->tail->p, vec1); } static void calculateGraphLength(ReebGraph *rg) { ReebArc *arc; - + for (arc = rg->arcs.first; arc; arc = arc->next) { calculateArcLength(arc); } @@ -896,9 +896,9 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) ReebNode *node = (ReebNode *)root_node; float axis[3]; int i; - + copy_v3_v3(axis, root_node->symmetry_axis); - + /* first pass, merge incrementally */ for (i = 0; i < count - 1; i++) { ReebNode *node1, *node2; @@ -909,45 +909,45 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) add_v3_v3v3(tangent, ring[i].n, ring[j].n); cross_v3_v3v3(normal, tangent, axis); - + node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node); node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node); - + arc1 = (ReebArc *)ring[i].arc; arc2 = (ReebArc *)ring[j].arc; /* mirror first node and mix with the second */ BLI_mirrorAlongAxis(node1->p, root_node->p, normal); interp_v3_v3v3(node2->p, node2->p, node1->p, 1.0f / (j + 1)); - + /* Merge buckets - * there shouldn't be any null arcs here, but just to be safe + * there shouldn't be any null arcs here, but just to be safe * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; BArcIterator *iter1 = (BArcIterator *)&arc_iter1; BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; - + initArcIterator(iter1, arc1, (ReebNode *)root_node); initArcIterator(iter2, arc2, (ReebNode *)root_node); - + bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); - + /* Make sure they both start at the same value */ while (bucket1 && bucket2 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } - + while (bucket1 && bucket2 && bucket2->val < bucket1->val) { bucket2 = IT_next(iter2); } - - + + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { bucket2->nv += bucket1->nv; /* add counts */ - + /* mirror on axis */ BLI_mirrorAlongAxis(bucket1->p, root_node->p, normal); /* add bucket2 in bucket1 */ @@ -955,7 +955,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) } } } - + /* second pass, mirror back on previous arcs */ for (i = count - 1; i > 0; i--) { ReebNode *node1, *node2; @@ -966,42 +966,42 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) add_v3_v3v3(tangent, ring[i].n, ring[j].n); cross_v3_v3v3(normal, tangent, axis); - + node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node); node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node); - + arc1 = (ReebArc *)ring[i].arc; arc2 = (ReebArc *)ring[j].arc; /* copy first node than mirror */ copy_v3_v3(node2->p, node1->p); BLI_mirrorAlongAxis(node2->p, root_node->p, normal); - + /* Copy buckets - * there shouldn't be any null arcs here, but just to be safe + * there shouldn't be any null arcs here, but just to be safe * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; BArcIterator *iter1 = (BArcIterator *)&arc_iter1; BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; - + initArcIterator(iter1, arc1, node); initArcIterator(iter2, arc2, node); - + bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); - + /* Make sure they both start at the same value */ while (bucket1 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } - + while (bucket2 && bucket2->val < bucket1->val) { bucket2 = IT_next(iter2); } - - + + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { /* copy and mirror back to bucket2 */ bucket2->nv = bucket1->nv; @@ -1021,7 +1021,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr arc2 = (ReebArc *)barc2; copy_v3_v3(nor, root_node->symmetry_axis); - + /* mirror node2 along axis */ copy_v3_v3(p, node2->p); BLI_mirrorAlongAxis(p, root_node->p, nor); @@ -1029,31 +1029,31 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr /* average with node1 */ add_v3_v3(node1->p, p); mul_v3_fl(node1->p, 0.5f); - + /* mirror back on node2 */ copy_v3_v3(node2->p, node1->p); BLI_mirrorAlongAxis(node2->p, root_node->p, nor); - + /* Merge buckets - * there shouldn't be any null arcs here, but just to be safe + * there shouldn't be any null arcs here, but just to be safe * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; BArcIterator *iter1 = (BArcIterator *)&arc_iter1; BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; - + initArcIterator(iter1, arc1, (ReebNode *)root_node); initArcIterator(iter2, arc2, (ReebNode *)root_node); - + bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); - + /* Make sure they both start at the same value */ while (bucket1 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } - + while (bucket2 && bucket2->val < bucket1->val) { bucket2 = IT_next(iter2); } @@ -1061,7 +1061,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { bucket1->nv += bucket2->nv; /* add counts */ - + /* mirror on axis */ BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor); /* add bucket2 in bucket1 */ @@ -1104,7 +1104,7 @@ void postprocessGraph(ReebGraph *rg, char mode) // error("Unknown post processing mode"); return; } - + for (arc = rg->arcs.first; arc; arc = arc->next) { EmbedBucket *buckets = arc->buckets; @@ -1125,7 +1125,7 @@ static int compareNodesWeight(void *vnode1, void *vnode2) { ReebNode *node1 = (ReebNode *)vnode1; ReebNode *node2 = (ReebNode *)vnode2; - + if (node1->weight < node2->weight) { return -1; @@ -1150,7 +1150,7 @@ static int compareArcsWeight(void *varc1, void *varc2) ReebArc *arc2 = (ReebArc *)varc2; ReebNode *node1 = (ReebNode *)arc1->head; ReebNode *node2 = (ReebNode *)arc2->head; - + if (node1->weight < node2->weight) { return -1; @@ -1176,9 +1176,9 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float float old_weight; float end_weight = start_weight + ABS(arc->tail->weight - arc->head->weight); int i; - + node = (ReebNode *)BLI_otherNode((BArc *)arc, (BNode *)start_node); - + /* prevent backtracking */ if (node->flag == 1) { @@ -1189,13 +1189,13 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float { flipArc(arc); } - + start_node->flag = 1; - + for (i = 0; i < node->degree; i++) { ReebArc *next_arc = node->arcs[i]; - + reweightArc(rg, next_arc, node, end_weight); } @@ -1203,28 +1203,28 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float if (arc->head->weight != start_weight || arc->tail->weight != end_weight) { old_weight = arc->head->weight; /* backup head weight, other arcs need it intact, it will be fixed by the source arc */ - + arc->head->weight = start_weight; arc->tail->weight = end_weight; - + reweightBuckets(arc); resizeArcBuckets(arc); fillArcEmptyBuckets(arc); - + arc->head->weight = old_weight; } -} +} static void reweightSubgraph(ReebGraph *rg, ReebNode *start_node, float start_weight) { int i; - + BLI_flagNodes((BGraph *)rg, 0); for (i = 0; i < start_node->degree; i++) { ReebArc *next_arc = start_node->arcs[i]; - + reweightArc(rg, next_arc, start_node, start_weight); } start_node->weight = start_weight; @@ -1234,24 +1234,24 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) { int joined = 0; int subgraph; - + for (subgraph = 1; subgraph <= nb_subgraphs; subgraph++) { ReebNode *start_node, *end_node; ReebNode *min_node_start = NULL, *min_node_end = NULL; float min_distance = FLT_MAX; - + for (start_node = rg->nodes.first; start_node; start_node = start_node->next) { if (start_node->subgraph_index == subgraph && start_node->degree == 1) { - + for (end_node = rg->nodes.first; end_node; end_node = end_node->next) { if (end_node->subgraph_index != subgraph) { float distance = len_v3v3(start_node->p, end_node->p); - + if (distance < threshold && distance < min_distance) { min_distance = distance; @@ -1262,24 +1262,24 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) } } } - + end_node = min_node_end; start_node = min_node_start; - + if (end_node && start_node) { ReebArc *start_arc /* , *end_arc */ /* UNUSED */; int merging = 0; - + start_arc = start_node->arcs[0]; /* end_arc = end_node->arcs[0]; */ /* UNUSED */ - + if (start_arc->tail == start_node) { reweightSubgraph(rg, end_node, start_node->weight); - + start_arc->tail = end_node; - + merging = 1; } else if (start_arc->head == start_node) @@ -1290,24 +1290,24 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) merging = 2; } - + if (merging) { BLI_ReflagSubgraph((BGraph *)rg, end_node->flag, subgraph); - + resizeArcBuckets(start_arc); fillArcEmptyBuckets(start_arc); - + NodeDegreeIncrement(rg, end_node); BLI_rebuildAdjacencyListForNode((BGraph *)rg, (BNode *)end_node); - + BLI_removeNode((BGraph *)rg, (BNode *)start_node); } - + joined = 1; } } - + return joined; } @@ -1315,12 +1315,12 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) static void fixSubgraphsOrientation(ReebGraph *rg, int nb_subgraphs) { int subgraph; - + for (subgraph = 1; subgraph <= nb_subgraphs; subgraph++) { ReebNode *node; ReebNode *start_node = NULL; - + for (node = rg->nodes.first; node; node = node->next) { if (node->subgraph_index == subgraph) @@ -1331,7 +1331,7 @@ static void fixSubgraphsOrientation(ReebGraph *rg, int nb_subgraphs) } } } - + if (start_node) { reweightSubgraph(rg, start_node, start_node->weight); @@ -1343,19 +1343,19 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) { int nb_subgraphs; int joined = 0; - + BLI_buildAdjacencyList((BGraph *)rg); - + if (BLI_isGraphCyclic((BGraph *)rg)) { /* don't deal with cyclic graphs YET */ return 0; } - + /* sort nodes before flagging subgraphs to make sure root node is subgraph 0 */ sortNodes(rg); - + nb_subgraphs = BLI_FlagSubgraphs((BGraph *)rg); - + /* Harmonic function can create flipped arcs, take the occasion to fix them */ // XXX // if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC) @@ -1366,14 +1366,14 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) if (nb_subgraphs > 1) { joined |= joinSubgraphsEnds(rg, threshold, nb_subgraphs); - + if (joined) { removeNormalNodes(rg); BLI_buildAdjacencyList((BGraph *)rg); } } - + return joined; } @@ -1384,7 +1384,7 @@ static float lengthArc(ReebArc *arc) #if 0 ReebNode *head = (ReebNode *)arc->head; ReebNode *tail = (ReebNode *)arc->tail; - + return tail->weight - head->weight; #else return arc->length; @@ -1397,7 +1397,7 @@ static int compareArcs(void *varc1, void *varc2) ReebArc *arc2 = (ReebArc *)varc2; float len1 = lengthArc(arc1); float len2 = lengthArc(arc2); - + if (len1 < len2) { return -1; } @@ -1428,7 +1428,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R arc = rg->arcs.first; while (arc) { nextArc = arc->next; - + if (arc->head == removedNode || arc->tail == removedNode) { if (arc->head == removedNode) { arc->head = newNode; @@ -1441,7 +1441,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R if (arc->head == arc->tail) { // v1 or v2 was already newNode, since we're removing an arc, decrement degree NodeDegreeDecrement(rg, newNode); - + // If it's srcArc, it'll be removed later, so keep it for now if (arc != srcArc) { BLI_remlink(&rg->arcs, arc); @@ -1464,13 +1464,13 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R // resize bucket list resizeArcBuckets(arc); mergeArcBuckets(arc, srcArc, head->weight, tail->weight); - + /* update length */ arc->length += srcArc->length; } } } - + arc = nextArc; } } @@ -1478,7 +1478,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R void filterNullReebGraph(ReebGraph *rg) { ReebArc *arc = NULL, *nextArc = NULL; - + arc = rg->arcs.first; while (arc) { nextArc = arc->next; @@ -1487,22 +1487,22 @@ void filterNullReebGraph(ReebGraph *rg) ReebNode *newNode = (ReebNode *)arc->head; ReebNode *removedNode = (ReebNode *)arc->tail; float blend; - + blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors - + interp_v3_v3v3(newNode->p, removedNode->p, newNode->p, blend); - + filterArc(rg, newNode, removedNode, arc, 0); // Reset nextArc, it might have changed nextArc = arc->next; - + BLI_remlink(&rg->arcs, arc); REEB_freeArc((BArc *)arc); - + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); } - + arc = nextArc; } } @@ -1511,9 +1511,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern { ReebArc *arc = NULL, *nextArc = NULL; int value = 0; - + BLI_listbase_sort(&rg->arcs, compareArcs); - + for (arc = rg->arcs.first; arc; arc = nextArc) { nextArc = arc->next; @@ -1525,7 +1525,7 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern { ReebNode *newNode = NULL; ReebNode *removedNode = NULL; - + /* Always remove lower node, so arcs don't flip */ newNode = arc->head; removedNode = arc->tail; @@ -1534,14 +1534,14 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern // Reset nextArc, it might have changed nextArc = arc->next; - + BLI_remlink(&rg->arcs, arc); REEB_freeArc((BArc *)arc); - + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); value = 1; } - + // Only collapse terminal arcs that are shorter than threshold else if ((threshold_external > 0) && (arc->head->degree == 1 || arc->tail->degree == 1) && @@ -1550,7 +1550,7 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern ReebNode *terminalNode = NULL; ReebNode *middleNode = NULL; ReebNode *removedNode = NULL; - + // Assign terminal and middle nodes if (arc->head->degree == 1) { terminalNode = arc->head; @@ -1560,13 +1560,13 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern terminalNode = arc->tail; middleNode = arc->head; } - + if (middleNode->degree == 2 && middleNode != rg->nodes.first) { #if 1 // If middle node is a normal node, it will be removed later // Only if middle node is not the root node /* USE THIS IF YOU WANT TO PROLONG ARCS TO THEIR TERMINAL NODES - * FOR HANDS, THIS IS NOT THE BEST RESULT + * FOR HANDS, THIS IS NOT THE BEST RESULT * */ continue; #else @@ -1586,15 +1586,15 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern // Reset nextArc, it might have changed nextArc = arc->next; - + BLI_remlink(&rg->arcs, arc); REEB_freeArc((BArc *)arc); - + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); value = 1; } } - + return value; } @@ -1603,7 +1603,7 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold) ReebArc *arc1, *arc2; ReebArc *next2; int filtered = 0; - + for (arc1 = rg->arcs.first; arc1; arc1 = arc1->next) { for (arc2 = arc1->next; arc2; arc2 = next2) { next2 = arc2->next; @@ -1617,12 +1617,12 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold) BLI_remlink(&rg->arcs, arc2); REEB_freeArc((BArc *)arc2); - + filtered = 1; } } } - + return filtered; } @@ -1631,7 +1631,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) int value = 0; #if 0 //XXX ReebArc *arc = NULL, *nextArc = NULL; - + BLI_listbase_sort(&rg->arcs, compareArcs); #ifdef DEBUG_REEB @@ -1647,7 +1647,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) while (arc) { nextArc = arc->next; - + /* need correct normals and center */ recalc_editnormals(); @@ -1659,7 +1659,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) int total = BLI_ghash_len(arc->faces); float avg_angle = 0; float avg_vec[3] = {0, 0, 0}; - + for (BLI_ghashIterator_init(&ghi, arc->faces); BLI_ghashIterator_done(&ghi) == false; BLI_ghashIterator_step(&ghi)) @@ -1673,18 +1673,18 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) EmbedBucket *previous = NULL; float min_distance = -1; float angle = 0; - + initArcIterator(iter, arc, arc->head); - + bucket = nextBucket(iter); - + while (bucket != NULL) { float *vec0 = NULL; float *vec1 = bucket->p; float midpoint[3], tangent[3]; float distance; - + /* first bucket. Previous is head */ if (previous == NULL) { @@ -1694,25 +1694,25 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) else { vec0 = previous->p; } - + copy_v3_v3(midpoint, vec1); - + distance = len_v3v3(midpoint, efa->cent); - + if (min_distance == -1 || distance < min_distance) { min_distance = distance; - + sub_v3_v3v3(tangent, vec1, vec0); normalize_v3(tangent); - + angle = dot_v3v3(tangent, efa->n); } - + previous = bucket; bucket = nextBucket(iter); } - + avg_angle += saacos(fabs(angle)); #ifdef DEBUG_REEB efa->tmp.fp = saacos(fabs(angle)); @@ -1723,13 +1723,13 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) } -#if 0 +#if 0 avg_angle /= total; #else mul_v3_fl(avg_vec, 1.0 / total); avg_angle = dot_v3v3(avg_vec, avg_vec); #endif - + arc->angle = avg_angle; if (avg_angle > threshold) @@ -1777,27 +1777,27 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) /* Reset nextArc, it might have changed */ nextArc = arc->next; - + BLI_remlink(&rg->arcs, arc); REEB_freeArc((BArc *)arc); - + BLI_freelinkN(&rg->nodes, removedNode); value = 1; } } - + arc = nextArc; } - + #endif - + return value; } static void filterGraph(ReebGraph *rg, short options, float threshold_internal, float threshold_external) { bool done = true; - + calculateGraphLength(rg); if ((options & SKGEN_FILTER_EXTERNAL) == 0) { @@ -1812,7 +1812,7 @@ static void filterGraph(ReebGraph *rg, short options, float threshold_internal, /* filter until there's nothing more to do */ while (done == true) { done = false; /* no work done yet */ - + done = filterInternalExternalReebGraph(rg, threshold_internal, threshold_external); } } @@ -1831,17 +1831,17 @@ static void filterGraph(ReebGraph *rg, short options, float threshold_internal, static void finalizeGraph(ReebGraph *rg, char passes, char method) { int i; - + BLI_buildAdjacencyList((BGraph *)rg); sortNodes(rg); - + sortArcs(rg); - + for (i = 0; i < passes; i++) { postprocessGraph(rg, method); } - + extendGraphBuckets(rg); } @@ -1852,7 +1852,7 @@ static int compareVerts(const void *a, const void *b) EditVert *va = *(EditVert **)a; EditVert *vb = *(EditVert **)b; int value = 0; - + if (weightData(va) < weightData(vb)) { value = -1; } @@ -1870,20 +1870,20 @@ static void spreadWeight(EditMesh *em) int totvert = BLI_listbase_count(&em->verts); int i; int work_needed = 1; - + verts = MEM_callocN(sizeof(EditVert *) * totvert, "verts array"); - + for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) { verts[i] = eve; } - + while (work_needed == 1) { work_needed = 0; qsort(verts, totvert, sizeof(EditVert *), compareVerts); - + for (i = 0; i < totvert; i++) { eve = verts[i]; - + if (i == 0 || (weightData(eve) - lastWeight) > FLT_EPSILON) { lastWeight = weightData(eve); } @@ -1894,7 +1894,7 @@ static void spreadWeight(EditMesh *em) } } } - + MEM_freeN(verts); } @@ -1910,7 +1910,7 @@ void REEB_exportGraph(ReebGraph *rg, int count) ReebArc *arc; char filename[128]; FILE *f; - + if (count == -1) { strcpy(filename, "test.txt"); } @@ -1922,20 +1922,20 @@ void REEB_exportGraph(ReebGraph *rg, int count) for (arc = rg->arcs.first; arc; arc = arc->next) { int i; float p[3]; - + exportNode(f, "v1", arc->head); - + for (i = 0; i < arc->bcount; i++) { fprintf(f, "b nv:%i %f %f %f\n", arc->buckets[i].nv, arc->buckets[i].p[0], arc->buckets[i].p[1], arc->buckets[i].p[2]); } - + add_v3_v3v3(p, arc->tail->p, arc->head->p); mul_v3_fl(p, 0.5f); - + fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_len(arc->faces)); exportNode(f, "v2", arc->tail); } - + fclose(f); } @@ -1945,10 +1945,10 @@ void REEB_exportGraph(ReebGraph *rg, int count) static void removeZeroNodes(ReebGraph *rg) { ReebNode *node, *next_node; - + for (node = rg->nodes.first; node; node = next_node) { next_node = node->next; - + if (node->degree == 0) { BLI_removeNode((BGraph *)rg, (BNode *)node); } @@ -1958,11 +1958,11 @@ static void removeZeroNodes(ReebGraph *rg) void removeNormalNodes(ReebGraph *rg) { ReebArc *arc, *nextArc; - + // Merge degree 2 nodes for (arc = rg->arcs.first; arc; arc = nextArc) { nextArc = arc->next; - + while (arc->head->degree == 2 || arc->tail->degree == 2) { // merge at v1 if (arc->head->degree == 2) { @@ -1986,11 +1986,11 @@ void removeNormalNodes(ReebGraph *rg) break; } } - + /* merge at v2 */ if (arc->tail->degree == 2) { ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->tail); - + /* If arcs are one after the other */ if (arc->tail == connectedArc->head) { /* remove furthest arc */ @@ -2011,7 +2011,7 @@ void removeNormalNodes(ReebGraph *rg) } } } - + } static int edgeEquals(ReebEdge *e1, ReebEdge *e2) @@ -2027,9 +2027,9 @@ static ReebArc *nextArcMappedToEdge(ReebArc *arc, ReebEdge *e) /* Find the ReebEdge in the edge list */ for (edge = arc->edges.first; edge && !edgeEquals(edge, e); edge = edge->next) { } - + nextEdge = edge->nextEdge; - + if (nextEdge != NULL) { result = nextEdge->arc; } @@ -2045,7 +2045,7 @@ void addFacetoArc(ReebArc *arc, EditFace *efa) void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc) { GHashIterator ghi; - + for (BLI_ghashIterator_init(&ghi, aSrc->faces); BLI_ghashIterator_done(&ghi) == false; BLI_ghashIterator_step(&ghi)) @@ -2053,17 +2053,17 @@ void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc) EditFace *efa = BLI_ghashIterator_getValue(&ghi); BLI_ghash_insert(aDst->faces, efa, efa); } -} +} void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction) { ReebEdge *e = NULL; - + if (direction == MERGE_APPEND) { for (e = aSrc->edges.first; e; e = e->next) { e->arc = aDst; // Edge is stolen by new arc } - + BLI_movelisttolist(&aDst->edges, &aSrc->edges); } else { @@ -2071,12 +2071,12 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d ReebEdge *newEdge = copyEdge(e); newEdge->arc = aDst; - + BLI_addtail(&aDst->edges, newEdge); - + if (direction == MERGE_LOWER) { void **p = BLI_edgehash_lookup_p(rg->emap, e->v1->index, e->v2->index); - + newEdge->nextEdge = e; // if edge was the first in the list, point the edit edge to the new reeb edge instead. @@ -2086,11 +2086,11 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d // otherwise, advance in the list until the predecessor is found then insert it there else { ReebEdge *previous = (ReebEdge *)*p; - + while (previous->nextEdge != e) { previous = previous->nextEdge; } - + previous->nextEdge = newEdge; } } @@ -2100,19 +2100,19 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d } } } -} +} // return 1 on full merge int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) { int result = 0; ReebNode *removedNode = NULL; - + a0->length += a1->length; - + mergeArcEdges(rg, a0, a1, MERGE_APPEND); mergeArcFaces(rg, a0, a1); - + // Bring a0 to the combine length of both arcs if (a0->tail == a1->head) { removedNode = a0->tail; @@ -2122,18 +2122,18 @@ int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) removedNode = a0->head; a0->head = a1->head; } - + resizeArcBuckets(a0); // Merge a1 in a0 mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight); - + // remove a1 from graph BLI_remlink(&rg->arcs, a1); REEB_freeArc((BArc *)a1); - + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); result = 1; - + return result; } // return 1 on full merge @@ -2145,18 +2145,18 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) if (a0->tail->weight == a1->tail->weight) { /* tails also the same, arcs can be totally merge together */ mergeArcEdges(rg, a0, a1, MERGE_APPEND); mergeArcFaces(rg, a0, a1); - + mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight); - + // Adjust node degree //a1->head->degree--; NodeDegreeDecrement(rg, a1->head); //a1->tail->degree--; NodeDegreeDecrement(rg, a1->tail); - + // remove a1 from graph BLI_remlink(&rg->arcs, a1); - + REEB_freeArc((BArc *)a1); result = 1; } @@ -2169,7 +2169,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) NodeDegreeDecrement(rg, a0->head); //a1->tail->degree++; NodeDegreeIncrement(rg, a1->tail); - + mergeArcBuckets(a1, a0, a1->head->weight, a1->tail->weight); a0->head = a1->tail; resizeArcBuckets(a0); @@ -2177,13 +2177,13 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) else { /* a0>n2 is in the middle */ mergeArcEdges(rg, a0, a1, MERGE_LOWER); mergeArcFaces(rg, a0, a1); - + // Adjust node degree //a1->head->degree--; NodeDegreeDecrement(rg, a1->head); //a0->tail->degree++; NodeDegreeIncrement(rg, a0->tail); - + mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight); a1->head = a0->tail; resizeArcBuckets(a1); @@ -2194,13 +2194,13 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) if (a0->head->weight > a1->head->weight) { /* a0->head->weight is in the middle */ mergeArcEdges(rg, a0, a1, MERGE_HIGHER); mergeArcFaces(rg, a0, a1); - + // Adjust node degree //a1->tail->degree--; NodeDegreeDecrement(rg, a1->tail); //a0->head->degree++; NodeDegreeIncrement(rg, a0->head); - + mergeArcBuckets(a0, a1, a0->head->weight, a0->tail->weight); a1->tail = a0->head; resizeArcBuckets(a1); @@ -2223,7 +2223,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) else { /* Need something here (OR NOT) */ } - + return result; } @@ -2232,7 +2232,7 @@ static void glueByMergeSort(ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e int total = 0; while (total == 0 && a0 != a1 && a0 != NULL && a1 != NULL) { total = mergeArcs(rg, a0, a1); - + if (total == 0) // if it wasn't a total merge, go forward { if (a0->tail->weight < a1->tail->weight) { a0 = nextArcMappedToEdge(a0, e0); @@ -2250,31 +2250,31 @@ static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2) a0 = e0->arc; a1 = e1->arc; a2 = e2->arc; - + glueByMergeSort(rg, a0, a1, e0, e1); glueByMergeSort(rg, a0, a2, e0, e2); -} +} static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) { ReebEdge *edge; - + edge = BLI_edgehash_lookup(rg->emap, node1->index, node2->index); - + // Only add existing edges that haven't been added yet if (edge == NULL) { ReebArc *arc; ReebNode *v1, *v2; float len, offset; int i; - + arc = MEM_callocN(sizeof(ReebArc), "reeb arc"); edge = MEM_callocN(sizeof(ReebEdge), "reeb edge"); - + arc->flag = 0; // clear flag on init arc->symmetry_level = 0; arc->faces = BLI_ghash_ptr_new("createArc gh"); - + if (node1->weight <= node2->weight) { v1 = node1; v2 = node2; @@ -2283,10 +2283,10 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) v1 = node2; v2 = node1; } - + arc->head = v1; arc->tail = v2; - + // increase node degree //v1->degree++; NodeDegreeIncrement(rg, v1); @@ -2294,18 +2294,18 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) NodeDegreeIncrement(rg, v2); BLI_edgehash_insert(rg->emap, node1->index, node2->index, edge); - + edge->arc = arc; edge->nextEdge = NULL; edge->v1 = v1; edge->v2 = v2; - + BLI_addtail(&rg->arcs, arc); BLI_addtail(&arc->edges, edge); - + /* adding buckets for embedding */ allocArcBuckets(arc); - + offset = arc->head->weight; len = arc->tail->weight - arc->head->weight; @@ -2322,14 +2322,14 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) for (i = 0; i < arc->bcount; i++) { float co[3]; float f = (arc->buckets[i].val - offset) / len; - + interp_v3_v3v3(co, v1->p, v2->p, f); addVertToBucket(&(arc->buckets[i]), co); } #endif } - + return edge; } @@ -2338,21 +2338,21 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNo ReebEdge *re1, *re2, *re3; ReebEdge *e1, *e2, *e3; float len1, len2, len3; - + re1 = createArc(rg, n1, n2); re2 = createArc(rg, n2, n3); re3 = createArc(rg, n3, n1); - + addFacetoArc(re1->arc, efa); addFacetoArc(re2->arc, efa); addFacetoArc(re3->arc, efa); - + len1 = (float)fabs(n1->weight - n2->weight); len2 = (float)fabs(n2->weight - n3->weight); len3 = (float)fabs(n3->weight - n1->weight); - + /* The rest of the algorithm assumes that e1 is the longest edge */ - + if (len1 >= len2 && len1 >= len3) { e1 = re1; e2 = re2; @@ -2368,7 +2368,7 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNo e2 = re2; e3 = re1; } - + /* And e2 is the lowest edge * If e3 is lower than e2, swap them */ @@ -2377,8 +2377,8 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNo e2 = e3; e3 = etmp; } - - + + mergePaths(rg, e1, e2, e3); } @@ -2389,23 +2389,23 @@ ReebGraph *generateReebGraph(EditMesh *em, int subdivisions) EditFace *efa; int index; /*int totvert;*/ - + #ifdef DEBUG_REEB int totfaces; int countfaces = 0; #endif rg = newReebGraph(); - + rg->resolution = subdivisions; - + /*totvert = BLI_listbase_count(&em->verts);*/ /*UNUSED*/ #ifdef DEBUG_REEB totfaces = BLI_listbase_count(&em->faces); #endif - + renormalizeWeight(em, 1.0f); - + /* Spread weight to minimize errors */ spreadWeight(em); @@ -2419,18 +2419,18 @@ ReebGraph *generateReebGraph(EditMesh *em, int subdivisions) index++; } } - + /* Adding face, edge per edge */ for (efa = em->faces.first; efa; efa = efa->next) { if (efa->h == 0) { ReebNode *n1, *n2, *n3; - + n1 = nodeData(efa->v1); n2 = nodeData(efa->v2); n3 = nodeData(efa->v3); - + addTriangleToGraph(rg, n1, n2, n3, efa); - + if (efa->v4) { ReebNode *n4 = nodeData(efa->v4); addTriangleToGraph(rg, n1, n3, n4, efa); @@ -2443,13 +2443,13 @@ ReebGraph *generateReebGraph(EditMesh *em, int subdivisions) #endif } } - + printf("\n"); - + removeZeroNodes(rg); - + removeNormalNodes(rg); - + return rg; } @@ -2459,7 +2459,7 @@ void renormalizeWeight(EditMesh *em, float newmax) { EditVert *eve; float minimum, maximum, range; - + if (em == NULL || BLI_listbase_is_empty(&em->verts)) return; @@ -2471,7 +2471,7 @@ void renormalizeWeight(EditMesh *em, float newmax) maximum = MAX2(maximum, weightData(eve)); minimum = MIN2(minimum, weightData(eve)); } - + range = maximum - minimum; /* Normalize weights */ @@ -2485,7 +2485,7 @@ void renormalizeWeight(EditMesh *em, float newmax) int weightFromLoc(EditMesh *em, int axis) { EditVert *eve; - + if (em == NULL || BLI_listbase_is_empty(&em->verts) || axis < 0 || axis > 2) return 0; @@ -2501,17 +2501,17 @@ static void addTriangle(LinearSolver *context, EditVert *v1, EditVert *v2, EditV { /* Angle opposite e1 */ float t1 = cotangent_tri_weight_v3(v1->co, v2->co, v3->co) / e2; - + /* Angle opposite e2 */ float t2 = cotangent_tri_weight_v3(v2->co, v3->co, v1->co) / e3; /* Angle opposite e3 */ float t3 = cotangent_tri_weight_v3(v3->co, v1->co, v2->co) / e1; - + int i1 = indexData(v1); int i2 = indexData(v2); int i3 = indexData(v3); - + EIG_linear_solver_matrix_add(context, i1, i1, t2 + t3); EIG_linear_solver_matrix_add(context, i2, i2, t1 + t3); EIG_linear_solver_matrix_add(context, i3, i3, t1 + t2); @@ -2536,14 +2536,14 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) int totvert = 0; int index; int rval; - + /* Find local extrema */ for (eve = em->verts.first; eve; eve = eve->next) { totvert++; } /* Solve */ - + context = EIG_linear_solver_new(, 0, totvert, 1); /* Find local extrema */ @@ -2552,18 +2552,18 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) EditEdge *eed; int maximum = 1; int minimum = 1; - + NextEdgeForVert(indexed_edges, -1); /* Reset next edge */ for (eed = NextEdgeForVert(indexed_edges, index); eed && (maximum || minimum); eed = NextEdgeForVert(indexed_edges, index)) { EditVert *eve2; - + if (eed->v1 == eve) { eve2 = eed->v2; } else { eve2 = eed->v1; } - + if (eve2->h == 0) { /* Adjacent vertex is bigger, not a local maximum */ if (weightData(eve2) > weightData(eve)) { @@ -2575,7 +2575,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) } } } - + if (maximum || minimum) { float w = weightData(eve); eve->f1 = 0; @@ -2587,19 +2587,19 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) } } } - + /* Zero edge weight */ for (eed = em->edges.first; eed; eed = eed->next) { eed->tmp.l = 0; } - + /* Add faces count to the edge weight */ for (efa = em->faces.first; efa; efa = efa->next) { if (efa->h == 0) { efa->e1->tmp.l++; efa->e2->tmp.l++; efa->e3->tmp.l++; - + if (efa->e4) { efa->e4->tmp.l++; } @@ -2618,7 +2618,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) } } } - + success = EIG_linear_solver_solve(context); if (success) { @@ -2640,13 +2640,13 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index) { static int offset = -1; - + /* Reset method, call with NULL mesh pointer */ if (index == -1) { offset = -1; return NULL; } - + /* first pass, start at the head of the list */ if (offset == -1) { offset = indexed_edges->offset[index]; @@ -2655,7 +2655,7 @@ EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index) else { offset++; } - + return indexed_edges->edges[offset]; } @@ -2665,11 +2665,11 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd EditVert *current_eve = NULL; EditEdge *eed = NULL; EditEdge *select_eed = NULL; - + edge_heap = BLI_heap_new(); - + current_eve = starting_vert; - + /* insert guard in heap, when that is returned, no more edges */ BLI_heap_insert(edge_heap, FLT_MAX, NULL); @@ -2677,12 +2677,12 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd for (eed = em->edges.first; eed; eed = eed->next) { eed->f1 = 0; } - + while (BLI_heap_len(edge_heap) > 0) { float current_weight; - + current_eve->f1 = 1; /* mark vertex as selected */ - + /* Add all new edges connected to current_eve to the list */ NextEdgeForVert(indexed_edges, -1); // Reset next edge for (eed = NextEdgeForVert(indexed_edges, indexData(current_eve)); eed; eed = NextEdgeForVert(indexed_edges, indexData(current_eve))) { @@ -2691,27 +2691,27 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd eed->f1 = 1; } } - + /* Find next shortest edge with unselected verts */ do { current_weight = BLI_heap_node_value(BLI_heap_top(edge_heap)); select_eed = BLI_heap_pop_min(edge_heap); } while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1); - + if (select_eed != NULL) { select_eed->f1 = 2; - + if (select_eed->v1->f1 == 0) /* v1 is the new vertex */ { current_eve = select_eed->v1; } else { /* otherwise, it's v2 */ current_eve = select_eed->v2; } - + weightSetData(current_eve, current_weight); } } - + BLI_heap_free(edge_heap, NULL); } @@ -2740,7 +2740,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) indexed_edges->offset[indexData(eed->v2)]++; } } - + tot_indexed += totvert; indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge *), "EdgeIndex edges"); @@ -2764,7 +2764,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) break; } } - + for (i = indexed_edges->offset[indexData(eed->v2)]; i < tot_indexed; i++) { if (indexed_edges->edges[i] == NULL) { indexed_edges->edges[i] = eed; @@ -2781,19 +2781,19 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) int totedge = 0; int totvert = 0; int vCount = 0; - + totvert = BLI_listbase_count(&em->verts); - + if (em == NULL || totvert == 0) { return 0; } - + totedge = BLI_listbase_count(&em->edges); - + if (totedge == 0) { return 0; } - + /* Initialize vertice flag and find at least one selected vertex */ for (eve = em->verts.first; eve; eve = eve->next) { eve->f1 = 0; @@ -2801,7 +2801,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) vCount = 1; } } - + if (vCount == 0) { return 0; /* no selected vert, failure */ } @@ -2822,20 +2822,20 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) shortestPathsFromVert(em, eve, indexed_edges); } } - + /* connect unselected islands */ while (allDone == 0) { EditVert *selected_eve = NULL; float selected_weight = 0; float min_distance = FLT_MAX; - + allDone = 1; - + for (eve = em->verts.first; eve; eve = eve->next) { /* for every vertex visible that hasn't been processed yet */ if (eve->h == 0 && eve->f1 != 1) { EditVert *closest_eve; - + /* find the closest processed vertex */ for (closest_eve = em->verts.first; closest_eve; closest_eve = closest_eve->next) { /* vertex is already processed and distance is smaller than current minimum */ @@ -2850,7 +2850,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) } } } - + if (selected_eve) { allDone = 0; @@ -2866,7 +2866,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) break; } } - + return 1; } #endif @@ -2911,7 +2911,7 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head) initIteratorFct(iter); iter->arc = arc; - + if (head == arc->head) { iter->start = 0; iter->end = arc->bcount - 1; @@ -2922,9 +2922,9 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head) iter->end = 0; iter->stride = -1; } - + iter->length = arc->bcount; - + iter->index = -1; } @@ -2934,7 +2934,7 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod initIteratorFct(iter); iter->arc = arc; - + if (head == arc->head) { iter->start = start; iter->end = arc->bcount - 1; @@ -2945,9 +2945,9 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod iter->end = 0; iter->stride = -1; } - + iter->index = -1; - + iter->length = arc->bcount - start; if (start >= arc->bcount) { @@ -2961,10 +2961,10 @@ void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end) initIteratorFct(iter); iter->arc = arc; - + iter->start = start; iter->end = end; - + if (end > start) { iter->stride = 1; } @@ -2981,18 +2981,18 @@ static void *headNode(void *arg) { ReebArcIterator *iter = (ReebArcIterator *)arg; ReebNode *node; - + if (iter->start < iter->end) { node = iter->arc->head; } else { node = iter->arc->tail; } - + iter->p = node->p; iter->no = node->no; iter->size = 0; - + return node; } @@ -3000,18 +3000,18 @@ static void *tailNode(void *arg) { ReebArcIterator *iter = (ReebArcIterator *)arg; ReebNode *node; - + if (iter->start < iter->end) { node = iter->arc->tail; } else { node = iter->arc->head; } - + iter->p = node->p; iter->no = node->no; iter->size = 0; - + return node; } @@ -3019,13 +3019,13 @@ static void *nextBucket(void *arg) { ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; - + iter->index++; - + if (iter->index < iter->length) { result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]); } - + setIteratorValues(iter, result); return result; } @@ -3034,14 +3034,14 @@ static void *nextNBucket(void *arg, int n) { ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; - + iter->index += n; /* check if passed end */ if (iter->index < iter->length) { result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]); } - + setIteratorValues(iter, result); return result; } @@ -3065,7 +3065,7 @@ static void *previousBucket(void *arg) { ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; - + if (iter->index > 0) { iter->index--; result = &(iter->arc->buckets[iter->start + (iter->stride * iter->index)]); @@ -3105,7 +3105,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) if (em == NULL) return NULL; - + data = allocVertexData(em); buildIndexedEdges(em, &indexed_edges); @@ -3116,16 +3116,16 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) freeEdgeIndex(&indexed_edges); return NULL; } - + renormalizeWeight(em, 1.0f); if (scene->toolsettings->skgen_options & SKGEN_HARMONIC) { weightToHarmonic(em, &indexed_edges); } - + freeEdgeIndex(&indexed_edges); - + rg = generateReebGraph(em, scene->toolsettings->skgen_resolution); /* Remove arcs without embedding */ @@ -3138,11 +3138,11 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) /* Filtering might have created degree 2 nodes, so remove them */ removeNormalNodes(rg); - + joinSubgraphs(rg, 1.0); BLI_buildAdjacencyList((BGraph *)rg); - + /* calc length before copy, so we have same length on all levels */ BLI_calcGraphLength((BGraph *)rg); @@ -3150,7 +3150,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) for (i = 0; i <= nb_levels; i++) { rgi = rg; - + /* don't filter last level */ if (i > 0) { @@ -3165,7 +3165,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) else { internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal * (2 * i / (float)nb_levels); } - + external_threshold = rg->length * scene->toolsettings->skgen_threshold_external * (i / (float)nb_levels); filterGraph(rgi, scene->toolsettings->skgen_options, internal_threshold, external_threshold); @@ -3179,23 +3179,23 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) finalizeGraph(rgi, scene->toolsettings->skgen_postpro_passes, scene->toolsettings->skgen_postpro); BLI_markdownSymmetry((BGraph *)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit); - + if (previous != NULL) { relinkNodes(rgi, previous); } previous = rgi; } - + verifyMultiResolutionLinks(rg, 0); - + MEM_freeN(data); /* no need to load the editmesh back into the object, just * free it (avoids ngon conversion issues too going back the other way) */ free_editMesh(em); MEM_freeN(em); - + return rg; #endif } @@ -3208,14 +3208,14 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void) EdgeIndex indexed_edges; VertexData *data; ReebGraph *rg = NULL; - + if (em == NULL) return NULL; data = allocVertexData(em); buildIndexedEdges(em, &indexed_edges); - + if (weightFromDistance(em, &indexed_edges) == 0) { error("No selected vertex\n"); @@ -3223,20 +3223,20 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void) freeEdgeIndex(&indexed_edges); return NULL; } - + renormalizeWeight(em, 1.0f); if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC) { weightToHarmonic(em, &indexed_edges); } - + freeEdgeIndex(&indexed_edges); - + #ifdef DEBUG_REEB // weightToVCol(em, 1); #endif - + rg = generateReebGraph(em, G.scene->toolsettings->skgen_resolution); @@ -3250,28 +3250,28 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void) /* Filtering might have created degree 2 nodes, so remove them */ removeNormalNodes(rg); - + joinSubgraphs(rg, 1.0); BLI_buildAdjacencyList((BGraph *)rg); - + /* calc length before copy, so we have same length on all levels */ BLI_calcGraphLength((BGraph *)rg); - + filterGraph(rg, G.scene->toolsettings->skgen_options, G.scene->toolsettings->skgen_threshold_internal, G.scene->toolsettings->skgen_threshold_external); finalizeGraph(rg, G.scene->toolsettings->skgen_postpro_passes, G.scene->toolsettings->skgen_postpro); #ifdef DEBUG_REEB REEB_exportGraph(rg, -1); - + arcToVCol(rg, em, 0); //angleToVCol(em, 1); #endif printf("DONE\n"); printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph *)rg)); - + MEM_freeN(data); return rg; @@ -3289,9 +3289,9 @@ void BIF_GlobalReebFree() void BIF_GlobalReebGraphFromEditMesh(void) { ReebGraph *rg; - + BIF_GlobalReebFree(); - + rg = BIF_ReebGraphMultiFromEditMesh(); GLOBAL_RG = rg; @@ -3302,24 +3302,24 @@ void REEB_draw() ReebGraph *rg; ReebArc *arc; int i = 0; - + if (GLOBAL_RG == NULL) { return; } - + if (GLOBAL_RG->link_up && G.scene->toolsettings->skgen_options & SKGEN_DISP_ORIG) { for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up) ; } else { i = G.scene->toolsettings->skgen_multi_level; - + for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up) ; } - + glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE)); - + glDisable(GL_DEPTH_TEST); for (arc = rg->arcs.first; arc; arc = arc->next, i++) { @@ -3328,12 +3328,12 @@ void REEB_draw() float vec[3]; char text[128]; char *s = text; - + glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE) + 2); glColor3f(0, 0, 0); glBegin(GL_LINE_STRIP); glVertex3fv(arc->head->p); - + if (arc->bcount) { initArcIterator(iter, arc, arc->head); @@ -3342,7 +3342,7 @@ void REEB_draw() glVertex3fv(iter->p); } } - + glVertex3fv(arc->tail->p); glEnd(); @@ -3365,7 +3365,7 @@ void REEB_draw() } glBegin(GL_LINE_STRIP); glVertex3fv(arc->head->p); - + if (arc->bcount) { initArcIterator(iter, arc, arc->head); @@ -3374,18 +3374,18 @@ void REEB_draw() glVertex3fv(iter->p); } } - + glVertex3fv(arc->tail->p); glEnd(); - + if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED) { glColor3f(1, 1, 1); glBegin(GL_POINTS); glVertex3fv(arc->head->p); glVertex3fv(arc->tail->p); - + glColor3f(0.5f, 0.5f, 1); if (arc->bcount) { @@ -3397,22 +3397,22 @@ void REEB_draw() } glEnd(); } - + if (G.scene->toolsettings->skgen_options & SKGEN_DISP_INDEX) { mid_v3_v3v3(vec, arc->head->p, arc->tail->p); s += sprintf(s, "%i (%i-%i-%i) ", i, arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group); - + if (G.scene->toolsettings->skgen_options & SKGEN_DISP_WEIGHT) { s += sprintf(s, "w:%0.3f ", arc->tail->weight - arc->head->weight); } - + if (G.scene->toolsettings->skgen_options & SKGEN_DISP_LENGTH) { s += sprintf(s, "l:%0.3f", arc->length); } - + glColor3f(0, 1, 0); glRasterPos3fv(vec); BMF_DrawString(G.fonts, text); @@ -3423,7 +3423,7 @@ void REEB_draw() sprintf(text, " %i", arc->head->index); glRasterPos3fv(arc->head->p); BMF_DrawString(G.fonts, text); - + sprintf(text, " %i", arc->tail->index); glRasterPos3fv(arc->tail->p); BMF_DrawString(G.fonts, text); diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h index 7297f25c980..9eed343f18a 100644 --- a/source/blender/editors/armature/reeb.h +++ b/source/blender/editors/armature/reeb.h @@ -24,7 +24,7 @@ * \ingroup edarmature */ - + #ifndef __REEB_H__ #define __REEB_H__ @@ -43,15 +43,15 @@ struct ReebNode; typedef struct ReebGraph { ListBase arcs; ListBase nodes; - + float length; - + FreeArc free_arc; FreeNode free_node; RadialSymmetry radial_symmetry; AxialSymmetry axial_symmetry; /*********************************/ - + int resolution; int totnodes; struct EdgeHash *emap; @@ -80,7 +80,7 @@ typedef struct ReebNode { int symmetry_flag; float symmetry_axis[3]; /*********************************/ - + float no[3]; int index; @@ -127,10 +127,10 @@ typedef struct ReebArcIterator { NextNFct nextN; PreviousFct previous; StoppedFct stopped; - + float *p, *no; float size; - + int length; int index; /*********************************/ diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 85b561f3a9f..5d27e13ed17 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -73,10 +73,10 @@ void ED_operatortypes_curve(void) WM_operatortype_append(FONT_OT_change_character); WM_operatortype_append(FONT_OT_change_spacing); - + WM_operatortype_append(FONT_OT_open); WM_operatortype_append(FONT_OT_unlink); - + WM_operatortype_append(FONT_OT_textbox_add); WM_operatortype_append(FONT_OT_textbox_remove); @@ -98,20 +98,20 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_shade_smooth); WM_operatortype_append(CURVE_OT_shade_flat); WM_operatortype_append(CURVE_OT_tilt_clear); - + WM_operatortype_append(CURVE_OT_primitive_bezier_curve_add); WM_operatortype_append(CURVE_OT_primitive_bezier_circle_add); WM_operatortype_append(CURVE_OT_primitive_nurbs_curve_add); WM_operatortype_append(CURVE_OT_primitive_nurbs_circle_add); WM_operatortype_append(CURVE_OT_primitive_nurbs_path_add); - + WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_curve_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_circle_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_surface_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_cylinder_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_sphere_add); WM_operatortype_append(SURFACE_OT_primitive_nurbs_surface_torus_add); - + WM_operatortype_append(CURVE_OT_smooth); WM_operatortype_append(CURVE_OT_smooth_weight); WM_operatortype_append(CURVE_OT_smooth_radius); @@ -168,10 +168,10 @@ void ED_keymap_curve(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + keymap = WM_keymap_find(keyconf, "Font", 0, 0); keymap->poll = ED_operator_editfont; - + /* only set in editmode font, by space_view3d listener */ RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", BKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_BOLD); RNA_enum_set(WM_keymap_add_item(keymap, "FONT_OT_style_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "style", CU_CHINFO_ITALIC); @@ -233,7 +233,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) keymap->poll = ED_operator_editsurfcurve; WM_keymap_add_menu(keymap, "INFO_MT_edit_curve_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "CURVE_OT_handle_type_set", VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CURVE_OT_vertex_add", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); @@ -289,7 +289,7 @@ void ED_keymap_curve(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CURVE_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_curve_specials", WKEY, KM_PRESS, 0, 0); /* menus */ diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index ebf2b63bb49..139034a22d5 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1342,12 +1342,12 @@ void CURVE_OT_separate(wmOperatorType *ot) ot->name = "Separate"; ot->idname = "CURVE_OT_separate"; ot->description = "Separate selected points from connected unselected points into a new object"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = separate_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1852,7 +1852,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const short flag) while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); select_bpoint(newbp, DESELECT, flag, HIDDEN); - bp++; + bp++; newbp++; } @@ -2332,7 +2332,7 @@ void CURVE_OT_switch_direction(wmOperatorType *ot) ot->name = "Switch Direction"; ot->description = "Switch direction of selected splines"; ot->idname = "CURVE_OT_switch_direction"; - + /* api callbacks */ ot->exec = switch_direction_exec; ot->poll = ED_operator_editsurfcurve; @@ -2352,7 +2352,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op) BPoint *bp; float weight = RNA_float_get(op->ptr, "weight"); int a; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { @@ -2380,7 +2380,7 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot) ot->name = "Set Goal Weight"; ot->description = "Set softbody goal weight for selected points"; ot->idname = "CURVE_OT_spline_weight_set"; - + /* api callbacks */ ot->exec = set_goal_weight_exec; ot->invoke = WM_operator_props_popup; @@ -2404,7 +2404,7 @@ static int set_radius_exec(bContext *C, wmOperator *op) BPoint *bp; float radius = RNA_float_get(op->ptr, "radius"); int a; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { @@ -2432,7 +2432,7 @@ void CURVE_OT_radius_set(wmOperatorType *ot) ot->name = "Set Curve Radius"; ot->description = "Set per-point radius which is used for bevel tapering"; ot->idname = "CURVE_OT_radius_set"; - + /* api callbacks */ ot->exec = set_radius_exec; ot->invoke = WM_operator_props_popup; @@ -2584,7 +2584,7 @@ void CURVE_OT_smooth(wmOperatorType *ot) ot->name = "Smooth"; ot->description = "Flatten angles of selected points"; ot->idname = "CURVE_OT_smooth"; - + /* api callbacks */ ot->exec = smooth_exec; ot->poll = ED_operator_editsurfcurve; @@ -2788,7 +2788,7 @@ static int curve_smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) { Object *obedit = CTX_data_edit_object(C); ListBase *editnurb = object_editcurve_get(obedit); - + curve_smooth_value(editnurb, offsetof(BezTriple, radius), offsetof(BPoint, radius)); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -2803,11 +2803,11 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot) ot->name = "Smooth Curve Radius"; ot->description = "Interpolate radii of selected points"; ot->idname = "CURVE_OT_smooth_radius"; - + /* api clastbacks */ ot->exec = curve_smooth_radius_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2905,14 +2905,14 @@ void CURVE_OT_hide(wmOperatorType *ot) ot->name = "Hide Selected"; ot->idname = "CURVE_OT_hide"; ot->description = "Hide (un)selected control points"; - + /* api callbacks */ ot->exec = hide_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); } @@ -2967,11 +2967,11 @@ void CURVE_OT_reveal(wmOperatorType *ot) ot->name = "Reveal Hidden"; ot->idname = "CURVE_OT_reveal"; ot->description = "Reveal hidden control points"; - + /* api callbacks */ ot->exec = reveal_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3227,7 +3227,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for (b = 0; b < nu->pntsu; b++) { *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); - bpn++; + bpn++; bp++; if (b < nu->pntsu - 1) { prevbp = bp - 1; @@ -3255,7 +3255,7 @@ static void subdividenurb(Object *obedit, int number_cuts) interp_v4_v4v4(tmp->vec, prevbp->vec, bp->vec, factor); tmp += countu; } - bp++; + bp++; prevbp++; bpn++; } @@ -3331,7 +3331,7 @@ static void subdividenurb(Object *obedit, int number_cuts) for (b = 0; b < nu->pntsu; b++) { *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); - bpn++; + bpn++; bp++; if ( (b < nu->pntsu - 1) && usel[b] == nu->pntsv && usel[b + 1] == nu->pntsv) { /* @@ -3358,7 +3358,7 @@ static void subdividenurb(Object *obedit, int number_cuts) } } } - MEM_freeN(usel); + MEM_freeN(usel); MEM_freeN(vsel); } /* End of 'if (nu->type == CU_NURBS)' */ @@ -3389,11 +3389,11 @@ void CURVE_OT_subdivide(wmOperatorType *ot) ot->name = "Subdivide"; ot->description = "Subdivide selected segments"; ot->idname = "CURVE_OT_subdivide"; - + /* api callbacks */ ot->exec = subdivide_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3551,7 +3551,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Not yet implemented"); return OPERATOR_CANCELLED; } - + for (nu = editnurb->first; nu; nu = nu->next) { if (ED_curve_nurb_select_check(obedit->data, nu)) { const int pntsu_prev = nu->pntsu; @@ -3601,12 +3601,12 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) ot->name = "Set Spline Type"; ot->description = "Set type of active spline"; ot->idname = "CURVE_OT_spline_type_set"; - + /* api callbacks */ ot->exec = set_spline_type_exec; ot->invoke = WM_menu_invoke; ot->poll = ED_operator_editcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3646,12 +3646,12 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot) ot->name = "Set Handle Type"; ot->description = "Set type of handles for selected control points"; ot->idname = "CURVE_OT_handle_type_set"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = set_handle_type_exec; ot->poll = ED_operator_editcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3701,9 +3701,9 @@ static void switchdirection_knots(float *base, int tot) { float *fp1, *fp2, *tempf; int a; - + if (base == NULL || tot == 0) return; - + /* reverse knots */ a = tot; fp1 = base; @@ -3712,7 +3712,7 @@ static void switchdirection_knots(float *base, int tot) while (fp1 != fp2 && a > 0) { SWAP(float, *fp1, *fp2); a--; - fp1++; + fp1++; fp2--; } @@ -3744,15 +3744,15 @@ static void rotate_direction_nurb(Nurb *nu) { BPoint *bp1, *bp2, *temp; int u, v; - + SWAP(int, nu->pntsu, nu->pntsv); SWAP(short, nu->orderu, nu->orderv); SWAP(short, nu->resolu, nu->resolv); SWAP(short, nu->flagu, nu->flagv); - + SWAP(float *, nu->knotsu, nu->knotsv); switchdirection_knots(nu->knotsv, KNOTSV(nu)); - + temp = MEM_dupallocN(nu->bp); bp1 = nu->bp; for (v = 0; v < nu->pntsv; v++) { @@ -3769,7 +3769,7 @@ static bool is_u_selected(Nurb *nu, int u) { BPoint *bp; int v; - + /* what about resolu == 2? */ bp = &nu->bp[u]; for (v = 0; v < nu->pntsv - 1; v++, bp += nu->pntsu) { @@ -3777,7 +3777,7 @@ static bool is_u_selected(Nurb *nu, int u) return true; } } - + return false; } @@ -3798,14 +3798,14 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) BPoint *bp; float dist, headdist, taildist; int a; - + for (nu = editnurb->first; nu; nu = nu->next) { if (ED_curve_nurb_select_check(cu, nu)) { - + nus = (NurbSort *)MEM_callocN(sizeof(NurbSort), "sort"); BLI_addhead(&nbase, nus); nus->nu = nu; - + bp = nu->bp; a = nu->pntsu; while (a--) { @@ -3813,8 +3813,8 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) bp++; } mul_v3_fl(nus->vec, 1.0f / (float)nu->pntsu); - - + + } } @@ -3822,10 +3822,10 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) nus = nbase.first; BLI_remlink(&nbase, nus); BLI_addtail(&nsortbase, nus); - + /* now add, either at head or tail, the closest one */ while (nbase.first) { - + headdist = taildist = 1.0e30; headdo = taildo = NULL; @@ -3845,7 +3845,7 @@ static void make_selection_list_nurb(Curve *cu, ListBase *editnurb) } nustest = nustest->next; } - + if (headdist < taildist) { BLI_remlink(&nbase, headdo); BLI_addhead(&nsortbase, headdo); @@ -3862,12 +3862,12 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu BPoint *bp, *bp1, *bp2, *temp; float len1, len2; int origu, u, v; - + /* first nurbs will be changed to make u = resolu-1 selected */ /* 2nd nurbs will be changed to make u = 0 selected */ /* first nurbs: u = resolu-1 selected */ - + if (is_u_selected(nu1, nu1->pntsu - 1)) { /* pass */ } @@ -3898,7 +3898,7 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu } } } - + /* 2nd nurbs: u = 0 selected */ if (is_u_selected(nu2, 0)) { /* pass */ @@ -3928,19 +3928,19 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu } } } - + if (nu1->pntsv != nu2->pntsv) { BKE_report(op->reports, RPT_ERROR, "Resolution does not match"); return; } - + /* ok, now nu1 has the rightmost column and nu2 the leftmost column selected */ /* maybe we need a 'v' flip of nu2? */ - + bp1 = &nu1->bp[nu1->pntsu - 1]; bp2 = nu2->bp; len1 = 0.0; - + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 += nu2->pntsu) { len1 += len_v3v3(bp1->vec, bp2->vec); } @@ -3948,7 +3948,7 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu bp1 = &nu1->bp[nu1->pntsu - 1]; bp2 = &nu2->bp[nu2->pntsu * (nu2->pntsv - 1)]; len2 = 0.0; - + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 -= nu2->pntsu) { len2 += len_v3v3(bp1->vec, bp2->vec); } @@ -3960,12 +3960,12 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) nu1->orderv++; temp = nu1->bp; nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP"); - + bp = nu1->bp; bp1 = temp; - + for (v = 0; v < nu1->pntsv; v++) { - + /* switch direction? */ if (len1 < len2) bp2 = &nu2->bp[v * nu2->pntsu]; else bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu]; @@ -3986,11 +3986,11 @@ static void merge_2_nurb(wmOperator *op, Curve *cu, ListBase *editnurb, Nurb *nu if (nu1->type == CU_NURBS) { /* merge knots */ BKE_nurb_knot_calc_u(nu1); - + /* make knots, for merged curved for example */ BKE_nurb_knot_calc_v(nu1); } - + MEM_freeN(temp); BLI_remlink(editnurb, nu2); BKE_nurb_free(nu2); @@ -4003,15 +4003,15 @@ static int merge_nurb(bContext *C, wmOperator *op) ListBase *editnurb = object_editcurve_get(obedit); NurbSort *nus1, *nus2; bool ok = true; - + make_selection_list_nurb(cu, editnurb); - + if (nsortbase.first == nsortbase.last) { BLI_freelistN(&nsortbase); BKE_report(op->reports, RPT_ERROR, "Too few selections to merge"); return OPERATOR_CANCELLED; } - + nus1 = nsortbase.first; nus2 = nus1->next; @@ -4041,7 +4041,7 @@ static int merge_nurb(bContext *C, wmOperator *op) else { ok = 0; } - + if (ok == 0) { BKE_report(op->reports, RPT_ERROR, "Resolution does not match"); BLI_freelistN(&nsortbase); @@ -4052,14 +4052,14 @@ static int merge_nurb(bContext *C, wmOperator *op) merge_2_nurb(op, cu, editnurb, nus1->nu, nus2->nu); nus2 = nus2->next; } - + BLI_freelistN(&nsortbase); - + BKE_curve_nurb_active_set(obedit->data, NULL); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); - + return OPERATOR_FINISHED; } @@ -4077,7 +4077,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) /* first decide if this is a surface merge! */ if (obedit->type == OB_SURF) nu = nubase->first; else nu = NULL; - + while (nu) { const int nu_select_num = ED_curve_nurb_select_count(cu, nu); if (nu_select_num) { @@ -4106,7 +4106,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) if (nu) return merge_nurb(C, op); - + /* find both nurbs and points, nu1 will be put behind nu2 */ for (nu = nubase->first; nu; nu = nu->next) { if (nu->pntsu == 1) @@ -4276,7 +4276,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) ot->name = "Make Segment"; ot->idname = "CURVE_OT_make_segment"; ot->description = "Join two curves by their selected ends"; - + /* api callbacks */ ot->exec = make_segment_exec; ot->poll = ED_operator_editsurfcurve; @@ -4299,10 +4299,10 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend, const void *vert = BKE_curve_vert_active_get(cu); int location[2]; short hand; - + view3d_operator_needs_opengl(C); ED_view3d_viewcontext_init(C, &vc); - + location[0] = mval[0]; location[1] = mval[1]; @@ -4400,7 +4400,7 @@ bool ED_curve_editnurb_select_pick(bContext *C, const int mval[2], bool extend, return true; } - + return false; } @@ -4425,7 +4425,7 @@ bool ed_editnurb_spin(float viewmat[4][4], Object *obedit, const float axis[3], /* imat and center and size */ copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - + axis_angle_to_mat3(cmat, axis, M_PI / 4.0); mul_m3_m3m3(tmat, cmat, bmat); mul_m3_m3m3(rotmat, imat, tmat); @@ -4488,18 +4488,18 @@ static int spin_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); float cent[3], axis[3], viewmat[4][4]; - + RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); - + invert_m4_m4(obedit->imat, obedit->obmat); mul_m4_v3(obedit->imat, cent); - + if (rv3d) copy_m4_m4(viewmat, rv3d->viewmat); else unit_m4(viewmat); - + if (!ed_editnurb_spin(viewmat, obedit, axis, cent)) { BKE_report(op->reports, RPT_ERROR, "Cannot spin"); return OPERATOR_CANCELLED; @@ -4520,13 +4520,13 @@ static int spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = ED_view3d_context_rv3d(C); float axis[3] = {0.0f, 0.0f, 1.0f}; - + if (rv3d) copy_v3_v3(axis, rv3d->viewinv[2]); - + RNA_float_set_array(op->ptr, "center", ED_view3d_cursor3d_get(scene, v3d)); RNA_float_set_array(op->ptr, "axis", axis); - + return spin_exec(C, op); } @@ -4536,7 +4536,7 @@ void CURVE_OT_spin(wmOperatorType *ot) ot->name = "Spin"; ot->idname = "CURVE_OT_spin"; ot->description = "Extrude selected boundary row around pivot point and current view axis"; - + /* api callbacks */ ot->exec = spin_exec; ot->invoke = spin_invoke; @@ -4544,7 +4544,7 @@ void CURVE_OT_spin(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -OBJECT_ADD_SIZE_MAXF, OBJECT_ADD_SIZE_MAXF, "Center", "Center in global view space", -1000.0f, 1000.0f); RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -1.0f, 1.0f); @@ -5069,7 +5069,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) ot->name = "Add Vertex"; ot->idname = "CURVE_OT_vertex_add"; ot->description = "Add a new control point (linked to only selected end-curve one, if any)"; - + /* api callbacks */ ot->exec = add_vertex_exec; ot->invoke = add_vertex_invoke; @@ -5092,7 +5092,7 @@ static int curve_extrude_exec(bContext *C, wmOperator *UNUSED(op)) EditNurb *editnurb = cu->editnurb; bool changed = false; bool as_curve = false; - + /* first test: curve? */ if (obedit->type != OB_CURVE) { Nurb *nu; @@ -5131,7 +5131,7 @@ void CURVE_OT_extrude(wmOperatorType *ot) ot->name = "Extrude"; ot->description = "Extrude selected control point(s)"; ot->idname = "CURVE_OT_extrude"; - + /* api callbacks */ ot->exec = curve_extrude_exec; ot->poll = ED_operator_editsurfcurve; @@ -5198,7 +5198,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) a = nu->pntsu * nu->pntsv; bp = nu->bp; while (a--) { - + if (bp->f1 & SELECT) { if (direction == 0 && nu->pntsu > 1) { nu->flagu ^= CU_NURB_CYCLIC; @@ -5212,7 +5212,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } bp++; } - + } } } @@ -5260,7 +5260,7 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) ot->name = "Toggle Cyclic"; ot->description = "Make active spline closed/opened loop"; ot->idname = "CURVE_OT_cyclic_toggle"; - + /* api callbacks */ ot->exec = toggle_cyclic_exec; ot->invoke = toggle_cyclic_invoke; @@ -5300,11 +5300,11 @@ void CURVE_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Curve"; ot->description = "Duplicate selected control points"; ot->idname = "CURVE_OT_duplicate"; - + /* api callbacks */ ot->exec = duplicate_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5775,12 +5775,12 @@ void CURVE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete selected control points or segments"; ot->idname = "CURVE_OT_delete"; - + /* api callbacks */ ot->exec = curve_delete_exec; ot->invoke = WM_menu_invoke; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -5989,17 +5989,17 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; int clear = (STREQ(op->idname, "CURVE_OT_shade_flat")); - + if (obedit->type != OB_CURVE) return OPERATOR_CANCELLED; - + for (nu = editnurb->first; nu; nu = nu->next) { if (ED_curve_nurb_select_check(obedit->data, nu)) { if (!clear) nu->flag |= CU_SMOOTH; else nu->flag &= ~CU_SMOOTH; } } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); @@ -6012,11 +6012,11 @@ void CURVE_OT_shade_smooth(wmOperatorType *ot) ot->name = "Shade Smooth"; ot->idname = "CURVE_OT_shade_smooth"; ot->description = "Set shading to smooth"; - + /* api callbacks */ ot->exec = shade_smooth_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -6027,11 +6027,11 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) ot->name = "Shade Flat"; ot->idname = "CURVE_OT_shade_flat"; ot->description = "Set shading to flat"; - + /* api callbacks */ ot->exec = shade_smooth_exec; ot->poll = ED_operator_editsurfcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -6068,21 +6068,21 @@ int join_curve_exec(bContext *C, wmOperator *op) } BLI_listbase_clear(&tempbase); - + /* trasnform all selected curves inverse in obact */ invert_m4_m4(imat, ob->obmat); - + CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases) { if (base->object->type == ob->type) { if (base->object != ob) { - + cu = base->object->data; - + if (cu->nurb.first) { /* watch it: switch order here really goes wrong */ mul_m4_m4m4(cmat, imat, base->object->obmat); - + nu = cu->nurb.first; while (nu) { newnu = BKE_nurb_duplicate(nu); @@ -6093,7 +6093,7 @@ int join_curve_exec(bContext *C, wmOperator *op) newnu->mat_nr = 0; } BLI_addtail(&tempbase, newnu); - + if ((bezt = newnu->bezt)) { a = newnu->pntsu; while (a--) { @@ -6114,16 +6114,16 @@ int join_curve_exec(bContext *C, wmOperator *op) nu = nu->next; } } - + ED_base_object_free_and_unlink(bmain, scene, base); } } } CTX_DATA_END; - + cu = ob->data; BLI_movelisttolist(&cu->nurb, &tempbase); - + if (ob->type == OB_CURVE) { /* Account for mixed 2D/3D curves when joining */ BKE_curve_curve_dimension_update(cu); @@ -6182,11 +6182,11 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) ot->name = "Clear Tilt"; ot->idname = "CURVE_OT_tilt_clear"; ot->description = "Clear the tilt of selected control points"; - + /* api callbacks */ ot->exec = clear_tilt_exec; ot->poll = ED_operator_editcurve; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 36d9f8a4c55..964296df205 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -987,7 +987,7 @@ static int curve_draw_exec(bContext *C, wmOperator *op) nu->resolv = 1; nu->orderu = 4; nu->orderv = 1; - + BPoint *bp = nu->bp; BLI_mempool_iternew(cdd->stroke_elem_pool, &iter); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index d651f673a7f..e4db0f1b3fc 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -81,7 +81,7 @@ static int kill_selection(Object *obedit, int ins); static char findaccent(char char1, unsigned int code) { char new = 0; - + if (char1 == 'a') { if (code == '`') new = 224; else if (code == 39) new = 225; @@ -213,7 +213,7 @@ static char findaccent(char char1, unsigned int code) else if (char1 == '+') { if (code == '-') new = 177; } - + if (new) return new; else return char1; } @@ -222,7 +222,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) { Curve *cu = obedit->data; EditFont *ef = cu->editfont; - + if (ef->len < MAXTEXT - 1) { int x; @@ -232,7 +232,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) ef->textbufinfo[ef->pos] = cu->curinfo; ef->textbufinfo[ef->pos].kern = 0; ef->textbufinfo[ef->pos].mat_nr = obedit->actcol; - + ef->pos++; ef->len++; ef->textbuf[ef->len] = '\0'; @@ -375,7 +375,7 @@ static int paste_from_file_exec(bContext *C, wmOperator *op) { char *path; int retval; - + path = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); retval = paste_from_file(C, op->reports, path); MEM_freeN(path); @@ -388,7 +388,7 @@ static int paste_from_file_invoke(bContext *C, wmOperator *op, const wmEvent *UN if (RNA_struct_property_is_set(op->ptr, "filepath")) return paste_from_file_exec(C, op); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -399,12 +399,12 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot) ot->name = "Paste File"; ot->description = "Paste contents from file"; ot->idname = "FONT_OT_text_paste_from_file"; - + /* api callbacks */ ot->exec = paste_from_file_exec; ot->invoke = paste_from_file_invoke; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -428,7 +428,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const char *s; int a; float rot[3] = {0.f, 0.f, 0.f}; - + obedit = BKE_object_add(bmain, scene, OB_FONT, NULL); base = scene->basact; @@ -501,12 +501,12 @@ void ED_text_to_object(bContext *C, Text *text, const bool split_lines) linenum++; continue; } - + /* do the translation */ offset[0] = 0; offset[1] = -linenum; offset[2] = 0; - + if (rv3d) mul_mat3_m4_v3(rv3d->viewinv, offset); @@ -602,11 +602,11 @@ void FONT_OT_style_set(wmOperatorType *ot) ot->name = "Set Style"; ot->description = "Set font style"; ot->idname = "FONT_OT_style_set"; - + /* api callbacks */ ot->exec = set_style_exec; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -625,7 +625,7 @@ static int toggle_style_exec(bContext *C, wmOperator *op) if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; - + style = RNA_enum_get(op->ptr, "style"); cu->curinfo.flag ^= style; @@ -640,11 +640,11 @@ void FONT_OT_style_toggle(wmOperatorType *ot) ot->name = "Toggle Style"; ot->description = "Toggle font style"; ot->idname = "FONT_OT_style_toggle"; - + /* api callbacks */ ot->exec = toggle_style_exec; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -698,7 +698,7 @@ void FONT_OT_select_all(wmOperatorType *ot) static void copy_selection(Object *obedit) { int selstart, selend; - + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { Curve *cu = obedit->data; EditFont *ef = cu->editfont; @@ -735,7 +735,7 @@ void FONT_OT_text_copy(wmOperatorType *ot) ot->name = "Copy Text"; ot->description = "Copy selected text to clipboard"; ot->idname = "FONT_OT_text_copy"; - + /* api callbacks */ ot->exec = copy_text_exec; ot->poll = ED_operator_editfont; @@ -765,7 +765,7 @@ void FONT_OT_text_cut(wmOperatorType *ot) ot->name = "Cut Text"; ot->description = "Cut selected text to clipboard"; ot->idname = "FONT_OT_text_cut"; - + /* api callbacks */ ot->exec = cut_text_exec; ot->poll = ED_operator_editfont; @@ -866,7 +866,7 @@ void FONT_OT_text_paste(wmOperatorType *ot) ot->name = "Paste Text"; ot->description = "Paste text from clipboard"; ot->idname = "FONT_OT_text_paste"; - + /* api callbacks */ ot->exec = paste_text_exec; ot->poll = ED_operator_editfont; @@ -910,7 +910,7 @@ static int move_cursor(bContext *C, int type, const bool select) } cursmove = FO_CURS; break; - + case LINE_END: while (ef->pos < ef->len) { if (ef->textbuf[ef->pos] == 0) break; @@ -953,7 +953,7 @@ static int move_cursor(bContext *C, int type, const bool select) case PREV_LINE: cursmove = FO_CURSUP; break; - + case NEXT_LINE: cursmove = FO_CURSDOWN; break; @@ -966,7 +966,7 @@ static int move_cursor(bContext *C, int type, const bool select) cursmove = FO_PAGEDOWN; break; } - + if (cursmove == -1) return OPERATOR_CANCELLED; @@ -1011,7 +1011,7 @@ void FONT_OT_move(wmOperatorType *ot) ot->name = "Move Cursor"; ot->description = "Move cursor to position type"; ot->idname = "FONT_OT_move"; - + /* api callbacks */ ot->exec = move_exec; ot->poll = ED_operator_editfont; @@ -1038,7 +1038,7 @@ void FONT_OT_move_select(wmOperatorType *ot) ot->name = "Move Select"; ot->description = "Move the cursor while selecting"; ot->idname = "FONT_OT_move_select"; - + /* api callbacks */ ot->exec = move_select_exec; ot->poll = ED_operator_editfont; @@ -1079,7 +1079,7 @@ void FONT_OT_change_spacing(wmOperatorType *ot) ot->name = "Change Spacing"; ot->description = "Change font spacing"; ot->idname = "FONT_OT_change_spacing"; - + /* api callbacks */ ot->exec = change_spacing_exec; ot->poll = ED_operator_editfont; @@ -1123,7 +1123,7 @@ void FONT_OT_change_character(wmOperatorType *ot) ot->name = "Change Character"; ot->description = "Change font character code"; ot->idname = "FONT_OT_change_character"; - + /* api callbacks */ ot->exec = change_character_exec; ot->poll = ED_operator_editfont; @@ -1158,7 +1158,7 @@ void FONT_OT_line_break(wmOperatorType *ot) ot->name = "Line Break"; ot->description = "Insert line break at cursor position"; ot->idname = "FONT_OT_line_break"; - + /* api callbacks */ ot->exec = line_break_exec; ot->poll = ED_operator_editfont; @@ -1284,7 +1284,7 @@ void FONT_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete text by cursor position"; ot->idname = "FONT_OT_delete"; - + /* api callbacks */ ot->exec = delete_exec; ot->poll = ED_operator_editfont; @@ -1307,7 +1307,7 @@ static int insert_text_exec(bContext *C, wmOperator *op) if (!RNA_struct_property_is_set(op->ptr, "text")) return OPERATOR_CANCELLED; - + inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0); len = BLI_strlen_utf8(inserted_utf8); @@ -1345,7 +1345,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) accentcode = 1; return OPERATOR_FINISHED; } - + /* tab should exit editmode, but we allow it to be typed using modifier keys */ if (event_type == TABKEY) { if ((alt || ctrl || shift) == 0) @@ -1353,7 +1353,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) else ascii = 9; } - + if (event_type == BACKSPACEKEY) { if (alt && ef->len != 0 && ef->pos > 0) accentcode = 1; @@ -1389,7 +1389,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) else { BLI_assert(0); } - + kill_selection(obedit, 1); text_update_edited(C, obedit, FO_EDIT); } @@ -1413,7 +1413,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* reset property? */ if (event_val == 0) accentcode = 0; - + return OPERATOR_FINISHED; } @@ -1423,12 +1423,12 @@ void FONT_OT_text_insert(wmOperatorType *ot) ot->name = "Insert Text"; ot->description = "Insert text at cursor position"; ot->idname = "FONT_OT_text_insert"; - + /* api callbacks */ ot->exec = insert_text_exec; ot->invoke = insert_text_invoke; ot->poll = ED_operator_editfont; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1444,14 +1444,14 @@ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_active_object(C); Curve *cu = obedit->data; int i; - + if (cu->totbox < 256) { for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1]; cu->tb[cu->actbox] = cu->tb[cu->actbox - 1]; cu->actbox++; cu->totbox++; } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -1462,15 +1462,15 @@ void FONT_OT_textbox_add(wmOperatorType *ot) ot->name = "Add Textbox"; ot->description = "Add a new text box"; ot->idname = "FONT_OT_textbox_add"; - + /* api callbacks */ ot->exec = textbox_add_exec; ot->poll = ED_operator_object_active_editable_font; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - + + } @@ -1485,17 +1485,17 @@ static int textbox_remove_exec(bContext *C, wmOperator *op) Curve *cu = obedit->data; int i; int index = RNA_int_get(op->ptr, "index"); - - + + if (cu->totbox > 1) { for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1]; cu->totbox--; if (cu->actbox >= index) cu->actbox--; } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - + return OPERATOR_FINISHED; } @@ -1505,14 +1505,14 @@ void FONT_OT_textbox_remove(wmOperatorType *ot) ot->name = "Remove Textbox"; ot->description = "Remove the textbox"; ot->idname = "FONT_OT_textbox_remove"; - + /* api callbacks */ ot->exec = textbox_remove_exec; ot->poll = ED_operator_object_active_editable_font; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX); } @@ -1525,14 +1525,14 @@ void ED_curve_editfont_make(Object *obedit) Curve *cu = obedit->data; EditFont *ef = cu->editfont; int len_wchar; - + if (ef == NULL) { ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont"); - + ef->textbuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditbuf"); ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo"); } - + /* Convert the original text to wchar_t */ len_wchar = BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); BLI_assert(len_wchar == cu->len_wchar); @@ -1571,7 +1571,7 @@ void ED_curve_editfont_load(Object *obedit) /* Copy the wchar to UTF-8 */ BLI_strncpy_wchar_as_utf8(cu->str, ef->textbuf, cu->len + 1); - + if (cu->strinfo) MEM_freeN(cu->strinfo); cu->strinfo = MEM_callocN((cu->len_wchar + 4) * sizeof(CharInfo), "texteditinfo"); @@ -1603,7 +1603,7 @@ static int set_case(bContext *C, int ccase) wchar_t *str; int len; int selstart, selend; - + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { len = (selend - selstart) + 1; str = &ef->textbuf[selstart]; @@ -1643,7 +1643,7 @@ void FONT_OT_case_set(wmOperatorType *ot) ot->name = "Set Case"; ot->description = "Set font case"; ot->idname = "FONT_OT_case_set"; - + /* api callbacks */ ot->exec = set_case_exec; ot->poll = ED_operator_editfont; @@ -1664,7 +1664,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op)) EditFont *ef = cu->editfont; wchar_t *str; int len, ccase = CASE_UPPER; - + len = wcslen(ef->textbuf); str = ef->textbuf; while (len) { @@ -1676,7 +1676,7 @@ static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op)) len--; str++; } - + return set_case(C, ccase); } @@ -1686,7 +1686,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot) ot->name = "Toggle Case"; ot->description = "Toggle font case"; ot->idname = "FONT_OT_case_toggle"; - + /* api callbacks */ ot->exec = toggle_case_exec; ot->poll = ED_operator_editfont; @@ -1700,7 +1700,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot) static void font_ui_template_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; - + op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); UI_context_active_but_prop_get_templateID(C, &pprop->ptr, &pprop->prop); } @@ -1729,7 +1729,7 @@ static int font_open_exec(bContext *C, wmOperator *op) if (!op->customdata) font_ui_template_init(C, op); - + /* hook into UI */ pprop = op->customdata; @@ -1737,7 +1737,7 @@ static int font_open_exec(bContext *C, wmOperator *op) /* when creating new ID blocks, use is already 1, but RNA * pointer use also increases user, so this compensates it */ id_us_min(&font->id); - + RNA_id_pointer_create(&font->id, &idptr); RNA_property_pointer_set(&pprop->ptr, pprop->prop, idptr); RNA_property_update(C, &pprop->ptr, pprop->prop); @@ -1772,7 +1772,7 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event) return font_open_exec(C, op); RNA_string_set(op->ptr, "filepath", path); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -1783,15 +1783,15 @@ void FONT_OT_open(wmOperatorType *ot) ot->name = "Open Font"; ot->idname = "FONT_OT_open"; ot->description = "Load a new font from a file"; - + /* api callbacks */ ot->exec = font_open_exec; ot->invoke = open_invoke; ot->cancel = font_open_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_FTFONT, FILE_SPECIAL, FILE_OPENFILE, @@ -1808,7 +1808,7 @@ static int font_unlink_exec(bContext *C, wmOperator *op) PropertyPointerRNA pprop; UI_context_active_but_prop_get_templateID(C, &pprop.ptr, &pprop.prop); - + if (pprop.prop == NULL) { BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink"); return OPERATOR_CANCELLED; @@ -1829,7 +1829,7 @@ void FONT_OT_unlink(wmOperatorType *ot) ot->name = "Unlink"; ot->idname = "FONT_OT_unlink"; ot->description = "Unlink active font data-block"; - + /* api callbacks */ ot->exec = font_unlink_exec; } diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index b23b9a06fbb..338fac03fef 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -124,15 +124,15 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn { tGPspoint *pt; int i; - + /* error checking */ if ((points == NULL) || (totpoints <= 0)) return; - + /* check if buffer can be drawn */ if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; - + if (totpoints == 1) { /* if drawing a single point, draw it larger */ glPointSize((float)(thickness + 2) * points->pressure); @@ -146,13 +146,13 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn } else { float oldpressure = points[0].pressure; - + /* draw stroke curve */ if (G.debug & G_DEBUG) setlinestyle(2); - + glLineWidth(max_ff(oldpressure * thickness, 1.0)); glBegin(GL_LINE_STRIP); - + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) @@ -161,15 +161,15 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn glEnd(); glLineWidth(max_ff(pt->pressure * thickness, 1.0f)); glBegin(GL_LINE_STRIP); - + /* need to roll-back one point to ensure that there are no gaps in the stroke */ - if (i != 0) { + if (i != 0) { gp_set_color_and_tpoint((pt - 1), ink); } - + /* now the point we want... */ gp_set_color_and_tpoint(pt, ink); - + oldpressure = pt->pressure; } else { @@ -215,37 +215,37 @@ static void gp_draw_stroke_volumetric_buffer(tGPspoint *points, int totpoints, s { GLUquadricObj *qobj = gluNewQuadric(); float modelview[4][4]; - + tGPspoint *pt; int i; - + /* error checking */ if ((points == NULL) || (totpoints <= 0)) return; - + /* check if buffer can be drawn */ if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; - + /* get basic matrix - should be camera space (i.e "identity") */ glGetFloatv(GL_MODELVIEW_MATRIX, (float *)modelview); - + /* draw points */ glPushMatrix(); - + for (i = 0, pt = points; i < totpoints; i++, pt++) { /* set the transformed position */ // TODO: scale should change based on zoom level, which requires proper translation mult too! modelview[3][0] = pt->x; modelview[3][1] = pt->y; - + glLoadMatrixf((float *)modelview); - + /* draw the disk using the current state... */ gp_set_tpoint_color(pt, ink); gluDisk(qobj, 0.0, pt->pressure * thickness, 32, 1); - - + + modelview[3][0] = modelview[3][1] = 0.0f; } @@ -263,11 +263,11 @@ static void gp_draw_stroke_volumetric_2d(bGPDspoint *points, int totpoints, shor float modelview[4][4]; float baseloc[3]; float scalefac = 1.0f; - + bGPDspoint *pt; int i; float fpt[3]; - + /* HACK: We need a scale factor for the drawing in the image editor, * which seems to use 1 unit as it's maximum size, whereas everything * else assumes 1 unit = 1 pixel. Otherwise, we only get a massive blob. @@ -275,34 +275,34 @@ static void gp_draw_stroke_volumetric_2d(bGPDspoint *points, int totpoints, shor if ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) { scalefac = 0.001f; } - + /* get basic matrix */ glGetFloatv(GL_MODELVIEW_MATRIX, (float *)modelview); copy_v3_v3(baseloc, modelview[3]); - + /* draw points */ glPushMatrix(); - + for (i = 0, pt = points; i < totpoints; i++, pt++) { /* color of point */ gp_set_point_color(pt, ink); /* set the transformed position */ float co[2]; - + mul_v3_m4v3(fpt, diff_mat, &pt->x); gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co); translate_m4(modelview, co[0], co[1], 0.0f); - + glLoadMatrixf((float *)modelview); - + /* draw the disk using the current state... */ gluDisk(qobj, 0.0, pt->pressure * thickness * scalefac, 32, 1); - + /* restore matrix */ copy_v3_v3(modelview[3], baseloc); } - + glPopMatrix(); gluDeleteQuadric(qobj); } @@ -313,18 +313,18 @@ static void gp_draw_stroke_volumetric_3d( short UNUSED(dflag), short UNUSED(sflag), float diff_mat[4][4], float ink[4]) { GLUquadricObj *qobj = gluNewQuadric(); - + float base_modelview[4][4], modelview[4][4]; float base_loc[3]; - + bGPDspoint *pt; int i; float fpt[3]; - + /* Get the basic modelview matrix we use for performing calculations */ glGetFloatv(GL_MODELVIEW_MATRIX, (float *)base_modelview); copy_v3_v3(base_loc, base_modelview[3]); - + /* Create the basic view-aligned billboard matrix we're going to actually draw qobj with: * - We need to knock out the rotation so that we are * simply left with a camera-facing billboard @@ -333,10 +333,10 @@ static void gp_draw_stroke_volumetric_3d( * large! */ scale_m4_fl(modelview, 0.1f); - + /* draw each point as a disk... */ glPushMatrix(); - + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* color of point */ gp_set_point_color(pt, ink); @@ -345,21 +345,21 @@ static void gp_draw_stroke_volumetric_3d( /* apply translation to base_modelview, so that the translated point is put in the right place */ translate_m4(base_modelview, fpt[0], fpt[1], fpt[2]); - + /* copy the translation component to the billboard matrix we're going to use, * then reset the base matrix to the original values so that we can do the same * for the next point without accumulation/pollution effects */ copy_v3_v3(modelview[3], base_modelview[3]); /* copy offset value */ copy_v3_v3(base_modelview[3], base_loc); /* restore */ - + /* apply our billboard matrix for drawing... */ glLoadMatrixf((float *)modelview); - + /* draw the disk using the current state... */ gluDisk(qobj, 0.0, pt->pressure * thickness, 32, 1); } - + glPopMatrix(); gluDeleteQuadric(qobj); } @@ -373,40 +373,40 @@ static void gp_stroke_2d_flat(bGPDspoint *points, int totpoints, float(*points2d bGPDspoint *pt0 = &points[0]; bGPDspoint *pt1 = &points[1]; bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)]; - + float locx[3]; float locy[3]; float loc3[3]; float normal[3]; - + /* local X axis (p0 -> p1) */ sub_v3_v3v3(locx, &pt1->x, &pt0->x); - + /* point vector at 3/4 */ sub_v3_v3v3(loc3, &pt3->x, &pt0->x); - + /* vector orthogonal to polygon plane */ cross_v3_v3v3(normal, locx, loc3); - + /* local Y axis (cross to normal/x axis) */ cross_v3_v3v3(locy, normal, locx); - + /* Normalize vectors */ normalize_v3(locx); normalize_v3(locy); - + /* Get all points in local space */ for (int i = 0; i < totpoints; i++) { bGPDspoint *pt = &points[i]; float loc[3]; - + /* Get local space using first point as origin */ sub_v3_v3v3(loc, &pt->x, &pt0->x); - + points2d[i][0] = dot_v3v3(loc, locx); points2d[i][1] = dot_v3v3(loc, locy); } - + /* Concave (-1), Convex (1), or Autodetect (0)? */ *r_direction = (int)locy[2]; } @@ -416,14 +416,14 @@ static void gp_stroke_2d_flat(bGPDspoint *points, int totpoints, float(*points2d static void gp_triangulate_stroke_fill(bGPDstroke *gps) { BLI_assert(gps->totpoints >= 3); - + /* allocate memory for temporary areas */ gps->tot_triangles = gps->totpoints - 2; unsigned int (*tmp_triangles)[3] = MEM_mallocN(sizeof(*tmp_triangles) * gps->tot_triangles, "GP Stroke temp triangulation"); float (*points2d)[2] = MEM_mallocN(sizeof(*points2d) * gps->totpoints, "GP Stroke temp 2d points"); - + int direction = 0; - + /* convert to 2d and triangulate */ gp_stroke_2d_flat(gps->points, gps->totpoints, points2d, &direction); BLI_polyfill_calc(points2d, (unsigned int)gps->totpoints, direction, tmp_triangles); @@ -438,7 +438,7 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps) else { gps->triangles = MEM_recallocN(gps->triangles, sizeof(*gps->triangles) * gps->tot_triangles); } - + for (int i = 0; i < gps->tot_triangles; i++) { bGPDtriangle *stroke_triangle = &gps->triangles[i]; memcpy(stroke_triangle->verts, tmp_triangles[i], sizeof(uint[3])); @@ -448,15 +448,15 @@ static void gp_triangulate_stroke_fill(bGPDstroke *gps) /* No triangles needed - Free anything allocated previously */ if (gps->triangles) MEM_freeN(gps->triangles); - + gps->triangles = NULL; } - + /* disable recalculation flag */ if (gps->flag & GP_STROKE_RECALC_CACHES) { gps->flag &= ~GP_STROKE_RECALC_CACHES; } - + /* clear memory */ if (tmp_triangles) MEM_freeN(tmp_triangles); if (points2d) MEM_freeN(points2d); @@ -556,7 +556,7 @@ static void gp_draw_stroke_point( /* set point thickness (since there's only one of these) */ glPointSize((float)(thickness + 2) * points->pressure); - + /* get final position using parent matrix */ mul_v3_m4v3(fpt, diff_mat, &pt->x); @@ -568,10 +568,10 @@ static void gp_draw_stroke_point( } else { float co[2]; - + /* get coordinates of point */ gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, co); - + /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok * - also mandatory in if Image Editor 'image-based' dot */ @@ -585,14 +585,14 @@ static void gp_draw_stroke_point( else { /* draw filled circle as is done in circf (but without the matrix push/pops which screwed things up) */ GLUquadricObj *qobj = gluNewQuadric(); - + gluQuadricDrawStyle(qobj, GLU_FILL); - + /* need to translate drawing position, but must reset after too! */ glTranslate2fv(co); gluDisk(qobj, 0.0, thickness, 32, 1); glTranslatef(-co[0], -co[1], 0.0); - + gluDeleteQuadric(qobj); } } @@ -623,14 +623,14 @@ static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness curpressure = pt->pressure; glLineWidth(max_ff(curpressure * thickness, 1.0f)); glBegin(GL_LINE_STRIP); - + /* need to roll-back one point to ensure that there are no gaps in the stroke */ - if (i != 0) { + if (i != 0) { pt2 = pt - 1; mul_v3_m4v3(fpt, diff_mat, &pt2->x); glVertex3fv(fpt); } - + /* now the point we want... */ mul_v3_m4v3(fpt, diff_mat, &pt->x); glVertex3fv(fpt); @@ -654,7 +654,7 @@ static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness /* XXX: for now, we represent "selected" strokes in the same way as debug, which isn't used anymore */ if (debug) { glPointSize((float)(thickness + 2)); - + glBegin(GL_POINTS); for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { mul_v3_m4v3(fpt, diff_mat, &pt->x); @@ -673,13 +673,13 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness { /* otherwise thickness is twice that of the 3D view */ float thickness = (float)thickness_s * 0.5f; - + /* strokes in Image Editor need a scale factor, since units there are not pixels! */ float scalefac = 1.0f; if ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) { scalefac = 0.001f; } - + /* tessellation code - draw stroke as series of connected quads with connection * edges rotated to minimize shrinking artifacts, and rounded endcaps */ @@ -689,7 +689,7 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness float pm[2]; /* normal from previous segment. */ int i; float fpt[3]; - + glShadeModel(GL_FLAT); glBegin(GL_QUADS); @@ -706,17 +706,17 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness /* get x and y coordinates from point2 (point1 has already been computed in previous iteration). */ mul_v3_m4v3(fpt, diff_mat, &pt2->x); gp_calc_2d_stroke_fxy(fpt, sflag, offsx, offsy, winx, winy, s1); - + /* calculate gradient and normal - 'angle'=(ny/nx) */ m1[1] = s1[1] - s0[1]; m1[0] = s1[0] - s0[0]; normalize_v2(m1); m2[1] = -m1[0]; m2[0] = m1[1]; - + /* always use pressure from first point here */ pthick = (pt1->pressure * thickness * scalefac); - + /* color of point */ gp_set_point_color(pt1, ink); @@ -729,24 +729,24 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness mt[1] = m2[1] * pthick * 0.5f; sc[0] = s0[0] - (m1[0] * pthick * 0.75f); sc[1] = s0[1] - (m1[1] * pthick * 0.75f); - + t0[0] = sc[0] - mt[0]; t0[1] = sc[1] - mt[1]; t1[0] = sc[0] + mt[0]; t1[1] = sc[1] + mt[1]; - + glVertex2fv(t0); glVertex2fv(t1); - + /* calculate points for start of segment */ mt[0] = m2[0] * pthick; mt[1] = m2[1] * pthick; - + t0[0] = s0[0] - mt[0]; t0[1] = s0[1] - mt[1]; t1[0] = s0[0] + mt[0]; t1[1] = s0[1] + mt[1]; - + /* draw this line twice (first to finish off start cap, then for stroke) */ glVertex2fv(t1); glVertex2fv(t0); @@ -757,12 +757,12 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness else { float mb[2]; /* bisector normal */ float athick, dfac; /* actual thickness, difference between thicknesses */ - + /* calculate gradient of bisector (as average of normals) */ mb[0] = (pm[0] + m2[0]) / 2; mb[1] = (pm[1] + m2[1]) / 2; normalize_v2(mb); - + /* calculate gradient to apply * - as basis, use just pthick * bisector gradient * - if cross-section not as thick as it should be, add extra padding to fix it @@ -771,49 +771,49 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness mt[1] = mb[1] * pthick; athick = len_v2(mt); dfac = pthick - (athick * 2); - + if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); } - + /* calculate points for start of segment */ t0[0] = s0[0] - mt[0]; t0[1] = s0[1] - mt[1]; t1[0] = s0[0] + mt[0]; t1[1] = s0[1] + mt[1]; - + /* draw this line twice (once for end of current segment, and once for start of next) */ glVertex2fv(t1); glVertex2fv(t0); glVertex2fv(t0); glVertex2fv(t1); } - + /* if last segment, also draw end of segment (defined as segment's normal) */ if (i == totpoints - 2) { /* for once, we use second point's pressure (otherwise it won't be drawn) */ pthick = (pt2->pressure * thickness * scalefac); - + /* color of point */ gp_set_point_color(pt2, ink); /* calculate points for end of segment */ mt[0] = m2[0] * pthick; mt[1] = m2[1] * pthick; - + t0[0] = s1[0] - mt[0]; t0[1] = s1[1] - mt[1]; t1[0] = s1[0] + mt[0]; t1[1] = s1[1] + mt[1]; - + /* draw this line twice (once for end of stroke, and once for endcap)*/ glVertex2fv(t1); glVertex2fv(t0); glVertex2fv(t0); glVertex2fv(t1); - - + + /* draw end cap as last step * - make points slightly closer to center (about halfway across) */ @@ -821,26 +821,26 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness mt[1] = m2[1] * pthick * 0.5f; sc[0] = s1[0] + (m1[0] * pthick * 0.75f); sc[1] = s1[1] + (m1[1] * pthick * 0.75f); - + t0[0] = sc[0] - mt[0]; t0[1] = sc[1] - mt[1]; t1[0] = sc[0] + mt[0]; t1[1] = sc[1] + mt[1]; - + glVertex2fv(t1); glVertex2fv(t0); } - + /* store computed point2 coordinates as point1 ones of next segment. */ copy_v2_v2(s0, s1); /* store stroke's 'natural' normal for next stroke to use */ copy_v2_v2(pm, m2); } - + glEnd(); glShadeModel(GL_SMOOTH); } - + /* draw debug points of curve on top? (original stroke points) */ if (debug) { bGPDspoint *pt; @@ -848,7 +848,7 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness float fpt[3]; glPointSize((float)(thickness_s + 2)); - + glBegin(GL_POINTS); for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { float co[2]; @@ -871,24 +871,24 @@ static bool gp_can_draw_stroke(const bGPDstroke *gps, const int dflag) return false; if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) return false; - + /* 2) Screen Space 2D Strokes */ if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) return false; if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) return false; - + /* 3) Image Space (2D) */ if ((dflag & GP_DRAWDATA_ONLYI2D) && !(gps->flag & GP_STROKE_2DIMAGE)) return false; if (!(dflag & GP_DRAWDATA_ONLYI2D) && (gps->flag & GP_STROKE_2DIMAGE)) return false; - - + + /* skip stroke if it doesn't have any valid data */ if ((gps->points == NULL) || (gps->totpoints < 1)) return false; - + /* stroke can be drawn */ return true; } @@ -1073,7 +1073,7 @@ static void gp_draw_strokes_edit( short lflag, float diff_mat[4][4], float alpha) { bGPDstroke *gps; - + /* if alpha 0 do not draw */ if (alpha == 0.0f) return; @@ -1087,7 +1087,7 @@ static void gp_draw_strokes_edit( glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); glDepthMask(0); glEnable(GL_DEPTH_TEST); - + /* first arg is normally rv3d->dist, but this isn't * available here and seems to work quite well without */ bglPolygonOffset(1.0f, 1.0f); @@ -1097,8 +1097,8 @@ static void gp_draw_strokes_edit( #endif } } - - + + /* draw stroke verts */ for (gps = gpf->strokes.first; gps; gps = gps->next) { bGPDspoint *pt; @@ -1109,14 +1109,14 @@ static void gp_draw_strokes_edit( /* check if stroke can be drawn */ if (gp_can_draw_stroke(gps, dflag) == false) continue; - + /* Optimisation: only draw points for selected strokes * We assume that selected points can only occur in * strokes that are selected too. */ if ((gps->flag & GP_STROKE_SELECT) == 0) continue; - + /* verify palette color lock */ { bGPDpalettecolor *palcolor = ED_gpencil_stroke_getcolor(gpd, gps); @@ -1143,7 +1143,7 @@ static void gp_draw_strokes_edit( else { vsize = bsize + 2; } - + /* First Pass: Draw all the verts (i.e. these become the unselected state) */ /* for now, we assume that the base color of the points is not too close to the real color */ /* set color using palette */ @@ -1151,7 +1151,7 @@ static void gp_draw_strokes_edit( glColor3fv(palcolor->color); glPointSize(bsize); - + glBegin(GL_POINTS); for (i = 0, pt = gps->points; i < gps->totpoints && pt; i++, pt++) { if (gps->flag & GP_STROKE_3DSPACE) { @@ -1166,15 +1166,15 @@ static void gp_draw_strokes_edit( } } glEnd(); - - + + /* Second Pass: Draw only verts which are selected */ float curColor[4]; UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, curColor); glColor4f(curColor[0], curColor[1], curColor[2], alpha); glPointSize(vsize); - + glBegin(GL_POINTS); for (i = 0, pt = gps->points; i < gps->totpoints && pt; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) { @@ -1184,7 +1184,7 @@ static void gp_draw_strokes_edit( } else { float co[2]; - + mul_v3_m4v3(fpt, diff_mat, &pt->x); gp_calc_2d_stroke_fxy(fpt, gps->flag, offsx, offsy, winx, winy, co); glVertex2fv(co); @@ -1196,7 +1196,7 @@ static void gp_draw_strokes_edit( /* Draw start and end point if enabled stroke direction hint */ if ((gpd->flag & GP_DATA_SHOW_DIRECTION) && (gps->totpoints > 1)) { bGPDspoint *p; - + glPointSize(vsize + 4); glBegin(GL_POINTS); @@ -1218,14 +1218,14 @@ static void gp_draw_strokes_edit( glEnd(); } } - - + + /* clear depth mask */ if (dflag & GP_DRAWDATA_ONLY3D) { if (no_xray) { glDepthMask(mask_orig); glDisable(GL_DEPTH_TEST); - + bglPolygonOffset(0.0, 0.0); #if 0 glDisable(GL_POLYGON_OFFSET_LINE); @@ -1253,11 +1253,11 @@ static void gp_draw_onionskins( else { copy_v3_v3(color, default_color); } - + if (gpl->gstep > 0) { bGPDframe *gf; float fac; - + /* draw previous frames first */ for (gf = gpf->prev; gf; gf = gf->prev) { /* check if frame is drawable */ @@ -1283,8 +1283,8 @@ static void gp_draw_onionskins( else { /* don't draw - disabled */ } - - + + /* 2) Now draw next frames */ if (gpl->flag & GP_LAYER_GHOST_NEXTCOL) { copy_v3_v3(color, gpl->gcolor_next); @@ -1292,11 +1292,11 @@ static void gp_draw_onionskins( else { copy_v3_v3(color, default_color); } - + if (gpl->gstep_next > 0) { bGPDframe *gf; float fac; - + /* now draw next frames */ for (gf = gpf->next; gf; gf = gf->next) { /* check if frame is drawable */ @@ -1322,7 +1322,7 @@ static void gp_draw_onionskins( else { /* don't draw - disabled */ } - + } /* draw interpolate strokes (used only while operator is running) */ @@ -1339,7 +1339,7 @@ void ED_gp_draw_interpolation(tGPDinterpolate *tgpi, const int type) UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, color); color[3] = 0.6f; - int dflag = 0; + int dflag = 0; /* if 3d stuff, enable flags */ if (type == REGION_DRAW_POST_VIEW) { dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); @@ -1373,19 +1373,19 @@ static void gp_draw_data_layers( bool debug = (gpl->flag & GP_LAYER_DRAWDEBUG) ? true : false; short lthick = brush->thickness + gpl->thickness; - + /* don't draw layer if hidden */ if (gpl->flag & GP_LAYER_HIDE) continue; - + /* get frame to draw */ gpf = BKE_gpencil_layer_getframe(gpl, cfra, 0); if (gpf == NULL) continue; - + /* set basic stroke thickness */ glLineWidth(lthick); - + /* Add layer drawing settings to the set of "draw flags" * NOTE: If the setting doesn't apply, it *must* be cleared, * as dflag's carry over from the previous layer @@ -1394,10 +1394,10 @@ static void gp_draw_data_layers( if (condition) dflag |= (draw_flag_value); \ else dflag &= ~(draw_flag_value); \ } (void)0 - + /* xray... */ GP_DRAWFLAG_APPLY((gpl->flag & GP_LAYER_NO_XRAY), GP_DRAWDATA_NO_XRAY); - + /* volumetric strokes... */ GP_DRAWFLAG_APPLY((gpl->flag & GP_LAYER_VOLUMETRIC), GP_DRAWDATA_VOLUMETRIC); @@ -1405,7 +1405,7 @@ static void gp_draw_data_layers( GP_DRAWFLAG_APPLY((gpl->flag & GP_LAYER_HQ_FILL), GP_DRAWDATA_HQ_FILL); #undef GP_DRAWFLAG_APPLY - + /* Draw 'onionskins' (frame left + right) * - It is only possible to show these if the option is enabled * - The "no onions" flag prevents ghosts from appearing during animation playback/scrubbing @@ -1413,19 +1413,19 @@ static void gp_draw_data_layers( * - The per-layer "always show" flag however overrides the playback/render restriction, * allowing artists to selectively turn onionskins on/off during playback */ - if ((gpl->flag & GP_LAYER_ONIONSKIN) && - ((dflag & GP_DRAWDATA_NO_ONIONS) == 0 || (gpl->flag & GP_LAYER_GHOST_ALWAYS))) + if ((gpl->flag & GP_LAYER_ONIONSKIN) && + ((dflag & GP_DRAWDATA_NO_ONIONS) == 0 || (gpl->flag & GP_LAYER_GHOST_ALWAYS))) { /* Drawing method - only immediately surrounding (gstep = 0), * or within a frame range on either side (gstep > 0) */ gp_draw_onionskins(gpd, gpl, gpf, offsx, offsy, winx, winy, cfra, dflag, debug, diff_mat); } - + /* draw the strokes already in active frame */ gp_draw_strokes(gpd, gpf, offsx, offsy, winx, winy, dflag, debug, gpl->thickness, gpl->opacity, gpl->tintcolor, false, false, diff_mat); - + /* Draw verts of selected strokes * - when doing OpenGL renders, we don't want to be showing these, as that ends up flickering * - locked layers can't be edited, so there's no point showing these verts @@ -1440,7 +1440,7 @@ static void gp_draw_data_layers( { gp_draw_strokes_edit(gpd, gpf, offsx, offsy, winx, winy, dflag, gpl->flag, diff_mat, alpha); } - + /* Check if may need to draw the active stroke cache, only if this layer is the active layer * that is being edited. (Stroke buffer is currently stored in gp-data) */ @@ -1449,10 +1449,10 @@ static void gp_draw_data_layers( { /* Set color for drawing buffer stroke - since this may not be set yet */ // glColor4fv(gpl->color); - + /* Buffer stroke needs to be drawn with a different linestyle * to help differentiate them from normal strokes. - * + * * It should also be noted that sbuffer contains temporary point types * i.e. tGPspoints NOT bGPDspoints */ @@ -1471,25 +1471,25 @@ static void gp_draw_data_layers( static void gp_draw_status_text(bGPdata *gpd, ARegion *ar) { rcti rect; - + /* Cannot draw any status text when drawing OpenGL Renders */ if (G.f & G_RENDER_OGL) return; - + /* Get bounds of region - Necessary to avoid problems with region overlap */ ED_region_visible_rect(ar, &rect); - + /* for now, this should only be used to indicate when we are in stroke editmode */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { const char *printable = IFACE_("GPencil Stroke Editing"); float printable_size[2]; int xco, yco; - + BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]); - + xco = (rect.xmax - U.widget_unit) - (int)printable_size[0]; yco = (rect.ymax - U.widget_unit); - + /* text label */ UI_ThemeColor(TH_TEXT_HI); #ifdef WITH_INTERNATIONAL @@ -1497,17 +1497,17 @@ static void gp_draw_status_text(bGPdata *gpd, ARegion *ar) #else BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX); #endif - + /* grease pencil icon... */ // XXX: is this too intrusive? glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + xco -= U.widget_unit; yco -= (int)printable_size[1] / 2; UI_icon_draw(xco, yco, ICON_GREASEPENCIL); - + glDisable(GL_BLEND); } } @@ -1519,26 +1519,26 @@ static void gp_draw_data( { /* reset line drawing style (in case previous user didn't reset) */ setlinestyle(0); - + /* turn on smooth lines (i.e. anti-aliasing) */ glEnable(GL_LINE_SMOOTH); - - /* XXX: turn on some way of ensuring that the polygon edges get smoothed + + /* XXX: turn on some way of ensuring that the polygon edges get smoothed * GL_POLYGON_SMOOTH is nasty and shouldn't be used, as it ends up * creating internal white rays due to the ways it accumulates stuff */ - + /* turn on alpha-blending */ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + /* draw! */ gp_draw_data_layers(brush, alpha, gpd, offsx, offsy, winx, winy, cfra, dflag); - + /* turn off alpha blending, then smooth lines */ glDisable(GL_BLEND); // alpha blending glDisable(GL_LINE_SMOOTH); // smooth lines - + /* restore initial gl conditions */ glColor4f(0, 0, 0, 1); } @@ -1575,7 +1575,7 @@ static void gp_draw_data_all(Scene *scene, bGPdata *gpd, int offsx, int offsy, i } } } - + /* scene/clip data has already been drawn, only object/track data is drawn here * if gpd_source == gpd, we don't have any object/track data and we can skip */ if (gpd_source == NULL || (gpd_source && gpd_source != gpd)) { @@ -1604,25 +1604,25 @@ void ED_gpencil_draw_2dimage(const bContext *C) bGPdata *gpd; int offsx, offsy, sizex, sizey; int dflag = GP_DRAWDATA_NOSTATUS; - + gpd = ED_gpencil_data_get_active(C); // XXX if (gpd == NULL) return; - + /* calculate rect */ switch (sa->spacetype) { case SPACE_IMAGE: /* image */ case SPACE_CLIP: /* clip */ { - + /* just draw using standard scaling (settings here are currently ignored anyways) */ /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ offsx = 0; offsy = 0; sizex = ar->winx; sizey = ar->winy; - + wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax); - + dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK; break; } @@ -1633,7 +1633,7 @@ void ED_gpencil_draw_2dimage(const bContext *C) offsy = 0; sizex = ar->winx; sizey = ar->winy; - + /* NOTE: I2D was used in 2.4x, but the old settings for that have been deprecated * and everything moved to standard View2d */ @@ -1645,19 +1645,19 @@ void ED_gpencil_draw_2dimage(const bContext *C) offsy = 0; sizex = ar->winx; sizey = ar->winy; - + dflag |= GP_DRAWDATA_ONLYI2D; break; } - + if (ED_screen_animation_playing(wm)) { /* don't show onionskins during animation playback/scrub (i.e. it obscures the poses) * OpenGL Renders (i.e. final output), or depth buffer (i.e. not real strokes) */ dflag |= GP_DRAWDATA_NO_ONIONS; } - - + + /* draw it! */ gp_draw_data_all(scene, gpd, offsx, offsy, sizex, sizey, CFRA, dflag, sa->spacetype); } @@ -1673,23 +1673,23 @@ void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d) Scene *scene = CTX_data_scene(C); bGPdata *gpd; int dflag = 0; - + /* check that we have grease-pencil stuff to draw */ if (sa == NULL) return; gpd = ED_gpencil_data_get_active(C); // XXX if (gpd == NULL) return; - + /* special hack for Image Editor */ /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) dflag |= GP_DRAWDATA_IEDITHACK; - + /* draw it! */ if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS); if (ED_screen_animation_playing(wm)) dflag |= GP_DRAWDATA_NO_ONIONS; - + gp_draw_data_all(scene, gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag, sa->spacetype); - + /* draw status text (if in screen/pixel-space) */ if (onlyv2d == false) { gp_draw_status_text(gpd, ar); @@ -1705,17 +1705,17 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm, Scene *scene, View3D *v3d, AReg int dflag = 0; RegionView3D *rv3d = ar->regiondata; int offsx, offsy, winx, winy; - + /* check that we have grease-pencil stuff to draw */ gpd = ED_gpencil_data_get_active_v3d(scene, v3d); if (gpd == NULL) return; - + /* when rendering to the offscreen buffer we don't want to * deal with the camera border, otherwise map the coords to the camera border. */ if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_RENDER_OGL)) { rctf rectf; ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &rectf, true); /* no shift */ - + offsx = round_fl_to_int(rectf.xmin); offsy = round_fl_to_int(rectf.ymin); winx = round_fl_to_int(rectf.xmax - rectf.xmin); @@ -1727,7 +1727,7 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm, Scene *scene, View3D *v3d, AReg winx = ar->winx; winy = ar->winy; } - + /* set flags */ if (only3d) { /* 3D strokes/3D space: @@ -1736,28 +1736,28 @@ void ED_gpencil_draw_view3d(wmWindowManager *wm, Scene *scene, View3D *v3d, AReg */ dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); } - + if (v3d->flag2 & V3D_RENDER_OVERRIDE) { /* don't draw status text when "only render" flag is set */ dflag |= GP_DRAWDATA_NOSTATUS; } - + if ((wm == NULL) || ED_screen_animation_playing(wm)) { /* don't show onionskins during animation playback/scrub (i.e. it obscures the poses) * OpenGL Renders (i.e. final output), or depth buffer (i.e. not real strokes) */ dflag |= GP_DRAWDATA_NO_ONIONS; } - + /* draw it! */ gp_draw_data_all(scene, gpd, offsx, offsy, winx, winy, CFRA, dflag, v3d->spacetype); - + } void ED_gpencil_draw_ex(Scene *scene, bGPdata *gpd, int winx, int winy, const int cfra, const char spacetype) { int dflag = GP_DRAWDATA_NOSTATUS | GP_DRAWDATA_ONLYV2D; - + gp_draw_data_all(scene, gpd, 0, 0, winx, winy, cfra, dflag, spacetype); } diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index 90d44503013..5e62a87caf3 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -66,18 +66,18 @@ bool ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDframe *, Scene *)) { bGPDframe *gpf; - + /* error checker */ if (gpl == NULL) return false; - + /* do loop */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* execute callback */ if (gpf_cb(gpf, scene)) return true; } - + /* nothing to return */ return false; } @@ -90,19 +90,19 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel) { bGPDframe *gpf; CfraElem *ce; - + /* error checking */ if (ELEM(NULL, gpl, elems)) return; - + /* loop through gp-frames, adding */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if ((onlysel == 0) || (gpf->flag & GP_FRAME_SELECT)) { ce = MEM_callocN(sizeof(CfraElem), "CfraElem"); - + ce->cfra = (float)gpf->framenum; ce->sel = (gpf->flag & GP_FRAME_SELECT) ? 1 : 0; - + BLI_addtail(elems, ce); } } @@ -115,17 +115,17 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel) bool ED_gplayer_frame_select_check(bGPDlayer *gpl) { bGPDframe *gpf; - + /* error checking */ if (gpl == NULL) return false; - + /* stop at the first one found */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (gpf->flag & GP_FRAME_SELECT) return true; } - + /* not found */ return false; } @@ -135,7 +135,7 @@ static void gpframe_select(bGPDframe *gpf, short select_mode) { if (gpf == NULL) return; - + switch (select_mode) { case SELECT_ADD: gpf->flag |= GP_FRAME_SELECT; @@ -153,11 +153,11 @@ static void gpframe_select(bGPDframe *gpf, short select_mode) void ED_gpencil_select_frames(bGPDlayer *gpl, short select_mode) { bGPDframe *gpf; - + /* error checking */ if (gpl == NULL) return; - + /* handle according to mode */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { gpframe_select(gpf, select_mode); @@ -170,7 +170,7 @@ void ED_gplayer_frame_select_set(bGPDlayer *gpl, short mode) /* error checking */ if (gpl == NULL) return; - + /* now call the standard function */ ED_gpencil_select_frames(gpl, mode); } @@ -179,12 +179,12 @@ void ED_gplayer_frame_select_set(bGPDlayer *gpl, short mode) void ED_gpencil_select_frame(bGPDlayer *gpl, int selx, short select_mode) { bGPDframe *gpf; - + if (gpl == NULL) return; - + gpf = BKE_gpencil_layer_find_frame(gpl, selx); - + if (gpf) { gpframe_select(gpf, select_mode); } @@ -194,10 +194,10 @@ void ED_gpencil_select_frame(bGPDlayer *gpl, int selx, short select_mode) void ED_gplayer_frames_select_border(bGPDlayer *gpl, float min, float max, short select_mode) { bGPDframe *gpf; - + if (gpl == NULL) return; - + /* only select those frames which are in bounds */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (IN_RANGE(gpf->framenum, min, max)) @@ -209,21 +209,21 @@ void ED_gplayer_frames_select_border(bGPDlayer *gpl, float min, float max, short void ED_gplayer_frames_select_region(KeyframeEditData *ked, bGPDlayer *gpl, short tool, short select_mode) { bGPDframe *gpf; - + if (gpl == NULL) return; - + /* only select frames which are within the region */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* construct a dummy point coordinate to do this testing with */ float pt[2] = {0}; - + pt[0] = gpf->framenum; pt[1] = ked->channel_y; - + /* check the necessary regions */ if (tool == BEZT_OK_CHANNEL_LASSO) { - /* Lasso */ + /* Lasso */ if (keyframe_region_lasso_test(ked->data, pt)) gpframe_select(gpf, select_mode); } @@ -243,21 +243,21 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl) { bGPDframe *gpf, *gpfn; bool changed = false; - + /* error checking */ if (gpl == NULL) return false; - + /* check for frames to delete */ for (gpf = gpl->frames.first; gpf; gpf = gpfn) { gpfn = gpf->next; - + if (gpf->flag & GP_FRAME_SELECT) { BKE_gpencil_layer_delframe(gpl, gpf); changed = true; } } - + return changed; } @@ -265,23 +265,23 @@ bool ED_gplayer_frames_delete(bGPDlayer *gpl) void ED_gplayer_frames_duplicate(bGPDlayer *gpl) { bGPDframe *gpf, *gpfn; - + /* error checking */ if (gpl == NULL) return; - + /* duplicate selected frames */ for (gpf = gpl->frames.first; gpf; gpf = gpfn) { gpfn = gpf->next; - + /* duplicate this frame */ if (gpf->flag & GP_FRAME_SELECT) { bGPDframe *gpfd; - + /* duplicate frame, and deselect self */ gpfd = BKE_gpencil_frame_duplicate(gpf); gpf->flag &= ~GP_FRAME_SELECT; - + BLI_insertlinkafter(&gpl->frames, gpf, gpfd); } } @@ -293,10 +293,10 @@ void ED_gplayer_frames_duplicate(bGPDlayer *gpl) void ED_gplayer_frames_keytype_set(bGPDlayer *gpl, short type) { bGPDframe *gpf; - + if (gpl == NULL) return; - + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (gpf->flag & GP_FRAME_SELECT) { gpf->key_type = type; @@ -327,7 +327,7 @@ void ED_gpencil_anim_copybuf_free(void) { BKE_gpencil_free_layers(&gp_anim_copybuf); BLI_listbase_clear(&gp_anim_copybuf); - + gp_anim_copy_firstframe = 999999999; gp_anim_copy_lastframe = -999999999; gp_anim_copy_cfra = 0; @@ -344,23 +344,23 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; - - + + /* clear buffer first */ ED_gpencil_anim_copybuf_free(); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* assume that each of these is a GP layer */ for (ale = anim_data.first; ale; ale = ale->next) { ListBase copied_frames = {NULL, NULL}; bGPDlayer *gpl = (bGPDlayer *)ale->data; bGPDframe *gpf; - + /* loop over frames, and copy only selected frames */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* if frame is selected, make duplicate it and its strokes */ @@ -368,41 +368,41 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac) /* make a copy of this frame */ bGPDframe *new_frame = BKE_gpencil_frame_duplicate(gpf); BLI_addtail(&copied_frames, new_frame); - + /* extend extents for keyframes encountered */ if (gpf->framenum < gp_anim_copy_firstframe) - gp_anim_copy_firstframe = gpf->framenum; + gp_anim_copy_firstframe = gpf->framenum; if (gpf->framenum > gp_anim_copy_lastframe) gp_anim_copy_lastframe = gpf->framenum; } } - + /* create a new layer in buffer if there were keyframes here */ if (BLI_listbase_is_empty(&copied_frames) == false) { bGPDlayer *new_layer = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); BLI_addtail(&gp_anim_copybuf, new_layer); - + /* move over copied frames */ BLI_movelisttolist(&new_layer->frames, &copied_frames); BLI_assert(copied_frames.first == NULL); - + /* make a copy of the layer's name - for name-based matching later... */ BLI_strncpy(new_layer->info, gpl->info, sizeof(new_layer->info)); } } - + /* in case 'relative' paste method is used */ gp_anim_copy_cfra = CFRA; - + /* clean up */ ANIM_animdata_freelist(&anim_data); - + /* check if anything ended up in the buffer */ if (ELEM(NULL, gp_anim_copybuf.first, gp_anim_copybuf.last)) { BKE_report(ac->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer"); return false; } - + /* report success */ return true; } @@ -414,22 +414,22 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; bool no_name = false; int offset = 0; - + /* check if buffer is empty */ if (BLI_listbase_is_empty(&gp_anim_copybuf)) { BKE_report(ac->reports, RPT_ERROR, "No data in buffer to paste"); return false; } - + /* check if single channel in buffer (disregard names if so) */ if (gp_anim_copybuf.first == gp_anim_copybuf.last) { no_name = true; } - + /* methods of offset (eKeyPasteOffset) */ switch (offset_mode) { case KEYFRAME_PASTE_OFFSET_CFRA_START: @@ -446,19 +446,19 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) break; } - + /* filter data */ // TODO: try doing it with selection, then without selection imits filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* from selected channels */ for (ale = anim_data.first; ale; ale = ale->next) { bGPDlayer *gpld = (bGPDlayer *)ale->data; bGPDlayer *gpls = NULL; bGPDframe *gpfs, *gpf; - - + + /* find suitable layer from buffer to use to paste from */ for (gpls = gp_anim_copybuf.first; gpls; gpls = gpls->next) { /* check if layer name matches */ @@ -466,21 +466,21 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) break; } } - + /* this situation might occur! */ if (gpls == NULL) continue; - + /* add frames from buffer */ for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) { /* temporarily apply offset to buffer-frame while copying */ gpfs->framenum += offset; - + /* get frame to copy data into (if no frame returned, then just ignore) */ gpf = BKE_gpencil_layer_getframe(gpld, gpfs->framenum, 1); if (gpf) { bGPDstroke *gps, *gpsn; - + /* This should be the right frame... as it may be a pre-existing frame, * must make sure that only compatible stroke types get copied over * - We cannot just add a duplicate frame, as that would cause errors @@ -495,19 +495,19 @@ bool ED_gpencil_anim_copybuf_paste(bAnimContext *ac, const short offset_mode) /* duplicate triangle information */ gpsn->triangles = MEM_dupallocN(gps->triangles); /* append stroke to frame */ - BLI_addtail(&gpf->strokes, gpsn); + BLI_addtail(&gpf->strokes, gpsn); } - + /* if no strokes (i.e. new frame) added, free gpf */ if (BLI_listbase_is_empty(&gpf->strokes)) BKE_gpencil_layer_delframe(gpld, gpf); } - + /* unapply offset from buffer-frame */ gpfs->framenum -= offset; } } - + /* clean up */ ANIM_animdata_freelist(&anim_data); return true; @@ -574,37 +574,37 @@ void ED_gplayer_snap_frames(bGPDlayer *gpl, Scene *scene, short mode) static short mirror_gpf_cframe(bGPDframe *gpf, Scene *scene) { int diff; - + if (gpf->flag & GP_FRAME_SELECT) { diff = CFRA - gpf->framenum; gpf->framenum = CFRA + diff; } - + return 0; } static short mirror_gpf_yaxis(bGPDframe *gpf, Scene *UNUSED(scene)) { int diff; - + if (gpf->flag & GP_FRAME_SELECT) { diff = -gpf->framenum; gpf->framenum = diff; } - + return 0; } static short mirror_gpf_xaxis(bGPDframe *gpf, Scene *UNUSED(scene)) { int diff; - + /* NOTE: since we can't really do this, we just do the same as for yaxis... */ if (gpf->flag & GP_FRAME_SELECT) { diff = -gpf->framenum; gpf->framenum = diff; } - + return 0; } @@ -613,7 +613,7 @@ static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene) static TimeMarker *marker; static short initialized = 0; int diff; - + /* In order for this mirror function to work without * any extra arguments being added, we use the case * of bezt==NULL to denote that we should find the @@ -621,7 +621,7 @@ static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene) * to use this way, as it will be set to null after * each cycle in which this is called. */ - + if (gpf) { /* mirroring time */ if ((gpf->flag & GP_FRAME_SELECT) && (marker)) { @@ -644,7 +644,7 @@ static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene) } } } - + return 0; } diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index 5fe16226421..c35b64de991 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -87,54 +87,54 @@ typedef struct tGP_BrushEditData { /* Current editor/region/etc. */ /* NOTE: This stuff is mainly needed to handle 3D view projection stuff... */ Scene *scene; - + ScrArea *sa; ARegion *ar; - + /* Current GPencil datablock */ bGPdata *gpd; - + /* Brush Settings */ GP_BrushEdit_Settings *settings; GP_EditBrush_Data *brush; - + eGP_EditBrush_Types brush_type; eGP_EditBrush_Flag flag; - + /* Space Conversion Data */ GP_SpaceConversion gsc; - - + + /* Is the brush currently painting? */ bool is_painting; - + /* Start of new sculpt stroke */ bool first; - + /* Current frame */ int cfra; - - + + /* Brush Runtime Data: */ /* - position and pressure * - the *_prev variants are the previous values */ int mval[2], mval_prev[2]; float pressure, pressure_prev; - + /* - effect vector (e.g. 2D/3D translation for grab brush) */ float dvec[3]; - + /* brush geometry (bounding box) */ rcti brush_rect; - + /* Custom data for certain brushes */ /* - map from bGPDstroke's to structs containing custom data about those strokes */ GHash *stroke_customdata; /* - general customdata */ void *customdata; - - + + /* Timer for in-place accumulation of brush effect */ wmTimer *timer; bool timerTick; /* is this event from a timer */ @@ -170,12 +170,12 @@ static bool gp_brush_invert_check(tGP_BrushEditData *gso) { /* The basic setting is the brush's setting (from the panel) */ bool invert = ((gso->brush->flag & GP_EDITBRUSH_FLAG_INVERT) != 0); - + /* During runtime, the user can hold down the Ctrl key to invert the basic behaviour */ if (gso->flag & GP_EDITBRUSH_FLAG_INVERT) { invert ^= true; } - + return invert; } @@ -183,26 +183,26 @@ static bool gp_brush_invert_check(tGP_BrushEditData *gso) static float gp_brush_influence_calc(tGP_BrushEditData *gso, const int radius, const int co[2]) { GP_EditBrush_Data *brush = gso->brush; - + /* basic strength factor from brush settings */ float influence = brush->strength; - + /* use pressure? */ if (brush->flag & GP_EDITBRUSH_FLAG_USE_PRESSURE) { influence *= gso->pressure; } - + /* distance fading */ if (brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) { float distance = (float)len_v2v2_int(gso->mval, co); float fac; - + CLAMP(distance, 0.0f, (float)radius); fac = 1.0f - (distance / (float)radius); - + influence *= fac; } - + /* return influence */ return influence; } @@ -241,7 +241,7 @@ static bool gp_brush_smooth_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i if (gso->settings->flag & GP_BRUSHEDIT_FLAG_APPLY_THICKNESS) { gp_smooth_stroke_thickness(gps, i, inf); } - + return true; } @@ -254,13 +254,13 @@ static bool gp_brush_thickness_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in { bGPDspoint *pt = gps->points + i; float inf; - + /* Compute strength of effect * - We divide the strength by 10, so that users can set "sane" values. * Otherwise, good default values are in the range of 0.093 */ inf = gp_brush_influence_calc(gso, radius, co) / 10.0f; - + /* apply */ // XXX: this is much too strong, and it should probably do some smoothing with the surrounding stuff if (gp_brush_invert_check(gso)) { @@ -271,7 +271,7 @@ static bool gp_brush_thickness_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in /* make line thicker - increase stroke pressure */ pt->pressure += inf; } - + /* Pressure should stay within [0.0, 1.0] * However, it is nice for volumetric strokes to be able to exceed * the upper end of this range. Therefore, we don't actually clamp @@ -279,7 +279,7 @@ static bool gp_brush_thickness_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in */ if (pt->pressure < 0.0f) pt->pressure = 0.0f; - + return true; } @@ -333,7 +333,7 @@ typedef struct tGPSB_Grab_StrokeData { int *points; /* array of influence weights for each of the included points */ float *weights; - + /* capacity of the arrays */ int capacity; /* actual number of items currently stored */ @@ -344,9 +344,9 @@ typedef struct tGPSB_Grab_StrokeData { static void gp_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps) { tGPSB_Grab_StrokeData *data = NULL; - + BLI_assert(gps->totpoints > 0); - + /* Check if there are buffers already (from a prior run) */ if (BLI_ghash_haskey(gso->stroke_customdata, gps)) { /* Ensure that the caches are empty @@ -355,25 +355,25 @@ static void gp_brush_grab_stroke_init(tGP_BrushEditData *gso, bGPDstroke *gps) */ data = BLI_ghash_lookup(gso->stroke_customdata, gps); BLI_assert(data != NULL); - + data->size = 0; /* minimum requirement - so that we can repopulate again */ - + memset(data->points, 0, sizeof(int) * data->capacity); memset(data->weights, 0, sizeof(float) * data->capacity); } else { /* Create new instance */ data = MEM_callocN(sizeof(tGPSB_Grab_StrokeData), "GP Stroke Grab Data"); - + data->capacity = gps->totpoints; data->size = 0; - + data->points = MEM_callocN(sizeof(int) * data->capacity, "GP Stroke Grab Indices"); data->weights = MEM_callocN(sizeof(float) * data->capacity, "GP Stroke Grab Weights"); - + /* hook up to the cache */ BLI_ghash_insert(gso->stroke_customdata, gps, data); - } + } } /* store references to stroke points in the initial stage */ @@ -382,15 +382,15 @@ static bool gp_brush_grab_store_points(tGP_BrushEditData *gso, bGPDstroke *gps, { tGPSB_Grab_StrokeData *data = BLI_ghash_lookup(gso->stroke_customdata, gps); float inf = gp_brush_influence_calc(gso, radius, co); - + BLI_assert(data != NULL); BLI_assert(data->size < data->capacity); - + /* insert this point into the set of affected points */ data->points[data->size] = i; data->weights[data->size] = inf; data->size++; - + /* done */ return true; } @@ -406,13 +406,13 @@ static void gp_brush_grab_calc_dvec(tGP_BrushEditData *gso) RegionView3D *rv3d = gso->ar->regiondata; float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d); float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); - + float mval_f[2]; - + /* convert from 2D screenspace to 3D... */ mval_f[0] = (float)(gso->mval[0] - gso->mval_prev[0]); mval_f[1] = (float)(gso->mval[1] - gso->mval_prev[1]); - + ED_view3d_win_to_delta(gso->ar, mval_f, gso->dvec, zfac); } else { @@ -435,7 +435,7 @@ static void gp_brush_grab_apply_cached( for (i = 0; i < data->size; i++) { bGPDspoint *pt = &gps->points[data->points[i]]; float delta[3] = {0.0f}; - + /* adjust the amount of displacement to apply */ mul_v3_v3fl(delta, gso->dvec, data->weights[i]); if (!parented) { @@ -454,7 +454,7 @@ static void gp_brush_grab_apply_cached( invert_m4_m4(inverse_diff_mat, diff_mat); mul_m4_v3(inverse_diff_mat, &pt->x); } - + } } @@ -462,11 +462,11 @@ static void gp_brush_grab_apply_cached( static void gp_brush_grab_stroke_free(void *ptr) { tGPSB_Grab_StrokeData *data = (tGPSB_Grab_StrokeData *)ptr; - + /* free arrays */ MEM_freeN(data->points); MEM_freeN(data->weights); - + /* ... and this item itself, since it was also allocated */ MEM_freeN(data); } @@ -481,10 +481,10 @@ static bool gp_brush_push_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i, bGPDspoint *pt = gps->points + i; float inf = gp_brush_influence_calc(gso, radius, co); float delta[3] = {0.0f}; - + /* adjust the amount of displacement to apply */ mul_v3_v3fl(delta, gso->dvec, inf); - + /* apply */ add_v3_v3(&pt->x, delta); @@ -506,12 +506,12 @@ static void gp_brush_calc_midpoint(tGP_BrushEditData *gso) RegionView3D *rv3d = gso->ar->regiondata; float *rvec = ED_view3d_cursor3d_get(gso->scene, v3d); float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); - + float mval_f[2] = {UNPACK2(gso->mval)}; float mval_prj[2]; float dvec[3]; - - + + if (ED_view3d_project_float_global(gso->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval_f); ED_view3d_win_to_delta(gso->ar, mval_f, dvec, zfac); @@ -537,17 +537,17 @@ static bool gp_brush_pinch_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i, bGPDspoint *pt = gps->points + i; float fac, inf; float vec[3]; - + /* Scale down standard influence value to get it more manageable... * - No damping = Unmanageable at > 0.5 strength * - Div 10 = Not enough effect * - Div 5 = Happy medium... (by trial and error) */ inf = gp_brush_influence_calc(gso, radius, co) / 5.0f; - + /* 1) Make this point relative to the cursor/midpoint (dvec) */ sub_v3_v3v3(vec, &pt->x, gso->dvec); - + /* 2) Shrink the distance by pulling the point towards the midpoint * (0.0 = at midpoint, 1 = at edge of brush region) * OR @@ -562,10 +562,10 @@ static bool gp_brush_pinch_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i, fac = 1.0f - (inf * inf); /* squared to temper the effect... */ } mul_v3_fl(vec, fac); - + /* 3) Translate back to original space, with the shrinkage applied */ add_v3_v3v3(&pt->x, gso->dvec, vec); - + /* done */ return true; } @@ -582,16 +582,16 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i, { bGPDspoint *pt = gps->points + i; float angle, inf; - + /* Angle to rotate by */ inf = gp_brush_influence_calc(gso, radius, co); angle = DEG2RADF(1.0f) * inf; - + if (gp_brush_invert_check(gso)) { /* invert angle that we rotate by */ angle *= -1; } - + /* Rotate in 2D or 3D space? */ if (gps->flag & GP_STROKE_3DSPACE) { /* Perform rotation in 3D space... */ @@ -599,13 +599,13 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i, float rmat[3][3]; float axis[3]; float vec[3]; - + /* Compute rotation matrix - rotate around view vector by angle */ negate_v3_v3(axis, rv3d->persinv[2]); normalize_v3(axis); - + axis_angle_normalized_to_mat3(rmat, axis, angle); - + /* Rotate point (no matrix-space transforms needed, as GP points are in world space) */ sub_v3_v3v3(vec, &pt->x, gso->dvec); /* make relative to center (center is stored in dvec) */ mul_m3_v3(rmat, vec); @@ -615,20 +615,20 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i, const float axis[3] = {0.0f, 0.0f, 1.0f}; float vec[3] = {0.0f}; float rmat[3][3]; - + /* Express position of point relative to cursor, ready to rotate */ // XXX: There is still some offset here, but it's close to working as expected... vec[0] = (float)(co[0] - gso->mval[0]); vec[1] = (float)(co[1] - gso->mval[1]); - + /* rotate point */ axis_angle_normalized_to_mat3(rmat, axis, angle); mul_m3_v3(rmat, vec); - + /* Convert back to screen-coordinates */ vec[0] += (float)gso->mval[0]; vec[1] += (float)gso->mval[1]; - + /* Map from screen-coordinates to final coordinate space */ if (gps->flag & GP_STROKE_2DSPACE) { View2D *v2d = gso->gsc.v2d; @@ -639,7 +639,7 @@ static bool gp_brush_twist_apply(tGP_BrushEditData *gso, bGPDstroke *gps, int i, copy_v2_v2(&pt->x, vec); } } - + /* done */ return true; } @@ -653,7 +653,7 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in const int radius, const int co[2]) { bGPDspoint *pt = gps->points + i; - + /* Amount of jitter to apply depends on the distance of the point to the cursor, * as well as the strength of the brush */ @@ -766,13 +766,13 @@ static bool gp_brush_randomize_apply(tGP_BrushEditData *gso, bGPDstroke *gps, in typedef struct tGPSB_CloneBrushData { /* midpoint of the strokes on the clipboard */ float buffer_midpoint[3]; - + /* number of strokes in the paste buffer (and/or to be created each time) */ size_t totitems; - + /* for "stamp" mode, the currently pasted brushes */ bGPDstroke **new_strokes; - + /* mapping from colors referenced per stroke, to the new colours in the "pasted" strokes */ GHash *new_colors; } tGPSB_CloneBrushData; @@ -782,43 +782,43 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso) { tGPSB_CloneBrushData *data; bGPDstroke *gps; - + /* init custom data */ gso->customdata = data = MEM_callocN(sizeof(tGPSB_CloneBrushData), "CloneBrushData"); - + /* compute midpoint of strokes on clipboard */ for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { const float dfac = 1.0f / ((float)gps->totpoints); float mid[3] = {0.0f}; - + bGPDspoint *pt; int i; - + /* compute midpoint of this stroke */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { float co[3]; - + mul_v3_v3fl(co, &pt->x, dfac); add_v3_v3(mid, co); } - + /* combine this stroke's data with the main data */ add_v3_v3(data->buffer_midpoint, mid); data->totitems++; } } - + /* Divide the midpoint by the number of strokes, to finish averaging it */ if (data->totitems > 1) { mul_v3_fl(data->buffer_midpoint, 1.0f / (float)data->totitems); } - + /* Create a buffer for storing the current strokes */ if (1 /*gso->brush->mode == GP_EDITBRUSH_CLONE_MODE_STAMP*/) { data->new_strokes = MEM_callocN(sizeof(bGPDstroke *) * data->totitems, "cloned strokes ptr array"); } - + /* Init colormap for mapping between the pasted stroke's source colour(names) * and the final colours that will be used here instead... */ @@ -829,19 +829,19 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso) static void gp_brush_clone_free(tGP_BrushEditData *gso) { tGPSB_CloneBrushData *data = gso->customdata; - + /* free strokes array */ if (data->new_strokes) { MEM_freeN(data->new_strokes); data->new_strokes = NULL; } - + /* free copybuf colormap */ if (data->new_colors) { BLI_ghash_free(data->new_colors, NULL, NULL); data->new_colors = NULL; } - + /* free the customdata itself */ MEM_freeN(data); gso->customdata = NULL; @@ -851,44 +851,44 @@ static void gp_brush_clone_free(tGP_BrushEditData *gso) static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) { tGPSB_CloneBrushData *data = gso->customdata; - + Scene *scene = gso->scene; bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); bGPDstroke *gps; - + float delta[3]; size_t strokes_added = 0; - + /* Compute amount to offset the points by */ /* NOTE: This assumes that screenspace strokes are NOT used in the 3D view... */ - + gp_brush_calc_midpoint(gso); /* this puts the cursor location into gso->dvec */ sub_v3_v3v3(delta, gso->dvec, data->buffer_midpoint); - + /* Copy each stroke into the layer */ for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { bGPDstroke *new_stroke; bGPDspoint *pt; int i; - + /* Make a new stroke */ new_stroke = MEM_dupallocN(gps); - + new_stroke->points = MEM_dupallocN(gps->points); new_stroke->triangles = MEM_dupallocN(gps->triangles); - + new_stroke->next = new_stroke->prev = NULL; BLI_addtail(&gpf->strokes, new_stroke); - + /* Fix color references */ BLI_assert(new_stroke->colorname[0] != '\0'); new_stroke->palcolor = BLI_ghash_lookup(data->new_colors, new_stroke->colorname); - + BLI_assert(new_stroke->palcolor != NULL); BLI_strncpy(new_stroke->colorname, new_stroke->palcolor->info, sizeof(new_stroke->colorname)); - + /* Adjust all the stroke's points, so that the strokes * get pasted relative to where the cursor is now */ @@ -896,7 +896,7 @@ static void gp_brush_clone_add(bContext *C, tGP_BrushEditData *gso) /* assume that the delta can just be applied, and then everything works */ add_v3_v3(&pt->x, delta); } - + /* Store ref for later */ if ((data->new_strokes) && (strokes_added < data->totitems)) { data->new_strokes[strokes_added] = new_stroke; @@ -911,31 +911,31 @@ static void gp_brush_clone_adjust(tGP_BrushEditData *gso) { tGPSB_CloneBrushData *data = gso->customdata; size_t snum; - + /* Compute the amount of movement to apply (overwrites dvec) */ gp_brush_grab_calc_dvec(gso); - + /* For each of the stored strokes, apply the offset to each point */ /* NOTE: Again this assumes that in the 3D view, we only have 3d space and not screenspace strokes... */ for (snum = 0; snum < data->totitems; snum++) { bGPDstroke *gps = data->new_strokes[snum]; bGPDspoint *pt; int i; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (gso->brush->flag & GP_EDITBRUSH_FLAG_USE_FALLOFF) { /* "Smudge" Effect when falloff is enabled */ float delta[3] = {0.0f}; int sco[2] = {0}; float influence; - + /* compute influence on point */ gp_point_to_xy(&gso->gsc, gps, pt, &sco[0], &sco[1]); influence = gp_brush_influence_calc(gso, gso->brush->size, sco); - + /* adjust the amount of displacement to apply */ mul_v3_v3fl(delta, gso->dvec, influence); - + /* apply */ add_v3_v3(&pt->x, delta); } @@ -967,7 +967,7 @@ static bool gpsculpt_brush_apply_clone(bContext *C, tGP_BrushEditData *gso) gp_brush_clone_add(C, gso); } } - + return true; } @@ -978,27 +978,27 @@ static bool gpsculpt_brush_apply_clone(bContext *C, tGP_BrushEditData *gso) static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata)) { GP_EditBrush_Data *brush = gpsculpt_get_brush(CTX_data_scene(C)); - + if (brush) { glPushMatrix(); - + glTranslatef((float)x, (float)y, 0.0f); - + glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + /* Inner Ring: Light color for action of the brush */ /* TODO: toggle between add and remove? */ glColor4ub(255, 255, 255, 200); glutil_draw_lined_arc(0.0, M_PI * 2.0, brush->size, 40); - + /* Outer Ring: Dark color for contrast on light backgrounds (e.g. gray on white) */ glColor3ub(30, 30, 30); glutil_draw_lined_arc(0.0, M_PI * 2.0, brush->size + 1, 40); - + glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); - + glPopMatrix(); } } @@ -1007,7 +1007,7 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customda static void gpencil_toggle_brush_cursor(bContext *C, bool enable) { GP_BrushEdit_Settings *gset = gpsculpt_get_settings(CTX_data_scene(C)); - + if (gset->paintcursor && !enable) { /* clear cursor */ WM_paint_cursor_end(CTX_wm_manager(C), gset->paintcursor); @@ -1015,8 +1015,8 @@ static void gpencil_toggle_brush_cursor(bContext *C, bool enable) } else if (enable) { /* enable cursor */ - gset->paintcursor = WM_paint_cursor_activate(CTX_wm_manager(C), - NULL, + gset->paintcursor = WM_paint_cursor_activate(CTX_wm_manager(C), + NULL, gp_brush_drawcursor, NULL); } } @@ -1029,15 +1029,15 @@ static void gpsculpt_brush_header_set(bContext *C, tGP_BrushEditData *gso) { const char *brush_name = NULL; char str[UI_MAX_DRAW_STR] = ""; - + RNA_enum_name(rna_enum_gpencil_sculpt_brush_items, gso->brush_type, &brush_name); - + BLI_snprintf(str, sizeof(str), IFACE_("GPencil Sculpt: %s Stroke | LMB to paint | RMB/Escape to Exit" " | Ctrl to Invert Action | Wheel Up/Down for Size " " | Shift-Wheel Up/Down for Strength"), (brush_name) ? brush_name : ""); - + ED_area_headerprint(CTX_wm_area(C), str); } @@ -1050,36 +1050,36 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); tGP_BrushEditData *gso; - + /* setup operator data */ gso = MEM_callocN(sizeof(tGP_BrushEditData), "tGP_BrushEditData"); op->customdata = gso; - + /* store state */ gso->settings = gpsculpt_get_settings(scene); gso->brush = gpsculpt_get_brush(scene); - + gso->brush_type = gso->settings->brushtype; - - + + gso->is_painting = false; gso->first = true; - + gso->gpd = ED_gpencil_data_get_active(C); gso->cfra = INT_MAX; /* NOTE: So that first stroke will get handled in init_stroke() */ - + gso->scene = scene; - + gso->sa = CTX_wm_area(C); gso->ar = CTX_wm_region(C); - + /* initialise custom data for brushes */ switch (gso->brush_type) { case GP_EDITBRUSH_TYPE_CLONE: { bGPDstroke *gps; bool found = false; - + /* check that there are some usable strokes in the buffer */ for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { @@ -1087,12 +1087,12 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) break; } } - + if (found == false) { /* STOP HERE! Nothing to paste! */ - BKE_report(op->reports, RPT_ERROR, + BKE_report(op->reports, RPT_ERROR, "Copy some strokes to the clipboard before using the Clone brush to paste copies of them"); - + MEM_freeN(gso); op->customdata = NULL; return false; @@ -1103,30 +1103,30 @@ static bool gpsculpt_brush_init(bContext *C, wmOperator *op) } break; } - + case GP_EDITBRUSH_TYPE_GRAB: { /* initialise the cache needed for this brush */ gso->stroke_customdata = BLI_ghash_ptr_new("GP Grab Brush - Strokes Hash"); break; } - + /* Others - No customdata needed */ default: break; } - - + + /* setup space conversions */ gp_point_conversion_init(C, &gso->gsc); - + /* update header */ gpsculpt_brush_header_set(C, gso); - + /* setup cursor drawing */ WM_cursor_modal_set(CTX_wm_window(C), BC_CROSSCURSOR); gpencil_toggle_brush_cursor(C, true); - + return true; } @@ -1134,7 +1134,7 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op) { tGP_BrushEditData *gso = op->customdata; wmWindow *win = CTX_wm_window(C); - + /* free brush-specific data */ switch (gso->brush_type) { case GP_EDITBRUSH_TYPE_GRAB: @@ -1146,18 +1146,18 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op) BLI_ghash_free(gso->stroke_customdata, NULL, gp_brush_grab_stroke_free); break; } - + case GP_EDITBRUSH_TYPE_CLONE: { /* Free customdata */ gp_brush_clone_free(gso); break; } - + default: break; } - + /* unregister timer (only used for realtime) */ if (gso->timer) { WM_event_remove_timer(CTX_wm_manager(C), win, gso->timer); @@ -1167,7 +1167,7 @@ static void gpsculpt_brush_exit(bContext *C, wmOperator *op) ED_area_headerprint(CTX_wm_area(C), NULL); WM_cursor_modal_restore(win); gpencil_toggle_brush_cursor(C, false); - + /* free operator data */ MEM_freeN(gso); op->customdata = NULL; @@ -1188,18 +1188,18 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso) bGPdata *gpd = gso->gpd; bGPDlayer *gpl; int cfra = CFRA; - + /* only try to add a new frame if this is the first stroke, or the frame has changed */ if ((gpd == NULL) || (cfra == gso->cfra)) return; - + /* go through each layer, and ensure that we've got a valid frame to use */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { bGPDframe *gpf = gpl->actframe; - - /* Make a new frame to work on if the layer's frame and the current scene frame don't match up + + /* Make a new frame to work on if the layer's frame and the current scene frame don't match up * - This is useful when animating as it saves that "uh-oh" moment when you realize you've * spent too much time editing the wrong frame... */ @@ -1209,7 +1209,7 @@ static void gpsculpt_brush_init_stroke(tGP_BrushEditData *gso) } } } - + /* save off new current frame, so that next update works fine */ gso->cfra = cfra; } @@ -1224,7 +1224,7 @@ static bool gpsculpt_brush_do_stroke( GP_SpaceConversion *gsc = &gso->gsc; rcti *rect = &gso->brush_rect; const int radius = gso->brush->size; - + bGPDspoint *pt1, *pt2; int pc1[2] = {0}; int pc2[2] = {0}; @@ -1241,7 +1241,7 @@ static bool gpsculpt_brush_do_stroke( gp_point_to_parent_space(gps->points, diff_mat, &pt_temp); gp_point_to_xy(gsc, gps, &pt_temp, &pc1[0], &pc1[1]); } - + /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, pc1[0], pc1[1])) && BLI_rcti_isect_pt(rect, pc1[0], pc1[1])) { /* only check if point is inside */ @@ -1252,14 +1252,14 @@ static bool gpsculpt_brush_do_stroke( } } else { - /* Loop over the points in the stroke, checking for intersections + /* Loop over the points in the stroke, checking for intersections * - an intersection means that we touched the stroke */ for (i = 0; (i + 1) < gps->totpoints; i++) { /* Get points to work with */ pt1 = gps->points + i; pt2 = gps->points + i + 1; - + /* Skip if neither one is selected (and we are only allowed to edit/consider selected points) */ if (gso->settings->flag & GP_BRUSHEDIT_FLAG_SELECT_MASK) { if (!(pt1->flag & GP_SPOINT_SELECT) && !(pt2->flag & GP_SPOINT_SELECT)) { @@ -1292,14 +1292,14 @@ static bool gpsculpt_brush_do_stroke( if (gp_stroke_inside_circle(gso->mval, gso->mval_prev, radius, pc1[0], pc1[1], pc2[0], pc2[1])) { /* Apply operation to these points */ bool ok = false; - + /* To each point individually... */ ok = apply(gso, gps, i, radius, pc1); - + /* Only do the second point if this is the last segment, * and it is unlikely that the point will get handled - * otherwise. - * + * otherwise. + * * NOTE: There is a small risk here that the second point wasn't really * actually in-range. In that case, it only got in because * the line linking the points was! @@ -1311,13 +1311,13 @@ static bool gpsculpt_brush_do_stroke( else { include_last = true; } - + changed |= ok; } else if (include_last) { /* This case is for cases where for whatever reason the second vert (1st here) doesn't get included * because the whole edge isn't in bounds, but it would've qualified since it did with the - * previous step (but wasn't added then, to avoid double-ups) + * previous step (but wasn't added then, to avoid double-ups) */ changed |= apply(gso, gps, i, radius, pc1); include_last = false; @@ -1325,7 +1325,7 @@ static bool gpsculpt_brush_do_stroke( } } } - + return changed; } @@ -1333,7 +1333,7 @@ static bool gpsculpt_brush_do_stroke( static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) { bool changed = false; - + /* Calculate brush-specific data which applies equally to all points */ switch (gso->brush_type) { case GP_EDITBRUSH_TYPE_GRAB: /* Grab points */ @@ -1343,7 +1343,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) gp_brush_grab_calc_dvec(gso); break; } - + case GP_EDITBRUSH_TYPE_PINCH: /* Pinch points */ case GP_EDITBRUSH_TYPE_TWIST: /* Twist points around midpoint */ { @@ -1351,19 +1351,19 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) gp_brush_calc_midpoint(gso); break; } - + case GP_EDITBRUSH_TYPE_RANDOMIZE: /* Random jitter */ { /* compute the displacement vector for the cursor (in data space) */ gp_brush_grab_calc_dvec(gso); break; } - + default: break; } - - + + /* Find visible strokes, and perform operations on those if hit */ float diff_mat[4][4]; bool parented = false; @@ -1373,7 +1373,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) bGPDframe *gpf = gpl->actframe; if (gpf == NULL) continue; - + /* calculate difference matrix if parent object */ if (gpl->parent != NULL) { ED_gpencil_parent_location(gpl, diff_mat); @@ -1382,7 +1382,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) else { parented = false; } - + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) @@ -1477,34 +1477,34 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt float mousef[2]; int mouse[2]; bool changed = false; - + /* Get latest mouse coordinates */ RNA_float_get_array(itemptr, "mouse", mousef); gso->mval[0] = mouse[0] = (int)(mousef[0]); gso->mval[1] = mouse[1] = (int)(mousef[1]); - + gso->pressure = RNA_float_get(itemptr, "pressure"); - + if (RNA_boolean_get(itemptr, "pen_flip")) gso->flag |= GP_EDITBRUSH_FLAG_INVERT; else gso->flag &= ~GP_EDITBRUSH_FLAG_INVERT; - - + + /* Store coordinates as reference, if operator just started running */ if (gso->first) { gso->mval_prev[0] = gso->mval[0]; gso->mval_prev[1] = gso->mval[1]; gso->pressure_prev = gso->pressure; } - + /* Update brush_rect, so that it represents the bounding rectangle of brush */ gso->brush_rect.xmin = mouse[0] - radius; gso->brush_rect.ymin = mouse[1] - radius; gso->brush_rect.xmax = mouse[0] + radius; gso->brush_rect.ymax = mouse[1] + radius; - - + + /* Apply brush */ if (gso->brush_type == GP_EDITBRUSH_TYPE_CLONE) { changed = gpsculpt_brush_apply_clone(C, gso); @@ -1512,13 +1512,13 @@ static void gpsculpt_brush_apply(bContext *C, wmOperator *op, PointerRNA *itempt else { changed = gpsculpt_brush_apply_standard(C, gso); } - - + + /* Updates */ if (changed) { WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } - + /* Store values for next step */ gso->mval_prev[0] = gso->mval[0]; gso->mval_prev[1] = gso->mval[1]; @@ -1535,24 +1535,24 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven PointerRNA itemptr; float mouse[2]; int tablet = 0; - + mouse[0] = event->mval[0] + 1; mouse[1] = event->mval[1] + 1; - + /* fill in stroke */ RNA_collection_add(op->ptr, "stroke", &itemptr); - + RNA_float_set_array(&itemptr, "mouse", mouse); RNA_boolean_set(&itemptr, "pen_flip", event->ctrl != false); RNA_boolean_set(&itemptr, "is_start", gso->first); - + /* handle pressure sensitivity (which is supplied by tablets) */ if (event->tablet_data) { const wmTabletData *wmtab = event->tablet_data; float pressure = wmtab->Pressure; - + tablet = (wmtab->Active != EVT_TABLET_NONE); - + /* special exception here for too high pressure values on first touch in * windows for some tablets: clamp the values to be sane */ @@ -1564,7 +1564,7 @@ static void gpsculpt_brush_apply_event(bContext *C, wmOperator *op, const wmEven else { RNA_float_set(&itemptr, "pressure", 1.0f); } - + /* apply */ gpsculpt_brush_apply(C, op, &itemptr); } @@ -1574,15 +1574,15 @@ static int gpsculpt_brush_exec(bContext *C, wmOperator *op) { if (!gpsculpt_brush_init(C, op)) return OPERATOR_CANCELLED; - - RNA_BEGIN(op->ptr, itemptr, "stroke") + + RNA_BEGIN(op->ptr, itemptr, "stroke") { gpsculpt_brush_apply(C, op, &itemptr); } RNA_END; - + gpsculpt_brush_exit(C, op); - + return OPERATOR_FINISHED; } @@ -1594,13 +1594,13 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve const bool is_modal = RNA_boolean_get(op->ptr, "wait_for_input"); bool needs_timer = false; float brush_rate = 0.0f; - + /* init painting data */ if (!gpsculpt_brush_init(C, op)) return OPERATOR_CANCELLED; - + gso = op->customdata; - + /* initialise type-specific data (used for the entire session) */ switch (gso->brush_type) { /* Brushes requiring timer... */ @@ -1608,7 +1608,7 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve brush_rate = 0.01f; // XXX: hardcoded needs_timer = true; break; - + case GP_EDITBRUSH_TYPE_STRENGTH: brush_rate = 0.01f; // XXX: hardcoded needs_timer = true; @@ -1618,39 +1618,39 @@ static int gpsculpt_brush_invoke(bContext *C, wmOperator *op, const wmEvent *eve brush_rate = 0.001f; // XXX: hardcoded needs_timer = true; break; - + case GP_EDITBRUSH_TYPE_TWIST: brush_rate = 0.01f; // XXX: hardcoded needs_timer = true; break; - + default: break; } - + /* register timer for increasing influence by hovering over an area */ if (needs_timer) { gso->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, brush_rate); } - + /* register modal handler */ WM_event_add_modal_handler(C, op); - + /* start drawing immediately? */ if (is_modal == false) { ARegion *ar = CTX_wm_region(C); - + /* ensure that we'll have a new frame to draw on */ gpsculpt_brush_init_stroke(gso); - + /* apply first dab... */ gso->is_painting = true; gpsculpt_brush_apply_event(C, op, event); - + /* redraw view with feedback */ ED_region_tag_redraw(ar); } - + return OPERATOR_RUNNING_MODAL; } @@ -1661,7 +1661,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even const bool is_modal = RNA_boolean_get(op->ptr, "wait_for_input"); bool redraw_region = false; bool redraw_toolsettings = false; - + /* The operator can be in 2 states: Painting and Idling */ if (gso->is_painting) { /* Painting */ @@ -1671,11 +1671,11 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even case INBETWEEN_MOUSEMOVE: /* apply brush effect at new position */ gpsculpt_brush_apply_event(C, op, event); - + /* force redraw, so that the cursor will at least be valid */ redraw_region = true; break; - + /* Timer Tick - Only if this was our own timer */ case TIMER: if (event->customdata == gso->timer) { @@ -1684,7 +1684,7 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even gso->timerTick = false; } break; - + /* Adjust brush settings */ /* FIXME: Step increments and modifier keys are hardcoded here! */ case WHEELUPMOUSE: @@ -1699,12 +1699,12 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even gso->brush->size += 3; CLAMP_MAX(gso->brush->size, 300); } - + redraw_region = true; redraw_toolsettings = true; break; - - case WHEELDOWNMOUSE: + + case WHEELDOWNMOUSE: case PADMINUS: if (event->shift) { /* decrease strength */ @@ -1716,11 +1716,11 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even gso->brush->size -= 3; CLAMP_MIN(gso->brush->size, 1); } - + redraw_region = true; redraw_toolsettings = true; break; - + /* Painting mbut release = Stop painting (back to idle) */ case LEFTMOUSE: //BLI_assert(event->val == KM_RELEASE); @@ -1731,12 +1731,12 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even else { /* end sculpt session, since we're not modal */ gso->is_painting = false; - + gpsculpt_brush_exit(C, op); return OPERATOR_FINISHED; } break; - + /* Abort painting if any of the usual things are tried */ case MIDDLEMOUSE: case RIGHTMOUSE: @@ -1748,34 +1748,34 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even else { /* Idling */ BLI_assert(is_modal == true); - + switch (event->type) { /* Painting mbut press = Start painting (switch to painting state) */ case LEFTMOUSE: /* do initial "click" apply */ gso->is_painting = true; gso->first = true; - + gpsculpt_brush_init_stroke(gso); gpsculpt_brush_apply_event(C, op, event); break; - + /* Exit modal operator, based on the "standard" ops */ case RIGHTMOUSE: case ESCKEY: gpsculpt_brush_exit(C, op); return OPERATOR_FINISHED; - + /* MMB is often used for view manipulations */ case MIDDLEMOUSE: return OPERATOR_PASS_THROUGH; - + /* Mouse movements should update the brush cursor - Just redraw the active region */ case MOUSEMOVE: case INBETWEEN_MOUSEMOVE: redraw_region = true; break; - + /* Adjust brush settings */ /* FIXME: Step increments and modifier keys are hardcoded here! */ case WHEELUPMOUSE: @@ -1790,12 +1790,12 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even gso->brush->size += 3; CLAMP_MAX(gso->brush->size, 300); } - + redraw_region = true; redraw_toolsettings = true; break; - - case WHEELDOWNMOUSE: + + case WHEELDOWNMOUSE: case PADMINUS: if (event->shift) { /* decrease strength */ @@ -1807,41 +1807,41 @@ static int gpsculpt_brush_modal(bContext *C, wmOperator *op, const wmEvent *even gso->brush->size -= 3; CLAMP_MIN(gso->brush->size, 1); } - + redraw_region = true; redraw_toolsettings = true; break; - + /* Change Frame - Allowed */ case LEFTARROWKEY: case RIGHTARROWKEY: case UPARROWKEY: case DOWNARROWKEY: return OPERATOR_PASS_THROUGH; - + /* Camera/View Manipulations - Allowed */ /* (See rationale in gpencil_paint.c -> gpencil_draw_modal()) */ case PAD0: case PAD1: case PAD2: case PAD3: case PAD4: case PAD5: case PAD6: case PAD7: case PAD8: case PAD9: return OPERATOR_PASS_THROUGH; - + /* Unhandled event */ default: break; } } - + /* Redraw region? */ if (redraw_region) { ARegion *ar = CTX_wm_region(C); ED_region_tag_redraw(ar); } - + /* Redraw toolsettings (brush settings)? */ if (redraw_toolsettings) { WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } - + return OPERATOR_RUNNING_MODAL; } @@ -1854,7 +1854,7 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot) ot->name = "Stroke Sculpt"; ot->idname = "GPENCIL_OT_brush_paint"; ot->description = "Apply tweaks to strokes by painting over the strokes"; // XXX - + /* api callbacks */ ot->exec = gpsculpt_brush_exec; ot->invoke = gpsculpt_brush_invoke; @@ -1869,7 +1869,7 @@ void GPENCIL_OT_brush_paint(wmOperatorType *ot) PropertyRNA *prop; prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - + prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "Enter a mini 'sculpt-mode' if enabled, otherwise, exit after drawing a single stroke"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index 7d455f214db..f44c3ee4113 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -174,7 +174,7 @@ static void gp_strokepoint_convertcoords( else { const float *fp = ED_view3d_cursor3d_get(scene, v3d); float mvalf[2]; - + /* get screen coordinate */ if (gps->flag & GP_STROKE_2DSPACE) { View2D *v2d = &ar->v2d; @@ -190,7 +190,7 @@ static void gp_strokepoint_convertcoords( mvalf[1] = (float)pt->y / 100.0f * ar->winy; } } - + ED_view3d_win_to_3d(v3d, ar, fp, mvalf, p3d); } } @@ -206,19 +206,19 @@ typedef struct tGpTimingData { bool realtime; /* Will overwrite end_frame in case of Original or CustomGap timing... */ float gap_duration, gap_randomness; /* To be used with CustomGap mode*/ int seed; - + /* Data set from points, used to compute final timing FCurve */ int num_points, cur_point; - + /* Distances */ float *dists; float tot_dist; - + /* Times */ float *times; /* Note: Gap times will be negative! */ float tot_time, gap_tot_time; double inittime; - + /* Only used during creation of dists & times lists. */ float offset_time; } tGpTimingData; @@ -229,9 +229,9 @@ typedef struct tGpTimingData { static void gp_timing_data_set_nbr(tGpTimingData *gtd, const int nbr) { float *tmp; - + BLI_assert(nbr > gtd->num_points); - + /* distances */ tmp = gtd->dists; gtd->dists = MEM_callocN(sizeof(float) * nbr, __func__); @@ -239,7 +239,7 @@ static void gp_timing_data_set_nbr(tGpTimingData *gtd, const int nbr) memcpy(gtd->dists, tmp, sizeof(float) * gtd->num_points); MEM_freeN(tmp); } - + /* times */ tmp = gtd->times; gtd->times = MEM_callocN(sizeof(float) * nbr, __func__); @@ -247,7 +247,7 @@ static void gp_timing_data_set_nbr(tGpTimingData *gtd, const int nbr) memcpy(gtd->times, tmp, sizeof(float) * gtd->num_points); MEM_freeN(tmp); } - + gtd->num_points = nbr; } @@ -257,7 +257,7 @@ static void gp_timing_data_add_point(tGpTimingData *gtd, const double stroke_ini { float delta_time = 0.0f; const int cur_point = gtd->cur_point; - + if (!cur_point) { /* Special case, first point, if time is not 0.0f we have to compensate! */ gtd->offset_time = -time; @@ -267,18 +267,18 @@ static void gp_timing_data_add_point(tGpTimingData *gtd, const double stroke_ini /* This is a gap, negative value! */ gtd->times[cur_point] = -(((float)(stroke_inittime - gtd->inittime)) + time + gtd->offset_time); delta_time = -gtd->times[cur_point] - gtd->times[cur_point - 1]; - + gtd->gap_tot_time += delta_time; } else { gtd->times[cur_point] = (((float)(stroke_inittime - gtd->inittime)) + time + gtd->offset_time); delta_time = gtd->times[cur_point] - fabsf(gtd->times[cur_point - 1]); } - + gtd->tot_time += delta_time; gtd->tot_dist += delta_dist; gtd->dists[cur_point] = gtd->tot_dist; - + gtd->cur_point++; } @@ -293,7 +293,7 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd, RNG *rng, const int idx float *next_delta_time) { int j; - + for (j = idx + 1; j < gtd->num_points; j++) { if (gtd->times[j] < 0) { gtd->times[j] = -gtd->times[j]; @@ -312,16 +312,16 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd, RNG *rng, const int idx } else { float delta, min, max; - + /* This code ensures that if the first gaps have been shorter than average gap_duration, * next gaps will tend to be longer (i.e. try to recover the lateness), and vice-versa! */ delta = delta_time - (gtd->gap_duration * (*nbr_done_gaps)); - + /* Clamp min between [-gap_randomness, 0.0], with lower delta giving higher min */ min = -gtd->gap_randomness - delta; CLAMP(min, -gtd->gap_randomness, 0.0f); - + /* Clamp max between [0.0, gap_randomness], with lower delta giving higher max */ max = gtd->gap_randomness - delta; CLAMP(max, 0.0f, gtd->gap_randomness); @@ -336,7 +336,7 @@ static int gp_find_end_of_stroke_idx(tGpTimingData *gtd, RNG *rng, const int idx break; } } - + return j - 1; } @@ -344,7 +344,7 @@ static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, RNG *rn { int i; float delta_time = 0.0f; - + for (i = 0; i < gtd->num_points; i++) { if (gtd->times[i] < 0 && i) { (*nbr_gaps)++; @@ -357,7 +357,7 @@ static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, RNG *rn } } gtd->tot_time -= delta_time; - + *tot_gaps_time = (float)(*nbr_gaps) * gtd->gap_duration; gtd->tot_time += *tot_gaps_time; if (G.debug & G_DEBUG) { @@ -374,18 +374,18 @@ static void gp_stroke_path_animation_add_keyframes(ReportList *reports, PointerR { /* Use actual recorded timing! */ const float time_start = (float)gtd->start_frame; - + float last_valid_time = 0.0f; int end_stroke_idx = -1, start_stroke_idx = 0; float end_stroke_time = 0.0f; - + /* CustomGaps specific */ float delta_time = 0.0f, next_delta_time = 0.0f; int nbr_done_gaps = 0; - + int i; float cfra; - + /* This is a bit tricky, as: * - We can't add arbitrarily close points on FCurve (in time). * - We *must* have all "caps" points of all strokes in FCurve, as much as possible! @@ -401,11 +401,11 @@ static void gp_stroke_path_animation_add_keyframes(ReportList *reports, PointerR /* This one should *never* be negative! */ end_stroke_time = time_start + ((gtd->times[end_stroke_idx] + delta_time) / gtd->tot_time * time_range); } - + /* Simple proportional stuff... */ cu->ctime = gtd->dists[i] / gtd->tot_dist * cu->pathlen; cfra = time_start + ((gtd->times[i] + delta_time) / gtd->tot_time * time_range); - + /* And now, the checks about timing... */ if (i == start_stroke_idx) { /* If first point of a stroke, be sure it's enough ahead of last valid keyframe, and @@ -456,43 +456,43 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu PointerRNA ptr; PropertyRNA *prop = NULL; int nbr_gaps = 0, i; - + if (gtd->mode == GP_STROKECONVERT_TIMING_NONE) return; - + /* gap_duration and gap_randomness are in frames, but we need seconds!!! */ gtd->gap_duration = FRA2TIME(gtd->gap_duration); gtd->gap_randomness = FRA2TIME(gtd->gap_randomness); - + /* Enable path! */ cu->flag |= CU_PATH; cu->pathlen = gtd->frame_range; - + /* Get RNA pointer to read/write path time values */ RNA_id_pointer_create((ID *)cu, &ptr); prop = RNA_struct_find_property(&ptr, "eval_time"); - + /* Ensure we have an F-Curve to add keyframes to */ act = verify_adt_action((ID *)cu, true); fcu = verify_fcurve(act, NULL, &ptr, "eval_time", 0, true); - + if (G.debug & G_DEBUG) { printf("%s: tot len: %f\t\ttot time: %f\n", __func__, gtd->tot_dist, gtd->tot_time); for (i = 0; i < gtd->num_points; i++) { printf("\tpoint %d:\t\tlen: %f\t\ttime: %f\n", i, gtd->dists[i], gtd->times[i]); } } - + if (gtd->mode == GP_STROKECONVERT_TIMING_LINEAR) { float cfra; - + /* Linear extrapolation! */ fcu->extend = FCURVE_EXTRAPOLATE_LINEAR; - + cu->ctime = 0.0f; cfra = (float)gtd->start_frame; insert_keyframe_direct(reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, INSERTKEY_FAST); - + cu->ctime = cu->pathlen; if (gtd->realtime) { cfra += (float)TIME2FRA(gtd->tot_time); /* Seconds to frames */ @@ -506,35 +506,35 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu /* Use actual recorded timing! */ RNG *rng = BLI_rng_new(0); float time_range; - + /* CustomGaps specific */ float tot_gaps_time = 0.0f; - + /* Pre-process gaps, in case we don't want to keep their original timing */ if (gtd->mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) { gp_stroke_path_animation_preprocess_gaps(gtd, rng, &nbr_gaps, &tot_gaps_time); } - + if (gtd->realtime) { time_range = (float)TIME2FRA(gtd->tot_time); /* Seconds to frames */ } else { time_range = (float)(gtd->end_frame - gtd->start_frame); } - + if (G.debug & G_DEBUG) { printf("GP Stroke Path Conversion: Starting keying!\n"); } - + gp_stroke_path_animation_add_keyframes(reports, ptr, prop, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time); - + BLI_rng_free(rng); } - + /* As we used INSERTKEY_FAST mode, we need to recompute all curve's handles now */ calchandles_fcurve(fcu); - + if (G.debug & G_DEBUG) { printf("%s: \ntot len: %f\t\ttot time: %f\n", __func__, gtd->tot_dist, gtd->tot_time); for (i = 0; i < gtd->num_points; i++) { @@ -542,9 +542,9 @@ static void gp_stroke_path_animation(bContext *C, ReportList *reports, Curve *cu } printf("\n\n"); } - + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + /* send updates */ DAG_id_tag_update(&cu->id, 0); } @@ -564,7 +564,7 @@ static void gp_stroke_to_path_add_point(tGpTimingData *gtd, BPoint *bp, const fl { copy_v3_v3(bp->vec, p); bp->vec[3] = 1.0f; - + /* set settings */ bp->f1 = SELECT; bp->radius = width * rad_fac; @@ -576,7 +576,7 @@ static void gp_stroke_to_path_add_point(tGpTimingData *gtd, BPoint *bp, const fl else if (bp->weight > minmax_weights[1]) { minmax_weights[1] = bp->weight; } - + /* Update timing data */ if (do_gtd) { gp_timing_data_add_point(gtd, inittime, time, len_v3v3(prev_p, p)); @@ -593,7 +593,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv const bool do_gtd = (gtd->mode != GP_STROKECONVERT_TIMING_NONE); const int add_start_end_points = (add_start_point ? 1 : 0) + (add_end_point ? 1 : 0); int i, old_nbp = 0; - + /* create new 'nurb' or extend current one within the curve */ if (nu) { old_nbp = nu->pntsu; @@ -605,7 +605,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv } else { nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_path(nurb)"); - + nu->pntsu = gps->totpoints + add_start_end_points; nu->pntsv = 1; nu->orderu = 2; /* point-to-point! */ @@ -614,16 +614,16 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv nu->resolu = cu->resolu; nu->resolv = cu->resolv; nu->knotsu = NULL; - + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * nu->pntsu, "bpoints"); - + stitch = false; /* Security! */ } - + if (do_gtd) { gp_timing_data_set_nbr(gtd, nu->pntsu); } - + /* If needed, make the link between both strokes with two zero-radius additional points */ /* About "zero-radius" point interpolations: * - If we have at least two points in current curve (most common case), we linearly extrapolate @@ -636,16 +636,16 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv if (curnu && !stitch && old_nbp) { float p1[3], p2[3], p[3], next_p[3]; float dt1 = 0.0f, dt2 = 0.0f; - + BLI_assert(gps->prev != NULL); - + prev_bp = NULL; if ((old_nbp > 1) && (gps->prev->totpoints > 1)) { /* Only use last curve segment if previous stroke was not a single-point one! */ prev_bp = &nu->bp[old_nbp - 2]; } bp = &nu->bp[old_nbp - 1]; - + /* First point */ gp_strokepoint_convertcoords(C, gpl, gps, gps->points, p, subrect); if (prev_bp) { @@ -664,7 +664,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv bp++; gp_stroke_to_path_add_point(gtd, bp, p1, (bp - 1)->vec, do_gtd, gps->prev->inittime, dt1, 0.0f, rad_fac, minmax_weights); - + /* Second point */ /* Note dt2 is always negative, which marks the gap. */ if (gps->totpoints > 1) { @@ -682,13 +682,13 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv } bp++; gp_stroke_to_path_add_point(gtd, bp, p2, p1, do_gtd, gps->inittime, dt2, 0.0f, rad_fac, minmax_weights); - + old_nbp += 2; } else if (add_start_point) { float p[3], next_p[3]; float dt = 0.0f; - + gp_strokepoint_convertcoords(C, gpl, gps, gps->points, p, subrect); if (gps->totpoints > 1) { gp_strokepoint_convertcoords(C, gpl, gps, gps->points + 1, next_p, subrect); @@ -706,14 +706,14 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv * would not work (it would be *before* gtd->inittime, which is not supported currently). */ gp_stroke_to_path_add_point(gtd, bp, p, p, do_gtd, gps->inittime, dt, 0.0f, rad_fac, minmax_weights); - + old_nbp++; } - + if (old_nbp) { prev_bp = &nu->bp[old_nbp - 1]; } - + /* add points */ for (i = (stitch) ? 1 : 0, pt = &gps->points[(stitch) ? 1 : 0], bp = &nu->bp[old_nbp]; i < gps->totpoints; @@ -721,20 +721,20 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv { float p[3]; float width = pt->pressure * (gps->thickness + gpl->thickness) * WIDTH_CORR_FAC; - + /* get coordinates to add at */ gp_strokepoint_convertcoords(C, gpl, gps, pt, p, subrect); - + gp_stroke_to_path_add_point(gtd, bp, p, (prev_bp) ? prev_bp->vec : p, do_gtd, gps->inittime, pt->time, width, rad_fac, minmax_weights); - + prev_bp = bp; } if (add_end_point) { float p[3]; float dt = 0.0f; - + if (gps->totpoints > 1) { interp_v3_v3v3(p, prev_bp->vec, (prev_bp - 1)->vec, -GAP_DFAC); if (do_gtd) { @@ -750,7 +750,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv /* Note bp has already been incremented in main loop above, so it points to the right place. */ gp_stroke_to_path_add_point(gtd, bp, p, prev_bp->vec, do_gtd, gps->inittime, dt, 0.0f, rad_fac, minmax_weights); } - + /* add nurb to curve */ if (!curnu || !*curnu) { BLI_addtail(&cu->nurb, nu); @@ -758,7 +758,7 @@ static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curv if (curnu) { *curnu = nu; } - + BKE_nurb_knot_calc_u(nu); } @@ -773,7 +773,7 @@ static void gp_stroke_to_bezier_add_point(tGpTimingData *gtd, BezTriple *bezt, copy_v3_v3(bezt->vec[0], h1); copy_v3_v3(bezt->vec[1], p); copy_v3_v3(bezt->vec[2], h2); - + /* set settings */ bezt->h1 = bezt->h2 = HD_FREE; bezt->f1 = bezt->f2 = bezt->f3 = SELECT; @@ -786,7 +786,7 @@ static void gp_stroke_to_bezier_add_point(tGpTimingData *gtd, BezTriple *bezt, else if (bezt->weight > minmax_weights[1]) { minmax_weights[1] = bezt->weight; } - + /* Update timing data */ if (do_gtd) { gp_timing_data_add_point(gtd, inittime, time, len_v3v3(prev_p, p)); @@ -804,7 +804,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu const int add_start_end_points = (add_start_point ? 1 : 0) + (add_end_point ? 1 : 0); float p3d_cur[3], p3d_prev[3], p3d_next[3], h1[3], h2[3]; const bool do_gtd = (gtd->mode != GP_STROKECONVERT_TIMING_NONE); - + /* create new 'nurb' or extend current one within the curve */ if (nu) { old_nbezt = nu->pntsu; @@ -816,22 +816,22 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu } else { nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_bezier(nurb)"); - + nu->pntsu = gps->totpoints + add_start_end_points; nu->resolu = 12; nu->resolv = 12; nu->type = CU_BEZIER; nu->bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple) * nu->pntsu, "bezts"); - + stitch = false; /* Security! */ } - + if (do_gtd) { gp_timing_data_set_nbr(gtd, nu->pntsu); } - + tot = gps->totpoints; - + /* get initial coordinates */ pt = gps->points; if (tot) { @@ -843,11 +843,11 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu gp_strokepoint_convertcoords(C, gpl, gps, pt + 2, p3d_next, subrect); } } - + /* If needed, make the link between both strokes with two zero-radius additional points */ if (curnu && old_nbezt) { BLI_assert(gps->prev != NULL); - + /* Update last point's second handle */ if (stitch) { bezt = &nu->bezt[old_nbezt - 1]; @@ -855,7 +855,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu copy_v3_v3(bezt->vec[2], h2); pt++; } - + /* Create "link points" */ /* About "zero-radius" point interpolations: * - If we have at least two points in current curve (most common case), we linearly extrapolate @@ -868,14 +868,14 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu else { float p1[3], p2[3]; float dt1 = 0.0f, dt2 = 0.0f; - + prev_bezt = NULL; if ((old_nbezt > 1) && (gps->prev->totpoints > 1)) { /* Only use last curve segment if previous stroke was not a single-point one! */ prev_bezt = &nu->bezt[old_nbezt - 2]; } bezt = &nu->bezt[old_nbezt - 1]; - + /* First point */ if (prev_bezt) { interp_v3_v3v3(p1, prev_bezt->vec[1], bezt->vec[1], 1.0f + GAP_DFAC); @@ -890,7 +890,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu dt1 = interpf(gps->inittime - gps->prev->inittime, 0.0f, GAP_DFAC); } } - + /* Second point */ /* Note dt2 is always negative, which marks the gap. */ if (tot > 1) { @@ -905,25 +905,25 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu dt2 = interpf(gps->prev->inittime - gps->inittime, 0.0f, GAP_DFAC); } } - + /* Second handle of last point of previous stroke. */ interp_v3_v3v3(h2, bezt->vec[1], p1, BEZT_HANDLE_FAC); copy_v3_v3(bezt->vec[2], h2); - + /* First point */ interp_v3_v3v3(h1, p1, bezt->vec[1], BEZT_HANDLE_FAC); interp_v3_v3v3(h2, p1, p2, BEZT_HANDLE_FAC); bezt++; gp_stroke_to_bezier_add_point(gtd, bezt, p1, h1, h2, (bezt - 1)->vec[1], do_gtd, gps->prev->inittime, dt1, 0.0f, rad_fac, minmax_weights); - + /* Second point */ interp_v3_v3v3(h1, p2, p1, BEZT_HANDLE_FAC); interp_v3_v3v3(h2, p2, p3d_cur, BEZT_HANDLE_FAC); bezt++; gp_stroke_to_bezier_add_point(gtd, bezt, p2, h1, h2, p1, do_gtd, gps->inittime, dt2, 0.0f, rad_fac, minmax_weights); - + old_nbezt += 2; copy_v3_v3(p3d_prev, p2); } @@ -931,7 +931,7 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu else if (add_start_point) { float p[3]; float dt = 0.0f; - + if (gps->totpoints > 1) { interp_v3_v3v3(p, p3d_cur, p3d_next, -GAP_DFAC); if (do_gtd) { @@ -948,51 +948,51 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu bezt = &nu->bezt[old_nbezt]; gp_stroke_to_bezier_add_point(gtd, bezt, p, h1, h2, p, do_gtd, gps->inittime, dt, 0.0f, rad_fac, minmax_weights); - + old_nbezt++; copy_v3_v3(p3d_prev, p); } - + if (old_nbezt) { prev_bezt = &nu->bezt[old_nbezt - 1]; } - + /* add points */ for (i = stitch ? 1 : 0, bezt = &nu->bezt[old_nbezt]; i < tot; i++, pt++, bezt++) { float width = pt->pressure * (gps->thickness + gpl->thickness) * WIDTH_CORR_FAC; - + if (i || old_nbezt) { interp_v3_v3v3(h1, p3d_cur, p3d_prev, BEZT_HANDLE_FAC); } else { interp_v3_v3v3(h1, p3d_cur, p3d_next, -BEZT_HANDLE_FAC); } - + if (i < tot - 1) { interp_v3_v3v3(h2, p3d_cur, p3d_next, BEZT_HANDLE_FAC); } else { interp_v3_v3v3(h2, p3d_cur, p3d_prev, -BEZT_HANDLE_FAC); } - + gp_stroke_to_bezier_add_point(gtd, bezt, p3d_cur, h1, h2, prev_bezt ? prev_bezt->vec[1] : p3d_cur, do_gtd, gps->inittime, pt->time, width, rad_fac, minmax_weights); - + /* shift coord vects */ copy_v3_v3(p3d_prev, p3d_cur); copy_v3_v3(p3d_cur, p3d_next); - + if (i + 2 < tot) { gp_strokepoint_convertcoords(C, gpl, gps, pt + 2, p3d_next, subrect); } - + prev_bezt = bezt; } if (add_end_point) { float p[3]; float dt = 0.0f; - + if (gps->totpoints > 1) { interp_v3_v3v3(p, prev_bezt->vec[1], (prev_bezt - 1)->vec[1], -GAP_DFAC); if (do_gtd) { @@ -1005,11 +1005,11 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu p[0] += GAP_DFAC; /* Rather arbitrary... */ dt = GAP_DFAC; /* Rather arbitrary too! */ } - + /* Second handle of last point of this stroke. */ interp_v3_v3v3(h2, prev_bezt->vec[1], p, BEZT_HANDLE_FAC); copy_v3_v3(prev_bezt->vec[2], h2); - + /* The end point */ interp_v3_v3v3(h1, p, prev_bezt->vec[1], BEZT_HANDLE_FAC); interp_v3_v3v3(h2, p, prev_bezt->vec[1], -BEZT_HANDLE_FAC); @@ -1017,10 +1017,10 @@ static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cu gp_stroke_to_bezier_add_point(gtd, bezt, p, h1, h2, prev_bezt->vec[1], do_gtd, gps->inittime, dt, 0.0f, rad_fac, minmax_weights); } - + /* must calculate handles or else we crash */ BKE_nurb_handles_calc(nu); - + if (!curnu || !*curnu) { BLI_addtail(&cu->nurb, nu); } @@ -1050,7 +1050,7 @@ static void gp_stroke_finalize_curve_endpoints(Curve *cu) bp[i].weight = bp[i].radius = 0.0f; } } - + /* end */ nu = cu->nurb.last; i = nu->pntsu - 1; @@ -1074,13 +1074,13 @@ static void gp_stroke_norm_curve_weights(Curve *cu, const float minmax_weights[2 const float delta = minmax_weights[0]; float fac; int i; - + /* when delta == minmax_weights[0] == minmax_weights[1], we get div by zero [#35686] */ if (IS_EQF(delta, minmax_weights[1])) fac = 1.0f; else fac = 1.0f / (minmax_weights[1] - delta); - + for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu->bezt) { BezTriple *bezt = nu->bezt; @@ -1101,10 +1101,10 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) { View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); - + if (v3d) { RegionView3D *rv3d = ar->regiondata; - + /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); @@ -1112,7 +1112,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) return 1; } } - + return 0; } @@ -1130,55 +1130,55 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG Nurb *nu = NULL; Base *base_orig = BASACT, *base_new = NULL; float minmax_weights[2] = {1.0f, 0.0f}; - + /* camera framing */ rctf subrect, *subrect_ptr = NULL; - + /* error checking */ if (ELEM(NULL, gpd, gpl, gpf)) return; - + /* only convert if there are any strokes on this layer's frame to convert */ if (BLI_listbase_is_empty(&gpf->strokes)) return; - + /* initialize camera framing */ if (gp_camera_view_subrect(C, &subrect)) { subrect_ptr = &subrect; } - + /* init the curve object (remove rotation and get curve data from it) * - must clear transforms set on object, as those skew our results */ ob = BKE_object_add_only_object(bmain, OB_CURVE, gpl->info); cu = ob->data = BKE_curve_add(bmain, gpl->info, OB_CURVE); base_new = BKE_scene_base_add(scene, ob); - + cu->flag |= CU_3D; - + gtd->inittime = ((bGPDstroke *)gpf->strokes.first)->inittime; - + /* add points to curve */ for (gps = gpf->strokes.first; gps; gps = gps->next) { const bool add_start_point = (link_strokes && !(prev_gps)); const bool add_end_point = (link_strokes && !(gps->next)); - + /* Detect new strokes created because of GP_STROKE_BUFFER_MAX reached, and stitch them to previous one. */ bool stitch = false; if (prev_gps) { bGPDspoint *pt1 = &prev_gps->points[prev_gps->totpoints - 1]; bGPDspoint *pt2 = &gps->points[0]; - + if ((pt1->x == pt2->x) && (pt1->y == pt2->y)) { stitch = true; } } - + /* Decide whether we connect this stroke to previous one */ if (!(stitch || link_strokes)) { nu = NULL; } - + switch (mode) { case GP_STROKECONVERT_PATH: gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr, &nu, minmax_weights, rad_fac, stitch, @@ -1195,26 +1195,26 @@ static void gp_layer_to_curve(bContext *C, ReportList *reports, bGPdata *gpd, bG } prev_gps = gps; } - + /* If link_strokes, be sure first and last points have a zero weight/size! */ if (link_strokes) { gp_stroke_finalize_curve_endpoints(cu); } - + /* Update curve's weights, if needed */ if (norm_weights && ((minmax_weights[0] > 0.0f) || (minmax_weights[1] < 1.0f))) { gp_stroke_norm_curve_weights(cu, minmax_weights); } - + /* Create the path animation, if needed */ gp_stroke_path_animation(C, reports, cu, gtd); - + if (mode == GP_STROKECONVERT_POLY) { for (nu = cu->nurb.first; nu; nu = nu->next) { BKE_nurb_type_convert(nu, CU_POLY, false); } } - + /* set the layer and select */ base_new->lay = ob->lay = base_orig ? base_orig->lay : BKE_screen_view3d_layer_active(v3d, scene); base_new->flag = ob->flag = base_new->flag | SELECT; @@ -1234,17 +1234,17 @@ static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOpe double base_time, cur_time, prev_time = -1.0; int i; bool valid = true; - + if (!gpl || !(gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0)) || !(gps = gpf->strokes.first)) return false; - + do { base_time = cur_time = gps->inittime; if (cur_time <= prev_time) { valid = false; break; } - + prev_time = cur_time; for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { cur_time = base_time + (double)pt->time; @@ -1257,12 +1257,12 @@ static bool gp_convert_check_has_valid_timing(bContext *C, bGPDlayer *gpl, wmOpe } prev_time = cur_time; } - + if (!valid) { break; } } while ((gps = gps->next)); - + if (op) { RNA_boolean_set(op->ptr, "use_timing_data", valid); } @@ -1274,7 +1274,7 @@ static void gp_convert_set_end_frame(struct Main *UNUSED(main), struct Scene *UN { int start_frame = RNA_int_get(ptr, "start_frame"); int end_frame = RNA_int_get(ptr, "end_frame"); - + if (end_frame <= start_frame) { RNA_int_set(ptr, "end_frame", start_frame + 1); } @@ -1287,7 +1287,7 @@ static int gp_convert_poll(bContext *C) bGPDframe *gpf = NULL; ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); - + /* only if the current view is 3D View, if there's valid data (i.e. at least one stroke!), * and if we are not in edit mode! */ @@ -1310,19 +1310,19 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op) const bool link_strokes = RNA_boolean_get(op->ptr, "use_link_strokes"); bool valid_timing; tGpTimingData gtd; - + /* check if there's data to work with */ if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data to work on"); return OPERATOR_CANCELLED; } - + if (!RNA_property_is_set(op->ptr, prop) && !gp_convert_check_has_valid_timing(C, gpl, op)) { BKE_report(op->reports, RPT_WARNING, "Current Grease Pencil strokes have no valid timing data, most timing options will be hidden!"); } valid_timing = RNA_property_boolean_get(op->ptr, prop); - + gtd.mode = RNA_enum_get(op->ptr, "timing_mode"); /* Check for illegal timing mode! */ if (!valid_timing && !ELEM(gtd.mode, GP_STROKECONVERT_TIMING_NONE, GP_STROKECONVERT_TIMING_LINEAR)) { @@ -1332,7 +1332,7 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op) if (!link_strokes) { gtd.mode = GP_STROKECONVERT_TIMING_NONE; } - + /* grab all relevant settings */ gtd.frame_range = RNA_int_get(op->ptr, "frame_range"); gtd.start_frame = RNA_int_get(op->ptr, "start_frame"); @@ -1347,10 +1347,10 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op) gtd.tot_dist = gtd.tot_time = gtd.gap_tot_time = 0.0f; gtd.inittime = 0.0; gtd.offset_time = 0.0f; - + /* perform conversion */ gp_layer_to_curve(C, op->reports, gpd, gpl, mode, norm_weights, rad_fac, link_strokes, >d); - + /* free temp memory */ if (gtd.dists) { MEM_freeN(gtd.dists); @@ -1360,11 +1360,11 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op) MEM_freeN(gtd.times); gtd.times = NULL; } - + /* notifiers */ WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); - + /* done */ return OPERATOR_FINISHED; } @@ -1378,7 +1378,7 @@ static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) float gap_duration = RNA_float_get(ptr, "gap_duration"); float gap_randomness = RNA_float_get(ptr, "gap_randomness"); const bool valid_timing = RNA_boolean_get(ptr, "use_timing_data"); - + /* Always show those props */ if (STREQ(prop_id, "type") || STREQ(prop_id, "use_normalize_weights") || @@ -1387,16 +1387,16 @@ static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) { return true; } - + /* Never show this prop */ if (STREQ(prop_id, "use_timing_data")) return false; - + if (link_strokes) { /* Only show when link_stroke is true */ if (STREQ(prop_id, "timing_mode")) return true; - + if (timing_mode != GP_STROKECONVERT_TIMING_NONE) { /* Only show when link_stroke is true and stroke timing is enabled */ if (STREQ(prop_id, "frame_range") || @@ -1404,31 +1404,31 @@ static bool gp_convert_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) { return true; } - + /* Only show if we have valid timing data! */ if (valid_timing && STREQ(prop_id, "use_realtime")) return true; - + /* Only show if realtime or valid_timing is false! */ if ((!realtime || !valid_timing) && STREQ(prop_id, "end_frame")) return true; - + if (valid_timing && timing_mode == GP_STROKECONVERT_TIMING_CUSTOMGAP) { /* Only show for custom gaps! */ if (STREQ(prop_id, "gap_duration")) return true; - + /* Only show randomness for non-null custom gaps! */ if (STREQ(prop_id, "gap_randomness") && (gap_duration > 0.0f)) return true; - + /* Only show seed for randomize action! */ if (STREQ(prop_id, "seed") && (gap_duration > 0.0f) && (gap_randomness > 0.0f)) return true; } } } - + /* Else, hidden! */ return false; } @@ -1438,9 +1438,9 @@ static void gp_convert_ui(bContext *C, wmOperator *op) uiLayout *layout = op->layout; wmWindowManager *wm = CTX_wm_manager(C); PointerRNA ptr; - + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); - + /* Main auto-draw call */ uiDefAutoButsRNA(layout, &ptr, gp_convert_draw_check_prop, '\0'); } @@ -1448,35 +1448,35 @@ static void gp_convert_ui(bContext *C, wmOperator *op) void GPENCIL_OT_convert(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Convert Grease Pencil"; ot->idname = "GPENCIL_OT_convert"; ot->description = "Convert the active Grease Pencil layer to a new Curve Object"; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = gp_convert_layer_exec; ot->poll = gp_convert_poll; ot->ui = gp_convert_ui; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", "Which type of curve to convert to"); - + RNA_def_boolean(ot->srna, "use_normalize_weights", true, "Normalize Weight", "Normalize weight (set from stroke width)"); RNA_def_float(ot->srna, "radius_multiplier", 1.0f, 0.0f, 1000.0f, "Radius Fac", "Multiplier for the points' radii (set from stroke width)", 0.0f, 10.0f); RNA_def_boolean(ot->srna, "use_link_strokes", true, "Link Strokes", "Whether to link strokes with zero-radius sections of curves"); - + prop = RNA_def_enum(ot->srna, "timing_mode", prop_gpencil_convert_timingmodes, GP_STROKECONVERT_TIMING_FULL, "Timing Mode", "How to use timing data stored in strokes"); RNA_def_enum_funcs(prop, rna_GPConvert_mode_items); - + RNA_def_int(ot->srna, "frame_range", 100, 1, 10000, "Frame Range", "The duration of evaluation of the path control curve", 1, 1000); RNA_def_int(ot->srna, "start_frame", 1, 1, 100000, "Start Frame", @@ -1486,7 +1486,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) prop = RNA_def_int(ot->srna, "end_frame", 250, 1, 100000, "End Frame", "The end frame of the path control curve (if Realtime is not set)", 1, 100000); RNA_def_property_update_runtime(prop, gp_convert_set_end_frame); - + RNA_def_float(ot->srna, "gap_duration", 0.0f, 0.0f, 10000.0f, "Gap Duration", "Custom Gap mode: (Average) length of gaps, in frames " "(Note: Realtime value, will be scaled if Realtime is not set)", 0.0f, 1000.0f); @@ -1494,7 +1494,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) "Custom Gap mode: Number of frames that gap lengths can vary", 0.0f, 1000.0f); RNA_def_int(ot->srna, "seed", 0, 0, 1000, "Random Seed", "Custom Gap mode: Random generator seed", 0, 100); - + /* Note: Internal use, this one will always be hidden by UI code... */ prop = RNA_def_boolean(ot->srna, "use_timing_data", false, "Has Valid Timing", "Whether the converted Grease Pencil layer has valid timing data (internal use)"); diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 9d183222c2d..2e8e48b2f15 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -93,7 +93,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op) else { /* decrement user count and add new datablock */ bGPdata *gpd = (*gpd_ptr); - + id_us_min(&gpd->id); *gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil")); @@ -106,10 +106,10 @@ static int gp_data_add_exec(bContext *C, wmOperator *op) } } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -120,7 +120,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) ot->idname = "GPENCIL_OT_data_add"; ot->description = "Add new Grease Pencil data-block"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* callbacks */ ot->exec = gp_data_add_exec; ot->poll = gp_add_poll; @@ -132,7 +132,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) static int gp_data_unlink_poll(bContext *C) { bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); - + /* if we have access to some active data, make sure there's a datablock before enabling this */ return (gpd_ptr && *gpd_ptr); } @@ -142,7 +142,7 @@ static int gp_data_unlink_poll(bContext *C) static int gp_data_unlink_exec(bContext *C, wmOperator *op) { bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); - + if (gpd_ptr == NULL) { BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go"); return OPERATOR_CANCELLED; @@ -154,10 +154,10 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op) id_us_min(&gpd->id); *gpd_ptr = NULL; } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -168,7 +168,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) ot->idname = "GPENCIL_OT_data_unlink"; ot->description = "Unlink active Grease Pencil data-block"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* callbacks */ ot->exec = gp_data_unlink_exec; ot->poll = gp_data_unlink_poll; @@ -193,7 +193,7 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op) } if (*gpd_ptr == NULL) *gpd_ptr = BKE_gpencil_data_addnew(DATA_("GPencil")); - + /* if not exist brushes, create a new set */ if (ts) { if (BLI_listbase_is_empty(&ts->gp_brushes)) { @@ -204,10 +204,10 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op) /* add new layer now */ BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true); - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -217,9 +217,9 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot) ot->name = "Add New Layer"; ot->idname = "GPENCIL_OT_layer_add"; ot->description = "Add new Grease Pencil layer for the active Grease Pencil data-block"; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* callbacks */ ot->exec = gp_layer_add_exec; ot->poll = gp_add_poll; @@ -231,16 +231,16 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); - + /* sanity checks */ if (ELEM(NULL, gpd, gpl)) return OPERATOR_CANCELLED; - + if (gpl->flag & GP_LAYER_LOCKED) { BKE_report(op->reports, RPT_ERROR, "Cannot delete locked layers"); return OPERATOR_CANCELLED; } - + /* make the layer before this the new active layer * - use the one after if this is the first * - if this is the only layer, this naturally becomes NULL @@ -249,13 +249,13 @@ static int gp_layer_remove_exec(bContext *C, wmOperator *op) BKE_gpencil_layer_setactive(gpd, gpl->prev); else BKE_gpencil_layer_setactive(gpd, gpl->next); - + /* delete the layer now... */ BKE_gpencil_layer_delete(gpd, gpl); - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -265,9 +265,9 @@ void GPENCIL_OT_layer_remove(wmOperatorType *ot) ot->name = "Remove Layer"; ot->idname = "GPENCIL_OT_layer_remove"; ot->description = "Remove active Grease Pencil layer"; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* callbacks */ ot->exec = gp_layer_remove_exec; ot->poll = gp_active_layer_poll; @@ -284,18 +284,18 @@ static int gp_layer_move_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); - + int direction = RNA_enum_get(op->ptr, "type"); - + /* sanity checks */ if (ELEM(NULL, gpd, gpl)) return OPERATOR_CANCELLED; - + BLI_assert(ELEM(direction, -1, 0, 1)); /* we use value below */ if (BLI_listbase_link_move(&gpd->layers, gpl, direction)) { WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } - + return OPERATOR_FINISHED; } @@ -306,19 +306,19 @@ void GPENCIL_OT_layer_move(wmOperatorType *ot) {GP_LAYER_MOVE_DOWN, "DOWN", 0, "Down", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Move Grease Pencil Layer"; ot->idname = "GPENCIL_OT_layer_move"; ot->description = "Move the active Grease Pencil layer up/down in the list"; - + /* api callbacks */ ot->exec = gp_layer_move_exec; ot->poll = gp_active_layer_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", ""); } @@ -329,22 +329,22 @@ static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op)) bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); bGPDlayer *new_layer; - + /* sanity checks */ if (ELEM(NULL, gpd, gpl)) return OPERATOR_CANCELLED; - + /* make copy of layer, and add it immediately after the existing layer */ new_layer = BKE_gpencil_layer_duplicate(gpl); BLI_insertlinkafter(&gpd->layers, gpl, new_layer); - + /* ensure new layer has a unique name, and is now the active layer */ BLI_uniquename(&gpd->layers, new_layer, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(new_layer->info)); BKE_gpencil_layer_setactive(gpd, new_layer); - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -354,11 +354,11 @@ void GPENCIL_OT_layer_duplicate(wmOperatorType *ot) ot->name = "Duplicate Layer"; ot->idname = "GPENCIL_OT_layer_duplicate"; ot->description = "Make a copy of the active Grease Pencil layer"; - + /* callbacks */ ot->exec = gp_layer_copy_exec; ot->poll = gp_active_layer_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -370,14 +370,14 @@ static int gp_hide_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *layer = BKE_gpencil_layer_getactive(gpd); bool unselected = RNA_boolean_get(op->ptr, "unselected"); - + /* sanity checks */ if (ELEM(NULL, gpd, layer)) return OPERATOR_CANCELLED; - + if (unselected) { bGPDlayer *gpl; - + /* hide unselected */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { if (gpl != layer) { @@ -389,10 +389,10 @@ static int gp_hide_exec(bContext *C, wmOperator *op) /* hide selected/active */ layer->flag |= GP_LAYER_HIDE; } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -402,14 +402,14 @@ void GPENCIL_OT_hide(wmOperatorType *ot) ot->name = "Hide Layer(s)"; ot->idname = "GPENCIL_OT_hide"; ot->description = "Hide selected/unselected Grease Pencil layers"; - + /* callbacks */ ot->exec = gp_hide_exec; ot->poll = gp_active_layer_poll; /* NOTE: we need an active layer to play with */ - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected layers"); } @@ -452,7 +452,7 @@ static int gp_reveal_exec(bContext *C, wmOperator *op) /* sanity checks */ if (gpd == NULL) return OPERATOR_CANCELLED; - + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { if (gpl->flag & GP_LAYER_HIDE) { @@ -476,10 +476,10 @@ static int gp_reveal_exec(bContext *C, wmOperator *op) } } } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -489,11 +489,11 @@ void GPENCIL_OT_reveal(wmOperatorType *ot) ot->name = "Show All Layers"; ot->idname = "GPENCIL_OT_reveal"; ot->description = "Show all Grease Pencil layers"; - + /* callbacks */ ot->exec = gp_reveal_exec; ot->poll = gp_reveal_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -507,19 +507,19 @@ static int gp_lock_all_exec(bContext *C, wmOperator *UNUSED(op)) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl; - + /* sanity checks */ if (gpd == NULL) return OPERATOR_CANCELLED; - + /* make all layers non-editable */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { gpl->flag |= GP_LAYER_LOCKED; } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -529,11 +529,11 @@ void GPENCIL_OT_lock_all(wmOperatorType *ot) ot->name = "Lock All Layers"; ot->idname = "GPENCIL_OT_lock_all"; ot->description = "Lock all Grease Pencil layers to prevent them from being accidentally modified"; - + /* callbacks */ ot->exec = gp_lock_all_exec; ot->poll = gp_reveal_poll; /* XXX: could use dedicated poll later */ - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -544,19 +544,19 @@ static int gp_unlock_all_exec(bContext *C, wmOperator *UNUSED(op)) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl; - + /* sanity checks */ if (gpd == NULL) return OPERATOR_CANCELLED; - + /* make all layers editable again */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { gpl->flag &= ~GP_LAYER_LOCKED; } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -566,11 +566,11 @@ void GPENCIL_OT_unlock_all(wmOperatorType *ot) ot->name = "Unlock All Layers"; ot->idname = "GPENCIL_OT_unlock_all"; ot->description = "Unlock all Grease Pencil layers so that they can be edited"; - + /* callbacks */ ot->exec = gp_unlock_all_exec; ot->poll = gp_reveal_poll; /* XXX: could use dedicated poll later */ - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -584,21 +584,21 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op) bGPDlayer *gpl; int flags = GP_LAYER_LOCKED; bool isolate = false; - + if (RNA_boolean_get(op->ptr, "affect_visibility")) flags |= GP_LAYER_HIDE; - + if (ELEM(NULL, gpd, layer)) { BKE_report(op->reports, RPT_ERROR, "No active layer to isolate"); return OPERATOR_CANCELLED; } - + /* Test whether to isolate or clear all flags */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* Skip if this is the active layer */ if (gpl == layer) continue; - + /* If the flags aren't set, that means that the layer is * not alone, so we have some layers to isolate still */ @@ -607,7 +607,7 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op) break; } } - + /* Set/Clear flags as appropriate */ /* TODO: Include onionskinning on this list? */ if (isolate) { @@ -625,10 +625,10 @@ static int gp_isolate_layer_exec(bContext *C, wmOperator *op) gpl->flag &= ~flags; } } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -638,14 +638,14 @@ void GPENCIL_OT_layer_isolate(wmOperatorType *ot) ot->name = "Isolate Layer"; ot->idname = "GPENCIL_OT_layer_isolate"; ot->description = "Toggle whether the active layer is the only one that can be edited and/or visible"; - + /* callbacks */ ot->exec = gp_isolate_layer_exec; ot->poll = gp_active_layer_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "affect_visibility", false, "Affect Visibility", "In addition to toggling the editability, also affect the visibility"); @@ -712,13 +712,13 @@ static int gp_layer_change_invoke(bContext *C, wmOperator *op, const wmEvent *UN { uiPopupMenu *pup; uiLayout *layout; - + /* call the menu, which will call this operator again, hence the canceled */ pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); layout = UI_popup_menu_layout(pup); uiItemsEnumO(layout, "GPENCIL_OT_layer_change", "layer"); UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -727,7 +727,7 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op) bGPdata *gpd = CTX_data_gpencil_data(C); bGPDlayer *gpl = NULL; int layer_num = RNA_enum_get(op->ptr, "layer"); - + /* Get layer or create new one */ if (layer_num == -1) { /* Create layer */ @@ -736,19 +736,19 @@ static int gp_layer_change_exec(bContext *C, wmOperator *op) else { /* Try to get layer */ gpl = BLI_findlink(&gpd->layers, layer_num); - + if (gpl == NULL) { BKE_reportf(op->reports, RPT_ERROR, "Cannot change to non-existent layer (index = %d)", layer_num); return OPERATOR_CANCELLED; } } - + /* Set active layer */ BKE_gpencil_layer_setactive(gpd, gpl); - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -758,15 +758,15 @@ void GPENCIL_OT_layer_change(wmOperatorType *ot) ot->name = "Change Layer"; ot->idname = "GPENCIL_OT_layer_change"; ot->description = "Change active Grease Pencil layer"; - + /* callbacks */ ot->invoke = gp_layer_change_invoke; ot->exec = gp_layer_change_exec; ot->poll = gp_active_layer_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* gp layer to use (dynamic enum) */ ot->prop = RNA_def_enum(ot->srna, "layer", DummyRNA_DEFAULT_items, 0, "Grease Pencil Layer", ""); RNA_def_enum_funcs(ot->prop, ED_gpencil_layers_with_new_enum_itemf); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index bc54bd89958..d48efd75746 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -91,10 +91,10 @@ static int gpencil_editmode_toggle_poll(bContext *C) static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + if (gpd == NULL) return OPERATOR_CANCELLED; - + /* Just toggle editmode flag... */ gpd->flag ^= GP_DATA_STROKE_EDITMODE; /* recalculate parent matrix */ @@ -105,7 +105,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *UNUSED(op)) WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); WM_event_add_notifier(C, NC_GPENCIL | ND_GPENCIL_EDITMODE, NULL); WM_event_add_notifier(C, NC_SCENE | ND_MODE, NULL); - + return OPERATOR_FINISHED; } @@ -115,11 +115,11 @@ void GPENCIL_OT_editmode_toggle(wmOperatorType *ot) ot->name = "Strokes Edit Mode Toggle"; ot->idname = "GPENCIL_OT_editmode_toggle"; ot->description = "Enter/Exit edit mode for Grease Pencil strokes"; - + /* callbacks */ ot->exec = gpencil_editmode_toggle_exec; ot->poll = gpencil_editmode_toggle_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; } @@ -180,10 +180,10 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co { bGPDspoint *pt; int i; - + int start_idx = -1; - - + + /* Step through the original stroke's points: * - We accumulate selected points (from start_idx to current index) * and then convert that to a new stroke @@ -198,7 +198,7 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co } else { size_t len = 0; - + /* is this the end of current island yet? * 1) Point i-1 was the last one that was selected * 2) Point i is the last in the array @@ -210,29 +210,29 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co len = i - start_idx + 1; } //printf("copying from %d to %d = %d\n", start_idx, i, len); - + /* make copies of the relevant data */ if (len) { bGPDstroke *gpsd; - + /* make a stupid copy first of the entire stroke (to get the flags too) */ gpsd = MEM_dupallocN(gps); BLI_strncpy(gpsd->tmp_layerinfo, layername, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */ - + /* initialize triangle memory - will be calculated on next redraw */ gpsd->triangles = NULL; gpsd->flag |= GP_STROKE_RECALC_CACHES; gpsd->tot_triangles = 0; - + /* now, make a new points array, and copy of the relevant parts */ gpsd->points = MEM_callocN(sizeof(bGPDspoint) * len, "gps stroke points copy"); memcpy(gpsd->points, gps->points + start_idx, sizeof(bGPDspoint) * len); gpsd->totpoints = len; - + /* add to temp buffer */ gpsd->next = gpsd->prev = NULL; BLI_addtail(new_strokes, gpsd); - + /* cleanup + reset for next */ start_idx = -1; } @@ -243,12 +243,12 @@ static void gp_duplicate_points(const bGPDstroke *gps, ListBase *new_strokes, co static int gp_duplicate_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); return OPERATOR_CANCELLED; } - + /* for each visible (and editable) layer's selected strokes, * copy the strokes into a temporary buffer, then append * once all done @@ -258,22 +258,22 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op) ListBase new_strokes = {NULL, NULL}; bGPDframe *gpf = gpl->actframe; bGPDstroke *gps; - + if (gpf == NULL) continue; - + /* make copies of selected strokes, and deselect these once we're done */ for (gps = gpf->strokes.first; gps; gps = gps->next) { /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) { continue; } - + if (gps->flag & GP_STROKE_SELECT) { if (gps->totpoints == 1) { /* Special Case: If there's just a single point in this stroke... */ bGPDstroke *gpsd; - + /* make direct copies of the stroke and its points */ gpsd = MEM_dupallocN(gps); BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo)); @@ -282,7 +282,7 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op) /* triangle information - will be calculated on next redraw */ gpsd->flag |= GP_STROKE_RECALC_CACHES; gpsd->triangles = NULL; - + /* add to temp buffer */ gpsd->next = gpsd->prev = NULL; BLI_addtail(&new_strokes, gpsd); @@ -291,23 +291,23 @@ static int gp_duplicate_exec(bContext *C, wmOperator *op) /* delegate to a helper, as there's too much to fit in here (for copying subsets)... */ gp_duplicate_points(gps, &new_strokes, gpl->info); } - + /* deselect original stroke, or else the originals get moved too * (when using the copy + move macro) */ gps->flag &= ~GP_STROKE_SELECT; } } - + /* add all new strokes in temp buffer to the frame (preventing double-copies) */ BLI_movelisttolist(&gpf->strokes, &new_strokes); BLI_assert(new_strokes.first == NULL); } CTX_DATA_END; - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -317,11 +317,11 @@ void GPENCIL_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Strokes"; ot->idname = "GPENCIL_OT_duplicate"; ot->description = "Duplicate the selected Grease Pencil strokes"; - + /* callbacks */ ot->exec = gp_duplicate_exec; ot->poll = gp_stroke_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -350,7 +350,7 @@ static GHash *gp_strokes_copypastebuf_colors = NULL; void ED_gpencil_strokes_copybuf_free(void) { bGPDstroke *gps, *gpsn; - + /* Free the palettes buffer * NOTE: This is done before the strokes so that the name ptrs (keys) are still safe */ @@ -358,17 +358,17 @@ void ED_gpencil_strokes_copybuf_free(void) BLI_ghash_free(gp_strokes_copypastebuf_colors, NULL, MEM_freeN); gp_strokes_copypastebuf_colors = NULL; } - + /* Free the stroke buffer */ for (gps = gp_strokes_copypastebuf.first; gps; gps = gpsn) { gpsn = gps->next; - + if (gps->points) MEM_freeN(gps->points); if (gps->triangles) MEM_freeN(gps->triangles); - + BLI_freelinkN(&gp_strokes_copypastebuf, gps); } - + gp_strokes_copypastebuf.first = gp_strokes_copypastebuf.last = NULL; } @@ -379,18 +379,18 @@ GHash *gp_copybuf_validate_colormap(bGPdata *gpd) { GHash *new_colors = BLI_ghash_str_new("GPencil Paste Dst Colors"); GHashIterator gh_iter; - + /* If there's no active palette yet (i.e. new datablock), add one */ bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); if (palette == NULL) { palette = BKE_gpencil_palette_addnew(gpd, "Pasted Palette", true); } - + /* For each color, figure out what to map to... */ GHASH_ITER(gh_iter, gp_strokes_copypastebuf_colors) { bGPDpalettecolor *palcolor; char *name = BLI_ghashIterator_getKey(&gh_iter); - + /* Look for existing color to map to */ /* XXX: What to do if same name but different color? Behaviour here should depend on a property? */ palcolor = BKE_gpencil_palettecolor_getbyname(palette, name); @@ -398,17 +398,17 @@ GHash *gp_copybuf_validate_colormap(bGPdata *gpd) /* Doesn't Exist - Create new matching color for this palette */ /* XXX: This still doesn't fix the pasting across file boundaries problem... */ bGPDpalettecolor *src_color = BLI_ghashIterator_getValue(&gh_iter); - + palcolor = MEM_dupallocN(src_color); BLI_addtail(&palette->colors, palcolor); - + BLI_uniquename(&palette->colors, palcolor, DATA_("GP Color"), '.', offsetof(bGPDpalettecolor, info), sizeof(palcolor->info)); } - + /* Store this mapping (for use later when pasting) */ BLI_ghash_insert(new_colors, name, palcolor); } - + return new_colors; } @@ -418,15 +418,15 @@ GHash *gp_copybuf_validate_colormap(bGPdata *gpd) static int gp_strokes_copy_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); return OPERATOR_CANCELLED; } - + /* clear the buffer first */ ED_gpencil_strokes_copybuf_free(); - + /* for each visible (and editable) layer's selected strokes, * copy the strokes into a temporary buffer, then append * once all done @@ -435,31 +435,31 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op) { bGPDframe *gpf = gpl->actframe; bGPDstroke *gps; - + if (gpf == NULL) continue; - + /* make copies of selected strokes, and deselect these once we're done */ for (gps = gpf->strokes.first; gps; gps = gps->next) { /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; - + if (gps->flag & GP_STROKE_SELECT) { if (gps->totpoints == 1) { /* Special Case: If there's just a single point in this stroke... */ bGPDstroke *gpsd; - + /* make direct copies of the stroke and its points */ gpsd = MEM_dupallocN(gps); BLI_strncpy(gpsd->tmp_layerinfo, gpl->info, sizeof(gpsd->tmp_layerinfo)); /* saves original layer name */ gpsd->points = MEM_dupallocN(gps->points); - + /* triangles cache - will be recalculated on next redraw */ gpsd->flag |= GP_STROKE_RECALC_CACHES; gpsd->tot_triangles = 0; gpsd->triangles = NULL; - + /* add to temp buffer */ gpsd->next = gpsd->prev = NULL; BLI_addtail(&gp_strokes_copypastebuf, gpsd); @@ -472,26 +472,26 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* Build up hash of colors used in these strokes, making copies of these to protect against dangling pointers */ if (gp_strokes_copypastebuf.first) { gp_strokes_copypastebuf_colors = BLI_ghash_str_new("GPencil CopyBuf Colors"); - + for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { if (BLI_ghash_haskey(gp_strokes_copypastebuf_colors, gps->colorname) == false) { bGPDpalettecolor *color = MEM_dupallocN(gps->palcolor); - + BLI_ghash_insert(gp_strokes_copypastebuf_colors, gps->colorname, color); gps->palcolor = color; } } } } - + /* updates (to ensure operator buttons are refreshed, when used via hotkeys) */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL); // XXX? - + /* done */ return OPERATOR_FINISHED; } @@ -502,11 +502,11 @@ void GPENCIL_OT_copy(wmOperatorType *ot) ot->name = "Copy Strokes"; ot->idname = "GPENCIL_OT_copy"; ot->description = "Copy selected Grease Pencil points and strokes"; - + /* callbacks */ ot->exec = gp_strokes_copy_exec; ot->poll = gp_stroke_edit_poll; - + /* flags */ //ot->flag = OPTYPE_REGISTER; } @@ -535,10 +535,10 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); /* only use active for copy merge */ bGPDframe *gpf; - + eGP_PasteMode type = RNA_enum_get(op->ptr, "type"); GHash *new_colors; - + /* check for various error conditions */ if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); @@ -560,14 +560,14 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) /* Check that some of the strokes in the buffer can be used */ bGPDstroke *gps; bool ok = false; - + for (gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { ok = true; break; } } - + if (ok == false) { /* XXX: this check is not 100% accurate (i.e. image editor is incompatible with normal 2D strokes), * but should be enough to give users a good idea of what's going on @@ -576,28 +576,28 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot paste 2D strokes in 3D View"); else BKE_report(op->reports, RPT_ERROR, "Cannot paste 3D strokes in 2D editors"); - + return OPERATOR_CANCELLED; } } - + /* Deselect all strokes first */ CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { bGPDspoint *pt; int i; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } - + gps->flag &= ~GP_STROKE_SELECT; } CTX_DATA_END; - + /* Ensure that all the necessary colors exist */ new_colors = gp_copybuf_validate_colormap(gpd); - + /* Copy over the strokes from the buffer (and adjust the colors) */ for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { @@ -609,7 +609,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) gpl = CTX_data_active_gpencil_layer(C); } } - + /* Ensure we have a frame to draw into * NOTE: Since this is an op which creates strokes, * we are obliged to add a new frame if one @@ -620,33 +620,33 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op) /* Create new stroke */ bGPDstroke *new_stroke = MEM_dupallocN(gps); new_stroke->tmp_layerinfo[0] = '\0'; - + new_stroke->points = MEM_dupallocN(gps->points); - + new_stroke->flag |= GP_STROKE_RECALC_CACHES; new_stroke->triangles = NULL; - + new_stroke->next = new_stroke->prev = NULL; BLI_addtail(&gpf->strokes, new_stroke); - + /* Fix color references */ BLI_assert(new_stroke->colorname[0] != '\0'); new_stroke->palcolor = BLI_ghash_lookup(new_colors, new_stroke->colorname); - + BLI_assert(new_stroke->palcolor != NULL); BLI_strncpy(new_stroke->colorname, new_stroke->palcolor->info, sizeof(new_stroke->colorname)); - + /*new_stroke->flag |= GP_STROKE_RECALC_COLOR; */ } } } - + /* free temp data */ BLI_ghash_free(new_colors, NULL, NULL); - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -657,19 +657,19 @@ void GPENCIL_OT_paste(wmOperatorType *ot) {GP_COPY_MERGE, "MERGE", 0, "Merge", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Paste Strokes"; ot->idname = "GPENCIL_OT_paste"; ot->description = "Paste previously copied strokes or copy and merge in active layer"; - + /* callbacks */ ot->exec = gp_strokes_paste_exec; ot->poll = gp_strokes_paste_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", copy_type, 0, "Type", ""); } @@ -680,13 +680,13 @@ static int gp_move_to_layer_invoke(bContext *C, wmOperator *op, const wmEvent *U { uiPopupMenu *pup; uiLayout *layout; - + /* call the menu, which will call this operator again, hence the canceled */ pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE); layout = UI_popup_menu_layout(pup); uiItemsEnumO(layout, "GPENCIL_OT_move_to_layer", "layer"); UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -697,7 +697,7 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) bGPDlayer *target_layer = NULL; ListBase strokes = {NULL, NULL}; int layer_num = RNA_enum_get(op->ptr, "layer"); - + /* Get layer or create new one */ if (layer_num == -1) { /* Create layer */ @@ -706,13 +706,13 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) else { /* Try to get layer */ target_layer = BLI_findlink(&gpd->layers, layer_num); - + if (target_layer == NULL) { BKE_reportf(op->reports, RPT_ERROR, "There is no layer number %d", layer_num); return OPERATOR_CANCELLED; } } - + /* Extract all strokes to move to this layer * NOTE: We need to do this in a two-pass system to avoid conflicts with strokes * getting repeatedly moved @@ -721,19 +721,19 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) { bGPDframe *gpf = gpl->actframe; bGPDstroke *gps, *gpsn; - + /* skip if no frame with strokes, or if this is the layer we're moving strokes to */ if ((gpl == target_layer) || (gpf == NULL)) continue; - + /* make copies of selected strokes, and deselect these once we're done */ for (gps = gpf->strokes.first; gps; gps = gpsn) { gpsn = gps->next; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; - + /* TODO: Don't just move entire strokes - instead, only copy the selected portions... */ if (gps->flag & GP_STROKE_SELECT) { BLI_remlink(&gpf->strokes, gps); @@ -742,19 +742,19 @@ static int gp_move_to_layer_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* Paste them all in one go */ if (strokes.first) { Scene *scene = CTX_data_scene(C); bGPDframe *gpf = BKE_gpencil_layer_getframe(target_layer, CFRA, true); - + BLI_movelisttolist(&gpf->strokes, &strokes); BLI_assert((strokes.first == strokes.last) && (strokes.first == NULL)); } - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -764,15 +764,15 @@ void GPENCIL_OT_move_to_layer(wmOperatorType *ot) ot->name = "Move Strokes to Layer"; ot->idname = "GPENCIL_OT_move_to_layer"; ot->description = "Move selected strokes to another layer"; // XXX: allow moving individual points too? - + /* callbacks */ ot->invoke = gp_move_to_layer_invoke; ot->exec = gp_move_to_layer_exec; ot->poll = gp_stroke_edit_poll; // XXX? - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* gp layer to use (dynamic enum) */ ot->prop = RNA_def_enum(ot->srna, "layer", DummyRNA_DEFAULT_items, 0, "Grease Pencil Layer", ""); RNA_def_enum_funcs(ot->prop, ED_gpencil_layers_with_new_enum_itemf); @@ -795,7 +795,7 @@ static int UNUSED_FUNCTION(gp_blank_frame_add_poll)(bContext *C) else { CTX_wm_operator_poll_msg_set(C, "Active region not set"); } - + return 0; } @@ -812,8 +812,8 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op) /* let's just be lazy, and call the "Add New Layer" operator, which sets everything up as required */ WM_operator_name_call(C, "GPENCIL_OT_layer_add", WM_OP_EXEC_DEFAULT, NULL); } - - /* Go through each layer, adding a frame after the active one + + /* Go through each layer, adding a frame after the active one * and/or shunting all the others out of the way */ CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) @@ -830,15 +830,15 @@ static int gp_blank_frame_add_exec(bContext *C, wmOperator *op) gpf->framenum += 1; } } - + /* 2) Now add a new frame, with nothing in it */ gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_NEW); } CTX_DATA_END; - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -849,11 +849,11 @@ void GPENCIL_OT_blank_frame_add(wmOperatorType *ot) ot->idname = "GPENCIL_OT_blank_frame_add"; ot->description = "Insert a blank frame on the current frame " "(all subsequently existing frames, if any, are shifted right by one frame)"; - + /* callbacks */ ot->exec = gp_blank_frame_add_exec; ot->poll = gp_add_poll; - + /* properties */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "all_layers", false, "All Layers", "Create blank frame in all layers, not only active"); @@ -865,7 +865,7 @@ static int gp_actframe_delete_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); - + /* only if there's an active layer with an active frame */ return (gpl && gpl->actframe); } @@ -877,7 +877,7 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0); - + /* if there's no existing Grease-Pencil data there, add some */ if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No grease pencil data"); @@ -887,13 +887,13 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active frame to delete"); return OPERATOR_CANCELLED; } - + /* delete it... */ BKE_gpencil_layer_delframe(gpl, gpf); - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -903,9 +903,9 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) ot->name = "Delete Active Frame"; ot->idname = "GPENCIL_OT_active_frame_delete"; ot->description = "Delete the active frame for the active Grease Pencil Layer"; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* callbacks */ ot->exec = gp_actframe_delete_exec; ot->poll = gp_actframe_delete_poll; @@ -916,7 +916,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) static int gp_actframe_delete_all_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + /* 1) There must be grease pencil data * 2) Hopefully some of the layers have stuff we can use */ @@ -927,26 +927,26 @@ static int gp_actframe_delete_all_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); bool success = false; - + CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) { /* try to get the "active" frame - but only if it actually occurs on this frame */ bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0); - + if (gpf == NULL) continue; - + /* delete it... */ BKE_gpencil_layer_delframe(gpl, gpf); - + /* we successfully modified something */ success = true; } CTX_DATA_END; - + /* updates */ if (success) { - WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } else { @@ -961,9 +961,9 @@ void GPENCIL_OT_active_frames_delete_all(wmOperatorType *ot) ot->name = "Delete All Active Frames"; ot->idname = "GPENCIL_OT_active_frames_delete_all"; ot->description = "Delete the active frame(s) of all editable Grease Pencil layers"; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* callbacks */ ot->exec = gp_actframe_delete_all_exec; ot->poll = gp_actframe_delete_all_poll; @@ -986,36 +986,36 @@ typedef enum eGP_DeleteMode { static int gp_delete_selected_strokes(bContext *C) { bool changed = false; - + CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) { bGPDframe *gpf = gpl->actframe; bGPDstroke *gps, *gpsn; - + if (gpf == NULL) continue; - + /* simply delete strokes which are selected */ for (gps = gpf->strokes.first; gps; gps = gpsn) { gpsn = gps->next; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; - + /* free stroke if selected */ if (gps->flag & GP_STROKE_SELECT) { /* free stroke memory arrays, then stroke itself */ if (gps->points) MEM_freeN(gps->points); if (gps->triangles) MEM_freeN(gps->triangles); BLI_freelinkN(&gpf->strokes, gps); - + changed = true; } } } CTX_DATA_END; - + if (changed) { WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -1031,34 +1031,34 @@ static int gp_delete_selected_strokes(bContext *C) static int gp_dissolve_selected_points(bContext *C) { bool changed = false; - + CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) { bGPDframe *gpf = gpl->actframe; bGPDstroke *gps, *gpsn; - + if (gpf == NULL) continue; - + /* simply delete points from selected strokes * NOTE: we may still have to remove the stroke if it ends up having no points! */ for (gps = gpf->strokes.first; gps; gps = gpsn) { gpsn = gps->next; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; /* check if the color is editable */ if (ED_gpencil_stroke_color_use(gpl, gps) == false) continue; - + if (gps->flag & GP_STROKE_SELECT) { bGPDspoint *pt; int i; - + int tot = gps->totpoints; /* number of points in new buffer */ - + /* First Pass: Count how many points are selected (i.e. how many to remove) */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) { @@ -1066,7 +1066,7 @@ static int gp_dissolve_selected_points(bContext *C) tot--; } } - + /* if no points are left, we simply delete the entire stroke */ if (tot <= 0) { /* remove the entire stroke */ @@ -1080,35 +1080,35 @@ static int gp_dissolve_selected_points(bContext *C) /* just copy all unselected into a smaller buffer */ bGPDspoint *new_points = MEM_callocN(sizeof(bGPDspoint) * tot, "new gp stroke points copy"); bGPDspoint *npt = new_points; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if ((pt->flag & GP_SPOINT_SELECT) == 0) { *npt = *pt; npt++; } } - + /* free the old buffer */ MEM_freeN(gps->points); - + /* save the new buffer */ gps->points = new_points; gps->totpoints = tot; - + /* triangles cache needs to be recalculated */ gps->flag |= GP_STROKE_RECALC_CACHES; gps->tot_triangles = 0; - + /* deselect the stroke, since none of its selected points will still be selected */ gps->flag &= ~GP_STROKE_SELECT; } - + changed = true; } } } CTX_DATA_END; - + if (changed) { WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -1148,10 +1148,10 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke tGPDeleteIsland *islands = MEM_callocN(sizeof(tGPDeleteIsland) * (gps->totpoints + 1) / 2, "gp_point_islands"); bool in_island = false; int num_islands = 0; - + bGPDspoint *pt; int i; - + /* First Pass: Identify start/end of islands */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & tag_flags) { @@ -1161,7 +1161,7 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke else { /* unselected - start of a new island? */ int idx; - + if (in_island) { /* extend existing island */ idx = num_islands - 1; @@ -1171,37 +1171,37 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke /* start of new island */ in_island = true; num_islands++; - + idx = num_islands - 1; islands[idx].start_idx = islands[idx].end_idx = i; } } } - + /* Watch out for special case where No islands = All points selected = Delete Stroke only */ if (num_islands) { /* there are islands, so create a series of new strokes, adding them before the "next" stroke */ int idx; - + /* Create each new stroke... */ for (idx = 0; idx < num_islands; idx++) { tGPDeleteIsland *island = &islands[idx]; bGPDstroke *new_stroke = MEM_dupallocN(gps); - + /* initialize triangle memory - to be calculated on next redraw */ new_stroke->triangles = NULL; new_stroke->flag |= GP_STROKE_RECALC_CACHES; new_stroke->tot_triangles = 0; - + /* Compute new buffer size (+ 1 needed as the endpoint index is "inclusive") */ new_stroke->totpoints = island->end_idx - island->start_idx + 1; new_stroke->points = MEM_callocN(sizeof(bGPDspoint) * new_stroke->totpoints, "gp delete stroke fragment"); - + /* Copy over the relevant points */ memcpy(new_stroke->points, gps->points + island->start_idx, sizeof(bGPDspoint) * new_stroke->totpoints); - - - /* Each island corresponds to a new stroke. We must adjust the + + + /* Each island corresponds to a new stroke. We must adjust the * timings of these new strokes: * * Each point's timing data is a delta from stroke's inittime, so as we erase some points from @@ -1213,15 +1213,15 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke bGPDspoint *pts; float delta = gps->points[island->start_idx].time; int j; - + new_stroke->inittime += (double)delta; - + pts = new_stroke->points; for (j = 0; j < new_stroke->totpoints; j++, pts++) { pts->time -= delta; } } - + /* Add new stroke to the frame */ if (next_stroke) { BLI_insertlinkbefore(&gpf->strokes, next_stroke, new_stroke); @@ -1231,10 +1231,10 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke } } } - + /* free islands */ MEM_freeN(islands); - + /* Delete the old stroke */ MEM_freeN(gps->points); if (gps->triangles) { @@ -1248,40 +1248,40 @@ void gp_stroke_delete_tagged_points(bGPDframe *gpf, bGPDstroke *gps, bGPDstroke static int gp_delete_selected_points(bContext *C) { bool changed = false; - + CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) { bGPDframe *gpf = gpl->actframe; bGPDstroke *gps, *gpsn; - + if (gpf == NULL) continue; - + /* simply delete strokes which are selected */ for (gps = gpf->strokes.first; gps; gps = gpsn) { gpsn = gps->next; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; /* check if the color is editable */ if (ED_gpencil_stroke_color_use(gpl, gps) == false) continue; - - + + if (gps->flag & GP_STROKE_SELECT) { /* deselect old stroke, since it will be used as template for the new strokes */ gps->flag &= ~GP_STROKE_SELECT; - + /* delete unwanted points by splitting stroke into several smaller ones */ gp_stroke_delete_tagged_points(gpf, gps, gpsn, GP_SPOINT_SELECT); - + changed = true; } } } CTX_DATA_END; - + if (changed) { WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -1297,21 +1297,21 @@ static int gp_delete_exec(bContext *C, wmOperator *op) { eGP_DeleteMode mode = RNA_enum_get(op->ptr, "type"); int result = OPERATOR_CANCELLED; - + switch (mode) { case GP_DELETEOP_STROKES: /* selected strokes */ result = gp_delete_selected_strokes(C); break; - + case GP_DELETEOP_POINTS: /* selected points (breaks the stroke into segments) */ result = gp_delete_selected_points(C); break; - + case GP_DELETEOP_FRAME: /* active frame */ result = gp_actframe_delete_exec(C, op); break; } - + return result; } @@ -1323,20 +1323,20 @@ void GPENCIL_OT_delete(wmOperatorType *ot) {GP_DELETEOP_FRAME, "FRAME", 0, "Frame", "Delete active frame"}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Delete"; ot->idname = "GPENCIL_OT_delete"; ot->description = "Delete selected Grease Pencil strokes, vertices, or frames"; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = gp_delete_exec; ot->poll = gp_stroke_edit_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_REGISTER; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_delete_types, 0, "Type", "Method used for deleting Grease Pencil data"); } @@ -1371,7 +1371,7 @@ static int gp_snap_poll(bContext *C) { bGPdata *gpd = CTX_data_gpencil_data(C); ScrArea *sa = CTX_wm_area(C); - + return (gpd != NULL) && ((sa != NULL) && (sa->spacetype == SPACE_VIEW3D)); } @@ -1382,29 +1382,29 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) bGPdata *gpd = ED_gpencil_data_get_active(C); RegionView3D *rv3d = CTX_wm_region_data(C); const float gridf = rv3d->gridview; - + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { bGPDframe *gpf = gpl->actframe; float diff_mat[4][4]; - + /* calculate difference matrix if parent object */ if (gpl->parent != NULL) { ED_gpencil_parent_location(gpl, diff_mat); } - + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { bGPDspoint *pt; int i; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; /* check if the color is editable */ if (ED_gpencil_stroke_color_use(gpl, gps) == false) continue; - + // TODO: if entire stroke is selected, offset entire stroke by same amount? for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { /* only if point is selected */ @@ -1418,11 +1418,11 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) /* apply parent transformations */ float fpt[3]; mul_v3_m4v3(fpt, diff_mat, &pt->x); - + fpt[0] = gridf * floorf(0.5f + fpt[0] / gridf); fpt[1] = gridf * floorf(0.5f + fpt[1] / gridf); fpt[2] = gridf * floorf(0.5f + fpt[2] / gridf); - + /* return data */ copy_v3_v3(&pt->x, fpt); gp_apply_parent_point(gpl, pt); @@ -1432,7 +1432,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) } } } - + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1443,11 +1443,11 @@ void GPENCIL_OT_snap_to_grid(wmOperatorType *ot) ot->name = "Snap Selection to Grid"; ot->idname = "GPENCIL_OT_snap_to_grid"; ot->description = "Snap selected points to the nearest grid points"; - + /* callbacks */ ot->exec = gp_snap_to_grid; ot->poll = gp_snap_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1457,28 +1457,28 @@ void GPENCIL_OT_snap_to_grid(wmOperatorType *ot) static int gp_snap_to_cursor(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - + const bool use_offset = RNA_boolean_get(op->ptr, "use_offset"); const float *cursor_global = ED_view3d_cursor3d_get(scene, v3d); - + for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { bGPDframe *gpf = gpl->actframe; float diff_mat[4][4]; - + /* calculate difference matrix if parent object */ if (gpl->parent != NULL) { ED_gpencil_parent_location(gpl, diff_mat); } - + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { bGPDspoint *pt; int i; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; @@ -1488,14 +1488,14 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op) /* only continue if this stroke is selected (editable doesn't guarantee this)... */ if ((gps->flag & GP_STROKE_SELECT) == 0) continue; - + if (use_offset) { float offset[3]; - + /* compute offset from first point of stroke to cursor */ /* TODO: Allow using midpoint instead? */ sub_v3_v3v3(offset, cursor_global, &gps->points->x); - + /* apply offset to all points in the stroke */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { add_v3_v3(&pt->x, offset); @@ -1513,10 +1513,10 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op) } } } - + } } - + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1527,14 +1527,14 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot) ot->name = "Snap Selection to Cursor"; ot->idname = "GPENCIL_OT_snap_to_cursor"; ot->description = "Snap selected points/strokes to the cursor"; - + /* callbacks */ ot->exec = gp_snap_to_cursor; ot->poll = gp_snap_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "use_offset", true, "With Offset", "Offset the entire stroke instead of selected points only"); @@ -1545,33 +1545,33 @@ void GPENCIL_OT_snap_to_cursor(wmOperatorType *ot) static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - + float *cursor = ED_view3d_cursor3d_get(scene, v3d); float centroid[3] = {0.0f}; float min[3], max[3]; size_t count = 0; - + INIT_MINMAX(min, max); - + /* calculate midpoints from selected points */ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only editable and visible layers are considered */ if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { bGPDframe *gpf = gpl->actframe; float diff_mat[4][4]; - + /* calculate difference matrix if parent object */ if (gpl->parent != NULL) { ED_gpencil_parent_location(gpl, diff_mat); } - + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { bGPDspoint *pt; int i; - + /* skip strokes that are invalid for current view */ if (ED_gpencil_stroke_can_use(C, gps) == false) continue; @@ -1581,7 +1581,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) /* only continue if this stroke is selected (editable doesn't guarantee this)... */ if ((gps->flag & GP_STROKE_SELECT) == 0) continue; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (pt->flag & GP_SPOINT_SELECT) { if (gpl->parent == NULL) { @@ -1592,18 +1592,18 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) /* apply parent transformations */ float fpt[3]; mul_v3_m4v3(fpt, diff_mat, &pt->x); - + add_v3_v3(centroid, fpt); minmax_v3v3_v3(min, max, fpt); } count++; } } - + } } } - + if (v3d->around == V3D_AROUND_CENTER_MEAN && count) { mul_v3_fl(centroid, 1.0f / (float)count); copy_v3_v3(cursor, centroid); @@ -1612,7 +1612,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) mid_v3_v3v3(cursor, min, max); } - + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1623,11 +1623,11 @@ void GPENCIL_OT_snap_cursor_to_selected(wmOperatorType *ot) ot->name = "Snap Cursor to Selected Points"; ot->idname = "GPENCIL_OT_snap_cursor_to_selected"; ot->description = "Snap cursor to center of selected points"; - + /* callbacks */ ot->exec = gp_snap_cursor_to_sel; ot->poll = gp_snap_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1683,27 +1683,27 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); const int type = RNA_enum_get(op->ptr, "type"); - + /* sanity checks */ if (ELEM(NULL, gpd)) return OPERATOR_CANCELLED; - + /* loop all selected strokes */ CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) { if (gpl->actframe == NULL) continue; - + for (bGPDstroke *gps = gpl->actframe->strokes.last; gps; gps = gps->prev) { bGPDpalettecolor *palcolor = gps->palcolor; - + /* skip strokes that are not selected or invalid for current view */ if (((gps->flag & GP_STROKE_SELECT) == 0) || ED_gpencil_stroke_can_use(C, gps) == false) continue; /* skip hidden or locked colors */ if (!palcolor || (palcolor->flag & PC_COLOR_HIDE) || (palcolor->flag & PC_COLOR_LOCKED)) continue; - + switch (type) { case GP_STROKE_CYCLIC_CLOSE: /* Close all (enable) */ @@ -1724,10 +1724,10 @@ static int gp_stroke_cyclical_set_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1743,19 +1743,19 @@ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot) {GP_STROKE_CYCLIC_TOGGLE, "TOGGLE", 0, "Toggle", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Set Cyclical State"; ot->idname = "GPENCIL_OT_stroke_cyclical_set"; ot->description = "Close or open the selected stroke adding an edge from last to first point"; - + /* api callbacks */ ot->exec = gp_stroke_cyclical_set_exec; ot->poll = gp_active_layer_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", cyclic_type, GP_STROKE_CYCLIC_TOGGLE, "Type", ""); } @@ -1766,11 +1766,11 @@ void GPENCIL_OT_stroke_cyclical_set(wmOperatorType *ot) static void gpencil_flip_stroke(bGPDstroke *gps) { int end = gps->totpoints - 1; - + for (int i = 0; i < gps->totpoints / 2; i++) { bGPDspoint *point, *point2; bGPDspoint pt; - + /* save first point */ point = &gps->points[i]; pt.x = point->x; @@ -1780,7 +1780,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps) pt.pressure = point->pressure; pt.strength = point->strength; pt.time = point->time; - + /* replace first point with last point */ point2 = &gps->points[end]; point->x = point2->x; @@ -1790,7 +1790,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps) point->pressure = point2->pressure; point->strength = point2->strength; point->time = point2->time; - + /* replace last point with first saved before */ point = &gps->points[end]; point->x = pt.x; @@ -1800,7 +1800,7 @@ static void gpencil_flip_stroke(bGPDstroke *gps) point->pressure = pt.pressure; point->strength = pt.strength; point->time = pt.time; - + end--; } } @@ -1810,10 +1810,10 @@ static void gpencil_stroke_copy_point(bGPDstroke *gps, bGPDspoint *point, float float pressure, float strength, float deltatime) { bGPDspoint *newpoint; - + gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; - + newpoint = &gps->points[gps->totpoints - 1]; newpoint->x = point->x * delta[0]; newpoint->y = point->y * delta[1]; @@ -1832,28 +1832,28 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a, bGPDstroke *gps_b, co int i; float delta[3] = {1.0f, 1.0f, 1.0f}; float deltatime = 0.0f; - + /* sanity checks */ if (ELEM(NULL, gps_a, gps_b)) return; - + if ((gps_a->totpoints == 0) || (gps_b->totpoints == 0)) return; - + /* define start and end points of each stroke */ float sa[3], sb[3], ea[3], eb[3]; pt = &gps_a->points[0]; copy_v3_v3(sa, &pt->x); - + pt = &gps_a->points[gps_a->totpoints - 1]; copy_v3_v3(ea, &pt->x); - + pt = &gps_b->points[0]; copy_v3_v3(sb, &pt->x); - + pt = &gps_b->points[gps_b->totpoints - 1]; copy_v3_v3(eb, &pt->x); - + /* review if need flip stroke B */ float ea_sb = len_squared_v3v3(ea, sb); float ea_eb = len_squared_v3v3(ea, eb); @@ -1861,19 +1861,19 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a, bGPDstroke *gps_b, co if (ea_eb < ea_sb) { gpencil_flip_stroke(gps_b); } - + /* don't visibly link the first and last points? */ if (leave_gaps) { /* 1st: add one tail point to start invisible area */ point = gps_a->points[gps_a->totpoints - 1]; deltatime = point.time; gpencil_stroke_copy_point(gps_a, &point, delta, 0.0f, 0.0f, 0.0f); - + /* 2nd: add one head point to finish invisible area */ point = gps_b->points[0]; gpencil_stroke_copy_point(gps_a, &point, delta, 0.0f, 0.0f, deltatime); } - + /* 3rd: add all points */ for (i = 0, pt = gps_b->points; i < gps_b->totpoints && pt; i++, pt++) { /* check if still room in buffer */ @@ -1890,25 +1890,25 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) bGPDstroke *gps, *gpsn; bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd); bGPDpalettecolor *palcolor = BKE_gpencil_palettecolor_getactive(palette); - + bGPDframe *gpf_a = NULL; bGPDstroke *stroke_a = NULL; bGPDstroke *stroke_b = NULL; bGPDstroke *new_stroke = NULL; - + const int type = RNA_enum_get(op->ptr, "type"); const bool leave_gaps = RNA_boolean_get(op->ptr, "leave_gaps"); - + /* sanity checks */ if (ELEM(NULL, gpd)) return OPERATOR_CANCELLED; - + if (activegpl->flag & GP_LAYER_LOCKED) return OPERATOR_CANCELLED; - + BLI_assert(ELEM(type, GP_STROKE_JOIN, GP_STROKE_JOINCOPY)); - - + + /* read all selected strokes */ bool first = false; CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) @@ -1916,7 +1916,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) bGPDframe *gpf = gpl->actframe; if (gpf == NULL) continue; - + for (gps = gpf->strokes.first; gps; gps = gpsn) { gpsn = gps->next; if (gps->flag & GP_STROKE_SELECT) { @@ -1928,10 +1928,10 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) if (ED_gpencil_stroke_color_use(gpl, gps) == false) { continue; } - + /* to join strokes, cyclic must be disabled */ gps->flag &= ~GP_STROKE_CYCLIC; - + /* saves first frame and stroke */ if (!first) { first = true; @@ -1940,7 +1940,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) } else { stroke_b = gps; - + /* create a new stroke if was not created before (only created if something to join) */ if (new_stroke == NULL) { new_stroke = MEM_dupallocN(stroke_a); @@ -1948,7 +1948,7 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) new_stroke->triangles = NULL; new_stroke->tot_triangles = 0; new_stroke->flag |= GP_STROKE_RECALC_CACHES; - + /* if new, set current color */ if (type == GP_STROKE_JOINCOPY) { new_stroke->palcolor = palcolor; @@ -1956,10 +1956,10 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) new_stroke->flag |= GP_STROKE_RECALC_COLOR; } } - + /* join new_stroke and stroke B. New stroke will contain all the previous data */ gpencil_stroke_join_strokes(new_stroke, stroke_b, leave_gaps); - + /* if join only, delete old strokes */ if (type == GP_STROKE_JOIN) { if (stroke_a) { @@ -1979,21 +1979,21 @@ static int gp_stroke_join_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* add new stroke if was not added before */ if (type == GP_STROKE_JOINCOPY) { if (new_stroke) { /* Add a new frame if needed */ if (activegpl->actframe == NULL) activegpl->actframe = BKE_gpencil_frame_addnew(activegpl, gpf_a->framenum); - + BLI_addtail(&activegpl->actframe->strokes, new_stroke); } } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2004,19 +2004,19 @@ void GPENCIL_OT_stroke_join(wmOperatorType *ot) {GP_STROKE_JOINCOPY, "JOINCOPY", 0, "Join and Copy", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Join Strokes"; ot->idname = "GPENCIL_OT_stroke_join"; ot->description = "Join selected strokes (optionally as new stroke)"; - + /* api callbacks */ ot->exec = gp_stroke_join_exec; ot->poll = gp_active_layer_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", join_type, GP_STROKE_JOIN, "Type", ""); RNA_def_boolean(ot->srna, "leave_gaps", false, "Leave Gaps", "Leave gaps between joined strokes instead of linking them"); @@ -2038,7 +2038,7 @@ static int gp_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op)) bGPDframe *gpf = gpl->actframe; if (gpf == NULL) continue; - + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { if (gps->flag & GP_STROKE_SELECT) { /* skip strokes that are invalid for current view */ @@ -2049,17 +2049,17 @@ static int gp_stroke_flip_exec(bContext *C, wmOperator *UNUSED(op)) if (ED_gpencil_stroke_color_use(gpl, gps) == false) { continue; } - + /* flip stroke */ gpencil_flip_stroke(gps); } } } CTX_DATA_END; - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -2069,11 +2069,11 @@ void GPENCIL_OT_stroke_flip(wmOperatorType *ot) ot->name = "Flip Stroke"; ot->idname = "GPENCIL_OT_stroke_flip"; ot->description = "Change direction of the points of the selected strokes"; - + /* api callbacks */ ot->exec = gp_stroke_flip_exec; ot->poll = gp_active_layer_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2101,18 +2101,18 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); GP_SpaceConversion gsc = {NULL}; eGP_ReprojectModes mode = RNA_boolean_get(op->ptr, "type"); - + /* init space conversion stuff */ gp_point_conversion_init(C, &gsc); - + /* init autodist for geometry projection */ if (mode == GP_REPROJECT_SURFACE) { view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar); ED_view3d_autodist_init(scene, gsc.ar, CTX_wm_view3d(C), 0); } - + // TODO: For deforming geometry workflow, create new frames? - + /* Go through each editable + selected stroke, adjusting each of its points one by one... */ GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) { @@ -2120,17 +2120,17 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) bGPDspoint *pt; int i; float inverse_diff_mat[4][4]; - + /* Compute inverse matrix for unapplying parenting once instead of doing per-point */ /* TODO: add this bit to the iteration macro? */ if (gpl->parent) { invert_m4_m4(inverse_diff_mat, diff_mat); } - + /* Adjust each point */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { float xy[2]; - + /* 3D to Screenspace */ /* Note: We can't use gp_point_to_xy() here because that uses ints for the screenspace * coordinates, resulting in lost precision, which in turn causes stairstepping @@ -2144,7 +2144,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) gp_point_to_parent_space(pt, diff_mat, &pt2); gp_point_to_xy_fl(&gsc, gps, &pt2, &xy[0], &xy[1]); } - + /* Project screenspace back to 3D space (from current perspective) * so that all points have been treated the same way */ @@ -2156,10 +2156,10 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) /* Geometry - Snap to surfaces of visible geometry */ /* XXX: There will be precision loss (possible stairstep artifacts) from this conversion to satisfy the API's */ const int screen_co[2] = {(int)xy[0], (int)xy[1]}; - + int depth_margin = 0; // XXX: 4 for strokes, 0 for normal float depth; - + /* XXX: The proper procedure computes the depths into an array, to have smooth transitions when all else fails... */ if (ED_view3d_autodist_depth(gsc.ar, screen_co, depth_margin, &depth)) { ED_view3d_autodist_simple(gsc.ar, screen_co, &pt->x, 0, &depth); @@ -2169,7 +2169,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) gp_point_xy_to_3d(&gsc, scene, xy, &pt->x); } } - + /* Unapply parent corrections */ if (gpl->parent) { mul_m4_v3(inverse_diff_mat, &pt->x); @@ -2178,7 +2178,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) } } GP_EDITABLE_STROKES_END; - + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2186,29 +2186,29 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) void GPENCIL_OT_reproject(wmOperatorType *ot) { static const EnumPropertyItem reproject_type[] = { - {GP_REPROJECT_PLANAR, "PLANAR", 0, "Planar", + {GP_REPROJECT_PLANAR, "PLANAR", 0, "Planar", "Reproject the strokes to end up on the same plane, as if drawn from the current viewpoint " "using 'Cursor' Stroke Placement"}, {GP_REPROJECT_SURFACE, "SURFACE", 0, "Surface", "Reproject the strokes on to the scene geometry, as if drawn using 'Surface' placement"}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Reproject Strokes"; ot->idname = "GPENCIL_OT_reproject"; ot->description = "Reproject the selected strokes from the current viewpoint as if they had been newly drawn " "(e.g. to fix problems from accidental 3D cursor movement or accidental viewport changes, " "or for matching deforming geometry)"; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = gp_strokes_reproject_exec; ot->poll = gp_strokes_reproject_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", reproject_type, GP_REPROJECT_PLANAR, "Projection Type", ""); } diff --git a/source/blender/editors/gpencil/gpencil_interpolate.c b/source/blender/editors/gpencil/gpencil_interpolate.c index 83e2a85db49..ff3f5b20858 100644 --- a/source/blender/editors/gpencil/gpencil_interpolate.c +++ b/source/blender/editors/gpencil/gpencil_interpolate.c @@ -89,18 +89,18 @@ static int gpencil_view3d_poll(bContext *C) { bGPdata *gpd = CTX_data_gpencil_data(C); bGPDlayer *gpl = CTX_data_active_gpencil_layer(C); - + /* only 3D view */ ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacetype != SPACE_VIEW3D) { return 0; } - + /* need data to interpolate */ if (ELEM(NULL, gpd, gpl)) { return 0; } - + return 1; } @@ -108,13 +108,13 @@ static int gpencil_view3d_poll(bContext *C) static void gp_interpolate_update_points(bGPDstroke *gps_from, bGPDstroke *gps_to, bGPDstroke *new_stroke, float factor) { bGPDspoint *prev, *pt, *next; - + /* update points */ for (int i = 0; i < new_stroke->totpoints; i++) { prev = &gps_from->points[i]; pt = &new_stroke->points[i]; next = &gps_to->points[i]; - + /* Interpolate all values */ interp_v3_v3v3(&pt->x, &prev->x, &next->x, factor); pt->pressure = interpf(prev->pressure, next->pressure, 1.0f - factor); @@ -130,32 +130,32 @@ static void gp_interpolate_update_strokes(bContext *C, tGPDinterpolate *tgpi) { tGPDinterpolate_layer *tgpil; const float shift = tgpi->shift; - + for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) { bGPDstroke *new_stroke; const float factor = tgpil->factor + shift; - + for (new_stroke = tgpil->interFrame->strokes.first; new_stroke; new_stroke = new_stroke->next) { bGPDstroke *gps_from, *gps_to; int stroke_idx; - + if (new_stroke->totpoints == 0) { continue; } - + /* get strokes to interpolate */ stroke_idx = BLI_findindex(&tgpil->interFrame->strokes, new_stroke); - + gps_from = BLI_findlink(&tgpil->prevFrame->strokes, stroke_idx); gps_to = BLI_findlink(&tgpil->nextFrame->strokes, stroke_idx); - + /* update points position */ if ((gps_from) && (gps_to)) { gp_interpolate_update_points(gps_from, gps_to, new_stroke, factor); } } } - + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); } @@ -164,7 +164,7 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd) { ToolSettings *ts = CTX_data_tool_settings(C); eGP_Interpolate_SettingsFlag flag = ts->gp_interpolate.flag; - + /* get layers */ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* all layers or only active */ @@ -175,12 +175,12 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd) if (!gpencil_layer_is_editable(gpl) || (gpl->actframe == NULL)) { continue; } - + /* read strokes */ for (bGPDstroke *gps_from = gpl->actframe->strokes.first; gps_from; gps_from = gps_from->next) { bGPDstroke *gps_to; int fFrame; - + /* only selected */ if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) { continue; @@ -193,14 +193,14 @@ static bool gp_interpolate_check_todo(bContext *C, bGPdata *gpd) if (ED_gpencil_stroke_color_use(gpl, gps_from) == false) { continue; } - + /* get final stroke to interpolate */ fFrame = BLI_findindex(&gpl->actframe->strokes, gps_from); gps_to = BLI_findlink(&gpl->actframe->next->strokes, fFrame); if (gps_to == NULL) { continue; } - + return true; } } @@ -213,18 +213,18 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) bGPdata *gpd = tgpi->gpd; bGPDlayer *active_gpl = CTX_data_active_gpencil_layer(C); bGPDframe *actframe = active_gpl->actframe; - + /* save initial factor for active layer to define shift limits */ tgpi->init_factor = (float)(tgpi->cframe - actframe->framenum) / (actframe->next->framenum - actframe->framenum + 1); - + /* limits are 100% below 0 and 100% over the 100% */ tgpi->low_limit = -1.0f - tgpi->init_factor; tgpi->high_limit = 2.0f - tgpi->init_factor; - + /* set layers */ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { tGPDinterpolate_layer *tgpil; - + /* all layers or only active */ if (!(tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) && (gpl != active_gpl)) { continue; @@ -233,32 +233,32 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) if (!gpencil_layer_is_editable(gpl) || (gpl->actframe == NULL)) { continue; } - + /* create temp data for each layer */ tgpil = MEM_callocN(sizeof(tGPDinterpolate_layer), "GPencil Interpolate Layer"); - + tgpil->gpl = gpl; tgpil->prevFrame = gpl->actframe; tgpil->nextFrame = gpl->actframe->next; - + BLI_addtail(&tgpi->ilayers, tgpil); - + /* create a new temporary frame */ tgpil->interFrame = MEM_callocN(sizeof(bGPDframe), "bGPDframe"); tgpil->interFrame->framenum = tgpi->cframe; - + /* get interpolation factor by layer (usually must be equal for all layers, but not sure) */ tgpil->factor = (float)(tgpi->cframe - tgpil->prevFrame->framenum) / (tgpil->nextFrame->framenum - tgpil->prevFrame->framenum + 1); - + /* create new strokes data with interpolated points reading original stroke */ for (bGPDstroke *gps_from = tgpil->prevFrame->strokes.first; gps_from; gps_from = gps_from->next) { bGPDstroke *gps_to; int fFrame; - + bGPDstroke *new_stroke; bool valid = true; - - + + /* only selected */ if ((tgpi->flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) { valid = false; @@ -267,19 +267,19 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) if (ED_gpencil_stroke_can_use(C, gps_from) == false) { valid = false; } - + /* check if the color is editable */ if (ED_gpencil_stroke_color_use(tgpil->gpl, gps_from) == false) { valid = false; } - + /* get final stroke to interpolate */ fFrame = BLI_findindex(&tgpil->prevFrame->strokes, gps_from); gps_to = BLI_findlink(&tgpil->nextFrame->strokes, fFrame); if (gps_to == NULL) { valid = false; } - + /* create new stroke */ new_stroke = MEM_dupallocN(gps_from); new_stroke->points = MEM_dupallocN(gps_from->points); @@ -306,7 +306,7 @@ static void gp_interpolate_set_points(bContext *C, tGPDinterpolate *tgpi) new_stroke->triangles = MEM_recallocN(new_stroke->triangles, sizeof(*new_stroke->triangles)); new_stroke->flag |= GP_STROKE_RECALC_CACHES; } - + /* add to strokes */ BLI_addtail(&tgpil->interFrame->strokes, new_stroke); } @@ -339,14 +339,14 @@ static void gpencil_mouse_update_shift(tGPDinterpolate *tgpi, wmOperator *op, co { float mid = (float)(tgpi->ar->winx - tgpi->ar->winrct.xmin) / 2.0f; float mpos = event->x - tgpi->ar->winrct.xmin; - + if (mpos >= mid) { tgpi->shift = ((mpos - mid) * tgpi->high_limit) / mid; } else { tgpi->shift = tgpi->low_limit - ((mpos * tgpi->low_limit) / mid); } - + CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit); RNA_float_set(op->ptr, "shift", tgpi->shift); } @@ -357,19 +357,19 @@ static void gpencil_interpolate_status_indicators(tGPDinterpolate *p) Scene *scene = p->scene; char status_str[UI_MAX_DRAW_STR]; char msg_str[UI_MAX_DRAW_STR]; - + BLI_strncpy(msg_str, IFACE_("GPencil Interpolation: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL/MOVE to adjust factor"), UI_MAX_DRAW_STR); - + if (hasNumInput(&p->num)) { char str_offs[NUM_STR_REP_LEN]; - + outputNumInput(&p->num, str_offs, &scene->unit); BLI_snprintf(status_str, sizeof(status_str), "%s: %s", msg_str, str_offs); } else { BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", msg_str, (int)((p->init_factor + p->shift) * 100.0f)); } - + ED_area_headerprint(p->sa, status_str); } @@ -391,7 +391,7 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op) { tGPDinterpolate *tgpi = op->customdata; tGPDinterpolate_layer *tgpil; - + /* don't assume that operator data exists at all */ if (tgpi) { /* remove drawing handler */ @@ -401,21 +401,21 @@ static void gpencil_interpolate_exit(bContext *C, wmOperator *op) if (tgpi->draw_handle_3d) { ED_region_draw_cb_exit(tgpi->ar->type, tgpi->draw_handle_3d); } - + /* clear status message area */ ED_area_headerprint(tgpi->sa, NULL); - + /* finally, free memory used by temp data */ for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) { BKE_gpencil_free_strokes(tgpil->interFrame); MEM_freeN(tgpil->interFrame); } - + BLI_freelistN(&tgpi->ilayers); MEM_freeN(tgpi); } WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); - + /* clear pointer */ op->customdata = NULL; } @@ -425,24 +425,24 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte { ToolSettings *ts = CTX_data_tool_settings(C); bGPdata *gpd = CTX_data_gpencil_data(C); - + /* set current scene and window */ tgpi->scene = CTX_data_scene(C); tgpi->sa = CTX_wm_area(C); tgpi->ar = CTX_wm_region(C); tgpi->flag = ts->gp_interpolate.flag; - + /* set current frame number */ tgpi->cframe = tgpi->scene->r.cfra; - + /* set GP datablock */ tgpi->gpd = gpd; - + /* set interpolation weight */ tgpi->shift = RNA_float_get(op->ptr, "shift"); /* set layers */ gp_interpolate_set_points(C, tgpi); - + return 1; } @@ -450,10 +450,10 @@ static bool gp_interpolate_set_init_values(bContext *C, wmOperator *op, tGPDinte static tGPDinterpolate *gp_session_init_interpolation(bContext *C, wmOperator *op) { tGPDinterpolate *tgpi = MEM_callocN(sizeof(tGPDinterpolate), "GPencil Interpolate Data"); - + /* define initial values */ gp_interpolate_set_init_values(C, op, tgpi); - + /* return context data for running operator */ return tgpi; } @@ -462,7 +462,7 @@ static tGPDinterpolate *gp_session_init_interpolation(bContext *C, wmOperator *o static int gpencil_interpolate_init(bContext *C, wmOperator *op) { tGPDinterpolate *tgpi; - + /* check context */ tgpi = op->customdata = gp_session_init_interpolation(C, op); if (tgpi == NULL) { @@ -470,7 +470,7 @@ static int gpencil_interpolate_init(bContext *C, wmOperator *op) gpencil_interpolate_exit(C, op); return 0; } - + /* everything is now setup ok */ return 1; } @@ -492,19 +492,19 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent BKE_report(op->reports, RPT_ERROR, "Cannot find a pair of grease pencil frames to interpolate between in active layer"); return OPERATOR_CANCELLED; } - + /* cannot interpolate in extremes */ if (ELEM(CFRA, actframe->framenum, actframe->next->framenum)) { BKE_report(op->reports, RPT_ERROR, "Cannot interpolate as current frame already has existing grease pencil frames"); return OPERATOR_CANCELLED; } - + /* need editable strokes */ if (!gp_interpolate_check_todo(C, gpd)) { BKE_report(op->reports, RPT_ERROR, "Interpolation requires some editable strokes"); return OPERATOR_CANCELLED; } - + /* try to initialize context data needed */ if (!gpencil_interpolate_init(C, op)) { if (op->customdata) @@ -514,24 +514,24 @@ static int gpencil_interpolate_invoke(bContext *C, wmOperator *op, const wmEvent else { tgpi = op->customdata; } - + /* Enable custom drawing handlers - * It needs 2 handlers because strokes can in 3d space and screen space - * and each handler use different coord system + * It needs 2 handlers because strokes can in 3d space and screen space + * and each handler use different coord system */ tgpi->draw_handle_screen = ED_region_draw_cb_activate(tgpi->ar->type, gpencil_interpolate_draw_screen, tgpi, REGION_DRAW_POST_PIXEL); tgpi->draw_handle_3d = ED_region_draw_cb_activate(tgpi->ar->type, gpencil_interpolate_draw_3d, tgpi, REGION_DRAW_POST_VIEW); - + /* set cursor to indicate modal */ WM_cursor_modal_set(win, BC_EW_SCROLLCURSOR); - + /* update shift indicator in header */ gpencil_interpolate_status_indicators(tgpi); WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); - + /* add a modal handler for this operator */ WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; } @@ -544,7 +544,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent bGPDstroke *gps_src, *gps_dst; tGPDinterpolate_layer *tgpil; const bool has_numinput = hasNumInput(&tgpi->num); - + switch (event->type) { case LEFTMOUSE: /* confirm */ case RETKEY: @@ -552,19 +552,19 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent /* return to normal cursor and header status */ ED_area_headerprint(tgpi->sa, NULL); WM_cursor_modal_restore(win); - + /* insert keyframes as required... */ for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) { gpf_dst = BKE_gpencil_layer_getframe(tgpil->gpl, tgpi->cframe, GP_GETFRAME_ADD_NEW); gpf_dst->key_type = BEZT_KEYTYPE_BREAKDOWN; - + /* copy strokes */ BLI_listbase_clear(&gpf_dst->strokes); for (gps_src = tgpil->interFrame->strokes.first; gps_src; gps_src = gps_src->next) { if (gps_src->totpoints == 0) { continue; } - + /* make copy of source stroke, then adjust pointer to points too */ gps_dst = MEM_dupallocN(gps_src); gps_dst->points = MEM_dupallocN(gps_src->points); @@ -573,34 +573,34 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent BLI_addtail(&gpf_dst->strokes, gps_dst); } } - + /* clean up temp data */ gpencil_interpolate_exit(C, op); - + /* done! */ return OPERATOR_FINISHED; } - + case ESCKEY: /* cancel */ case RIGHTMOUSE: { /* return to normal cursor and header status */ ED_area_headerprint(tgpi->sa, NULL); WM_cursor_modal_restore(win); - + /* clean up temp data */ gpencil_interpolate_exit(C, op); - + /* canceled! */ return OPERATOR_CANCELLED; } - + case WHEELUPMOUSE: { tgpi->shift = tgpi->shift + 0.01f; CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit); RNA_float_set(op->ptr, "shift", tgpi->shift); - + /* update screen */ gpencil_interpolate_update(C, op, tgpi); break; @@ -610,7 +610,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent tgpi->shift = tgpi->shift - 0.01f; CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit); RNA_float_set(op->ptr, "shift", tgpi->shift); - + /* update screen */ gpencil_interpolate_update(C, op, tgpi); break; @@ -621,7 +621,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent if (has_numinput == false) { /* update shift based on position of mouse */ gpencil_mouse_update_shift(tgpi, op, event); - + /* update screen */ gpencil_interpolate_update(C, op, tgpi); } @@ -632,21 +632,21 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent if ((event->val == KM_PRESS) && handleNumInput(C, &tgpi->num, event)) { const float factor = tgpi->init_factor; float value; - + /* Grab shift from numeric input, and store this new value (the user see an int) */ value = (factor + tgpi->shift) * 100.0f; applyNumInput(&tgpi->num, &value); tgpi->shift = value / 100.0f; - + /* recalculate the shift to get the right value in the frame scale */ tgpi->shift = tgpi->shift - factor; - + CLAMP(tgpi->shift, tgpi->low_limit, tgpi->high_limit); RNA_float_set(op->ptr, "shift", tgpi->shift); - + /* update screen */ gpencil_interpolate_update(C, op, tgpi); - + break; } else { @@ -655,7 +655,7 @@ static int gpencil_interpolate_modal(bContext *C, wmOperator *op, const wmEvent } } } - + /* still running... */ return OPERATOR_RUNNING_MODAL; } @@ -673,16 +673,16 @@ void GPENCIL_OT_interpolate(wmOperatorType *ot) ot->name = "Grease Pencil Interpolation"; ot->idname = "GPENCIL_OT_interpolate"; ot->description = "Interpolate grease pencil strokes between frames"; - + /* callbacks */ ot->invoke = gpencil_interpolate_invoke; ot->modal = gpencil_interpolate_modal; ot->cancel = gpencil_interpolate_cancel; ot->poll = gpencil_view3d_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; - + /* properties */ RNA_def_float_percentage(ot->srna, "shift", 0.0f, -1.0f, 1.0f, "Shift", "Bias factor for which frame has more influence on the interpolated strokes", -0.9f, 0.9f); } @@ -695,14 +695,14 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting const float begin = 0.0f; const float change = 1.0f; const float duration = 1.0f; - + const float back = ipo_settings->back; const float amplitude = ipo_settings->amplitude; const float period = ipo_settings->period; - + eBezTriple_Easing easing = ipo_settings->easing; float result = time; - + switch (ipo_settings->type) { case GP_IPO_BACK: switch (easing) { @@ -715,7 +715,7 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_back_ease_in_out(time, begin, change, duration, back); break; - + default: /* default/auto: same as ease out */ result = BLI_easing_back_ease_out(time, begin, change, duration, back); break; @@ -733,13 +733,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_bounce_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease out */ result = BLI_easing_bounce_ease_out(time, begin, change, duration); break; } break; - + case GP_IPO_CIRC: switch (easing) { case BEZT_IPO_EASE_IN: @@ -751,7 +751,7 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_circ_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease in */ result = BLI_easing_circ_ease_in(time, begin, change, duration); break; @@ -769,13 +769,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_cubic_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease in */ result = BLI_easing_cubic_ease_in(time, begin, change, duration); break; } break; - + case GP_IPO_ELASTIC: switch (easing) { case BEZT_IPO_EASE_IN: @@ -787,13 +787,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_elastic_ease_in_out(time, begin, change, duration, amplitude, period); break; - + default: /* default/auto: same as ease out */ result = BLI_easing_elastic_ease_out(time, begin, change, duration, amplitude, period); break; } break; - + case GP_IPO_EXPO: switch (easing) { case BEZT_IPO_EASE_IN: @@ -805,13 +805,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_expo_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease in */ result = BLI_easing_expo_ease_in(time, begin, change, duration); break; } break; - + case GP_IPO_QUAD: switch (easing) { case BEZT_IPO_EASE_IN: @@ -823,13 +823,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_quad_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease in */ result = BLI_easing_quad_ease_in(time, begin, change, duration); break; } break; - + case GP_IPO_QUART: switch (easing) { case BEZT_IPO_EASE_IN: @@ -841,13 +841,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_quart_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease in */ result = BLI_easing_quart_ease_in(time, begin, change, duration); break; } break; - + case GP_IPO_QUINT: switch (easing) { case BEZT_IPO_EASE_IN: @@ -859,13 +859,13 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_quint_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease in */ result = BLI_easing_quint_ease_in(time, begin, change, duration); break; } break; - + case GP_IPO_SINE: switch (easing) { case BEZT_IPO_EASE_IN: @@ -877,18 +877,18 @@ static float gp_interpolate_seq_easing_calc(GP_Interpolate_Settings *ipo_setting case BEZT_IPO_EASE_IN_OUT: result = BLI_easing_sine_ease_in_out(time, begin, change, duration); break; - + default: /* default/auto: same as ease in */ result = BLI_easing_sine_ease_in(time, begin, change, duration); break; } break; - + default: printf("%s: Unknown interpolation type - %d\n", __func__, ipo_settings->type); break; } - + return result; } @@ -897,12 +897,12 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) bGPdata *gpd = CTX_data_gpencil_data(C); bGPDlayer *active_gpl = CTX_data_active_gpencil_layer(C); bGPDframe *actframe = active_gpl->actframe; - + Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); GP_Interpolate_Settings *ipo_settings = &ts->gp_interpolate; eGP_Interpolate_SettingsFlag flag = ipo_settings->flag; - + /* cannot interpolate if not between 2 frames */ if (ELEM(NULL, actframe, actframe->next)) { BKE_report(op->reports, RPT_ERROR, "Cannot find a pair of grease pencil frames to interpolate between in active layer"); @@ -913,13 +913,13 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot interpolate as current frame already has existing grease pencil frames"); return OPERATOR_CANCELLED; } - + /* loop all layer to check if need interpolation */ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { bGPDframe *prevFrame, *nextFrame; bGPDstroke *gps_from, *gps_to; int cframe, fFrame; - + /* all layers or only active */ if (((flag & GP_TOOLFLAG_INTERPOLATE_ALL_LAYERS) == 0) && (gpl != active_gpl)) { continue; @@ -928,19 +928,19 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) if (!gpencil_layer_is_editable(gpl) || (gpl->actframe == NULL)) { continue; } - + /* store extremes */ prevFrame = gpl->actframe; nextFrame = gpl->actframe->next; - + /* Loop over intermediary frames and create the interpolation */ for (cframe = prevFrame->framenum + 1; cframe < nextFrame->framenum; cframe++) { bGPDframe *interFrame = NULL; float factor; - + /* get interpolation factor */ factor = (float)(cframe - prevFrame->framenum) / (nextFrame->framenum - prevFrame->framenum + 1); - + if (ipo_settings->type == GP_IPO_CURVEMAP) { /* custom curvemap */ if (ipo_settings->custom_ipo) { @@ -954,11 +954,11 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) /* easing equation... */ factor = gp_interpolate_seq_easing_calc(ipo_settings, factor); } - + /* create new strokes data with interpolated points reading original stroke */ for (gps_from = prevFrame->strokes.first; gps_from; gps_from = gps_from->next) { bGPDstroke *new_stroke; - + /* only selected */ if ((flag & GP_TOOLFLAG_INTERPOLATE_ONLY_SELECTED) && ((gps_from->flag & GP_STROKE_SELECT) == 0)) { continue; @@ -971,20 +971,20 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) if (ED_gpencil_stroke_color_use(gpl, gps_from) == false) { continue; } - + /* get final stroke to interpolate */ fFrame = BLI_findindex(&prevFrame->strokes, gps_from); gps_to = BLI_findlink(&nextFrame->strokes, fFrame); if (gps_to == NULL) { continue; } - + /* create a new frame if needed */ if (interFrame == NULL) { interFrame = BKE_gpencil_layer_getframe(gpl, cframe, GP_GETFRAME_ADD_NEW); interFrame->key_type = BEZT_KEYTYPE_BREAKDOWN; } - + /* create new stroke */ new_stroke = MEM_dupallocN(gps_from); new_stroke->points = MEM_dupallocN(gps_from->points); @@ -999,19 +999,19 @@ static int gpencil_interpolate_seq_exec(bContext *C, wmOperator *op) new_stroke->tot_triangles = 0; new_stroke->flag |= GP_STROKE_RECALC_CACHES; } - + /* update points position */ gp_interpolate_update_points(gps_from, gps_to, new_stroke, factor); - + /* add to strokes */ BLI_addtail(&interFrame->strokes, new_stroke); } } } - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1021,11 +1021,11 @@ void GPENCIL_OT_interpolate_sequence(wmOperatorType *ot) ot->name = "Interpolate Sequence"; ot->idname = "GPENCIL_OT_interpolate_sequence"; ot->description = "Generate 'in-betweens' to smoothly interpolate between Grease Pencil frames"; - + /* api callbacks */ ot->exec = gpencil_interpolate_seq_exec; ot->poll = gpencil_view3d_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1045,7 +1045,7 @@ static int gpencil_interpolate_reverse_poll(bContext *C) CTX_wm_operator_poll_msg_set(C, "Expected current frame to be a breakdown"); return 0; } - + return 1; } @@ -1059,11 +1059,11 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op)) bGPDframe *start_key = NULL; bGPDframe *end_key = NULL; bGPDframe *gpf, *gpfn; - + /* Only continue if we're currently on a breakdown keyframe */ if ((gpl->actframe == NULL) || (gpl->actframe->key_type != BEZT_KEYTYPE_BREAKDOWN)) continue; - + /* Search left for "start_key" (i.e. the first breakdown to remove) */ gpf = gpl->actframe; while (gpf) { @@ -1077,7 +1077,7 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + /* Search right for "end_key" (i.e. the last breakdown to remove) */ gpf = gpl->actframe; while (gpf) { @@ -1091,36 +1091,36 @@ static int gpencil_interpolate_reverse_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + /* Did we find anything? */ /* NOTE: We should only proceed if there's something before/after these extents... * Otherwise, there's just an extent of breakdowns with no keys to interpolate between */ - if ((start_key && end_key) && + if ((start_key && end_key) && ELEM(NULL, start_key->prev, end_key->next) == false) { /* Set actframe to the key before start_key, since the keys have been removed now */ gpl->actframe = start_key->prev; - + /* Free each frame we're removing (except the last one) */ for (gpf = start_key; gpf && gpf != end_key; gpf = gpfn) { gpfn = gpf->next; - + /* free strokes and their associated memory */ BKE_gpencil_free_strokes(gpf); BLI_freelinkN(&gpl->frames, gpf); } - + /* Now free the last one... */ BKE_gpencil_free_strokes(end_key); BLI_freelinkN(&gpl->frames, end_key); } } CTX_DATA_END; - + /* notifiers */ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -1130,11 +1130,11 @@ void GPENCIL_OT_interpolate_reverse(wmOperatorType *ot) ot->name = "Remove Breakdowns"; ot->idname = "GPENCIL_OT_interpolate_reverse"; ot->description = "Remove breakdown frames generated by interpolating between two Grease Pencil frames"; - + /* callbacks */ ot->exec = gpencil_interpolate_reverse_exec; ot->poll = gpencil_interpolate_reverse_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index 3a2169798e5..84a106856b3 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -57,28 +57,28 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil", 0, 0); wmKeyMapItem *kmi; - + /* Draw --------------------------------------- */ /* draw */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY); RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); RNA_boolean_set(kmi->ptr, "wait_for_input", false); - + /* draw - straight lines */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY); RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT); RNA_boolean_set(kmi->ptr, "wait_for_input", false); - + /* draw - poly lines */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY); RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY); RNA_boolean_set(kmi->ptr, "wait_for_input", false); - + /* erase */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY); RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); RNA_boolean_set(kmi->ptr, "wait_for_input", false); - + /* Tablet Mappings for Drawing ------------------ */ /* For now, only support direct drawing using the eraser, as most users using a tablet * may still want to use that as their primary pointing device! @@ -88,24 +88,24 @@ static void ed_keymap_gpencil_general(wmKeyConfig *keyconf) RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); RNA_boolean_set(kmi->ptr, "wait_for_input", false); #endif - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", TABLET_ERASER, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); RNA_boolean_set(kmi->ptr, "wait_for_input", false); - + /* Viewport Tools ------------------------------- */ - + /* Enter EditMode */ WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, DKEY); - + /* Pie Menu - For standard tools */ WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_tool_palette", QKEY, KM_PRESS, 0, DKEY); WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_settings_palette", WKEY, KM_PRESS, 0, DKEY); - + /* Add Blank Frame */ /* XXX: BKEY or NKEY? BKEY is easier to reach from DKEY, so we'll use that for now */ WM_keymap_add_item(keymap, "GPENCIL_OT_blank_frame_add", BKEY, KM_PRESS, 0, DKEY); - + /* Delete Active Frame - For easier video tutorials/review sessions */ /* NOTE: This works even when not in EditMode */ WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, 0, DKEY); @@ -125,81 +125,81 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Grease Pencil Stroke Edit Mode", 0, 0); wmKeyMapItem *kmi; - + /* set poll callback - so that this keymap only gets enabled when stroke editmode is enabled */ keymap->poll = gp_stroke_editmode_poll; - + /* ----------------------------------------------- */ - + /* Exit EditMode */ WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, KM_PRESS, 0, 0); - + /* Pie Menu - For settings/tools easy access */ WM_keymap_add_menu_pie(keymap, "GPENCIL_MT_pie_sculpt", EKEY, KM_PRESS, 0, DKEY); - + /* Brush Settings */ /* NOTE: We cannot expose these in the standard keymap, as they will interfere with regular hotkeys * in other modes. However, when we are dealing with Stroke Edit Mode, we know for certain * that the only data being edited is that of the Grease Pencil strokes */ - + /* CTRL + FKEY = Eraser Radius */ kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path_primary", "user_preferences.edit.grease_pencil_eraser_radius"); - + /* Interpolation */ WM_keymap_add_item(keymap, "GPENCIL_OT_interpolate", EKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "GPENCIL_OT_interpolate_sequence", EKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); /* Sculpting ------------------------------------- */ - + /* Brush-Based Editing: - * EKEY + LMB = Single stroke, draw immediately + * EKEY + LMB = Single stroke, draw immediately * + Other Modifiers (Ctrl/Shift) = Invert, Smooth, etc. * * For the modal version, use D+E -> Sculpt */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_paint", LEFTMOUSE, KM_PRESS, 0, EKEY); RNA_boolean_set(kmi->ptr, "wait_for_input", false); - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_paint", LEFTMOUSE, KM_PRESS, KM_CTRL, EKEY); RNA_boolean_set(kmi->ptr, "wait_for_input", false); /*RNA_boolean_set(kmi->ptr, "use_invert", true);*/ - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_paint", LEFTMOUSE, KM_PRESS, KM_SHIFT, EKEY); RNA_boolean_set(kmi->ptr, "wait_for_input", false); /*RNA_boolean_set(kmi->ptr, "use_smooth", true);*/ - - + + /* Shift-FKEY = Sculpt Strength */ kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.gpencil_sculpt.brush.strength"); - + /* FKEY = Sculpt Brush Size */ kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.gpencil_sculpt.brush.size"); - - + + /* Selection ------------------------------------- */ /* select all */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "action", SEL_INVERT); - + /* circle select */ WM_keymap_add_item(keymap, "GPENCIL_OT_select_circle", CKEY, KM_PRESS, 0, 0); - + /* border select */ WM_keymap_add_item(keymap, "GPENCIL_OT_select_border", BKEY, KM_PRESS, 0, 0); - + /* lasso select */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + /* In the Node Editor, lasso select needs ALT modifier too (as somehow CTRL+LMB drag gets taken for "cut" quite early) * There probably isn't too much harm adding this for other editors too as part of standard GP editing keymap. This hotkey * combo doesn't seem to see much use under standard scenarios? @@ -208,57 +208,57 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + /* normal select */ WM_keymap_add_item(keymap, "GPENCIL_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); RNA_boolean_set(kmi->ptr, "toggle", true); - + /* whole stroke select */ kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "entire_strokes", true); - + /* select linked */ /* NOTE: While LKEY is redundant, not having it breaks the mode illusion too much */ WM_keymap_add_item(keymap, "GPENCIL_OT_select_linked", LKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GPENCIL_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); - + /* select grouped */ WM_keymap_add_item(keymap, "GPENCIL_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); - + /* select more/less */ WM_keymap_add_item(keymap, "GPENCIL_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GPENCIL_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - + /* Editing ----------------------------------------- */ - + /* duplicate and move selected points */ WM_keymap_add_item(keymap, "GPENCIL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - + /* delete */ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_gpencil_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_gpencil_delete", DELKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", XKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GPENCIL_OT_dissolve", DELKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "GPENCIL_OT_active_frames_delete_all", XKEY, KM_PRESS, KM_SHIFT, 0); - + /* menu edit specials */ WM_keymap_add_menu(keymap, "GPENCIL_MT_gpencil_edit_specials", WKEY, KM_PRESS, 0, 0); /* join strokes */ WM_keymap_add_item(keymap, "GPENCIL_OT_stroke_join", JKEY, KM_PRESS, KM_CTRL, 0); - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_stroke_join", JKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", GP_STROKE_JOINCOPY); - + /* copy + paste */ WM_keymap_add_item(keymap, "GPENCIL_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GPENCIL_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); - + #ifdef __APPLE__ WM_keymap_add_item(keymap, "GPENCIL_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "GPENCIL_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); @@ -266,32 +266,32 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) /* snap */ WM_keymap_add_menu(keymap, "GPENCIL_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - - + + /* convert to geometry */ WM_keymap_add_item(keymap, "GPENCIL_OT_convert", CKEY, KM_PRESS, KM_ALT, 0); - - + + /* Show/Hide */ /* NOTE: These are available only in EditMode now, since they clash with general-purpose hotkeys */ WM_keymap_add_item(keymap, "GPENCIL_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); - + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "unselected", true); WM_keymap_add_item(keymap, "GPENCIL_OT_selection_opacity_toggle", HKEY, KM_PRESS, KM_CTRL, 0); - + /* Isolate Layer */ WM_keymap_add_item(keymap, "GPENCIL_OT_layer_isolate", PADASTERKEY, KM_PRESS, 0, 0); - + /* Move to Layer */ WM_keymap_add_item(keymap, "GPENCIL_OT_move_to_layer", MKEY, KM_PRESS, 0, 0); /* Select drawing brush using index */ - kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", ONEKEY, KM_PRESS, 0, 0); + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", ONEKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "index", 0); kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_brush_select", TWOKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "index", 1); @@ -314,24 +314,24 @@ static void ed_keymap_gpencil_editing(wmKeyConfig *keyconf) /* Transform Tools */ kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", GKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", EVT_TWEAK_S, KM_ANY, 0, 0); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_rotate", RKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_resize", SKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_bend", WKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "TRANSFORM_OT_tosphere", SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "TRANSFORM_OT_shear", SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0); - + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_ALT, 0); RNA_enum_set(kmi->ptr, "mode", TFM_GPENCIL_SHRINKFATTEN); - + /* Proportional Editing */ ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_editmode(keyconf, keymap, true); @@ -350,11 +350,11 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf) void ED_operatortypes_gpencil(void) { /* Drawing ----------------------- */ - + WM_operatortype_append(GPENCIL_OT_draw); - + /* Editing (Strokes) ------------ */ - + WM_operatortype_append(GPENCIL_OT_editmode_toggle); WM_operatortype_append(GPENCIL_OT_selection_opacity_toggle); @@ -363,41 +363,41 @@ void ED_operatortypes_gpencil(void) WM_operatortype_append(GPENCIL_OT_select_circle); WM_operatortype_append(GPENCIL_OT_select_border); WM_operatortype_append(GPENCIL_OT_select_lasso); - + WM_operatortype_append(GPENCIL_OT_select_linked); WM_operatortype_append(GPENCIL_OT_select_grouped); WM_operatortype_append(GPENCIL_OT_select_more); WM_operatortype_append(GPENCIL_OT_select_less); WM_operatortype_append(GPENCIL_OT_select_first); WM_operatortype_append(GPENCIL_OT_select_last); - + WM_operatortype_append(GPENCIL_OT_duplicate); WM_operatortype_append(GPENCIL_OT_delete); WM_operatortype_append(GPENCIL_OT_dissolve); WM_operatortype_append(GPENCIL_OT_copy); WM_operatortype_append(GPENCIL_OT_paste); - + WM_operatortype_append(GPENCIL_OT_move_to_layer); WM_operatortype_append(GPENCIL_OT_layer_change); - + WM_operatortype_append(GPENCIL_OT_snap_to_grid); WM_operatortype_append(GPENCIL_OT_snap_to_cursor); WM_operatortype_append(GPENCIL_OT_snap_cursor_to_selected); - + WM_operatortype_append(GPENCIL_OT_reproject); - + WM_operatortype_append(GPENCIL_OT_brush_paint); - + /* Editing (Buttons) ------------ */ - + WM_operatortype_append(GPENCIL_OT_data_add); WM_operatortype_append(GPENCIL_OT_data_unlink); - + WM_operatortype_append(GPENCIL_OT_layer_add); WM_operatortype_append(GPENCIL_OT_layer_remove); WM_operatortype_append(GPENCIL_OT_layer_move); WM_operatortype_append(GPENCIL_OT_layer_duplicate); - + WM_operatortype_append(GPENCIL_OT_hide); WM_operatortype_append(GPENCIL_OT_reveal); WM_operatortype_append(GPENCIL_OT_lock_all); @@ -406,10 +406,10 @@ void ED_operatortypes_gpencil(void) WM_operatortype_append(GPENCIL_OT_layer_merge); WM_operatortype_append(GPENCIL_OT_blank_frame_add); - + WM_operatortype_append(GPENCIL_OT_active_frame_delete); WM_operatortype_append(GPENCIL_OT_active_frames_delete_all); - + WM_operatortype_append(GPENCIL_OT_convert); WM_operatortype_append(GPENCIL_OT_stroke_arrange); @@ -445,7 +445,7 @@ void ED_operatortypes_gpencil(void) WM_operatortype_append(GPENCIL_OT_brush_select); /* Editing (Time) --------------- */ - + /* Interpolation */ WM_operatortype_append(GPENCIL_OT_interpolate); WM_operatortype_append(GPENCIL_OT_interpolate_sequence); @@ -456,7 +456,7 @@ void ED_operatormacros_gpencil(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + /* Duplicate + Move = Interactively place newly duplicated strokes */ ot = WM_operatortype_append_macro("GPENCIL_OT_duplicate_move", "Duplicate Strokes", "Make copies of the selected Grease Pencil strokes and move them", diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 84b3ddccf77..af140501069 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -112,35 +112,35 @@ typedef enum eGPencil_PaintFlags { */ typedef struct tGPsdata { Scene *scene; /* current scene from context */ - + wmWindow *win; /* window where painting originated */ ScrArea *sa; /* area where painting originated */ ARegion *ar; /* region where painting originated */ View2D *v2d; /* needed for GP_STROKE_2DSPACE */ rctf *subrect; /* for using the camera rect within the 3d view */ rctf subrect_data; - + GP_SpaceConversion gsc; /* settings to pass to gp_points_to_xy() */ - + PointerRNA ownerPtr; /* pointer to owner of gp-datablock */ bGPdata *gpd; /* gp-datablock layer comes from */ bGPDlayer *gpl; /* layer we're working on */ bGPDframe *gpf; /* frame we're working on */ - + char *align_flag; /* projection-mode flags (toolsettings - eGPencil_Placement_Flags) */ - + eGPencil_PaintStatus status; /* current status of painting */ eGPencil_PaintModes paintmode; /* mode for painting */ eGPencil_PaintFlags flags; /* flags that can get set during runtime (eGPencil_PaintFlags) */ - + short radius; /* radius of influence for eraser */ - + int mval[2]; /* current mouse-position */ int mvalo[2]; /* previous recorded mouse-position */ - + float pressure; /* current stylus pressure */ float opressure; /* previous stylus pressure */ - + /* These need to be doubles, as (at least under unix) they are in seconds since epoch, * float (and its 7 digits precision) is definitively not enough here! * double, with its 15 digits precision, ensures us millisecond precision for a few centuries at least. @@ -148,13 +148,13 @@ typedef struct tGPsdata { double inittime; /* Used when converting to path */ double curtime; /* Used when converting to path */ double ocurtime; /* Used when converting to path */ - + float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space * to region space */ float mat[4][4]; - + float custom_color[4]; /* custom color - hack for enforcing a particular color for track/mask editing */ - + void *erasercursor; /* radial cursor data for drawing eraser */ bGPDpalettecolor *palettecolor; /* current palette color */ @@ -211,7 +211,7 @@ static int gpencil_draw_poll(bContext *C) else { CTX_wm_operator_poll_msg_set(C, "Active region not set"); } - + return 0; } @@ -232,12 +232,12 @@ static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { View3D *v3d = p->sa->spacedata.first; const float *fp = ED_view3d_cursor3d_get(p->scene, v3d); - + /* the reference point used depends on the owner... */ #if 0 /* XXX: disabled for now, since we can't draw relative to the owner yet */ if (p->ownerPtr.type == &RNA_Object) { Object *ob = (Object *)p->ownerPtr.data; - + /* active Object * - use relative distance of 3D-cursor from object center */ @@ -258,24 +258,24 @@ static bool gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) { int dx = abs(mval[0] - pmval[0]); int dy = abs(mval[1] - pmval[1]); - + /* if buffer is empty, just let this go through (i.e. so that dots will work) */ if (p->gpd->sbuffer_size == 0) return true; - + /* check if mouse moved at least certain distance on both axes (best case) * - aims to eliminate some jitter-noise from input when trying to draw straight lines freehand */ else if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) return true; - + /* check if the distance since the last point is significant enough * - prevents points being added too densely * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though */ else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) return true; - + /* mouse 'didn't move' */ else return false; @@ -344,7 +344,7 @@ static void gp_reproject_toplane(tGPsdata *p, bGPDstroke *gps) static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth) { bGPdata *gpd = p->gpd; - + /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) { if (gpencil_project_check(p) && (ED_view3d_autodist_simple(p->ar, mval, out, 0, depth))) { @@ -357,7 +357,7 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] float rvec[3], dvec[3]; float mval_f[2] = {UNPACK2(mval)}; float zfac; - + /* Current method just converts each point in screen-coordinates to * 3D-coordinates using the 3D-cursor as reference. In general, this * works OK, but it could of course be improved. @@ -366,10 +366,10 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] * - investigate using nearest point(s) on a previous stroke as * reference point instead or as offset, for easier stroke matching */ - + gp_get_3d_reference(p, rvec); zfac = ED_view3d_calc_zfac(p->ar->regiondata, rvec, NULL); - + if (ED_view3d_project_float_global(p->ar, rvec, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval_f); ED_view3d_win_to_delta(p->ar, mval_f, dvec, zfac); @@ -380,13 +380,13 @@ static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3] } } } - + /* 2d - on 'canvas' (assume that p->v2d is set) */ else if ((gpd->sbuffer_sflag & GP_STROKE_2DSPACE) && (p->v2d)) { UI_view2d_region_to_view(p->v2d, mval[0], mval[1], &out[0], &out[1]); mul_v3_m4v3(out, p->imat, out); } - + /* 2d - relative to screen (viewport area) */ else { if (p->subrect == NULL) { /* normal 3D view */ @@ -472,7 +472,7 @@ static void gp_brush_angle(bGPdata *gpd, bGPDbrush *brush, tGPspoint *pt, const fac = 1.0f - fabs(dot_v2v2(v0, mvec)); /* 0.0 to 1.0 */ /* interpolate with previous point for smoother transitions */ mpressure = interpf(pt->pressure - (sen * fac), (pt - 1)->pressure, 0.3f); - pt->pressure = mpressure; + pt->pressure = mpressure; CLAMP(pt->pressure, GPENCIL_ALPHA_OPACITY_THRESH, 1.0f); } @@ -493,13 +493,13 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, if (gpd->sbuffer_size == 0) { /* first point in buffer (start point) */ pt = (tGPspoint *)(gpd->sbuffer); - + /* store settings */ copy_v2_v2_int(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); - + /* increment buffer size */ gpd->sbuffer_size++; } @@ -508,17 +508,17 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, * - assume that pointers for this are always valid... */ pt = ((tGPspoint *)(gpd->sbuffer) + 1); - + /* store settings */ copy_v2_v2_int(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); - + /* now the buffer has 2 points (and shouldn't be allowed to get any larger) */ gpd->sbuffer_size = 2; } - + /* can keep carrying on this way :) */ return GP_STROKEADD_NORMAL; } @@ -526,10 +526,10 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, /* check if still room in buffer */ if (gpd->sbuffer_size >= GP_STROKE_BUFFER_MAX) return GP_STROKEADD_OVERFLOW; - + /* get pointer to destination point */ pt = ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); - + /* store settings */ /* pressure */ if (brush->flag & GP_BRUSH_USE_PRESSURE) { @@ -591,10 +591,10 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, /* point time */ pt->time = (float)(curtime - p->inittime); - + /* increment counters */ gpd->sbuffer_size++; - + /* check if another operation can still occur */ if (gpd->sbuffer_size == GP_STROKE_BUFFER_MAX) return GP_STROKEADD_FULL; @@ -602,17 +602,17 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, return GP_STROKEADD_NORMAL; } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { - + bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); /* get pointer to destination point */ pt = (tGPspoint *)(gpd->sbuffer); - + /* store settings */ copy_v2_v2_int(&pt->x, mval); pt->pressure = 1.0f; /* T44932 - Pressure vals are unreliable, so ignore for now */ pt->strength = 1.0f; pt->time = (float)(curtime - p->inittime); - + /* if there's stroke for this poly line session add (or replace last) point * to stroke. This allows to draw lines more interactively (see new segment * during mouse slide, e.g.) @@ -620,15 +620,15 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, if (gp_stroke_added_check(p)) { bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; - + /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->sbuffer_size == 0) { gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; } - + pts = &gps->points[gps->totpoints - 1]; - + /* special case for poly lines: normally, * depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, @@ -636,11 +636,11 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, */ if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; - + view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init(p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } - + /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL); /* if axis locked, reproject to plane locked (only in 3d space) */ @@ -658,11 +658,11 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure, /* force fill recalc */ gps->flag |= GP_STROKE_RECALC_CACHES; } - + /* increment counters */ if (gpd->sbuffer_size == 0) gpd->sbuffer_size++; - + return GP_STROKEADD_NORMAL; } @@ -681,15 +681,15 @@ static void gp_stroke_simplify(tGPsdata *p) short num_points = gpd->sbuffer_size; short flag = gpd->sbuffer_sflag; short i, j; - + /* only simplify if simplification is enabled, and we're not doing a straight line */ if (!(U.gp_settings & GP_PAINT_DOSIMPLIFY) || (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT)) return; - + /* don't simplify if less than 4 points in buffer */ if ((num_points <= 4) || (old_points == NULL)) return; - + /* clear buffer (but don't free mem yet) so that we can write to it * - firstly set sbuffer to NULL, so a new one is allocated * - secondly, reset flag after, as it gets cleared auto @@ -697,7 +697,7 @@ static void gp_stroke_simplify(tGPsdata *p) gpd->sbuffer = NULL; gp_session_validatebuffer(p); gpd->sbuffer_sflag = flag; - + /* macro used in loop to get position of new point * - used due to the mixture of datatypes in use here */ @@ -708,39 +708,39 @@ static void gp_stroke_simplify(tGPsdata *p) pressure += old_points[offs].pressure * sfac; \ time += old_points[offs].time * sfac; \ } (void)0 - + /* XXX Here too, do not lose start and end points! */ gp_stroke_addpoint(p, &old_points->x, old_points->pressure, p->inittime + (double)old_points->time); for (i = 0, j = 0; i < num_points; i++) { if (i - j == 3) { float co[2], pressure, time; int mco[2]; - + /* initialize values */ co[0] = 0.0f; co[1] = 0.0f; pressure = 0.0f; time = 0.0f; - + /* using macro, calculate new point */ GP_SIMPLIFY_AVPOINT(j, -0.25f); GP_SIMPLIFY_AVPOINT(j + 1, 0.75f); GP_SIMPLIFY_AVPOINT(j + 2, 0.75f); GP_SIMPLIFY_AVPOINT(j + 3, -0.25f); - + /* set values for adding */ mco[0] = (int)co[0]; mco[1] = (int)co[1]; - + /* ignore return values on this... assume to be ok for now */ gp_stroke_addpoint(p, mco, pressure, p->inittime + (double)time); - + j += 2; } } gp_stroke_addpoint(p, &old_points[num_points - 1].x, old_points[num_points - 1].pressure, p->inittime + (double)old_points[num_points - 1].time); - + /* free old buffer */ MEM_freeN(old_points); } @@ -755,11 +755,11 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) tGPspoint *ptc; bGPDbrush *brush = p->brush; ToolSettings *ts = p->scene->toolsettings; - + int i, totelem; /* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */ int depth_margin = (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 4 : 0; - + /* get total number of points to allocate space for * - drawing straight-lines only requires the endpoints */ @@ -767,14 +767,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) totelem = (gpd->sbuffer_size >= 2) ? 2 : gpd->sbuffer_size; else totelem = gpd->sbuffer_size; - + /* exit with error if no valid points from this stroke */ if (totelem == 0) { if (G.debug & G_DEBUG) printf("Error: No valid points in stroke buffer to convert (tot=%d)\n", gpd->sbuffer_size); return; } - + /* special case for poly line -- for already added stroke during session * coordinates are getting added to stroke immediately to allow more * interactive behavior @@ -784,23 +784,23 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) return; } } - + /* allocate memory for a new stroke */ gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); - + /* copy appropriate settings for stroke */ gps->totpoints = totelem; gps->thickness = brush->thickness; gps->flag = gpd->sbuffer_sflag; gps->inittime = p->inittime; - + /* enable recalculation flag by default (only used if hq fill) */ gps->flag |= GP_STROKE_RECALC_CACHES; /* allocate enough memory for a continuous array for storage points */ int sublevel = brush->sublevel; int new_totpoints = gps->totpoints; - + for (i = 0; i < sublevel; i++) { new_totpoints += new_totpoints - 1; } @@ -811,14 +811,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) gps->tot_triangles = 0; /* set pointer to first non-initialized point */ pt = gps->points + (gps->totpoints - totelem); - + /* copy points from the buffer to the stroke */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { /* straight lines only -> only endpoints */ { /* first point */ ptc = gpd->sbuffer; - + /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* if axis locked, reproject to plane locked (only in 3d space) */ @@ -834,14 +834,14 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) pt->strength = ptc->strength; CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = ptc->time; - + pt++; } - + if (totelem == 2) { /* last point if applicable */ ptc = ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); - + /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* if axis locked, reproject to plane locked (only in 3d space) */ @@ -863,7 +863,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* first point */ ptc = gpd->sbuffer; - + /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* if axis locked, reproject to plane locked (only in 3d space) */ @@ -1005,7 +1005,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p) gps->palcolor = palcolor; BLI_strncpy(gps->colorname, palcolor->info, sizeof(gps->colorname)); - /* add stroke to frame, usually on tail of the listbase, but if on back is enabled the stroke is added on listbase head + /* add stroke to frame, usually on tail of the listbase, but if on back is enabled the stroke is added on listbase head * because the drawing order is inverse and the head stroke is the first to draw. This is very useful for artist * when drawing the background */ @@ -1053,7 +1053,7 @@ static bool gp_stroke_eraser_is_occluded(tGPsdata *p, const bGPDspoint *pt, cons mul_v3_m4v3(fpt, diff_mat, &pt->x); const float depth_pt = view3d_point_depth(rv3d, fpt); - + if (depth_pt > depth_mval) { return true; } @@ -1068,13 +1068,13 @@ static float gp_stroke_eraser_calc_influence(tGPsdata *p, const int mval[2], con /* Linear Falloff... */ float distance = (float)len_v2v2_int(mval, co); float fac; - + CLAMP(distance, 0.0f, (float)radius); fac = 1.0f - (distance / (float)radius); - + /* Control this further using pen pressure */ fac *= p->pressure; - + /* Return influence factor computed here */ return fac; } @@ -1135,15 +1135,15 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, * below which we would have invisible strokes */ const float cull_thresh = (gps->thickness) ? 1.0f / ((float)gps->thickness) : 1.0f; - + /* Amount to decrease the pressure of each point with each stroke */ // TODO: Fetch from toolsettings, or compute based on thickness instead? const float strength = 0.1f; - + /* Perform culling? */ bool do_cull = false; - - + + /* Clear Tags * * Note: It's better this way, as we are sure that @@ -1154,7 +1154,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, bGPDspoint *pt = &gps->points[i]; pt->flag &= ~GP_SPOINT_TAG; } - + /* First Pass: Loop over the points in the stroke * 1) Thin out parts of the stroke under the brush * 2) Tag "too thin" parts for removal (in second pass) @@ -1167,7 +1167,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, /* only process if it hasn't been masked out... */ if ((p->flags & GP_PAINTFLAG_SELECTMASK) && !(gps->points->flag & GP_SPOINT_SELECT)) continue; - + if (gpl->parent == NULL) { gp_point_to_xy(&p->gsc, gps, pt1, &pc1[0], &pc1[1]); gp_point_to_xy(&p->gsc, gps, pt2, &pc2[0], &pc2[1]); @@ -1200,7 +1200,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, */ pt1->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc1) * strength; pt2->pressure -= gp_stroke_eraser_calc_influence(p, mval, radius, pc2) * strength / 2.0f; - + /* 2) Tag any point with overly low influence for removal in the next pass */ if (pt1->pressure < cull_thresh) { pt1->flag |= GP_SPOINT_TAG; @@ -1214,7 +1214,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, } } } - + /* Second Pass: Remove any points that are tagged */ if (do_cull) { gp_stroke_delete_tagged_points(gpf, gps, gps->next, GP_SPOINT_TAG); @@ -1228,29 +1228,29 @@ static void gp_stroke_doeraser(tGPsdata *p) bGPDlayer *gpl; bGPDstroke *gps, *gpn; rcti rect; - + /* rect is rectangle of eraser */ rect.xmin = p->mval[0] - p->radius; rect.ymin = p->mval[1] - p->radius; rect.xmax = p->mval[0] + p->radius; rect.ymax = p->mval[1] + p->radius; - + if (p->sa->spacetype == SPACE_VIEW3D) { if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) { View3D *v3d = p->sa->spacedata.first; - + view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init(p->scene, p->ar, v3d, 0); } } - + /* loop over all layers too, since while it's easy to restrict editing to * only a subset of layers, it is harder to perform the same erase operation * on multiple layers... */ for (gpl = p->gpd->layers.first; gpl; gpl = gpl->next) { bGPDframe *gpf = gpl->actframe; - + /* only affect layer if it's editable (and visible) */ if (gpencil_layer_is_editable(gpl) == false) { continue; @@ -1258,7 +1258,7 @@ static void gp_stroke_doeraser(tGPsdata *p) else if (gpf == NULL) { continue; } - + /* loop over strokes, checking segments for intersections */ for (gps = gpf->strokes.first; gps; gps = gpn) { gpn = gps->next; @@ -1283,7 +1283,7 @@ static void gp_stroke_doeraser(tGPsdata *p) static void gp_session_validatebuffer(tGPsdata *p) { bGPdata *gpd = p->gpd; - + /* clear memory of buffer (or allocate it if starting a new session) */ if (gpd->sbuffer) { /* printf("\t\tGP - reset sbuffer\n"); */ @@ -1293,13 +1293,13 @@ static void gp_session_validatebuffer(tGPsdata *p) /* printf("\t\tGP - allocate sbuffer\n"); */ gpd->sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); } - + /* reset indices */ gpd->sbuffer_size = 0; - + /* reset flags */ gpd->sbuffer_sflag = 0; - + /* reset inittime */ p->inittime = 0.0; } @@ -1310,7 +1310,7 @@ static bGPDpalettecolor *gp_create_new_color(bGPDpalette *palette) bGPDpalettecolor *palcolor; palcolor = BKE_gpencil_palettecolor_addnew(palette, DATA_("Color"), true); - + return palcolor; } @@ -1383,7 +1383,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) ScrArea *curarea = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); ToolSettings *ts = CTX_data_tool_settings(C); - + /* make sure the active view (at the starting time) is a 3d-view */ if (curarea == NULL) { p->status = GP_STATUS_ERROR; @@ -1391,21 +1391,21 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) printf("Error: No active view for painting\n"); return 0; } - + /* pass on current scene and window */ p->scene = CTX_data_scene(C); p->win = CTX_wm_window(C); - + unit_m4(p->imat); unit_m4(p->mat); - + switch (curarea->spacetype) { /* supported views first */ case SPACE_VIEW3D: { /* View3D *v3d = curarea->spacedata.first; */ /* RegionView3D *rv3d = ar->regiondata; */ - + /* set current area * - must verify that region data is 3D-view (and not something else) */ @@ -1413,7 +1413,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) p->sa = curarea; p->ar = ar; p->align_flag = &ts->gpencil_v3d_align; - + if (ar->regiondata == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) @@ -1425,7 +1425,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) case SPACE_NODE: { /* SpaceNode *snode = curarea->spacedata.first; */ - + /* set current area */ p->sa = curarea; p->ar = ar; @@ -1436,13 +1436,13 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) case SPACE_SEQ: { SpaceSeq *sseq = curarea->spacedata.first; - + /* set current area */ p->sa = curarea; p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_seq_align; - + /* check that gpencil data is allowed to be drawn */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) { p->status = GP_STATUS_ERROR; @@ -1455,7 +1455,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) case SPACE_IMAGE: { /* SpaceImage *sima = curarea->spacedata.first; */ - + /* set the current area */ p->sa = curarea; p->ar = ar; @@ -1467,7 +1467,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) { SpaceClip *sc = curarea->spacedata.first; MovieClip *clip = ED_space_clip_get_clip(sc); - + if (clip == NULL) { p->status = GP_STATUS_ERROR; return false; @@ -1478,15 +1478,15 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) p->ar = ar; p->v2d = &ar->v2d; p->align_flag = &ts->gpencil_v2d_align; - + invert_m4_m4(p->imat, sc->unistabmat); - + /* custom color for new layer */ p->custom_color[0] = 1.0f; p->custom_color[1] = 0.0f; p->custom_color[2] = 0.5f; p->custom_color[3] = 0.9f; - + if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { int framenr = ED_space_clip_get_clip_frame_number(sc); MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking); @@ -1501,7 +1501,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) return false; } } - + invert_m4_m4(p->mat, p->imat); copy_m4_m4(p->gsc.mat, p->mat); break; @@ -1515,7 +1515,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) return 0; } } - + /* get gp-data */ gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr); if (gpd_ptr == NULL) { @@ -1530,14 +1530,14 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) *gpd_ptr = BKE_gpencil_data_addnew("GPencil"); p->gpd = *gpd_ptr; } - + if (ED_gpencil_session_active() == 0) { /* initialize undo stack, * also, existing undo stack would make buffer drawn */ gpencil_undo_init(p->gpd); } - + /* clear out buffer (stored in gp-data), in case something contaminated it */ gp_session_validatebuffer(p); /* set brush and create a new one if null */ @@ -1559,12 +1559,12 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) static tGPsdata *gp_session_initpaint(bContext *C) { tGPsdata *p = NULL; - + /* create new context data */ p = MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); - + gp_session_initdata(C, p); - + /* radius for eraser circle is defined in userprefs now */ /* NOTE: we do this here, so that if we exit immediately, * erase size won't get lost @@ -1579,18 +1579,18 @@ static tGPsdata *gp_session_initpaint(bContext *C) static void gp_session_cleanup(tGPsdata *p) { bGPdata *gpd = (p) ? p->gpd : NULL; - + /* error checking */ if (gpd == NULL) return; - + /* free stroke buffer */ if (gpd->sbuffer) { /* printf("\t\tGP - free sbuffer\n"); */ MEM_freeN(gpd->sbuffer); gpd->sbuffer = NULL; } - + /* clear flags */ gpd->sbuffer_size = 0; gpd->sbuffer_sflag = 0; @@ -1602,12 +1602,12 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) { Scene *scene = p->scene; ToolSettings *ts = scene->toolsettings; - + /* get active layer (or add a new one if non-existent) */ p->gpl = BKE_gpencil_layer_getactive(p->gpd); if (p->gpl == NULL) { p->gpl = BKE_gpencil_layer_addnew(p->gpd, "GP_Layer", true); - + if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); } @@ -1617,7 +1617,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) printf("Error: Cannot paint on locked layer\n"); return; } - + /* get active frame (add a new one if not matching frame) */ if (paintmode == GP_PAINTMODE_ERASER) { /* Eraser mode: @@ -1626,12 +1626,12 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) * (to avoid problems with other tools which expect it to exist) */ bool has_layer_to_erase = false; - + for (bGPDlayer *gpl = p->gpd->layers.first; gpl; gpl = gpl->next) { /* Skip if layer not editable */ if (gpencil_layer_is_editable(gpl) == false) continue; - + /* Add a new frame if needed (and based off the active frame, * as we need some existing strokes to erase) * @@ -1643,16 +1643,16 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) gpl->actframe = BKE_gpencil_layer_getframe(gpl, CFRA, GP_GETFRAME_ADD_COPY); has_layer_to_erase = true; } - + /* XXX: we omit GP_FRAME_PAINT here for now, * as it is only really useful for doing * paintbuffer drawing */ } - + /* Ensure this gets set... */ p->gpf = p->gpl->actframe; - + /* Restrict eraser to only affecting selected strokes, if the "selection mask" is on * (though this is only available in editmode) */ @@ -1661,7 +1661,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) p->flags |= GP_PAINTFLAG_SELECTMASK; } } - + if (has_layer_to_erase == false) { p->status = GP_STATUS_ERROR; //if (G.debug & G_DEBUG) @@ -1672,14 +1672,14 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) else { /* Drawing Modes - Add a new frame if needed on the active layer */ short add_frame_mode; - + if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) add_frame_mode = GP_GETFRAME_ADD_COPY; else add_frame_mode = GP_GETFRAME_ADD_NEW; - + p->gpf = BKE_gpencil_layer_getframe(p->gpl, CFRA, add_frame_mode); - + if (p->gpf == NULL) { p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) @@ -1690,12 +1690,12 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) p->gpf->flag |= GP_FRAME_PAINT; } } - + /* set 'eraser' for this stroke if using eraser */ p->paintmode = paintmode; if (p->paintmode == GP_PAINTMODE_ERASER) { p->gpd->sbuffer_sflag |= GP_STROKE_ERASER; - + /* check if we should respect depth while erasing */ if (p->sa->spacetype == SPACE_VIEW3D) { if (p->gpl->flag & GP_LAYER_NO_XRAY) { @@ -1706,25 +1706,25 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) else { /* disable eraser flags - so that we can switch modes during a session */ p->gpd->sbuffer_sflag &= ~GP_STROKE_ERASER; - + if (p->sa->spacetype == SPACE_VIEW3D) { if (p->gpl->flag & GP_LAYER_NO_XRAY) { p->flags &= ~GP_PAINTFLAG_V3D_ERASER_DEPTH; } } } - + /* set 'initial run' flag, which is only used to denote when a new stroke is starting */ p->flags |= GP_PAINTFLAG_FIRSTRUN; - - + + /* when drawing in the camera view, in 2D space, set the subrect */ p->subrect = NULL; if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) { if (p->sa->spacetype == SPACE_VIEW3D) { View3D *v3d = p->sa->spacedata.first; RegionView3D *rv3d = p->ar->regiondata; - + /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, true); /* no shift */ @@ -1732,21 +1732,21 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) } } } - + /* init stroke point space-conversion settings... */ p->gsc.gpd = p->gpd; p->gsc.gpl = p->gpl; - + p->gsc.sa = p->sa; p->gsc.ar = p->ar; p->gsc.v2d = p->v2d; - + p->gsc.subrect_data = p->subrect_data; p->gsc.subrect = p->subrect; - + copy_m4_m4(p->gsc.mat, p->mat); - - + + /* check if points will need to be made in view-aligned space */ if (*p->align_flag & GP_PROJECT_VIEWSPACE) { switch (p->sa->spacetype) { @@ -1768,7 +1768,7 @@ static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode) case SPACE_IMAGE: { SpaceImage *sima = (SpaceImage *)p->sa->spacedata.first; - + /* only set these flags if the image editor doesn't have an image active, * otherwise user will be confused by strokes not appearing after they're drawn * @@ -1802,21 +1802,21 @@ static void gp_paint_strokeend(tGPsdata *p) */ if (gpencil_project_check(p)) { View3D *v3d = p->sa->spacedata.first; - + /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->ar); ED_view3d_autodist_init(p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0); } - + /* check if doing eraser or not */ if ((p->gpd->sbuffer_sflag & GP_STROKE_ERASER) == 0) { /* simplify stroke before transferring? */ gp_stroke_simplify(p); - + /* transfer stroke to frame */ gp_stroke_newfrombuffer(p); } - + /* clean up buffer now */ gp_session_validatebuffer(p); } @@ -1831,7 +1831,7 @@ static void gp_paint_cleanup(tGPsdata *p) /* finish off a stroke */ gp_paint_strokeend(p); } - + /* "unlock" frame */ if (p->gpf) p->gpf->flag &= ~GP_FRAME_PAINT; @@ -1843,27 +1843,27 @@ static void gp_paint_cleanup(tGPsdata *p) static void gpencil_draw_eraser(bContext *UNUSED(C), int x, int y, void *p_ptr) { tGPsdata *p = (tGPsdata *)p_ptr; - + if (p->paintmode == GP_PAINTMODE_ERASER) { glPushMatrix(); - + glTranslatef((float)x, (float)y, 0.0f); - + glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + glColor4ub(255, 100, 100, 20); glutil_draw_filled_arc(0.0, M_PI * 2.0, p->radius, 40); - + setlinestyle(6); - + glColor4ub(255, 100, 100, 200); glutil_draw_lined_arc(0.0, M_PI * 2.0, p->radius, 40); - + setlinestyle(0); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); - + glPopMatrix(); } } @@ -1891,7 +1891,7 @@ static bool gpencil_is_tablet_eraser_active(const wmEvent *event) const wmTabletData *wmtab = event->tablet_data; return (wmtab->Active == EVT_TABLET_ERASER); } - + return false; } @@ -1900,13 +1900,13 @@ static bool gpencil_is_tablet_eraser_active(const wmEvent *event) static void gpencil_draw_exit(bContext *C, wmOperator *op) { tGPsdata *p = op->customdata; - + /* clear undo stack */ gpencil_undo_finish(); - + /* restore cursor to indicate end of drawing */ WM_cursor_modal_restore(CTX_wm_window(C)); - + /* don't assume that operator data exists at all */ if (p) { /* check size of buffer before cleanup, to determine if anything happened here */ @@ -1920,15 +1920,15 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op) * have been toggled at some point. */ U.gp_eraser = p->radius; - + /* cleanup */ gp_paint_cleanup(p); gp_session_cleanup(p); - + /* finally, free the temp data */ MEM_freeN(p); } - + op->customdata = NULL; } @@ -1945,7 +1945,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event) { tGPsdata *p; eGPencil_PaintModes paintmode = RNA_enum_get(op->ptr, "mode"); - + /* check context */ p = op->customdata = gp_session_initpaint(C); if ((p == NULL) || (p->status == GP_STATUS_ERROR)) { @@ -1953,7 +1953,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event) gpencil_draw_exit(C, op); return 0; } - + /* init painting data */ gp_paint_initstroke(p, paintmode); if (p->status == GP_STATUS_ERROR) { @@ -1967,7 +1967,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event) else { p->keymodifier = -1; } - + /* everything is now setup ok */ return 1; } @@ -1994,7 +1994,7 @@ static void gpencil_draw_status_indicators(tGPsdata *p) if (GPENCIL_SKETCH_SESSIONS_ON(p->scene)) ED_area_headerprint(p->sa, IFACE_("Grease Pencil: Drawing/erasing stroke... Release to end stroke")); break; - + case GP_STATUS_IDLING: /* print status info */ switch (p->paintmode) { @@ -2014,13 +2014,13 @@ static void gpencil_draw_status_indicators(tGPsdata *p) ED_area_headerprint(p->sa, IFACE_("Grease Pencil Poly Session: LMB click to place next stroke vertex | " "ESC/Enter to end (or click outside this area)")); break; - + default: /* unhandled future cases */ ED_area_headerprint(p->sa, IFACE_("Grease Pencil Session: ESC/Enter to end (or click outside this area)")); break; } break; - + case GP_STATUS_ERROR: case GP_STATUS_DONE: /* clear status string */ @@ -2038,7 +2038,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) if (p->paintmode == GP_PAINTMODE_ERASER) { /* do 'live' erasing now */ gp_stroke_doeraser(p); - + /* store used values */ p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; @@ -2048,14 +2048,14 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) { /* try to add point */ short ok = gp_stroke_addpoint(p, p->mval, p->pressure, p->curtime); - + /* handle errors while adding point */ if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { /* finish off old stroke */ gp_paint_strokeend(p); /* And start a new one!!! Else, projection errors! */ gp_paint_initstroke(p, p->paintmode); - + /* start a new stroke, starting from previous point */ /* XXX Must manually reset inittime... */ /* XXX We only need to reuse previous point if overflow! */ @@ -2072,12 +2072,12 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) /* the painting operation cannot continue... */ BKE_report(op->reports, RPT_ERROR, "Cannot paint stroke"); p->status = GP_STATUS_ERROR; - + if (G.debug & G_DEBUG) printf("Error: Grease-Pencil Paint - Add Point Invalid\n"); return; } - + /* store used values */ p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; @@ -2093,13 +2093,13 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event) PointerRNA itemptr; float mousef[2]; int tablet = 0; - + /* convert from window-space to area-space mouse coordinates * NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... */ p->mval[0] = event->mval[0] + 1; p->mval[1] = event->mval[1] + 1; - + /* verify key status for straight lines */ if ((event->ctrl > 0) || (event->alt > 0)) { if (p->straight[0] == 0) { @@ -2125,14 +2125,14 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event) } p->curtime = PIL_check_seconds_timer(); - + /* handle pressure sensitivity (which is supplied by tablets) */ if (event->tablet_data) { const wmTabletData *wmtab = event->tablet_data; - + tablet = (wmtab->Active != EVT_TABLET_NONE); p->pressure = wmtab->Pressure; - + /* Hack for pressure sensitive eraser on D+RMB when using a tablet: * The pen has to float over the tablet surface, resulting in * zero pressure (T47101). Ignore pressure values if floating @@ -2149,11 +2149,11 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event) /* No tablet data -> No pressure info is available */ p->pressure = 1.0f; } - + /* special exception for start of strokes (i.e. maybe for just a dot) */ if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - + p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; p->opressure = p->pressure; @@ -2167,7 +2167,7 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event) if (tablet && (p->pressure >= 0.99f)) return; } - + /* check if alt key is pressed and limit to straight lines */ if (p->straight[0] != 0) { if (p->straight[0] == 1) { @@ -2182,18 +2182,18 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event) /* fill in stroke data (not actually used directly by gpencil_draw_apply) */ RNA_collection_add(op->ptr, "stroke", &itemptr); - + mousef[0] = p->mval[0]; mousef[1] = p->mval[1]; RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "pressure", p->pressure); RNA_boolean_set(&itemptr, "is_start", (p->flags & GP_PAINTFLAG_FIRSTRUN) != 0); - + RNA_float_set(&itemptr, "time", p->curtime - p->inittime); - + /* apply the current latest drawing point */ gpencil_draw_apply(op, p); - + /* force refresh */ ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */ } @@ -2204,9 +2204,9 @@ static void gpencil_draw_apply_event(wmOperator *op, const wmEvent *event) static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; - + /* printf("GPencil - Starting Re-Drawing\n"); */ - + /* try to initialize context data needed while drawing */ if (!gpencil_draw_init(C, op, NULL)) { if (op->customdata) MEM_freeN(op->customdata); @@ -2215,25 +2215,25 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op) } else p = op->customdata; - + /* printf("\tGP - Start redrawing stroke\n"); */ - + /* loop over the stroke RNA elements recorded (i.e. progress of mouse movement), * setting the relevant values in context at each step, then applying */ RNA_BEGIN (op->ptr, itemptr, "stroke") { float mousef[2]; - + /* printf("\t\tGP - stroke elem\n"); */ - + /* get relevant data for this point from stroke */ RNA_float_get_array(&itemptr, "mouse", mousef); p->mval[0] = (int)mousef[0]; p->mval[1] = (int)mousef[1]; p->pressure = RNA_float_get(&itemptr, "pressure"); p->curtime = (double)RNA_float_get(&itemptr, "time") + p->inittime; - + if (RNA_boolean_get(&itemptr, "is_start")) { /* if first-run flag isn't set already (i.e. not true first stroke), * then we must terminate the previous one first before continuing @@ -2244,30 +2244,30 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op) gp_paint_initstroke(p, p->paintmode); } } - + /* if first run, set previous data too */ if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - + p->mvalo[0] = p->mval[0]; p->mvalo[1] = p->mval[1]; p->opressure = p->pressure; p->ocurtime = p->curtime; } - + /* apply this data as necessary now (as per usual) */ gpencil_draw_apply(op, p); } RNA_END; - + /* printf("\tGP - done\n"); */ - + /* cleanup */ gpencil_draw_exit(C, op); - + /* refreshes */ WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -2278,10 +2278,10 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op) static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event) { tGPsdata *p = NULL; - + if (G.debug & G_DEBUG) printf("GPencil - Starting Drawing\n"); - + /* try to initialize context data needed while drawing */ if (!gpencil_draw_init(C, op, event)) { if (op->customdata) @@ -2292,17 +2292,17 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event } else p = op->customdata; - + /* TODO: set any additional settings that we can take from the events? * TODO? if tablet is erasing, force eraser to be on? */ - + /* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */ - + /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { gpencil_draw_toggle_eraser_cursor(C, p, true); } - /* set cursor + /* set cursor * NOTE: This may change later (i.e. intentionally via brush toggle, * or unintentionally if the user scrolls outside the area)... */ @@ -2323,7 +2323,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event /* printf("\tGP - hotkey invoked... waiting for click-drag\n"); */ op->flag |= OP_IS_MODAL_CURSOR_REGION; } - + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* add a modal handler for this operator, so that we can then draw continuous strokes */ WM_event_add_modal_handler(C, op); @@ -2340,7 +2340,7 @@ static bool gpencil_area_exists(bContext *C, ScrArea *sa_test) static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) { tGPsdata *p = op->customdata; - + /* we must check that we're still within the area that we're set up to work from * otherwise we could crash (see bug #20586) */ @@ -2348,37 +2348,37 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) printf("\t\t\tGP - wrong area execution abort!\n"); p->status = GP_STATUS_ERROR; } - + /* printf("\t\tGP - start stroke\n"); */ - + /* we may need to set up paint env again if we're resuming */ /* XXX: watch it with the paintmode! in future, * it'd be nice to allow changing paint-mode when in sketching-sessions */ - + if (gp_session_initdata(C, p)) gp_paint_initstroke(p, p->paintmode); - + if (p->status != GP_STATUS_ERROR) { p->status = GP_STATUS_PAINTING; op->flag &= ~OP_IS_MODAL_CURSOR_REGION; } - + return op->customdata; } static void gpencil_stroke_end(wmOperator *op) { tGPsdata *p = op->customdata; - + gp_paint_cleanup(p); - + gpencil_undo_push(p->gpd); - + gp_session_cleanup(p); - + p->status = GP_STATUS_IDLING; op->flag |= OP_IS_MODAL_CURSOR_REGION; - + p->gpd = NULL; p->gpl = NULL; p->gpf = NULL; @@ -2412,7 +2412,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) tGPsdata *p = op->customdata; ToolSettings *ts = CTX_data_tool_settings(C); int estate = OPERATOR_PASS_THROUGH; /* default exit state - pass through to support MMB view nav, etc. */ - + /* if (event->type == NDOF_MOTION) * return OPERATOR_PASS_THROUGH; * ------------------------------- @@ -2425,7 +2425,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) * better in tools that immediately apply * in 3D space. */ - + if (p->status == GP_STATUS_IDLING) { ARegion *ar = CTX_wm_region(C); p->ar = ar; @@ -2462,9 +2462,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) estate = OPERATOR_RUNNING_MODAL; } } - + //printf("\tGP - handle modal event...\n"); - + /* exit painting mode (and/or end current stroke) * NOTE: cannot do RIGHTMOUSE (as is standard for canceling) as that would break polyline [#32647] */ @@ -2482,7 +2482,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; } - + /* toggle painting mode upon mouse-button movement * - LEFTMOUSE = standard drawing (all) / straight line drawing (all) / polyline (toolbox only) * - RIGHTMOUSE = polyline (hotkey) / eraser (all) @@ -2493,31 +2493,31 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* if painting, end stroke */ if (p->status == GP_STATUS_PAINTING) { int sketch = 0; - + /* basically, this should be mouse-button up = end stroke * BUT what happens next depends on whether we 'painting sessions' is enabled */ sketch |= GPENCIL_SKETCH_SESSIONS_ON(p->scene); /* polyline drawing is also 'sketching' -- all knots should be added during one session */ sketch |= (p->paintmode == GP_PAINTMODE_DRAW_POLY); - + if (sketch) { /* end stroke only, and then wait to resume painting soon */ /* printf("\t\tGP - end stroke only\n"); */ gpencil_stroke_end(op); - + /* If eraser mode is on, turn it off after the stroke finishes * NOTE: This just makes it nicer to work with drawing sessions */ if (p->paintmode == GP_PAINTMODE_ERASER) { p->paintmode = RNA_enum_get(op->ptr, "mode"); - + /* if the original mode was *still* eraser, * we'll let it say for now, since this gives * users an opportunity to have visual feedback * when adjusting eraser size */ - if (p->paintmode != GP_PAINTMODE_ERASER) { + if (p->paintmode != GP_PAINTMODE_ERASER) { /* turn off cursor... * NOTE: this should be enough for now * Just hiding this makes it seem like @@ -2526,10 +2526,10 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) gpencil_draw_toggle_eraser_cursor(C, p, false); } } - + /* we've just entered idling state, so this event was processed (but no others yet) */ estate = OPERATOR_RUNNING_MODAL; - + /* stroke could be smoothed, send notifier to refresh screen */ WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); } @@ -2549,7 +2549,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) } else if (event->val == KM_PRESS) { bool in_bounds = false; - + /* Check if we're outside the bounds of the active region * NOTE: An exception here is that if launched from the toolbar, * whatever region we're now in should become the new region @@ -2557,13 +2557,13 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) if ((p->ar) && (p->ar->regiontype == RGN_TYPE_TOOLS)) { /* Change to whatever region is now under the mouse */ ARegion *current_region = BKE_area_find_region_xy(p->sa, RGN_TYPE_ANY, event->x, event->y); - + if (G.debug & G_DEBUG) { printf("found alternative region %p (old was %p) - at %d %d (sa: %d %d -> %d %d)\n", current_region, p->ar, event->x, event->y, p->sa->totrct.xmin, p->sa->totrct.ymin, p->sa->totrct.xmax, p->sa->totrct.ymax); } - + if (current_region) { /* Assume that since we found the cursor in here, it is in bounds * and that this should be the region that we begin drawing in @@ -2575,14 +2575,14 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* Out of bounds, or invalid in some other way */ p->status = GP_STATUS_ERROR; estate = OPERATOR_CANCELLED; - + if (G.debug & G_DEBUG) printf("%s: Region under cursor is out of bounds, so cannot be drawn on\n", __func__); } } else if (p->ar) { rcti region_rect; - + /* Perform bounds check using */ ED_region_visible_rect(p->ar, ®ion_rect); in_bounds = BLI_rcti_isect_pt_v(®ion_rect, event->mval); @@ -2591,11 +2591,11 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* No region */ p->status = GP_STATUS_ERROR; estate = OPERATOR_CANCELLED; - + if (G.debug & G_DEBUG) printf("%s: No active region found in GP Paint session data\n", __func__); } - + if (in_bounds) { /* Switch paintmode (temporarily if need be) based on which button was used * NOTE: This is to make it more convenient to erase strokes when using drawing sessions @@ -2608,18 +2608,18 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* restore drawmode to default */ p->paintmode = RNA_enum_get(op->ptr, "mode"); } - + gpencil_draw_toggle_eraser_cursor(C, p, p->paintmode == GP_PAINTMODE_ERASER); - + /* not painting, so start stroke (this should be mouse-button down) */ p = gpencil_stroke_begin(C, op); - + if (p->status == GP_STATUS_ERROR) { estate = OPERATOR_CANCELLED; } } else if (p->status != GP_STATUS_ERROR) { - /* User clicked outside bounds of window while idling, so exit paintmode + /* User clicked outside bounds of window while idling, so exit paintmode * NOTE: Don't enter this case if an error occurred while finding the * region (as above) */ @@ -2640,7 +2640,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) op->flag |= OP_IS_MODAL_CURSOR_REGION; } } - + /* handle mode-specific events */ if (p->status == GP_STATUS_PAINTING) { /* handle painting mouse-movements? */ @@ -2648,7 +2648,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) /* handle drawing event */ /* printf("\t\tGP - add point\n"); */ gpencil_draw_apply_event(op, event); - + /* finish painting operation if anything went wrong just now */ if (p->status == GP_STATUS_ERROR) { printf("\t\t\t\tGP - add error done!\n"); @@ -2673,19 +2673,19 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) case PADPLUSKEY: p->radius += 5; break; - + case WHEELUPMOUSE: /* smaller */ case PADMINUS: p->radius -= 5; - + if (p->radius <= 0) p->radius = 1; break; } - + /* force refresh */ ED_region_tag_redraw(p->ar); /* just active area for now, since doing whole screen is too slow */ - + /* event handled, so just tag as running modal */ estate = OPERATOR_RUNNING_MODAL; } @@ -2697,7 +2697,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) estate = OPERATOR_RUNNING_MODAL; } } - + /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ if (0 == gpencil_area_exists(C, p->sa)) estate = OPERATOR_CANCELLED; @@ -2706,7 +2706,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) gpencil_draw_status_indicators(p); gpencil_draw_cursor_set(p); /* cursor may have changed outside our control - T44084 */ } - + /* process last operations before exiting */ switch (estate) { case OPERATOR_FINISHED: @@ -2714,11 +2714,11 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) gpencil_draw_exit(C, op); WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); break; - + case OPERATOR_CANCELLED: gpencil_draw_exit(C, op); break; - + case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH: /* event doesn't need to be handled */ #if 0 @@ -2727,7 +2727,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) #endif break; } - + /* return status code */ return estate; } @@ -2745,28 +2745,28 @@ static const EnumPropertyItem prop_gpencil_drawmodes[] = { void GPENCIL_OT_draw(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Grease Pencil Draw"; ot->idname = "GPENCIL_OT_draw"; ot->description = "Make annotations on the active data"; - + /* api callbacks */ ot->exec = gpencil_draw_exec; ot->invoke = gpencil_draw_invoke; ot->modal = gpencil_draw_modal; ot->cancel = gpencil_draw_cancel; ot->poll = gpencil_draw_poll; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; - + /* settings for drawing */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements"); prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - + /* NOTE: wait for input is enabled by default, so that all UI code can work properly without needing users to know about this */ prop = RNA_def_boolean(ot->srna, "wait_for_input", true, "Wait for Input", "Wait for first click instead of painting immediately"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index dc3483163bf..ac0b046e499 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -70,14 +70,14 @@ static int gpencil_select_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + /* we just need some visible strokes, and to be in editmode */ if ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)) { /* TODO: include a check for visible strokes? */ if (gpd->layers.first) return true; } - + return false; } @@ -88,16 +88,16 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); int action = RNA_enum_get(op->ptr, "action"); - + if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); return OPERATOR_CANCELLED; } - + /* for "toggle", test for existing selected strokes */ if (action == SEL_TOGGLE) { action = SEL_SELECT; - + CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { if (gps->flag & GP_STROKE_SELECT) { @@ -107,7 +107,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + /* if deselecting, we need to deselect strokes across all frames * - Currently, an exception is only given for deselection * Selecting and toggling should only affect what's visible, @@ -122,21 +122,21 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) { bGPDframe *gpf; - + /* deselect all strokes on all frames */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { bGPDstroke *gps; - + for (gps = gpf->strokes.first; gps; gps = gps->next) { bGPDspoint *pt; int i; - + /* only edit strokes that are valid in this view... */ if (ED_gpencil_stroke_can_use(C, gps)) { for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } - + gps->flag &= ~GP_STROKE_SELECT; } } @@ -151,7 +151,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) bGPDspoint *pt; int i; bool selected = false; - + /* Change selection status of all points, then make the stroke match */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { switch (action) { @@ -165,11 +165,11 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) pt->flag ^= GP_SPOINT_SELECT; break; } - + if (pt->flag & GP_SPOINT_SELECT) selected = true; } - + /* Change status of stroke */ if (selected) gps->flag |= GP_STROKE_SELECT; @@ -178,7 +178,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -190,14 +190,14 @@ void GPENCIL_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All Strokes"; ot->idname = "GPENCIL_OT_select_all"; ot->description = "Change selection of all Grease Pencil strokes currently visible"; - + /* callbacks */ ot->exec = gpencil_select_all_exec; ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + WM_operator_properties_select_all(ot); } @@ -207,26 +207,26 @@ void GPENCIL_OT_select_all(wmOperatorType *ot) static int gpencil_select_linked_exec(bContext *C, wmOperator *op) { bGPdata *gpd = ED_gpencil_data_get_active(C); - + if (gpd == NULL) { BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); return OPERATOR_CANCELLED; } - + /* select all points in selected strokes */ CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { if (gps->flag & GP_STROKE_SELECT) { bGPDspoint *pt; int i; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag |= GP_SPOINT_SELECT; } } } CTX_DATA_END; - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -238,11 +238,11 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "GPENCIL_OT_select_linked"; ot->description = "Select all points in same strokes as already selected points"; - + /* callbacks */ ot->exec = gpencil_select_linked_exec; ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -253,10 +253,10 @@ void GPENCIL_OT_select_linked(wmOperatorType *ot) typedef enum eGP_SelectGrouped { /* Select strokes in the same layer */ GP_SEL_SAME_LAYER = 0, - + /* Select strokes with the same color */ GP_SEL_SAME_COLOR = 1, - + /* TODO: All with same prefix - Useful for isolating all layers for a particular character for instance */ /* TODO: All with same appearance - colour/opacity/volumetric/fills ? */ } eGP_SelectGrouped; @@ -267,16 +267,16 @@ typedef enum eGP_SelectGrouped { static void gp_select_same_layer(bContext *C) { Scene *scene = CTX_data_scene(C); - + CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) { bGPDframe *gpf = BKE_gpencil_layer_getframe(gpl, CFRA, 0); bGPDstroke *gps; bool found = false; - + if (gpf == NULL) continue; - + /* Search for a selected stroke */ for (gps = gpf->strokes.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { @@ -286,18 +286,18 @@ static void gp_select_same_layer(bContext *C) } } } - + /* Select all if found */ if (found) { for (gps = gpf->strokes.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use(C, gps)) { bGPDspoint *pt; int i; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag |= GP_SPOINT_SELECT; } - + gps->flag |= GP_STROKE_SELECT; } } @@ -310,11 +310,11 @@ static void gp_select_same_layer(bContext *C) static void gp_select_same_color(bContext *C) { /* First, build set containing all the colors of selected strokes - * - We use the palette names, so that we can select all strokes with one + * - We use the palette names, so that we can select all strokes with one * (potentially missing) color, and remap them to something else */ GSet *selected_colors = BLI_gset_str_new("GP Selected Colors"); - + CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { if (gps->flag & GP_STROKE_SELECT) { @@ -325,7 +325,7 @@ static void gp_select_same_color(bContext *C) } } CTX_DATA_END; - + /* Second, select any visible stroke that uses these colors */ CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { @@ -333,11 +333,11 @@ static void gp_select_same_color(bContext *C) /* select this stroke */ bGPDspoint *pt; int i; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag |= GP_SPOINT_SELECT; } - + gps->flag |= GP_STROKE_SELECT; } } @@ -350,7 +350,7 @@ static void gp_select_same_color(bContext *C) static int gpencil_select_grouped_exec(bContext *C, wmOperator *op) { eGP_SelectGrouped mode = RNA_enum_get(op->ptr, "type"); - + switch (mode) { case GP_SEL_SAME_LAYER: gp_select_same_layer(C); @@ -358,12 +358,12 @@ static int gpencil_select_grouped_exec(bContext *C, wmOperator *op) case GP_SEL_SAME_COLOR: gp_select_same_color(C); break; - + default: BLI_assert(!"unhandled select grouped gpencil mode"); break; } - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -376,20 +376,20 @@ void GPENCIL_OT_select_grouped(wmOperatorType *ot) {GP_SEL_SAME_COLOR, "COLOR", 0, "Color", "Shared colors"}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Select Grouped"; ot->idname = "GPENCIL_OT_select_grouped"; ot->description = "Select all strokes with similar characteristics"; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = gpencil_select_grouped_exec; ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, GP_SEL_SAME_LAYER, "Type", ""); } @@ -401,33 +401,33 @@ static int gpencil_select_first_exec(bContext *C, wmOperator *op) { const bool only_selected = RNA_boolean_get(op->ptr, "only_selected_strokes"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { /* skip stroke if we're only manipulating selected strokes */ if (only_selected && !(gps->flag & GP_STROKE_SELECT)) { continue; } - + /* select first point */ BLI_assert(gps->totpoints >= 1); - + gps->points->flag |= GP_SPOINT_SELECT; gps->flag |= GP_STROKE_SELECT; - + /* deselect rest? */ if ((extend == false) && (gps->totpoints > 1)) { /* start from index 1, to skip the first point that we'd just selected... */ bGPDspoint *pt = &gps->points[1]; int i = 1; - + for (; i < gps->totpoints; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } } } CTX_DATA_END; - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -439,18 +439,18 @@ void GPENCIL_OT_select_first(wmOperatorType *ot) ot->name = "Select First"; ot->idname = "GPENCIL_OT_select_first"; ot->description = "Select first point in Grease Pencil strokes"; - + /* callbacks */ ot->exec = gpencil_select_first_exec; ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "only_selected_strokes", false, "Selected Strokes Only", "Only select the first point of strokes that already have points selected"); - + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting all other selected points"); } @@ -461,33 +461,33 @@ static int gpencil_select_last_exec(bContext *C, wmOperator *op) { const bool only_selected = RNA_boolean_get(op->ptr, "only_selected_strokes"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { /* skip stroke if we're only manipulating selected strokes */ if (only_selected && !(gps->flag & GP_STROKE_SELECT)) { continue; } - + /* select last point */ BLI_assert(gps->totpoints >= 1); - + gps->points[gps->totpoints - 1].flag |= GP_SPOINT_SELECT; gps->flag |= GP_STROKE_SELECT; - + /* deselect rest? */ if ((extend == false) && (gps->totpoints > 1)) { /* don't include the last point... */ bGPDspoint *pt = gps->points; int i = 1; - + for (; i < gps->totpoints - 1; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } } } CTX_DATA_END; - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -499,18 +499,18 @@ void GPENCIL_OT_select_last(wmOperatorType *ot) ot->name = "Select Last"; ot->idname = "GPENCIL_OT_select_last"; ot->description = "Select last point in Grease Pencil strokes"; - + /* callbacks */ ot->exec = gpencil_select_last_exec; ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "only_selected_strokes", false, "Selected Strokes Only", "Only select the last point of strokes that already have points selected"); - + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting all other selected points"); } @@ -525,8 +525,8 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op)) bGPDspoint *pt; int i; bool prev_sel; - - /* First Pass: Go in forward order, expanding selection if previous was selected (pre changes)... + + /* First Pass: Go in forward order, expanding selection if previous was selected (pre changes)... * - This pass covers the "after" edges of selection islands */ prev_sel = false; @@ -543,8 +543,8 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op)) prev_sel = false; } } - - /* Second Pass: Go in reverse order, doing the same as before (except in opposite order) + + /* Second Pass: Go in reverse order, doing the same as before (except in opposite order) * - This pass covers the "before" edges of selection islands */ prev_sel = false; @@ -563,7 +563,7 @@ static int gpencil_select_more_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -575,11 +575,11 @@ void GPENCIL_OT_select_more(wmOperatorType *ot) ot->name = "Select More"; ot->idname = "GPENCIL_OT_select_more"; ot->description = "Grow sets of selected Grease Pencil points"; - + /* callbacks */ ot->exec = gpencil_select_more_exec; ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -595,8 +595,8 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op)) bGPDspoint *pt; int i; bool prev_sel; - - /* First Pass: Go in forward order, shrinking selection if previous was not selected (pre changes)... + + /* First Pass: Go in forward order, shrinking selection if previous was not selected (pre changes)... * - This pass covers the "after" edges of selection islands */ prev_sel = false; @@ -613,8 +613,8 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op)) prev_sel = false; } } - - /* Second Pass: Go in reverse order, doing the same as before (except in opposite order) + + /* Second Pass: Go in reverse order, doing the same as before (except in opposite order) * - This pass covers the "before" edges of selection islands */ prev_sel = false; @@ -634,7 +634,7 @@ static int gpencil_select_less_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + /* updates */ WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -646,11 +646,11 @@ void GPENCIL_OT_select_less(wmOperatorType *ot) ot->name = "Select Less"; ot->idname = "GPENCIL_OT_select_less"; ot->description = "Shrink sets of selected Grease Pencil points"; - + /* callbacks */ ot->exec = gpencil_select_less_exec; ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -671,7 +671,7 @@ static bool gp_stroke_do_circle_sel( int x0 = 0, y0 = 0, x1 = 0, y1 = 0; int i; bool changed = false; - + if (gps->totpoints == 1) { if (!parented) { gp_point_to_xy(gsc, gps, gps->points, &x0, &y0); @@ -681,7 +681,7 @@ static bool gp_stroke_do_circle_sel( gp_point_to_parent_space(gps->points, diff_mat, &pt_temp); gp_point_to_xy(gsc, gps, &pt_temp, &x0, &y0); } - + /* do boundbox check first */ if ((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) { /* only check if point is inside */ @@ -695,13 +695,13 @@ static bool gp_stroke_do_circle_sel( gps->points->flag &= ~GP_SPOINT_SELECT; gps->flag &= ~GP_STROKE_SELECT; } - + return true; } } } else { - /* Loop over the points in the stroke, checking for intersections + /* Loop over the points in the stroke, checking for intersections * - an intersection means that we touched the stroke */ for (i = 0; (i + 1) < gps->totpoints; i++) { @@ -720,43 +720,43 @@ static bool gp_stroke_do_circle_sel( gp_point_to_parent_space(pt2, diff_mat, &npt); gp_point_to_xy(gsc, gps, &npt, &x1, &y1); } - + /* check that point segment of the boundbox of the selection stroke */ if (((!ELEM(V2D_IS_CLIPPED, x0, y0)) && BLI_rcti_isect_pt(rect, x0, y0)) || ((!ELEM(V2D_IS_CLIPPED, x1, y1)) && BLI_rcti_isect_pt(rect, x1, y1))) { int mval[2] = {mx, my}; int mvalo[2] = {mx, my}; /* dummy - this isn't used... */ - + /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) * - this assumes that linewidth is irrelevant */ if (gp_stroke_inside_circle(mval, mvalo, radius, x0, y0, x1, y1)) { - /* change selection of stroke, and then of both points + /* change selection of stroke, and then of both points * (as the last point otherwise wouldn't get selected - * as we only do n-1 loops through) + * as we only do n-1 loops through) */ if (select) { pt1->flag |= GP_SPOINT_SELECT; pt2->flag |= GP_SPOINT_SELECT; - + changed = true; } else { pt1->flag &= ~GP_SPOINT_SELECT; pt2->flag &= ~GP_SPOINT_SELECT; - + changed = true; } } } } - + /* Ensure that stroke selection is in sync with its points */ BKE_gpencil_stroke_sync_selection(gps); } - + return changed; } @@ -764,36 +764,36 @@ static bool gp_stroke_do_circle_sel( static int gpencil_circle_select_exec(bContext *C, wmOperator *op) { ScrArea *sa = CTX_wm_area(C); - + const int mx = RNA_int_get(op->ptr, "x"); const int my = RNA_int_get(op->ptr, "y"); const int radius = RNA_int_get(op->ptr, "radius"); - + bool select = !RNA_boolean_get(op->ptr, "deselect"); - + GP_SpaceConversion gsc = {NULL}; rcti rect = {0}; /* for bounding rect around circle (for quicky intersection testing) */ - + bool changed = false; - - + + /* sanity checks */ if (sa == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } - + /* init space conversion stuff */ gp_point_conversion_init(C, &gsc); - - + + /* rect is rectangle of selection circle */ rect.xmin = mx - radius; rect.ymin = my - radius; rect.xmax = mx + radius; rect.ymax = my + radius; - - + + /* find visible strokes, and select if hit */ GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) { @@ -807,7 +807,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op) if (changed) { WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); } - + return OPERATOR_FINISHED; } @@ -817,17 +817,17 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot) ot->name = "Circle Select"; ot->description = "Select Grease Pencil strokes using brush selection"; ot->idname = "GPENCIL_OT_select_circle"; - + /* callbacks */ ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = gpencil_circle_select_exec; ot->poll = gpencil_select_poll; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ WM_operator_properties_gesture_circle_select(ot); } @@ -838,45 +838,45 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot) static int gpencil_border_select_exec(bContext *C, wmOperator *op) { ScrArea *sa = CTX_wm_area(C); - + const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + GP_SpaceConversion gsc = {NULL}; rcti rect = {0}; - + bool changed = false; - - + + /* sanity checks */ if (sa == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } - + /* init space conversion stuff */ gp_point_conversion_init(C, &gsc); - - + + /* deselect all strokes first? */ if (select && !extend) { CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { bGPDspoint *pt; int i; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } - + gps->flag &= ~GP_STROKE_SELECT; } CTX_DATA_END; } - + /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); - + /* select/deselect points */ GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) { @@ -919,7 +919,7 @@ static int gpencil_border_select_exec(bContext *C, wmOperator *op) if (changed) { WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); } - + return OPERATOR_FINISHED; } @@ -929,18 +929,18 @@ void GPENCIL_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->description = "Select Grease Pencil strokes within a rectangular region"; ot->idname = "GPENCIL_OT_select_border"; - + /* callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = gpencil_border_select_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = gpencil_select_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); } @@ -952,41 +952,41 @@ static int gpencil_lasso_select_exec(bContext *C, wmOperator *op) { GP_SpaceConversion gsc = {NULL}; rcti rect = {0}; - + const bool extend = RNA_boolean_get(op->ptr, "extend"); const bool select = !RNA_boolean_get(op->ptr, "deselect"); - + int mcords_tot; const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); - + bool changed = false; - + /* sanity check */ if (mcords == NULL) return OPERATOR_PASS_THROUGH; - + /* compute boundbox of lasso (for faster testing later) */ BLI_lasso_boundbox(&rect, mcords, mcords_tot); - + /* init space conversion stuff */ gp_point_conversion_init(C, &gsc); - + /* deselect all strokes first? */ if (select && !extend) { CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) { bGPDspoint *pt; int i; - + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } - + gps->flag &= ~GP_STROKE_SELECT; } CTX_DATA_END; } - + /* select/deselect points */ GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) { @@ -1027,12 +1027,12 @@ static int gpencil_lasso_select_exec(bContext *C, wmOperator *op) /* cleanup */ MEM_freeN((void *)mcords); - + /* updates */ if (changed) { WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); } - + return OPERATOR_FINISHED; } @@ -1041,16 +1041,16 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot) ot->name = "Lasso Select Strokes"; ot->description = "Select Grease Pencil strokes using lasso selection"; ot->idname = "GPENCIL_OT_select_lasso"; - + ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = gpencil_lasso_select_exec; ot->poll = gpencil_select_poll; ot->cancel = WM_gesture_lasso_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_gesture_lasso_select(ot); } @@ -1061,36 +1061,36 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot) static int gpencil_select_exec(bContext *C, wmOperator *op) { ScrArea *sa = CTX_wm_area(C); - + /* "radius" is simply a threshold (screen space) to make it easier to test with a tolerance */ const float radius = 0.75f * U.widget_unit; const int radius_squared = (int)(radius * radius); - + bool extend = RNA_boolean_get(op->ptr, "extend"); bool deselect = RNA_boolean_get(op->ptr, "deselect"); bool toggle = RNA_boolean_get(op->ptr, "toggle"); bool whole = RNA_boolean_get(op->ptr, "entire_strokes"); - + int mval[2] = {0}; - + GP_SpaceConversion gsc = {NULL}; - + bGPDstroke *hit_stroke = NULL; bGPDspoint *hit_point = NULL; int hit_distance = radius_squared; - + /* sanity checks */ if (sa == NULL) { BKE_report(op->reports, RPT_ERROR, "No active area"); return OPERATOR_CANCELLED; } - + /* init space conversion stuff */ gp_point_conversion_init(C, &gsc); - + /* get mouse location */ RNA_int_get_array(op->ptr, "location", mval); - + /* First Pass: Find stroke point which gets hit */ /* XXX: maybe we should go from the top of the stack down instead... */ GP_EDITABLE_STROKES_BEGIN(C, gpl, gps) @@ -1133,38 +1133,38 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) if (ELEM(NULL, hit_stroke, hit_point)) { return OPERATOR_CANCELLED; } - + /* adjust selection behaviour - for toggle option */ if (toggle) { deselect = (hit_point->flag & GP_SPOINT_SELECT) != 0; } - + /* If not extending selection, deselect everything else */ if (extend == false) { CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) - { + { /* deselect stroke and its points if selected */ if (gps->flag & GP_STROKE_SELECT) { bGPDspoint *pt; int i; - + /* deselect points */ for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } - + /* deselect stroke itself too */ gps->flag &= ~GP_STROKE_SELECT; } } CTX_DATA_END; } - + /* Perform selection operations... */ if (whole) { bGPDspoint *pt; int i; - + /* entire stroke's points */ for (i = 0, pt = hit_stroke->points; i < hit_stroke->totpoints; i++, pt++) { if (deselect == false) @@ -1172,7 +1172,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) else pt->flag &= ~GP_SPOINT_SELECT; } - + /* stroke too... */ if (deselect == false) hit_stroke->flag |= GP_STROKE_SELECT; @@ -1189,17 +1189,17 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) else { /* deselect point */ hit_point->flag &= ~GP_SPOINT_SELECT; - + /* ensure that stroke is selected correctly */ BKE_gpencil_stroke_sync_selection(hit_stroke); } } - + /* updates */ if (hit_point != NULL) { WM_event_add_notifier(C, NC_GPENCIL | NA_SELECTED, NULL); } - + return OPERATOR_FINISHED; } @@ -1212,26 +1212,26 @@ static int gpencil_select_invoke(bContext *C, wmOperator *op, const wmEvent *eve void GPENCIL_OT_select(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Select"; ot->description = "Select Grease Pencil strokes and/or stroke points"; ot->idname = "GPENCIL_OT_select"; - + /* callbacks */ ot->invoke = gpencil_select_invoke; ot->exec = gpencil_select_exec; ot->poll = gpencil_select_poll; - + /* flag */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ WM_operator_properties_mouse_select(ot); - + prop = RNA_def_boolean(ot->srna, "entire_strokes", false, "Entire Strokes", "Select entire strokes instead of just the nearest stroke vertex"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - + prop = RNA_def_int_vector(ot->srna, "location", 2, NULL, INT_MIN, INT_MAX, "Location", "Mouse location", INT_MIN, INT_MAX); RNA_def_property_flag(prop, PROP_HIDDEN); } diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 202d7630ae0..5e2be7c41f0 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -55,7 +55,7 @@ typedef struct bGPundonode { struct bGPundonode *next, *prev; - + char name[BKE_UNDO_STR_MAX]; struct bGPdata *gpd; } bGPundonode; @@ -71,9 +71,9 @@ int ED_gpencil_session_active(void) int ED_undo_gpencil_step(bContext *C, int step, const char *name) { bGPdata **gpd_ptr = NULL, *new_gpd = NULL; - + gpd_ptr = ED_gpencil_data_get_pointers(C, NULL); - + if (step == 1) { /* undo */ //printf("\t\tGP - undo step\n"); if (cur_node->prev) { @@ -92,18 +92,18 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) } } } - + if (new_gpd) { if (gpd_ptr) { if (*gpd_ptr) { bGPdata *gpd = *gpd_ptr; bGPDlayer *gpl, *gpld; - + BKE_gpencil_free_layers(&gpd->layers); - + /* copy layers */ BLI_listbase_clear(&gpd->layers); - + for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) { /* make a copy of source layer and its data */ gpld = BKE_gpencil_layer_duplicate(gpl); @@ -112,9 +112,9 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) } } } - + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -129,7 +129,7 @@ static void gpencil_undo_free_node(bGPundonode *undo_node) * or else the real copy will segfault when accessed */ undo_node->gpd->adt = NULL; - + BKE_gpencil_free(undo_node->gpd, false); MEM_freeN(undo_node->gpd); } @@ -137,65 +137,65 @@ static void gpencil_undo_free_node(bGPundonode *undo_node) void gpencil_undo_push(bGPdata *gpd) { bGPundonode *undo_node; - + //printf("\t\tGP - undo push\n"); - + if (cur_node) { /* remove all un-done nodes from stack */ undo_node = cur_node->next; - + while (undo_node) { bGPundonode *next_node = undo_node->next; - + gpencil_undo_free_node(undo_node); BLI_freelinkN(&undo_nodes, undo_node); - + undo_node = next_node; } } - + /* limit number of undo steps to the maximum undo steps - * - to prevent running out of memory during **really** + * - to prevent running out of memory during **really** * long drawing sessions (triggering swapping) */ /* TODO: Undo-memory constraint is not respected yet, but can be added if we have any need for it */ if (U.undosteps && !BLI_listbase_is_empty(&undo_nodes)) { /* remove anything older than n-steps before cur_node */ int steps = 0; - + undo_node = (cur_node) ? cur_node : undo_nodes.last; while (undo_node) { bGPundonode *prev_node = undo_node->prev; - + if (steps >= U.undosteps) { gpencil_undo_free_node(undo_node); BLI_freelinkN(&undo_nodes, undo_node); } - + steps++; undo_node = prev_node; } } - + /* create new undo node */ undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node"); undo_node->gpd = BKE_gpencil_data_duplicate(G.main, gpd, true); - + cur_node = undo_node; - + BLI_addtail(&undo_nodes, undo_node); } void gpencil_undo_finish(void) { bGPundonode *undo_node = undo_nodes.first; - + while (undo_node) { gpencil_undo_free_node(undo_node); undo_node = undo_node->next; } - + BLI_freelistN(&undo_nodes); - + cur_node = NULL; } diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 672c87ed6fd..707afa72c6a 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -80,16 +80,16 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr */ if (sa) { SpaceLink *sl = sa->spacedata.first; - + switch (sa->spacetype) { case SPACE_VIEW3D: /* 3D-View */ { BLI_assert(scene && ELEM(scene->toolsettings->gpencil_src, GP_TOOL_SOURCE_SCENE, GP_TOOL_SOURCE_OBJECT)); - + if (scene->toolsettings->gpencil_src == GP_TOOL_SOURCE_OBJECT) { /* legacy behaviour for usage with old addons requiring object-linked to objects */ - + /* just in case no active/selected object... */ if (ob && (ob->flag & SELECT)) { /* for now, as long as there's an object, default to using that in 3D-View */ @@ -107,21 +107,21 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr case SPACE_NODE: /* Nodes Editor */ { SpaceNode *snode = (SpaceNode *)sl; - + /* return the GP data for the active node block/node */ if (snode && snode->nodetree) { /* for now, as long as there's an active node tree, default to using that in the Nodes Editor */ if (ptr) RNA_id_pointer_create(&snode->nodetree->id, ptr); return &snode->nodetree->gpd; } - + /* even when there is no node-tree, don't allow this to flow to scene */ return NULL; } case SPACE_SEQ: /* Sequencer */ { SpaceSeq *sseq = (SpaceSeq *)sl; - + /* for now, Grease Pencil data is associated with the space (actually preview region only) */ /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr); @@ -130,7 +130,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr case SPACE_IMAGE: /* Image/UV Editor */ { SpaceImage *sima = (SpaceImage *)sl; - + /* for now, Grease Pencil data is associated with the space... */ /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr); @@ -140,23 +140,23 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr { SpaceClip *sc = (SpaceClip *)sl; MovieClip *clip = ED_space_clip_get_clip(sc); - + if (clip) { if (sc->gpencil_src == SC_GPENCIL_SRC_TRACK) { MovieTrackingTrack *track = BKE_tracking_track_get_active(&clip->tracking); - + if (!track) return NULL; - + if (ptr) RNA_pointer_create(&clip->id, &RNA_MovieTrackingTrack, track, ptr); - + return &track->gpd; } else { if (ptr) RNA_id_pointer_create(&clip->id, ptr); - + return &clip->gpd; } } @@ -166,7 +166,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(ID *screen_id, Scene *scene, ScrAr return NULL; } } - + /* just fall back on the scene's GP data */ if (ptr) RNA_id_pointer_create((ID *)scene, ptr); return (scene) ? &scene->gpd : NULL; @@ -179,7 +179,7 @@ bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); Object *ob = CTX_data_active_object(C); - + return ED_gpencil_data_get_pointers_direct(screen_id, scene, sa, ob, ptr); } @@ -209,7 +209,7 @@ bGPdata *ED_gpencil_data_get_active_v3d(Scene *scene, View3D *v3d) /* We have to make sure active object is actually visible and selected, else we must use default scene gpd, * to be consistent with ED_gpencil_data_get_active's behavior. */ - + if (base && TESTBASE(v3d, base)) { gpd = base->object->gpd; } @@ -237,7 +237,7 @@ bool ED_gpencil_has_keyframe_v3d(Scene *scene, Object *ob, int cfra) } } } - + if (ob && ob->gpd) { bGPDlayer *gpl = BKE_gpencil_layer_getactive(ob->gpd); if (gpl) { @@ -251,7 +251,7 @@ bool ED_gpencil_has_keyframe_v3d(Scene *scene, Object *ob, int cfra) } } } - + return false; } @@ -270,7 +270,7 @@ int gp_active_layer_poll(bContext *C) { bGPdata *gpd = ED_gpencil_data_get_active(C); bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); - + return (gpl != NULL); } @@ -315,25 +315,25 @@ const EnumPropertyItem *ED_gpencil_layers_enum_itemf( EnumPropertyItem *item = NULL, item_tmp = {0}; int totitem = 0; int i = 0; - + if (ELEM(NULL, C, gpd)) { return DummyRNA_DEFAULT_items; } - + /* Existing layers */ for (gpl = gpd->layers.first; gpl; gpl = gpl->next, i++) { item_tmp.identifier = gpl->info; item_tmp.name = gpl->info; item_tmp.value = i; - + if (gpl->flag & GP_LAYER_ACTIVE) item_tmp.icon = ICON_GREASEPENCIL; - else + else item_tmp.icon = ICON_NONE; - + RNA_enum_item_add(&item, &totitem, &item_tmp); } - + RNA_enum_item_end(&item, &totitem); *r_free = true; @@ -349,11 +349,11 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf( EnumPropertyItem *item = NULL, item_tmp = {0}; int totitem = 0; int i = 0; - + if (ELEM(NULL, C, gpd)) { return DummyRNA_DEFAULT_items; } - + /* Create new layer */ /* TODO: have some way of specifying that we don't want this? */ { @@ -363,25 +363,25 @@ const EnumPropertyItem *ED_gpencil_layers_with_new_enum_itemf( item_tmp.value = -1; item_tmp.icon = ICON_ZOOMIN; RNA_enum_item_add(&item, &totitem, &item_tmp); - + /* separator */ RNA_enum_item_add_separator(&item, &totitem); } - + /* Existing layers */ for (gpl = gpd->layers.first, i = 0; gpl; gpl = gpl->next, i++) { item_tmp.identifier = gpl->info; item_tmp.name = gpl->info; item_tmp.value = i; - + if (gpl->flag & GP_LAYER_ACTIVE) item_tmp.icon = ICON_GREASEPENCIL; - else + else item_tmp.icon = ICON_NONE; - + RNA_enum_item_add(&item, &totitem, &item_tmp); } - + RNA_enum_item_end(&item, &totitem); *r_free = true; @@ -410,11 +410,11 @@ bool gp_stroke_inside_circle(const int mval[2], const int UNUSED(mvalo[2]), const float mval_fl[2] = {mval[0], mval[1]}; const float screen_co_a[2] = {x0, y0}; const float screen_co_b[2] = {x1, y1}; - + if (edge_inside_circle(mval_fl, rad, screen_co_a, screen_co_b)) { return true; } - + /* not inside */ return false; } @@ -467,7 +467,7 @@ bool ED_gpencil_stroke_color_use(const bGPDlayer *gpl, const bGPDstroke *gps) if (((gpl->flag & GP_LAYER_UNLOCK_COLOR) == 0) && (palcolor->flag & PC_COLOR_LOCKED)) return false; } - + return true; } @@ -522,29 +522,29 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - + /* zero out the storage (just in case) */ memset(r_gsc, 0, sizeof(GP_SpaceConversion)); unit_m4(r_gsc->mat); - + /* store settings */ r_gsc->sa = sa; r_gsc->ar = ar; r_gsc->v2d = &ar->v2d; - + /* init region-specific stuff */ if (sa->spacetype == SPACE_VIEW3D) { wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); View3D *v3d = (View3D *)CTX_wm_space_data(C); RegionView3D *rv3d = ar->regiondata; - + /* init 3d depth buffers */ view3d_operator_needs_opengl(C); - + view3d_region_operator_needs_opengl(win, ar); ED_view3d_autodist_init(scene, ar, v3d, 0); - + /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &r_gsc->subrect_data, true); /* no shift */ @@ -560,7 +560,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) * \param diff_mat Matrix with the difference between original parent matrix * \param[out] r_pt Pointer to new point after apply matrix */ -void gp_point_to_parent_space(bGPDspoint *pt, float diff_mat[4][4], bGPDspoint *r_pt) +void gp_point_to_parent_space(bGPDspoint *pt, float diff_mat[4][4], bGPDspoint *r_pt) { float fpt[3]; @@ -623,12 +623,12 @@ void gp_point_to_xy(GP_SpaceConversion *gsc, bGPDstroke *gps, bGPDspoint *pt, View2D *v2d = gsc->v2d; rctf *subrect = gsc->subrect; int xyval[2]; - + /* sanity checks */ BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D)); BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D)); - - + + if (gps->flag & GP_STROKE_3DSPACE) { if (ED_view3d_project_int_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { *r_x = xyval[0]; @@ -676,12 +676,12 @@ void gp_point_to_xy_fl(GP_SpaceConversion *gsc, bGPDstroke *gps, bGPDspoint *pt, View2D *v2d = gsc->v2d; rctf *subrect = gsc->subrect; float xyval[2]; - + /* sanity checks */ BLI_assert(!(gps->flag & GP_STROKE_3DSPACE) || (gsc->sa->spacetype == SPACE_VIEW3D)); BLI_assert(!(gps->flag & GP_STROKE_2DSPACE) || (gsc->sa->spacetype != SPACE_VIEW3D)); - - + + if (gps->flag & GP_STROKE_3DSPACE) { if (ED_view3d_project_float_global(ar, &pt->x, xyval, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { *r_x = xyval[0]; @@ -695,10 +695,10 @@ void gp_point_to_xy_fl(GP_SpaceConversion *gsc, bGPDstroke *gps, bGPDspoint *pt, else if (gps->flag & GP_STROKE_2DSPACE) { float vec[3] = {pt->x, pt->y, 0.0f}; int t_x, t_y; - + mul_m4_v3(gsc->mat, vec); UI_view2d_view_to_region_clip(v2d, vec[0], vec[1], &t_x, &t_y); - + if ((t_x == t_y) && (t_x == V2D_IS_CLIPPED)) { /* XXX: Or should we just always use the values as-is? */ *r_x = 0.0f; @@ -745,22 +745,22 @@ bool gp_point_xy_to_3d(GP_SpaceConversion *gsc, Scene *scene, const float screen float *rvec = ED_view3d_cursor3d_get(scene, v3d); float ref[3] = {rvec[0], rvec[1], rvec[2]}; float zfac = ED_view3d_calc_zfac(rv3d, rvec, NULL); - + float mval_f[2], mval_prj[2]; float dvec[3]; - + copy_v2_v2(mval_f, screen_co); - + if (ED_view3d_project_float_global(gsc->ar, ref, mval_prj, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { sub_v2_v2v2(mval_f, mval_prj, mval_f); ED_view3d_win_to_delta(gsc->ar, mval_f, dvec, zfac); sub_v3_v3v3(r_out, rvec, dvec); - + return true; } else { zero_v3(r_out); - + return false; } } @@ -777,19 +777,19 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure) bGPDspoint *pt = &gps->points[i]; float pressure = 0.0f; float sco[3] = {0.0f}; - + /* Do nothing if not enough points to smooth out */ if (gps->totpoints <= 2) { return false; } - + /* Only affect endpoints by a fraction of the normal strength, * to prevent the stroke from shrinking too much */ if ((i == 0) || (i == gps->totpoints - 1)) { inf *= 0.1f; } - + /* Compute smoothed coordinate by taking the ones nearby */ /* XXX: This is potentially slow, and suffers from accumulation error as earlier points are handled before later ones */ { @@ -797,14 +797,14 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure) const int steps = 2; const float average_fac = 1.0f / (float)(steps * 2 + 1); int step; - + /* add the point itself */ madd_v3_v3fl(sco, &pt->x, average_fac); - + if (affect_pressure) { pressure += pt->pressure * average_fac; } - + /* n-steps before/after current point */ // XXX: review how the endpoints are treated by this algorithm // XXX: falloff measures should also introduce some weighting variations, so that further-out points get less weight @@ -812,17 +812,17 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure) bGPDspoint *pt1, *pt2; int before = i - step; int after = i + step; - + CLAMP_MIN(before, 0); CLAMP_MAX(after, gps->totpoints - 1); - + pt1 = &gps->points[before]; pt2 = &gps->points[after]; - + /* add both these points to the average-sum (s += p[i]/n) */ madd_v3_v3fl(sco, &pt1->x, average_fac); madd_v3_v3fl(sco, &pt2->x, average_fac); - + #if 0 /* XXX: Disabled because get weird result */ /* do pressure too? */ @@ -833,17 +833,17 @@ bool gp_smooth_stroke(bGPDstroke *gps, int i, float inf, bool affect_pressure) #endif } } - + /* Based on influence factor, blend between original and optimal smoothed coordinate */ interp_v3_v3v3(&pt->x, &pt->x, sco, inf); - + #if 0 /* XXX: Disabled because get weird result */ if (affect_pressure) { pt->pressure = pressure; } #endif - + return true; } @@ -936,22 +936,22 @@ void gp_subdivide_stroke(bGPDstroke *gps, const int new_totpoints) gps->points[new_totpoints - y] = gps->points[i]; y += 2; } - + /* Create interpolated points */ for (int i = 0; i < new_totpoints - 1; i += 2) { bGPDspoint *prev = &gps->points[i]; bGPDspoint *pt = &gps->points[i + 1]; bGPDspoint *next = &gps->points[i + 2]; - + /* Interpolate all values */ interp_v3_v3v3(&pt->x, &prev->x, &next->x, 0.5f); - + pt->pressure = interpf(prev->pressure, next->pressure, 0.5f); pt->strength = interpf(prev->strength, next->strength, 0.5f); CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f); pt->time = interpf(prev->time, next->time, 0.5f); } - + /* Update to new total number of points */ gps->totpoints = new_totpoints; } @@ -984,12 +984,12 @@ void gp_randomize_stroke(bGPDstroke *gps, bGPDbrush *brush) float normal[3]; cross_v3_v3v3(normal, v1, v2); normalize_v3(normal); - + /* get orthogonal vector to plane to rotate random effect */ float ortho[3]; cross_v3_v3v3(ortho, v1, normal); normalize_v3(ortho); - + /* Read all points and apply shift vector (first and last point not modified) */ for (int i = 1; i < gps->totpoints - 1; ++i) { bGPDspoint *pt = &gps->points[i]; diff --git a/source/blender/editors/include/BIF_gl.h b/source/blender/editors/include/BIF_gl.h index e264d9e16a3..4ec1e791499 100644 --- a/source/blender/editors/include/BIF_gl.h +++ b/source/blender/editors/include/BIF_gl.h @@ -40,7 +40,7 @@ * these should be phased out. cpack should be replaced in * code with calls to glColor3ub. - zr */ -/* +/* * * This define converts a numerical value to the equivalent 24-bit * color, while not being endian-sensitive. On little-endians, this diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 483e10faaf6..b84353f93f6 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -64,29 +64,29 @@ struct PropertyRNA; /* --------------- Context --------------------- */ -/* This struct defines a structure used for animation-specific +/* This struct defines a structure used for animation-specific * 'context' information */ typedef struct bAnimContext { void *data; /* data to be filtered for use in animation editor */ short datatype; /* type of data eAnimCont_Types */ - + short mode; /* editor->mode */ short spacetype; /* sa->spacetype */ short regiontype; /* active region -> type (channels or main) */ - + struct ScrArea *sa; /* editor host */ struct SpaceLink *sl; /* editor data */ struct ARegion *ar; /* region within editor */ - + struct bDopeSheet *ads; /* dopesheet data for editor (or which is being used) */ - + struct Scene *scene; /* active scene */ struct Object *obact; /* active object */ ListBase *markers; /* active set of markers */ - + struct ReportList *reports; /* pointer to current reports list */ - + float yscale_fac; /* scale factor for height of channels (i.e. based on the size of keyframes) */ } bAnimContext; @@ -106,24 +106,24 @@ typedef enum eAnimCont_Types { /* --------------- Channels -------------------- */ -/* This struct defines a structure used for quick and uniform access for +/* This struct defines a structure used for quick and uniform access for * channels of animation data */ typedef struct bAnimListElem { struct bAnimListElem *next, *prev; - + void *data; /* source data this elem represents */ int type; /* (eAnim_ChannelType) one of the ANIMTYPE_* values */ int flag; /* copy of elem's flags for quick access */ int index; /* for un-named data, the index of the data in its collection */ - + char update; /* (eAnim_Update_Flags) tag the element for updating */ char tag; /* tag the included data. Temporary always */ short datatype; /* (eAnim_KeyType) type of motion data to expect */ void *key_data; /* motion data - mostly F-Curves, but can be other types too */ - - + + /* NOTE: id here is the "IdAdtTemplate"-style datablock (e.g. Object, Material, Texture, NodeTree) * from which evaluation of the RNA-paths takes place. It's used to figure out how deep * channels should be nested (e.g. for Textures/NodeTrees) in the tree, and allows property @@ -135,12 +135,12 @@ typedef struct bAnimListElem { */ struct ID *id; /* ID block that channel is attached to */ struct AnimData *adt; /* source of the animation data attached to ID block (for convenience) */ - + void *owner; /* for per-element F-Curves (e.g. NLA Control Curves), the element that this represents (e.g. NlaStrip) */ } bAnimListElem; -/* Some types for easier type-testing +/* Some types for easier type-testing * NOTE: need to keep the order of these synchronized with the channels define code * which is used for drawing and handling channel lists for */ @@ -148,20 +148,20 @@ typedef enum eAnim_ChannelType { ANIMTYPE_NONE = 0, ANIMTYPE_ANIMDATA, ANIMTYPE_SPECIALDATA, - + ANIMTYPE_SUMMARY, - + ANIMTYPE_SCENE, ANIMTYPE_OBJECT, ANIMTYPE_GROUP, ANIMTYPE_FCURVE, - + ANIMTYPE_NLACONTROLS, ANIMTYPE_NLACURVE, - + ANIMTYPE_FILLACTD, ANIMTYPE_FILLDRIVERS, - + ANIMTYPE_DSMAT, ANIMTYPE_DSLAM, ANIMTYPE_DSCAM, @@ -180,18 +180,18 @@ typedef enum eAnim_ChannelType { ANIMTYPE_DSSPK, ANIMTYPE_DSGPENCIL, ANIMTYPE_DSMCLIP, - + ANIMTYPE_SHAPEKEY, - + ANIMTYPE_GPDATABLOCK, ANIMTYPE_GPLAYER, - + ANIMTYPE_MASKDATABLOCK, ANIMTYPE_MASKLAYER, - + ANIMTYPE_NLATRACK, ANIMTYPE_NLAACTION, - + /* always as last item, the total number of channel types... */ ANIMTYPE_NUM_TYPES } eAnim_ChannelType; @@ -236,31 +236,31 @@ typedef enum eAnimFilter_Flags { ANIMFILTER_LIST_VISIBLE = (1 << 1), /* channel has specifically been tagged as visible in Graph Editor (* Graph Editor Only) */ ANIMFILTER_CURVE_VISIBLE = (1 << 2), - + /* include summary channels and "expanders" (for drawing/mouse-selection in channel list) */ ANIMFILTER_LIST_CHANNELS = (1 << 3), - + /* for its type, channel should be "active" one */ ANIMFILTER_ACTIVE = (1 << 4), /* channel is a child of the active group (* Actions speciality) */ ANIMFILTER_ACTGROUPED = (1 << 5), - + /* channel must be selected/not-selected, but both must not be set together */ ANIMFILTER_SEL = (1 << 6), ANIMFILTER_UNSEL = (1 << 7), - + /* editability status - must be editable to be included */ ANIMFILTER_FOREDIT = (1 << 8), /* only selected animchannels should be considerable as editable - mainly for Graph Editor's option for keys on select curves only */ ANIMFILTER_SELEDIT = (1 << 9), - + /* flags used to enforce certain data types */ // NOTE: the ones for curves and NLA tracks were redundant and have been removed for now... ANIMFILTER_ANIMDATA = (1 << 10), - + /* duplicate entries for animation data attached to multi-user blocks must not occur */ ANIMFILTER_NODUPLIS = (1 << 11), - + /* for checking if we should keep some collapsed channel around (internal use only!) */ ANIMFILTER_TMP_PEEK = (1 << 30), @@ -322,7 +322,7 @@ typedef enum eAnimFilter_Flags { /* Grease Pencil only */ /* Grease Pencil datablock settings */ -#define EXPANDED_GPD(gpd) (gpd->flag & GP_DATA_EXPAND) +#define EXPANDED_GPD(gpd) (gpd->flag & GP_DATA_EXPAND) /* Grease Pencil Layer settings */ #define EDITABLE_GPL(gpl) ((gpl->flag & GP_LAYER_LOCKED) == 0) #define SEL_GPL(gpl) (gpl->flag & GP_LAYER_SELECT) @@ -388,7 +388,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, eAnimFilter_F */ bool ANIM_animdata_get_context(const struct bContext *C, bAnimContext *ac); -/* Obtain current anim-data context (from Animation Editor) given +/* Obtain current anim-data context (from Animation Editor) given * that Blender Context info has already been set. * Returns whether the operation was successful. */ @@ -441,7 +441,7 @@ typedef struct bAnimChannelType { const char *channel_type_name; /* "level" or role in hierarchy - for finding the active channel */ eAnimChannel_Role channel_role; - + /* -- Drawing -- */ /* get RGB color that is used to draw the majority of the backdrop */ void (*get_backdrop_color)(bAnimContext *ac, bAnimListElem *ale, float r_color[3]); @@ -451,14 +451,14 @@ typedef struct bAnimChannelType { short (*get_indent_level)(bAnimContext *ac, bAnimListElem *ale); /* get offset in pixels for the start of the channel (in addition to the indent depth) */ short (*get_offset)(bAnimContext *ac, bAnimListElem *ale); - + /* get name (for channel lists) */ void (*name)(bAnimListElem *ale, char *name); /* get RNA property+pointer for editing the name */ bool (*name_prop)(bAnimListElem *ale, struct PointerRNA *ptr, struct PropertyRNA **prop); /* get icon (for channel lists) */ int (*icon)(bAnimListElem *ale); - + /* -- Settings -- */ /* check if the given setting is valid in the current context */ bool (*has_setting)(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting); @@ -487,21 +487,21 @@ void ANIM_channel_draw_widgets(const struct bContext *C, bAnimContext *ac, bAnim /* ------------------------ Editing API -------------------------- */ -/* Check if some setting for a channel is enabled +/* Check if some setting for a channel is enabled * Returns: 1 = On, 0 = Off, -1 = Invalid * * - setting: eAnimChannel_Settings */ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting); -/* Change value of some setting for a channel +/* Change value of some setting for a channel * - setting: eAnimChannel_Settings * - mode: eAnimChannels_SetFlag */ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, eAnimChannel_Settings setting, eAnimChannels_SetFlag mode); -/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting +/* Flush visibility (for Graph Editor) changes up/down hierarchy for changes in the given setting * - anim_data: list of the all the anim channels that can be chosen * -> filtered using ANIMFILTER_CHANNELS only, since if we took VISIBLE too, * then the channels under closed expanders get ignored... @@ -569,7 +569,7 @@ void ANIM_fmodifiers_copybuf_free(void); */ bool ANIM_fmodifiers_copy_to_buf(ListBase *modifiers, bool active); -/* 'Paste' the F-Modifier(s) from the buffer to the specified list +/* 'Paste' the F-Modifier(s) from the buffer to the specified list * - replace: free all the existing modifiers to leave only the pasted ones */ bool ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, bool replace, struct FCurve *curve); @@ -644,7 +644,7 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FC */ #define BEZKEYTYPE(bezt) ((bezt)->hide) -/* set/clear/toggle macro +/* set/clear/toggle macro * - channel - channel with a 'flag' member that we're setting * - smode - 0=clear, 1=set, 2=invert * - sflag - bitflag to set @@ -655,8 +655,8 @@ float ANIM_unit_mapping_get_factor(struct Scene *scene, struct ID *id, struct FC else if (smode == ACHANNEL_SETFLAG_ADD) (channel)->flag |= (sflag); \ else (channel)->flag &= ~(sflag); \ } - -/* set/clear/toggle macro, where the flag is negative + +/* set/clear/toggle macro, where the flag is negative * - channel - channel with a 'flag' member that we're setting * - smode - 0=clear, 1=set, 2=invert * - sflag - bitflag to set @@ -680,7 +680,7 @@ void ANIM_sync_animchannels_to_data(const struct bContext *C); void ANIM_center_frame(struct bContext *C, int smooth_viewtx); /* ************************************************* */ /* OPERATORS */ - + /* generic animation channels */ void ED_operatortypes_animchannels(void); void ED_keymap_animchannels(struct wmKeyConfig *keyconf); @@ -688,7 +688,7 @@ void ED_keymap_animchannels(struct wmKeyConfig *keyconf); /* generic time editing */ void ED_operatortypes_anim(void); void ED_keymap_anim(struct wmKeyConfig *keyconf); - + /* space_graph */ void ED_operatormacros_graph(void); /* space_action */ @@ -700,7 +700,7 @@ void ED_operatormacros_action(void); /* Action Editor - Action Management */ struct AnimData *ED_actedit_animdata_from_context(struct bContext *C); -void ED_animedit_unlink_action(struct bContext *C, struct ID *id, +void ED_animedit_unlink_action(struct bContext *C, struct ID *id, struct AnimData *adt, struct bAction *act, struct ReportList *reports, bool force_delete); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index 567e477ec6c..51fb5abedd2 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -70,7 +70,7 @@ typedef struct EditBone { * animation are automatically relative to the bones' rest positions*/ int flag; int layer; - + float dist, weight; float xwidth, length, zwidth; /* put them in order! transform uses this as scale */ float rad_head, rad_tail; @@ -83,7 +83,7 @@ typedef struct EditBone { float scaleIn, scaleOut; float oldlength; /* for envelope scaling */ - + short segments; /* Used to store temporary data */ @@ -230,7 +230,7 @@ void ED_mesh_deform_bind_callback(struct Scene *scene, struct MeshDeformModifierData *mmd, struct DerivedMesh *cagedm, float *vertexcos, int totvert, float cagemat[4][4]); - + #ifdef __cplusplus } #endif diff --git a/source/blender/editors/include/ED_gpencil.h b/source/blender/editors/include/ED_gpencil.h index 74d9ad0886d..6b9cf23ce73 100644 --- a/source/blender/editors/include/ED_gpencil.h +++ b/source/blender/editors/include/ED_gpencil.h @@ -84,7 +84,7 @@ typedef struct tGPDinterpolate { void *draw_handle_screen; /* handle for drawing strokes while operator is running screen stuff */ } tGPDinterpolate; -/* Temporary 'Stroke Point' data +/* Temporary 'Stroke Point' data * * Used as part of the 'stroke cache' used during drawing of new strokes */ diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index c478a8b17e5..a29057197ed 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -53,17 +53,17 @@ struct DLRBT_Tree; typedef struct ActKeyColumn { /* ListBase linkage */ struct ActKeyColumn *next, *prev; - + /* sorting-tree linkage */ struct ActKeyColumn *left, *right; /* 'children' of this node, less than and greater than it (respectively) */ struct ActKeyColumn *parent; /* parent of this node in the tree */ char tree_col; /* DLRB_BLACK or DLRB_RED */ - + /* keyframe info */ char key_type; /* eBezTripe_KeyframeType */ short sel; float cfra; - + /* only while drawing - used to determine if long-keyframe needs to be drawn */ short modified; short totcurve; @@ -73,21 +73,21 @@ typedef struct ActKeyColumn { typedef struct ActKeyBlock { /* ListBase linkage */ struct ActKeyBlock *next, *prev; - + /* sorting-tree linkage */ struct ActKeyBlock *left, *right; /* 'children' of this node, less than and greater than it (respectively) */ struct ActKeyBlock *parent; /* parent of this node in the tree */ char tree_col; /* DLRB_BLACK or DLRB_RED */ - + /* key-block info */ char sel; short flag; float val; float start, end; - + /* only while drawing - used to determine if block needs to be drawn */ short modified; - short totcurve; + short totcurve; } ActKeyBlock; /* ActKeyBlock - Flag */ diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 189cc36c134..5787a63d324 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -141,12 +141,12 @@ typedef enum eKeyframeVertOk { typedef enum eKeyframeIterFlags { /* consider handles in addition to key itself */ KEYFRAME_ITER_INCL_HANDLES = (1 << 0), - + /* Perform NLA time remapping (global -> strip) for the "f1" parameter * (e.g. used for selection tools on summary tracks) */ KED_F1_NLA_UNMAP = (1 << 1), - + /* Perform NLA time remapping (global -> strip) for the "f2" parameter */ KED_F2_NLA_UNMAP = (1 << 2), } eKeyframeIterFlags; @@ -165,7 +165,7 @@ typedef struct KeyframeEditData { struct FCurve *fcu; /* F-Curve that is being iterated over */ int curIndex; /* index of current keyframe being iterated over */ float channel_y; /* y-position of midpoint of the channel (for the dopesheet) */ - + /* flags */ eKeyframeVertOk curflags; /* current flags for the keyframe we're reached in the iteration process */ eKeyframeIterFlags iterflags; /* settings for iteration process */ @@ -243,7 +243,7 @@ KeyframeEditFunc ANIM_editkeyframes_easing(short mode); /* -------- BezTriple Callbacks (Selection Map) ---------- */ -/* Get a callback to populate the selection settings map +/* Get a callback to populate the selection settings map * requires: ked->custom = char[] of length fcurve->totvert */ KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode); diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index bf4e9495e01..6b842bcd132 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -59,19 +59,19 @@ struct EnumPropertyItem; /* ************ Keyframing Management **************** */ -/* Get the active settings for keyframing settings from context (specifically the given scene) +/* Get the active settings for keyframing settings from context (specifically the given scene) * - incl_mode: include settings from keyframing mode in the result (i.e. replace only) */ short ANIM_get_keyframing_flags(struct Scene *scene, short incl_mode); /* -------- */ -/* Get (or add relevant data to be able to do so) the Active Action for the given +/* Get (or add relevant data to be able to do so) the Active Action for the given * Animation Data block, given an ID block where the Animation Data should reside. */ struct bAction *verify_adt_action(struct ID *id, short add); -/* Get (or add relevant data to be able to do so) F-Curve from the given Action. +/* Get (or add relevant data to be able to do so) F-Curve from the given Action. * This assumes that all the destinations are valid. */ struct FCurve *verify_fcurve(struct bAction *act, const char group[], struct PointerRNA *ptr, @@ -94,7 +94,7 @@ void update_autoflags_fcurve(struct FCurve *fcu, struct bContext *C, struct Repo */ int insert_bezt_fcurve(struct FCurve *fcu, const struct BezTriple *bezt, eInsertKeyFlags flag); -/* Main Keyframing API call: +/* Main Keyframing API call: * Use this when validation of necessary animation data isn't necessary as it * already exists. It will insert a keyframe using the current value being keyframed. * Returns the index at which a keyframe was added (or -1 if failed) @@ -103,7 +103,7 @@ int insert_vert_fcurve(struct FCurve *fcu, float x, float y, eBezTriple_Keyframe /* -------- */ -/* Secondary Keyframing API calls: +/* Secondary Keyframing API calls: * Use this to insert a keyframe using the current value being keyframed, in the * nominated F-Curve (no creation of animation data performed). Returns success. */ @@ -111,13 +111,13 @@ bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, s /* -------- */ -/* Main Keyframing API calls: +/* Main Keyframing API calls: * Use this to create any necessary animation data, and then insert a keyframe * using the current value being keyframed, in the relevant place. Returns success. */ short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eBezTriple_KeyframeType keytype, eInsertKeyFlags flag); -/* Main Keyframing API call: +/* Main Keyframing API call: * Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case. */ short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, eInsertKeyFlags flag); @@ -133,13 +133,13 @@ typedef int (*cbKeyingSet_Poll)(struct KeyingSetInfo *ksi, struct bContext *C); /* Context Iterator Callback for KeyingSets */ typedef void (*cbKeyingSet_Iterator)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks); /* Property Specifier Callback for KeyingSets (called from iterators) */ -typedef void (*cbKeyingSet_Generate)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks, struct PointerRNA *ptr); +typedef void (*cbKeyingSet_Generate)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks, struct PointerRNA *ptr); /* Callback info for 'Procedural' KeyingSets to use */ typedef struct KeyingSetInfo { struct KeyingSetInfo *next, *prev; - + /* info */ /* identifier used for class name, which KeyingSet instances reference as "Typeinfo Name" */ char idname[64]; @@ -149,11 +149,11 @@ typedef struct KeyingSetInfo { char description[240]; /* RNA_DYN_DESCR_MAX */ /* keying settings */ short keyingflag; - + /* polling callbacks */ /* callback for polling the context for whether the right data is available */ cbKeyingSet_Poll poll; - + /* generate callbacks */ /* iterator to use to go through collections of data in context * - this callback is separate from the 'adding' stage, allowing @@ -162,7 +162,7 @@ typedef struct KeyingSetInfo { cbKeyingSet_Iterator iter; /* generator to use to add properties based on the data found by iterator */ cbKeyingSet_Generate generate; - + /* RNA integration */ struct ExtensionRNA ext; } KeyingSetInfo; @@ -241,7 +241,7 @@ typedef enum eCreateDriver_MappingTypes { CREATEDRIVER_MAPPING_1_N = 0, /* 1 to Many - Use the specified index, and drive all elements with it */ CREATEDRIVER_MAPPING_1_1 = 1, /* 1 to 1 - Only for the specified index on each side */ CREATEDRIVER_MAPPING_N_N = 2, /* Many to Many - Match up the indices one by one (only for drivers on vectors/arrays) */ - + CREATEDRIVER_MAPPING_NONE = 3, /* None (Single Prop) - Do not create driver with any targets; these will get added later instead */ CREATEDRIVER_MAPPING_NONE_ALL = 4, /* None (All Properties) - Do not create driver with any targets; these will get added later instead */ } eCreateDriver_MappingTypes; @@ -270,7 +270,7 @@ struct FCurve *verify_driver_fcurve(struct ID *id, const char rna_path[], const * - mapping_type: eCreateDriver_MappingTypes */ int ANIM_add_driver_with_target( - struct ReportList *reports, + struct ReportList *reports, struct ID *dst_id, const char dst_path[], int dst_index, struct ID *src_id, const char src_path[], int src_index, short flag, int driver_type, short mapping_type); @@ -362,7 +362,7 @@ bool fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter); */ bool id_frame_has_keyframe(struct ID *id, float frame, short filter); -/* filter flags for id_cfra_has_keyframe +/* filter flags for id_cfra_has_keyframe * * WARNING: do not alter order of these, as also stored in files * (for v3d->keyflags) diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h index 8c720ddea95..a95e283f218 100644 --- a/source/blender/editors/include/ED_markers.h +++ b/source/blender/editors/include/ED_markers.h @@ -68,7 +68,7 @@ struct TimeMarker *ED_markers_get_first_selected(ListBase *markers); /* Operators ------------------------------ */ /* called in screen_ops.c:ED_operatortypes_screen() */ -void ED_operatortypes_marker(void); +void ED_operatortypes_marker(void); /* called in screen_ops.c:ED_keymap_screen() */ void ED_keymap_marker(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index e6c697b9d06..2b1ce461b0e 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -63,7 +63,7 @@ enum { #define REDRAW_FRAME_AVERAGE 8 -/* for playback framerate info +/* for playback framerate info * stored during runtime as scene->fps_info */ typedef struct ScreenFrameRateInfo { diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h index 6de1f9c6f1f..ff9e66ea151 100644 --- a/source/blender/editors/include/ED_space_api.h +++ b/source/blender/editors/include/ED_space_api.h @@ -59,7 +59,7 @@ void ED_spacetype_console(void); void ED_spacetype_userpref(void); void ED_spacetype_clip(void); -/* calls for instancing and freeing spacetype static data +/* calls for instancing and freeing spacetype static data * called in WM_init_exit */ /* in space_file.c */ void ED_file_init(void); @@ -69,7 +69,7 @@ void ED_file_exit(void); #define REGION_DRAW_POST_PIXEL 1 #define REGION_DRAW_PRE_VIEW 2 -void *ED_region_draw_cb_activate(struct ARegionType *, +void *ED_region_draw_cb_activate(struct ARegionType *, void (*draw)(const struct bContext *, struct ARegion *, void *), void *custumdata, int type); void ED_region_draw_cb_draw(const struct bContext *, struct ARegion *, int); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 99aa392effc..5110dd1a3f6 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -86,7 +86,7 @@ typedef struct ViewDepths { short x, y; /* only for temp use for sub-rects, added to ar->winx/y */ float *depths; double depth_range[2]; - + bool damaged; } ViewDepths; diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index a0d24ad60bf..0c5631abe3b 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -61,7 +61,7 @@ DEF_ICON(PLUG) DEF_ICON(UI) DEF_ICON(NODE) DEF_ICON(NODE_SEL) - + /* ui */ DEF_ICON(FULLSCREEN) DEF_ICON(SPLITSCREEN) @@ -89,7 +89,7 @@ DEF_ICON(DOTSDOWN) DEF_ICON(LINK) DEF_ICON(INLINK) DEF_ICON(PLUGIN) - + /* various ui */ DEF_ICON(HELP) DEF_ICON(GHOST_ENABLED) @@ -119,7 +119,7 @@ DEF_ICON(RECOVER_LAST) DEF_ICON(FULLSCREEN_ENTER) DEF_ICON(FULLSCREEN_EXIT) DEF_ICON(BLANK1) // Not actually blank - this is used all over the place - + /* BUTTONS */ DEF_ICON(LAMP) DEF_ICON(MATERIAL) @@ -208,7 +208,7 @@ DEF_ICON(LIGHTPAINT) DEF_ICON(BLANK077) DEF_ICON(BLANK077b) #endif - + /* DATA */ DEF_ICON(SCENE_DATA) DEF_ICON(RENDERLAYERS) @@ -300,7 +300,7 @@ DEF_ICON(RNA_ADD) DEF_ICON(BLANK116) DEF_ICON(BLANK116b) #endif - + /* OUTLINER */ DEF_ICON(OUTLINER_OB_EMPTY) DEF_ICON(OUTLINER_OB_MESH) @@ -362,7 +362,7 @@ DEF_ICON(OUTLINER_DATA_POSE) DEF_ICON(BLANK142) DEF_ICON(BLANK142b) #endif - + /* PRIMITIVES */ DEF_ICON(MESH_PLANE) DEF_ICON(MESH_CUBE) @@ -396,7 +396,7 @@ DEF_ICON(META_CAPSULE) #ifndef DEF_ICON_BLANK_SKIP DEF_ICON(BLANK625) #endif - + /* PRIMITIVES */ DEF_ICON(SURFACE_NCURVE) DEF_ICON(SURFACE_NCIRCLE) @@ -487,7 +487,7 @@ DEF_ICON(NODE_INSERT_OFF) DEF_ICON(BLANK713) DEF_ICON(BLANK714) DEF_ICON(BLANK715) - + /* EMPTY */ DEF_ICON(BLANK720) DEF_ICON(BLANK721) @@ -602,7 +602,7 @@ DEF_ICON(MOD_NORMALEDIT) DEF_ICON(BLANK176) DEF_ICON(BLANK177) #endif - + /* ANIMATION */ DEF_ICON(REC) DEF_ICON(PLAY) @@ -693,7 +693,7 @@ DEF_ICON(SCULPT_DYNTOPO) /* XXX Empty icon! */ DEF_ICON(PARTICLE_POINT) DEF_ICON(PARTICLE_TIP) DEF_ICON(PARTICLE_PATH) - + /* EDITING */ DEF_ICON(MAN_TRANS) DEF_ICON(MAN_ROT) @@ -755,7 +755,7 @@ DEF_ICON(UV_SYNC_SELECT) DEF_ICON(BLANK247) DEF_ICON(BLANK247b) #endif - + /* 3D VIEW */ DEF_ICON(BBOX) DEF_ICON(WIRE) @@ -878,7 +878,7 @@ DEF_ICON(FORWARD) DEF_ICON(FILE_HIDDEN) DEF_ICON(FILE_BACKUP) DEF_ICON(DISK_DRIVE) - + /* SHADING / TEXT */ DEF_ICON(MATPLANE) DEF_ICON(MATSPHERE) @@ -910,7 +910,7 @@ DEF_ICON(SCRIPTPLUGINS) // XXX CREATE NEW DEF_ICON(BLANK328) DEF_ICON(BLANK328b) #endif - + /* SEQUENCE / IMAGE EDITOR */ DEF_ICON(SEQ_SEQUENCER) DEF_ICON(SEQ_PREVIEW) @@ -1004,7 +1004,7 @@ DEF_ICON(MATCAP_22) DEF_ICON(MATCAP_23) DEF_ICON(MATCAP_24) -/* vector icons, VICO_ prefix added */ +/* vector icons, VICO_ prefix added */ DEF_VICO(SMALL_TRI_RIGHT_VEC) DEF_VICO(KEYTYPE_KEYFRAME_VEC) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 4647d9f10d8..b6e75893431 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -543,7 +543,7 @@ bool UI_but_online_manual_id_from_active( * - R: RNA * - O: operator */ -uiBut *uiDefBut(uiBlock *block, +uiBut *uiDefBut(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, @@ -563,7 +563,7 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x, int y, short width, short height, const char *tip); -uiBut *uiDefIconBut(uiBlock *block, +uiBut *uiDefIconBut(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, @@ -627,7 +627,7 @@ enum { typedef struct uiStringInfo { int type; char *strinfo; -} uiStringInfo; +} uiStringInfo; /* Note: Expects pointers to uiStringInfo structs as parameters. * Will fill them with translated strings, when possible. @@ -936,9 +936,9 @@ void uiTemplateIDBrowse( void uiTemplateIDPreview( uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, int rows, int cols, int filter); -void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, +void uiTemplateAnyID(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *proptypename, const char *text); -void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, +void uiTemplatePathBuilder(uiLayout *layout, struct PointerRNA *ptr, const char *propname, struct PointerRNA *root_ptr, const char *text); uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr); uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr); diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 7249cfda244..b0cb2418e6f 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -56,7 +56,7 @@ enum { TH_THEMEUI, // common colors among spaces - + TH_BACK, TH_TEXT, TH_TEXT_HI, @@ -65,22 +65,22 @@ enum { TH_TAB_INACTIVE, TH_TAB_BACK, TH_TAB_OUTLINE, - + TH_HEADER, TH_HEADERDESEL, TH_HEADER_TEXT, TH_HEADER_TEXT_HI, - + /* panels */ TH_PANEL_HEADER, TH_PANEL_BACK, TH_PANEL_SHOW_HEADER, TH_PANEL_SHOW_BACK, - + TH_BUTBACK, TH_BUTBACK_TEXT, TH_BUTBACK_TEXT_HI, - + TH_SHADE1, TH_SHADE2, TH_HILITE, @@ -141,14 +141,14 @@ enum { TH_SYNTAX_D, TH_SYNTAX_N, TH_SYNTAX_S, - + TH_BONE_SOLID, TH_BONE_POSE, TH_BONE_POSE_ACTIVE, - + TH_STRIP, TH_STRIP_SELECT, - + TH_KEYTYPE_KEYFRAME, /* KEYTYPES */ TH_KEYTYPE_KEYFRAME_SELECT, TH_KEYTYPE_EXTREME, @@ -157,15 +157,15 @@ enum { TH_KEYTYPE_BREAKDOWN_SELECT, TH_KEYTYPE_JITTER, TH_KEYTYPE_JITTER_SELECT, - + TH_KEYBORDER, TH_KEYBORDER_SELECT, - + TH_LAMP, TH_SPEAKER, TH_CAMERA, TH_EMPTY, - + TH_NODE, TH_NODE_INPUT, TH_NODE_OUTPUT, @@ -183,14 +183,14 @@ enum { TH_NODE_FRAME, TH_NODE_MATTE, TH_NODE_DISTORT, - + TH_CONSOLE_OUTPUT, TH_CONSOLE_INPUT, TH_CONSOLE_INFO, TH_CONSOLE_ERROR, TH_CONSOLE_CURSOR, TH_CONSOLE_SELECT, - + TH_SEQ_MOVIE, TH_SEQ_MOVIECLIP, TH_SEQ_MASK, @@ -205,20 +205,20 @@ enum { TH_EDGE_SHARP, TH_EDITMESH_ACTIVE, - + TH_HANDLE_VERTEX, TH_HANDLE_VERTEX_SELECT, TH_HANDLE_VERTEX_SIZE, - + TH_GP_VERTEX, TH_GP_VERTEX_SELECT, TH_GP_VERTEX_SIZE, - + TH_DOPESHEET_CHANNELOB, TH_DOPESHEET_CHANNELSUBOB, - + TH_PREVIEW_BACK, - + TH_EDGE_CREASE, TH_DRAWEXTRA_EDGELEN, @@ -259,20 +259,20 @@ enum { TH_SELECT_HIGHLIGHT, /* highlight color for selected outliner item */ TH_SKIN_ROOT, - + TH_ANIM_ACTIVE, /* active action */ TH_ANIM_INACTIVE, /* no active action */ - + TH_NLA_TWEAK, /* 'tweaking' track in NLA */ TH_NLA_TWEAK_DUPLI, /* error/warning flag for other strips referencing dupli strip */ - + TH_NLA_TRANSITION, TH_NLA_TRANSITION_SEL, TH_NLA_META, TH_NLA_META_SEL, TH_NLA_SOUND, TH_NLA_SOUND_SEL, - + TH_WIDGET_EMBOSS, TH_AXIS_X, /* X/Y/Z Axis */ @@ -294,7 +294,7 @@ enum { TH_INFO_DEBUG, TH_INFO_DEBUG_TEXT, TH_VIEW_OVERLAY, - + TH_V3D_CLIPPING_BORDER, TH_METADATA_BG, diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index e7280398b33..99cee0cb673 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -44,7 +44,7 @@ /* generic value to use when coordinate lies out of view when converting */ #define V2D_IS_CLIPPED 12000 -/* Common View2D view types +/* Common View2D view types * NOTE: only define a type here if it completely sets all (+/- a few) of the relevant flags * and settings for a View2D region, and that set of settings is used in more * than one specific place @@ -75,7 +75,7 @@ enum eView2D_Units { V2D_UNIT_SECONDS = 0, V2D_UNIT_FRAMES, V2D_UNIT_FRAMESCALE, - + /* for drawing values */ V2D_UNIT_VALUES, V2D_UNIT_DEGREES, @@ -95,7 +95,7 @@ enum eView2D_Gridlines { V2D_HORIZONTAL_AXIS = (1 << 2), V2D_VERTICAL_AXIS = (1 << 3), V2D_HORIZONTAL_FINELINES = (1 << 4), - + V2D_GRIDLINES_MAJOR = (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS | V2D_HORIZONTAL_LINES | V2D_HORIZONTAL_AXIS), V2D_GRIDLINES_ALL = (V2D_GRIDLINES_MAJOR | V2D_HORIZONTAL_FINELINES), }; diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 2d605e3226a..83f5af0709d 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -59,7 +59,7 @@ #include "io_collada.h" static int wm_collada_export_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) -{ +{ if (!RNA_struct_property_is_set(op->ptr, "filepath")) { char filepath[FILE_MAX]; @@ -596,8 +596,8 @@ void WM_OT_collada_import(wmOperatorType *ot) 0, INT_MAX); - RNA_def_boolean(ot->srna, - "keep_bind_info", 0, "Keep Bind Info", + RNA_def_boolean(ot->srna, + "keep_bind_info", 0, "Keep Bind Info", "Store Bindpose information in custom bone properties for later use during Collada export"); } diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c index 6df4b0f4783..26414661f52 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.c @@ -42,7 +42,7 @@ #include "io_cache.h" -void ED_operatortypes_io(void) +void ED_operatortypes_io(void) { #ifdef WITH_COLLADA /* Collada operators: */ diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 16147bdc7f8..364800ed1a2 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -205,21 +205,21 @@ void ED_masklayer_frames_select_border(MaskLayer *masklay, float min, float max, void ED_masklayer_frames_select_region(KeyframeEditData *ked, MaskLayer *masklay, short tool, short select_mode) { MaskLayerShape *masklay_shape; - + if (masklay == NULL) return; - + /* only select frames which are within the region */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { /* construct a dummy point coordinate to do this testing with */ float pt[2] = {0}; - + pt[0] = masklay_shape->frame; pt[1] = ked->channel_y; - + /* check the necessary regions */ if (tool == BEZT_OK_CHANNEL_LASSO) { - /* Lasso */ + /* Lasso */ if (keyframe_region_lasso_test(ked->data, pt)) masklayshape_select(masklay_shape, select_mode); } diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index c453284a617..899f1924222 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -65,7 +65,7 @@ void paintface_flush_flags(Object *ob, short flag) const int *index_array = NULL; int totpoly; int i; - + BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0); if (me == NULL) @@ -110,7 +110,7 @@ void paintface_hide(Object *ob, const bool unselected) Mesh *me; MPoly *mpoly; int a; - + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; @@ -126,10 +126,10 @@ void paintface_hide(Object *ob, const bool unselected) if (mpoly->flag & ME_HIDE) { mpoly->flag &= ~ME_FACE_SEL; } - + mpoly++; } - + BKE_mesh_flush_hidden_from_polys(me); paintface_flush_flags(ob, SELECT | ME_HIDE); @@ -262,7 +262,7 @@ void paintface_deselect_all_visible(Object *ob, int action, bool flush_flags) me = BKE_mesh_from_object(ob); if (me == NULL) return; - + if (action == SEL_TOGGLE) { action = SEL_SELECT; @@ -315,7 +315,7 @@ bool paintface_minmax(Object *ob, float r_min[3], float r_max[3]) if (!me || !me->mloopuv) { return ok; } - + copy_m3_m4(bmat, ob->obmat); mvert = me->mvert; @@ -342,19 +342,19 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b Mesh *me; MPoly *mpoly, *mpoly_sel; unsigned int a, index; - + /* Get the face under the cursor */ me = BKE_mesh_from_object(ob); if (!ED_mesh_pick_face(C, ob, mval, &index, ED_MESH_PICK_DEFAULT_FACE_SIZE)) return false; - + if (index >= me->totpoly) return false; mpoly_sel = me->mpoly + index; if (mpoly_sel->flag & ME_HIDE) return false; - + /* clear flags */ mpoly = me->mpoly; a = me->totpoly; @@ -364,7 +364,7 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b mpoly++; } } - + me->act_face = (int)index; if (extend) { @@ -382,9 +382,9 @@ bool paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], b else { mpoly_sel->flag |= ME_FACE_SEL; } - + /* image window redraw */ - + paintface_flush_flags(ob, SELECT); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views @@ -403,7 +403,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten const int size[2] = { BLI_rcti_size_x(rect) + 1, BLI_rcti_size_y(rect) + 1}; - + me = BKE_mesh_from_object(ob); if ((me == NULL) || (me->totpoly == 0) || (size[0] * size[1] <= 0)) { @@ -459,7 +459,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, bool select, bool exten IMB_freeImBuf(ibuf); MEM_freeN(selar); -#ifdef __APPLE__ +#ifdef __APPLE__ glReadBuffer(GL_BACK); #endif @@ -522,7 +522,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, bool flush_flags) me = BKE_mesh_from_object(ob); if (me == NULL) return; - + if (action == SEL_TOGGLE) { action = SEL_SELECT; diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index c8d33a9cc60..bf349a4c678 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -79,7 +79,7 @@ typedef struct { BMEditMesh *em; float initial_length[NUM_VALUE_KINDS]; float scale[NUM_VALUE_KINDS]; - NumInput num_input[NUM_VALUE_KINDS]; + NumInput num_input[NUM_VALUE_KINDS]; float shift_value[NUM_VALUE_KINDS]; /* The current value when shift is pressed. Negative when shift not active. */ bool is_modal; @@ -155,7 +155,7 @@ static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal) opdata->shift_value[i] = -1.0f; opdata->initial_length[i] = -1.0f; /* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */ - opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch; + opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch; initNumInput(&opdata->num_input[i]); opdata->num_input[i].idx_max = 0; @@ -305,7 +305,7 @@ static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, len = len_v2(mlen); vmode = opdata->value_mode; if (mode_changed || opdata->initial_length[vmode] == -1.0f) { - /* If current value is not default start value, adjust len so that + /* If current value is not default start value, adjust len so that * the scaling and offset in edbm_bevel_mouse_set_value will * start at current value */ value = (vmode == SEGMENTS_VALUE) ? @@ -519,7 +519,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) (opdata->value_mode == OFFSET_VALUE || opdata->value_mode == OFFSET_VALUE_PERCENT)) { edbm_bevel_mouse_set_value(op, event); - } + } edbm_bevel_calc(op); edbm_bevel_update_header(C, op); handled = true; @@ -561,7 +561,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) case VKEY: if (event->val == KM_RELEASE) break; - + { PropertyRNA *prop = RNA_struct_find_property(op->ptr, "vertex_only"); RNA_property_boolean_set(op->ptr, prop, !RNA_property_boolean_get(op->ptr, prop)); @@ -570,7 +570,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) edbm_bevel_update_header(C, op); handled = true; break; - + } /* Modal numinput inactive, try to handle numeric inputs last... */ diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index da441221646..8eb3ad84919 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -1045,7 +1045,7 @@ static void knifetool_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) knifetool_draw_angle_snapping(kcd); glColor3ubv(kcd->colors.line); - + glLineWidth(2.0); glBegin(GL_LINES); @@ -1791,7 +1791,7 @@ static void knife_input_ray_segment(KnifeTool_OpData *kcd, const float mval[2], ED_view3d_unproject(&mats, r_origin_ofs, mval[0], mval[1], ofs); /* transform into object space */ - invert_m4_m4(kcd->ob->imat, kcd->ob->obmat); + invert_m4_m4(kcd->ob->imat, kcd->ob->obmat); mul_m4_v3(kcd->ob->imat, r_origin); mul_m4_v3(kcd->ob->imat, r_origin_ofs); diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 785d81d75ff..f07073cd3d7 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -73,7 +73,7 @@ typedef struct RingSelOpData { ARegion *ar; /* region that ringsel was activated in */ void *draw_handle; /* for drawing preview loop */ - + float (*edges)[2][3]; int totedge; @@ -99,7 +99,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg) { View3D *v3d = CTX_wm_view3d(C); RingSelOpData *lcd = arg; - + if ((lcd->totedge > 0) || (lcd->totpoint > 0)) { if (v3d && v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -148,7 +148,7 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed, break; } } - + /* this should never happen */ if (!l) { v[0][0] = eed->v1; @@ -157,7 +157,7 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed, v[1][1] = lasteed->v2; return; } - + l2 = BM_loop_other_edge_loop(l, eed->v1); rev = (l2 == l->prev); while (l2->v != lasteed->v1 && l2->v != lasteed->v2) { @@ -371,7 +371,7 @@ static void edgering_select(RingSelOpData *lcd) BMEdge *eed_start = lcd->eed; BMWalker walker; BMEdge *eed; - + if (!eed_start) return; @@ -417,7 +417,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) BMVert *v_eed_orig[2] = {lcd->eed->v1, lcd->eed->v2}; edgering_select(lcd); - + if (lcd->do_cut) { const bool is_macro = (op->opm != NULL); /* a single edge (rare, but better support) */ @@ -465,7 +465,7 @@ static void ringsel_finish(bContext *C, wmOperator *op) BM_select_history_store(em->bm, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */ if (em->selectmode & SCE_SELECT_EDGE) BM_select_history_store(em->bm, lcd->eed); - + EDBM_selectmode_flush(lcd->em); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, lcd->ob->data); } @@ -479,7 +479,7 @@ static void ringsel_exit(bContext *UNUSED(C), wmOperator *op) /* deactivate the extra drawing stuff in 3D-View */ ED_region_draw_cb_exit(lcd->ar->type, lcd->draw_handle); - + edgering_preview_free(lcd); ED_region_tag_redraw(lcd->ar); @@ -498,7 +498,7 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) /* alloc new customdata */ lcd = op->customdata = MEM_callocN(sizeof(RingSelOpData), "ringsel Modal Op Data"); - + /* assign the drawing handle for drawing preview line... */ lcd->ar = CTX_wm_region(C); lcd->draw_handle = ED_region_draw_cb_activate(lcd->ar->type, ringsel_draw, lcd, REGION_DRAW_POST_VIEW); @@ -508,7 +508,7 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) lcd->do_cut = do_cut; lcd->cuts = RNA_int_get(op->ptr, "number_cuts"); lcd->smoothness = RNA_float_get(op->ptr, "smoothness"); - + initNumInput(&lcd->num); lcd->num.idx_max = 1; lcd->num.val_flag[0] |= NUM_NO_NEGATIVE | NUM_NO_FRACTION; @@ -679,7 +679,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) case LEFTMOUSE: /* confirm */ // XXX hardcoded if (event->val == KM_PRESS) return loopcut_finish(lcd, C, op); - + ED_region_tag_redraw(lcd->ar); handled = true; break; @@ -694,11 +694,11 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) /* cancel */ ED_region_tag_redraw(lcd->ar); ED_area_headerprint(CTX_wm_area(C), NULL); - + ringcut_cancel(C, op); return OPERATOR_CANCELLED; } - + ED_region_tag_redraw(lcd->ar); handled = true; break; @@ -800,7 +800,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) str_rep, str_rep + NUM_STR_REP_LEN); ED_area_headerprint(CTX_wm_area(C), buf); } - + /* keep going until the user confirms */ return OPERATOR_RUNNING_MODAL; } @@ -814,11 +814,11 @@ void MESH_OT_edgering_select(wmOperatorType *ot) ot->name = "Edge Ring Select"; ot->idname = "MESH_OT_edgering_select"; ot->description = "Select an edge ring"; - + /* callbacks */ ot->invoke = ringsel_invoke; - ot->poll = ED_operator_editmesh_region_view3d; - + ot->poll = ED_operator_editmesh_region_view3d; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -835,14 +835,14 @@ void MESH_OT_loopcut(wmOperatorType *ot) ot->name = "Loop Cut"; ot->idname = "MESH_OT_loopcut"; ot->description = "Add a new loop between existing loops"; - + /* callbacks */ ot->invoke = ringcut_invoke; ot->exec = loopcut_exec; ot->modal = loopcut_modal; ot->cancel = ringcut_cancel; ot->poll = ED_operator_editmesh_region_view3d; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index ba271da7110..f3ccdf32938 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -254,7 +254,7 @@ void ED_mesh_uv_loop_reset(struct bContext *C, struct Mesh *me) CustomData *pdata = GET_CD_DATA(me, pdata); const int layernum = CustomData_get_active_layer(pdata, CD_MTEXPOLY); ED_mesh_uv_loop_reset_ex(me, layernum); - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); } @@ -313,7 +313,7 @@ int ED_mesh_uv_texture_add(Mesh *me, const char *name, const bool active_set) CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, me->totloop, name); CustomData_add_layer_named(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface, name); } - + if (active_set || layernum_dst == 0) { CustomData_set_layer_active(&me->pdata, CD_MTEXPOLY, layernum_dst); CustomData_set_layer_active(&me->ldata, CD_MLOOPUV, layernum_dst); @@ -541,7 +541,7 @@ static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op)) BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } - + return OPERATOR_FINISHED; } @@ -551,7 +551,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot) ot->name = "Add UV Map"; ot->description = "Add UV Map"; ot->idname = "MESH_OT_uv_texture_add"; - + /* api callbacks */ ot->poll = layers_poll; ot->exec = mesh_uv_texture_add_exec; @@ -570,7 +570,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e Mesh *me; Object *obedit; int exitmode = 0; - + if (v3d == NULL) { BKE_report(op->reports, RPT_ERROR, "No 3D View Available"); return OPERATOR_CANCELLED; @@ -583,7 +583,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e BKE_report(op->reports, RPT_ERROR, "Not an object or mesh"); return OPERATOR_CANCELLED; } - + ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM); if (!ima) { return OPERATOR_CANCELLED; @@ -601,7 +601,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e } if (me->edit_btmesh == NULL) return OPERATOR_CANCELLED; - + ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL); if (exitmode) { @@ -618,9 +618,9 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, const wmEvent *e /* dummie drop support; ensure view shows a result :) */ if (v3d) v3d->flag2 |= V3D_SOLID_TEX; - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - + return OPERATOR_FINISHED; } @@ -630,14 +630,14 @@ void MESH_OT_drop_named_image(wmOperatorType *ot) ot->name = "Drop Image to Mesh UV Map"; ot->description = "Assign Image to active UV Map, or create an UV Map"; ot->idname = "MESH_OT_drop_named_image"; - + /* api callbacks */ ot->poll = layers_poll; ot->invoke = drop_named_image_invoke; - + /* flags */ ot->flag = OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign"); RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file"); @@ -657,7 +657,7 @@ static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op)) BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } - + return OPERATOR_FINISHED; } @@ -667,7 +667,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot) ot->name = "Remove UV Map"; ot->description = "Remove UV Map"; ot->idname = "MESH_OT_uv_texture_remove"; - + /* api callbacks */ ot->poll = layers_poll; ot->exec = mesh_uv_texture_remove_exec; @@ -695,7 +695,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot) ot->name = "Add Vertex Color"; ot->description = "Add vertex color layer"; ot->idname = "MESH_OT_vertex_color_add"; - + /* api callbacks */ ot->poll = layers_poll; ot->exec = mesh_vertex_color_add_exec; @@ -721,7 +721,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot) ot->name = "Remove Vertex Color"; ot->description = "Remove vertex color layer"; ot->idname = "MESH_OT_vertex_color_remove"; - + /* api callbacks */ ot->exec = mesh_vertex_color_remove_exec; ot->poll = layers_poll; diff --git a/source/blender/editors/mesh/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index 96b9f054252..20ece9c3336 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -93,7 +93,7 @@ int ED_mesh_mirror_spatial_table(Object *ob, BMEditMesh *em, DerivedMesh *dm, co else { MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; int i; - + for (i = 0; i < totvert; i++, mvert++) { BLI_kdtree_insert(MirrKdStore.tree, i, mvert->co); } diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index 0d6c7320a95..5cfb269cbc3 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -383,7 +383,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, /* create custom data layer to save polygon idx */ CustomData_add_layer_named(&em->bm->pdata, CD_RECAST, CD_CALLOC, NULL, 0, "createRepresentation recastData"); CustomData_bmesh_init_pool(&em->bm->pdata, 0, BM_FACE); - + /* create verts and faces for detailed mesh */ meshes = recast_polyMeshDetailGetMeshes(dmesh, &nmeshes); polys = recast_polyMeshGetPolys(pmesh, NULL, &nvp); @@ -445,7 +445,7 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - ED_object_editmode_exit(C, EM_FREEDATA); + ED_object_editmode_exit(C, EM_FREEDATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); if (createob) { @@ -616,14 +616,14 @@ static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op)) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMFace *ef; BMIter iter; - + if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) { int targetPolyIdx = findFreeNavPolyIndex(em); if (targetPolyIdx > 0) { /* set target poly idx to selected faces */ /*XXX this originally went last to first, but that isn't possible anymore*/ - + BM_ITER_MESH (ef, &iter, em->bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(ef, BM_ELEM_SELECT)) { int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 33498eb113a..3c8e18027f4 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -94,12 +94,12 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_loop_to_region); WM_operatortype_append(MESH_OT_region_to_loop); WM_operatortype_append(MESH_OT_select_axis); - + WM_operatortype_append(MESH_OT_uvs_rotate); WM_operatortype_append(MESH_OT_uvs_reverse); WM_operatortype_append(MESH_OT_colors_rotate); WM_operatortype_append(MESH_OT_colors_reverse); - + WM_operatortype_append(MESH_OT_fill); WM_operatortype_append(MESH_OT_fill_grid); WM_operatortype_append(MESH_OT_fill_holes); @@ -147,7 +147,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_rip_edge); WM_operatortype_append(MESH_OT_blend_from_shape); WM_operatortype_append(MESH_OT_shape_propagate_to_all); - + WM_operatortype_append(MESH_OT_uv_texture_add); WM_operatortype_append(MESH_OT_uv_texture_remove); WM_operatortype_append(MESH_OT_vertex_color_add); @@ -219,7 +219,7 @@ void ED_operatormacros_mesh(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it", OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); @@ -292,14 +292,14 @@ void ED_operatormacros_mesh(void) /* note mesh keymap also for other space? */ void ED_keymap_mesh(wmKeyConfig *keyconf) -{ +{ wmKeyMap *keymap; wmKeyMapItem *kmi; int i; - + keymap = WM_keymap_find(keyconf, "Mesh", 0, 0); keymap->poll = ED_operator_editmesh; - + WM_keymap_add_item(keymap, "MESH_OT_loopcut_slide", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_offset_edge_loops_slide", RKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_inset", IKEY, KM_PRESS, 0, 0); @@ -347,20 +347,20 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_select_prev_item", PADMINUS, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); - + WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); - + /* selection mode */ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0); - + /* hide */ kmi = WM_keymap_add_item(keymap, "MESH_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); @@ -373,14 +373,14 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "inside", false); kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "inside", true); - + WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */ WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_extrude", EKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "TRANSFORM_OT_edge_crease", EKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); @@ -414,9 +414,9 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_edge_face_add", FKEY, KM_PRESS, 0, 0); // WM_keymap_add_item(keymap, "MESH_OT_skin", FKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); /* python, removed */ WM_keymap_add_item(keymap, "MESH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_menu(keymap, "INFO_MT_mesh_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "MESH_OT_separate", PKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_split", YKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MESH_OT_vert_connect_path", JKEY, KM_PRESS, 0, 0); @@ -434,7 +434,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", XKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "MESH_OT_dissolve_mode", DELKEY, KM_PRESS, KM_CTRL, 0); - + kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", true); RNA_boolean_set(kmi->ptr, "only_selected", false); @@ -442,7 +442,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", false); RNA_boolean_set(kmi->ptr, "only_selected", true); - + WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); /* menus */ @@ -453,13 +453,13 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_hook", HKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0); - + /* useful stuff from object-mode */ for (i = 0; i <= 5; i++) { kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0); RNA_int_set(kmi->ptr, "level", i); } - + ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_editmode(keyconf, keymap, true); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index d3d29b61182..6953473a792 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -282,13 +282,13 @@ int join_mesh_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode"); return OPERATOR_CANCELLED; } - + /* ob is the object we are adding geometry to */ if (!ob || ob->type != OB_MESH) { BKE_report(op->reports, RPT_WARNING, "Active object is not a mesh"); return OPERATOR_CANCELLED; } - + /* count & check */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { @@ -300,23 +300,23 @@ int join_mesh_exec(bContext *C, wmOperator *op) totloop += me->totloop; totpoly += me->totpoly; totmat += base->object->totcol; - + if (base->object == ob) ok = true; - + /* check for shapekeys */ if (me->key) haskey++; } } CTX_DATA_END; - - /* that way the active object is always selected */ + + /* that way the active object is always selected */ if (ok == false) { BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh"); return OPERATOR_CANCELLED; } - + /* only join meshes if there are verts to join, there aren't too many, and we only had one mesh selected */ me = (Mesh *)ob->data; key = me->key; @@ -325,7 +325,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No mesh data to join"); return OPERATOR_CANCELLED; } - + if (totvert > MESH_MAX_VERTS) { BKE_reportf(op->reports, RPT_WARNING, "Joining results in %d vertices, limit is %ld", totvert, MESH_MAX_VERTS); return OPERATOR_CANCELLED; @@ -340,23 +340,23 @@ int join_mesh_exec(bContext *C, wmOperator *op) matmap = MEM_callocN(sizeof(*matmap) * totmat, "join_mesh matmap"); } totcol = ob->totcol; - + /* obact materials in new main array, is nicer start! */ for (a = 0; a < ob->totcol; a++) { matar[a] = give_current_material(ob, a + 1); id_us_plus((ID *)matar[a]); /* increase id->us : will be lowered later */ } - + /* - if destination mesh had shapekeys, move them somewhere safe, and set up placeholders * with arrays that are large enough to hold shapekey data for all meshes - * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're + * - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're * joining, set up a new keyblock and assign to the mesh */ if (key) { /* make a duplicate copy that will only be used here... (must remember to free it!) */ nkey = BKE_key_copy(bmain, key); - + /* for all keys in old block, clear data-arrays */ for (kb = key->block.first; kb; kb = kb->next) { if (kb->data) MEM_freeN(kb->data); @@ -369,14 +369,14 @@ int join_mesh_exec(bContext *C, wmOperator *op) key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; } - + /* first pass over objects - copying materials and vertexgroups across */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { /* only act if a mesh, and not the one we're joining to */ if ((ob != base->object) && (base->object->type == OB_MESH)) { me = base->object->data; - + /* Join this object's vertex groups to the base one's */ for (dg = base->object->defbase.first; dg; dg = dg->next) { /* See if this group exists in the object (if it doesn't, add it to the end) */ @@ -388,8 +388,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) } if (ob->defbase.first && ob->actdef == 0) ob->actdef = 1; - - + + if (me->totvert) { /* Add this object's materials to the base one's if they don't exist already (but only if limits not exceeded yet) */ if (totcol < MAXMAT) { @@ -413,7 +413,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) } } } - + /* if this mesh has shapekeys, check if destination mesh already has matching entries too */ if (me->key && key) { /* for remapping KeyBlock.relative */ @@ -475,7 +475,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) edgeofs = 0; loopofs = 0; polyofs = 0; - + /* inverse transform for all selected meshes in this object */ invert_m4_m4(imat, ob->obmat); @@ -516,10 +516,10 @@ int join_mesh_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* return to mesh we're merging to */ me = ob->data; - + CustomData_free(&me->vdata, me->totvert); CustomData_free(&me->edata, me->totedge); CustomData_free(&me->ldata, me->totloop); @@ -540,7 +540,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* update normals in case objects with non-uniform scale are joined */ BKE_mesh_calc_normals(me); - + /* old material array */ for (a = 1; a <= ob->totcol; a++) { ma = ob->mat[a - 1]; @@ -567,13 +567,13 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* other mesh users */ test_all_objects_materials(bmain, (ID *)me); - + /* free temp copy of destination shapekeys (if applicable) */ if (nkey) { /* We can assume nobody is using that ID currently. */ BKE_libblock_free_ex(bmain, nkey, false, false); } - + /* ensure newly inserted keys are time sorted */ if (key && (key->type != KEY_RELATIVE)) { BKE_key_sort(key); @@ -593,7 +593,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /*********************** JOIN AS SHAPES ***************************/ -/* Append selected meshes vertex locations as shapes of the active mesh, +/* Append selected meshes vertex locations as shapes of the active mesh, * return 0 if no join is made (error) and 1 of the join is done */ int join_mesh_shapes_exec(bContext *C, wmOperator *op) @@ -606,14 +606,14 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) Key *key = me->key; KeyBlock *kb; bool ok = false, nonequal_verts = false; - + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object == ob) continue; - + if (base->object->type == OB_MESH) { selme = (Mesh *)base->object->data; - + if (selme->totvert == me->totvert) ok = true; else @@ -621,7 +621,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + if (!ok) { if (nonequal_verts) BKE_report(op->reports, RPT_WARNING, "Selected meshes must have equal numbers of vertices"); @@ -629,7 +629,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No additional selected meshes with equal vertex count to join"); return OPERATOR_CANCELLED; } - + if (key == NULL) { key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; @@ -638,32 +638,32 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) kb = BKE_keyblock_add(key, NULL); BKE_keyblock_convert_from_mesh(me, kb); } - + /* now ready to add new keys from selected meshes */ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { if (base->object == ob) continue; - + if (base->object->type == OB_MESH) { selme = (Mesh *)base->object->data; - + if (selme->totvert == me->totvert) { dm = mesh_get_derived_deform(scene, base->object, CD_MASK_BAREMESH); - + if (!dm) continue; - + kb = BKE_keyblock_add(key, base->object->id.name + 2); - + DM_to_meshkey(dm, me, kb); - + dm->release(dm); } } } CTX_DATA_END; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); - + return OPERATOR_FINISHED; } @@ -707,12 +707,12 @@ static int mesh_get_x_mirror_vert_spatial(Object *ob, DerivedMesh *dm, int index Mesh *me = ob->data; MVert *mvert = dm ? dm->getVertArray(dm) : me->mvert; float vec[3]; - + mvert = &mvert[index]; vec[0] = -mvert->co[0]; vec[1] = mvert->co[1]; vec[2] = mvert->co[2]; - + return ED_mesh_mirror_spatial_table(ob, NULL, dm, vec, 'u'); } @@ -738,7 +738,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c { float vec[3]; int i; - + /* ignore nan verts */ if ((isfinite(co[0]) == false) || (isfinite(co[1]) == false) || @@ -746,11 +746,11 @@ static BMVert *editbmesh_get_x_mirror_vert_spatial(Object *ob, BMEditMesh *em, c { return NULL; } - + vec[0] = -co[0]; vec[1] = co[1]; vec[2] = co[2]; - + i = ED_mesh_mirror_spatial_table(ob, em, NULL, vec, 'u'); if (i != -1) { return BM_vert_at_index(em->bm, i); @@ -767,14 +767,14 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e if (index == -1) { BMIter iter; BMVert *v; - + index = 0; BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { if (v == eve) break; index++; } - + if (index == em->bm->totvert) { return NULL; } @@ -785,7 +785,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e if (poinval != -1) return (BMVert *)(poinval); return NULL; -} +} BMVert *editbmesh_get_x_mirror_vert(Object *ob, struct BMEditMesh *em, BMVert *eve, const float co[3], int index, const bool use_topology) { @@ -857,19 +857,19 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float { BMIter iter; BMFace *efa; - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { uv_poly_center(efa, cent, cd_loop_uv_offset); - + if ( (fabsf(cent[0] - cent_vec[0]) < 0.001f) && (fabsf(cent[1] - cent_vec[1]) < 0.001f) ) { BMIter liter; BMLoop *l; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); if ( (fabsf(luv->uv[0] - vec[0]) < 0.001f) && (fabsf(luv->uv[1] - vec[1]) < 0.001f) ) { return luv->uv; - + } } } @@ -918,7 +918,7 @@ static int mirror_facerotation(MFace *a, MFace *b) else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3) return 2; } - + return -1; } @@ -983,7 +983,7 @@ int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em, DerivedMesh *dm) BLI_ghash_free(fhash, NULL, NULL); MEM_freeN(mirrorverts); - + return mirrorfaces; } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index 27140bcdf3b..fa48462d2c7 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -19,7 +19,7 @@ * All rights reserved. * * The Original Code is: all of this file. - + * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** @@ -77,7 +77,7 @@ void ED_mball_editmball_make(Object *obedit) MetaElem *ml; /*, *newml;*/ ml = mb->elems.first; - + while (ml) { if (ml->flag & SELECT) mb->lastelem = ml; ml = ml->next; @@ -105,7 +105,7 @@ MetaElem *ED_mball_add_primitive(bContext *UNUSED(C), Object *obedit, float mat[ ml->flag &= ~SELECT; ml = ml->next; } - + ml = BKE_mball_element_add(mball, type); ml->rad *= dia; mball->wiresize *= dia; @@ -372,7 +372,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; const int seed = WM_operator_properties_select_random_seed_increment_get(op); - + RNG *rng = BLI_rng_new_srandom(seed); for (ml = mb->editelems->first; ml; ml = ml->next) { @@ -387,7 +387,7 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) BLI_rng_free(rng); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); - + return OPERATOR_FINISHED; } @@ -398,14 +398,14 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) ot->name = "Select Random"; ot->description = "Randomly select metaelements"; ot->idname = "MBALL_OT_select_random_metaelems"; - + /* callback functions */ ot->exec = select_random_metaelems_exec; ot->poll = ED_operator_editmball; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ WM_operator_properties_select_random(ot); } @@ -418,7 +418,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_edit_object(C); MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *newml; - + ml = mb->editelems->last; if (ml) { while (ml) { @@ -460,7 +460,7 @@ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) Object *obedit = CTX_data_edit_object(C); MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *next; - + ml = mb->editelems->first; if (ml) { while (ml) { @@ -532,7 +532,7 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "unselected", false, "Unselected", "Hide unselected rather than selected"); } @@ -558,7 +558,7 @@ static int reveal_metaelems_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } - + return OPERATOR_FINISHED; } @@ -568,11 +568,11 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) ot->name = "Reveal"; ot->description = "Reveal all hidden metaelements"; ot->idname = "MBALL_OT_reveal_metaelems"; - + /* callback functions */ ot->exec = reveal_metaelems_exec; ot->poll = ED_operator_editmball; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -607,7 +607,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese } if (ml == NULL) startelem = mb->editelems->first; - + if (hits > 0) { ml = startelem; while (ml) { @@ -627,7 +627,7 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese if (ml == NULL) ml = mb->editelems->first; if (ml == startelem) break; } - + /* When some metaelem was found, then it is necessary to select or * deselect it. */ if (ml_act) { @@ -650,9 +650,9 @@ bool ED_mball_select_pick(bContext *C, const int mval[2], bool extend, bool dese /* Select only metaelem clicked on */ ml_act->flag |= SELECT; } - + mb->lastelem = ml_act; - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); return true; diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 6bf49187483..2e1b7299295 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -45,10 +45,10 @@ void ED_operatortypes_metaball(void) { WM_operatortype_append(MBALL_OT_delete_metaelems); WM_operatortype_append(MBALL_OT_duplicate_metaelems); - + WM_operatortype_append(MBALL_OT_hide_metaelems); WM_operatortype_append(MBALL_OT_reveal_metaelems); - + WM_operatortype_append(MBALL_OT_select_all); WM_operatortype_append(MBALL_OT_select_similar); WM_operatortype_append(MBALL_OT_select_random_metaelems); @@ -71,22 +71,22 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + keymap = WM_keymap_find(keyconf, "Metaball", 0, 0); keymap->poll = ED_operator_editmball; WM_keymap_add_item(keymap, "OBJECT_OT_metaball_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "MBALL_OT_reveal_metaelems", HKEY, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); kmi = WM_keymap_add_item(keymap, "MBALL_OT_hide_metaelems", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "unselected", true); - + WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MBALL_OT_delete_metaelems", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MBALL_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - + kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 38f09570aca..cd163298642 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -971,13 +971,13 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) Group *group; unsigned int layer; float loc[3], rot[3]; - + if (RNA_struct_property_is_set(op->ptr, "name")) { char name[MAX_ID_NAME - 2]; - + RNA_string_get(op->ptr, "name", name); group = (Group *)BKE_libblock_find_name(bmain, ID_GR, name); - + if (0 == RNA_struct_property_is_set(op->ptr, "location")) { const wmEvent *event = CTX_wm_window(C)->eventstate; ARegion *ar = CTX_wm_region(C); @@ -1136,7 +1136,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) const bool use_global = RNA_boolean_get(op->ptr, "use_global"); bool changed = false; - if (CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return OPERATOR_CANCELLED; CTX_DATA_BEGIN (C, Base *, base, selected_bases) @@ -1217,10 +1217,10 @@ static int object_delete_exec(bContext *C, wmOperator *op) BKE_main_id_tag_listbase(&bmain->scene, LIB_TAG_DOIT, true); for (win = wm->windows.first; win; win = win->next) { scene = win->screen->scene; - + if (scene->id.tag & LIB_TAG_DOIT) { scene->id.tag &= ~LIB_TAG_DOIT; - + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); @@ -1989,7 +1989,7 @@ void OBJECT_OT_convert(wmOperatorType *ot) /**************************** Duplicate ************************/ -/* +/* * dupflag: a flag made from constants declared in DNA_userdef_types.h * The flag tells adduplicate() whether to copy data linked to the object, or to reference the existing data. * U.dupflag for default operations or you can construct a flag as python does @@ -2386,7 +2386,7 @@ static int add_named_exec(bContext *C, wmOperator *op) ED_object_location_from_view(C, basen->object->loc); ED_view3d_cursor3d_position(C, basen->object->loc, mval); } - + ED_base_object_select(basen, BA_SELECT); ED_base_object_activate(C, basen); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 66a87d956f3..ee0dfe14cd3 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -557,7 +557,7 @@ typedef struct BakeRender { short *stop; short *do_update; float *progress; - + ListBase threads; /* backup */ @@ -662,7 +662,7 @@ static void finish_bake_internal(BakeRender *bkr) } BKE_image_release_ibuf(ima, ibuf, NULL); - DAG_id_tag_update(&ima->id, 0); + DAG_id_tag_update(&ima->id, 0); } } diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index d24fc96b007..3e0f62154ac 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -272,7 +272,7 @@ static void refresh_images(BakeImages *bake_images) Image *ima = bake_images->data[i].image; if (ima->ok == IMA_OK_LOADED) { GPU_free_image(ima); - DAG_id_tag_update(&ima->id, 0); + DAG_id_tag_update(&ima->id, 0); } } } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 1ec47cde029..d0588806313 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -89,17 +89,17 @@ ListBase *get_active_constraints(Object *ob) { if (ob == NULL) return NULL; - + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; - + pchan = BKE_pose_channel_active(ob); if (pchan) return &pchan->constraints; } - else + else return &ob->constraints; - + return NULL; } @@ -108,33 +108,33 @@ ListBase *get_constraint_lb(Object *ob, bConstraint *con, bPoseChannel **r_pchan { if (r_pchan) *r_pchan = NULL; - + if (ELEM(NULL, ob, con)) return NULL; - + /* try object constraints first */ if ((BLI_findindex(&ob->constraints, con) != -1)) { return &ob->constraints; } - + /* if armature, try pose bones too */ if (ob->pose) { bPoseChannel *pchan; - - /* try each bone in order + + /* try each bone in order * NOTE: it's not possible to directly look up the active bone yet, so this will have to do */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((BLI_findindex(&pchan->constraints, con) != -1)) { - + if (r_pchan) *r_pchan = pchan; - + return &pchan->constraints; } } } - + /* done */ return NULL; } @@ -156,7 +156,7 @@ static void validate_pyconstraint_cb(void *arg1, void *arg2) Text *text = NULL; int index = *((int *)arg2); int i; - + /* exception for no script */ if (index) { /* innovative use of a for...loop to search */ @@ -173,36 +173,36 @@ static char *buildmenu_pyconstraints(Text *con_text, int *pyconindex) char *str; char buf[64]; int i; - + /* add title first */ sprintf(buf, "Scripts: %%t|[None]%%x0|"); BLI_dynstr_append(pupds, buf); - + /* init active-index first */ if (con_text == NULL) *pyconindex = 0; - + /* loop through markers, adding them */ for (text = G.main->text.first, i = 1; text; i++, text = text->id.next) { /* this is important to ensure that right script is shown as active */ if (text == con_text) *pyconindex = i; - + /* only include valid pyconstraint scripts */ if (BPY_is_pyconstraint(text)) { BLI_dynstr_append(pupds, text->id.name + 2); - + sprintf(buf, "%%x%d", i); BLI_dynstr_append(pupds, buf); - + if (text->id.next) BLI_dynstr_append(pupds, "|"); } } - + /* convert to normal MEM_malloc'd string */ str = BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); - + return str; } #endif /* WITH_PYTHON */ @@ -230,11 +230,11 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch ListBase targets = {NULL, NULL}; bConstraintTarget *ct; int num_targets, i; - + if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); num_targets = BLI_listbase_count(&targets); - + if (index < 0) { if (abs(index) < num_targets) index = num_targets - abs(index); @@ -244,7 +244,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch else if (index >= num_targets) { index = num_targets - 1; } - + for (ct = targets.first, i = 0; ct; ct = ct->next, i++) { if (i == index) { ct->tar = target; @@ -252,7 +252,7 @@ static void set_constraint_nth_target(bConstraint *con, Object *target, const ch break; } } - + if (cti->flush_constraint_targets) cti->flush_constraint_targets(con, &targets, 0); } @@ -506,7 +506,7 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan) bConstraint *curcon; ListBase *conlist = NULL; int type; - + if (owner == NULL) return; type = constraint_type_get(owner, pchan); @@ -520,7 +520,7 @@ static void test_constraints(Main *bmain, Object *owner, bPoseChannel *pchan) conlist = &pchan->constraints; break; } - + /* Check all constraints - is constraint valid? */ if (conlist) { for (curcon = conlist->first; curcon; curcon = curcon->next) { @@ -533,10 +533,10 @@ void object_test_constraints(Main *bmain, Object *owner) { if (owner->constraints.first) test_constraints(bmain, owner, NULL); - + if (owner->type == OB_ARMATURE && owner->pose) { bPoseChannel *pchan; - + for (pchan = owner->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->constraints.first) test_constraints(bmain, owner, pchan); @@ -616,24 +616,24 @@ static int edit_constraint_invoke_properties(bContext *C, wmOperator *op) Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); bConstraint *con; ListBase *list; - + if (RNA_struct_property_is_set(op->ptr, "constraint") && RNA_struct_property_is_set(op->ptr, "owner")) return 1; - + if (ptr.data) { con = ptr.data; RNA_string_set(op->ptr, "constraint", con->name); - + list = get_constraint_lb(ob, con, NULL); - + if (&ob->constraints == list) RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_OBJECT); else RNA_enum_set(op->ptr, "owner", EDIT_CONSTRAINT_OWNER_BONE); - + return 1; } - + return 0; } @@ -643,9 +643,9 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int int owner = RNA_enum_get(op->ptr, "owner"); bConstraint *con; ListBase *list = NULL; - + RNA_string_get(op->ptr, "constraint", constraint_name); - + if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { list = &ob->constraints; } @@ -664,14 +664,14 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int //printf("edit_constraint_property_get: defaulting to getting list in the standard way\n"); list = get_active_constraints(ob); } - + con = BKE_constraints_find_name(list, constraint_name); //if (G.debug & G_DEBUG) //printf("constraint found = %p, %s\n", (void *)con, (con) ? con->name : ""); if (con && (type != 0) && (con->type != type)) con = NULL; - + return con; } @@ -686,15 +686,15 @@ static int stretchto_reset_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_STRETCHTO); bStretchToConstraint *data = (con) ? (bStretchToConstraint *)con->data : NULL; - + /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) return OPERATOR_CANCELLED; - + /* just set original length to 0.0, which will cause a reset on next recalc */ data->orglength = 0.0f; ED_object_constraint_update(bmain, ob); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -713,15 +713,15 @@ void CONSTRAINT_OT_stretchto_reset(wmOperatorType *ot) ot->name = "Reset Original Length"; ot->idname = "CONSTRAINT_OT_stretchto_reset"; ot->description = "Reset original length of bone for Stretch To Constraint"; - + /* callbacks */ ot->invoke = stretchto_reset_invoke; ot->exec = stretchto_reset_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -733,15 +733,15 @@ static int limitdistance_reset_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_DISTLIMIT); bDistLimitConstraint *data = (con) ? (bDistLimitConstraint *)con->data : NULL; - + /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) return OPERATOR_CANCELLED; - + /* just set original length to 0.0, which will cause a reset on next recalc */ data->dist = 0.0f; ED_object_constraint_update(bmain, ob); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); return OPERATOR_FINISHED; } @@ -760,15 +760,15 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot) ot->name = "Reset Distance"; ot->idname = "CONSTRAINT_OT_limitdistance_reset"; ot->description = "Reset limiting distance for Limit Distance Constraint"; - + /* callbacks */ ot->invoke = limitdistance_reset_invoke; ot->exec = limitdistance_reset_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -779,7 +779,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, { /* nullify inverse matrix first */ unit_m4(invmat); - + if (owner == EDIT_CONSTRAINT_OWNER_BONE) { bPoseChannel *pchan; /* try to find a pose channel - assume that this is the constraint owner */ @@ -874,11 +874,11 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; } - + child_get_inverse_matrix(scene, ob, con, data->invmat, owner); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } @@ -896,15 +896,15 @@ void CONSTRAINT_OT_childof_set_inverse(wmOperatorType *ot) ot->name = "Set Inverse"; ot->idname = "CONSTRAINT_OT_childof_set_inverse"; ot->description = "Set inverse correction for ChildOf constraint"; - + /* callbacks */ ot->invoke = childof_set_inverse_invoke; ot->exec = childof_set_inverse_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -915,17 +915,17 @@ static int childof_clear_inverse_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); bChildOfConstraint *data = (con) ? (bChildOfConstraint *)con->data : NULL; - + if (data == NULL) { BKE_report(op->reports, RPT_ERROR, "Child Of constraint not found"); return OPERATOR_CANCELLED; } - + /* simply clear the matrix */ unit_m4(data->invmat); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } @@ -943,15 +943,15 @@ void CONSTRAINT_OT_childof_clear_inverse(wmOperatorType *ot) ot->name = "Clear Inverse"; ot->idname = "CONSTRAINT_OT_childof_clear_inverse"; ot->description = "Clear inverse correction for ChildOf constraint"; - + /* callbacks */ ot->invoke = childof_clear_inverse_invoke; ot->exec = childof_clear_inverse_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -963,30 +963,30 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_FOLLOWPATH); bFollowPathConstraint *data = (con) ? (bFollowPathConstraint *)con->data : NULL; - + bAction *act = NULL; FCurve *fcu = NULL; int sfra = RNA_int_get(op->ptr, "frame_start"); int len = RNA_int_get(op->ptr, "length"); float standardRange = 1.0; - + /* nearly impossible sanity check */ if (data == NULL) { BKE_report(op->reports, RPT_ERROR, "Follow Path constraint not found"); return OPERATOR_CANCELLED; } - + /* add F-Curve as appropriate */ if (data->tar) { Curve *cu = (Curve *)data->tar->data; - + if (ELEM(NULL, cu->adt, cu->adt->action) || (list_find_fcurve(&cu->adt->action->curves, "eval_time", 0) == NULL)) { /* create F-Curve for path animation */ act = verify_adt_action(&cu->id, 1); fcu = verify_fcurve(act, NULL, NULL, "eval_time", 0, 1); - + /* standard vertical range - 1:1 = 100 frames */ standardRange = 100.0f; } @@ -1001,46 +1001,46 @@ static int followpath_path_animate_exec(bContext *C, wmOperator *op) PointerRNA ptr; PropertyRNA *prop; char *path; - + /* get RNA pointer to constraint's "offset_factor" property - to build RNA path */ RNA_pointer_create(&ob->id, &RNA_FollowPathConstraint, con, &ptr); prop = RNA_struct_find_property(&ptr, "offset_factor"); - + path = RNA_path_from_ID_to_property(&ptr, prop); - + /* create F-Curve for constraint */ act = verify_adt_action(&ob->id, 1); fcu = verify_fcurve(act, NULL, NULL, path, 0, 1); - + /* standard vertical range - 0.0 to 1.0 */ standardRange = 1.0f; - + /* enable "Use Fixed Position" so that animating this has effect */ data->followflag |= FOLLOWPATH_STATIC; - + /* path needs to be freed */ - if (path) + if (path) MEM_freeN(path); } - + /* setup dummy 'generator' modifier here to get 1-1 correspondence still working * and define basic slope of this curve based on the properties */ if (!fcu->bezt && !fcu->fpt && !fcu->modifiers.first) { FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR, fcu); FMod_Generator *gen = fcm->data; - + /* Assume that we have the following equation: * y = Ax + B * 1 0 <-- coefficients array indices */ float A = standardRange / (float)(len); float B = (float)(-sfra) * A; - + gen->coefficients[1] = A; gen->coefficients[0] = B; } - + /* updates... */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); return OPERATOR_FINISHED; @@ -1063,20 +1063,20 @@ void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot) ot->name = "Auto Animate Path"; ot->idname = "CONSTRAINT_OT_followpath_path_animate"; ot->description = "Add default animation for path used by constraint if it isn't animated already"; - + /* callbacks */ ot->invoke = followpath_path_animate_invoke; ot->exec = followpath_path_animate_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ edit_constraint_properties(ot); - RNA_def_int(ot->srna, "frame_start", 1, MINAFRAME, MAXFRAME, "Start Frame", + RNA_def_int(ot->srna, "frame_start", 1, MINAFRAME, MAXFRAME, "Start Frame", "First frame of path animation", MINAFRAME, MAXFRAME); - RNA_def_int(ot->srna, "length", 100, 0, MAXFRAME, "Length", + RNA_def_int(ot->srna, "length", 100, 0, MAXFRAME, "Length", "Number of frames that path animation should take", 0, MAXFRAME); } @@ -1118,7 +1118,7 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot) ot->name = "Set Inverse"; ot->idname = "CONSTRAINT_OT_objectsolver_set_inverse"; ot->description = "Set inverse correction for ObjectSolver constraint"; - + /* callbacks */ ot->invoke = objectsolver_set_inverse_invoke; ot->exec = objectsolver_set_inverse_exec; @@ -1126,7 +1126,7 @@ void CONSTRAINT_OT_objectsolver_set_inverse(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -1164,7 +1164,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) ot->name = "Clear Inverse"; ot->idname = "CONSTRAINT_OT_objectsolver_clear_inverse"; ot->description = "Clear inverse correction for ObjectSolver constraint"; - + /* callbacks */ ot->invoke = objectsolver_clear_inverse_invoke; ot->exec = objectsolver_clear_inverse_exec; @@ -1172,7 +1172,7 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -1180,14 +1180,14 @@ void CONSTRAINT_OT_objectsolver_clear_inverse(wmOperatorType *ot) /***************************** BUTTONS ****************************/ void ED_object_constraint_set_active(Object *ob, bConstraint *con) -{ +{ ListBase *lb = get_constraint_lb(ob, con, NULL); - + /* lets be nice and escape if its active already */ /* NOTE: this assumes that the stack doesn't have other active ones set... */ if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE)) return; - + BKE_constraints_active_set(lb, con); } @@ -1197,9 +1197,9 @@ void ED_object_constraint_update(Main *bmain, Object *ob) object_test_constraints(bmain, ob); - if (ob->type == OB_ARMATURE) + if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); - else + else DAG_id_tag_update(&ob->id, OB_RECALC_OB); } @@ -1276,7 +1276,7 @@ static int constraint_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* notifiers */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); - + return OPERATOR_FINISHED; } else { @@ -1291,11 +1291,11 @@ void CONSTRAINT_OT_delete(wmOperatorType *ot) ot->name = "Delete Constraint"; ot->idname = "CONSTRAINT_OT_delete"; ot->description = "Remove constraint from constraint stack"; - + /* callbacks */ ot->exec = constraint_delete_exec; ot->poll = constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1305,20 +1305,20 @@ static int constraint_move_down_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, 0); - + if (con && con->next) { ListBase *conlist = get_constraint_lb(ob, con, NULL); bConstraint *nextCon = con->next; - + /* insert the nominated constraint after the one that used to be after it */ BLI_remlink(conlist, con); BLI_insertlinkafter(conlist, nextCon, con); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -1336,15 +1336,15 @@ void CONSTRAINT_OT_move_down(wmOperatorType *ot) ot->name = "Move Constraint Down"; ot->idname = "CONSTRAINT_OT_move_down"; ot->description = "Move constraint down in constraint stack"; - + /* callbacks */ ot->invoke = constraint_move_down_invoke; ot->exec = constraint_move_down_exec; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ edit_constraint_properties(ot); } @@ -1354,20 +1354,20 @@ static int constraint_move_up_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, 0); - + if (con && con->prev) { ListBase *conlist = get_constraint_lb(ob, con, NULL); bConstraint *prevCon = con->prev; - + /* insert the nominated constraint before the one that used to be before it */ BLI_remlink(conlist, con); BLI_insertlinkbefore(conlist, prevCon, con); - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); - + return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -1385,12 +1385,12 @@ void CONSTRAINT_OT_move_up(wmOperatorType *ot) ot->name = "Move Constraint Up"; ot->idname = "CONSTRAINT_OT_move_up"; ot->description = "Move constraint up in constraint stack"; - + /* callbacks */ ot->exec = constraint_move_up_exec; ot->invoke = constraint_move_up_invoke; ot->poll = edit_constraint_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; edit_constraint_properties(ot); @@ -1404,7 +1404,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + /* free constraints for all selected bones */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { @@ -1412,16 +1412,16 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_SPLINEIK | PCHAN_HAS_CONST); } CTX_DATA_END; - + /* force depsgraph to get recalculated since relationships removed */ DAG_relations_tag_update(bmain); - + /* note, calling BIK_clear_data() isn't needed here */ /* do updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); - + return OPERATOR_FINISHED; } @@ -1431,7 +1431,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) ot->name = "Clear Pose Constraints"; ot->idname = "POSE_OT_constraints_clear"; ot->description = "Clear all the constraints for the selected bones"; - + /* callbacks */ ot->exec = pose_constraints_clear_exec; ot->poll = ED_operator_posemode_exclusive; // XXX - do we want to ensure there are selected bones too? @@ -1441,7 +1441,7 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - + /* do freeing */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -1449,13 +1449,13 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; - + /* force depsgraph to get recalculated since relationships removed */ DAG_relations_tag_update(bmain); - + /* do updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, NULL); - + return OPERATOR_FINISHED; } @@ -1465,7 +1465,7 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) ot->name = "Clear Object Constraints"; ot->idname = "OBJECT_OT_constraints_clear"; ot->description = "Clear all the constraints for the active Object only"; - + /* callbacks */ ot->exec = object_constraints_clear_exec; ot->poll = ED_operator_object_active_editable; @@ -1479,19 +1479,19 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) bPoseChannel *pchan = CTX_data_active_pose_bone(C); ListBase lb; CollectionPointerLink *link; - + /* don't do anything if bone doesn't exist or doesn't have any constraints */ if (ELEM(NULL, pchan, pchan->constraints.first)) { BKE_report(op->reports, RPT_ERROR, "No active bone with constraints for copying"); return OPERATOR_CANCELLED; } - + /* copy all constraints from active posebone to all selected posebones */ CTX_data_selected_pose_bones(C, &lb); for (link = lb.first; link; link = link->next) { Object *ob = link->ptr.id.data; bPoseChannel *chan = link->ptr.data; - + /* if we're not handling the object we're copying from, copy all constraints over */ if (pchan != chan) { BKE_constraints_copy(&chan->constraints, &pchan->constraints, true); @@ -1503,12 +1503,12 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) } } BLI_freelistN(&lb); - + /* force depsgraph to get recalculated since new relationships added */ DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); - + return OPERATOR_FINISHED; } @@ -1518,7 +1518,7 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) ot->name = "Copy Constraints to Selected Bones"; ot->idname = "POSE_OT_constraints_copy"; ot->description = "Copy constraints to other selected bones"; - + /* api callbacks */ ot->exec = pose_constraint_copy_exec; ot->poll = ED_operator_posemode_exclusive; @@ -1531,7 +1531,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Object *obact = ED_object_active_context(C); - + /* copy all constraints from active object to all selected objects */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -1542,13 +1542,13 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + /* force depsgraph to get recalculated since new relationships added */ DAG_relations_tag_update(bmain); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } @@ -1558,7 +1558,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot) ot->name = "Copy Constraints to Selected Objects"; ot->idname = "OBJECT_OT_constraints_copy"; ot->description = "Copy constraints to other selected objects"; - + /* api callbacks */ ot->exec = object_constraint_copy_exec; ot->poll = ED_operator_object_active_editable; @@ -1576,15 +1576,15 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob bPoseChannel *pchanact = BKE_pose_channel_active(obact); bool only_curve = false, only_mesh = false, only_ob = false; bool found = false; - - /* clear tar_ob and tar_pchan fields before use + + /* clear tar_ob and tar_pchan fields before use * - assume for now that both always exist... */ *tar_ob = NULL; *tar_pchan = NULL; - + /* check if constraint type doesn't requires a target - * - if so, no need to get any targets + * - if so, no need to get any targets */ switch (con_type) { /* no-target constraints --------------------------- */ @@ -1596,7 +1596,7 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob case CONSTRAINT_TYPE_SIZELIMIT: case CONSTRAINT_TYPE_SAMEVOL: return false; - + /* restricted target-type constraints -------------- */ /* NOTE: for these, we cannot try to add a target object if no valid ones are found, since that doesn't work */ /* curve-based constraints - set the only_curve and only_ob flags */ @@ -1607,20 +1607,20 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob only_ob = true; add = false; break; - + /* mesh only? */ case CONSTRAINT_TYPE_SHRINKWRAP: only_mesh = true; only_ob = true; add = false; break; - + /* object only - add here is ok? */ case CONSTRAINT_TYPE_RIGIDBODYJOINT: only_ob = true; break; } - + /* if the active Object is Armature, and we can search for bones, do so... */ if ((obact->type == OB_ARMATURE) && (only_ob == false)) { /* search in list of selected Pose-Channels for target */ @@ -1631,33 +1631,33 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob *tar_ob = obact; *tar_pchan = pchan; found = true; - + break; } } CTX_DATA_END; } - + /* if not yet found, try selected Objects... */ if (found == false) { /* search in selected objects context */ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { - /* just use the first object we encounter (that isn't the active object) - * and which fulfills the criteria for the object-target that we've got + /* just use the first object we encounter (that isn't the active object) + * and which fulfills the criteria for the object-target that we've got */ if (ob != obact) { /* for armatures in pose mode, look inside the armature for the active bone * so that we set up cross-armature constraints with less effort */ - if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) && + if ((ob->type == OB_ARMATURE) && (ob->mode & OB_MODE_POSE) && (!only_curve && !only_mesh)) { /* just use the active bone, and assume that it is visible + usable */ *tar_ob = ob; *tar_pchan = BKE_pose_channel_active(ob); found = true; - + break; } else if (((!only_curve) || (ob->type == OB_CURVE)) && @@ -1666,39 +1666,39 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob /* set target */ *tar_ob = ob; found = true; - + /* perform some special operations on the target */ if (only_curve) { /* Curve-Path option must be enabled for follow-path constraints to be able to work */ Curve *cu = (Curve *)ob->data; cu->flag |= CU_PATH; } - + break; } } } CTX_DATA_END; } - + /* if still not found, add a new empty to act as a target (if allowed) */ if ((found == false) && (add)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Base *base = BASACT, *newbase = NULL; Object *obt; - + /* add new target object */ obt = BKE_object_add(bmain, scene, OB_EMPTY, NULL); - + /* set layers OK */ newbase = BASACT; newbase->lay = base->lay; obt->lay = newbase->lay; - + /* transform cent to global coords for loc */ if (pchanact) { - /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel + /* since by default, IK targets the tip of the last bone, use the tip of the active PoseChannel * if adding a target for an IK Constraint */ if (con_type == CONSTRAINT_TYPE_KINEMATIC) @@ -1713,12 +1713,12 @@ static bool get_new_constraint_target(bContext *C, int con_type, Object **tar_ob /* restore, BKE_object_add sets active */ BASACT = base; base->flag |= SELECT; - + /* make our new target the new object */ *tar_ob = obt; found = true; } - + /* return whether there's any target */ return found; } @@ -1729,13 +1729,13 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase Main *bmain = CTX_data_main(C); bPoseChannel *pchan; bConstraint *con; - + if (list == &ob->constraints) { pchan = NULL; } else { pchan = BKE_pose_channel_active(ob); - + /* ensure not to confuse object/pose adding */ if (pchan == NULL) { BKE_report(op->reports, RPT_ERROR, "No active pose bone to add a constraint to"); @@ -1758,23 +1758,23 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase BKE_report(op->reports, RPT_ERROR, "Spline IK constraint can only be added to bones"); return OPERATOR_CANCELLED; } - + /* create a new constraint of the type requried, and add it to the active/given constraints list */ if (pchan) con = BKE_constraint_add_for_pose(ob, pchan, NULL, type); else con = BKE_constraint_add_for_object(ob, NULL, type); - + /* get the first selected object/bone, and make that the target * - apart from the buttons-window add buttons, we shouldn't add in this way */ if (setTarget) { Object *tar_ob = NULL; bPoseChannel *tar_pchan = NULL; - + /* get the target objects, adding them as need be */ if (get_new_constraint_target(C, type, &tar_ob, &tar_pchan, 1)) { - /* method of setting target depends on the type of target we've got + /* method of setting target depends on the type of target we've got * - by default, just set the first target (distinction here is only for multiple-targeted constraints) */ if (tar_pchan) @@ -1783,7 +1783,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase set_constraint_nth_target(con, tar_ob, "", 0); } } - + /* do type-specific tweaking to the constraint settings */ switch (type) { case CONSTRAINT_TYPE_PYTHON: /* FIXME: this code is not really valid anymore */ @@ -1800,7 +1800,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase if (scriptint) { /* add constraint */ validate_pyconstraint_cb(con->data, &scriptint); - + /* make sure target allowance is set correctly */ BPY_pyconstraint_update(ob, con); } @@ -1811,7 +1811,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase default: break; } - + /* make sure all settings are valid - similar to above checks, but sometimes can be wrong */ object_test_constraints(bmain, ob); @@ -1821,7 +1821,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* force depsgraph to get recalculated since new relationships added */ DAG_relations_tag_update(bmain); - + if ((ob->type == OB_ARMATURE) && (pchan)) { BKE_pose_tag_recalc(bmain, ob->pose); /* sort pose channels */ if (BKE_constraints_proxylocked_owner(ob, pchan) && ob->adt) { @@ -1834,10 +1834,10 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase } else DAG_id_tag_update(&ob->id, OB_RECALC_OB); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, ob); - + return OPERATOR_FINISHED; } @@ -1849,12 +1849,12 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); short with_targets = 0; - + if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to"); return OPERATOR_CANCELLED; } - + /* hack: set constraint targets from selected objects in context is allowed when * operator name included 'with_targets', since the menu doesn't allow multiple properties */ @@ -1870,18 +1870,18 @@ static int pose_constraint_add_exec(bContext *C, wmOperator *op) Object *ob = BKE_object_pose_armature_get(ED_object_active_context(C)); int type = RNA_enum_get(op->ptr, "type"); short with_targets = 0; - + if (!ob) { BKE_report(op->reports, RPT_ERROR, "No active object to add constraint to"); return OPERATOR_CANCELLED; } - + /* hack: set constraint targets from selected objects in context is allowed when * operator name included 'with_targets', since the menu doesn't allow multiple properties */ if (strstr(op->idname, "with_targets")) with_targets = 1; - + return constraint_add_exec(C, op, ob, get_active_constraints(ob), type, with_targets); } @@ -1893,15 +1893,15 @@ void OBJECT_OT_constraint_add(wmOperatorType *ot) ot->name = "Add Constraint"; ot->description = "Add a constraint to the active object"; ot->idname = "OBJECT_OT_constraint_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_constraint_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1912,15 +1912,15 @@ void OBJECT_OT_constraint_add_with_targets(wmOperatorType *ot) ot->name = "Add Constraint (with Targets)"; ot->description = "Add a constraint to the active object, with target (where applicable) set to the selected Objects/Bones"; ot->idname = "OBJECT_OT_constraint_add_with_targets"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_constraint_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1931,15 +1931,15 @@ void POSE_OT_constraint_add(wmOperatorType *ot) ot->name = "Add Constraint"; ot->description = "Add a constraint to the active bone"; ot->idname = "POSE_OT_constraint_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = pose_constraint_add_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1950,15 +1950,15 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) ot->name = "Add Constraint (with Targets)"; ot->description = "Add a constraint to the active bone, with target (where applicable) set to the selected Objects/Bones"; ot->idname = "POSE_OT_constraint_add_with_targets"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = pose_constraint_add_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_constraint_type_items, 0, "Type", ""); } @@ -1973,18 +1973,18 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraint *con = NULL; - + uiPopupMenu *pup; uiLayout *layout; Object *tar_ob = NULL; bPoseChannel *tar_pchan = NULL; - + /* must have active bone */ if (ELEM(NULL, ob, pchan)) { BKE_report(op->reports, RPT_ERROR, "Must have an active bone to add IK constraint to"); return OPERATOR_CANCELLED; } - + /* bone must not have any constraints already */ for (con = pchan->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_KINEMATIC) break; @@ -1993,14 +1993,14 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint"); return OPERATOR_CANCELLED; } - + /* prepare popup menu to choose targetting options */ pup = UI_popup_menu_begin(C, IFACE_("Add IK"), ICON_NONE); layout = UI_popup_menu_layout(pup); - + /* the type of targets we'll set determines the menu entries to show... */ if (get_new_constraint_target(C, CONSTRAINT_TYPE_KINEMATIC, &tar_ob, &tar_pchan, 0)) { - /* bone target, or object target? + /* bone target, or object target? * - the only thing that matters is that we want a target... */ if (tar_pchan) @@ -2013,10 +2013,10 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED uiItemBooleanO(layout, IFACE_("To New Empty Object"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 1); uiItemBooleanO(layout, IFACE_("Without Targets"), ICON_NONE, "POSE_OT_ik_add", "with_targets", 0); } - + /* finish building the menu, and process it (should result in calling self again) */ UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -2025,7 +2025,7 @@ static int pose_ik_add_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); const bool with_targets = RNA_boolean_get(op->ptr, "with_targets"); - + /* add the constraint - all necessary checks should have been done by the invoke() callback already... */ return constraint_add_exec(C, op, ob, get_active_constraints(ob), CONSTRAINT_TYPE_KINEMATIC, with_targets); } @@ -2036,15 +2036,15 @@ void POSE_OT_ik_add(wmOperatorType *ot) ot->name = "Add IK to Bone"; ot->description = "Add IK Constraint to the active Bone"; ot->idname = "POSE_OT_ik_add"; - + /* api callbacks */ ot->invoke = pose_ik_add_invoke; ot->exec = pose_ik_add_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "with_targets", 1, "With Targets", "Assign IK Constraint with targets derived from the select bones/objects"); } @@ -2055,12 +2055,12 @@ void POSE_OT_ik_add(wmOperatorType *ot) static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); - + /* only remove IK Constraints */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { bConstraint *con, *next; - + /* TODO: should we be checking if these contraints were local before we try and remove them? */ for (con = pchan->constraints.first; con; con = next) { next = con->next; @@ -2071,13 +2071,13 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) pchan->constflag &= ~(PCHAN_HAS_IK | PCHAN_HAS_TARGET); } CTX_DATA_END; - + /* refresh depsgraph */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_REMOVED, ob); - + return OPERATOR_FINISHED; } @@ -2087,11 +2087,11 @@ void POSE_OT_ik_clear(wmOperatorType *ot) ot->name = "Remove IK"; ot->description = "Remove all IK Constraints from selected bones"; ot->idname = "POSE_OT_ik_clear"; - + /* api callbacks */ ot->exec = pose_ik_clear_exec; ot->poll = ED_operator_posemode_exclusive; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 34c0b22a34e..2737ae5d92d 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -145,7 +145,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) Base *base; bool changed = false; const bool select = RNA_boolean_get(op->ptr, "select"); - + /* XXX need a context loop to handle such cases */ for (base = FIRSTBASE; base; base = base->next) { if ((base->lay & v3d->lay) && base->object->restrictflag & OB_RESTRICT_VIEW) { @@ -153,7 +153,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) SET_FLAG_FROM_TEST(base->flag, select, SELECT); } base->object->flag = base->flag; - base->object->restrictflag &= ~OB_RESTRICT_VIEW; + base->object->restrictflag &= ~OB_RESTRICT_VIEW; changed = true; } } @@ -168,16 +168,16 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op) void OBJECT_OT_hide_view_clear(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Clear Restrict View"; ot->description = "Reveal the object by setting the hide flag"; ot->idname = "OBJECT_OT_hide_view_clear"; - + /* api callbacks */ ot->exec = object_hide_view_clear_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -190,7 +190,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); bool changed = false; const bool unselected = RNA_boolean_get(op->ptr, "unselected"); - + CTX_DATA_BEGIN(C, Base *, base, visible_bases) { if (!unselected) { @@ -219,9 +219,9 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) if (changed) { DAG_id_type_tag(bmain, ID_OB); DAG_relations_tag_update(bmain); - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - + } return OPERATOR_FINISHED; @@ -233,16 +233,16 @@ void OBJECT_OT_hide_view_set(wmOperatorType *ot) ot->name = "Set Restrict View"; ot->description = "Hide the object by setting the hide flag"; ot->idname = "OBJECT_OT_hide_view_set"; - + /* api callbacks */ ot->exec = object_hide_view_set_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected objects"); - + } /* 99% same as above except no need for scene refreshing (TODO, update render preview) */ @@ -669,16 +669,16 @@ static int editmode_toggle_poll(bContext *C) void OBJECT_OT_editmode_toggle(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Toggle Editmode"; ot->description = "Toggle object's editmode"; ot->idname = "OBJECT_OT_editmode_toggle"; - + /* api callbacks */ ot->exec = editmode_toggle_exec; ot->poll = editmode_toggle_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -691,7 +691,7 @@ static int posemode_exec(bContext *C, wmOperator *op) Object *ob = base->object; const int mode_flag = OB_MODE_POSE; bool is_mode_set = (ob->mode & mode_flag) != 0; - + if (!is_mode_set) { if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) { return OPERATOR_CANCELLED; @@ -710,49 +710,49 @@ static int posemode_exec(bContext *C, wmOperator *op) else { ED_object_posemode_enter(C, ob); } - + return OPERATOR_FINISHED; } - + return OPERATOR_PASS_THROUGH; } -void OBJECT_OT_posemode_toggle(wmOperatorType *ot) +void OBJECT_OT_posemode_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Pose Mode"; ot->idname = "OBJECT_OT_posemode_toggle"; ot->description = "Enable or disable posing/selecting bones"; - + /* api callbacks */ ot->exec = posemode_exec; ot->poll = ED_operator_object_active_editable; - + /* flag */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) -{ +{ //XXX no longer used - to be removed - replaced by game_properties_copy_exec bProperty *prop; Base *base; int nr, tot = 0; char *str; - + prop = ob->prop.first; while (prop) { tot++; prop = prop->next; } - + str = MEM_callocN(50 + 33 * tot, "copymenu prop"); - + if (tot) strcpy(str, "Copy Property %t|Replace All|Merge All|%l"); else strcpy(str, "Copy Property %t|Clear All (no properties on active)"); - + tot = 0; prop = ob->prop.first; while (prop) { @@ -763,7 +763,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) } nr = pupmenu(str); - + if (nr == 1 || nr == 2) { for (base = FIRSTBASE; base; base = base->next) { if ((base != BASACT) && (TESTBASELIB(v3d, base))) { @@ -780,7 +780,7 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) } else if (nr > 0) { prop = BLI_findlink(&ob->prop, nr - 4); /* account for first 3 menu items & menu index starting at 1*/ - + if (prop) { for (base = FIRSTBASE; base; base = base->next) { if ((base != BASACT) && (TESTBASELIB(v3d, base))) { @@ -790,36 +790,36 @@ static void copymenu_properties(Scene *scene, View3D *v3d, Object *ob) } } MEM_freeN(str); - + } static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) { //XXX no longer used - to be removed - replaced by logicbricks_copy_exec Base *base; - + for (base = FIRSTBASE; base; base = base->next) { if (base->object != ob) { if (TESTBASELIB(v3d, base)) { - + /* first: free all logic */ free_sensors(&base->object->sensors); unlink_controllers(&base->object->controllers); free_controllers(&base->object->controllers); unlink_actuators(&base->object->actuators); free_actuators(&base->object->actuators); - + /* now copy it, this also works without logicbricks! */ clear_sca_new_poins_ob(ob); copy_sensors(&base->object->sensors, &ob->sensors, 0); copy_controllers(&base->object->controllers, &ob->controllers, 0); copy_actuators(&base->object->actuators, &ob->actuators, 0); set_sca_new_poins_ob(base->object); - + /* some menu settings */ base->object->scavisflag = ob->scavisflag; base->object->scaflag = ob->scaflag; - + /* set the initial state */ base->object->state = ob->state; base->object->init_state = ob->init_state; @@ -833,7 +833,7 @@ static void copy_texture_space(Object *to, Object *ob) { float *poin1 = NULL, *poin2 = NULL; short texflag = 0; - + if (ob->type == OB_MESH) { texflag = ((Mesh *)ob->data)->texflag; poin2 = ((Mesh *)ob->data)->loc; @@ -848,7 +848,7 @@ static void copy_texture_space(Object *to, Object *ob) } else return; - + if (to->type == OB_MESH) { ((Mesh *)to->data)->texflag = texflag; poin1 = ((Mesh *)to->data)->loc; @@ -863,9 +863,9 @@ static void copy_texture_space(Object *to, Object *ob) } else return; - + memcpy(poin1, poin2, 9 * sizeof(float)); /* this was noted in DNA_mesh, curve, mball */ - + if (to->type == OB_MESH) { /* pass */ } @@ -875,7 +875,7 @@ static void copy_texture_space(Object *to, Object *ob) else { BKE_curve_texspace_calc(to->data); } - + } /* UNUSED, keep in case we want to copy functionality for use elsewhere */ @@ -886,11 +886,11 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) Curve *cu, *cu1; Nurb *nu; bool do_depgraph_update = false; - + if (ID_IS_LINKED(scene)) return; if (!(ob = OBACT)) return; - + if (scene->obedit) { // XXX get from context /* obedit_copymenu(); */ return; @@ -913,7 +913,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) if (base != BASACT) { if (TESTBASELIB(v3d, base)) { DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); - + if (event == 1) { /* loc */ copy_v3_v3(base->object->loc, ob->loc); copy_v3_v3(base->object->dloc, ob->dloc); @@ -943,7 +943,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) base->object->dupoff = ob->dupoff; base->object->dupsta = ob->dupsta; base->object->dupend = ob->dupend; - + base->object->transflag &= ~OB_DUPLI; base->object->transflag |= (ob->transflag & OB_DUPLI); @@ -979,7 +979,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) copy_texture_space(base->object, ob); } else if (event == 18) { /* font settings */ - + if (base->object->type == ob->type) { cu = ob->data; cu1 = base->object->data; @@ -1012,25 +1012,25 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) id_us_min(&cu1->vfontbi->id); cu1->vfontbi = cu->vfontbi; id_us_plus((ID *)cu1->vfontbi); - + BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family)); - + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } else if (event == 19) { /* bevel settings */ - + if (ELEM(base->object->type, OB_CURVE, OB_FONT)) { cu = ob->data; cu1 = base->object->data; - + cu1->bevobj = cu->bevobj; cu1->taperobj = cu->taperobj; cu1->width = cu->width; cu1->bevresol = cu->bevresol; cu1->ext1 = cu->ext1; cu1->ext2 = cu->ext2; - + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } @@ -1039,17 +1039,17 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) if (ELEM(base->object->type, OB_CURVE, OB_FONT)) { cu = ob->data; cu1 = base->object->data; - + cu1->resolu = cu->resolu; cu1->resolu_ren = cu->resolu_ren; - + nu = cu1->nurb.first; - + while (nu) { nu->resolu = cu1->resolu; nu = nu->next; } - + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } @@ -1073,13 +1073,13 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) else if (event == 22) { /* Copy the constraint channels over */ BKE_constraints_copy(&base->object->constraints, &ob->constraints, true); - + do_depgraph_update = true; } else if (event == 23) { base->object->softflag = ob->softflag; if (base->object->soft) sbFree(base->object->soft); - + base->object->soft = copy_softbody(ob->soft, 0); if (!modifiers_findByType(base->object, eModifierType_Softbody)) { @@ -1106,7 +1106,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) if (ELEM(base->object->type, OB_CURVE, OB_SURF)) { cu = ob->data; cu1 = base->object->data; - + if (cu->flag & CU_UV_ORCO) cu1->flag |= CU_UV_ORCO; else @@ -1125,7 +1125,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) } } } - + if (do_depgraph_update) DAG_relations_tag_update(bmain); } @@ -1135,36 +1135,36 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D * Object *ob; short event; char str[512]; - + if (!(ob = OBACT)) return; - + if (scene->obedit) { /* XXX get from context */ /* if (ob->type == OB_MESH) */ /* XXX mesh_copy_menu(); */ return; } - + /* Object Mode */ - + /* If you change this menu, don't forget to update the menu in header_view3d.c * view3d_edit_object_copyattrmenu() and in toolbox.c */ - + strcpy(str, "Copy Attributes %t|Location %x1|Rotation %x2|Size %x3|Draw Options %x4|" "Time Offset %x5|Dupli %x6|Object Color %x31|%l|Mass %x7|Damping %x8|All Physical Attributes %x11|Properties %x9|" "Logic Bricks %x10|Protected Transform %x29|%l"); - + strcat(str, "|Object Constraints %x22"); strcat(str, "|NLA Strips %x26"); - + /* XXX if (OB_TYPE_SUPPORT_MATERIAL(ob->type)) { */ /* strcat(str, "|Texture Space %x17"); */ /* } */ - + if (ob->type == OB_FONT) strcat(str, "|Font Settings %x18|Bevel Settings %x19"); if (ob->type == OB_CURVE) strcat(str, "|Bevel Settings %x19|UV Orco %x28"); - + if ((ob->type == OB_FONT) || (ob->type == OB_CURVE)) { strcat(str, "|Curve Resolution %x25"); } @@ -1174,16 +1174,16 @@ static void UNUSED_FUNCTION(copy_attr_menu) (Main *bmain, Scene *scene, View3D * } if (ob->soft) strcat(str, "|Soft Body Settings %x23"); - + strcat(str, "|Pass Index %x30"); - + if (ob->type == OB_MESH || ob->type == OB_CURVE || ob->type == OB_LATTICE || ob->type == OB_SURF) { strcat(str, "|Modifiers ... %x24"); } event = pupmenu(str); if (event <= 0) return; - + copy_attr(bmain, scene, v3d, event); } @@ -1219,7 +1219,7 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ob->pd->forcefield = PFIELD_FORCE; else ob->pd->forcefield = 0; - + ED_object_check_force_modifiers(CTX_data_main(C), CTX_data_scene(C), ob); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); @@ -1229,16 +1229,16 @@ static int forcefield_toggle_exec(bContext *C, wmOperator *UNUSED(op)) void OBJECT_OT_forcefield_toggle(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Toggle Force Field"; ot->description = "Toggle object's force field"; ot->idname = "OBJECT_OT_forcefield_toggle"; - + /* api callbacks */ ot->exec = forcefield_toggle_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1254,7 +1254,7 @@ void OBJECT_OT_forcefield_toggle(wmOperatorType *ot) void ED_objects_recalculate_paths(bContext *C, Scene *scene) { ListBase targets = {NULL, NULL}; - + /* loop over objects in scene */ CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { @@ -1263,7 +1263,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) animviz_get_object_motionpaths(ob, &targets); } CTX_DATA_END; - + /* recalculate paths, then free */ animviz_calc_motionpaths(scene, &targets); BLI_freelistN(&targets); @@ -1274,18 +1274,18 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) static int object_calculate_paths_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { Object *ob = CTX_data_active_object(C); - + if (ob == NULL) return OPERATOR_CANCELLED; - + /* set default settings from existing/stored settings */ { bAnimVizSettings *avs = &ob->avs; - + RNA_int_set(op->ptr, "start_frame", avs->path_sf); RNA_int_set(op->ptr, "end_frame", avs->path_ef); } - + /* show popup dialog to allow editing of range... */ /* FIXME: hardcoded dimensions here are just arbitrary */ return WM_operator_props_dialog_popup(C, op, 10 * UI_UNIT_X, 10 * UI_UNIT_Y); @@ -1297,28 +1297,28 @@ static int object_calculate_paths_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); int start = RNA_int_get(op->ptr, "start_frame"); int end = RNA_int_get(op->ptr, "end_frame"); - + /* set up path data for bones being calculated */ CTX_DATA_BEGIN(C, Object *, ob, selected_editable_objects) { bAnimVizSettings *avs = &ob->avs; - + /* grab baking settings from operator settings */ avs->path_sf = start; avs->path_ef = end; - + /* verify that the selected object has the appropriate settings */ animviz_verify_motionpaths(op->reports, scene, ob, NULL); } CTX_DATA_END; - + /* calculate the paths for objects that have them (and are tagged to get refreshed) */ ED_objects_recalculate_paths(C, scene); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - - return OPERATOR_FINISHED; + + return OPERATOR_FINISHED; } void OBJECT_OT_paths_calculate(wmOperatorType *ot) @@ -1327,19 +1327,19 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) ot->name = "Calculate Object Paths"; ot->idname = "OBJECT_OT_paths_calculate"; ot->description = "Calculate motion paths for the selected objects"; - + /* api callbacks */ ot->invoke = object_calculate_paths_invoke; ot->exec = object_calculate_paths_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", + RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", "First frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0); - RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", + RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", "Last frame to calculate object paths on", MINFRAME, MAXFRAME / 2.0); } @@ -1351,23 +1351,23 @@ static int object_update_paths_poll(bContext *C) Object *ob = ED_object_active_context(C); return (ob->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS) != 0; } - + return false; } static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - + if (scene == NULL) return OPERATOR_CANCELLED; - + /* calculate the paths for objects that have them (and are tagged to get refreshed) */ ED_objects_recalculate_paths(C, scene); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - + return OPERATOR_FINISHED; } @@ -1377,11 +1377,11 @@ void OBJECT_OT_paths_update(wmOperatorType *ot) ot->name = "Update Object Paths"; ot->idname = "OBJECT_OT_paths_update"; ot->description = "Recalculate paths for selected objects"; - + /* api callbakcs */ ot->exec = object_update_paths_exec; ot->poll = object_update_paths_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1423,14 +1423,14 @@ void ED_objects_clear_paths(bContext *C, bool only_selected) static int object_clear_paths_exec(bContext *C, wmOperator *op) { bool only_selected = RNA_boolean_get(op->ptr, "only_selected"); - + /* use the backend function for this */ ED_objects_clear_paths(C, only_selected); - + /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - - return OPERATOR_FINISHED; + + return OPERATOR_FINISHED; } /* operator callback/wrapper */ @@ -1448,15 +1448,15 @@ void OBJECT_OT_paths_clear(wmOperatorType *ot) ot->name = "Clear Object Paths"; ot->idname = "OBJECT_OT_paths_clear"; ot->description = "Clear path caches for all objects, hold Shift key for selected objects only"; - + /* api callbacks */ ot->invoke = object_clear_paths_invoke; ot->exec = object_clear_paths_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "only_selected", false, "Only Selected", "Only clear paths from selected objects"); @@ -1524,7 +1524,7 @@ void OBJECT_OT_shade_flat(wmOperatorType *ot) ot->name = "Shade Flat"; ot->description = "Render and display faces uniform, using Face Normals"; ot->idname = "OBJECT_OT_shade_flat"; - + /* api callbacks */ ot->poll = shade_poll; ot->exec = shade_smooth_exec; @@ -1539,11 +1539,11 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot) ot->name = "Shade Smooth"; ot->description = "Render and display faces smooth, using interpolated Vertex Normals"; ot->idname = "OBJECT_OT_shade_smooth"; - + /* api callbacks */ ot->poll = shade_poll; ot->exec = shade_smooth_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1559,15 +1559,15 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) Tex *tex; float x, y, space; int a, b, done; - + if (scene->obedit) return; // XXX get from context if (ID_IS_LINKED(scene)) return; - + for (base = FIRSTBASE; base; base = base->next) { if (TESTBASELIB(v3d, base)) { ob = base->object; done = false; - + for (a = 1; a <= ob->totcol; a++) { ma = give_current_material(ob, a); if (ma) { @@ -1576,7 +1576,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) tex = ma->mtex[b]->tex; if (tex->type == TEX_IMAGE && tex->ima) { ImBuf *ibuf = BKE_image_acquire_ibuf(tex->ima, NULL, NULL); - + /* texturespace */ space = 1.0; if (ob->type == OB_MESH) { @@ -1589,13 +1589,13 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) BKE_curve_texspace_get(ob->data, NULL, NULL, size); space = size[0] / size[1]; } - + x = ibuf->x / space; y = ibuf->y; - + if (x > y) ob->size[0] = ob->size[1] * x / y; else ob->size[1] = ob->size[0] * y / x; - + done = true; DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -1609,7 +1609,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene *scene, View3D *v3d) } } } - + } static const EnumPropertyItem *object_mode_set_itemsf( @@ -1646,7 +1646,7 @@ static const EnumPropertyItem *object_mode_set_itemsf( /* We need at least this one! */ RNA_enum_items_add_value(&item, &totitem, input, OB_MODE_OBJECT); } - + /* On top of all the rest, GPencil Stroke Edit Mode * is available if there's a valid gp datablock... */ @@ -1682,7 +1682,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) eObjectMode mode = RNA_enum_get(op->ptr, "mode"); eObjectMode restore_mode = (ob) ? ob->mode : OB_MODE_OBJECT; const bool toggle = RNA_boolean_get(op->ptr, "toggle"); - + if (gpd) { /* GP Mode is not bound to a specific object. Therefore, * we don't want it to be actually saved on any objects, @@ -1700,7 +1700,7 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) WM_operator_name_call(C, "GPENCIL_OT_editmode_toggle", WM_OP_EXEC_REGION_WIN, NULL); } } - + if (!ob || !ED_object_mode_compat_test(ob, mode)) return OPERATOR_PASS_THROUGH; @@ -1735,20 +1735,20 @@ static int object_mode_set_exec(bContext *C, wmOperator *op) void OBJECT_OT_mode_set(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Set Object Mode"; ot->description = "Sets the object interaction mode"; ot->idname = "OBJECT_OT_mode_set"; - + /* api callbacks */ ot->exec = object_mode_set_exec; - + ot->poll = object_mode_set_poll; //ED_operator_object_active_editable; - + /* flags */ ot->flag = 0; /* no register/undo here, leave it to operators being called */ - + ot->prop = RNA_def_enum(ot->srna, "mode", rna_enum_object_mode_items, OB_MODE_OBJECT, "Mode", ""); RNA_def_enum_funcs(ot->prop, object_mode_set_itemsf); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); @@ -1922,13 +1922,13 @@ static const EnumPropertyItem game_properties_copy_operations[] = { }; static const EnumPropertyItem *gameprops_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = ED_object_active_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; bProperty *prop; int a, totitem = 0; - + if (!ob) return DummyRNA_NULL_items; @@ -1954,7 +1954,7 @@ static int game_property_copy_exec(bContext *C, wmOperator *op) if (propid > 0) { /* copy */ prop = BLI_findlink(&ob->prop, propid - 1); - + if (prop) { CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { @@ -2048,18 +2048,18 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) free_controllers(&ob_iter->controllers); unlink_actuators(&ob_iter->actuators); free_actuators(&ob_iter->actuators); - + /* now copy it, this also works without logicbricks! */ clear_sca_new_poins_ob(ob); copy_sensors(&ob_iter->sensors, &ob->sensors, 0); copy_controllers(&ob_iter->controllers, &ob->controllers, 0); copy_actuators(&ob_iter->actuators, &ob->actuators, 0); set_sca_new_poins_ob(ob_iter); - + /* some menu settings */ ob_iter->scavisflag = ob->scavisflag; ob_iter->scaflag = ob->scaflag; - + /* set the initial state */ ob_iter->state = ob->state; ob_iter->init_state = ob->init_state; @@ -2095,7 +2095,7 @@ void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot) static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_active_context(C); - + CTX_DATA_BEGIN(C, Object *, ob_iter, selected_editable_objects) { if (ob != ob_iter) { @@ -2115,7 +2115,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) ob_iter->collision_boundtype = ob->collision_boundtype; ob_iter->margin = ob->margin; ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft, 0); - if (ob->restrictflag & OB_RESTRICT_RENDER) + if (ob->restrictflag & OB_RESTRICT_RENDER) ob_iter->restrictflag |= OB_RESTRICT_RENDER; else ob_iter->restrictflag &= ~OB_RESTRICT_RENDER; @@ -2125,7 +2125,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) } } CTX_DATA_END; - + return OPERATOR_FINISHED; } @@ -2135,11 +2135,11 @@ void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot) ot->name = "Copy Game Physics Properties to Selected"; ot->description = "Copy game physics properties to other selected objects"; ot->idname = "OBJECT_OT_game_physics_copy"; - + /* api callbacks */ ot->exec = game_physics_copy_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 46c2c4e4b7d..e5accee171a 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -181,7 +181,7 @@ void GROUP_OT_objects_add_active(wmOperatorType *ot) ot->name = "Add Selected To Active Group"; ot->description = "Add the object to an object group that contains the active object"; ot->idname = "GROUP_OT_objects_add_active"; - + /* api callbacks */ ot->exec = objects_add_active_exec; ot->invoke = WM_menu_invoke; @@ -206,10 +206,10 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) Group *single_group = group_object_active_find_index(ob, single_group_index); Group *group; bool ok = false; - + if (ob == NULL) return OPERATOR_CANCELLED; - + /* linking to same group requires its own loop so we can avoid * looking up the active objects groups each time */ @@ -227,13 +227,13 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) CTX_DATA_END; } } - + if (!ok) BKE_report(op->reports, RPT_ERROR, "Active object contains no groups"); - + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -245,12 +245,12 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) ot->name = "Remove Selected From Active Group"; ot->description = "Remove the object from an object group that contains the active object"; ot->idname = "GROUP_OT_objects_remove_active"; - + /* api callbacks */ ot->exec = objects_remove_active_exec; ot->invoke = WM_menu_invoke; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -274,7 +274,7 @@ static int group_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -284,11 +284,11 @@ void GROUP_OT_objects_remove_all(wmOperatorType *ot) ot->name = "Remove From All Groups"; ot->description = "Remove selected objects from all groups"; ot->idname = "GROUP_OT_objects_remove_all"; - + /* api callbacks */ ot->exec = group_objects_remove_all_exec; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -360,11 +360,11 @@ static int group_create_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Group *group = NULL; char name[MAX_ID_NAME - 2]; /* id name */ - + RNA_string_get(op->ptr, "name", name); - + group = BKE_group_add(bmain, name); - + CTX_DATA_BEGIN (C, Base *, base, selected_bases) { BKE_group_object_add(group, base->object, scene, base); @@ -373,7 +373,7 @@ static int group_create_exec(bContext *C, wmOperator *op) DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -383,14 +383,14 @@ void GROUP_OT_create(wmOperatorType *ot) ot->name = "Create New Group"; ot->description = "Create an object group from selected objects"; ot->idname = "GROUP_OT_create"; - + /* api callbacks */ ot->exec = group_create_exec; ot->poll = ED_operator_objectmode; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_string(ot->srna, "name", "Group", MAX_ID_NAME - 2, "Name", "Name of the new group"); } @@ -420,7 +420,7 @@ void OBJECT_OT_group_add(wmOperatorType *ot) ot->name = "Add to Group"; ot->idname = "OBJECT_OT_group_add"; ot->description = "Add an object to a new group"; - + /* api callbacks */ ot->exec = group_add_exec; ot->poll = ED_operator_objectmode; @@ -472,7 +472,7 @@ void OBJECT_OT_group_link(wmOperatorType *ot) ot->name = "Link to Group"; ot->idname = "OBJECT_OT_group_link"; ot->description = "Add an object to an existing group"; - + /* api callbacks */ ot->exec = group_link_exec; ot->invoke = WM_enum_search_invoke; @@ -500,7 +500,7 @@ static int group_remove_exec(bContext *C, wmOperator *UNUSED(op)) BKE_group_object_unlink(group, ob, scene, NULL); /* base will be used if found */ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -510,7 +510,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) ot->name = "Remove Group"; ot->idname = "OBJECT_OT_group_remove"; ot->description = "Remove the active object from this group"; - + /* api callbacks */ ot->exec = group_remove_exec; ot->poll = ED_operator_objectmode; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index e9203fa1972..5963e4b769b 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -79,17 +79,17 @@ static int return_editmesh_indexar( BMVert *eve; BMIter iter; int *index, nr, totvert = 0; - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) totvert++; } if (totvert == 0) return 0; - + *r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar"); *r_tot = totvert; nr = 0; zero_v3(r_cent); - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { *index = nr; index++; @@ -97,9 +97,9 @@ static int return_editmesh_indexar( } nr++; } - + mul_v3_fl(r_cent, 1.0f / (float)totvert); - + return totvert; } @@ -133,9 +133,9 @@ static bool return_editmesh_vgroup(Object *obedit, BMEditMesh *em, char *r_name, return true; } } - + return false; -} +} static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) { @@ -144,10 +144,10 @@ static void select_editbmesh_hook(Object *ob, HookModifierData *hmd) BMVert *eve; BMIter iter; int index = 0, nr = 0; - + if (hmd->indexar == NULL) return; - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (nr == hmd->indexar[index]) { BM_vert_select_set(em->bm, eve, true); @@ -166,7 +166,7 @@ static int return_editlattice_indexar( { BPoint *bp; int *index, nr, totvert = 0, a; - + /* count */ a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; bp = editlatt->def; @@ -178,12 +178,12 @@ static int return_editlattice_indexar( } if (totvert == 0) return 0; - + *r_indexar = index = MEM_mallocN(4 * totvert, "hook indexar"); *r_tot = totvert; nr = 0; zero_v3(r_cent); - + a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; bp = editlatt->def; while (a--) { @@ -196,9 +196,9 @@ static int return_editlattice_indexar( bp++; nr++; } - + mul_v3_fl(r_cent, 1.0f / (float)totvert); - + return totvert; } @@ -231,7 +231,7 @@ static int return_editcurve_indexar( BPoint *bp; BezTriple *bezt; int *index, a, nr, totvert = 0; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { bezt = nu->bezt; @@ -253,12 +253,12 @@ static int return_editcurve_indexar( } } if (totvert == 0) return 0; - + *r_indexar = index = MEM_mallocN(sizeof(*index) * totvert, "hook indexar"); *r_tot = totvert; nr = 0; zero_v3(r_cent); - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { bezt = nu->bezt; @@ -295,9 +295,9 @@ static int return_editcurve_indexar( } } } - + mul_v3_fl(r_cent, 1.0f / (float)totvert); - + return totvert; } @@ -307,7 +307,7 @@ static bool object_hook_index_array(Scene *scene, Object *obedit, *r_indexar = NULL; *r_tot = 0; r_name[0] = 0; - + switch (obedit->type) { case OB_MESH: { @@ -353,7 +353,7 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) BPoint *bp; BezTriple *bezt; int index = 0, a, nr = 0; - + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { bezt = nu->bezt; @@ -374,7 +374,7 @@ static void select_editcurve_hook(Object *obedit, HookModifierData *hmd) if (index < hmd->totindex - 1) index++; } nr++; - + bezt++; } } @@ -418,11 +418,11 @@ static void object_hook_from_context(bContext *C, PointerRNA *ptr, const int num } } -static void object_hook_select(Object *ob, HookModifierData *hmd) +static void object_hook_select(Object *ob, HookModifierData *hmd) { if (hmd->indexar == NULL) return; - + if (ob->type == OB_MESH) select_editbmesh_hook(ob, hmd); else if (ob->type == OB_LATTICE) select_editlattice_hook(ob, hmd); else if (ob->type == OB_CURVE) select_editcurve_hook(ob, hmd); @@ -434,14 +434,14 @@ static void object_hook_select(Object *ob, HookModifierData *hmd) static int hook_op_edit_poll(bContext *C) { Object *obedit = CTX_data_edit_object(C); - + if (obedit) { if (ED_operator_editmesh(C)) return 1; if (ED_operator_editsurfcurve(C)) return 1; if (ED_operator_editlattice(C)) return 1; //if (ED_operator_editmball(C)) return 1; } - + return 0; } @@ -451,12 +451,12 @@ static Object *add_hook_object_new(Main *bmain, Scene *scene, Object *obedit) Object *ob; ob = BKE_object_add(bmain, scene, OB_EMPTY, NULL); - + basedit = BKE_scene_base_find(scene, obedit); base = scene->basact; base->lay = ob->lay = obedit->lay; BLI_assert(scene->basact->object == ob); - + /* icky, BKE_object_add sets new base as active. * so set it back to the original edit object */ scene->basact = basedit; @@ -472,7 +472,7 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob float pose_mat[4][4]; int tot, ok, *indexar; char name[MAX_NAME]; - + ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); if (!ok) { @@ -481,29 +481,29 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob } if (mode == OBJECT_ADDHOOK_NEWOB && !ob) { - + ob = add_hook_object_new(bmain, scene, obedit); - + /* transform cent to global coords for loc */ mul_v3_m4v3(ob->loc, obedit->obmat, cent); } - + md = obedit->modifiers.first; while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) { md = md->next; } - + hmd = (HookModifierData *) modifier_new(eModifierType_Hook); BLI_insertlinkbefore(&obedit->modifiers, md, hmd); BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name + 2); modifier_unique_name(&obedit->modifiers, (ModifierData *)hmd); - + hmd->object = ob; hmd->indexar = indexar; copy_v3_v3(hmd->cent, cent); hmd->totindex = tot; BLI_strncpy(hmd->name, name, sizeof(hmd->name)); - + unit_m4(pose_mat); invert_m4_m4(obedit->imat, obedit->obmat); @@ -542,11 +542,11 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ BKE_object_where_is_calc(scene, ob); - + invert_m4_m4(ob->imat, ob->obmat); /* apparently this call goes from right to left... */ mul_m4_series(hmd->parentinv, pose_mat, ob->imat, obedit->obmat); - + DAG_relations_tag_update(bmain); return true; @@ -560,7 +560,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) Object *obsel = NULL; const bool use_bone = RNA_boolean_get(op->ptr, "use_bone"); const int mode = use_bone ? OBJECT_ADDHOOK_SELOB_BONE : OBJECT_ADDHOOK_SELOB; - + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { if (ob != obedit) { @@ -569,7 +569,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + if (!obsel) { BKE_report(op->reports, RPT_ERROR, "Cannot add hook with no other selected objects"); return OPERATOR_CANCELLED; @@ -579,7 +579,7 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot add hook bone for a non armature object"); return OPERATOR_CANCELLED; } - + if (add_hook_object(bmain, scene, obedit, obsel, mode, op->reports)) { WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obedit); return OPERATOR_FINISHED; @@ -595,11 +595,11 @@ void OBJECT_OT_hook_add_selob(wmOperatorType *ot) ot->name = "Hook to Selected Object"; ot->description = "Hook selected vertices to the first selected object"; ot->idname = "OBJECT_OT_hook_add_selob"; - + /* api callbacks */ ot->exec = object_add_hook_selob_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -629,11 +629,11 @@ void OBJECT_OT_hook_add_newob(wmOperatorType *ot) ot->name = "Hook to New Object"; ot->description = "Hook selected vertices to a newly created object"; ot->idname = "OBJECT_OT_hook_add_newob"; - + /* api callbacks */ ot->exec = object_add_hook_newob_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -649,29 +649,29 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* remove functionality */ - + BLI_remlink(&ob->modifiers, (ModifierData *)hmd); modifier_free((ModifierData *)hmd); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } static const EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = CTX_data_edit_object(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; ModifierData *md = NULL; int a, totitem = 0; - + if (!ob) return DummyRNA_NULL_items; - + for (a = 0, md = ob->modifiers.first; md; md = md->next, a++) { if (md->type == eModifierType_Hook) { tmp.value = a; @@ -681,32 +681,32 @@ static const EnumPropertyItem *hook_mod_itemf(bContext *C, PointerRNA *UNUSED(pt RNA_enum_item_add(&item, &totitem, &tmp); } } - + RNA_enum_item_end(&item, &totitem); *r_free = true; - + return item; } void OBJECT_OT_hook_remove(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Remove Hook"; ot->idname = "OBJECT_OT_hook_remove"; ot->description = "Remove a hook from the active object"; - + /* api callbacks */ ot->exec = object_hook_remove_exec; ot->invoke = WM_menu_invoke; ot->poll = hook_op_edit_poll; - + /* flags */ /* this operator removes modifier which isn't stored in local undo stack, * so redoing it from redo panel gives totally weird results */ ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -731,26 +731,26 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_reset(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Reset Hook"; ot->description = "Recalculate and clear offset transformation"; ot->idname = "OBJECT_OT_hook_reset"; - + /* callbacks */ ot->exec = object_hook_reset_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -765,42 +765,42 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) HookModifierData *hmd = NULL; Scene *scene = CTX_data_scene(C); float bmat[3][3], imat[3][3]; - + object_hook_from_context(C, &ptr, num, &ob, &hmd); if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* recenter functionality */ copy_m3_m4(bmat, ob->obmat); invert_m3_m3(imat, bmat); - + sub_v3_v3v3(hmd->cent, scene->cursor, ob->obmat[3]); mul_m3_v3(imat, hmd->cent); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_recenter(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Recenter Hook"; ot->description = "Set hook center to cursor position"; ot->idname = "OBJECT_OT_hook_recenter"; - + /* callbacks */ ot->exec = object_hook_recenter_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -817,50 +817,50 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) float cent[3]; char name[MAX_NAME]; int *indexar, tot; - + object_hook_from_context(C, &ptr, num, &ob, &hmd); if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* assign functionality */ - + if (!object_hook_index_array(scene, ob, &tot, &indexar, name, cent)) { BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); return OPERATOR_CANCELLED; } if (hmd->indexar) MEM_freeN(hmd->indexar); - + copy_v3_v3(hmd->cent, cent); hmd->indexar = indexar; hmd->totindex = tot; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_assign(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Assign to Hook"; ot->description = "Assign the selected vertices to a hook"; ot->idname = "OBJECT_OT_hook_assign"; - + /* callbacks */ ot->exec = object_hook_assign_exec; ot->poll = hook_op_edit_poll; - + /* flags */ /* this operator changes data stored in modifier which doesn't get pushed to undo stack, * so redoing it from redo panel gives totally weird results */ ot->flag = /*OPTYPE_REGISTER|*/ OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to assign to"); RNA_def_enum_funcs(prop, hook_mod_itemf); @@ -873,37 +873,37 @@ static int object_hook_select_exec(bContext *C, wmOperator *op) int num = RNA_enum_get(op->ptr, "modifier"); Object *ob = NULL; HookModifierData *hmd = NULL; - + object_hook_from_context(C, &ptr, num, &ob, &hmd); if (hmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } - + /* select functionality */ object_hook_select(ob, hmd); - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data); - + return OPERATOR_FINISHED; } void OBJECT_OT_hook_select(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Select Hook"; ot->description = "Select affected vertices on mesh"; ot->idname = "OBJECT_OT_hook_select"; - + /* callbacks */ ot->exec = object_hook_select_exec; ot->poll = hook_op_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "modifier", DummyRNA_NULL_items, 0, "Modifier", "Modifier number to remove"); RNA_def_enum_funcs(prop, hook_mod_itemf); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 34f192fbffa..c79be8ed223 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -97,7 +97,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc { ModifierData *md = NULL, *new_md = NULL; const ModifierTypeInfo *mti = modifierType_getInfo(type); - + /* Check compatibility of modifier [T25291, T50373]. */ if (!BKE_object_support_modifier_type_check(ob, type)) { BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2); @@ -110,23 +110,23 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc return NULL; } } - + if (type == eModifierType_ParticleSystem) { /* don't need to worry about the new modifier's name, since that is set to the number - * of particle systems which shouldn't have too many duplicates + * of particle systems which shouldn't have too many duplicates */ new_md = object_add_particle_system(scene, ob, name); } else { /* get new modifier data to add */ new_md = modifier_new(type); - + if (mti->flags & eModifierTypeFlag_RequiresOriginalData) { md = ob->modifiers.first; - + while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) md = md->next; - + BLI_insertlinkbefore(&ob->modifiers, md, new_md); } else @@ -139,7 +139,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* make sure modifier data has unique name */ modifier_unique_name(&ob->modifiers, new_md); - + /* special cases */ if (type == eModifierType_Softbody) { if (!ob->soft) { @@ -150,7 +150,7 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc else if (type == eModifierType_Collision) { if (!ob->pd) ob->pd = object_add_collision_fields(0); - + ob->pd->deflect = 1; } else if (type == eModifierType_Surface) { @@ -465,14 +465,14 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * /* add new mesh */ obn = BKE_object_add(bmain, scene, OB_MESH, NULL); me = obn->data; - + me->totvert = totvert; me->totedge = totedge; - + me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, totvert); me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_CALLOC, NULL, totedge); me->mface = CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, NULL, 0); - + mvert = me->mvert; medge = me->medge; @@ -547,18 +547,18 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M Mesh *me = ob->data; Key *key = me->key; KeyBlock *kb; - + if (!modifier_isSameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes"); return 0; } - + dm = mesh_create_derived_for_modifier(scene, ob, md, 0); if (!dm) { BKE_report(reports, RPT_ERROR, "Modifier is disabled or returned error, skipping apply"); return 0; } - + if (key == NULL) { key = me->key = BKE_key_add((ID *)me); key->type = KEY_RELATIVE; @@ -570,7 +570,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M kb = BKE_keyblock_add(key, md->name); DM_to_meshkey(dm, me, kb); - + dm->release(dm); } else { @@ -656,7 +656,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, ParticleSystem *psys = ob->particlesystem.first; for (; psys; psys = psys->next) { - + if (psys->part->type != PART_HAIR) continue; @@ -718,7 +718,7 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi int ED_object_modifier_copy(ReportList *UNUSED(reports), Object *ob, ModifierData *md) { ModifierData *nmd; - + nmd = modifier_new(md->type); modifier_copyData(md, nmd); BLI_insertlinkafter(&ob->modifiers, md, nmd); @@ -740,19 +740,19 @@ static int modifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } static const EnumPropertyItem *modifier_add_itemf( bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = ED_object_active_context(C); EnumPropertyItem *item = NULL; const EnumPropertyItem *md_item, *group_item = NULL; const ModifierTypeInfo *mti; int totitem = 0, a; - + if (!ob) return rna_enum_object_modifier_type_items; @@ -797,15 +797,15 @@ void OBJECT_OT_modifier_add(wmOperatorType *ot) ot->name = "Add Modifier"; ot->description = "Add a procedural operation/effect to the active object"; ot->idname = "OBJECT_OT_modifier_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = modifier_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "type", rna_enum_object_modifier_type_items, eModifierType_Subsurf, "Type", ""); RNA_def_enum_funcs(prop, modifier_add_itemf); @@ -818,11 +818,11 @@ int edit_modifier_poll_generic(bContext *C, StructRNA *rna_type, int obtype_flag { PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", rna_type); Object *ob = (ptr.id.data) ? ptr.id.data : ED_object_active_context(C); - + if (!ob || ID_IS_LINKED(ob)) return 0; if (obtype_flag && ((1 << ob->type) & obtype_flag) == 0) return 0; if (ptr.id.data && ID_IS_LINKED(ptr.id.data)) return 0; - + return 1; } @@ -839,7 +839,7 @@ void edit_modifier_properties(wmOperatorType *ot) int edit_modifier_invoke_properties(bContext *C, wmOperator *op) { ModifierData *md; - + if (RNA_struct_property_is_set(op->ptr, "modifier")) { return true; } @@ -860,9 +860,9 @@ ModifierData *edit_modifier_property_get(wmOperator *op, Object *ob, int type) char modifier_name[MAX_NAME]; ModifierData *md; RNA_string_get(op->ptr, "modifier", modifier_name); - + md = modifiers_findByName(ob, modifier_name); - + if (md && type != 0 && md->type != type) md = NULL; @@ -878,7 +878,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); int mode_orig = ob->mode; - + if (!md || !ED_object_modifier_remove(op->reports, bmain, ob, md)) return OPERATOR_CANCELLED; @@ -889,7 +889,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) if (scene->basact && scene->basact->object == ob) WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); - + return OPERATOR_FINISHED; } @@ -910,7 +910,7 @@ void OBJECT_OT_modifier_remove(wmOperatorType *ot) ot->invoke = modifier_remove_invoke; ot->exec = modifier_remove_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -928,7 +928,7 @@ static int modifier_move_up_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -949,7 +949,7 @@ void OBJECT_OT_modifier_move_up(wmOperatorType *ot) ot->invoke = modifier_move_up_invoke; ot->exec = modifier_move_up_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -967,7 +967,7 @@ static int modifier_move_down_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -988,7 +988,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) ot->invoke = modifier_move_down_invoke; ot->exec = modifier_move_down_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1009,7 +1009,7 @@ static int modifier_apply_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1036,10 +1036,10 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) ot->invoke = modifier_apply_invoke; ot->exec = modifier_apply_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + RNA_def_enum(ot->srna, "apply_as", modifier_apply_as_items, MODIFIER_APPLY_DATA, "Apply as", "How to apply the modifier to the geometry"); edit_modifier_properties(ot); } @@ -1052,13 +1052,13 @@ static int modifier_convert_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - + if (!md || !ED_object_modifier_convert(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1079,7 +1079,7 @@ void OBJECT_OT_modifier_convert(wmOperatorType *ot) ot->invoke = modifier_convert_invoke; ot->exec = modifier_convert_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1097,7 +1097,7 @@ static int modifier_copy_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1118,7 +1118,7 @@ void OBJECT_OT_modifier_copy(wmOperatorType *ot) ot->invoke = modifier_copy_invoke; ot->exec = modifier_copy_exec; ot->poll = edit_modifier_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1135,18 +1135,18 @@ static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_del_levels(mmd, ob, 1); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, &mmd->totlvl); - + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1167,7 +1167,7 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_higher_levels_delete_invoke; ot->exec = multires_higher_levels_delete_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1179,10 +1179,10 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_subdivide(mmd, ob, 0, mmd->simple); ED_object_iter_other(CTX_data_main(C), ob, true, @@ -1196,7 +1196,7 @@ static int multires_subdivide_exec(bContext *C, wmOperator *op) /* ensure that grid paint mask layer is created */ BKE_sculpt_mask_layers_ensure(ob, mmd); } - + return OPERATOR_FINISHED; } @@ -1217,7 +1217,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_subdivide_invoke; ot->exec = multires_subdivide_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1281,14 +1281,14 @@ void OBJECT_OT_multires_reshape(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_reshape_invoke; ot->exec = multires_reshape_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); } - + /****************** multires save external operator *********************/ static int multires_external_save_exec(bContext *C, wmOperator *op) @@ -1304,7 +1304,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; - + RNA_string_get(op->ptr, "filepath", path); if (relative) @@ -1312,7 +1312,7 @@ static int multires_external_save_exec(bContext *C, wmOperator *op) CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, me->totloop, path); CustomData_external_write(&me->ldata, &me->id, CD_MASK_MESH, me->totloop, 0); - + return OPERATOR_FINISHED; } @@ -1325,23 +1325,23 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv if (!edit_modifier_invoke_properties(C, op)) return OPERATOR_CANCELLED; - + mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + if (CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; if (RNA_struct_property_is_set(op->ptr, "filepath")) return multires_external_save_exec(C, op); - + op->customdata = me; BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2); RNA_string_set(op->ptr, "filepath", path); - + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; @@ -1357,7 +1357,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->exec = multires_external_save_exec; ot->invoke = multires_external_save_invoke; ot->poll = multires_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; @@ -1379,7 +1379,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) /* XXX don't remove.. */ CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); - + return OPERATOR_FINISHED; } @@ -1391,7 +1391,7 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) ot->poll = multires_poll; ot->exec = multires_external_pack_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1401,15 +1401,15 @@ static int multires_base_apply_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); - + if (!mmd) return OPERATOR_CANCELLED; - + multiresModifier_base_apply(mmd, ob); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1431,7 +1431,7 @@ void OBJECT_OT_multires_base_apply(wmOperatorType *ot) ot->poll = multires_poll; ot->invoke = multires_base_apply_invoke; ot->exec = multires_base_apply_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1444,7 +1444,7 @@ static void modifier_skin_customdata_delete(Object *ob) { Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; - + if (em) BM_data_layer_free(em->bm, &em->bm->vdata, CD_MVERT_SKIN); else @@ -1467,7 +1467,7 @@ static void skin_root_clear(BMVert *bm_vert, GSet *visited, const int cd_vert_sk { BMEdge *bm_edge; BMIter bm_iter; - + BM_ITER_ELEM (bm_edge, &bm_iter, bm_vert, BM_EDGES_OF_VERT) { BMVert *v2 = BM_edge_other_vert(bm_edge, bm_vert); @@ -1515,7 +1515,7 @@ static int skin_root_mark_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1527,7 +1527,7 @@ void OBJECT_OT_skin_root_mark(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_root_mark_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1570,7 +1570,7 @@ static int skin_loose_mark_clear_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1588,7 +1588,7 @@ void OBJECT_OT_skin_loose_mark_clear(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_loose_mark_clear_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1620,7 +1620,7 @@ static int skin_radii_equalize_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -1632,7 +1632,7 @@ void OBJECT_OT_skin_radii_equalize(wmOperatorType *ot) ot->poll = skin_edit_poll; ot->exec = skin_radii_equalize_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1676,7 +1676,7 @@ static void skin_armature_bone_create(Object *skin_ob, ED_vgroup_vert_add(skin_ob, dg, parent_v, 1, WEIGHT_REPLACE); ED_vgroup_vert_add(skin_ob, dg, v, 1, WEIGHT_REPLACE); } - + skin_armature_bone_create(skin_ob, mvert, medge, arm, @@ -1709,7 +1709,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * CD_CALLOC, NULL, me->totvert); - + arm_ob = BKE_object_add(bmain, scene, OB_ARMATURE, NULL); BKE_object_transform_copy(arm_ob, skin_ob); arm = arm_ob->data; @@ -1742,7 +1742,7 @@ static Object *modifier_skin_armature_create(Main *bmain, Scene *scene, Object * bone->head[1] = 1.0f; bone->rad_head = bone->rad_tail = 0.25; } - + if (emap[v].count >= 1) { skin_armature_bone_create(skin_ob, mvert, me->medge, @@ -1816,7 +1816,7 @@ void OBJECT_OT_skin_armature_create(wmOperatorType *ot) ot->poll = skin_poll; ot->invoke = skin_armature_create_invoke; ot->exec = skin_armature_create_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1901,7 +1901,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get(op, ob, eModifierType_MeshDeform); - + if (!mmd) return OPERATOR_CANCELLED; @@ -1926,7 +1926,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->totvert = 0; mmd->totcagevert = 0; mmd->totinfluence = 0; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); } @@ -1955,7 +1955,7 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) mmd->bindfunc = NULL; mmd->modifier.mode = mode; } - + return OPERATOR_FINISHED; } @@ -1963,7 +1963,7 @@ static int meshdeform_bind_invoke(bContext *C, wmOperator *op, const wmEvent *UN { if (edit_modifier_invoke_properties(C, op)) return meshdeform_bind_exec(C, op); - else + else return OPERATOR_CANCELLED; } @@ -1973,12 +1973,12 @@ void OBJECT_OT_meshdeform_bind(wmOperatorType *ot) ot->name = "Mesh Deform Bind"; ot->description = "Bind mesh to cage in mesh deform modifier"; ot->idname = "OBJECT_OT_meshdeform_bind"; - + /* api callbacks */ ot->poll = meshdeform_poll; ot->invoke = meshdeform_bind_invoke; ot->exec = meshdeform_bind_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -1995,7 +1995,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); ExplodeModifierData *emd = (ExplodeModifierData *)edit_modifier_property_get(op, ob, eModifierType_Explode); - + if (!emd) return OPERATOR_CANCELLED; @@ -2003,7 +2003,7 @@ static int explode_refresh_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); - + return OPERATOR_FINISHED; } @@ -2025,7 +2025,7 @@ void OBJECT_OT_explode_refresh(wmOperatorType *ot) ot->poll = explode_poll; ot->invoke = explode_refresh_invoke; ot->exec = explode_refresh_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); @@ -2043,14 +2043,14 @@ static int ocean_bake_poll(bContext *C) static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd) { int do_heightfield, do_chop, do_normals, do_jacobian; - - if (!omd || !oc) return; - + + if (!omd || !oc) return; + do_heightfield = true; do_chop = (omd->chop_amount > 0); do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); - + BKE_ocean_init(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size, omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, omd->depth, omd->time, @@ -2080,8 +2080,8 @@ static int oceanbake_breakjob(void *UNUSED(customdata)) { //OceanBakeJob *ob = (OceanBakeJob *)customdata; //return *(ob->stop); - - /* this is not nice yet, need to make the jobs list template better + + /* this is not nice yet, need to make the jobs list template better * for identifying/acting upon various different jobs */ /* but for now we'll reuse the render break... */ return (G.is_break); @@ -2091,10 +2091,10 @@ static int oceanbake_breakjob(void *UNUSED(customdata)) static void oceanbake_update(void *customdata, float progress, int *cancel) { OceanBakeJob *oj = customdata; - + if (oceanbake_breakjob(oj)) *cancel = 1; - + *(oj->do_update) = true; *(oj->progress) = progress; } @@ -2102,15 +2102,15 @@ static void oceanbake_update(void *customdata, float progress, int *cancel) static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress) { OceanBakeJob *oj = customdata; - + oj->stop = stop; oj->do_update = do_update; oj->progress = progress; - + G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ - + BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj); - + *do_update = true; *stop = 0; } @@ -2118,12 +2118,12 @@ static void oceanbake_startjob(void *customdata, short *stop, short *do_update, static void oceanbake_endjob(void *customdata) { OceanBakeJob *oj = customdata; - + if (oj->ocean) { BKE_ocean_free(oj->ocean); oj->ocean = NULL; } - + oj->omd->oceancache = oj->och; oj->omd->cached = true; } @@ -2138,13 +2138,13 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) struct Ocean *ocean; int f, cfra, i = 0; const bool free = RNA_boolean_get(op->ptr, "free"); - + wmJob *wm_job; OceanBakeJob *oj; - + if (!omd) return OPERATOR_CANCELLED; - + if (free) { omd->refresh |= MOD_OCEAN_REFRESH_CLEAR_CACHE; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -2155,11 +2155,11 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(bmain, ob), omd->bakestart, omd->bakeend, omd->wave_scale, omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); - + och->time = MEM_mallocN(och->duration * sizeof(float), "foam bake time"); - + cfra = scene->r.cfra; - + /* precalculate time variable before baking */ for (f = omd->bakestart; f <= omd->bakeend; f++) { /* from physics_fluid.c: @@ -2170,41 +2170,41 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) * This doesn't work with drivers: * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL); */ - - /* Modifying the global scene isn't nice, but we can do it in + + /* Modifying the global scene isn't nice, but we can do it in * this part of the process before a threaded job is created */ - + //scene->r.cfra = f; //ED_update_for_newframe(bmain, scene, 1); - - /* ok, this doesn't work with drivers, but is way faster. + + /* ok, this doesn't work with drivers, but is way faster. * let's use this for now and hope nobody wants to drive the time value... */ BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM); - + och->time[i] = omd->time; i++; } - + /* make a copy of ocean to use for baking - threadsafety */ ocean = BKE_ocean_add(); init_ocean_modifier_bake(ocean, omd); - + #if 0 BKE_ocean_bake(ocean, och); - + omd->oceancache = och; omd->cached = true; - + scene->r.cfra = cfra; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); #endif - + /* job stuff */ - + scene->r.cfra = cfra; - + /* setup job */ wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); @@ -2212,15 +2212,15 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) oj->ocean = ocean; oj->och = och; oj->omd = omd; - + WM_jobs_customdata_set(wm_job, oj, oceanbake_free); WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); WM_jobs_callbacks(wm_job, oceanbake_startjob, NULL, NULL, oceanbake_endjob); - + WM_jobs_start(CTX_wm_manager(C), wm_job); - - - + + + return OPERATOR_FINISHED; } @@ -2238,15 +2238,15 @@ void OBJECT_OT_ocean_bake(wmOperatorType *ot) ot->name = "Bake Ocean"; ot->description = "Bake an image sequence of ocean data"; ot->idname = "OBJECT_OT_ocean_bake"; - + ot->poll = ocean_bake_poll; ot->invoke = ocean_bake_invoke; ot->exec = ocean_bake_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); - + RNA_def_boolean(ot->srna, "free", false, "Free", "Free the bake, rather than generating it"); } @@ -2279,7 +2279,7 @@ static int laplaciandeform_bind_invoke(bContext *C, wmOperator *op, const wmEven { if (edit_modifier_invoke_properties(C, op)) return laplaciandeform_bind_exec(C, op); - else + else return OPERATOR_CANCELLED; } @@ -2289,12 +2289,12 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot) ot->name = "Laplacian Deform Bind"; ot->description = "Bind mesh to system in laplacian deform modifier"; ot->idname = "OBJECT_OT_laplaciandeform_bind"; - + /* api callbacks */ ot->poll = laplaciandeform_poll; ot->invoke = laplaciandeform_bind_invoke; ot->exec = laplaciandeform_bind_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_modifier_properties(ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index ed78342f3d2..9a0b37e6dab 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -62,7 +62,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_visual_transform_apply); WM_operatortype_append(OBJECT_OT_transform_apply); WM_operatortype_append(OBJECT_OT_origin_set); - + WM_operatortype_append(OBJECT_OT_mode_set); WM_operatortype_append(OBJECT_OT_editmode_toggle); WM_operatortype_append(OBJECT_OT_posemode_toggle); @@ -150,7 +150,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_meshdeform_bind); WM_operatortype_append(OBJECT_OT_explode_refresh); WM_operatortype_append(OBJECT_OT_ocean_bake); - + WM_operatortype_append(OBJECT_OT_constraint_add); WM_operatortype_append(OBJECT_OT_constraint_add_with_targets); WM_operatortype_append(POSE_OT_constraint_add); @@ -253,7 +253,7 @@ void ED_operatormacros_object(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { @@ -271,7 +271,7 @@ void ED_operatormacros_object(void) otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); } - + } static int object_mode_poll(bContext *C) @@ -285,10 +285,10 @@ void ED_keymap_object(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; int i; - + /* Objects, Regardless of Mode -------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "Object Non-modal", 0, 0); - + /* Note: this keymap works disregarding mode */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_EDIT); @@ -301,18 +301,18 @@ void ED_keymap_object(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", VKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_VERTEX_PAINT); RNA_boolean_set(kmi->ptr, "toggle", true); - + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_mode_set", TABKEY, KM_PRESS, KM_CTRL, 0); RNA_enum_set(kmi->ptr, "mode", OB_MODE_WEIGHT_PAINT); RNA_boolean_set(kmi->ptr, "toggle", true); - + WM_keymap_add_item(keymap, "OBJECT_OT_origin_set", CKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); /* Object Mode ---------------------------------------------------------------- */ /* Note: this keymap gets disabled in non-objectmode, */ keymap = WM_keymap_find(keyconf, "Object Mode", 0, 0); keymap->poll = object_mode_poll; - + /* object mode supports PET now */ ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_obmode(keyconf, keymap); @@ -331,7 +331,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_select_linked", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_enum_set_identifier(NULL, kmi->ptr, "direction", "PARENT"); RNA_boolean_set(kmi->ptr, "extend", false); @@ -353,20 +353,20 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_set", TKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_track_clear", TKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_verify_item(keymap, "OBJECT_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - - + + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_location_clear", GKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_rotation_clear", RKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_scale_clear", SKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "clear_delta", false); - + WM_keymap_verify_item(keymap, "OBJECT_OT_origin_clear", OKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_clear", HKEY, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_hide_view_set", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); @@ -385,7 +385,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) #endif WM_keymap_add_item(keymap, "OBJECT_OT_move_to_layer", MKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_delete", XKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_global", false); @@ -407,7 +407,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_duplicate_move_linked", DKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "OBJECT_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OBJECT_OT_convert", CKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); @@ -417,13 +417,13 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0); - + WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_all", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_add_active", GKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove_active", GKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_object_specials", WKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_data_transfer", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 440c9d01487..6b53807ce1c 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -83,7 +83,7 @@ * this takes into account the 'restrict selection in 3d view' flag. * deselect works always, the restriction just prevents selection */ -/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or +/* Note: send a NC_SCENE|ND_OB_SELECT notifier yourself! (or * or a NC_SCENE|ND_OB_VISIBLE in case of visibility toggling */ void ED_base_object_select(Base *base, short mode) @@ -104,15 +104,15 @@ void ED_base_object_select(Base *base, short mode) void ED_base_object_activate(bContext *C, Base *base) { Scene *scene = CTX_data_scene(C); - + /* sets scene->basact */ BASACT = base; - + if (base) { - + /* XXX old signals, remember to handle notifiers now! */ // select_actionchannel_by_name(base->object->action, "Object", 1); - + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } else @@ -131,7 +131,7 @@ static int objects_selectable_poll(bContext *C) return 0; if (obact && obact->mode) return 0; - + return 1; } @@ -140,10 +140,10 @@ static int objects_selectable_poll(bContext *C) static int object_select_by_type_exec(bContext *C, wmOperator *op) { short obtype, extend; - + obtype = RNA_enum_get(op->ptr, "type"); extend = RNA_boolean_get(op->ptr, "extend"); - + if (extend == 0) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { @@ -151,7 +151,7 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { if (base->object->type == obtype) { @@ -159,9 +159,9 @@ static int object_select_by_type_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } @@ -171,15 +171,15 @@ void OBJECT_OT_select_by_type(wmOperatorType *ot) ot->name = "Select By Type"; ot->description = "Select all visible objects that are of a type"; ot->idname = "OBJECT_OT_select_by_type"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_select_by_type_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_object_type_items, 1, "Type", ""); @@ -324,7 +324,7 @@ static bool object_select_all_by_particle(bContext *C, Object *ob) if ((base->flag & SELECT) == 0) { /* loop through other particles*/ ParticleSystem *psys; - + for (psys = base->object->particlesystem.first; psys; psys = psys->next) { if (psys->part == psys_act->part) { base->flag |= SELECT; @@ -413,7 +413,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) bool changed = false, extend; extend = RNA_boolean_get(op->ptr, "extend"); - + if (extend == 0) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { @@ -421,13 +421,13 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + ob = OBACT; if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; } - + if (nr == OBJECT_SELECT_LINKED_IPO) { // XXX old animation system //if (ob->ipo == 0) return OPERATOR_CANCELLED; @@ -485,7 +485,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -495,15 +495,15 @@ void OBJECT_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->description = "Select all visible objects that are linked"; ot->idname = "OBJECT_OT_select_linked"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_select_linked_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", prop_select_linked_types, 0, "Type", ""); @@ -781,7 +781,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList { KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); bool changed = false; - + /* firstly, validate KeyingSet */ if (ks == NULL) { BKE_report(reports, RPT_ERROR, "No active Keying Set to use"); @@ -790,7 +790,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList else if (ANIM_validate_keyingset(C, NULL, ks) != 0) { if (ks->paths.first == NULL) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - BKE_report(reports, RPT_ERROR, + BKE_report(reports, RPT_ERROR, "Use another Keying Set, as the active one depends on the currently " "selected objects or cannot find any targets due to unsuitable context"); } @@ -800,7 +800,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList } return false; } - + /* select each object that Keying Set refers to */ /* TODO: perhaps to be more in line with the rest of these, we should only take objects * if the passed in object is included in this too */ @@ -809,8 +809,8 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList /* only check for this object if it isn't selected already, to limit time wasted */ if ((base->flag & SELECT) == 0) { KS_Path *ksp; - - /* this is the slow way... we could end up with > 500 items here, + + /* this is the slow way... we could end up with > 500 items here, * with none matching, but end up doing this on 1000 objects... */ for (ksp = ks->paths.first; ksp; ksp = ksp->next) { @@ -824,7 +824,7 @@ static bool select_grouped_keyingset(bContext *C, Object *UNUSED(ob), ReportList } } CTX_DATA_END; - + return changed; } @@ -914,15 +914,15 @@ void OBJECT_OT_select_grouped(wmOperatorType *ot) ot->name = "Select Grouped"; ot->description = "Select all visible objects grouped by various properties"; ot->idname = "OBJECT_OT_select_grouped"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_select_grouped_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", ""); @@ -939,11 +939,11 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) unsigned int layernum; bool extend; int match; - + extend = RNA_boolean_get(op->ptr, "extend"); layernum = RNA_int_get(op->ptr, "layers"); match = RNA_enum_get(op->ptr, "match"); - + if (extend == false) { CTX_DATA_BEGIN (C, Base *, base, visible_bases) { @@ -951,7 +951,7 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) } CTX_DATA_END; } - + CTX_DATA_BEGIN (C, Base *, base, visible_bases) { bool ok = false; @@ -973,10 +973,10 @@ static int object_select_by_layer_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + /* undo? */ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } @@ -992,15 +992,15 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) ot->name = "Select by Layer"; ot->description = "Select all visible objects on a layer"; ot->idname = "OBJECT_OT_select_by_layer"; - + /* api callbacks */ /*ot->invoke = XXX - need a int grid popup*/ ot->exec = object_select_by_layer_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_enum(ot->srna, "match", match_items, OB_SEL_LAYERMATCH_EXACT, "Match", ""); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); @@ -1012,7 +1012,7 @@ void OBJECT_OT_select_by_layer(wmOperatorType *ot) static int object_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); - + /* passthrough if no objects are visible */ if (CTX_DATA_COUNT(C, visible_bases) == 0) return OPERATOR_PASS_THROUGH; @@ -1048,24 +1048,24 @@ static int object_select_all_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } void OBJECT_OT_select_all(wmOperatorType *ot) { - + /* identifiers */ ot->name = "(De)select All"; ot->description = "Change selection of all visible objects in scene"; ot->idname = "OBJECT_OT_select_all"; - + /* api callbacks */ ot->exec = object_select_all_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1099,22 +1099,22 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) CTX_DATA_END; WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } void OBJECT_OT_select_same_group(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Select Same Group"; ot->description = "Select object in the same group"; ot->idname = "OBJECT_OT_select_same_group"; - + /* api callbacks */ ot->exec = object_select_same_group_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -1127,15 +1127,15 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bool extend; - + extend = RNA_boolean_get(op->ptr, "extend"); - + CTX_DATA_BEGIN (C, Base *, primbase, selected_bases) { char name_flip[MAXBONENAME]; BLI_string_flip_side_name(name_flip, primbase->object->id.name + 2, true, sizeof(name_flip)); - + if (!STREQ(name_flip, primbase->object->id.name + 2)) { Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip); if (ob) { @@ -1146,33 +1146,33 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) } } } - + if (extend == false) ED_base_object_select(primbase, BA_DESELECT); - + } CTX_DATA_END; - + /* undo? */ WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); - + return OPERATOR_FINISHED; } void OBJECT_OT_select_mirror(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Select Mirror"; ot->description = "Select the Mirror objects of the selected object eg. L.sword -> R.sword"; ot->idname = "OBJECT_OT_select_mirror"; - + /* api callbacks */ ot->exec = object_select_mirror_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend selection instead of deselecting everything first"); } @@ -1297,7 +1297,7 @@ void OBJECT_OT_select_less(wmOperatorType *ot) /**************************** Select Random ****************************/ static int object_select_random_exec(bContext *C, wmOperator *op) -{ +{ const float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; const int seed = WM_operator_properties_select_random_seed_increment_get(op); const bool select = (RNA_enum_get(op->ptr, "action") == SEL_SELECT); @@ -1315,7 +1315,7 @@ static int object_select_random_exec(bContext *C, wmOperator *op) BLI_rng_free(rng); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } @@ -1325,15 +1325,15 @@ void OBJECT_OT_select_random(wmOperatorType *ot) ot->name = "Select Random"; ot->description = "Set select on random visible objects"; ot->idname = "OBJECT_OT_select_random"; - + /* api callbacks */ /*ot->invoke = object_select_random_invoke XXX - need a number popup ;*/ ot->exec = object_select_random_exec; ot->poll = objects_selectable_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ WM_operator_properties_select_random(ot); } diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 27da607c696..7d7130fdbc7 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -35,7 +35,7 @@ #include #else #include -#endif +#endif #include "MEM_guardedalloc.h" @@ -117,7 +117,7 @@ static bool object_shape_key_mirror(bContext *C, Object *ob, key = BKE_key_from_object(ob); if (key == NULL) return 0; - + kb = BLI_findlink(&key->block, ob->shapenr - 1); if (kb) { @@ -209,7 +209,7 @@ static bool object_shape_key_mirror(bContext *C, Object *ob, MEM_freeN(tag_elem); } - + *r_totmirr = totmirr; *r_totfail = totfail; @@ -276,7 +276,7 @@ void OBJECT_OT_shape_key_add(wmOperatorType *ot) ot->name = "Add Shape Key"; ot->idname = "OBJECT_OT_shape_key_add"; ot->description = "Add shape key to the object"; - + /* api callbacks */ ot->poll = shape_key_mode_poll; ot->exec = shape_key_add_exec; @@ -319,7 +319,7 @@ void OBJECT_OT_shape_key_remove(wmOperatorType *ot) ot->name = "Remove Shape Key"; ot->idname = "OBJECT_OT_shape_key_remove"; ot->description = "Remove shape key from the object"; - + /* api callbacks */ ot->poll = shape_key_mode_exists_poll; ot->exec = shape_key_remove_exec; @@ -339,13 +339,13 @@ static int shape_key_clear_exec(bContext *C, wmOperator *UNUSED(op)) if (!key || !kb) return OPERATOR_CANCELLED; - + for (kb = key->block.first; kb; kb = kb->next) kb->curval = 0.0f; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -355,7 +355,7 @@ void OBJECT_OT_shape_key_clear(wmOperatorType *ot) ot->name = "Clear Shape Keys"; ot->description = "Clear weights for all shape keys"; ot->idname = "OBJECT_OT_shape_key_clear"; - + /* api callbacks */ ot->poll = shape_key_poll; ot->exec = shape_key_clear_exec; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 080710e0a38..19dad374696 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -118,7 +118,7 @@ static void object_clear_rot(Object *ob, const bool clear_delta) ob->rotAxis[2] = 0.0f; if (clear_delta) ob->drotAxis[2] = 0.0f; } - + /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ if (IS_EQF(ob->rotAxis[0], ob->rotAxis[1]) && IS_EQF(ob->rotAxis[1], ob->rotAxis[2])) ob->rotAxis[1] = 1.0f; @@ -164,7 +164,7 @@ static void object_clear_rot(Object *ob, const bool clear_delta) /* perform clamping using euler form (3-components) */ /* FIXME: deltas are not handled for these cases yet... */ float eul[3], oldeul[3], quat1[4] = {0}; - + if (ob->rotmode == ROT_MODE_QUAT) { copy_qt_qt(quat1, ob->quat); quat_to_eul(oldeul, ob->quat); @@ -175,16 +175,16 @@ static void object_clear_rot(Object *ob, const bool clear_delta) else { copy_v3_v3(oldeul, ob->rot); } - + eul[0] = eul[1] = eul[2] = 0.0f; - + if (ob->protectflag & OB_LOCK_ROTX) eul[0] = oldeul[0]; if (ob->protectflag & OB_LOCK_ROTY) eul[1] = oldeul[1]; if (ob->protectflag & OB_LOCK_ROTZ) eul[2] = oldeul[2]; - + if (ob->rotmode == ROT_MODE_QUAT) { eul_to_quat(ob->quat, eul); /* quaternions flip w sign to accumulate rotations correctly */ @@ -237,24 +237,24 @@ static void object_clear_scale(Object *ob, const bool clear_delta) /* --------------- */ /* generic exec for clear-transform operators */ -static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, +static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, void (*clear_func)(Object *, const bool), const char default_ksName[]) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; const bool clear_delta = RNA_boolean_get(op->ptr, "clear_delta"); - + /* sanity checks */ if (ELEM(NULL, clear_func, default_ksName)) { BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name"); return OPERATOR_CANCELLED; } - + /* get KeyingSet to use */ ks = ANIM_get_keyingset_for_autokeying(scene, default_ksName); - - /* operate on selected objects only if they aren't in weight-paint mode + + /* operate on selected objects only if they aren't in weight-paint mode * (so that object-transform clearing won't be applied at same time as bone-clearing) */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -262,15 +262,15 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, if (!(ob->mode & OB_MODE_WEIGHT_PAINT)) { /* run provided clearing function */ clear_func(ob, clear_delta); - + ED_autokeyframe_object(C, scene, ob, ks); - + /* tag for updates */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } CTX_DATA_END; - + /* this is needed so children are also updated */ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); @@ -291,15 +291,15 @@ void OBJECT_OT_location_clear(wmOperatorType *ot) ot->name = "Clear Location"; ot->description = "Clear the object's location"; ot->idname = "OBJECT_OT_location_clear"; - + /* api callbacks */ ot->exec = object_location_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - + + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta", "Clear delta location in addition to clearing the normal location transform"); @@ -316,14 +316,14 @@ void OBJECT_OT_rotation_clear(wmOperatorType *ot) ot->name = "Clear Rotation"; ot->description = "Clear the object's rotation"; ot->idname = "OBJECT_OT_rotation_clear"; - + /* api callbacks */ ot->exec = object_rotation_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta", "Clear delta rotation in addition to clearing the normal rotation transform"); @@ -340,14 +340,14 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) ot->name = "Clear Scale"; ot->description = "Clear the object's scale"; ot->idname = "OBJECT_OT_scale_clear"; - + /* api callbacks */ ot->exec = object_scale_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "clear_delta", false, "Clear Delta", "Clear delta scale in addition to clearing the normal scale transform"); @@ -366,7 +366,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) /* vectors pointed to by v1 and v3 will get modified */ v1 = ob->loc; v3 = ob->parentinv[3]; - + copy_m3_m4(mat, ob->parentinv); negate_v3_v3(v3, v1); mul_m3_v3(mat, v3); @@ -377,7 +377,7 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - + return OPERATOR_FINISHED; } @@ -387,11 +387,11 @@ void OBJECT_OT_origin_clear(wmOperatorType *ot) ot->name = "Clear Origin"; ot->description = "Clear the object's origin"; ot->idname = "OBJECT_OT_origin_clear"; - + /* api callbacks */ ot->exec = object_origin_clear_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -404,7 +404,7 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob) { Object workob; Object *ob_child; - + /* a change was made, adjust the children to compensate */ for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) { if (ob_child->parent == ob) { @@ -424,7 +424,7 @@ static int apply_objects_internal( Scene *scene = CTX_data_scene(C); float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale; bool changed = true; - + /* first check if we can execute */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -487,7 +487,7 @@ static int apply_objects_internal( } } CTX_DATA_END; - + if (!changed) return OPERATOR_CANCELLED; @@ -539,10 +539,10 @@ static int apply_objects_internal( if (apply_scale) multiresModifier_scale_disp(scene, ob); - + /* adjust data */ BKE_mesh_transform(me, mat, true); - + /* update normals */ BKE_mesh_calc_normals(me); } @@ -594,12 +594,12 @@ static int apply_objects_internal( BKE_tracking_reconstruction_scale(&clip->tracking, ob->size); } else if (ob->type == OB_EMPTY) { - /* It's possible for empties too, even though they don't + /* It's possible for empties too, even though they don't * really have obdata, since we can simply apply the maximum * scaling to the empty's drawsize. * * Core Assumptions: - * 1) Most scaled empties have uniform scaling + * 1) Most scaled empties have uniform scaling * (i.e. for visibility reasons), AND/OR * 2) Preserving non-uniform scaling is not that important, * and is something that many users would be willing to @@ -670,7 +670,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); bool changed = false; - + CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { BKE_object_where_is_calc(scene, ob); @@ -679,7 +679,7 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) /* update for any children that may get moved */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); - + changed = true; } CTX_DATA_END; @@ -697,11 +697,11 @@ void OBJECT_OT_visual_transform_apply(wmOperatorType *ot) ot->name = "Apply Visual Transform"; ot->description = "Apply the object's visual transformation to its data"; ot->idname = "OBJECT_OT_visual_transform_apply"; - + /* api callbacks */ ot->exec = visual_transform_apply_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -791,7 +791,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) BMEditMesh *em = me->edit_btmesh; BMVert *eve; BMIter iter; - + if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(cent, cursor); invert_m4_m4(obedit->imat, obedit->obmat); @@ -815,7 +815,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mid_v3_v3v3(cent, min, max); } } - + BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { sub_v3_v3(eve->co, cent); } @@ -868,7 +868,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } - + if (ob->data == NULL) { /* special support for dupligroups */ if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group && (ob->dup_group->id.tag & LIB_TAG_DOIT) == 0) { @@ -888,7 +888,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); } - + add_v3_v3(ob->dup_group->dupli_ofs, cent); tot_change++; @@ -1065,7 +1065,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) } ignore_parent_tx(bmain, scene, ob); - + /* other users? */ //CTX_DATA_BEGIN (C, Object *, ob_other, selected_editable_objects) //{ @@ -1136,27 +1136,27 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) "Calculate the center of mass from the volume (must be manifold geometry with consistent normals)"}, {0, NULL, 0, NULL, NULL} }; - + static const EnumPropertyItem prop_set_bounds_types[] = { {V3D_AROUND_CENTER_MEAN, "MEDIAN", 0, "Median Center", ""}, {V3D_AROUND_CENTER_BOUNDS, "BOUNDS", 0, "Bounds Center", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Set Origin"; ot->description = "Set the object's origin, by either moving the data, or set to center of data, or use 3D cursor"; ot->idname = "OBJECT_OT_origin_set"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = object_origin_set_exec; - + ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_AROUND_CENTER_MEAN, "Center", ""); } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index c6c20182ac3..fcb2d45f73b 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -769,7 +769,7 @@ static void ED_vgroup_nr_vert_add( /* get the vert */ BKE_object_defgroup_array_get(ob->data, &dvert, &tot); - + if (dvert == NULL) return; @@ -934,7 +934,7 @@ static float get_vert_def_nr(Object *ob, const int def_nr, const int vertnum) dv = <->dvert[vertnum]; } } - + if (dv) { MDeformWeight *dw = defvert_find_index(dv, def_nr); if (dw) { @@ -1021,12 +1021,12 @@ static void vgroup_select_verts(Object *ob, int select) } else if (ob->type == OB_LATTICE) { Lattice *lt = vgroup_edit_lattice(ob); - + if (lt->dvert) { MDeformVert *dv; BPoint *bp, *actbp = BKE_lattice_active_point_get(lt); int a, tot; - + dv = lt->dvert; tot = lt->pntsu * lt->pntsv * lt->pntsw; @@ -1054,7 +1054,7 @@ static void vgroup_duplicate(Object *ob) dg = BLI_findlink(&ob->defbase, (ob->actdef - 1)); if (!dg) return; - + if (!strstr(dg->name, "_copy")) { BLI_snprintf(name, sizeof(name), "%s_copy", dg->name); } @@ -1124,7 +1124,7 @@ static bool vgroup_normalize(Object *ob) if (weight_max > 0.0f) { for (i = 0; i < dvert_tot; i++) { - + /* in case its not selected */ if (!(dv = dvert_array[i])) { continue; @@ -1133,7 +1133,7 @@ static bool vgroup_normalize(Object *ob) dw = defvert_find_index(dv, def_nr); if (dw) { dw->weight /= weight_max; - + /* in case of division errors with very low weights */ CLAMP(dw->weight, 0.0f, 1.0f); } @@ -1458,7 +1458,7 @@ static void moveCloserToDistanceFromPlane( MEM_freeN(dwIndices); } -/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex +/* this is used to try to smooth a surface by only adjusting the nonzero weights of a vertex * but it could be used to raise or lower an existing 'bump.' */ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, float cp) { @@ -1483,7 +1483,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, dm->getVert(dm, verts[k], &m); p[k] = m; } - + if (count >= 3) { float d /*, dist */ /* UNUSED */, mag; float coord[3]; @@ -2638,7 +2638,7 @@ static int vertex_group_add_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -2648,7 +2648,7 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot) ot->name = "Add Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_add"; ot->description = "Add a new vertex group to the active object"; - + /* api callbacks */ ot->poll = vertex_group_supported_poll; ot->exec = vertex_group_add_exec; @@ -2671,7 +2671,7 @@ static int vertex_group_remove_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_VERTEX_GROUP, ob->data); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); - + return OPERATOR_FINISHED; } @@ -2681,7 +2681,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) ot->name = "Remove Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove"; ot->description = "Delete the active or all vertex groups from the active object"; - + /* api callbacks */ ot->poll = vertex_group_poll; ot->exec = vertex_group_remove_exec; @@ -2701,11 +2701,11 @@ static int vertex_group_assign_exec(bContext *C, wmOperator *UNUSED(op)) { ToolSettings *ts = CTX_data_tool_settings(C); Object *ob = ED_object_context(C); - + vgroup_assign_verts(ob, ts->vgroup_weight); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - + return OPERATOR_FINISHED; } @@ -2715,7 +2715,7 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) ot->name = "Assign to Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_assign"; ot->description = "Assign the selected vertices to the active vertex group"; - + /* api callbacks */ ot->poll = vertex_group_vert_select_unlocked_poll; ot->exec = vertex_group_assign_exec; @@ -2733,7 +2733,7 @@ static int vertex_group_assign_new_exec(bContext *C, wmOperator *op) /* create new group... */ Object *ob = ED_object_context(C); BKE_object_defgroup_add(ob); - + /* assign selection to new group */ return vertex_group_assign_exec(C, op); } @@ -2744,11 +2744,11 @@ void OBJECT_OT_vertex_group_assign_new(wmOperatorType *ot) ot->name = "Assign to New Group"; ot->idname = "OBJECT_OT_vertex_group_assign_new"; ot->description = "Assign the selected vertices to a new vertex group"; - + /* api callbacks */ ot->poll = vertex_group_vert_select_poll; ot->exec = vertex_group_assign_new_exec; - + /* flags */ /* redo operator will fail in this case because vertex group assignment * isn't stored in local edit mode stack and toggling "new" property will @@ -2890,7 +2890,7 @@ void OBJECT_OT_vertex_group_copy(wmOperatorType *ot) static int vertex_group_levels_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - + float offset = RNA_float_get(op->ptr, "offset"); float gain = RNA_float_get(op->ptr, "gain"); eVGroupSelect subset_type = RNA_enum_get(op->ptr, "group_select_mode"); @@ -2900,11 +2900,11 @@ static int vertex_group_levels_exec(bContext *C, wmOperator *op) const bool *vgroup_validmap = BKE_object_defgroup_subset_from_select_type(ob, subset_type, &vgroup_tot, &subset_count); vgroup_levels_subset(ob, vgroup_validmap, vgroup_tot, subset_count, offset, gain); MEM_freeN((void *)vgroup_validmap); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - + return OPERATOR_FINISHED; } @@ -2914,14 +2914,14 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) ot->name = "Vertex Group Levels"; ot->idname = "OBJECT_OT_vertex_group_levels"; ot->description = "Add some offset and multiply with some gain the weights of the active vertex group"; - + /* api callbacks */ ot->poll = vertex_group_poll; ot->exec = vertex_group_levels_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + vgroup_operator_subset_select_props(ot, true); RNA_def_float(ot->srna, "offset", 0.f, -1.0, 1.0, "Offset", "Value to add to weights", -1.0f, 1.f); RNA_def_float(ot->srna, "gain", 1.f, 0.f, FLT_MAX, "Gain", "Value to multiply weights by", 0.0f, 10.f); @@ -3010,7 +3010,7 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - + float distToBe = RNA_float_get(op->ptr, "dist"); float strength = RNA_float_get(op->ptr, "strength"); float cp = RNA_float_get(op->ptr, "accuracy"); @@ -3022,17 +3022,17 @@ static int vertex_group_fix_exec(bContext *C, wmOperator *op) } md = md->next; } - + if (md && md->type == eModifierType_Mirror) { BKE_report(op->reports, RPT_ERROR_INVALID_CONTEXT, "This operator does not support an active mirror modifier"); return OPERATOR_CANCELLED; } vgroup_fix(scene, ob, distToBe, strength, cp); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - + return OPERATOR_FINISHED; } @@ -3043,11 +3043,11 @@ void OBJECT_OT_vertex_group_fix(wmOperatorType *ot) ot->idname = "OBJECT_OT_vertex_group_fix"; ot->description = "Modify the position of selected vertices by changing only their respective " "groups' weights (this tool may be slow for many vertices)"; - + /* api callbacks */ ot->poll = vertex_group_mesh_poll; ot->exec = vertex_group_fix_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float(ot->srna, "dist", 0.0f, -FLT_MAX, FLT_MAX, "Distance", "The distance to move to", -10.0f, 10.0f); @@ -3444,16 +3444,16 @@ static int set_active_group_exec(bContext *C, wmOperator *op) } static const EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) -{ +{ Object *ob = ED_object_context(C); EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item = NULL; bDeformGroup *def; int a, totitem = 0; - + if (!ob) return DummyRNA_NULL_items; - + for (a = 0, def = ob->defbase.first; def; def = def->next, a++) { tmp.value = a; tmp.icon = ICON_GROUP_VERTEX; @@ -3578,7 +3578,7 @@ static int vgroup_do_remap(Object *ob, const char *name_array, wmOperator *op) BLI_assert(sort_map_update[ob->actdef] >= 0); ob->actdef = sort_map_update[ob->actdef]; - + MEM_freeN(sort_map_update); return OPERATOR_FINISHED; @@ -3646,7 +3646,7 @@ static int vertex_group_sort_exec(bContext *C, wmOperator *op) vgroup_sort_bone_hierarchy(ob, NULL); break; } - + /*remap vgroup data to map to correct names*/ ret = vgroup_do_remap(ob, name_array, op); diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 4f516ec9c51..d63c28bb0cf 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -100,7 +100,7 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot) ot->name = "Add Surface Slot"; ot->idname = "DPAINT_OT_surface_slot_add"; ot->description = "Add a new Dynamic Paint surface slot"; - + /* api callbacks */ ot->exec = surface_slot_add_exec; ot->poll = ED_operator_object_active_editable; @@ -148,7 +148,7 @@ void DPAINT_OT_surface_slot_remove(wmOperatorType *ot) ot->name = "Remove Surface Slot"; ot->idname = "DPAINT_OT_surface_slot_remove"; ot->description = "Remove the selected surface slot"; - + /* api callbacks */ ot->exec = surface_slot_remove_exec; ot->poll = ED_operator_object_active_editable; @@ -179,7 +179,7 @@ static int type_toggle_exec(bContext *C, wmOperator *op) if (!dynamicPaint_createType(pmd, type, scene)) return OPERATOR_CANCELLED; } - + /* update dependency */ DAG_id_tag_update(&cObject->id, OB_RECALC_DATA); DAG_relations_tag_update(CTX_data_main(C)); @@ -196,14 +196,14 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot) ot->name = "Toggle Type Active"; ot->idname = "DPAINT_OT_type_toggle"; ot->description = "Toggle whether given type is active or not"; - + /* api callbacks */ ot->exec = type_toggle_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_enum(ot->srna, "type", rna_enum_prop_dynamicpaint_type_items, MOD_DYNAMICPAINT_TYPE_CANVAS, "Type", ""); ot->prop = prop; @@ -223,7 +223,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op) if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) { int exists = dynamicPaint_outputLayerExists(surface, ob, output); const char *name; - + if (output == 0) name = surface->output_name; else @@ -233,7 +233,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op) if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { if (!exists) ED_mesh_color_add(ob->data, name, true); - else + else ED_mesh_color_remove_named(ob->data, name); } /* Vertex Weight Layer */ @@ -263,14 +263,14 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot) ot->name = "Toggle Output Layer"; ot->idname = "DPAINT_OT_output_toggle"; ot->description = "Add or remove Dynamic Paint output data layer"; - + /* api callbacks */ ot->exec = output_toggle_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "output", prop_output_toggle_types, 0, "Output Toggle", ""); } @@ -505,7 +505,7 @@ void DPAINT_OT_bake(wmOperatorType *ot) ot->name = "Dynamic Paint Bake"; ot->description = "Bake dynamic paint image sequence surface"; ot->idname = "DPAINT_OT_bake"; - + /* api callbacks */ ot->exec = dynamicpaint_bake_exec; ot->poll = ED_operator_object_active_editable; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index cac96030b96..526eeb5d3ea 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -76,7 +76,7 @@ static int rule_add_exec(bContext *C, wmOperator *op) BLI_addtail(&state->rules, rule); DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); - + return OPERATOR_FINISHED; } @@ -86,14 +86,14 @@ void BOID_OT_rule_add(wmOperatorType *ot) ot->name = "Add Boid Rule"; ot->description = "Add a boid rule to the current boid state"; ot->idname = "BOID_OT_rule_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = rule_add_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - + ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_boidrule_type_items, 0, "Type", ""); } static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) @@ -133,7 +133,7 @@ void BOID_OT_rule_del(wmOperatorType *ot) ot->name = "Remove Boid Rule"; ot->idname = "BOID_OT_rule_del"; ot->description = "Delete current boid rule"; - + /* api callbacks */ ot->exec = rule_del_exec; @@ -151,7 +151,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op)) if (!part || part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; - + state = boid_get_current_state(part->boids); for (rule = state->rules.first; rule; rule=rule->next) { if (rule->flag & BOIDRULE_CURRENT && rule->prev) { @@ -162,7 +162,7 @@ static int rule_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -173,7 +173,7 @@ void BOID_OT_rule_move_up(wmOperatorType *ot) ot->idname = "BOID_OT_rule_move_up"; ot->exec = rule_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -187,7 +187,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op)) if (!part || part->phystype != PART_PHYS_BOIDS) return OPERATOR_CANCELLED; - + state = boid_get_current_state(part->boids); for (rule = state->rules.first; rule; rule=rule->next) { if (rule->flag & BOIDRULE_CURRENT && rule->next) { @@ -198,7 +198,7 @@ static int rule_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -209,7 +209,7 @@ void BOID_OT_rule_move_down(wmOperatorType *ot) ot->idname = "BOID_OT_rule_move_down"; ot->exec = rule_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -242,10 +242,10 @@ void BOID_OT_state_add(wmOperatorType *ot) ot->name = "Add Boid State"; ot->description = "Add a boid state to the particle system"; ot->idname = "BOID_OT_state_add"; - + /* api callbacks */ ot->exec = state_add_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -279,7 +279,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) DAG_relations_tag_update(bmain); DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); - + return OPERATOR_FINISHED; } @@ -289,7 +289,7 @@ void BOID_OT_state_del(wmOperatorType *ot) ot->name = "Remove Boid State"; ot->idname = "BOID_OT_state_del"; ot->description = "Delete current boid state"; - + /* api callbacks */ ot->exec = state_del_exec; @@ -309,7 +309,7 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; boids = part->boids; - + for (state = boids->states.first; state; state=state->next) { if (state->flag & BOIDSTATE_CURRENT && state->prev) { BLI_remlink(&boids->states, state); @@ -317,7 +317,7 @@ static int state_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -328,7 +328,7 @@ void BOID_OT_state_move_up(wmOperatorType *ot) ot->idname = "BOID_OT_state_move_up"; ot->exec = state_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -344,7 +344,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; boids = part->boids; - + for (state = boids->states.first; state; state=state->next) { if (state->flag & BOIDSTATE_CURRENT && state->next) { BLI_remlink(&boids->states, state); @@ -353,7 +353,7 @@ static int state_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -364,7 +364,7 @@ void BOID_OT_state_move_down(wmOperatorType *ot) ot->idname = "BOID_OT_state_move_down"; ot->exec = state_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index c05bf4f7dea..2a15fb21fb8 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -92,7 +92,7 @@ int PE_poll(bContext *C) if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; - + return (PE_get_current(scene, ob) != NULL); } @@ -104,7 +104,7 @@ int PE_hair_poll(bContext *C) if (!scene || !ob || !(ob->mode & OB_MODE_PARTICLE_EDIT)) return 0; - + edit= PE_get_current(scene, ob); return (edit && edit->psys); @@ -179,7 +179,7 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br // here we can enable unified brush size, needs more work... // UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; // float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size; - + return brush->size * U.pixelsize; } @@ -320,7 +320,7 @@ static int pe_x_mirror(Object *ob) { if (ob->type == OB_MESH) return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X); - + return 0; } @@ -329,7 +329,7 @@ static int pe_x_mirror(Object *ob) typedef struct PEData { ViewContext vc; bglMats mats; - + Scene *scene; Object *ob; DerivedMesh *dm; @@ -394,13 +394,13 @@ static void PE_set_view3d_data(bContext *C, PEData *data) static bool PE_create_shape_tree(PEData *data, Object *shapeob) { DerivedMesh *dm = shapeob->derivedFinal; - + memset(&data->shape_bvh, 0, sizeof(data->shape_bvh)); - + if (!dm) { return false; } - + return (bvhtree_from_mesh_get(&data->shape_bvh, dm, BVHTREE_FROM_LOOPTRI, 4) != NULL); } @@ -472,7 +472,7 @@ static bool key_inside_circle(PEData *data, float rad, const float co[3], float return 1; } - + return 0; } @@ -511,7 +511,7 @@ static bool point_is_selected(PTCacheEditPoint *point) LOOP_SELECTED_KEYS { return 1; } - + return 0; } @@ -756,7 +756,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) /* lookup particles and set in mirror cache */ if (!edit->mirror_cache) edit->mirror_cache= MEM_callocN(sizeof(int)*totpart, "PE mirror cache"); - + LOOP_PARTICLES { key = pa->hair; psys_mat_hair_to_orco(ob, psmd->dm_final, psys->part->from, pa, mat); @@ -801,7 +801,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys if (!mpa) { if (!edit->mirror_cache) PE_update_mirror_cache(ob, psys); - + if (!edit->mirror_cache) return; /* something went wrong! */ @@ -927,7 +927,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) LOOP_EDITED_POINTS { psys_mat_hair_to_object(ob, psmd->dm_final, psys->part->from, psys->particles + p, hairmat); - + LOOP_KEYS { mul_m4_v3(hairmat, key->co); } @@ -939,7 +939,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) } else { index= BLI_kdtree_find_nearest(edit->emitter_field, key->co, NULL); - + vec=edit->emitter_cosnos +index*6; nor=vec+3; @@ -964,7 +964,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) dist_1st*=1.3333f; } } - + invert_m4_m4(hairimat, hairmat); LOOP_KEYS { @@ -975,7 +975,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit) /* force set distances between neighboring keys */ static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit) { - + ParticleEditSettings *pset=PE_settings(scene); POINT_P; KEY_K; float dv1[3]; @@ -1114,7 +1114,7 @@ void recalc_emitter_field(Object *ob, ParticleSystem *psys) mvert=dm->getVertData(dm, mface->v4, CD_MVERT); add_v3_v3v3(vec, vec, mvert->co); VECADD(nor, nor, mvert->no); - + mul_v3_fl(vec, 0.25); } else @@ -1139,7 +1139,7 @@ static void PE_update_selection(Scene *scene, Object *ob, int useflag) LOOP_POINTS point->flag |= PEP_EDIT_RECALC; - /* flush edit key flag to hair key flag to preserve selection + /* flush edit key flag to hair key flag to preserve selection * on save */ if (edit->psys) LOOP_POINTS { hkey = edit->psys->particles[p].hair; @@ -1224,7 +1224,7 @@ static void update_velocities(PTCacheEdit *edit) } else { dfra = *(key+1)->time - *(key-1)->time; - + if (dfra <= 0.0f) continue; @@ -1411,7 +1411,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All"; ot->idname = "PARTICLE_OT_select_all"; ot->description = "(De)select all particles' keys"; - + /* api callbacks */ ot->exec = pe_select_all_exec; ot->poll = PE_poll; @@ -1431,7 +1431,7 @@ int PE_mouse_particles(bContext *C, const int mval[2], bool extend, bool deselec Object *ob= CTX_data_active_object(C); PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; @@ -1471,7 +1471,7 @@ static void select_root(PEData *data, int point_index) if (point->flag & PEP_HIDE) return; - + if (data->select_action != SEL_TOGGLE) select_action_apply(point, key, data->select_action); else if (key->flag & PEK_SELECT) @@ -1509,7 +1509,7 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot) ot->name = "Select Roots"; ot->idname = "PARTICLE_OT_select_roots"; ot->description = "Select roots of all visible particles"; - + /* api callbacks */ ot->exec = select_roots_exec; ot->poll = PE_poll; @@ -1533,10 +1533,10 @@ static void select_tip(PEData *data, int point_index) } key = &point->keys[point->totkey - 1]; - + if (point->flag & PEP_HIDE) return; - + if (data->select_action != SEL_TOGGLE) select_action_apply(point, key, data->select_action); else if (key->flag & PEK_SELECT) @@ -1708,7 +1708,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "PARTICLE_OT_select_linked"; ot->description = "Select nearest particle from mouse pointer"; - + /* api callbacks */ ot->exec = select_linked_exec; ot->invoke = select_linked_invoke; @@ -1881,7 +1881,7 @@ static int hide_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); PTCacheEdit *edit= PE_get_current(scene, ob); POINT_P; KEY_K; - + if (RNA_enum_get(op->ptr, "unselected")) { LOOP_UNSELECTED_POINTS { point->flag |= PEP_HIDE; @@ -1913,7 +1913,7 @@ void PARTICLE_OT_hide(wmOperatorType *ot) ot->name = "Hide Selected"; ot->idname = "PARTICLE_OT_hide"; ot->description = "Hide selected particles"; - + /* api callbacks */ ot->exec = hide_exec; ot->poll = PE_poll; @@ -1958,7 +1958,7 @@ void PARTICLE_OT_reveal(wmOperatorType *ot) ot->name = "Reveal"; ot->idname = "PARTICLE_OT_reveal"; ot->description = "Show hidden particles"; - + /* api callbacks */ ot->exec = reveal_exec; ot->poll = PE_poll; @@ -2020,7 +2020,7 @@ void PARTICLE_OT_select_less(wmOperatorType *ot) ot->name = "Select Less"; ot->idname = "PARTICLE_OT_select_less"; ot->description = "Deselect boundary selected keys of each particle"; - + /* api callbacks */ ot->exec = select_less_exec; ot->poll = PE_poll; @@ -2082,7 +2082,7 @@ void PARTICLE_OT_select_more(wmOperatorType *ot) ot->name = "Select More"; ot->idname = "PARTICLE_OT_select_more"; ot->description = "Select keys linked to boundary selected keys of each particle"; - + /* api callbacks */ ot->exec = select_more_exec; ot->poll = PE_poll; @@ -2142,7 +2142,7 @@ static void rekey_particle(PEData *data, int pa_index) if (point->keys) MEM_freeN(point->keys); ekey= point->keys= MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys"); - + for (k=0, key=pa->hair; ktotkey; k++, key++, ekey++) { ekey->co= key->co; ekey->time= &key->time; @@ -2165,7 +2165,7 @@ static int rekey_exec(bContext *C, wmOperator *op) data.totrekey= RNA_int_get(op->ptr, "keys_number"); foreach_selected_point(&data, rekey_particle); - + recalc_lengths(data.edit); PE_update_object(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); @@ -2179,7 +2179,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot) ot->name = "Rekey"; ot->idname = "PARTICLE_OT_rekey"; ot->description = "Change the number of keys of selected particles (root and tip keys included)"; - + /* api callbacks */ ot->exec = rekey_exec; ot->invoke = WM_operator_props_popup; @@ -2216,7 +2216,7 @@ static void rekey_particle_to_time(Scene *scene, Object *ob, int pa_index, float pa->flag |= PARS_REKEY; key= new_keys= MEM_dupallocN(pa->hair); - + /* interpolate new keys from old ones (roots stay the same) */ for (k=1, key++; k < pa->totkey; k++, key++) { state.time= path_time * (float)k / (float)(pa->totkey-1); @@ -2375,7 +2375,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) nhkey->editflag = hkey->editflag; nhkey->time= hkey->time; nhkey->weight= hkey->weight; - + nkey->co= nhkey->co; nkey->time= &nhkey->time; /* these can be copied from old edit keys */ @@ -2394,7 +2394,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys) if (point->keys) MEM_freeN(point->keys); - + pa->hair= new_hkeys; point->keys= new_keys; @@ -2439,7 +2439,7 @@ static void subdivide_particle(PEData *data, int pa_index) nkey= new_keys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(HairKey)), "Hair subdivide keys"); nekey= new_ekeys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(PTCacheEditKey)), "Hair subdivide edit keys"); - + key = pa->hair; endtime= key[pa->totkey-1].time; @@ -2496,7 +2496,7 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op)) PE_set_data(C, &data); foreach_point(&data, subdivide_particle); - + recalc_lengths(data.edit); PE_update_object(data.scene, data.ob, 1); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob); @@ -2510,7 +2510,7 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot) ot->name = "Subdivide"; ot->idname = "PARTICLE_OT_subdivide"; ot->description = "Subdivide selected particles segments (adds keys)"; - + /* api callbacks */ ot->exec = subdivide_exec; ot->poll = PE_hair_poll; @@ -2545,7 +2545,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op) removed= 0; tree=BLI_kdtree_new(psys->totpart); - + /* insert particles into kd tree */ LOOP_SELECTED_POINTS { psys_mat_hair_to_object(ob, psmd->dm_final, psys->part->from, psys->particles+p, mat); @@ -2599,7 +2599,7 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) ot->name = "Remove Doubles"; ot->idname = "PARTICLE_OT_remove_doubles"; ot->description = "Remove selected particles close enough of others"; - + /* api callbacks */ ot->exec = remove_doubles_exec; ot->poll = PE_hair_poll; @@ -2687,7 +2687,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) glutil_draw_lined_arc(0.0, M_PI*2.0, pe_brush_size_get(scene, brush), 40); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); - + glPopMatrix(); } } @@ -2757,7 +2757,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->idname = "PARTICLE_OT_delete"; ot->description = "Delete selected particles or keys"; - + /* api callbacks */ ot->exec = delete_exec; ot->invoke = WM_menu_invoke; @@ -2850,7 +2850,7 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) } edit->totpoint= psys->totpart= newtotpart; - + /* create new elements */ newpa= psys->particles + totpart; newpoint= edit->points + totpart; @@ -2925,7 +2925,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); PTCacheEdit *edit= PE_get_current(scene, ob); - + PE_mirror_x(scene, ob, 0); update_world_cos(ob, edit); @@ -2941,7 +2941,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) ot->name = "Mirror"; ot->idname = "PARTICLE_OT_mirror"; ot->description = "Duplicate and mirror the selected particles along the local X axis"; - + /* api callbacks */ ot->exec = mirror_exec; ot->poll = PE_hair_poll; @@ -3000,7 +3000,7 @@ static void brush_cut(PEData *data, int pa_index) o0= (float)data->mval[0]; o1= (float)data->mval[1]; - + xo0= x0 - o0; xo1= x1 - o1; @@ -3030,7 +3030,7 @@ static void brush_cut(PEData *data, int pa_index) dv= v0*v0 + v1*v1; d= (v0*xo1 - v1*xo0); - + d= dv * rad2 - d*d; if (d > 0.0f) { @@ -3263,7 +3263,7 @@ static void BKE_brush_weight_get(PEData *data, float UNUSED(mat[4][4]), float UN } static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4][4]), int UNUSED(point_index), int key_index, PTCacheEditKey *key) -{ +{ if (key_index) { float dvec[3]; @@ -3277,7 +3277,7 @@ static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4] static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4][4], int point_index, int key_index, PTCacheEditKey *key) { float vec[3], dvec[3]; - + if (key_index) { copy_v3_v3(vec, data->vec); mul_mat3_m4_v3(imat, vec); @@ -3286,7 +3286,7 @@ static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4] sub_v3_v3v3(dvec, vec, dvec); mul_v3_fl(dvec, data->smoothfac); - + add_v3_v3(key->co, dvec); } @@ -3323,7 +3323,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, int i, totface, intersect=0; float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3]; float cur_ipoint[3]; - + if (dm == NULL) { psys_disable_all(ob); @@ -3339,7 +3339,7 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, /* BMESH_ONLY, deform dm may not have tessface */ DM_ensure_tessface(dm); - + if (pa_minmax==0) { INIT_MINMAX(p_min, p_max); @@ -3509,7 +3509,7 @@ static int brush_add(PEData *data, short number) mul_m4_v3(imat, co1); mul_m4_v3(imat, co2); min_d=2.0; - + /* warning, returns the derived mesh face */ if (particle_intersect_dm(scene, ob, dm, 0, co1, co2, &min_d, &add_pars[n].num_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) { if (psys->part->use_modifier_stack && !psmd->dm_final->deformedOnly) { @@ -3560,7 +3560,7 @@ static int brush_add(PEData *data, short number) /* create tree for interpolation */ if (pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) { tree=BLI_kdtree_new(psys->totpart); - + for (i=0, pa=psys->particles; idm_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, cur_co, 0, 0, 0, 0, 0); BLI_kdtree_insert(tree, i, cur_co); @@ -3588,14 +3588,14 @@ static int brush_add(PEData *data, short number) if (!(psys->flag & PSYS_GLOBAL_HAIR)) key->flag |= PEK_USE_WCO; } - + pa->size= 1.0f; initialize_particle(&sim, pa); reset_particle(&sim, pa, 0.0, 1.0); point->flag |= PEP_EDIT_RECALC; if (pe_x_mirror(ob)) point->flag |= PEP_TAG; /* signal for duplicate */ - + framestep= pa->lifetime/(float)(pset->totaddkey-1); if (tree) { @@ -3610,7 +3610,7 @@ static int brush_add(PEData *data, short number) maxw = BLI_kdtree_find_nearest_n(tree, co1, ptn, 3); maxd= ptn[maxw-1].dist; - + for (w=0; wtime/ 100.0f; psys_get_particle_on_path(&sim, ptn[0].index, key3, 0); mul_v3_fl(key3[0].co, weight[0]); - + /* TODO: interpolating the weight would be nicer */ thkey->weight= (ppa->hair+MIN2(k, ppa->totkey-1))->weight; - + if (maxw>1) { key3[1].time= key3[0].time; psys_get_particle_on_path(&sim, ptn[1].index, &key3[1], 0); @@ -3684,7 +3684,7 @@ static int brush_add(PEData *data, short number) MEM_freeN(add_pars); BLI_rng_free(rng); - + return n; } @@ -3712,7 +3712,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) ARegion *ar= CTX_wm_region(C); BrushEdit *bedit; float min[3], max[3]; - + if (pset->brushtype < 0) return 0; @@ -3840,7 +3840,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) case PE_BRUSH_LENGTH: { data.mval= mval; - + data.rad= pe_brush_size_get(scene, brush); data.growfac= brush->strength / 50.0f; @@ -4001,7 +4001,7 @@ static int brush_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event) { if (!brush_edit_init(C, op)) return OPERATOR_CANCELLED; - + brush_edit_apply_event(C, op, event); WM_event_add_modal_handler(C, op); @@ -4036,7 +4036,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot) ot->name = "Brush Edit"; ot->idname = "PARTICLE_OT_brush_edit"; ot->description = "Apply a stroke of brush to the particles"; - + /* api callbacks */ ot->exec = brush_edit_exec; ot->invoke = brush_edit_invoke; @@ -4060,12 +4060,12 @@ static int shape_cut_poll(bContext *C) if (PE_hair_poll(C)) { Scene *scene = CTX_data_scene(C); ParticleEditSettings *pset = PE_settings(scene); - + if (pset->shape_object && (pset->shape_object->type == OB_MESH)) { return true; } } - + return false; } @@ -4077,9 +4077,9 @@ typedef struct PointInsideBVH { static void point_inside_bvh_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) { PointInsideBVH *data = userdata; - + data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit); - + if (hit->index != -1) ++data->num_hits; } @@ -4090,14 +4090,14 @@ static bool shape_cut_test_point(PEData *data, ParticleCacheKey *key) BVHTreeFromMesh *shape_bvh = &data->shape_bvh; const float dir[3] = {1.0f, 0.0f, 0.0f}; PointInsideBVH userdata; - + userdata.bvhdata = data->shape_bvh; userdata.num_hits = 0; - + BLI_bvhtree_ray_cast_all( shape_bvh->tree, key->co, dir, 0.0f, BVH_RAYCAST_DIST_MAX, point_inside_bvh_cb, &userdata); - + /* for any point inside a watertight mesh the number of hits is uneven */ return (userdata.num_hits % 2) == 1; } @@ -4108,17 +4108,17 @@ static void shape_cut(PEData *data, int pa_index) Object *ob = data->ob; ParticleEditSettings *pset = PE_settings(data->scene); ParticleCacheKey *key; - + bool cut; float cut_time = 1.0; int k, totkeys = 1 << pset->draw_step; - + /* don't cut hidden */ if (edit->points[pa_index].flag & PEP_HIDE) return; - + cut = false; - + /* check if root is inside the cut shape */ key = edit->pathcache[pa_index]; if (!shape_cut_test_point(data, key)) { @@ -4130,10 +4130,10 @@ static void shape_cut(PEData *data, int pa_index) BVHTreeRayHit hit; float dir[3]; float len; - + sub_v3_v3v3(dir, (key+1)->co, key->co); len = normalize_v3(dir); - + memset(&hit, 0, sizeof(hit)); hit.index = -1; hit.dist = len; @@ -4168,32 +4168,32 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) Object *shapeob = pset->shape_object; int selected = count_selected_keys(scene, edit); int lock_root = pset->flag & PE_LOCK_FIRST; - + if (!PE_start_edit(edit)) return OPERATOR_CANCELLED; - + /* disable locking temporatily for disconnected hair */ if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR) pset->flag &= ~PE_LOCK_FIRST; - + if (edit->psys && edit->pathcache) { PEData data; int removed; - + PE_set_data(C, &data); if (!PE_create_shape_tree(&data, shapeob)) { /* shapeob may not have faces... */ return OPERATOR_CANCELLED; } - + if (selected) foreach_selected_point(&data, shape_cut); else foreach_point(&data, shape_cut); - + removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob)); recalc_lengths(edit); - + if (removed) { update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); @@ -4201,7 +4201,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) } else PE_update_object(scene, ob, 1); - + if (edit->psys) { WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); } @@ -4209,12 +4209,12 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); } - + PE_free_shape_tree(&data); } - + pset->flag |= lock_root; - + return OPERATOR_FINISHED; } @@ -4224,7 +4224,7 @@ void PARTICLE_OT_shape_cut(wmOperatorType *ot) ot->name = "Shape Cut"; ot->idname = "PARTICLE_OT_shape_cut"; ot->description = "Cut hair to conform to the set shape object"; - + /* api callbacks */ ot->exec = shape_cut_exec; ot->poll = shape_cut_poll; @@ -4413,12 +4413,12 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op) PTCacheEdit *edit; ob->mode |= mode_flag; edit= PE_create_current(scene, ob); - + /* mesh may have changed since last entering editmode. * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */ if (edit && edit->psys) recalc_emitter_field(ob, edit->psys); - + toggle_particle_cursor(C, 1); WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL); } @@ -4439,7 +4439,7 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot) ot->name = "Particle Edit Toggle"; ot->idname = "PARTICLE_OT_particle_edit_toggle"; ot->description = "Toggle particle edit mode"; - + /* api callbacks */ ot->exec = particle_edit_toggle_exec; ot->poll = particle_edit_toggle_poll; @@ -4455,7 +4455,7 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob= CTX_data_active_object(C); ParticleSystem *psys = psys_get_current(ob); - + if (psys->edit) { if (psys->edit->edited || 1) { PE_free_ptcache_edit(psys->edit); @@ -4494,7 +4494,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot) ot->name = "Clear Edited"; ot->idname = "PARTICLE_OT_edited_clear"; ot->description = "Undo all edition performed on the particle system"; - + /* api callbacks */ ot->exec = clear_edited_exec; ot->poll = particle_edit_toggle_poll; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index c4bcb6a8469..8a363276c28 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -84,10 +84,10 @@ static int particle_system_add_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; object_add_particle_system(scene, ob, NULL); - + WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); - + return OPERATOR_FINISHED; } @@ -97,11 +97,11 @@ void OBJECT_OT_particle_system_add(wmOperatorType *ot) ot->name = "Add Particle System Slot"; ot->idname = "OBJECT_OT_particle_system_add"; ot->description = "Add a particle system"; - + /* api callbacks */ ot->poll = ED_operator_object_active_editable; ot->exec = particle_system_add_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -131,7 +131,7 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); - + return OPERATOR_FINISHED; } @@ -141,7 +141,7 @@ void OBJECT_OT_particle_system_remove(wmOperatorType *ot) ot->name = "Remove Particle System Slot"; ot->idname = "OBJECT_OT_particle_system_remove"; ot->description = "Remove the selected particle system"; - + /* api callbacks */ ot->poll = ED_operator_object_active_editable; ot->exec = particle_system_remove_exec; @@ -189,7 +189,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); - + return OPERATOR_FINISHED; } @@ -199,7 +199,7 @@ void PARTICLE_OT_new(wmOperatorType *ot) ot->name = "New Particle Settings"; ot->idname = "PARTICLE_OT_new"; ot->description = "Add new particle settings"; - + /* api callbacks */ ot->exec = new_particle_settings_exec; ot->poll = psys_poll; @@ -237,7 +237,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); - + return OPERATOR_FINISHED; } @@ -247,7 +247,7 @@ void PARTICLE_OT_new_target(wmOperatorType *ot) ot->name = "New Particle Target"; ot->idname = "PARTICLE_OT_new_target"; ot->description = "Add a new particle target"; - + /* api callbacks */ ot->exec = new_particle_target_exec; @@ -285,7 +285,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); - + return OPERATOR_FINISHED; } @@ -295,7 +295,7 @@ void PARTICLE_OT_target_remove(wmOperatorType *ot) ot->name = "Remove Particle Target"; ot->idname = "PARTICLE_OT_target_remove"; ot->description = "Remove the selected particle target"; - + /* api callbacks */ ot->exec = remove_particle_target_exec; @@ -314,7 +314,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op)) if (!psys) return OPERATOR_CANCELLED; - + pt = psys->targets.first; for (; pt; pt=pt->next) { if (pt->flag & PTARGET_CURRENT && pt->prev) { @@ -326,7 +326,7 @@ static int target_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -335,9 +335,9 @@ void PARTICLE_OT_target_move_up(wmOperatorType *ot) ot->name = "Move Up Target"; ot->idname = "PARTICLE_OT_target_move_up"; ot->description = "Move particle target up in the list"; - + ot->exec = target_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -364,7 +364,7 @@ static int target_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -373,9 +373,9 @@ void PARTICLE_OT_target_move_down(wmOperatorType *ot) ot->name = "Move Down Target"; ot->idname = "PARTICLE_OT_target_move_down"; ot->description = "Move particle target down in the list"; - + ot->exec = target_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -402,7 +402,7 @@ static int dupliob_move_up_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -411,9 +411,9 @@ void PARTICLE_OT_dupliob_move_up(wmOperatorType *ot) ot->name = "Move Up Dupli Object"; ot->idname = "PARTICLE_OT_dupliob_move_up"; ot->description = "Move dupli object up in the list"; - + ot->exec = dupliob_move_up_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -441,7 +441,7 @@ static int copy_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -451,7 +451,7 @@ void PARTICLE_OT_dupliob_copy(wmOperatorType *ot) ot->name = "Copy Particle Dupliob"; ot->idname = "PARTICLE_OT_dupliob_copy"; ot->description = "Duplicate the current dupliobject"; - + /* api callbacks */ ot->exec = copy_particle_dupliob_exec; @@ -484,7 +484,7 @@ static int remove_particle_dupliob_exec(bContext *C, wmOperator *UNUSED(op)) dw->flag |= PART_DUPLIW_CURRENT; WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, NULL); - + return OPERATOR_FINISHED; } @@ -494,7 +494,7 @@ void PARTICLE_OT_dupliob_remove(wmOperatorType *ot) ot->name = "Remove Particle Dupliobject"; ot->idname = "PARTICLE_OT_dupliob_remove"; ot->description = "Remove the selected dupliobject"; - + /* api callbacks */ ot->exec = remove_particle_dupliob_exec; @@ -524,7 +524,7 @@ static int dupliob_move_down_exec(bContext *C, wmOperator *UNUSED(op)) break; } } - + return OPERATOR_FINISHED; } @@ -533,9 +533,9 @@ void PARTICLE_OT_dupliob_move_down(wmOperatorType *ot) ot->name = "Move Down Dupli Object"; ot->idname = "PARTICLE_OT_dupliob_move_down"; ot->description = "Move dupli object down in the list"; - + ot->exec = dupliob_move_down_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } @@ -559,7 +559,7 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) if (!psys->part || psys->part->type != PART_HAIR) return; - + edit = psys->edit; point= edit ? edit->points : NULL; @@ -573,7 +573,7 @@ static void disconnect_hair(Scene *scene, Object *ob, ParticleSystem *psys) for (k=0, key=pa->hair; ktotkey; k++, key++) { mul_m4_v3(hairmat, key->co); - + if (ekey) { ekey->flag &= ~PEK_USE_WCO; ekey++; @@ -622,9 +622,9 @@ void PARTICLE_OT_disconnect_hair(wmOperatorType *ot) ot->name = "Disconnect Hair"; ot->description = "Disconnect hair from the emitter mesh"; ot->idname = "PARTICLE_OT_disconnect_hair"; - + ot->exec = disconnect_hair_exec; - + /* flags */ ot->flag = OPTYPE_UNDO; /* No REGISTER, redo does not work due to missing update, see T47750. */ @@ -658,14 +658,14 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, return false; if (!target_psys->part || target_psys->part->type != PART_HAIR) return false; - + edit_point = target_edit ? target_edit->points : NULL; - + invert_m4_m4(from_ob_imat, ob->obmat); invert_m4_m4(to_ob_imat, target_ob->obmat); invert_m4_m4(from_imat, from_mat); invert_m4_m4(to_imat, to_mat); - + if (target_psmd->dm_final->deformedOnly) { /* we don't want to mess up target_psmd->dm when converting to global coordinates below */ dm = target_psmd->dm_final; @@ -729,7 +729,7 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, if (mface) { float v[4][3]; - + mf = &mface[nearest.index]; copy_v3_v3(v[0], mvert[mf->v1].co); @@ -765,7 +765,7 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, HairKey *key, *tkey; float hairmat[4][4], imat[4][4]; float offset[3]; - + if (to_global) copy_m4_m4(imat, target_ob->obmat); else { @@ -774,41 +774,41 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, invert_m4_m4(imat, hairmat); } mul_m4_m4m4(imat, imat, to_imat); - + /* offset in world space */ sub_v3_v3v3(offset, nearest.co, from_co); - + if (edit_point) { for (k=0, key=pa->hair, tkey=tpa->hair, ekey = edit_point->keys; ktotkey; k++, key++, tkey++, ekey++) { float co_orig[3]; - + if (from_global) mul_v3_m4v3(co_orig, from_ob_imat, key->co); else mul_v3_m4v3(co_orig, from_ob_imat, key->world_co); mul_m4_v3(from_mat, co_orig); - + add_v3_v3v3(tkey->co, co_orig, offset); - + mul_m4_v3(imat, tkey->co); - + ekey->flag |= PEK_USE_WCO; } - + edit_point++; } else { for (k=0, key=pa->hair, tkey=tpa->hair; ktotkey; k++, key++, tkey++) { float co_orig[3]; - + if (from_global) mul_v3_m4v3(co_orig, from_ob_imat, key->co); else mul_v3_m4v3(co_orig, from_ob_imat, key->world_co); mul_m4_v3(from_mat, co_orig); - + add_v3_v3v3(tkey->co, co_orig, offset); - + mul_m4_v3(imat, tkey->co); } } @@ -828,13 +828,13 @@ static bool remap_hair_emitter(Scene *scene, Object *ob, ParticleSystem *psys, static bool connect_hair(Scene *scene, Object *ob, ParticleSystem *psys) { bool ok; - + if (!psys) return false; - + ok = remap_hair_emitter(scene, ob, psys, ob, psys, psys->edit, ob->obmat, ob->obmat, psys->flag & PSYS_GLOBAL_HAIR, false); psys->flag &= ~PSYS_GLOBAL_HAIR; - + return ok; } @@ -876,9 +876,9 @@ void PARTICLE_OT_connect_hair(wmOperatorType *ot) ot->name = "Connect Hair"; ot->description = "Connect hair to the emitter mesh"; ot->idname = "PARTICLE_OT_connect_hair"; - + ot->exec = connect_hair_exec; - + /* flags */ ot->flag = OPTYPE_UNDO; /* No REGISTER, redo does not work due to missing update, see T47750. */ @@ -898,17 +898,17 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P ParticleData *pa; KEY_K; POINT_P; - + if (!edit_from) return; - + edit = MEM_dupallocN(edit_from); edit->psys = psys; psys->edit = edit; - + edit->pathcache = NULL; BLI_listbase_clear(&edit->pathcachebufs); - + edit->emitter_field = NULL; edit->emitter_cosnos = NULL; @@ -916,7 +916,7 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P pa = psys->particles; LOOP_POINTS { HairKey *hkey = pa->hair; - + point->keys= MEM_dupallocN(point->keys); LOOP_KEYS { key->co = hkey->co; @@ -926,17 +926,17 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P key->flag |= PEK_USE_WCO; hkey->editflag |= PEK_USE_WCO; } - + hkey++; } - + pa++; } update_world_cos(ob, edit); - + UI_GetThemeColor3ubv(TH_EDGE_SELECT, edit->sel_col); UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col); - + recalc_lengths(edit); recalc_emitter_field(ob, psys); PE_update_object(scene, ob, true); @@ -945,15 +945,15 @@ static void copy_particle_edit(Scene *scene, Object *ob, ParticleSystem *psys, P static void remove_particle_systems_from_object(Object *ob_to) { ModifierData *md, *md_next; - + if (ob_to->type != OB_MESH) return; if (!ob_to->data || ID_IS_LINKED(ob_to->data)) return; - + for (md = ob_to->modifiers.first; md; md = md_next) { md_next = md->next; - + /* remove all particle system modifiers as well, * these need to sync to the particle system list */ @@ -962,7 +962,7 @@ static void remove_particle_systems_from_object(Object *ob_to) modifier_free(md); } } - + BKE_object_free_particlesystems(ob_to); } @@ -981,12 +981,12 @@ static bool copy_particle_systems_to_object(Main *bmain, DerivedMesh *final_dm; CustomDataMask cdmask; int i, totpsys; - + if (ob_to->type != OB_MESH) return false; if (!ob_to->data || ID_IS_LINKED(ob_to->data)) return false; - + /* For remapping we need a valid DM. * Because the modifiers are appended at the end it's safe to use * the final DM of the object without particles. @@ -998,9 +998,9 @@ static bool copy_particle_systems_to_object(Main *bmain, #define PSYS_FROM_FIRST (single_psys_from ? single_psys_from : ob_from->particlesystem.first) #define PSYS_FROM_NEXT(cur) (single_psys_from ? NULL : (cur)->next) totpsys = single_psys_from ? 1 : BLI_listbase_count(&ob_from->particlesystem); - + tmp_psys = MEM_mallocN(sizeof(ParticleSystem*) * totpsys, "temporary particle system array"); - + cdmask = 0; for (psys_from = PSYS_FROM_FIRST, i = 0; psys_from; @@ -1008,46 +1008,46 @@ static bool copy_particle_systems_to_object(Main *bmain, { psys = BKE_object_copy_particlesystem(psys_from, 0); tmp_psys[i] = psys; - + if (psys_start == NULL) psys_start = psys; - + cdmask |= psys_emitter_customdata_mask(psys); } /* to iterate source and target psys in sync, * we need to know where the newly added psys start */ psys_start = totpsys > 0 ? tmp_psys[0] : NULL; - + /* get the DM (psys and their modifiers have not been appended yet) */ final_dm = mesh_get_derived_final(scene, ob_to, cdmask); - + /* now append psys to the object and make modifiers */ for (i = 0, psys_from = PSYS_FROM_FIRST; i < totpsys; ++i, psys_from = PSYS_FROM_NEXT(psys_from)) { ParticleSystemModifierData *psmd; - + psys = tmp_psys[i]; - + /* append to the object */ BLI_addtail(&ob_to->particlesystem, psys); - + /* add a particle system modifier for each system */ md = modifier_new(eModifierType_ParticleSystem); psmd = (ParticleSystemModifierData *)md; /* push on top of the stack, no use trying to reproduce old stack order */ BLI_addtail(&ob_to->modifiers, md); - + BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i); modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd); - + psmd->psys = psys; psmd->dm_final = CDDM_copy(final_dm); CDDM_calc_normals(psmd->dm_final); DM_ensure_tessface(psmd->dm_final); - + if (psys_from->edit) copy_particle_edit(scene, ob_to, psys, psys_from); @@ -1057,7 +1057,7 @@ static bool copy_particle_systems_to_object(Main *bmain, } } MEM_freeN(tmp_psys); - + /* note: do this after creating DM copies for all the particle system modifiers, * the remapping otherwise makes final_dm invalid! */ @@ -1066,7 +1066,7 @@ static bool copy_particle_systems_to_object(Main *bmain, psys = psys->next, psys_from = PSYS_FROM_NEXT(psys_from), ++i) { float (*from_mat)[4], (*to_mat)[4]; - + switch (space) { case PAR_COPY_SPACE_OBJECT: from_mat = I; @@ -1085,14 +1085,14 @@ static bool copy_particle_systems_to_object(Main *bmain, if (ob_from != ob_to) { remap_hair_emitter(scene, ob_from, psys_from, ob_to, psys, psys->edit, from_mat, to_mat, psys_from->flag & PSYS_GLOBAL_HAIR, psys->flag & PSYS_GLOBAL_HAIR); } - + /* tag for recalc */ // psys->recalc |= PSYS_RECALC_RESET; } - + #undef PSYS_FROM_FIRST #undef PSYS_FROM_NEXT - + DAG_id_tag_update(&ob_to->id, OB_RECALC_DATA); WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, ob_to); return true; @@ -1103,11 +1103,11 @@ static int copy_particle_systems_poll(bContext *C) Object *ob; if (!ED_operator_object_active_editable(C)) return false; - + ob = ED_object_active_context(C); if (BLI_listbase_is_empty(&ob->particlesystem)) return false; - + return true; } @@ -1120,10 +1120,10 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob_from = ED_object_active_context(C); ParticleSystem *psys_from = use_active ? CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data : NULL; - + int changed_tot = 0; int fail = 0; - + CTX_DATA_BEGIN (C, Object *, ob_to, selected_editable_objects) { if (ob_from != ob_to) { @@ -1136,19 +1136,19 @@ static int copy_particle_systems_exec(bContext *C, wmOperator *op) changed = true; else fail++; - + if (changed) changed_tot++; } } CTX_DATA_END; - + if ((changed_tot == 0 && fail == 0) || fail) { BKE_reportf(op->reports, RPT_ERROR, "Copy particle systems to selected: %d done, %d failed", changed_tot, fail); } - + return OPERATOR_FINISHED; } @@ -1159,17 +1159,17 @@ void PARTICLE_OT_copy_particle_systems(wmOperatorType *ot) {PAR_COPY_SPACE_WORLD, "WORLD", 0, "World", "Copy in world space"}, {0, NULL, 0, NULL, NULL} }; - + ot->name = "Copy Particle Systems"; ot->description = "Copy particle systems from the active object to selected objects"; ot->idname = "PARTICLE_OT_copy_particle_systems"; - + ot->poll = copy_particle_systems_poll; ot->exec = copy_particle_systems_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "space", space_items, PAR_COPY_SPACE_OBJECT, "Space", "Space transform for copying from one object to another"); RNA_def_boolean(ot->srna, "remove_target_particles", true, "Remove Target Particles", "Remove particle systems on the target objects"); RNA_def_boolean(ot->srna, "use_active", false, "Use Active", "Use the active particle system from the context"); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index c050f889eee..4b9ce1ca210 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -39,7 +39,7 @@ /* types */ #include "DNA_action_types.h" #include "DNA_object_types.h" -#include "DNA_object_fluidsim_types.h" +#include "DNA_object_fluidsim_types.h" #include "BLI_blenlib.h" #include "BLI_math.h" @@ -82,12 +82,12 @@ static float get_fluid_viscosity(FluidsimSettings *settings) static float get_fluid_rate(FluidsimSettings *settings) { float rate = 1.0f; /* default rate if not animated... */ - + rate = settings->animRate; - + if (rate < 0.0f) rate = 0.0f; - + return rate; } @@ -109,10 +109,10 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * else { float dim[3]; float longest_axis; - + BKE_object_dimensions_get(domainob, dim); longest_axis = max_fff(dim[0], dim[1], dim[2]); - + return longest_axis * scene->unit.scale_length; } } @@ -138,9 +138,9 @@ void fluidsimGetGeometryObjFilename(Object *ob, char *dst) //, char *srcname) typedef struct FluidAnimChannels { int length; - + double aniFrameTime; - + float *timeAtFrame; float *DomainTime; float *DomainGravity; @@ -149,21 +149,21 @@ typedef struct FluidAnimChannels { typedef struct FluidObject { struct FluidObject *next, *prev; - + struct Object *object; - + float *Translation; float *Rotation; float *Scale; float *Active; - + float *InitialVelocity; - + float *AttractforceStrength; float *AttractforceRadius; float *VelocityforceStrength; float *VelocityforceRadius; - + float *VertexCache; int numVerts, numTris; } FluidObject; @@ -175,10 +175,10 @@ typedef struct FluidObject { // simplify channels before printing // for API this is done anyway upon init #if 0 -static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries) -{ +static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char *str, int entries) +{ int i, j; - int channelSize = paramsize; + int channelSize = paramsize; if (entries == 3) { elbeemSimplifyChannelVec3(channel, &channelSize); @@ -220,11 +220,11 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *channels) { int i; - + channels->timeAtFrame = MEM_callocN((channels->length + 1) * sizeof(float), "timeAtFrame channel"); - + channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1 - + for (i=2; i <= channels->length; i++) { channels->timeAtFrame[i] = channels->timeAtFrame[i - 1] + (float)channels->aniFrameTime; } @@ -254,25 +254,25 @@ static void set_vertex_channel(float *channel, float time, struct Scene *scene, int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd); int framesize = (3*fobj->numVerts) + 1; int j; - + if (channel == NULL) return; - + initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 1, modifierIndex); - + /* don't allow mesh to change number of verts in anim sequence */ if (numVerts != fobj->numVerts) { MEM_freeN(channel); channel = NULL; return; } - + /* fill frame of channel with vertex locations */ for (j=0; j < (3*numVerts); j++) { channel[i*framesize + j] = verts[j]; } channel[i*framesize + framesize-1] = time; - + MEM_freeN(verts); MEM_freeN(tris); } @@ -294,7 +294,7 @@ static void free_domain_channels(FluidAnimChannels *channels) static void free_all_fluidobject_channels(ListBase *fobjects) { FluidObject *fobj; - + for (fobj=fobjects->first; fobj; fobj=fobj->next) { if (fobj->Translation) { MEM_freeN(fobj->Translation); @@ -308,7 +308,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects) MEM_freeN(fobj->InitialVelocity); fobj->InitialVelocity = NULL; } - + if (fobj->AttractforceStrength) { MEM_freeN(fobj->AttractforceStrength); fobj->AttractforceStrength = NULL; @@ -319,7 +319,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects) MEM_freeN(fobj->VelocityforceRadius); fobj->VelocityforceRadius = NULL; } - + if (fobj->VertexCache) { MEM_freeN(fobj->VertexCache); fobj->VertexCache = NULL; @@ -334,108 +334,108 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid int i; int length = channels->length; float eval_time; - + /* init time values (assuming that time moves at a constant speed; may be overridden later) */ init_time(domainSettings, channels); - + /* allocate domain animation channels */ channels->DomainGravity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "channel DomainGravity"); channels->DomainViscosity = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainViscosity"); channels->DomainTime = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime"); - + /* allocate fluid objects */ for (base=scene->base.first; base; base= base->next) { Object *ob = base->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - + if (fluidmd) { FluidObject *fobj = MEM_callocN(sizeof(FluidObject), "Fluid Object"); fobj->object = ob; - + if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) { BLI_addtail(fobjects, fobj); continue; } - + fobj->Translation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Translation"); fobj->Rotation = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Rotation"); fobj->Scale = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject Scale"); fobj->Active = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject Active"); fobj->InitialVelocity = MEM_callocN(length * (CHANNEL_VEC+1) * sizeof(float), "fluidobject InitialVelocity"); - + if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) { fobj->AttractforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceStrength"); fobj->AttractforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject AttractforceRadius"); fobj->VelocityforceStrength = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceStrength"); fobj->VelocityforceRadius = MEM_callocN(length * (CHANNEL_FLOAT+1) * sizeof(float), "fluidobject VelocityforceRadius"); } - + if (fluid_is_animated_mesh(fluidmd->fss)) { float *verts=NULL; int *tris=NULL, modifierIndex = BLI_findindex(&ob->modifiers, (ModifierData *)fluidmd); initElbeemMesh(scene, ob, &fobj->numVerts, &verts, &fobj->numTris, &tris, 0, modifierIndex); fobj->VertexCache = MEM_callocN(length *((fobj->numVerts*CHANNEL_VEC)+1) * sizeof(float), "fluidobject VertexCache"); - + MEM_freeN(verts); MEM_freeN(tris); } - + BLI_addtail(fobjects, fobj); } } - + /* now we loop over the frames and fill the allocated channels with data */ for (i=0; i < channels->length; i++) { FluidObject *fobj; float viscosity, gravity[3]; float timeAtFrame, time; - + eval_time = domainSettings->bakeStart + i; - + /* XXX: This can't be used due to an anim sys optimization that ignores recalc object animation, * leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ ) * --> BKE_animsys_evaluate_all_animation(G.main, eval_time); * This doesn't work with drivers: * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL); */ - - /* Modifying the global scene isn't nice, but we can do it in + + /* Modifying the global scene isn't nice, but we can do it in * this part of the process before a threaded job is created */ scene->r.cfra = (int)eval_time; ED_update_for_newframe(CTX_data_main(C), scene, 1); - + /* now scene data should be current according to animation system, so we fill the channels */ - + /* Domain time */ // TODO: have option for not running sim, time mangling, in which case second case comes in handy if (channels->DomainTime) { time = get_fluid_rate(domainSettings) * (float)channels->aniFrameTime; timeAtFrame = channels->timeAtFrame[i] + time; - + channels->timeAtFrame[i+1] = timeAtFrame; set_channel(channels->DomainTime, i, &time, i, CHANNEL_FLOAT); } else { timeAtFrame = channels->timeAtFrame[i+1]; } - + /* Domain properties - gravity/viscosity */ get_fluid_gravity(gravity, scene, domainSettings); set_channel(channels->DomainGravity, timeAtFrame, gravity, i, CHANNEL_VEC); viscosity = get_fluid_viscosity(domainSettings); set_channel(channels->DomainViscosity, timeAtFrame, &viscosity, i, CHANNEL_FLOAT); - + /* object movement */ for (fobj=fobjects->first; fobj; fobj=fobj->next) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); float active= (float) ((fluidmd->fss->flag & OB_FLUIDSIM_ACTIVE) > 0 ? 1 : 0); float rot_d[3] = {0.f, 0.f, 0.f}, old_rot[3] = {0.f, 0.f, 0.f}; - + if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) continue; - + /* init euler rotation values and convert to elbeem format */ /* get the rotation from ob->obmat rather than ob->rot to account for parent animations */ if (i) { @@ -445,7 +445,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid mat4_to_compatible_eulO(rot_d, old_rot, 0, ob->obmat); mul_v3_fl(rot_d, -180.0f / (float)M_PI); - + set_channel(fobj->Translation, timeAtFrame, ob->loc, i, CHANNEL_VEC); set_channel(fobj->Rotation, timeAtFrame, rot_d, i, CHANNEL_VEC); set_channel(fobj->Scale, timeAtFrame, ob->size, i, CHANNEL_VEC); @@ -453,14 +453,14 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid set_channel(fobj->InitialVelocity, timeAtFrame, &fluidmd->fss->iniVelx, i, CHANNEL_VEC); // printf("Active: %f, Frame: %f\n", active, timeAtFrame); - + if (fluidmd->fss->type == OB_FLUIDSIM_CONTROL) { set_channel(fobj->AttractforceStrength, timeAtFrame, &fluidmd->fss->attractforceStrength, i, CHANNEL_FLOAT); set_channel(fobj->AttractforceRadius, timeAtFrame, &fluidmd->fss->attractforceRadius, i, CHANNEL_FLOAT); set_channel(fobj->VelocityforceStrength, timeAtFrame, &fluidmd->fss->velocityforceStrength, i, CHANNEL_FLOAT); set_channel(fobj->VelocityforceRadius, timeAtFrame, &fluidmd->fss->velocityforceRadius, i, CHANNEL_FLOAT); } - + if (fluid_is_animated_mesh(fluidmd->fss)) { set_vertex_channel(fobj->VertexCache, timeAtFrame, scene, fobj, i); } @@ -471,72 +471,72 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) { FluidObject *fobj; - + for (fobj=fobjects->first; fobj; fobj=fobj->next) { Object *ob = fobj->object; FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd); - + float *verts=NULL; int *tris=NULL; int numVerts=0, numTris=0; bool deform = fluid_is_animated_mesh(fluidmd->fss); - + elbeemMesh fsmesh; - + if (ELEM(fluidmd->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE)) continue; - + elbeemResetMesh(&fsmesh); - + fsmesh.type = fluidmd->fss->type; fsmesh.name = ob->id.name; - + initElbeemMesh(scene, ob, &numVerts, &verts, &numTris, &tris, 0, modifierIndex); - + fsmesh.numVertices = numVerts; fsmesh.numTriangles = numTris; fsmesh.vertices = verts; fsmesh.triangles = tris; - - fsmesh.channelSizeTranslation = - fsmesh.channelSizeRotation = - fsmesh.channelSizeScale = - fsmesh.channelSizeInitialVel = + + fsmesh.channelSizeTranslation = + fsmesh.channelSizeRotation = + fsmesh.channelSizeScale = + fsmesh.channelSizeInitialVel = fsmesh.channelSizeActive = length; - + fsmesh.channelTranslation = fobj->Translation; fsmesh.channelRotation = fobj->Rotation; fsmesh.channelScale = fobj->Scale; fsmesh.channelActive = fobj->Active; - + if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { fsmesh.channelInitialVel = fobj->InitialVelocity; fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD) ? 1 : 0); } - + if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; else if (fluidmd->fss->typeFlags & OB_FSBND_PARTSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_PARTSLIP; else if (fluidmd->fss->typeFlags & OB_FSBND_FREESLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_FREESLIP; - + fsmesh.obstaclePartslip = fluidmd->fss->partSlipValue; fsmesh.volumeInitType = fluidmd->fss->volumeInitType; fsmesh.obstacleImpactFactor = fluidmd->fss->surfaceSmoothing; // misused value - + if (fsmesh.type == OB_FLUIDSIM_CONTROL) { fsmesh.cpsTimeStart = fluidmd->fss->cpsTimeStart; fsmesh.cpsTimeEnd = fluidmd->fss->cpsTimeEnd; fsmesh.cpsQuality = fluidmd->fss->cpsQuality; fsmesh.obstacleType = (fluidmd->fss->flag & OB_FLUIDSIM_REVERSE); - - fsmesh.channelSizeAttractforceRadius = - fsmesh.channelSizeVelocityforceStrength = - fsmesh.channelSizeVelocityforceRadius = + + fsmesh.channelSizeAttractforceRadius = + fsmesh.channelSizeVelocityforceStrength = + fsmesh.channelSizeVelocityforceRadius = fsmesh.channelSizeAttractforceStrength = length; - + fsmesh.channelAttractforceStrength = fobj->AttractforceStrength; fsmesh.channelAttractforceRadius = fobj->AttractforceRadius; fsmesh.channelVelocityforceStrength = fobj->VelocityforceStrength; @@ -544,28 +544,28 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) } else { fsmesh.channelAttractforceStrength = - fsmesh.channelAttractforceRadius = - fsmesh.channelVelocityforceStrength = - fsmesh.channelVelocityforceRadius = NULL; + fsmesh.channelAttractforceRadius = + fsmesh.channelVelocityforceStrength = + fsmesh.channelVelocityforceRadius = NULL; } - + /* animated meshes */ if (deform) { fsmesh.channelSizeVertices = length; fsmesh.channelVertices = fobj->VertexCache; - + /* remove channels */ - fsmesh.channelTranslation = - fsmesh.channelRotation = + fsmesh.channelTranslation = + fsmesh.channelRotation = fsmesh.channelScale = NULL; - + /* Override user settings, only noslip is supported here! */ if (fsmesh.type != OB_FLUIDSIM_CONTROL) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; } - + elbeemAddMesh(&fsmesh); - + if (verts) MEM_freeN(verts); if (tris) MEM_freeN(tris); } @@ -584,7 +584,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom /* only find objects with fluid modifiers */ if (!fluidmdtmp || ob->type != OB_MESH) continue; - + if (fluidmdtmp->fss->type == OB_FLUIDSIM_DOMAIN) { /* if no initial domain object given, find another potential domain */ if (!fsDomain) { @@ -596,11 +596,11 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom return 0; } } - + /* count number of objects needed for animation channels */ if ( !ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_DOMAIN, OB_FLUIDSIM_PARTICLE) ) channelObjCount++; - + /* count number of fluid input objects */ if (ELEM(fluidmdtmp->fss->type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) fluidInputCount++; @@ -608,22 +608,22 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom if (newdomain) fsDomain = newdomain; - + if (!fsDomain) { BKE_report(reports, RPT_ERROR, "No domain object found"); return 0; } - + if (channelObjCount >= 255) { BKE_report(reports, RPT_ERROR, "Cannot bake with more than 256 objects"); return 0; } - + if (fluidInputCount == 0) { BKE_report(reports, RPT_ERROR, "No fluid input objects in the scene"); return 0; } - + return 1; } @@ -717,8 +717,8 @@ static int fluidbake_breakjob(void *customdata) if (fb->stop && *(fb->stop)) return 1; - - /* this is not nice yet, need to make the jobs list template better + + /* this is not nice yet, need to make the jobs list template better * for identifying/acting upon various different jobs */ /* but for now we'll reuse the render break... */ return (G.is_break); @@ -728,7 +728,7 @@ static int fluidbake_breakjob(void *customdata) static void fluidbake_updatejob(void *customdata, float progress) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - + *(fb->do_update) = true; *(fb->progress) = progress; } @@ -736,13 +736,13 @@ static void fluidbake_updatejob(void *customdata, float progress) static void fluidbake_startjob(void *customdata, short *stop, short *do_update, float *progress) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - + fb->stop= stop; fb->do_update = do_update; fb->progress = progress; - + G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ - + elbeemSimulate(); *do_update = true; *stop = 0; @@ -751,7 +751,7 @@ static void fluidbake_startjob(void *customdata, short *stop, short *do_update, static void fluidbake_endjob(void *customdata) { FluidBakeJob *fb= (FluidBakeJob *)customdata; - + if (fb->settings) { MEM_freeN(fb->settings); fb->settings = NULL; @@ -762,16 +762,16 @@ static int runSimulationCallback(void *data, int status, int frame) { FluidBakeJob *fb = (FluidBakeJob *)data; elbeemSimulationSettings *settings = fb->settings; - + if (status == FLUIDSIM_CBSTATUS_NEWFRAME) { fluidbake_updatejob(fb, frame / (float)settings->noOfFrames); //printf("elbeem blender cb s%d, f%d, domainid:%d noOfFrames: %d\n", status, frame, settings->domainId, settings->noOfFrames ); // DEBUG } - + if (fluidbake_breakjob(fb)) { return FLUIDSIM_CBRET_ABORT; } - + return FLUIDSIM_CBRET_CONTINUE; } @@ -785,12 +785,12 @@ static void fluidbake_free_data(FluidAnimChannels *channels, ListBase *fobjects, BLI_freelistN(fobjects); MEM_freeN(fobjects); fobjects = NULL; - + if (fsset) { MEM_freeN(fsset); fsset = NULL; } - + if (fb) { MEM_freeN(fb); fb = NULL; @@ -842,7 +842,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor FluidsimSettings *domainSettings; char debugStrBuffer[256]; - + int gridlevels = 0; const char *relbase= modifier_path_relbase(bmain, fsDomain); const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp @@ -857,7 +857,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor int noFrames; int origFrame = scene->r.cfra; - + FluidAnimChannels *channels = MEM_callocN(sizeof(FluidAnimChannels), "fluid domain animation channels"); ListBase *fobjects = MEM_callocN(sizeof(ListBase), "fluid objects"); FluidsimModifierData *fluidmd = NULL; @@ -867,14 +867,14 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor elbeemSimulationSettings *fsset= MEM_callocN(sizeof(elbeemSimulationSettings), "Fluid sim settings"); fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job"); - + if (getenv(strEnvName)) { int dlevel = atoi(getenv(strEnvName)); elbeemSetDebugLevel(dlevel); BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Debug messages activated due to envvar '%s'\n", strEnvName); elbeemDebugOut(debugStrBuffer); } - + /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */; noFrames = scene->r.efra - 0; if (noFrames<=0) { @@ -882,30 +882,30 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fluidbake_free_data(channels, fobjects, fsset, fb); return 0; } - + /* check scene for sane object/modifier settings */ if (!fluid_validate_scene(reports, scene, fsDomain)) { fluidbake_free_data(channels, fobjects, fsset, fb); return 0; } - + /* these both have to be valid, otherwise we wouldn't be here */ fluidmd = (FluidsimModifierData *)modifiers_findByType(fsDomain, eModifierType_Fluidsim); domainSettings = fluidmd->fss; mesh = fsDomain->data; - + domainSettings->bakeStart = 1; domainSettings->bakeEnd = scene->r.efra; - + // calculate bounding box fluid_get_bb(mesh->mvert, mesh->totvert, fsDomain->obmat, domainSettings->bbStart, domainSettings->bbSize); - + // reset last valid frame domainSettings->lastgoodframe = -1; /* delete old baked files */ fluidsim_delete_until_lastframe(domainSettings, relbase); - + /* rough check of settings... */ if (domainSettings->previewresxyz > domainSettings->resolutionxyz) { BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz, domainSettings->resolutionxyz); @@ -932,9 +932,9 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor } BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name, gridlevels); elbeemDebugOut(debugStrBuffer); - - - + + + /* ******** prepare output file paths ******** */ if (!fluid_init_filepaths(bmain, reports, domainSettings, fsDomain, targetDir, targetFile)) { fluidbake_free_data(channels, fobjects, fsset, fb); @@ -943,20 +943,20 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor channels->length = scene->r.efra; // DG TODO: why using endframe and not "noFrames" here? .. because "noFrames" is buggy too? (not using sfra) channels->aniFrameTime = (double)((double)domainSettings->animEnd - (double)domainSettings->animStart) / (double)noFrames; - + /* ******** initialize and allocate animation channels ******** */ fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects); /* reset to original current frame */ scene->r.cfra = origFrame; ED_update_for_newframe(CTX_data_main(C), scene, 1); - + /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); if (!invert_m4_m4(invDomMat, domainMat)) { BLI_snprintf(debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::error - Invalid obj matrix?\n"); elbeemDebugOut(debugStrBuffer); - BKE_report(reports, RPT_ERROR, "Invalid object matrix"); + BKE_report(reports, RPT_ERROR, "Invalid object matrix"); fluidbake_free_data(channels, fobjects, fsset, fb); return 0; @@ -973,7 +973,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // setup global settings copy_v3_v3(fsset->geoStart, domainSettings->bbStart); copy_v3_v3(fsset->geoSize, domainSettings->bbSize); - + // simulate with 50^3 fsset->resolutionxyz = (int)domainSettings->resolutionxyz; fsset->previewresxyz = (int)domainSettings->previewresxyz; @@ -992,21 +992,21 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor // defaults for compressibility and adaptive grids fsset->gstar = domainSettings->gstar; fsset->maxRefine = domainSettings->maxRefine; // check <-> gridlevels - fsset->generateParticles = domainSettings->generateParticles; - fsset->numTracerParticles = domainSettings->generateTracers; - fsset->surfaceSmoothing = domainSettings->surfaceSmoothing; - fsset->surfaceSubdivs = domainSettings->surfaceSubdivs; - fsset->farFieldSize = domainSettings->farFieldSize; + fsset->generateParticles = domainSettings->generateParticles; + fsset->numTracerParticles = domainSettings->generateTracers; + fsset->surfaceSmoothing = domainSettings->surfaceSmoothing; + fsset->surfaceSubdivs = domainSettings->surfaceSubdivs; + fsset->farFieldSize = domainSettings->farFieldSize; BLI_strncpy(fsset->outputPath, targetFile, sizeof(fsset->outputPath)); // domain channels - fsset->channelSizeFrameTime = - fsset->channelSizeViscosity = + fsset->channelSizeFrameTime = + fsset->channelSizeViscosity = fsset->channelSizeGravity = channels->length; fsset->channelFrameTime = channels->DomainTime; fsset->channelViscosity = channels->DomainViscosity; fsset->channelGravity = channels->DomainGravity; - + fsset->runsimCallback = &runSimulationCallback; fsset->runsimUserData = fb; @@ -1034,13 +1034,13 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* ******** init solver with settings ******** */ elbeemInit(); elbeemAddDomain(fsset); - + /* ******** export all fluid objects to elbeem ******** */ export_fluid_objects(fobjects, scene, channels->length); - + /* custom data for fluid bake job */ fb->settings = fsset; - + if (do_job) { wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_FLUID); @@ -1112,7 +1112,7 @@ void FLUID_OT_bake(wmOperatorType *ot) ot->name = "Fluid Simulation Bake"; ot->description = "Bake fluid simulation"; ot->idname = "FLUID_OT_bake"; - + /* api callbacks */ ot->invoke = fluid_bake_invoke; ot->exec = fluid_bake_exec; diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index cffee635199..7b86cb63f31 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -111,10 +111,10 @@ static void keymap_particle(wmKeyConfig *keyconf) { wmKeyMapItem *kmi; wmKeyMap *keymap; - + keymap = WM_keymap_find(keyconf, "Particle", 0, 0); keymap->poll = PE_poll; - + kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", AKEY, KM_PRESS, 0, 0); RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); @@ -166,7 +166,7 @@ static void keymap_particle(wmKeyConfig *keyconf) RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.particle_edit.brush.strength"); WM_keymap_add_menu(keymap, "VIEW3D_MT_particle_specials", WKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "PARTICLE_OT_weight_set", KKEY, KM_PRESS, KM_SHIFT, 0); ED_keymap_proportional_cycle(keyconf, keymap); @@ -222,7 +222,7 @@ static void operatortypes_dynamicpaint(void) //static void keymap_pointcache(wmWindowManager *wm) //{ // wmKeyMap *keymap = WM_keymap_find(wm, "Pointcache", 0, 0); -// +// // WM_keymap_add_item(keymap, "PHYSICS_OT_bake_all", AKEY, KM_PRESS, 0, 0); // WM_keymap_add_item(keymap, "PHYSICS_OT_free_all", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); // WM_keymap_add_item(keymap, "PHYSICS_OT_bake_particle_system", PADMINUS, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index f36ebb3715e..dadd086a774 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -264,9 +264,9 @@ static int ptcache_free_bake_all_exec(bContext *C, wmOperator *UNUSED(op)) for (pid=pidlist.first; pid; pid=pid->next) { ptcache_free_bake(pid->cache); } - + BLI_freelistN(&pidlist); - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, base->object); } @@ -281,7 +281,7 @@ void PTCACHE_OT_bake_all(wmOperatorType *ot) ot->name = "Bake All Physics"; ot->description = "Bake all physics"; ot->idname = "PTCACHE_OT_bake_all"; - + /* api callbacks */ ot->exec = ptcache_bake_exec; ot->invoke = ptcache_bake_invoke; @@ -300,7 +300,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) ot->name = "Free All Physics Bakes"; ot->idname = "PTCACHE_OT_free_bake_all"; ot->description = "Free all baked caches of all objects in the current scene"; - + /* api callbacks */ ot->exec = ptcache_free_bake_all_exec; ot->poll = ptcache_bake_all_poll; @@ -316,7 +316,7 @@ static int ptcache_free_bake_exec(bContext *C, wmOperator *UNUSED(op)) Object *ob= ptr.id.data; ptcache_free_bake(cache); - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; @@ -326,9 +326,9 @@ static int ptcache_bake_from_cache_exec(bContext *C, wmOperator *UNUSED(op)) PointerRNA ptr= CTX_data_pointer_get_type(C, "point_cache", &RNA_PointCache); PointCache *cache= ptr.data; Object *ob= ptr.id.data; - + cache->flag |= PTCACHE_BAKED; - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; @@ -339,7 +339,7 @@ void PTCACHE_OT_bake(wmOperatorType *ot) ot->name = "Bake Physics"; ot->description = "Bake physics"; ot->idname = "PTCACHE_OT_bake"; - + /* api callbacks */ ot->exec = ptcache_bake_exec; ot->invoke = ptcache_bake_invoke; @@ -358,7 +358,7 @@ void PTCACHE_OT_free_bake(wmOperatorType *ot) ot->name = "Free Physics Bake"; ot->description = "Free physics bake"; ot->idname = "PTCACHE_OT_free_bake"; - + /* api callbacks */ ot->exec = ptcache_free_bake_exec; ot->poll = ptcache_poll; @@ -372,7 +372,7 @@ void PTCACHE_OT_bake_from_cache(wmOperatorType *ot) ot->name = "Bake From Cache"; ot->description = "Bake from cache"; ot->idname = "PTCACHE_OT_bake_from_cache"; - + /* api callbacks */ ot->exec = ptcache_bake_from_cache_exec; ot->poll = ptcache_poll; @@ -391,7 +391,7 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op)) ListBase pidlist; BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - + for (pid=pidlist.first; pid; pid=pid->next) { if (pid->cache == cache) { PointCache *cache_new = BKE_ptcache_add(pid->ptcaches); @@ -418,7 +418,7 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) ListBase pidlist; BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - + for (pid=pidlist.first; pid; pid=pid->next) { if (pid->cache == cache) { if (pid->ptcaches->first == pid->ptcaches->last) @@ -433,7 +433,7 @@ static int ptcache_remove_exec(bContext *C, wmOperator *UNUSED(op)) } BLI_freelistN(&pidlist); - + WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); return OPERATOR_FINISHED; @@ -444,7 +444,7 @@ void PTCACHE_OT_add(wmOperatorType *ot) ot->name = "Add New Cache"; ot->description = "Add new cache"; ot->idname = "PTCACHE_OT_add"; - + /* api callbacks */ ot->exec = ptcache_add_new_exec; ot->poll = ptcache_poll; @@ -458,7 +458,7 @@ void PTCACHE_OT_remove(wmOperatorType *ot) ot->name = "Delete Current Cache"; ot->description = "Delete current cache"; ot->idname = "PTCACHE_OT_remove"; - + /* api callbacks */ ot->exec = ptcache_remove_exec; ot->poll = ptcache_poll; diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c index 008ab4c0554..8d5258a7522 100644 --- a/source/blender/editors/physics/rigidbody_world.c +++ b/source/blender/editors/physics/rigidbody_world.c @@ -24,7 +24,7 @@ * * ***** END GPL LICENSE BLOCK ***** */ - + /** \file rigidbody_world.c * \ingroup editor_physics * \brief Rigid Body world editing operators @@ -174,7 +174,7 @@ static int rigidbody_world_export_invoke(bContext *C, wmOperator *op, const wmEv // TODO: use the actual rigidbody world's name + .bullet instead of this temp crap RNA_string_set(op->ptr, "filepath", "rigidbodyworld_export.bullet"); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index c7d80bd1761..8a15179a46e 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -264,7 +264,7 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s RNA_string_get(op->ptr, "scene", scene_name); scn = (Scene *)BLI_findstring(&mainp->scene, scene_name, offsetof(ID, name) + 2); - + if (scn) { /* camera switch wont have updated */ scn->r.cfra = (*scene)->r.cfra; @@ -280,7 +280,7 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s RNA_string_get(op->ptr, "layer", rl_name); rl = (SceneRenderLayer *)BLI_findstring(&(*scene)->r.layers, rl_name, offsetof(SceneRenderLayer, name)); - + if (rl) *srl = rl; } @@ -427,7 +427,7 @@ static void make_renderinfo_string(const RenderStats *rs, /* full sample */ if (rs->curfsa) spos += sprintf(spos, IFACE_("| Full Sample %d "), rs->curfsa); - + /* extra info */ if (rs->infostr && rs->infostr[0]) { spos += sprintf(spos, "| %s ", rs->infostr); @@ -469,7 +469,7 @@ static void image_renderinfo_cb(void *rjv, RenderStats *rs) static void render_progress_update(void *rjv, float progress) { RenderJob *rj = rjv; - + if (rj->progress && *rj->progress != progress) { *rj->progress = progress; @@ -555,10 +555,10 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec *(rj->do_update) = true; return; } - + if (rr == NULL) return; - + /* update part of render */ render_image_update_pass_and_layer(rj, rr, &rj->iuser); ibuf = BKE_image_acquire_ibuf(ima, &rj->iuser, &lock); @@ -577,7 +577,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec { image_buffer_rect_update(rj, rr, ibuf, &rj->iuser, renrect, viewname); } - + /* make jobs timer to send notifier */ *(rj->do_update) = true; } @@ -663,13 +663,13 @@ static void render_endjob(void *rjv) ED_update_for_newframe(G.main, rj->scene, 1); } } - + /* XXX above function sets all tags in nodes */ ntreeCompositClearTags(rj->scene->nodetree); - + /* potentially set by caller */ rj->scene->r.scemode &= ~R_NO_FRAME_UPDATE; - + if (rj->srl) { nodeUpdateID(rj->scene->nodetree, &rj->scene->id); WM_main_add_notifier(NC_NODE | NA_EDITED, rj->scene); @@ -846,7 +846,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even struct Object *camera_override = v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; const char *name; ScrArea *sa; - + /* only one render job at a time */ if (WM_jobs_test(CTX_wm_manager(C), scene, WM_JOB_TYPE_RENDER)) return OPERATOR_CANCELLED; @@ -862,7 +862,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); return OPERATOR_CANCELLED; } - + /* stop all running jobs, except screen one. currently previews frustrate Render */ WM_jobs_kill_all_except(CTX_wm_manager(C), CTX_wm_screen(C)); @@ -878,7 +878,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even /* cancel animation playback */ if (ED_screen_animation_playing(CTX_wm_manager(C))) ED_screen_animation_play(C, 0, 0); - + /* handle UI stuff */ WM_cursor_wait(1); @@ -899,7 +899,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even sa = render_view_open(C, event->x, event->y, op->reports); jobflag = WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS; - + /* custom scene and single layer re-render */ screen_render_scene_layer_set(op, mainp, &scene, &srl); @@ -1055,7 +1055,7 @@ typedef struct RenderPreview { void *owner; short *stop, *do_update; wmJob *job; - + Scene *scene; ScrArea *sa; ARegion *ar; @@ -1063,7 +1063,7 @@ typedef struct RenderPreview { RegionView3D *rv3d; Main *bmain; RenderEngine *engine; - + float viewmat[4][4]; int start_resolution_divider; @@ -1076,7 +1076,7 @@ static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, Region /* copied code from view3d_draw.c */ rctf viewborder; int draw_border; - + if (rv3d->persp == RV3D_CAMOB) draw_border = (scene->r.mode & R_BORDER) != 0; else @@ -1085,7 +1085,7 @@ static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, Region if (draw_border) { if (rv3d->persp == RV3D_CAMOB) { ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false); - + disprect->xmin = viewborder.xmin + scene->r.border.xmin * BLI_rctf_size_x(&viewborder); disprect->ymin = viewborder.ymin + scene->r.border.ymin * BLI_rctf_size_y(&viewborder); disprect->xmax = viewborder.xmin + scene->r.border.xmax * BLI_rctf_size_x(&viewborder); @@ -1097,10 +1097,10 @@ static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, Region disprect->ymin = v3d->render_border.ymin * ar->winy; disprect->ymax = v3d->render_border.ymax * ar->winy; } - + return 1; } - + BLI_rcti_init(disprect, 0, 0, 0, 0); return 0; } @@ -1109,11 +1109,11 @@ static int render_view3d_disprect(Scene *scene, ARegion *ar, View3D *v3d, Region static bool render_view3d_get_rects(ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewplane, RenderEngine *engine, float *r_clipsta, float *r_clipend, float *r_pixsize, bool *r_ortho) { - + if (ar->winx < 4 || ar->winy < 4) return false; - + *r_ortho = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, viewplane, r_clipsta, r_clipend, r_pixsize); - + engine->resolution_x = ar->winx; engine->resolution_y = ar->winy; @@ -1129,22 +1129,22 @@ static bool render_view3d_is_valid(RenderPreview *rp) static int render_view3d_break(void *rpv) { RenderPreview *rp = rpv; - + if (G.is_break) return 1; - + /* during render, rv3d->engine can get freed */ if (render_view3d_is_valid(rp) == false) { *rp->stop = 1; } - + return *(rp->stop); } static void render_view3d_display_update(void *rpv, RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect)) { RenderPreview *rp = rpv; - + *(rp->do_update) = true; } @@ -1158,7 +1158,7 @@ static void render_view3d_renderinfo_cb(void *rjp, RenderStats *rs) } else { make_renderinfo_string(rs, rp->scene, false, NULL, rp->engine->text); - + /* make jobs timer to send notifier */ *(rp->do_update) = true; } @@ -1218,24 +1218,24 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda //printf("ma %d res %d view %d db %d\n", update_flag & PR_UPDATE_MATERIAL, update_flag & PR_UPDATE_RENDERSIZE, update_flag & PR_UPDATE_VIEW, update_flag & PR_UPDATE_DATABASE); G.is_break = false; - + if (false == render_view3d_get_rects(rp->ar, rp->v3d, rp->rv3d, &viewplane, rp->engine, &clipsta, &clipend, &pixsize, &orth)) return; - + rp->stop = stop; rp->do_update = do_update; // printf("Enter previewrender\n"); - + /* ok, are we rendering all over? */ sprintf(name, "View3dPreview %p", (void *)rp->ar); re = rp->engine->re = RE_GetRender(name); - + /* set this always, rp is different for each job */ RE_test_break_cb(re, rp, render_view3d_break); RE_display_update_cb(re, rp, render_view3d_display_update); RE_stats_draw_cb(re, rp, render_view3d_renderinfo_cb); - + rstats = RE_GetStats(re); if (update_flag & PR_UPDATE_VIEW) { @@ -1282,7 +1282,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda RE_SetWindow(re, &viewplane, clipsta, clipend); RE_SetPixelSize(re, pixsize); - + if ((update_flag & PR_UPDATE_DATABASE) || rstats->convertdone == 0) { unsigned int lay = rp->scene->lay; @@ -1290,7 +1290,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda if (rp->v3d->lay & 0xFF000000) lay |= rp->v3d->lay; else lay = rp->v3d->lay; - + RE_SetView(re, rp->viewmat); /* copying blender data while main thread is locked, to avoid crashes */ @@ -1366,7 +1366,7 @@ static void render_view3d_startjob(void *customdata, short *stop, short *do_upda static void render_view3d_free(void *customdata) { RenderPreview *rp = customdata; - + MEM_freeN(rp); } @@ -1384,7 +1384,7 @@ static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C) bool orth; int job_update_flag = 0; char name[32]; - + /* ensure render engine exists */ re = engine->re; @@ -1400,10 +1400,10 @@ static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C) /* check update_flag */ if (engine->update_flag & RE_ENGINE_UPDATE_MA) job_update_flag |= PR_UPDATE_MATERIAL; - + if (engine->update_flag & RE_ENGINE_UPDATE_OTHER) job_update_flag |= PR_UPDATE_MATERIAL; - + if (engine->update_flag & RE_ENGINE_UPDATE_DATABASE) { job_update_flag |= PR_UPDATE_DATABASE; @@ -1411,9 +1411,9 @@ static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C) if (scene->obedit) ED_object_editmode_load(bmain, scene->obedit); } - + engine->update_flag = 0; - + /* check if viewport changed */ if (engine->last_winx != ar->winx || engine->last_winy != ar->winy) { engine->last_winx = ar->winx; @@ -1425,14 +1425,14 @@ static bool render_view3d_flag_changed(RenderEngine *engine, const bContext *C) copy_m4_m4(engine->last_viewmat, rv3d->viewmat); job_update_flag |= PR_UPDATE_VIEW; } - + render_view3d_get_rects(ar, v3d, rv3d, &viewplane, engine, &clipsta, &clipend, NULL, &orth); - + if (BLI_rctf_compare(&viewplane, &engine->last_viewplane, 0.00001f) == 0) { engine->last_viewplane = viewplane; job_update_flag |= PR_UPDATE_VIEW; } - + render_view3d_disprect(scene, ar, v3d, rv3d, &disprect); if (BLI_rcti_compare(&disprect, &engine->last_disprect) == 0) { engine->last_disprect = disprect; @@ -1487,23 +1487,23 @@ static void render_view3d_do(RenderEngine *engine, const bContext *C) rp->start_resolution_divider = divider; rp->has_freestyle = (scene->r.mode & R_EDGE_FRS) != 0; copy_m4_m4(rp->viewmat, rp->rv3d->viewmat); - + /* clear info text */ engine->text[0] = '\0'; - + /* setup job */ WM_jobs_customdata_set(wm_job, rp, render_view3d_free); WM_jobs_timer(wm_job, 0.1, NC_SPACE | ND_SPACE_VIEW3D, NC_SPACE | ND_SPACE_VIEW3D); WM_jobs_callbacks(wm_job, render_view3d_startjob, NULL, NULL, NULL); - + WM_jobs_start(CTX_wm_manager(C), wm_job); - + engine->flag &= ~RE_ENGINE_DO_UPDATE; } /* callback for render engine, on changes */ void render_view3d_update(RenderEngine *engine, const bContext *C) -{ +{ /* this shouldn't be needed and causes too many database rebuilds, but we * aren't actually tracking updates for all relevant datablocks so this is * a catch-all for updates */ @@ -1517,19 +1517,19 @@ void render_view3d_draw(RenderEngine *engine, const bContext *C) Render *re = engine->re; RenderResult rres; char name[32]; - + render_view3d_do(engine, C); - + if (re == NULL) { sprintf(name, "View3dPreview %p", (void *)CTX_wm_region(C)); re = RE_GetRender(name); - + if (re == NULL) return; } - + /* Viewport render preview doesn't support multiview, view hardcoded to 0 */ RE_AcquireResultImage(re, &rres, 0); - + if (rres.rectf) { RegionView3D *rv3d = CTX_wm_region_view3d(C); View3D *v3d = CTX_wm_view3d(C); @@ -1617,13 +1617,13 @@ void ED_viewport_render_kill_jobs(wmWindowManager *wm, for (sa = sc->areabase.first; sa; sa = sa->next) { if (sa->spacetype != SPACE_VIEW3D) continue; - + for (ar = sa->regionbase.first; ar; ar = ar->next) { RegionView3D *rv3d; - + if (ar->regiontype != RGN_TYPE_WINDOW) continue; - + rv3d = ar->regiondata; if (rv3d->render_engine) { @@ -1656,10 +1656,10 @@ Scene *ED_render_job_get_scene(const bContext *C) { wmWindowManager *wm = CTX_wm_manager(C); RenderJob *rj = (RenderJob *)WM_jobs_customdata_from_type(wm, WM_JOB_TYPE_RENDER); - + if (rj) return rj->scene; - + return NULL; } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 1133b5f79d1..cdbfac06422 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -458,7 +458,7 @@ static void add_gpencil_renderpass(OGLRender *oglrender, RenderResult *rr, Rende short oldalphamode = scene->r.alphamode; /* set alpha transparent for gp */ scene->r.alphamode = R_ALPHAPREMUL; - + /* saves layer status */ short *oldsts = MEM_mallocN(BLI_listbase_count(&gpd->layers) * sizeof(short), "temp_gplayers_flag"); int i = 0; @@ -480,7 +480,7 @@ static void add_gpencil_renderpass(OGLRender *oglrender, RenderResult *rr, Rende /* render this gp layer */ screen_opengl_render_doit(oglrender, rr); - + /* add RendePass composite */ RenderPass *rp = RE_create_gp_pass(rr, gpl->info, rv->name); @@ -1105,7 +1105,7 @@ static int screen_opengl_render_modal(bContext *C, wmOperator *op, const wmEvent /* run first because screen_opengl_render_anim_step can free oglrender */ WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, oglrender->scene); - + if (anim == 0) { screen_opengl_render_apply(op->customdata); screen_opengl_render_end(C, op->customdata); @@ -1135,16 +1135,16 @@ static int screen_opengl_render_invoke(bContext *C, wmOperator *op, const wmEven if (!screen_opengl_render_anim_initialize(C, op)) return OPERATOR_CANCELLED; } - + oglrender = op->customdata; render_view_open(C, event->x, event->y, op->reports); - + /* view may be changed above (R_OUTPUT_WINDOW) */ oglrender->win = CTX_wm_window(C); WM_event_add_modal_handler(C, op); oglrender->timer = WM_event_add_timer(oglrender->wm, oglrender->win, TIMER, 0.01f); - + return OPERATOR_RUNNING_MODAL; } diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index 963153c559e..9a2549fca81 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -52,7 +52,7 @@ void ED_operatortypes_render(void) WM_operatortype_append(MATERIAL_OT_new); WM_operatortype_append(TEXTURE_OT_new); WM_operatortype_append(WORLD_OT_new); - + WM_operatortype_append(MATERIAL_OT_copy); WM_operatortype_append(MATERIAL_OT_paste); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index d236a7ba93d..dc79d5d9847 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -40,7 +40,7 @@ #include #else #include -#endif +#endif #include "MEM_guardedalloc.h" #include "BLI_math.h" @@ -147,20 +147,20 @@ typedef struct ShaderPreview { /* from wmJob */ void *owner; short *stop, *do_update; - + Scene *scene; ID *id; ID *parent; MTex *slot; - + /* datablocks with nodes need full copy during preview render, glsl uses it too */ Material *matcopy; Tex *texcopy; Lamp *lampcopy; World *worldcopy; - + float col[4]; /* active object color */ - + int sizex, sizey; unsigned int *pr_rect; int pr_method; @@ -265,7 +265,7 @@ static int preview_mat_has_sss(Material *mat, bNodeTree *ntree) static Scene *preview_get_scene(Main *pr_main) { if (pr_main == NULL) return NULL; - + return pr_main->scene.first; } @@ -282,7 +282,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty sce = preview_get_scene(pr_main); if (sce) { - + /* this flag tells render to not execute depsgraph or ipos etc */ sce->r.scemode |= R_BUTS_PREVIEW; /* set world always back, is used now */ @@ -292,13 +292,13 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty sce->world->exp = scene->world->exp; sce->world->range = scene->world->range; } - + sce->r.color_mgt_flag = scene->r.color_mgt_flag; BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings); BKE_color_managed_view_settings_free(&sce->view_settings); BKE_color_managed_view_settings_copy(&sce->view_settings, &scene->view_settings); - + /* prevent overhead for small renders and icons (32) */ if (id && sp->sizex < 40) { sce->r.tilex = sce->r.tiley = 64; @@ -307,7 +307,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty sce->r.tilex = sce->r.xsch / 4; sce->r.tiley = sce->r.ysch / 4; } - + if ((id && sp->pr_method == PR_ICON_RENDER) && id_type != ID_WO) sce->r.alphamode = R_ALPHAPREMUL; else @@ -325,20 +325,20 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty else { BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine)); } - + if (id_type == ID_MA) { Material *mat = NULL, *origmat = (Material *)id; - + if (origmat) { /* work on a copy */ mat = BKE_material_localize(origmat); sp->matcopy = mat; BLI_addtail(&pr_main->mat, mat); - + if (!BKE_scene_use_new_shading_nodes(scene)) { init_render_material(bmain, mat, 0, NULL); /* call that retrieves mode_l */ end_render_material(mat); - + /* un-useful option */ if (sp->pr_method == PR_ICON_RENDER) mat->shade_flag &= ~MA_OBCOLOR; @@ -352,7 +352,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty sce->r.mode |= R_RAYTRACE; if (preview_mat_has_sss(mat, NULL)) sce->r.mode |= R_SSS; - + /* turn off fake shadows if needed */ /* this only works in a specific case where the preview.blend contains * an object starting with 'c' which has a material linked to it (not the obdata) @@ -366,8 +366,8 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty } } } - - /* turn off bounce lights for volume, + + /* turn off bounce lights for volume, * doesn't make much visual difference and slows it down too */ for (base = sce->base.first; base; base = base->next) { if (base->object->type == OB_LAMP) { @@ -395,7 +395,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty sce->world->horb = 0.5f; } } - + if (sp->pr_method == PR_ICON_RENDER) { if (mat->material_type == MA_TYPE_HALO) { sce->lay = 1 << MA_FLAT; @@ -415,14 +415,14 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty } else { sce->r.mode &= ~(R_OSA | R_RAYTRACE | R_SSS); - + } - + for (base = sce->base.first; base; base = base->next) { if (base->object->id.name[2] == 'p') { /* copy over object color, in case material uses it */ copy_v4_v4(base->object->col, sp->col); - + if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) { /* don't use assign_material, it changed mat->id.us, which shows in the UI */ Material ***matar = give_matarar(base->object); @@ -439,20 +439,20 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty } else if (id_type == ID_TE) { Tex *tex = NULL, *origtex = (Tex *)id; - + if (origtex) { tex = BKE_texture_localize(origtex); sp->texcopy = tex; BLI_addtail(&pr_main->tex, tex); } sce->lay = 1 << MA_TEXTURE; - + for (base = sce->base.first; base; base = base->next) { if (base->object->id.name[2] == 't') { Material *mat = give_current_material(base->object, base->object->actcol); if (mat && mat->mtex[0]) { mat->mtex[0]->tex = tex; - + if (tex && sp->slot) mat->mtex[0]->which_output = sp->slot->which_output; @@ -508,7 +508,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty sce->world->horb = 0.0f; } } - + for (base = sce->base.first; base; base = base->next) { if (base->object->id.name[2] == 'p') { if (base->object->type == OB_LAMP) @@ -543,7 +543,7 @@ static Scene *preview_prepare_scene(Main *bmain, Scene *scene, ID *id, int id_ty return sce; } - + return NULL; } @@ -592,7 +592,7 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, } if (rv && rv->rectf) { - + if (ABS(rres.rectx - newx) < 2 && ABS(rres.recty - newy) < 2) { newrect->xmax = max_ii(newrect->xmax, rect->xmin + rres.rectx + offx); @@ -608,9 +608,9 @@ static bool ed_preview_draw_rect(ScrArea *sa, int split, int first, rcti *rect, RE_AcquiredResultGet32(re, &rres, (unsigned int *)rect_byte, 0); glaDrawPixelsSafe(fx, fy, rres.rectx, rres.recty, rres.rectx, GL_RGBA, GL_UNSIGNED_BYTE, rect_byte); - + MEM_freeN(rect_byte); - + ok = 1; } } @@ -672,7 +672,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r static void shader_preview_update(void *spv, RenderResult *UNUSED(rr), volatile struct rcti *UNUSED(rect)) { ShaderPreview *sp = spv; - + *(sp->do_update) = true; } @@ -688,30 +688,30 @@ static int shader_preview_break(void *spv) static void shader_preview_updatejob(void *spv) { ShaderPreview *sp = spv; - + if (sp->id) { if (sp->pr_method == PR_NODE_RENDER) { if (GS(sp->id->name) == ID_MA) { Material *mat = (Material *)sp->id; - + if (sp->matcopy && mat->nodetree && sp->matcopy->nodetree) ntreeLocalSync(sp->matcopy->nodetree, mat->nodetree); } else if (GS(sp->id->name) == ID_TE) { Tex *tex = (Tex *)sp->id; - + if (sp->texcopy && tex->nodetree && sp->texcopy->nodetree) ntreeLocalSync(sp->texcopy->nodetree, tex->nodetree); } else if (GS(sp->id->name) == ID_WO) { World *wrld = (World *)sp->id; - + if (sp->worldcopy && wrld->nodetree && sp->worldcopy->nodetree) ntreeLocalSync(sp->worldcopy->nodetree, wrld->nodetree); } else if (GS(sp->id->name) == ID_LA) { Lamp *la = (Lamp *)sp->id; - + if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); } @@ -728,7 +728,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs char name[32]; int sizex; Main *pr_main = sp->pr_main; - + /* in case of split preview, use border render */ if (split) { if (first) sizex = sp->sizex / 2; @@ -745,19 +745,19 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs sce->r.ysch = sp->sizey; sce->r.size = 100; } - + /* get the stuff from the builtin preview dbase */ sce = preview_prepare_scene(sp->bmain, sp->scene, id, idtype, sp); if (sce == NULL) return; - + if (!split || first) sprintf(name, "Preview %p", sp->owner); else sprintf(name, "SecondPreview %p", sp->owner); re = RE_GetRender(name); - + /* full refreshed render from first tile */ if (re == NULL) re = RE_NewRender(name); - + /* sce->r gets copied in RE_InitState! */ sce->r.scemode &= ~(R_MATNODE_PREVIEW | R_TEXNODE_PREVIEW); sce->r.scemode &= ~R_NO_IMAGE_LOAD; @@ -782,7 +782,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } /* set this for all previews, default is react to G.is_break still */ RE_test_break_cb(re, sp, shader_preview_break); - + /* lens adjust */ oldlens = ((Camera *)sce->camera->data)->lens; if (sizex > sp->sizey) @@ -796,14 +796,14 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs /* handle results */ if (sp->pr_method == PR_ICON_RENDER) { // char *rct= (char *)(sp->pr_rect + 32*16 + 16); - + if (sp->pr_rect) RE_ResultGet32(re, sp->pr_rect); } /* unassign the pointers, reset vars */ preview_prepare_scene(sp->bmain, sp->scene, NULL, GS(id->name), sp); - + /* XXX bad exception, end-exec is not being called in render, because it uses local main */ // if (idtype == ID_TE) { // Tex *tex= (Tex *)id; @@ -835,16 +835,16 @@ static void shader_preview_free(void *customdata) { ShaderPreview *sp = customdata; Main *pr_main = sp->pr_main; - + if (sp->matcopy) { struct IDProperty *properties; - + /* node previews */ shader_preview_updatejob(sp); - + /* get rid of copied material */ BLI_remlink(&pr_main->mat, sp->matcopy); - + BKE_material_free(sp->matcopy); properties = IDP_GetProperties((ID *)sp->matcopy, false); @@ -858,11 +858,11 @@ static void shader_preview_free(void *customdata) struct IDProperty *properties; /* node previews */ shader_preview_updatejob(sp); - + /* get rid of copied texture */ BLI_remlink(&pr_main->tex, sp->texcopy); BKE_texture_free(sp->texcopy); - + properties = IDP_GetProperties((ID *)sp->texcopy, false); if (properties) { IDP_FreeProperty(properties); @@ -874,11 +874,11 @@ static void shader_preview_free(void *customdata) struct IDProperty *properties; /* node previews */ shader_preview_updatejob(sp); - + /* get rid of copied world */ BLI_remlink(&pr_main->world, sp->worldcopy); BKE_world_free(sp->worldcopy); - + properties = IDP_GetProperties((ID *)sp->worldcopy, false); if (properties) { IDP_FreeProperty(properties); @@ -890,11 +890,11 @@ static void shader_preview_free(void *customdata) struct IDProperty *properties; /* node previews */ shader_preview_updatejob(sp); - + /* get rid of copied lamp */ BLI_remlink(&pr_main->lamp, sp->lampcopy); BKE_lamp_free(sp->lampcopy); - + properties = IDP_GetProperties((ID *)sp->lampcopy, false); if (properties) { IDP_FreeProperty(properties); @@ -902,7 +902,7 @@ static void shader_preview_free(void *customdata) } MEM_freeN(sp->lampcopy); } - + MEM_freeN(sp); } @@ -918,13 +918,13 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned /* paranoia test */ if (ibuf == NULL || (ibuf->rect == NULL && ibuf->rect_float == NULL)) return; - + /* waste of cpu cyles... but the imbuf API has no other way to scale fast (ton) */ ima = IMB_dupImBuf(ibuf); - - if (!ima) + + if (!ima) return; - + if (ima->x > ima->y) { scaledx = (float)w; scaledy = ( (float)ima->y / (float)ima->x) * (float)w; @@ -933,15 +933,15 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned scaledx = ( (float)ima->x / (float)ima->y) * (float)h; scaledy = (float)h; } - + ex = (short)scaledx; ey = (short)scaledy; - + dx = (w - ex) / 2; dy = (h - ey) / 2; - + IMB_scalefastImBuf(ima, ex, ey); - + /* if needed, convert to 32 bits */ if (ima->rect == NULL) IMB_rect_from_float(ima); @@ -959,7 +959,7 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned IMB_freeImBuf(ima); } -static void set_alpha(char *cp, int sizex, int sizey, char alpha) +static void set_alpha(char *cp, int sizex, int sizey, char alpha) { int a, size = sizex * sizey; @@ -1148,7 +1148,7 @@ static void icon_preview_endjob(void *customdata) if (GS(ip->id->name) == ID_BR) WM_main_add_notifier(NC_BRUSH | NA_EDITED, ip->id); -#if 0 +#if 0 if (GS(ip->id->name) == ID_MA) { Material *ma = (Material *)ip->id; PreviewImage *prv_img = ma->preview; @@ -1290,12 +1290,12 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M if (ob && ob->totcol) copy_v4_v4(sp->col, ob->col); else sp->col[0] = sp->col[1] = sp->col[2] = sp->col[3] = 1.0f; - + /* setup job */ WM_jobs_customdata_set(wm_job, sp, shader_preview_free); WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL); WM_jobs_callbacks(wm_job, common_preview_startjob, NULL, shader_preview_updatejob, NULL); - + WM_jobs_start(CTX_wm_manager(C), wm_job); } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 820042ac172..fe87f8bdbb2 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -102,7 +102,7 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) if (!ob) return OPERATOR_CANCELLED; - + BKE_object_material_slot_add(bmain, ob); if (ob->mode & OB_MODE_TEXTURE_PAINT) { @@ -110,11 +110,11 @@ static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op)) BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } - + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob); - + return OPERATOR_FINISHED; } @@ -124,7 +124,7 @@ void OBJECT_OT_material_slot_add(wmOperatorType *ot) ot->name = "Add Material Slot"; ot->idname = "OBJECT_OT_material_slot_add"; ot->description = "Add a new material slot"; - + /* api callbacks */ ot->exec = material_slot_add_exec; ot->poll = ED_operator_object_active_editable; @@ -145,7 +145,7 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode"); return OPERATOR_CANCELLED; } - + BKE_object_material_slot_remove(CTX_data_main(C), ob); if (ob->mode & OB_MODE_TEXTURE_PAINT) { @@ -153,12 +153,12 @@ static int material_slot_remove_exec(bContext *C, wmOperator *op) BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob); - + return OPERATOR_FINISHED; } @@ -168,7 +168,7 @@ void OBJECT_OT_material_slot_remove(wmOperatorType *ot) ot->name = "Remove Material Slot"; ot->idname = "OBJECT_OT_material_slot_remove"; ot->description = "Remove the selected material slot"; - + /* api callbacks */ ot->exec = material_slot_remove_exec; ot->poll = ED_operator_object_active_editable; @@ -222,7 +222,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); - + return OPERATOR_FINISHED; } @@ -232,7 +232,7 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot) ot->name = "Assign Material Slot"; ot->idname = "OBJECT_OT_material_slot_assign"; ot->description = "Assign active material slot to selection"; - + /* api callbacks */ ot->exec = material_slot_assign_exec; ot->poll = ED_operator_object_active_editable; @@ -316,7 +316,7 @@ void OBJECT_OT_material_slot_select(wmOperatorType *ot) ot->name = "Select Material Slot"; ot->idname = "OBJECT_OT_material_slot_select"; ot->description = "Select by active material slot"; - + /* api callbacks */ ot->exec = material_slot_select_exec; @@ -335,7 +335,7 @@ void OBJECT_OT_material_slot_deselect(wmOperatorType *ot) ot->name = "Deselect Material Slot"; ot->idname = "OBJECT_OT_material_slot_deselect"; ot->description = "Deselect by active material slot"; - + /* api callbacks */ ot->exec = material_slot_deselect_exec; @@ -358,7 +358,7 @@ static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op)) if (ob != ob_iter && give_matarar(ob_iter)) { if (ob->data != ob_iter->data) assign_matarar(bmain, ob_iter, matar, ob->totcol); - + if (ob_iter->totcol == ob->totcol) { ob_iter->actcol = ob->actcol; DAG_id_tag_update(&ob_iter->id, OB_RECALC_DATA); @@ -493,7 +493,7 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_MATERIAL | NA_ADDED, ma); - + return OPERATOR_FINISHED; } @@ -503,7 +503,7 @@ void MATERIAL_OT_new(wmOperatorType *ot) ot->name = "New Material"; ot->idname = "MATERIAL_OT_new"; ot->description = "Add a new material"; - + /* api callbacks */ ot->exec = new_material_exec; @@ -550,7 +550,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, tex); - + return OPERATOR_FINISHED; } @@ -560,7 +560,7 @@ void TEXTURE_OT_new(wmOperatorType *ot) ot->name = "New Texture"; ot->idname = "TEXTURE_OT_new"; ot->description = "Add a new texture"; - + /* api callbacks */ ot->exec = new_texture_exec; @@ -605,7 +605,7 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_WORLD | NA_ADDED, wo); - + return OPERATOR_FINISHED; } @@ -615,7 +615,7 @@ void WORLD_OT_new(wmOperatorType *ot) ot->name = "New World"; ot->idname = "WORLD_OT_new"; ot->description = "Create a new world Data-Block"; - + /* api callbacks */ ot->exec = new_world_exec; @@ -634,7 +634,7 @@ static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&scene->id, 0); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); - + return OPERATOR_FINISHED; } @@ -644,7 +644,7 @@ void SCENE_OT_render_layer_add(wmOperatorType *ot) ot->name = "Add Render Layer"; ot->idname = "SCENE_OT_render_layer_add"; ot->description = "Add a render layer"; - + /* api callbacks */ ot->exec = render_layer_add_exec; @@ -662,7 +662,7 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&scene->id, 0); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); - + return OPERATOR_FINISHED; } @@ -672,7 +672,7 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot) ot->name = "Remove Render Layer"; ot->idname = "SCENE_OT_render_layer_remove"; ot->description = "Remove the selected render layer"; - + /* api callbacks */ ot->exec = render_layer_remove_exec; @@ -1451,7 +1451,7 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op) mtexswap = mtex_ar[act]; mtex_ar[act] = mtex_ar[act - 1]; mtex_ar[act - 1] = mtexswap; - + BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act - 1, -1, 0); BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act - 1, 0); BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0); @@ -1464,7 +1464,7 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op) ma->septex &= ~(1 << (act - 1)); ma->septex |= mtexuse >> 1; } - + set_active_mtex(id, act - 1); } } @@ -1473,7 +1473,7 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op) mtexswap = mtex_ar[act]; mtex_ar[act] = mtex_ar[act + 1]; mtex_ar[act + 1] = mtexswap; - + BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act + 1, -1, 0); BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act + 1, 0); BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0); @@ -1486,7 +1486,7 @@ static int texture_slot_move_exec(bContext *C, wmOperator *op) ma->septex &= ~(1 << (act + 1)); ma->septex |= mtexuse << 1; } - + set_active_mtex(id, act + 1); } } @@ -1552,35 +1552,35 @@ static int envmap_save_exec(bContext *C, wmOperator *op) //int imtype = RNA_enum_get(op->ptr, "file_type"); char imtype = scene->r.im_format.imtype; char path[FILE_MAX]; - + RNA_string_get(op->ptr, "filepath", path); - + if (scene->r.scemode & R_EXTENSION) { BKE_image_path_ensure_ext_from_imformat(path, &scene->r.im_format); } - + WM_cursor_wait(1); - + save_envmap(op, scene, tex->env, path, imtype); - + WM_cursor_wait(0); - + WM_event_add_notifier(C, NC_TEXTURE, tex); - + return OPERATOR_FINISHED; } static int envmap_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { //Scene *scene= CTX_data_scene(C); - + if (RNA_struct_property_is_set(op->ptr, "filepath")) return envmap_save_exec(C, op); //RNA_enum_set(op->ptr, "file_type", scene->r.im_format.imtype); RNA_string_set(op->ptr, "filepath", G.main->name); WM_event_add_fileselect(C, op); - + return OPERATOR_RUNNING_MODAL; } @@ -1588,13 +1588,13 @@ static int envmap_save_poll(bContext *C) { Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - if (!tex) + if (!tex) return 0; if (!tex->env || !tex->env->ok) return 0; if (tex->env->cube[1] == NULL) return 0; - + return 1; } @@ -1605,15 +1605,15 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot) ot->name = "Save Environment Map"; ot->idname = "TEXTURE_OT_envmap_save"; ot->description = "Save the current generated Environment map to an image file"; - + /* api callbacks */ ot->exec = envmap_save_exec; ot->invoke = envmap_save_invoke; ot->poll = envmap_save_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo since this doesnt modify the env-map */ - + /* properties */ prop = RNA_def_float_array(ot->srna, "layout", 12, default_envmap_layout, 0.0f, 0.0f, "File layout", @@ -1630,25 +1630,25 @@ void TEXTURE_OT_envmap_save(wmOperatorType *ot) static int envmap_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - + BKE_texture_envmap_free_data(tex->env); - + WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex); - + return OPERATOR_FINISHED; } static int envmap_clear_poll(bContext *C) { Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - - if (!tex) + + if (!tex) return 0; if (!tex->env || !tex->env->ok) return 0; if (tex->env->cube[1] == NULL) return 0; - + return 1; } @@ -1658,11 +1658,11 @@ void TEXTURE_OT_envmap_clear(wmOperatorType *ot) ot->name = "Clear Environment Map"; ot->idname = "TEXTURE_OT_envmap_clear"; ot->description = "Discard the environment map and free it from memory"; - + /* api callbacks */ ot->exec = envmap_clear_exec; ot->poll = envmap_clear_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; } @@ -1671,13 +1671,13 @@ static int envmap_clear_all_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Tex *tex; - + for (tex = bmain->tex.first; tex; tex = tex->id.next) if (tex->env) BKE_texture_envmap_free_data(tex->env); - + WM_event_add_notifier(C, NC_TEXTURE | NA_EDITED, tex); - + return OPERATOR_FINISHED; } @@ -1687,11 +1687,11 @@ void TEXTURE_OT_envmap_clear_all(wmOperatorType *ot) ot->name = "Clear All Environment Maps"; ot->idname = "TEXTURE_OT_envmap_clear_all"; ot->description = "Discard all environment maps in the .blend file and free them from memory"; - + /* api callbacks */ ot->exec = envmap_clear_all_exec; ot->poll = envmap_clear_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1765,7 +1765,7 @@ void ED_render_clear_mtex_copybuf(void) static void copy_mtex_copybuf(ID *id) { MTex **mtex = NULL; - + switch (GS(id->name)) { case ID_MA: mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]); @@ -1787,7 +1787,7 @@ static void copy_mtex_copybuf(ID *id) default: break; } - + if (mtex && *mtex) { memcpy(&mtexcopybuf, *mtex, sizeof(MTex)); mtexcopied = 1; @@ -1800,10 +1800,10 @@ static void copy_mtex_copybuf(ID *id) static void paste_mtex_copybuf(ID *id) { MTex **mtex = NULL; - + if (mtexcopied == 0 || mtexcopybuf.tex == NULL) return; - + switch (GS(id->name)) { case ID_MA: mtex = &(((Material *)id)->mtex[(int)((Material *)id)->texact]); @@ -1826,7 +1826,7 @@ static void paste_mtex_copybuf(ID *id) BLI_assert(!"invalid id type"); return; } - + if (mtex) { if (*mtex == NULL) { *mtex = MEM_mallocN(sizeof(MTex), "mtex copy"); @@ -1834,9 +1834,9 @@ static void paste_mtex_copybuf(ID *id) else if ((*mtex)->tex) { id_us_min(&(*mtex)->tex->id); } - + memcpy(*mtex, &mtexcopybuf, sizeof(MTex)); - + id_us_plus((ID *)mtexcopybuf.tex); } } @@ -1860,7 +1860,7 @@ static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op)) static int copy_mtex_poll(bContext *C) { ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).id.data; - + return (id != NULL); } @@ -1874,7 +1874,7 @@ void TEXTURE_OT_slot_copy(wmOperatorType *ot) /* api callbacks */ ot->exec = copy_mtex_exec; ot->poll = copy_mtex_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_INTERNAL; /* no undo needed since no changes are made to the mtex */ } @@ -1900,7 +1900,7 @@ static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op)) id = &psys->part->id; else if (linestyle) id = &linestyle->id; - + if (id == NULL) return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 084e3fce8e6..ceb4c0b27ba 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -100,14 +100,14 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated) CTX_wm_manager_set(C, bmain->wm.first); wm = bmain->wm.first; - + for (win = wm->windows.first; win; win = win->next) { bScreen *sc = win->screen; ScrArea *sa; ARegion *ar; - + CTX_wm_window_set(C, win); - + for (sa = sc->areabase.first; sa; sa = sa->next) { if (sa->spacetype != SPACE_VIEW3D) continue; @@ -207,22 +207,22 @@ static void render_engine_flag_changed(Main *bmain, int update_flag) bScreen *sc; ScrArea *sa; ARegion *ar; - + for (sc = bmain->screen.first; sc; sc = sc->id.next) { for (sa = sc->areabase.first; sa; sa = sa->next) { if (sa->spacetype != SPACE_VIEW3D) continue; - + for (ar = sa->regionbase.first; ar; ar = ar->next) { RegionView3D *rv3d; - + if (ar->regiontype != RGN_TYPE_WINDOW) continue; - + rv3d = ar->regiondata; if (rv3d->render_engine) rv3d->render_engine->update_flag |= update_flag; - + } } } @@ -238,7 +238,7 @@ static int mtex_use_tex(MTex **mtex, int tot, Tex *tex) for (a = 0; a < tot; a++) if (mtex[a] && mtex[a]->tex == tex) return 1; - + return 0; } @@ -368,7 +368,7 @@ static int material_uses_texture(Material *ma, Tex *tex) return true; else if (ma->use_nodes && ma->nodetree && nodes_use_tex(ma->nodetree, tex)) return true; - + return false; } @@ -426,9 +426,9 @@ static void texture_changed(Main *bmain, Tex *tex) } BKE_icon_changed(BKE_icon_id_ensure(&wo->id)); - + if (wo->gpumaterial.first) - GPU_material_free(&wo->gpumaterial); + GPU_material_free(&wo->gpumaterial); } /* find compositing nodes */ @@ -474,7 +474,7 @@ static void world_changed(Main *bmain, World *wo) /* icons */ BKE_icon_changed(BKE_icon_id_ensure(&wo->id)); - + /* glsl */ for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->gpumaterial.first) @@ -482,7 +482,7 @@ static void world_changed(Main *bmain, World *wo) if (defmaterial.gpumaterial.first) GPU_material_free(&defmaterial.gpumaterial); - + if (wo->gpumaterial.first) GPU_material_free(&wo->gpumaterial); } @@ -510,7 +510,7 @@ static void scene_changed(Main *bmain, Scene *scene) for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->gpulamp.first) GPU_lamp_free(ob); - + if (ob->mode & OB_MODE_TEXTURE_PAINT) { BKE_texpaint_slots_refresh_object(scene, ob); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); @@ -525,7 +525,7 @@ static void scene_changed(Main *bmain, Scene *scene) for (wo = bmain->world.first; wo; wo = wo->id.next) if (wo->gpumaterial.first) GPU_material_free(&wo->gpumaterial); - + if (defmaterial.gpumaterial.first) GPU_material_free(&defmaterial.gpumaterial); } @@ -563,15 +563,15 @@ void ED_render_id_flush_update(Main *bmain, ID *id) render_engine_flag_changed(bmain, RE_ENGINE_UPDATE_OTHER); break; } - + } void ED_render_internal_init(void) { RenderEngineType *ret = RE_engines_find(RE_engine_id_BLENDER_RENDER); - + ret->view_update = render_view3d_update; ret->view_draw = render_view3d_draw; - + } diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index c4a9af79ec2..de1194fe93d 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -102,7 +102,7 @@ static ScrArea *find_area_showing_r_result(bContext *C, Scene *scene, wmWindow * break; } } - + return sa; } @@ -137,7 +137,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) if (scene->r.displaymode == R_OUTPUT_NONE) return NULL; - + if (scene->r.displaymode == R_OUTPUT_WINDOW) { int sizex = 30 * UI_DPI_FAC + (scene->r.xsch * scene->r.size) / 100; int sizey = 60 * UI_DPI_FAC + (scene->r.ysch * scene->r.size) / 100; @@ -175,7 +175,7 @@ ScrArea *render_view_open(bContext *C, int mx, int my, ReportList *reports) sa = find_area_showing_r_result(C, scene, &win); if (sa == NULL) sa = find_area_image_empty(C); - + /* if area found in other window, we make that one show in front */ if (win && win != CTX_wm_window(C)) wm_window_raise(win); @@ -290,7 +290,7 @@ void RENDER_OT_view_cancel(struct wmOperatorType *ot) static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *event) { wmWindow *wincur = CTX_wm_window(C); - + /* test if we have currently a temp screen active */ if (wincur->screen->temp) { wm_window_lower(wincur); @@ -298,7 +298,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e else { wmWindow *win, *winshow; ScrArea *sa = find_area_showing_r_result(C, CTX_data_scene(C), &winshow); - + /* is there another window on current scene showing result? */ for (win = CTX_wm_manager(C)->windows.first; win; win = win->next) { bScreen *sc = win->screen; @@ -309,7 +309,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *op, const wmEvent *e return OPERATOR_FINISHED; } } - + /* determine if render already shows */ if (sa) { /* but don't close it when rendering */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 3f38de7b9ad..3f365fc1500 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -79,25 +79,25 @@ extern void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, static void region_draw_emboss(const ARegion *ar, const rcti *scirct) { rcti rect; - + /* translate scissor rect to region space */ rect.xmin = scirct->xmin - ar->winrct.xmin; rect.ymin = scirct->ymin - ar->winrct.ymin; rect.xmax = scirct->xmax - ar->winrct.xmin; rect.ymax = scirct->ymax - ar->winrct.ymin; - + /* set transp line */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + /* right */ glColor4ub(0, 0, 0, 30); sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax); - + /* bottom */ glColor4ub(0, 0, 0, 30); sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin); - + /* top */ glColor4ub(255, 255, 255, 30); sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax); @@ -105,7 +105,7 @@ static void region_draw_emboss(const ARegion *ar, const rcti *scirct) /* left */ glColor4ub(255, 255, 255, 30); sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax); - + glDisable(GL_BLEND); } @@ -232,14 +232,14 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + glColor4ub(255, 255, 255, 180); fdrawline(x1, y2, x2, y1); glColor4ub(255, 255, 255, 130); fdrawline(x1, y2 - dy, x2 - dx, y1); glColor4ub(255, 255, 255, 80); fdrawline(x1, y2 - 2 * dy, x2 - 2 * dx, y1); - + glColor4ub(0, 0, 0, 210); fdrawline(x1, y2 + 1, x2 + 1, y1); glColor4ub(0, 0, 0, 180); @@ -253,33 +253,33 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) static void region_draw_azone_icon(AZone *az) { - GLUquadricObj *qobj = NULL; + GLUquadricObj *qobj = NULL; short midx = az->x1 + (az->x2 - az->x1) / 2; short midy = az->y1 + (az->y2 - az->y1) / 2; - + qobj = gluNewQuadric(); - + glPushMatrix(); glTranslatef(midx, midy, 0.0); - + /* outlined circle */ glEnable(GL_LINE_SMOOTH); glColor4f(1.f, 1.f, 1.f, 0.8f); - gluQuadricDrawStyle(qobj, GLU_FILL); + gluQuadricDrawStyle(qobj, GLU_FILL); gluDisk(qobj, 0.0, 4.25f, 16, 1); glColor4f(0.2f, 0.2f, 0.2f, 0.9f); - - gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); + + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0.0, 4.25f, 16, 1); - + glDisable(GL_LINE_SMOOTH); - + glPopMatrix(); gluDeleteQuadric(qobj); - + /* + */ sdrawline(midx, midy - 2, midx, midy + 3); sdrawline(midx - 2, midy, midx + 3, midy); @@ -289,7 +289,7 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) { float width = 0.1f * U.widget_unit; float pad = 0.2f * U.widget_unit; - + glRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad); glRectf(x1 + pad, (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f); glRectf((x1 + x2 + width) * 0.5f, (y1 + y2 - width) * 0.5f, x2 - pad, (y1 + y2 + width) * 0.5f); @@ -298,7 +298,7 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) static void region_draw_azone_tab_plus(AZone *az) { glEnable(GL_BLEND); - + /* add code to draw region hidden as 'too small' */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: @@ -329,43 +329,43 @@ static void region_draw_azone_tab_plus(AZone *az) static void region_draw_azone_tab(AZone *az) { float col[3]; - + glEnable(GL_BLEND); UI_GetThemeColor3fv(TH_HEADER, col); glColor4f(col[0], col[1], col[2], 0.5f); - + /* add code to draw region hidden as 'too small' */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT | UI_RB_ALPHA); - + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); UI_draw_roundbox_unfilled((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_BOTTOM_TO_TOPLEFT: UI_draw_roundbox_corner_set(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); - + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); UI_draw_roundbox_unfilled((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_LEFT_TO_TOPRIGHT: UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); - + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); UI_draw_roundbox_unfilled((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); break; case AE_RIGHT_TO_TOPLEFT: UI_draw_roundbox_corner_set(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT | UI_RB_ALPHA); - + UI_draw_roundbox_shade_x(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); UI_draw_roundbox_unfilled((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f); break; } - + glDisable(GL_BLEND); } @@ -374,13 +374,13 @@ static void region_draw_azone_tria(AZone *az) glEnable(GL_BLEND); //UI_GetThemeColor3fv(TH_HEADER, col); glColor4f(0.0f, 0.0f, 0.0f, 0.35f); - + /* add code to draw region hidden as 'too small' */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1 + az->x2) / 2, (float)az->y2); break; - + case AE_BOTTOM_TO_TOPLEFT: ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1 + az->x2) / 2, (float)az->y1); break; @@ -388,13 +388,13 @@ static void region_draw_azone_tria(AZone *az) case AE_LEFT_TO_TOPRIGHT: ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1 + az->y2) / 2); break; - + case AE_RIGHT_TO_TOPLEFT: ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1 + az->y2) / 2); break; - + } - + glDisable(GL_BLEND); } @@ -416,7 +416,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) glPushMatrix(); glTranslatef(-ar->winrct.xmin, -ar->winrct.ymin, 0.0f); - + for (az = sa->actionzones.first; az; az = az->next) { /* test if action zone is over this region */ rcti azrct; @@ -427,7 +427,7 @@ static void region_draw_azones(ScrArea *sa, ARegion *ar) area_draw_azone(az->x1, az->y1, az->x2, az->y2); } else if (az->type == AZONE_REGION) { - + if (az->ar) { /* only display tab or icons when the region is hidden */ if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { @@ -463,14 +463,14 @@ void ED_region_set(const bContext *C, ARegion *ar) { wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); - + ar->drawrct = ar->winrct; - + /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, true); - + UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0); - + ED_region_pixelspace(ar); } @@ -499,19 +499,19 @@ void ED_region_do_draw(bContext *C, ARegion *ar) } ar->do_draw |= RGN_DRAWING; - + /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct, scissor_pad); wmOrtho2_region_pixelspace(ar); - + UI_SetTheme(sa ? sa->spacetype : 0, at->regionid); - + /* optional header info instead? */ if (ar->headerstr) { UI_ThemeClearColor(TH_HEADER); glClear(GL_COLOR_BUFFER_BIT); - + UI_ThemeColor(TH_TEXT); BLF_draw_default(UI_UNIT_X, 0.4f * UI_UNIT_Y, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX); } @@ -536,7 +536,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) #endif memset(&ar->drawrct, 0, sizeof(ar->drawrct)); - + UI_blocklist_free_inactive(C, &ar->uiblocks); if (sa) { @@ -601,7 +601,7 @@ void ED_region_tag_redraw_partial(ARegion *ar, const rcti *rct) void ED_area_tag_redraw(ScrArea *sa) { ARegion *ar; - + if (sa) for (ar = sa->regionbase.first; ar; ar = ar->next) ED_region_tag_redraw(ar); @@ -610,7 +610,7 @@ void ED_area_tag_redraw(ScrArea *sa) void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) { ARegion *ar; - + if (sa) { for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == regiontype) { @@ -659,7 +659,7 @@ void ED_area_headerprint(ScrArea *sa, const char *str) static void area_azone_initialize(wmWindow *win, bScreen *screen, ScrArea *sa) { AZone *az; - + /* reinitalize entirely, regions and fullscreen add azones too */ BLI_freelistN(&sa->actionzones); @@ -688,7 +688,7 @@ static void area_azone_initialize(wmWindow *win, bScreen *screen, ScrArea *sa) az->y2 = sa->totrct.ymin + (AZONESPOT - 1); BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); } - + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); az->type = AZONE_AREA; @@ -757,14 +757,14 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; int tot = 0; - + /* count how many actionzones with along same edge are available. * This allows for adding more action zones in the future without * having to worry about correct offset */ for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } - + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: az->x1 = ar->winrct.xmax - tot * 2 * AZONEPAD_ICON; @@ -793,7 +793,7 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) } BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); - + /* if more azones on 1 spot, set offset */ for (azt = sa->actionzones.first; azt; azt = azt->next) { if (az != azt) { @@ -820,11 +820,11 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; int tot = 0, add; - + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } - + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: add = (ar->winrct.ymax == sa->totrct.ymin) ? 1 : 0; @@ -854,7 +854,7 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) } /* rect needed for mouse pointer test */ BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); -} +} #define AZONEPAD_TABW (0.9f * U.widget_unit) @@ -865,11 +865,11 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; int tot = 0, add; - + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } - + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: add = (ar->winrct.ymax == sa->totrct.ymin) ? 1 : 0; @@ -899,7 +899,7 @@ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) } /* rect needed for mouse pointer test */ BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); -} +} #define AZONEPAD_TRIAW (0.8f * U.widget_unit) #define AZONEPAD_TRIAH (0.45f * U.widget_unit) @@ -910,11 +910,11 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; int tot = 0, add; - + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } - + switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: add = (ar->winrct.ymax == sa->totrct.ymin) ? 1 : 0; @@ -944,14 +944,14 @@ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) } /* rect needed for mouse pointer test */ BLI_rcti_init(&az->rect, az->x1, az->x2, az->y1, az->y2); -} +} static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge, const bool is_fullscreen) { AZone *az = NULL; const bool is_hidden = (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) == 0; - + if (is_hidden || !is_fullscreen) { az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); @@ -959,7 +959,7 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge, const az->ar = ar; az->edge = edge; } - + if (!is_hidden) { if (!is_fullscreen) { if (G.debug_value == 3) @@ -975,7 +975,7 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge, const else { region_azone_edge(az, ar); } - + } @@ -984,7 +984,7 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge, const static void region_azone_add(ScrArea *sa, ARegion *ar, const int alignment, const bool is_fullscreen) { /* edge code (t b l r) is along which area edge azone will be drawn */ - + if (alignment == RGN_ALIGN_TOP) region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); else if (alignment == RGN_ALIGN_BOTTOM) @@ -1091,20 +1091,20 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti rcti *remainder_prev = remainder; int prefsizex, prefsizey; int alignment; - + if (ar == NULL) return; - + /* no returns in function, winrct gets set in the end again */ BLI_rcti_init(&ar->winrct, 0, 0, 0, 0); - + /* for test; allow split of previously defined region */ if (ar->alignment & RGN_SPLIT_PREV) if (ar->prev) remainder = &ar->prev->winrct; - + alignment = ar->alignment & ~RGN_SPLIT_PREV; - + /* set here, assuming userpref switching forces to call this again */ ar->overlap = region_is_overlap(win, sa, ar); @@ -1113,10 +1113,10 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti /* user errors */ if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT) alignment = RGN_ALIGN_NONE; - + /* prefsize, for header we stick to exception (prevent dpi rounding error) */ prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex); - + if (ar->regiontype == RGN_TYPE_HEADER) { prefsizey = ED_area_headersize(); } @@ -1144,7 +1144,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti BLI_rcti_init(remainder, 0, 0, 0, 0); } else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) { - + if (rct_fits(remainder, 'v', prefsizey) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } @@ -1153,9 +1153,9 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti if (fac < 0) prefsizey += fac; - + ar->winrct = *remainder; - + if (alignment == RGN_ALIGN_TOP) { ar->winrct.ymin = ar->winrct.ymax - prefsizey + 1; remainder->ymax = ar->winrct.ymin - 1; @@ -1167,18 +1167,18 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti } } else if (ELEM(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) { - + if (rct_fits(remainder, 'h', prefsizex) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } else { int fac = rct_fits(remainder, 'h', prefsizex); - + if (fac < 0) prefsizex += fac; - + ar->winrct = *remainder; - + if (alignment == RGN_ALIGN_RIGHT) { ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1; if (ar->overlap == 0) @@ -1194,7 +1194,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti else if (alignment == RGN_ALIGN_VSPLIT || alignment == RGN_ALIGN_HSPLIT) { /* percentage subdiv*/ ar->winrct = *remainder; - + if (alignment == RGN_ALIGN_HSPLIT) { if (rct_fits(remainder, 'h', prefsizex) > 4) { ar->winrct.xmax = BLI_rcti_cent_x(remainder); @@ -1216,18 +1216,18 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti } else if (alignment == RGN_ALIGN_QSPLIT) { ar->winrct = *remainder; - + /* test if there's still 4 regions left */ if (quad == 0) { ARegion *artest = ar->next; int count = 1; - + while (artest) { artest->alignment = RGN_ALIGN_QSPLIT; artest = artest->next; count++; } - + if (count != 4) { /* let's stop adding regions */ BLI_rcti_init(remainder, 0, 0, 0, 0); @@ -1260,16 +1260,16 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti quad++; } } - + /* for speedup */ ar->winx = BLI_rcti_size_x(&ar->winrct) + 1; ar->winy = BLI_rcti_size_y(&ar->winrct) + 1; - + /* if region opened normally, we store this for hide/reveal usage */ /* prevent rounding errors for UI_DPI_FAC mult and divide */ if (ar->winx > 1) ar->sizex = (ar->winx + 0.5f) / UI_DPI_FAC; if (ar->winy > 1) ar->sizey = (ar->winy + 0.5f) / UI_DPI_FAC; - + /* exception for multiple overlapping regions on same spot */ if (ar->overlap) region_overlap_fix(sa, ar); @@ -1277,7 +1277,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti /* set winrect for azones */ if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { ar->winrct = *remainder; - + switch (alignment) { case RGN_ALIGN_TOP: ar->winrct.ymin = ar->winrct.ymax; @@ -1304,7 +1304,7 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti ar->prev->winy = BLI_rcti_size_y(&ar->prev->winrct) + 1; } } - + /* in end, add azones, where appropriate */ if (ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) { /* The logic for this is: when the header takes up the full area, @@ -1336,12 +1336,12 @@ static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) else sa->totrct.xmin = sa->v1->vec.x; if (sa->v4->vec.x < sizex - 1) sa->totrct.xmax = sa->v4->vec.x - rt; else sa->totrct.xmax = sa->v4->vec.x; - + if (sa->v1->vec.y > 0) sa->totrct.ymin = sa->v1->vec.y + rt; else sa->totrct.ymin = sa->v1->vec.y; if (sa->v2->vec.y < sizey - 1) sa->totrct.ymax = sa->v2->vec.y - rt; else sa->totrct.ymax = sa->v2->vec.y; - + /* for speedup */ sa->winx = BLI_rcti_size_x(&sa->totrct) + 1; sa->winy = BLI_rcti_size_y(&sa->totrct) + 1; @@ -1389,7 +1389,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand if (flag & ED_KEYMAP_MARKERS) { /* time-markers */ wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0); - + /* time space only has this keymap, the others get a boundbox restricted map */ if (sa->spacetype != SPACE_TIME) { ARegion *ar; @@ -1416,16 +1416,16 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand } if (flag & ED_KEYMAP_GPENCIL) { /* grease pencil */ - /* NOTE: This is now 2 keymaps - One for basic functionality, - * and one that only applies when "Edit Mode" is enabled + /* NOTE: This is now 2 keymaps - One for basic functionality, + * and one that only applies when "Edit Mode" is enabled * for strokes. * - * For now, it's easier to just include both, + * For now, it's easier to just include both, * since you hardly want one without the other. */ wmKeyMap *keymap_general = WM_keymap_find(wm->defaultconf, "Grease Pencil", 0, 0); wmKeyMap *keymap_edit = WM_keymap_find(wm->defaultconf, "Grease Pencil Stroke Edit Mode", 0, 0); - + WM_event_add_keymap_handler(handlers, keymap_general); WM_event_add_keymap_handler(handlers, keymap_edit); } @@ -1442,38 +1442,38 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) { ARegion *ar; rcti rect; - + /* set typedefinitions */ sa->type = BKE_spacetype_from_id(sa->spacetype); - + if (sa->type == NULL) { sa->butspacetype = sa->spacetype = SPACE_VIEW3D; sa->type = BKE_spacetype_from_id(sa->spacetype); } - + for (ar = sa->regionbase.first; ar; ar = ar->next) ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype); - + /* area sizes */ area_calc_totrct(sa, WM_window_pixels_x(win), WM_window_pixels_y(win)); - + /* clear all azones, add the area triange widgets */ area_azone_initialize(win, win->screen, sa); /* region rect sizes */ rect = sa->totrct; region_rect_recursive(win, sa, sa->regionbase.first, &rect, 0); - + /* default area handlers */ ed_default_handlers(wm, sa, &sa->handlers, sa->type->keymapflag); /* checks spacedata, adds own handlers */ if (sa->type->init) sa->type->init(wm, sa); - + /* region windows, default and own handlers */ for (ar = sa->regionbase.first; ar; ar = ar->next) { region_subwindow(win, ar, false); - + if (ar->swinid) { /* default region handlers */ ed_default_handlers(wm, sa, &ar->handlers, ar->type->keymapflag); @@ -1534,9 +1534,9 @@ void ED_region_cursor_set(wmWindow *win, ScrArea *sa, ARegion *ar) void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade) { ScrArea *sa = CTX_wm_area(C); - + ar->flag ^= RGN_FLAG_HIDDEN; - + if (do_fade && ar->overlap) { /* starts a timer, and in end calls the stuff below itself (region_sblend_invoke()) */ region_blend_start(C, sa, ar); @@ -1544,7 +1544,7 @@ void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade) else { if (ar->flag & RGN_FLAG_HIDDEN) WM_event_remove_handlers(C, &ar->handlers); - + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); ED_area_tag_redraw(sa); } @@ -1565,7 +1565,7 @@ void ED_area_data_copy(ScrArea *sa_dst, ScrArea *sa_src, const bool do_free) ARegion *ar; const char spacetype = sa_dst->spacetype; const short flag_copy = HEADER_NO_PULLDOWN; - + sa_dst->headertype = sa_src->headertype; sa_dst->spacetype = sa_src->spacetype; sa_dst->type = sa_src->type; @@ -1627,7 +1627,7 @@ void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(C); - + ED_area_tag_redraw(sa1); ED_area_tag_refresh(sa1); ED_area_tag_redraw(sa2); @@ -1665,12 +1665,12 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi sa->spacetype = type; sa->butspacetype = type; sa->type = st; - + /* check previously stored space */ for (sl = sa->spacedata.first; sl; sl = sl->next) if (sl->spacetype == type) break; - + /* old spacedata... happened during work on 2.50, remove */ if (sl && BLI_listbase_is_empty(&sl->regionbase)) { st->free(sl); @@ -1680,13 +1680,13 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi } sl = NULL; } - + if (sl) { /* swap regions */ slold->regionbase = sa->regionbase; sa->regionbase = sl->regionbase; BLI_listbase_clear(&sl->regionbase); - + /* put in front of list */ BLI_remlink(&sa->spacedata, sl); BLI_addhead(&sa->spacedata, sl); @@ -1696,7 +1696,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi if (st) { sl = st->new(C); BLI_addhead(&sa->spacedata, sl); - + /* swap regions */ if (slold) slold->regionbase = sa->regionbase; @@ -1704,18 +1704,18 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type, const bool skip_ar_exi BLI_listbase_clear(&sl->regionbase); } } - + ED_area_initialize(CTX_wm_manager(C), CTX_wm_window(C), sa); - + /* tell WM to refresh, cursor types etc */ WM_event_add_mousemove(C); - + /* send space change notifier */ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); - + ED_area_tag_refresh(sa); } - + /* also redraw when re-used */ ED_area_tag_redraw(sa); } @@ -1786,7 +1786,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c if (contextnr != -1) is_context_new = UI_view2d_tab_set(v2d, contextnr); - + /* before setting the view */ if (vertical) { /* only allow scrolling in vertical direction */ @@ -1850,7 +1850,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c /* the layout engine works with fixed width (from v2d->cur), which is being set at end of the loop */ /* in case scroller settings (hide flags) differ from previous, the whole loop gets done again */ for (redo = 2; redo > 0; redo--) { - + if (vertical) { w = BLI_rctf_size_x(&v2d->cur); em = (ar->type->prefsizex) ? 10 : 20; /* works out to 10*UI_UNIT_X or 20*UI_UNIT_X */ @@ -1861,7 +1861,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c } w -= margin_x; - + /* create panels */ UI_panels_begin(C, ar); @@ -1935,7 +1935,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c /* align panels and return size */ UI_panels_end(C, ar, &x, &y); - + /* before setting the view */ if (vertical) { /* we always keep the scroll offset - so the total view gets increased with the scrolled away part */ @@ -1964,10 +1964,10 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c y = -y; } - + /* this also changes the 'cur' */ UI_view2d_totRect_set(v2d, x, y); - + if (scroll != v2d->scroll) { /* Note: this code scales fine, but because of rounding differences, positions of elements * flip +1 or -1 pixel compared to redoing the entire layout again. @@ -1995,7 +1995,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK); glClear(GL_COLOR_BUFFER_BIT); } - + /* reset line width for drawing tabs */ glLineWidth(1.0f); @@ -2007,7 +2007,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, const char *context, int c /* restore view matrix */ UI_view2d_view_restore(C); - + if (use_category_tabs) { UI_panel_category_draw_all(ar, category); } @@ -2041,7 +2041,7 @@ void ED_region_header(const bContext *C, ARegion *ar) /* clear */ UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); - + /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(&ar->v2d); @@ -2057,7 +2057,7 @@ void ED_region_header(const bContext *C, ARegion *ar) header.type = ht; header.layout = layout; ht->draw(C, &header); - + /* for view2d */ xco = uiLayoutGetWidth(layout); if (xco > maxco) @@ -2065,11 +2065,11 @@ void ED_region_header(const bContext *C, ARegion *ar) } UI_block_layout_resolve(block, &xco, &yco); - + /* for view2d */ if (xco > maxco) maxco = xco; - + UI_block_end(C, block); UI_block_draw(C, block); } @@ -2236,7 +2236,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const if (metadata_is_valid(ibuf, temp_str, i, len)) { BLF_position(fontid, xmin + ofs_x, ymin, 0.0f); BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); - + ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X; } } @@ -2423,18 +2423,18 @@ void ED_region_grid_draw(ARegion *ar, float zoomx, float zoomy) void ED_region_visible_rect(ARegion *ar, rcti *rect) { ARegion *arn = ar; - + /* allow function to be called without area */ while (arn->prev) arn = arn->prev; - + *rect = ar->winrct; - + /* check if a region overlaps with the current one */ for (; arn; arn = arn->next) { if (ar != arn && arn->overlap) { if (BLI_rcti_isect(rect, &arn->winrct, NULL)) { - + /* overlap left, also check 1 pixel offset (2 regions on one side) */ if (ABS(rect->xmin - arn->winrct.xmin) < 2) rect->xmin = arn->winrct.xmax; diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index f20b2a61370..6e9a580e403 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -62,18 +62,18 @@ void fdrawbezier(float vec[4][3]) { float dist; float curve_res = 24, spline_step = 0.0f; - + dist = 0.5f * fabsf(vec[0][0] - vec[3][0]); - + /* check direction later, for top sockets */ vec[1][0] = vec[0][0] + dist; vec[1][1] = vec[0][1]; - + vec[2][0] = vec[3][0] - dist; vec[2][1] = vec[3][1]; /* we can reuse the dist variable here to increment the GL curve eval amount */ dist = 1.0f / curve_res; - + cpack(0x0); glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]); glBegin(GL_LINE_STRIP); @@ -100,12 +100,12 @@ void fdrawline(float x1, float y1, float x2, float y2) void fdrawbox(float x1, float y1, float x2, float y2) { glBegin(GL_LINE_LOOP); - + glVertex2f(x1, y1); glVertex2f(x1, y2); glVertex2f(x2, y2); glVertex2f(x2, y1); - + glEnd(); } @@ -166,12 +166,12 @@ void sdrawtrifill(int x1, int y1, int x2, int y2) void sdrawbox(int x1, int y1, int x2, int y2) { glBegin(GL_LINE_LOOP); - + glVertex2i(x1, y1); glVertex2i(x1, y2); glVertex2i(x2, y2); glVertex2i(x2, y1); - + glEnd(); } @@ -184,7 +184,7 @@ void setlinestyle(int nr) glDisable(GL_LINE_STIPPLE); } else { - + glEnable(GL_LINE_STIPPLE); if (U.pixelsize > 1.0f) glLineStipple(nr, 0xCCCC); @@ -194,10 +194,10 @@ void setlinestyle(int nr) } /* Invert line handling */ - + #define GL_TOGGLE(mode, onoff) (((onoff) ? glEnable : glDisable)(mode)) -void set_inverted_drawing(int enable) +void set_inverted_drawing(int enable) { glLogicOp(enable ? GL_INVERT : GL_COPY); GL_TOGGLE(GL_COLOR_LOGIC_OP, enable); @@ -211,12 +211,12 @@ void sdrawXORline(int x0, int y0, int x1, int y1) if (x0 == x1 && y0 == y1) return; set_inverted_drawing(1); - + glBegin(GL_LINES); glVertex2i(x0, y0); glVertex2i(x1, y1); glEnd(); - + set_inverted_drawing(0); } @@ -224,11 +224,11 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) { static int old[4][2][2]; static char flags[4] = {0, 0, 0, 0}; - + /* with builtin memory, max 4 lines */ set_inverted_drawing(1); - + glBegin(GL_LINES); if (nr == -1) { /* flush */ for (nr = 0; nr < 4; nr++) { @@ -250,15 +250,15 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) old[nr][0][1] = y0; old[nr][1][0] = x1; old[nr][1][1] = y1; - + flags[nr] = 1; } - + glVertex2i(x0, y0); glVertex2i(x1, y1); } glEnd(); - + set_inverted_drawing(0); } @@ -294,13 +294,13 @@ void fdrawXORcirc(float xofs, float yofs, float rad) void glutil_draw_filled_arc(float start, float angle, float radius, int nsegments) { int i; - + glBegin(GL_TRIANGLE_FAN); glVertex2f(0.0, 0.0); for (i = 0; i < nsegments; i++) { float t = (float) i / (nsegments - 1); float cur = start + t * angle; - + glVertex2f(cosf(cur) * radius, sinf(cur) * radius); } glEnd(); @@ -309,12 +309,12 @@ void glutil_draw_filled_arc(float start, float angle, float radius, int nsegment void glutil_draw_lined_arc(float start, float angle, float radius, int nsegments) { int i; - + glBegin(GL_LINE_STRIP); for (i = 0; i < nsegments; i++) { float t = (float) i / (nsegments - 1); float cur = start + t * angle; - + glVertex2f(cosf(cur) * radius, sinf(cur) * radius); } glEnd(); @@ -406,13 +406,13 @@ void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, /* workaround for os x 10.5/10.6 driver bug: http://lists.apple.com/archives/Mac-opengl/2008/Jul/msg00117.html */ glPixelZoom(1.0f, 1.0f); #endif - + /* setup seamless 2=on, 0=off */ seamless = ((tex_w < img_w || tex_h < img_h) && tex_w > 2 && tex_h > 2) ? 2 : 0; - + offset_x = tex_w - seamless; offset_y = tex_h - seamless; - + nsubparts_x = (img_w + (offset_x - 1)) / (offset_x); nsubparts_y = (img_h + (offset_y - 1)) / (offset_y); @@ -474,7 +474,7 @@ void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, if (type == GL_FLOAT) { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, format, GL_FLOAT, &f_rect[((size_t)subpart_y) * offset_y * img_w * components + subpart_x * offset_x * components]); - + /* add an extra border of pixels so linear looks ok at edges of full image */ if (subpart_w < tex_w) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, format, GL_FLOAT, &f_rect[((size_t)subpart_y) * offset_y * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]); @@ -485,7 +485,7 @@ void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, } else { glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, format, GL_UNSIGNED_BYTE, &uc_rect[((size_t)subpart_y) * offset_y * img_w * components + subpart_x * offset_x * components]); - + if (subpart_w < tex_w) glTexSubImage2D(GL_TEXTURE_2D, 0, subpart_w, 0, 1, subpart_h, format, GL_UNSIGNED_BYTE, &uc_rect[((size_t)subpart_y) * offset_y * img_w * components + (subpart_x * offset_x + subpart_w - 1) * components]); if (subpart_h < tex_h) @@ -514,7 +514,7 @@ void glaDrawPixelsTexScaled_clipping(float x, float y, int img_w, int img_h, glBindTexture(GL_TEXTURE_2D, 0); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - + #if defined(__APPLE__) && 0 /* workaround for os x 10.5/10.6 driver bug (above) */ glPixelZoom(xzoom, yzoom); @@ -553,7 +553,7 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo */ float ix = -x / xzoom; float iy = -y / yzoom; - + /* The maximum pixel amounts the image can be cropped * at the lower left without exceeding the origin. */ @@ -619,7 +619,7 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y * row_w + off_x) * 4); } } - + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); GPU_BASIC_SHADER_ENABLE_AND_RESTORE(bound_options); @@ -685,23 +685,23 @@ struct gla2DDrawInfo { float wo_to_sc[2]; }; -void gla2DGetMap(gla2DDrawInfo *di, rctf *rect) +void gla2DGetMap(gla2DDrawInfo *di, rctf *rect) { *rect = di->world_rect; } -void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) +void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) { int sc_w, sc_h; float wo_w, wo_h; di->world_rect = *rect; - + sc_w = BLI_rcti_size_x(&di->screen_rect); sc_h = BLI_rcti_size_y(&di->screen_rect); wo_w = BLI_rcti_size_x(&di->world_rect); wo_h = BLI_rcti_size_y(&di->world_rect); - + di->wo_to_sc[0] = sc_w / wo_w; di->wo_to_sc[1] = sc_h / wo_h; } @@ -718,7 +718,7 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) * by \a screen_rect is supposed to represent. If NULL it is assumed the * world has a 1 to 1 mapping to the screen. */ -gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) +gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) { gla2DDrawInfo *di = MEM_mallocN(sizeof(*di), "gla2DDrawInfo"); int sc_w, sc_h; @@ -796,7 +796,7 @@ void bgl_get_mats(bglMats *mats) glGetDoublev(GL_MODELVIEW_MATRIX, mats->modelview); glGetDoublev(GL_PROJECTION_MATRIX, mats->projection); glGetIntegerv(GL_VIEWPORT, (GLint *)mats->viewport); - + /* Very strange code here - it seems that certain bad values in the * modelview matrix can cause gluUnProject to give bad results. */ if (mats->modelview[0] < badvalue && @@ -809,7 +809,7 @@ void bgl_get_mats(bglMats *mats) { mats->modelview[5] = 0; } - + /* Set up viewport so that gluUnProject will give correct values */ mats->viewport[0] = 0; mats->viewport[1] = 0; @@ -823,19 +823,19 @@ void bgl_get_mats(bglMats *mats) void bglPolygonOffset(float viewdist, float dist) { static float winmat[16], offset = 0.0f; - + if (dist != 0.0f) { float offs; - + // glEnable(GL_POLYGON_OFFSET_FILL); // glPolygonOffset(-1.0, -1.0); /* hack below is to mimic polygon offset */ glMatrixMode(GL_PROJECTION); glGetFloatv(GL_PROJECTION_MATRIX, (float *)winmat); - + /* dist is from camera to center point */ - + if (winmat[15] > 0.5f) { #if 1 offs = 0.00001f * dist * viewdist; // ortho tweaking @@ -860,10 +860,10 @@ void bglPolygonOffset(float viewdist, float dist) */ offs = winmat[14] * -0.0025f * dist; } - + winmat[14] -= offs; offset += offs; - + glLoadMatrixf(winmat); glMatrixMode(GL_MODELVIEW); } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index fed8449d9a2..b90430f27e2 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -86,7 +86,7 @@ const char *screen_context_dir[] = { "sequences", "selected_sequences", "selected_editable_sequences", /* sequencer */ "gpencil_data", "gpencil_data_owner", /* grease pencil data */ "visible_gpencil_layers", "editable_gpencil_layers", "editable_gpencil_strokes", - "active_gpencil_layer", "active_gpencil_frame", "active_gpencil_palette", + "active_gpencil_layer", "active_gpencil_frame", "active_gpencil_palette", "active_gpencil_palettecolor", "active_gpencil_brush", "active_operator", "selected_editable_fcurves", NULL}; @@ -185,7 +185,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "editable_objects") || CTX_data_equals(member, "editable_bases")) { const unsigned int lay = context_layers(sc, scene, sa); const bool editable_objects = CTX_data_equals(member, "editable_objects"); - + /* Visible + Editable, but not necessarily selected */ for (base = scene->base.first; base; base = base->next) { if (((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && (base->lay & lay)) { @@ -204,7 +204,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; EditBone *ebone, *flipbone = NULL; const bool editable_bones = CTX_data_equals(member, "editable_bones"); - + if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { @@ -212,19 +212,19 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult if (EBONE_VISIBLE(arm, ebone)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled * so that most users of this data don't need to explicitly check for it themselves. - * + * * We need to make sure that these mirrored copies are not selected, otherwise some * bones will be operated on twice. */ if (arm->flag & ARM_MIRROR_EDIT) flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); - + /* if we're filtering for editable too, use the check for that instead, as it has selection check too */ if (editable_bones) { /* only selected + editable */ if (EBONE_EDITABLE(ebone)) { CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); - + if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } @@ -232,7 +232,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else { /* only include bones if visible */ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); - + if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } @@ -246,7 +246,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; EditBone *ebone, *flipbone = NULL; const bool selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); - + if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { @@ -254,19 +254,19 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled * so that most users of this data don't need to explicitly check for it themselves. - * + * * We need to make sure that these mirrored copies are not selected, otherwise some * bones will be operated on twice. */ if (arm->flag & ARM_MIRROR_EDIT) flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); - + /* if we're filtering for editable too, use the check for that instead, as it has selection check too */ if (selected_editable_bones) { /* only selected + editable */ if (EBONE_EDITABLE(ebone)) { CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); - + if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } @@ -274,7 +274,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else { /* only include bones if selected */ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); - + if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } @@ -288,7 +288,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult Object *obpose = BKE_object_pose_armature_get(obact); bArmature *arm = (obpose) ? obpose->data : NULL; bPoseChannel *pchan; - + if (obpose && obpose->pose && arm) { for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ @@ -304,7 +304,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult Object *obpose = BKE_object_pose_armature_get(obact); bArmature *arm = (obpose) ? obpose->data : NULL; bPoseChannel *pchan; - + if (obpose && obpose->pose && arm) { for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ @@ -337,7 +337,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "active_pose_bone")) { bPoseChannel *pchan; Object *obpose = BKE_object_pose_armature_get(obact); - + pchan = BKE_pose_channel_active(obpose); if (pchan) { CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan); @@ -366,7 +366,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult /* convenience for now, 1 object per scene in editmode */ if (obedit) CTX_data_id_pointer_set(result, &obedit->id); - + return 1; } else if (CTX_data_equals(member, "sculpt_object")) { @@ -438,11 +438,11 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "gpencil_data")) { /* FIXME: for some reason, CTX_data_active_object(C) returns NULL when called from these situations - * (as outlined above - see Campbell's #ifdefs). That causes the get_active function to fail when + * (as outlined above - see Campbell's #ifdefs). That causes the get_active function to fail when * called from context. For that reason, we end up using an alternative where we pass everything in! */ bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact); - + if (gpd) { CTX_data_id_pointer_set(result, &gpd->id); return 1; @@ -450,14 +450,14 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "gpencil_data_owner")) { /* pointer to which data/datablock owns the reference to the Grease Pencil data being used (as gpencil_data) - * XXX: see comment for gpencil_data case... + * XXX: see comment for gpencil_data case... */ bGPdata **gpd_ptr = NULL; PointerRNA ptr; - + /* get pointer to Grease Pencil Data */ gpd_ptr = ED_gpencil_data_get_pointers_direct((ID *)sc, scene, sa, obact, &ptr); - + if (gpd_ptr) { CTX_data_pointer_set(result, ptr.id.data, ptr.type, ptr.data); return 1; @@ -466,10 +466,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "active_gpencil_layer")) { /* XXX: see comment for gpencil_data case... */ bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact); - + if (gpd) { bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); - + if (gpl) { CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl); return 1; @@ -517,10 +517,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "active_gpencil_frame")) { /* XXX: see comment for gpencil_data case... */ bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact); - + if (gpd) { bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd); - + if (gpl) { CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl->actframe); return 1; @@ -530,10 +530,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "visible_gpencil_layers")) { /* XXX: see comment for gpencil_data case... */ bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact); - + if (gpd) { bGPDlayer *gpl; - + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { if ((gpl->flag & GP_LAYER_HIDE) == 0) { CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl); @@ -546,10 +546,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "editable_gpencil_layers")) { /* XXX: see comment for gpencil_data case... */ bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact); - + if (gpd) { bGPDlayer *gpl; - + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { if (gpencil_layer_is_editable(gpl)) { CTX_data_list_add(result, &gpd->id, &RNA_GPencilLayer, gpl); @@ -562,15 +562,15 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult else if (CTX_data_equals(member, "editable_gpencil_strokes")) { /* XXX: see comment for gpencil_data case... */ bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, scene, sa, obact); - + if (gpd) { bGPDlayer *gpl; - + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { if (gpencil_layer_is_editable(gpl) && (gpl->actframe)) { bGPDframe *gpf = gpl->actframe; bGPDstroke *gps; - + for (gps = gpf->strokes.first; gps; gps = gps->next) { if (ED_gpencil_stroke_can_use_direct(sa, gps)) { /* check if the color is editable */ diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index e67ae4e321c..12f45faee94 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -144,7 +144,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) points[6].x = sa->v4->vec.x; points[6].y = sa->v4->vec.y + h; - + points[7].x = sa->v3->vec.x; points[7].y = sa->v3->vec.y; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 6e875f53c26..ec1c5511ae8 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -79,7 +79,7 @@ static ScrVert *screen_addvert(bScreen *sc, short x, short y) ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert"); sv->vec.x = x; sv->vec.y = y; - + BLI_addtail(&sc->vertbase, sv); return sv; } @@ -87,7 +87,7 @@ static ScrVert *screen_addvert(bScreen *sc, short x, short y) static void sortscrvert(ScrVert **v1, ScrVert **v2) { ScrVert *tmp; - + if (*v1 > *v2) { tmp = *v1; *v1 = *v2; @@ -98,11 +98,11 @@ static void sortscrvert(ScrVert **v1, ScrVert **v2) static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2) { ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge"); - + sortscrvert(&v1, &v2); se->v1 = v1; se->v2 = v2; - + BLI_addtail(&sc->edgebase, se); return se; } @@ -111,12 +111,12 @@ static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2) ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2) { ScrEdge *se; - + sortscrvert(&v1, &v2); for (se = sc->edgebase.first; se; se = se->next) if (se->v1 == v1 && se->v2 == v2) return se; - + return NULL; } @@ -125,7 +125,7 @@ void removedouble_scrverts(bScreen *sc) ScrVert *v1, *verg; ScrEdge *se; ScrArea *sa; - + verg = sc->vertbase.first; while (verg) { if (verg->newv == NULL) { /* !!! */ @@ -178,16 +178,16 @@ void removenotused_scrverts(bScreen *sc) { ScrVert *sv, *svn; ScrEdge *se; - + /* we assume edges are ok */ - + se = sc->edgebase.first; while (se) { se->v1->flag = 1; se->v2->flag = 1; se = se->next; } - + sv = sc->vertbase.first; while (sv) { svn = sv->next; @@ -205,7 +205,7 @@ void removenotused_scrverts(bScreen *sc) void removedouble_scredges(bScreen *sc) { ScrEdge *verg, *se, *sn; - + /* compare */ verg = sc->edgebase.first; while (verg) { @@ -227,7 +227,7 @@ void removenotused_scredges(bScreen *sc) ScrEdge *se, *sen; ScrArea *sa; int a = 0; - + /* sets flags when edge is used in area */ sa = sc->areabase.first; while (sa) { @@ -272,16 +272,16 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, { ScrEdge *se; int safety = U.widget_unit / 10; - + if (safety < 2) safety = 2; - + for (se = sc->edgebase.first; se; se = se->next) { if (scredge_is_horizontal(se)) { if (se->v1->vec.y > 0 && se->v1->vec.y < winsize_y - 1) { short min, max; min = MIN2(se->v1->vec.x, se->v2->vec.x); max = MAX2(se->v1->vec.x, se->v2->vec.x); - + if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max) return se; } @@ -291,13 +291,13 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, short min, max; min = MIN2(se->v1->vec.y, se->v2->vec.y); max = MAX2(se->v1->vec.y, se->v2->vec.y); - + if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max) return se; } } } - + return NULL; } @@ -313,19 +313,19 @@ static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v sa->v4 = v4; sa->headertype = headertype; sa->spacetype = sa->butspacetype = spacetype; - + BLI_addtail(&sc->areabase, sa); - + return sa; } static void screen_delarea(bContext *C, bScreen *sc, ScrArea *sa) { - + ED_area_exit(C, sa); - + BKE_screen_area_free(sa); - + BLI_remlink(&sc->areabase, sa); MEM_freeN(sa); } @@ -337,34 +337,34 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) short x, y; const short area_min_x = AREAMINX; const short area_min_y = ED_area_headersize(); - + // area big enough? if (dir == 'v' && (sa->v4->vec.x - sa->v1->vec.x <= 2 * area_min_x)) return 0; if (dir == 'h' && (sa->v2->vec.y - sa->v1->vec.y <= 2 * area_min_y)) return 0; - + // to be sure CLAMP(fac, 0.0f, 1.0f); - + if (dir == 'h') { y = sa->v1->vec.y + fac * (sa->v2->vec.y - sa->v1->vec.y); - + if (y - sa->v1->vec.y < area_min_y) y = sa->v1->vec.y + area_min_y; else if (sa->v2->vec.y - y < area_min_y) y = sa->v2->vec.y - area_min_y; else y -= (y % AREAGRID); - + return y; } else { x = sa->v1->vec.x + fac * (sa->v4->vec.x - sa->v1->vec.x); - + if (x - sa->v1->vec.x < area_min_x) x = sa->v1->vec.x + area_min_x; else if (sa->v4->vec.x - x < area_min_x) x = sa->v4->vec.x - area_min_x; else x -= (x % AREAGRID); - + return x; } } @@ -374,12 +374,12 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) ScrArea *newa = NULL; ScrVert *sv1, *sv2; short split; - + if (sa == NULL) return NULL; - + split = testsplitpoint(sa, dir, fac); if (split == 0) return NULL; - + /* note regarding (fac > 0.5f) checks below. * normally it shouldn't matter which is used since the copy should match the original * however with viewport rendering and python console this isn't the case. - campbell */ @@ -388,14 +388,14 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) /* new vertices */ sv1 = screen_addvert(sc, sa->v1->vec.x, split); sv2 = screen_addvert(sc, sa->v4->vec.x, split); - + /* new edges */ screen_addedge(sc, sa->v1, sv1); screen_addedge(sc, sv1, sa->v2); screen_addedge(sc, sa->v3, sv2); screen_addedge(sc, sv2, sa->v4); screen_addedge(sc, sv1, sv2); - + if (fac > 0.5f) { /* new areas: top */ newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype); @@ -414,20 +414,20 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) } ED_area_data_copy(newa, sa, true); - + } else { /* new vertices */ sv1 = screen_addvert(sc, split, sa->v1->vec.y); sv2 = screen_addvert(sc, split, sa->v2->vec.y); - + /* new edges */ screen_addedge(sc, sa->v1, sv1); screen_addedge(sc, sv1, sa->v4); screen_addedge(sc, sa->v2, sv2); screen_addedge(sc, sv2, sa->v3); screen_addedge(sc, sv1, sv2); - + if (fac > 0.5f) { /* new areas: right */ newa = screen_addarea(sc, sv1, sv2, sa->v3, sa->v4, sa->headertype, sa->spacetype); @@ -447,13 +447,13 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) ED_area_data_copy(newa, sa, true); } - + /* remove double vertices en edges */ if (merge) removedouble_scrverts(sc); removedouble_scredges(sc); removenotused_scredges(sc); - + return newa; } @@ -466,7 +466,7 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name) bScreen *sc; ScrVert *sv1, *sv2, *sv3, *sv4; - + sc = BKE_libblock_alloc(G.main, ID_SCR, name, 0); sc->scene = scene; sc->do_refresh = true; @@ -477,15 +477,15 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name) sv2 = screen_addvert(sc, 0, winsize_y - 1); sv3 = screen_addvert(sc, winsize_x - 1, winsize_y - 1); sv4 = screen_addvert(sc, winsize_x - 1, 0); - + screen_addedge(sc, sv1, sv2); screen_addedge(sc, sv2, sv3); screen_addedge(sc, sv3, sv4); screen_addedge(sc, sv4, sv1); - + /* dummy type, no spacedata */ screen_addarea(sc, sv1, sv2, sv3, sv4, HEADERDOWN, SPACE_EMPTY); - + return sc; } @@ -494,26 +494,26 @@ static void screen_copy(bScreen *to, bScreen *from) ScrVert *s1, *s2; ScrEdge *se; ScrArea *sa, *saf; - + /* free contents of 'to', is from blenkernel screen.c */ BKE_screen_free(to); - + BLI_duplicatelist(&to->vertbase, &from->vertbase); BLI_duplicatelist(&to->edgebase, &from->edgebase); BLI_duplicatelist(&to->areabase, &from->areabase); BLI_listbase_clear(&to->regionbase); - + s2 = to->vertbase.first; for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) { s1->newv = s2; } - + for (se = to->edgebase.first; se; se = se->next) { se->v1 = se->v1->newv; se->v2 = se->v2->newv; sortscrvert(&(se->v1), &(se->v2)); } - + saf = from->areabase.first; for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) { sa->v1 = sa->v1->newv; @@ -525,10 +525,10 @@ static void screen_copy(bScreen *to, bScreen *from) BLI_listbase_clear(&sa->regionbase); BLI_listbase_clear(&sa->actionzones); BLI_listbase_clear(&sa->handlers); - + ED_area_data_copy(sa, saf, true); } - + /* put at zero (needed?) */ for (s1 = from->vertbase.first; s1; s1 = s1->next) s1->newv = NULL; @@ -554,7 +554,7 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) sbv2 = sb->v2; sbv3 = sb->v3; sbv4 = sb->v4; - + if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ return 0; } @@ -567,7 +567,7 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ return 3; } - + return -1; } @@ -577,14 +577,14 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) { int dir; - + dir = area_getorientation(sa1, sa2); /*printf("dir is : %i\n", dir);*/ - + if (dir == -1) { return 0; } - + if (dir == 0) { sa1->v1 = sa2->v1; sa1->v2 = sa2->v2; @@ -609,7 +609,7 @@ int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) screen_addedge(scr, sa1->v1, sa1->v2); screen_addedge(scr, sa1->v3, sa1->v4); } - + screen_delarea(C, scr, sa2); removedouble_scrverts(scr); @@ -622,22 +622,22 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) ScrVert *sv; int oneselected; char dir; - + /* select connected, only in the right direction */ /* 'dir' is the direction of EDGE */ - + if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v'; else dir = 'h'; - + sv = sc->vertbase.first; while (sv) { sv->flag = 0; sv = sv->next; } - + edge->v1->flag = 1; edge->v2->flag = 1; - + oneselected = 1; while (oneselected) { se = sc->edgebase.first; @@ -674,22 +674,22 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y) ScrArea *sa; int winsize_x_prev, winsize_y_prev; float facx, facy, tempf, min[2], max[2]; - + /* calculate size */ min[0] = min[1] = 20000.0f; max[0] = max[1] = 0.0f; - + for (sv = sc->vertbase.first; sv; sv = sv->next) { const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; minmax_v2v2_v2(min, max, fv); } - + /* always make 0.0 left under */ for (sv = sc->vertbase.first; sv; sv = sv->next) { sv->vec.x -= min[0]; sv->vec.y -= min[1]; } - + winsize_x_prev = (max[0] - min[0]) + 1; winsize_y_prev = (max[1] - min[1]) + 1; @@ -725,7 +725,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y) if (winsize_x_prev != winsize_x || winsize_y_prev != winsize_y) { facx = ((float)winsize_x - 1) / ((float)winsize_x_prev - 1); facy = ((float)winsize_y - 1) / ((float)winsize_y_prev - 1); - + /* make sure it fits! */ for (sv = sc->vertbase.first; sv; sv = sv->next) { /* FIXME, this re-sizing logic is no good when re-sizing the window + redrawing [#24428] @@ -736,7 +736,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y) //sv->vec.x -= (sv->vec.x % AREAGRID); CLAMP(sv->vec.x, 0, winsize_x - 1); - + tempf = ((float)sv->vec.y) * facy; sv->vec.y = (short)(tempf + 0.5f); //sv->vec.y += AREAGRID - 1; @@ -800,25 +800,25 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y) /* test for collapsed areas. This could happen in some blender version... */ /* ton: removed option now, it needs Context... */ - + /* make each window at least ED_area_headersize() high */ for (sa = sc->areabase.first; sa; sa = sa->next) { int headery = headery_init; - + /* adjust headery if verts are along the edge of window */ if (sa->v1->vec.y > 0) headery += U.pixelsize; if (sa->v2->vec.y < winsize_y - 1) headery += U.pixelsize; - + if (sa->v2->vec.y - sa->v1->vec.y + 1 < headery) { /* lower edge */ ScrEdge *se = screen_findedge(sc, sa->v4, sa->v1); if (se && sa->v1 != sa->v2) { int yval; - + select_connected_scredge(sc, se); - + /* all selected vertices get the right offset */ yval = sa->v2->vec.y - headery + 1; for (sv = sc->vertbase.first; sv; sv = sv->next) { @@ -832,7 +832,7 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y) } } } - + } /* ****************** EXPORTED API TO OTHER MODULES *************************** */ @@ -840,9 +840,9 @@ static void screen_test_scale(bScreen *sc, int winsize_x, int winsize_y) bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) { bScreen *newsc; - + if (sc->state != SCREENNORMAL) return NULL; /* XXX handle this case! */ - + /* make new empty screen: */ newsc = ED_screen_add(win, sc->scene, sc->id.name + 2); /* copy all data */ @@ -869,7 +869,7 @@ static void region_cursor_set(wmWindow *win, int swinid, int swin_changed) void ED_screen_do_listen(bContext *C, wmNotifier *note) { wmWindow *win = CTX_wm_window(C); - + /* generic notes */ switch (note->category) { case NC_WM: @@ -895,7 +895,7 @@ static void screen_refresh_headersizes(void) { const ListBase *lb = BKE_spacetypes_list(); SpaceType *st; - + for (st = lb->first; st; st = st->next) { ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); if (art) art->prefsizey = ED_area_headersize(); @@ -905,38 +905,38 @@ static void screen_refresh_headersizes(void) /* make this screen usable */ /* for file read and first use, for scaling window, area moves */ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) -{ +{ /* exception for bg mode, we only need the screen context */ if (!G.background) { const int winsize_x = WM_window_pixels_x(win); const int winsize_y = WM_window_pixels_y(win); ScrArea *sa; rcti winrct; - + winrct.xmin = 0; winrct.xmax = winsize_x - 1; winrct.ymin = 0; winrct.ymax = winsize_y - 1; - + /* header size depends on DPI, let's verify */ WM_window_set_dpi(win); screen_refresh_headersizes(); - + screen_test_scale(win->screen, winsize_x, winsize_y); - + if (win->screen->mainwin == 0) { win->screen->mainwin = wm_subwindow_open(win, &winrct, false); } else { wm_subwindow_position(win, win->screen->mainwin, &winrct, false); } - + for (sa = win->screen->areabase.first; sa; sa = sa->next) { /* set spacetype and region callbacks, calls init() */ /* sets subwindows for regions, adds handlers */ ED_area_initialize(wm, win, sa); } - + /* wake up animtimer */ if (win->screen->animtimer) WM_event_timer_sleep(wm, win, win->screen->animtimer, false); @@ -954,12 +954,12 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) void ED_screens_initialize(wmWindowManager *wm) { wmWindow *win; - + for (win = wm->windows.first; win; win = win->next) { - + if (win->screen == NULL) win->screen = G.main->screen.first; - + ED_screen_refresh(wm, win); } } @@ -981,12 +981,12 @@ void ED_region_exit(bContext *C, ARegion *ar) wm_subwindow_close(CTX_wm_window(C), ar->swinid); ar->swinid = 0; } - + if (ar->headerstr) { MEM_freeN(ar->headerstr); ar->headerstr = NULL; } - + if (ar->regiontimer) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), ar->regiontimer); ar->regiontimer = NULL; @@ -1020,7 +1020,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) ARegion *ar; CTX_wm_window_set(C, window); - + if (screen->animtimer) WM_event_remove_timer(wm, window, screen->animtimer); screen->animtimer = NULL; @@ -1030,7 +1030,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) wm_subwindow_close(window, screen->mainwin); screen->mainwin = 0; screen->subwinactive = 0; - + for (ar = screen->regionbase.first; ar; ar = ar->next) ED_region_exit(C, ar); @@ -1039,7 +1039,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) /* mark it available for use for other windows */ screen->winid = 0; - + if (prevwin->screen->temp == 0) { /* use previous window if possible */ CTX_wm_window_set(C, prevwin); @@ -1048,7 +1048,7 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) /* none otherwise */ CTX_wm_window_set(C, NULL); } - + } /* *********************************** */ @@ -1061,11 +1061,11 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event) AZone *az = NULL; ScrArea *sa; - + for (sa = win->screen->areabase.first; sa; sa = sa->next) if ((az = is_in_area_actionzone(sa, &event->x))) break; - + if (sa) { if (az->type == AZONE_AREA) WM_cursor_set(win, CURSOR_EDIT); @@ -1078,7 +1078,7 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event) } else { ScrEdge *actedge = screen_find_active_scredge(win->screen, winsize_x, winsize_y, event->x, event->y); - + if (actedge) { if (scredge_is_horizontal(actedge)) WM_cursor_set(win, CURSOR_Y_MOVE); @@ -1096,7 +1096,7 @@ static void screen_cursor_set(wmWindow *win, const wmEvent *event) void ED_screen_set_subwinactive(bContext *C, const wmEvent *event) { wmWindow *win = CTX_wm_window(C); - + if (win->screen) { bScreen *scr = win->screen; ScrArea *sa; @@ -1120,17 +1120,17 @@ void ED_screen_set_subwinactive(bContext *C, const wmEvent *event) } else scr->subwinactive = scr->mainwin; - + /* check for redraw headers */ if (oldswin != scr->subwinactive) { for (sa = scr->areabase.first; sa; sa = sa->next) { bool do_draw = false; - + for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid == oldswin || ar->swinid == scr->subwinactive) do_draw = true; - + if (do_draw) { for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->regiontype == RGN_TYPE_HEADER) @@ -1138,7 +1138,7 @@ void ED_screen_set_subwinactive(bContext *C, const wmEvent *event) } } } - + /* cursors, for time being set always on edges, otherwise aregion doesnt switch */ if (scr->subwinactive == scr->mainwin) { screen_cursor_set(win, event); @@ -1168,10 +1168,10 @@ int ED_screen_area_active(const bContext *C) if (win && sc && sa) { AZone *az = is_in_area_actionzone(sa, &win->eventstate->x); ARegion *ar; - + if (az && az->type == AZONE_REGION) return 1; - + for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid == sc->subwinactive) return 1; @@ -1191,7 +1191,7 @@ bool ED_screen_set(bContext *C, bScreen *sc) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); bScreen *oldscreen = CTX_wm_screen(C); - + /* validate screen, it's called with notifier reference */ if (BLI_findindex(&bmain->screen, sc) == -1) { return true; @@ -1213,7 +1213,7 @@ bool ED_screen_set(bContext *C, bScreen *sc) if (sc->winid != 0 && sc->winid != win->winid) { return false; } - + if (oldscreen != sc) { wmTimer *wt = oldscreen->animtimer; ScrArea *sa; @@ -1246,14 +1246,14 @@ bool ED_screen_set(bContext *C, bScreen *sc) win->screen = sc; CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf - + /* prevent multiwin errors */ sc->winid = win->winid; - + ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_SCREEN | ND_SCREENSET, sc); - + /* makes button hilites work */ WM_event_add_mousemove(C); @@ -1308,7 +1308,7 @@ bool ED_screen_delete(bContext *C, bScreen *sc) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); bScreen *newsc; - + /* don't allow deleting temp fullscreens for now */ if (ELEM(sc->state, SCREENMAXIMIZED, SCREENFULL)) { return false; @@ -1321,7 +1321,7 @@ bool ED_screen_delete(bContext *C, bScreen *sc) for (newsc = sc->id.prev; newsc; newsc = newsc->id.prev) if (!ed_screen_used(wm, newsc) && !newsc->temp) break; - + if (!newsc) { for (newsc = sc->id.next; newsc; newsc = newsc->id.next) if (!ed_screen_used(wm, newsc) && !newsc->temp) @@ -1354,13 +1354,13 @@ static void ed_screen_set_3dview_camera(Scene *scene, bScreen *sc, ScrArea *sa, if (!v3d->camera) { ARegion *ar; ListBase *regionbase; - + /* regionbase is in different place depending if space is active */ if (v3d == sa->spacedata.first) regionbase = &sa->regionbase; else regionbase = &v3d->regionbase; - + for (ar = regionbase->first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = ar->regiondata; @@ -1388,7 +1388,7 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) for (sc = bmain->screen.first; sc; sc = sc->id.next) { if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { - + if (scene != sc->scene) { /* all areas endlocalview */ // XXX ScrArea *sa = sc->areabase.first; @@ -1398,12 +1398,12 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) // } sc->scene = scene; } - + } } - + // copy_view3d_lock(0); /* space.c */ - + /* are there cameras in the views that are not in the scene? */ for (sc = bmain->screen.first; sc; sc = sc->id.next) { if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { @@ -1422,17 +1422,17 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) } } } - + CTX_data_scene_set(C, scene); BKE_scene_set_background(bmain, scene); DAG_on_visible_update(bmain, false); - + ED_render_engine_changed(bmain); ED_update_for_newframe(bmain, scene, 1); - + /* complete redraw */ WM_event_add_notifier(C, NC_WINDOW, NULL); - + } /** @@ -1472,7 +1472,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) if (!sa || sa->full == NULL) { newsa = ED_screen_state_toggle(C, win, sa, SCREENMAXIMIZED); } - + if (!newsa) { if (sa->full && (screen->state == SCREENMAXIMIZED)) { /* if this has been called from the temporary info header generated in @@ -1540,10 +1540,10 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa) SpaceLink *sl = sa->spacedata.first; bScreen *screen = CTX_wm_screen(C); short state = (screen ? screen->state : SCREENMAXIMIZED); - + /* if fullscreen area has a temporary space (such as a file browser or fullscreen render * overlaid on top of an existing setup) then return to the previous space */ - + if (sl->next) { if (sa->flag & AREA_FLAG_TEMP_TYPE) { ED_screen_full_prevspace(C, sa); @@ -1717,15 +1717,15 @@ void ED_refresh_viewport_fps(bContext *C) { wmTimer *animtimer = CTX_wm_screen(C)->animtimer; Scene *scene = CTX_data_scene(C); - + /* is anim playback running? */ if (animtimer && (U.uiflag & USER_SHOW_FPS)) { ScreenFrameRateInfo *fpsi = scene->fps_info; - + /* if there isn't any info, init it first */ if (fpsi == NULL) fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo), "refresh_viewport_fps fps_info"); - + /* update the values */ fpsi->redrawtime = fpsi->lredrawtime; fpsi->lredrawtime = animtimer->ltime; @@ -1738,7 +1738,7 @@ void ED_refresh_viewport_fps(bContext *C) } } -/* redraws: uses defines from stime->redraws +/* redraws: uses defines from stime->redraws * enable: 1 - forward on, -1 - backwards on, 0 - off */ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, int enable) @@ -1748,17 +1748,17 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); bScreen *stopscreen = ED_screen_animation_playing(wm); - + if (stopscreen) { WM_event_remove_timer(wm, win, stopscreen->animtimer); stopscreen->animtimer = NULL; } - + if (enable) { ScreenAnimData *sad = MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); - + screen->animtimer = WM_event_add_timer(wm, win, TIMER0, (1.0 / FPS)); - + sad->ar = CTX_wm_region(C); /* if startframe is larger than current frame, we put currentframe on startframe. * note: first frame then is not drawn! (ton) */ @@ -1793,7 +1793,7 @@ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, sad->from_anim_edit = (ELEM(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_TIME)); screen->animtimer->customdata = sad; - + } /* notifier catched by top header, for button */ @@ -1806,7 +1806,7 @@ static ARegion *time_top_left_3dwindow(bScreen *screen) ARegion *aret = NULL; ScrArea *sa; int min = 10000; - + for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->spacetype == SPACE_VIEW3D) { ARegion *ar; @@ -1829,7 +1829,7 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) if (screen && screen->animtimer) { wmTimer *wt = screen->animtimer; ScreenAnimData *sad = wt->customdata; - + sad->redraws = redraws; sad->refresh = refresh; sad->ar = NULL; @@ -1857,7 +1857,7 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, int UNUSED(mute)) } } #endif - + ED_clip_update_frame(bmain, scene->r.cfra); /* get layers from all windows */ @@ -1870,7 +1870,7 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, int UNUSED(mute)) /* composite */ if (scene->use_nodes && scene->nodetree) ntreeCompositTagAnimated(scene->nodetree); - + /* update animated texture nodes */ { Tex *tex; @@ -1880,7 +1880,7 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, int UNUSED(mute)) } } } - + } /* diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4639a346243..b3e788a9a13 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -163,11 +163,11 @@ int ED_operator_objectmode(bContext *C) return 0; if (CTX_data_edit_object(C)) return 0; - + /* add a check for ob->mode too? */ if (obact && (obact->mode != OB_MODE_OBJECT)) return 0; - + return 1; } @@ -249,20 +249,20 @@ int ED_operator_buttons_active(bContext *C) int ED_operator_node_active(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - + if (snode && snode->edittree) return 1; - + return 0; } int ED_operator_node_editable(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - + if (snode && snode->edittree && !ID_IS_LINKED(snode->edittree)) return 1; - + return 0; } @@ -453,15 +453,15 @@ int ED_operator_uvmap(bContext *C) { Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = NULL; - + if (obedit && obedit->type == OB_MESH) { em = BKE_editmesh_from_object(obedit); } - + if (em && (em->bm->totface)) { return true; } - + return false; } @@ -602,7 +602,7 @@ static ARegion *screen_find_region_type(bContext *C, int type) /** \name Action Zone Operator * \{ */ -/* operator state vars used: +/* operator state vars used: * none * * functions: @@ -635,11 +635,11 @@ static int actionzone_area_poll(bContext *C) { wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); - + if (sa && win && win->eventstate) { const int *xy = &win->eventstate->x; AZone *az; - + for (az = sa->actionzones.first; az; az = az->next) if (BLI_rcti_isect_pt_v(&az->rect, xy)) return 1; @@ -668,13 +668,13 @@ static void fullscreen_click_rcti_init(rcti *rect, const short x1, const short y AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) { AZone *az = NULL; - + for (az = sa->actionzones.first; az; az = az->next) { if (BLI_rcti_isect_pt_v(&az->rect, xy)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ int radius = (xy[0] - az->x1) * (xy[0] - az->x1) + (xy[1] - az->y1) * (xy[1] - az->y1); - + if (radius <= AZONESPOT * AZONESPOT) break; } @@ -719,7 +719,7 @@ AZone *is_in_area_actionzone(ScrArea *sa, const int xy[2]) } } } - + return az; } @@ -737,9 +737,9 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) wmEvent event; wmWindow *win = CTX_wm_window(C); sActionzoneData *sad = op->customdata; - + sad->modifier = RNA_int_get(op->ptr, "modifier"); - + wm_event_init_from_window(win, &event); if (type == AZONE_AREA) @@ -753,7 +753,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) event.customdata = op->customdata; event.customdatafree = true; op->customdata = NULL; - + wm_event_add(win, &event); } @@ -762,17 +762,17 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) ScrArea *sa = CTX_wm_area(C); AZone *az = is_in_area_actionzone(sa, &event->x); sActionzoneData *sad; - + /* quick escape */ if (az == NULL) return OPERATOR_PASS_THROUGH; - + /* ok we do the actionzone */ sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); sad->sa1 = sa; sad->az = az; sad->x = event->x; sad->y = event->y; - + /* region azone directly reacts on mouse clicks */ if (ELEM(sad->az->type, AZONE_REGION, AZONE_FULLSCREEN)) { actionzone_apply(C, op, sad->az->type); @@ -782,7 +782,7 @@ static int actionzone_invoke(bContext *C, wmOperator *op, const wmEvent *event) else { /* add modal handler */ WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; } } @@ -813,7 +813,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) sad->gesture_dir = 's'; else sad->gesture_dir = 'w'; - + if (sad->az->type == AZONE_AREA) { /* once we drag outside the actionzone, register a gesture * check we're not on an edge so join finds the other area */ @@ -832,7 +832,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) /* apply sends event */ actionzone_apply(C, op, sad->az->type); actionzone_exit(op); - + return OPERATOR_FINISHED; } break; @@ -843,9 +843,9 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) case LEFTMOUSE: actionzone_exit(op); return OPERATOR_CANCELLED; - + } - + return OPERATOR_RUNNING_MODAL; } @@ -860,15 +860,15 @@ static void SCREEN_OT_actionzone(wmOperatorType *ot) ot->name = "Handle Area Action Zones"; ot->description = "Handle area action zones for mouse actions/gestures"; ot->idname = "SCREEN_OT_actionzone"; - + ot->invoke = actionzone_invoke; ot->modal = actionzone_modal; ot->poll = actionzone_area_poll; ot->cancel = actionzone_cancel; - + /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; - + RNA_def_int(ot->srna, "modifier", 0, 0, 2, "Modifier", "Modifier state", 0, 2); } @@ -906,15 +906,15 @@ static int area_swap_init(wmOperator *op, const wmEvent *event) { sAreaSwapData *sd = NULL; sActionzoneData *sad = event->customdata; - + if (sad == NULL || sad->sa1 == NULL) return 0; - + sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); sd->sa1 = sad->sa1; sd->sa2 = sad->sa2; op->customdata = sd; - + return 1; } @@ -934,22 +934,22 @@ static void area_swap_cancel(bContext *C, wmOperator *op) static int area_swap_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - + if (!area_swap_init(op, event)) return OPERATOR_PASS_THROUGH; - + /* add modal handler */ WM_cursor_modal_set(CTX_wm_window(C), BC_SWAPAREA_CURSOR); WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; - + } static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event) { sActionzoneData *sad = op->customdata; - + switch (event->type) { case MOUSEMOVE: /* second area, for join */ @@ -966,15 +966,15 @@ static int area_swap_modal(bContext *C, wmOperator *op, const wmEvent *event) ED_area_tag_redraw(sad->sa2); ED_area_swapspace(C, sad->sa1, sad->sa2); - + area_swap_exit(C, op); - + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } break; - + case ESCKEY: area_swap_cancel(C, op); return OPERATOR_CANCELLED; @@ -987,12 +987,12 @@ static void SCREEN_OT_area_swap(wmOperatorType *ot) ot->name = "Swap Areas"; ot->description = "Swap selected areas screen positions"; ot->idname = "SCREEN_OT_area_swap"; - + ot->invoke = area_swap_invoke; ot->modal = area_swap_modal; ot->poll = ED_operator_areaactive; ot->cancel = area_swap_cancel; - + ot->flag = OPTYPE_BLOCKING; } @@ -1011,18 +1011,18 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) bScreen *newsc, *sc; ScrArea *sa; rcti rect; - + win = CTX_wm_window(C); sc = CTX_wm_screen(C); sa = CTX_wm_area(C); - + /* XXX hrmf! */ if (event->type == EVT_ACTIONZONE_AREA) { sActionzoneData *sad = event->customdata; - + if (sad == NULL) return OPERATOR_PASS_THROUGH; - + sa = sad->sa1; } @@ -1039,11 +1039,11 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) } *newwin->stereo3d_format = *win->stereo3d_format; - + /* allocs new screen and adds to newly created window, using window size */ newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2); newwin->screen = newsc; - + /* copy area to new screen */ ED_area_data_copy((ScrArea *)newsc->areabase.first, sa, true); @@ -1056,7 +1056,7 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, const wmEvent *event) finally: if (event->type == EVT_ACTIONZONE_AREA) actionzone_exit(op); - + if (newwin) { return OPERATOR_FINISHED; } @@ -1070,7 +1070,7 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot) ot->name = "Duplicate Area into New Window"; ot->description = "Duplicate selected area into new window"; ot->idname = "SCREEN_OT_area_dupli"; - + ot->invoke = area_dupli_invoke; ot->poll = ED_operator_areaactive; } @@ -1081,7 +1081,7 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot) /** \name Move Area Edge Operator * \{ */ -/* operator state vars used: +/* operator state vars used: * x, y mouse coord near edge * delta movement of edge * @@ -1124,22 +1124,22 @@ static void area_move_set_limits(bScreen *sc, int dir, ScrArea *sa; int areaminy = ED_area_headersize(); int areamin; - + /* we check all areas and test for free space with MINSIZE */ *bigger = *smaller = 100000; - + for (sa = sc->areabase.first; sa; sa = sa->next) { if (dir == 'h') { int y1; areamin = areaminy; - + if (sa->v1->vec.y > 0) areamin += U.pixelsize; if (sa->v2->vec.y < winsize_y - 1) areamin += U.pixelsize; - + y1 = sa->v2->vec.y - sa->v1->vec.y + 1 - areamin; - + /* if top or down edge selected, test height */ if (sa->v1->editflag && sa->v4->editflag) *bigger = min_ii(*bigger, y1); @@ -1149,14 +1149,14 @@ static void area_move_set_limits(bScreen *sc, int dir, else { int x1; areamin = AREAMINX; - + if (sa->v1->vec.x > 0) areamin += U.pixelsize; if (sa->v4->vec.x < winsize_x - 1) areamin += U.pixelsize; - + x1 = sa->v4->vec.x - sa->v1->vec.x + 1 - areamin; - + /* if left or right edge selected, test width */ if (sa->v1->editflag && sa->v2->editflag) *bigger = min_ii(*bigger, x1); @@ -1178,29 +1178,29 @@ static int area_move_init(bContext *C, wmOperator *op) const int winsize_x = WM_window_pixels_x(win); const int winsize_y = WM_window_pixels_y(win); int x, y; - + /* required properties */ x = RNA_int_get(op->ptr, "x"); y = RNA_int_get(op->ptr, "y"); - + /* setup */ actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y); if (actedge == NULL) return 0; - + md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); op->customdata = md; - + md->dir = scredge_is_horizontal(actedge) ? 'h' : 'v'; if (md->dir == 'h') md->origval = actedge->v1->vec.y; else md->origval = actedge->v1->vec.x; - + select_connected_scredge(sc, actedge); /* now all vertices with 'flag==1' are the ones that can be moved. Move this to editflag */ for (v1 = sc->vertbase.first; v1; v1 = v1->next) v1->editflag = v1->flag; - + area_move_set_limits(sc, md->dir, winsize_x, winsize_y, &md->bigger, &md->smaller); - + return 1; } @@ -1313,7 +1313,7 @@ static void area_move_exit(bContext *C, wmOperator *op) if (op->customdata) MEM_freeN(op->customdata); op->customdata = NULL; - + /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(CTX_wm_screen(C)); removedouble_scredges(CTX_wm_screen(C)); @@ -1323,10 +1323,10 @@ static int area_move_exec(bContext *C, wmOperator *op) { if (!area_move_init(C, op)) return OPERATOR_CANCELLED; - + area_move_apply(C, op); area_move_exit(C, op); - + return OPERATOR_FINISHED; } @@ -1335,19 +1335,19 @@ static int area_move_invoke(bContext *C, wmOperator *op, const wmEvent *event) { RNA_int_set(op->ptr, "x", event->x); RNA_int_set(op->ptr, "y", event->y); - - if (!area_move_init(C, op)) + + if (!area_move_init(C, op)) return OPERATOR_PASS_THROUGH; - + /* add temp handler */ WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; } static void area_move_cancel(bContext *C, wmOperator *op) { - + RNA_int_set(op->ptr, "delta", 0); area_move_apply(C, op); area_move_exit(C, op); @@ -1358,17 +1358,17 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event) { sAreaMoveData *md = op->customdata; int delta, x, y; - + /* execute the events */ switch (event->type) { case MOUSEMOVE: { x = RNA_int_get(op->ptr, "x"); y = RNA_int_get(op->ptr, "y"); - + delta = (md->dir == 'v') ? event->x - x : event->y - y; RNA_int_set(op->ptr, "delta", delta); - + area_move_apply(C, op); break; } @@ -1378,7 +1378,7 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event) case KM_MODAL_APPLY: area_move_exit(C, op); return OPERATOR_FINISHED; - + case KM_MODAL_CANCEL: area_move_cancel(C, op); return OPERATOR_CANCELLED; @@ -1393,7 +1393,7 @@ static int area_move_modal(bContext *C, wmOperator *op, const wmEvent *event) break; } } - + return OPERATOR_RUNNING_MODAL; } @@ -1403,16 +1403,16 @@ static void SCREEN_OT_area_move(wmOperatorType *ot) ot->name = "Move Area Edges"; ot->description = "Move selected area edges"; ot->idname = "SCREEN_OT_area_move"; - + ot->exec = area_move_exec; ot->invoke = area_move_invoke; ot->cancel = area_move_cancel; ot->modal = area_move_modal; ot->poll = ED_operator_screen_mainwinactive; /* when mouse is over area-edge */ - + /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; - + /* rna */ RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); @@ -1471,7 +1471,7 @@ typedef struct sAreaSplitData { ScrEdge *nedge; /* new edge */ ScrArea *sarea; /* start area */ ScrArea *narea; /* new area */ - + } sAreaSplitData; static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdata) @@ -1491,11 +1491,11 @@ static void area_split_draw_cb(const struct wmWindow *UNUSED(win), void *userdat static int area_split_menu_init(bContext *C, wmOperator *op) { sAreaSplitData *sd; - + /* custom data */ sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; - + sd->sarea = CTX_wm_area(C); return 1; @@ -1508,25 +1508,25 @@ static int area_split_init(bContext *C, wmOperator *op) sAreaSplitData *sd; int areaminy = ED_area_headersize() + 1; int dir; - + /* required context */ if (sa == NULL) return 0; - + /* required properties */ dir = RNA_enum_get(op->ptr, "direction"); - + /* minimal size */ if (dir == 'v' && sa->winx < 2 * AREAMINX) return 0; if (dir == 'h' && sa->winy < 2 * areaminy) return 0; - + /* custom data */ sd = (sAreaSplitData *)MEM_callocN(sizeof(sAreaSplitData), "op_area_split"); op->customdata = sd; - + sd->sarea = sa; sd->origsize = dir == 'v' ? sa->winx : sa->winy; sd->origmin = dir == 'v' ? sa->totrct.xmin : sa->totrct.ymin; - + return 1; } @@ -1542,7 +1542,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) ScrVert *sbv2 = sb->v2; ScrVert *sbv3 = sb->v3; ScrVert *sbv4 = sb->v4; - + if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ return screen_findedge(screen, sav1, sav2); } @@ -1555,7 +1555,7 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ return screen_findedge(screen, sav1, sav4); } - + return NULL; } @@ -1567,24 +1567,24 @@ static int area_split_apply(bContext *C, wmOperator *op) sAreaSplitData *sd = (sAreaSplitData *)op->customdata; float fac; int dir; - + fac = RNA_float_get(op->ptr, "factor"); dir = RNA_enum_get(op->ptr, "direction"); - + sd->narea = area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ - + if (sd->narea) { ScrVert *sv; - + sd->nedge = area_findsharededge(sc, sd->sarea, sd->narea); - + /* select newly created edge, prepare for moving edge */ for (sv = sc->vertbase.first; sv; sv = sv->next) sv->editflag = 0; - + sd->nedge->v1->editflag = 1; sd->nedge->v2->editflag = 1; - + if (dir == 'h') sd->origval = sd->nedge->v1->vec.y; else sd->origval = sd->nedge->v1->vec.x; @@ -1592,10 +1592,10 @@ static int area_split_apply(bContext *C, wmOperator *op) ED_area_tag_redraw(sd->narea); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - + return 1; } - + return 0; } @@ -1612,10 +1612,10 @@ static void area_split_exit(bContext *C, wmOperator *op) MEM_freeN(op->customdata); op->customdata = NULL; } - + WM_cursor_modal_restore(CTX_wm_window(C)); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - + /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(CTX_wm_screen(C)); removedouble_scredges(CTX_wm_screen(C)); @@ -1637,26 +1637,26 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) const int winsize_x = WM_window_pixels_x(win); const int winsize_y = WM_window_pixels_y(win); int dir; - + /* no full window splitting allowed */ if (sc->state != SCREENNORMAL) return OPERATOR_CANCELLED; - + if (event->type == EVT_ACTIONZONE_AREA) { sActionzoneData *sad = event->customdata; - + if (sad == NULL || sad->modifier > 0) { return OPERATOR_PASS_THROUGH; } - + /* verify *sad itself */ if (sad->sa1 == NULL || sad->az == NULL) return OPERATOR_PASS_THROUGH; - + /* is this our *sad? if areas not equal it should be passed on */ if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2) return OPERATOR_PASS_THROUGH; - + /* prepare operator state vars */ if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') { dir = 'h'; @@ -1667,52 +1667,52 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy); } RNA_enum_set(op->ptr, "direction", dir); - + /* general init, also non-UI case, adds customdata, sets area and defaults */ if (!area_split_init(C, op)) return OPERATOR_PASS_THROUGH; - + } else { ScrEdge *actedge; int x, y; - + /* retrieve initial mouse coord, so we can find the active edge */ if (RNA_struct_property_is_set(op->ptr, "mouse_x")) x = RNA_int_get(op->ptr, "mouse_x"); else x = event->x; - + if (RNA_struct_property_is_set(op->ptr, "mouse_y")) y = RNA_int_get(op->ptr, "mouse_y"); else y = event->x; - + actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, x, y); if (actedge == NULL) return OPERATOR_CANCELLED; - + dir = scredge_is_horizontal(actedge) ? 'v' : 'h'; - + RNA_enum_set(op->ptr, "direction", dir); - + /* special case, adds customdata, sets defaults */ if (!area_split_menu_init(C, op)) return OPERATOR_CANCELLED; - + } - + sd = (sAreaSplitData *)op->customdata; - + if (event->type == EVT_ACTIONZONE_AREA) { - + /* do the split */ if (area_split_apply(C, op)) { area_move_set_limits(sc, dir, winsize_x, winsize_y, &sd->bigger, &sd->smaller); - + /* add temp handler for edge move or cancel */ WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; } } @@ -1724,22 +1724,22 @@ static int area_split_invoke(bContext *C, wmOperator *op, const wmEvent *event) area_split_preview_update_cursor(C, op); return OPERATOR_RUNNING_MODAL; - + } - + return OPERATOR_PASS_THROUGH; } /* function to be called outside UI context, or for redo */ static int area_split_exec(bContext *C, wmOperator *op) { - + if (!area_split_init(C, op)) return OPERATOR_CANCELLED; - + area_split_apply(C, op); area_split_exit(C, op); - + return OPERATOR_FINISHED; } @@ -1747,7 +1747,7 @@ static int area_split_exec(bContext *C, wmOperator *op) static void area_split_cancel(bContext *C, wmOperator *op) { sAreaSplitData *sd = (sAreaSplitData *)op->customdata; - + if (sd->previewmode) { /* pass */ } @@ -1788,7 +1788,7 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) } } break; - + case MIDDLEMOUSE: case TABKEY: if (sd->previewmode == 0) { @@ -1804,9 +1804,9 @@ static int area_split_modal(bContext *C, wmOperator *op, const wmEvent *event) } } } - + break; - + case RIGHTMOUSE: /* cancel operation */ case ESCKEY: area_split_cancel(C, op); @@ -1883,17 +1883,17 @@ static void SCREEN_OT_area_split(wmOperatorType *ot) ot->name = "Split Area"; ot->description = "Split selected area into new windows"; ot->idname = "SCREEN_OT_area_split"; - + ot->exec = area_split_exec; ot->invoke = area_split_invoke; ot->modal = area_split_modal; ot->cancel = area_split_cancel; - + ot->poll = screen_active_editable; /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; - + /* rna */ RNA_def_enum(ot->srna, "direction", prop_direction_items, 'h', "Direction", ""); RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0); @@ -1915,7 +1915,7 @@ typedef struct RegionMoveData { int origx, origy; int maxsize; AZEdge edge; - + } RegionMoveData; @@ -1923,20 +1923,20 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) { ARegion *ar; int dist; - + if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { dist = BLI_rcti_size_x(&sa->totrct); } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ dist = BLI_rcti_size_y(&sa->totrct); } - - /* subtractwidth of regions on opposite side + + /* subtractwidth of regions on opposite side * prevents dragging regions into other opposite regions */ for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar == scalear) continue; - + if (scalear->alignment == RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_BOTTOM) dist -= ar->winy; else if (scalear->alignment == RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_TOP) @@ -1945,7 +1945,7 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) dist -= ar->winx; else if (scalear->alignment == RGN_ALIGN_RIGHT && ar->alignment == RGN_ALIGN_LEFT) dist -= ar->winx; - + /* case of regions in regions, like operator properties panel */ /* these can sit on top of other regions such as headers, so account for this */ else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP && @@ -1967,20 +1967,20 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event { sActionzoneData *sad = event->customdata; AZone *az; - + if (event->type != EVT_ACTIONZONE_REGION) { BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); return OPERATOR_CANCELLED; } - + az = sad->az; - + if (az->ar) { RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); int maxsize; - + op->customdata = rmd; - + rmd->az = az; rmd->ar = az->ar; rmd->sa = sad->sa1; @@ -1988,13 +1988,13 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event rmd->origx = event->x; rmd->origy = event->y; rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge); - + /* if not set we do now, otherwise it uses type */ if (rmd->ar->sizex == 0) rmd->ar->sizex = rmd->ar->winx; if (rmd->ar->sizey == 0) rmd->ar->sizey = rmd->ar->winy; - + /* now copy to regionmovedata */ if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { rmd->origval = rmd->ar->sizex; @@ -2002,21 +2002,21 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event else { rmd->origval = rmd->ar->sizey; } - + /* limit headers to standard height for now */ if (rmd->ar->regiontype == RGN_TYPE_HEADER) maxsize = ED_area_headersize(); else maxsize = 1000; - + CLAMP(rmd->maxsize, 0, maxsize); - + /* add temp handler */ WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; } - + return OPERATOR_FINISHED; } @@ -2071,21 +2071,21 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) { RegionMoveData *rmd = op->customdata; int delta; - + /* execute the events */ switch (event->type) { case MOUSEMOVE: - + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { delta = event->x - rmd->origx; if (rmd->edge == AE_LEFT_TO_TOPRIGHT) delta = -delta; - + /* region sizes now get multiplied */ delta /= UI_DPI_FAC; - + rmd->ar->sizex = rmd->origval + delta; CLAMP(rmd->ar->sizex, 0, rmd->maxsize); - + if (rmd->ar->sizex < UI_UNIT_X) { rmd->ar->sizex = rmd->origval; if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) @@ -2098,7 +2098,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) int maxsize = region_scale_get_maxsize(rmd); delta = event->y - rmd->origy; if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta; - + /* region sizes now get multiplied */ delta /= UI_DPI_FAC; @@ -2113,19 +2113,19 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } - else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) + else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) rmd->ar->sizey = maxsize; else if (rmd->ar->flag & RGN_FLAG_HIDDEN) region_scale_toggle_hidden(C, rmd); } ED_area_tag_redraw(rmd->sa); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - + break; - + case LEFTMOUSE: if (event->val == KM_RELEASE) { - + if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if (rmd->ar->flag & RGN_FLAG_HIDDEN) { region_scale_toggle_hidden(C, rmd); @@ -2139,15 +2139,15 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) } MEM_freeN(op->customdata); op->customdata = NULL; - + return OPERATOR_FINISHED; } break; - + case ESCKEY: break; } - + return OPERATOR_RUNNING_MODAL; } @@ -2163,13 +2163,13 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot) ot->name = "Scale Region Size"; ot->description = "Scale selected area"; ot->idname = "SCREEN_OT_region_scale"; - + ot->invoke = region_scale_invoke; ot->modal = region_scale_modal; ot->cancel = region_scale_cancel; - + ot->poll = ED_operator_areaactive; - + /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; } @@ -2228,19 +2228,19 @@ static int frame_offset_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); int delta; - + delta = RNA_int_get(op->ptr, "delta"); CFRA += delta; FRAMENUMBER_MIN_CLAMP(CFRA); SUBFRA = 0.f; - + areas_do_frame_follow(C, false); BKE_sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); - + return OPERATOR_FINISHED; } @@ -2249,13 +2249,13 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot) ot->name = "Frame Offset"; ot->idname = "SCREEN_OT_frame_offset"; ot->description = "Move current frame forward/backward by a given number"; - + ot->exec = frame_offset_exec; - + ot->poll = ED_operator_screenactive_norender; ot->flag = OPTYPE_UNDO_GROUPED; ot->undo_group = "FRAME_CHANGE"; - + /* rna */ RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); } @@ -2279,9 +2279,9 @@ static int frame_jump_exec(bContext *C, wmOperator *op) */ if (animtimer) { ScreenAnimData *sad = animtimer->customdata; - + sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME; - + if (RNA_boolean_get(op->ptr, "end")) sad->nextfra = PEFRA; else @@ -2292,14 +2292,14 @@ static int frame_jump_exec(bContext *C, wmOperator *op) CFRA = PEFRA; else CFRA = PSFRA; - + areas_do_frame_follow(C, true); BKE_sound_seek_scene(bmain, scene); WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } - + return OPERATOR_FINISHED; } @@ -2308,13 +2308,13 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot) ot->name = "Jump to Endpoint"; ot->description = "Jump to first/last frame in frame range"; ot->idname = "SCREEN_OT_frame_jump"; - + ot->exec = frame_jump_exec; - + ot->poll = ED_operator_screenactive_norender; ot->flag = OPTYPE_UNDO_GROUPED; ot->undo_group = "FRAME_CHANGE"; - + /* rna */ RNA_def_boolean(ot->srna, "end", 0, "Last Frame", "Jump to the last frame of the frame range"); } @@ -2337,7 +2337,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) float cfra; const bool next = RNA_boolean_get(op->ptr, "next"); bool done = false; - + /* sanity checks */ if (scene == NULL) return OPERATOR_CANCELLED; @@ -2346,13 +2346,13 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) /* init binarytree-list for getting keyframes */ BLI_dlrbTree_init(&keys); - + /* seed up dummy dopesheet context with flags to perform necessary filtering */ if ((scene->flag & SCE_KEYS_NO_SELONLY) == 0) { /* only selected channels are included */ ads.filterflag |= ADS_FILTER_ONLYSEL; } - + /* populate tree with keyframe nodes */ scene_to_keylist(&ads, scene, &keys, NULL); gpencil_to_keylist(&ads, scene->gpd, &keys); @@ -2361,7 +2361,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) ob_to_keylist(&ads, ob, &keys, NULL); gpencil_to_keylist(&ads, ob->gpd, &keys); } - + { Mask *mask = CTX_data_edit_mask(C); if (mask) { @@ -2372,13 +2372,13 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) /* build linked-list for searching */ BLI_dlrbTree_linkedlist_sync(&keys); - + /* find matching keyframe in the right direction */ if (next) ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra); else ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra); - + while ((ak != NULL) && (done == false)) { if (CFRA != (int)ak->cfra) { /* this changes the frame, so set the frame and we're done */ @@ -2395,7 +2395,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) } } } - + /* free temp stuff */ BLI_dlrbTree_free(&keys); @@ -2421,13 +2421,13 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) ot->name = "Jump to Keyframe"; ot->description = "Jump to previous/next keyframe"; ot->idname = "SCREEN_OT_keyframe_jump"; - + ot->exec = keyframe_jump_exec; - + ot->poll = ED_operator_screenactive_norender; ot->flag = OPTYPE_UNDO_GROUPED; ot->undo_group = "FRAME_CHANGE"; - + /* properties */ RNA_def_boolean(ot->srna, "next", true, "Next Keyframe", ""); } @@ -2522,16 +2522,16 @@ static int screen_set_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); bScreen *screen = CTX_wm_screen(C); bScreen *screen_prev = screen; - + ScrArea *sa = CTX_wm_area(C); int tot = BLI_listbase_count(&bmain->screen); int delta = RNA_int_get(op->ptr, "delta"); - + /* temp screens are for userpref or render display */ if (screen->temp || (sa && sa->full && sa->full->temp)) { return OPERATOR_CANCELLED; } - + if (delta == 1) { while (tot--) { screen = screen->id.next; @@ -2553,13 +2553,13 @@ static int screen_set_exec(bContext *C, wmOperator *op) else { screen = NULL; } - + if (screen && screen_prev != screen) { /* return to previous state before switching screens */ if (sa && sa->full) { ED_screen_full_restore(C, sa); /* may free 'screen_prev' */ } - + ED_screen_set(C, screen); return OPERATOR_FINISHED; } @@ -2571,7 +2571,7 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) ot->name = "Set Screen"; ot->description = "Cycle through available screens"; ot->idname = "SCREEN_OT_screen_set"; - + ot->exec = screen_set_exec; ot->poll = ED_operator_screenactive; @@ -2591,17 +2591,17 @@ static int screen_maximize_area_exec(bContext *C, wmOperator *op) bScreen *screen = CTX_wm_screen(C); ScrArea *sa = NULL; const bool hide_panels = RNA_boolean_get(op->ptr, "use_hide_panels"); - + /* search current screen for 'fullscreen' areas */ /* prevents restoring info header, when mouse is over it */ for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->full) break; } - + if (sa == NULL) { sa = CTX_wm_area(C); } - + if (hide_panels) { if (!ELEM(screen->state, SCREENNORMAL, SCREENFULL)) { return OPERATOR_CANCELLED; @@ -2625,7 +2625,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot) ot->name = "Toggle Maximize Area"; ot->description = "Toggle display selected area as fullscreen/maximized"; ot->idname = "SCREEN_OT_screen_full_area"; - + ot->exec = screen_maximize_area_exec; ot->poll = ED_operator_areaactive; ot->flag = 0; @@ -2640,7 +2640,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot) /** \name Screen Join-Area Operator * \{ */ -/* operator state vars used: +/* operator state vars used: * x1, y1 mouse coord in first area, which will disappear * x2, y2 mouse coord in 2nd area, which will become joined * @@ -2695,18 +2695,18 @@ static int area_join_init(bContext *C, wmOperator *op) int x1, y1; int x2, y2; int shared = 0; - + /* required properties, make negative to get return 0 if not set by caller */ x1 = RNA_int_get(op->ptr, "min_x"); y1 = RNA_int_get(op->ptr, "min_y"); x2 = RNA_int_get(op->ptr, "max_x"); y2 = RNA_int_get(op->ptr, "max_y"); - + sa1 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x1, y1); sa2 = BKE_screen_find_area_xy(CTX_wm_screen(C), SPACE_TYPE_ANY, x2, y2); if (sa1 == NULL || sa2 == NULL || sa1 == sa2) return 0; - + /* do areas share an edge? */ if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++; if (sa1->v2 == sa2->v1 || sa1->v2 == sa2->v2 || sa1->v2 == sa2->v3 || sa1->v2 == sa2->v4) shared++; @@ -2716,7 +2716,7 @@ static int area_join_init(bContext *C, wmOperator *op) printf("areas don't share edge\n"); return 0; } - + jd = (sAreaJoinData *)MEM_callocN(sizeof(sAreaJoinData), "op_area_join"); jd->sa1 = sa1; @@ -2734,7 +2734,7 @@ static int area_join_apply(bContext *C, wmOperator *op) { sAreaJoinData *jd = (sAreaJoinData *)op->customdata; if (!jd) return 0; - + if (!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)) { return 0; } @@ -2742,7 +2742,7 @@ static int area_join_apply(bContext *C, wmOperator *op) CTX_wm_area_set(C, NULL); CTX_wm_region_set(C, NULL); } - + return 1; } @@ -2758,7 +2758,7 @@ static void area_join_exit(bContext *C, wmOperator *op) MEM_freeN(jd); op->customdata = NULL; } - + /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scredges(CTX_wm_screen(C)); removenotused_scredges(CTX_wm_screen(C)); @@ -2767,55 +2767,55 @@ static void area_join_exit(bContext *C, wmOperator *op) static int area_join_exec(bContext *C, wmOperator *op) { - if (!area_join_init(C, op)) + if (!area_join_init(C, op)) return OPERATOR_CANCELLED; - + area_join_apply(C, op); area_join_exit(C, op); - + return OPERATOR_FINISHED; } /* interaction callback */ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - + if (event->type == EVT_ACTIONZONE_AREA) { sActionzoneData *sad = event->customdata; - + if (sad == NULL || sad->modifier > 0) { return OPERATOR_PASS_THROUGH; } - + /* verify *sad itself */ if (sad->sa1 == NULL || sad->sa2 == NULL) return OPERATOR_PASS_THROUGH; - + /* is this our *sad? if areas equal it should be passed on */ if (sad->sa1 == sad->sa2) return OPERATOR_PASS_THROUGH; - + /* prepare operator state vars */ RNA_int_set(op->ptr, "min_x", sad->x); RNA_int_set(op->ptr, "min_y", sad->y); RNA_int_set(op->ptr, "max_x", event->x); RNA_int_set(op->ptr, "max_y", event->y); } - - - if (!area_join_init(C, op)) + + + if (!area_join_init(C, op)) return OPERATOR_PASS_THROUGH; - + /* add temp handler */ WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; } static void area_join_cancel(bContext *C, wmOperator *op) { WM_event_add_notifier(C, NC_WINDOW, NULL); - + area_join_exit(C, op); } @@ -2824,15 +2824,15 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) { bScreen *sc = CTX_wm_screen(C); sAreaJoinData *jd = (sAreaJoinData *)op->customdata; - + /* execute the events */ switch (event->type) { - - case MOUSEMOVE: + + case MOUSEMOVE: { ScrArea *sa = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y); int dir; - + if (sa) { if (jd->sa1 != sa) { dir = area_getorientation(jd->sa1, sa); @@ -2840,7 +2840,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) jd->sa2 = sa; } else { - /* we are not bordering on the previously selected area + /* we are not bordering on the previously selected area * we check if area has common border with the one marked for removal * in this case we can swap areas. */ @@ -2856,7 +2856,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) WM_event_add_notifier(C, NC_WINDOW, NULL); } else { - /* we are back in the area previously selected for keeping + /* we are back in the area previously selected for keeping * we swap the areas if possible to allow user to choose */ if (jd->sa2 != NULL) { jd->sa1 = jd->sa2; @@ -2888,13 +2888,13 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_FINISHED; } break; - + case RIGHTMOUSE: case ESCKEY: area_join_cancel(C, op); return OPERATOR_CANCELLED; } - + return OPERATOR_RUNNING_MODAL; } @@ -2905,17 +2905,17 @@ static void SCREEN_OT_area_join(wmOperatorType *ot) ot->name = "Join Area"; ot->description = "Join selected areas into new window"; ot->idname = "SCREEN_OT_area_join"; - + /* api callbacks */ ot->exec = area_join_exec; ot->invoke = area_join_invoke; ot->modal = area_join_modal; ot->poll = screen_active_editable; ot->cancel = area_join_cancel; - + /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; - + /* rna */ RNA_def_int(ot->srna, "min_x", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "min_y", -100, INT_MIN, INT_MAX, "Y 1", "", INT_MIN, INT_MAX); @@ -2941,12 +2941,12 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent const int winsize_y = WM_window_pixels_y(win); actedge = screen_find_active_scredge(sc, winsize_x, winsize_y, event->x, event->y); - + if (actedge == NULL) return OPERATOR_CANCELLED; - + pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); layout = UI_popup_menu_layout(pup); - + uiItemFullO(layout, "SCREEN_OT_area_split", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0, &ptr); /* store initial mouse cursor position */ RNA_int_set(&ptr, "mouse_x", event->x); @@ -2958,9 +2958,9 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent RNA_int_set(&ptr, "min_y", event->y + 4); RNA_int_set(&ptr, "max_x", event->x - 4); RNA_int_set(&ptr, "max_y", event->y - 4); - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -2970,10 +2970,10 @@ static void SCREEN_OT_area_options(wmOperatorType *ot) ot->name = "Area Options"; ot->description = "Operations for splitting and merging"; ot->idname = "SCREEN_OT_area_options"; - + /* api callbacks */ ot->invoke = screen_area_options_invoke; - + ot->poll = ED_operator_screen_mainwinactive; /* flags */ @@ -2992,7 +2992,7 @@ static int spacedata_cleanup_exec(bContext *C, wmOperator *op) bScreen *screen; ScrArea *sa; int tot = 0; - + for (screen = bmain->screen.first; screen; screen = screen->id.next) { for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->spacedata.first != sa->spacedata.last) { @@ -3006,7 +3006,7 @@ static int spacedata_cleanup_exec(bContext *C, wmOperator *op) } } BKE_reportf(op->reports, RPT_INFO, "Removed amount of editors: %d", tot); - + return OPERATOR_FINISHED; } @@ -3016,11 +3016,11 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot) ot->name = "Clean-up Space-data"; ot->description = "Remove unused settings for invisible editors"; ot->idname = "SCREEN_OT_spacedata_cleanup"; - + /* api callbacks */ ot->exec = spacedata_cleanup_exec; ot->poll = WM_operator_winactive; - + } /** \} */ @@ -3048,7 +3048,7 @@ static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op)) WM_operator_free_all_after(wm, lastop); WM_operator_repeat(C, lastop); } - + return OPERATOR_CANCELLED; } @@ -3058,12 +3058,12 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot) ot->name = "Repeat Last"; ot->description = "Repeat last action"; ot->idname = "SCREEN_OT_repeat_last"; - + /* api callbacks */ ot->exec = repeat_last_exec; - + ot->poll = ED_operator_screenactive; - + } /** \} */ @@ -3079,37 +3079,37 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU uiPopupMenu *pup; uiLayout *layout; int items, i; - + items = BLI_listbase_count(&wm->operators); if (items == 0) return OPERATOR_CANCELLED; - + pup = UI_popup_menu_begin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); layout = UI_popup_menu_layout(pup); - + for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) if ((lastop->type->flag & OPTYPE_REGISTER) && WM_operator_repeat_check(C, lastop)) { uiItemIntO(layout, RNA_struct_ui_name(lastop->type->srna), ICON_NONE, op->type->idname, "index", i); } - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } static int repeat_history_exec(bContext *C, wmOperator *op) { wmWindowManager *wm = CTX_wm_manager(C); - + op = BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")); if (op) { /* let's put it as last operator in list */ BLI_remlink(&wm->operators, op); BLI_addtail(&wm->operators, op); - + WM_operator_repeat(C, op); } - + return OPERATOR_FINISHED; } @@ -3119,13 +3119,13 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot) ot->name = "Repeat History"; ot->description = "Display menu for previous actions performed"; ot->idname = "SCREEN_OT_repeat_history"; - + /* api callbacks */ ot->invoke = repeat_history_invoke; ot->exec = repeat_history_exec; - + ot->poll = ED_operator_screenactive; - + RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000); } @@ -3138,10 +3138,10 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot) static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event)) { wmOperator *lastop = WM_operator_last_redo(C); - + if (lastop) WM_operator_redo_popup(C, lastop); - + return OPERATOR_CANCELLED; } @@ -3151,10 +3151,10 @@ static void SCREEN_OT_redo_last(wmOperatorType *ot) ot->name = "Redo Last"; ot->description = "Display menu for last action performed"; ot->idname = "SCREEN_OT_redo_last"; - + /* api callbacks */ ot->invoke = redo_last_invoke; - + ot->poll = ED_operator_screenactive; } @@ -3197,7 +3197,7 @@ static void region_quadview_init_rv3d(ScrArea *sa, ARegion *ar, static int region_quadview_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); - + /* some rules... */ if (ar->regiontype != RGN_TYPE_WINDOW) { BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted"); @@ -3206,10 +3206,10 @@ static int region_quadview_exec(bContext *C, wmOperator *op) /* Exit quad-view */ ScrArea *sa = CTX_wm_area(C); ARegion *arn; - + /* keep current region */ ar->alignment = 0; - + if (sa->spacetype == SPACE_VIEW3D) { ARegion *ar_iter; RegionView3D *rv3d = ar->regiondata; @@ -3239,7 +3239,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op) } } } - + for (ar = sa->regionbase.first; ar; ar = arn) { arn = ar->next; if (ar->alignment == RGN_ALIGN_QSPLIT) { @@ -3260,14 +3260,14 @@ static int region_quadview_exec(bContext *C, wmOperator *op) ScrArea *sa = CTX_wm_area(C); ARegion *newar; int count; - + ar->alignment = RGN_ALIGN_QSPLIT; - + for (count = 0; count < 3; count++) { newar = BKE_area_region_copy(sa->type, ar); BLI_addtail(&sa->regionbase, newar); } - + /* lock views and set them */ if (sa->spacetype == SPACE_VIEW3D) { View3D *v3d = sa->spacedata.first; @@ -3297,8 +3297,8 @@ static int region_quadview_exec(bContext *C, wmOperator *op) ED_area_tag_redraw(sa); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } - - + + return OPERATOR_FINISHED; } @@ -3308,7 +3308,7 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot) ot->name = "Toggle Quad View"; ot->description = "Split selected area into camera, front, right & top views"; ot->idname = "SCREEN_OT_region_quadview"; - + /* api callbacks */ ot->exec = region_quadview_exec; ot->poll = ED_operator_region_view3d_active; @@ -3325,10 +3325,10 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot) static int region_flip_exec(bContext *C, wmOperator *UNUSED(op)) { ARegion *ar = CTX_wm_region(C); - + if (!ar) return OPERATOR_CANCELLED; - + if (ar->alignment == RGN_ALIGN_TOP) ar->alignment = RGN_ALIGN_BOTTOM; else if (ar->alignment == RGN_ALIGN_BOTTOM) @@ -3340,7 +3340,7 @@ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op)) ED_area_tag_redraw(CTX_wm_area(C)); WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -3351,7 +3351,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) ot->name = "Flip Region"; ot->idname = "SCREEN_OT_region_flip"; ot->description = "Toggle the region's alignment (left/right or top/bottom)"; - + /* api callbacks */ ot->exec = region_flip_exec; ot->poll = ED_operator_areaactive; @@ -3406,7 +3406,7 @@ static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op)) sa->flag = sa->flag ^ HEADER_NO_PULLDOWN; ED_area_tag_redraw(sa); - WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -3418,7 +3418,7 @@ static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) ot->name = "Expand/Collapse Header Menus"; ot->idname = "SCREEN_OT_header_toggle_menus"; ot->description = "Expand or collapse the header pulldown menus"; - + /* api callbacks */ ot->exec = header_toggle_menus_exec; ot->poll = ED_operator_areaactive; @@ -3449,7 +3449,7 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */ if (sa->spacetype != SPACE_FILE) { - if (sa->full) + if (sa->full) uiItemO(layout, IFACE_("Tile Area"), ICON_NONE, "SCREEN_OT_screen_full_area"); else uiItemO(layout, IFACE_("Maximize Area"), ICON_NONE, "SCREEN_OT_screen_full_area"); @@ -3477,7 +3477,7 @@ static void SCREEN_OT_header_toolbox(wmOperatorType *ot) ot->name = "Header Toolbox"; ot->description = "Display header region toolbox"; ot->idname = "SCREEN_OT_header_toolbox"; - + /* api callbacks */ ot->invoke = header_toolbox_invoke; } @@ -3498,14 +3498,14 @@ static int match_area_with_refresh(int spacetype, int refresh) return 1; break; } - + return 0; } static int match_region_with_redraws(int spacetype, int regiontype, int redraws, bool from_anim_edit) { if (regiontype == RGN_TYPE_WINDOW) { - + switch (spacetype) { case SPACE_VIEW3D: if ((redraws & TIME_ALL_3D_WIN) || from_anim_edit) @@ -3542,7 +3542,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws, if ((redraws & TIME_CLIPS) || from_anim_edit) return 1; break; - + } } else if (regiontype == RGN_TYPE_CHANNELS) { @@ -3606,12 +3606,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv ScrArea *sa; int sync; float time; - + /* sync, don't sync, or follow scene setting */ if (sad->flag & ANIMPLAY_FLAG_SYNC) sync = 1; else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync = 0; else sync = (scene->flag & SCE_FRAME_DROP); - + if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == false && isfinite(time = BKE_sound_sync_scene(scene))) @@ -3657,12 +3657,12 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv scene->r.cfra++; } } - + sad->last_duration = wt->duration; /* reset 'jumped' flag before checking if we need to jump... */ sad->flag &= ~ANIMPLAY_FLAG_JUMPED; - + if (sad->flag & ANIMPLAY_FLAG_REVERSE) { /* jump back to end? */ if (PRVRANGEON) { @@ -3700,14 +3700,14 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv sad->flag &= ~ANIMPLAY_FLAG_USE_NEXT_FRAME; sad->flag |= ANIMPLAY_FLAG_JUMPED; } - + if (sad->flag & ANIMPLAY_FLAG_JUMPED) { BKE_sound_seek_scene(bmain, scene); #ifdef PROFILE_AUDIO_SYNCH old_frame = CFRA; #endif } - + /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(bmain, scene, 1); @@ -3744,24 +3744,24 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), const wmEv } } } - + if (match_area_with_refresh(sa->spacetype, sad->refresh)) ED_area_tag_refresh(sa); } } - - /* update frame rate info too - * NOTE: this may not be accurate enough, since we might need this after modifiers/etc. + + /* update frame rate info too + * NOTE: this may not be accurate enough, since we might need this after modifiers/etc. * have been calculated instead of just before updates have been done? */ ED_refresh_viewport_fps(C); - + /* recalculate the timestep for the timer now that we've finished calculating this, * since the frames-per-second value may have been changed */ /* TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? */ wt->timestep = (1.0 / FPS); - + return OPERATOR_FINISHED; } return OPERATOR_PASS_THROUGH; @@ -3773,12 +3773,12 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) ot->name = "Animation Step"; ot->description = "Step through animation by position"; ot->idname = "SCREEN_OT_animation_step"; - + /* api callbacks */ ot->invoke = screen_animation_step; - + ot->poll = ED_operator_screenactive_norender; - + } /** \} */ @@ -3832,16 +3832,16 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) } else { int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */ - + if (mode == 1) /* XXX only play audio forwards!? */ BKE_sound_play_scene(scene); - + ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode); - + if (screen->animtimer) { wmTimer *wt = screen->animtimer; ScreenAnimData *sad = wt->customdata; - + sad->ar = CTX_wm_region(C); } } @@ -3853,10 +3853,10 @@ static int screen_animation_play_exec(bContext *C, wmOperator *op) { int mode = (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; int sync = -1; - + if (RNA_struct_property_is_set(op->ptr, "sync")) sync = (RNA_boolean_get(op->ptr, "sync")); - + return ED_screen_animation_play(C, sync, mode); } @@ -3868,12 +3868,12 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot) ot->name = "Play Animation"; ot->description = "Play animation"; ot->idname = "SCREEN_OT_animation_play"; - + /* api callbacks */ ot->exec = screen_animation_play_exec; - + ot->poll = ED_operator_screenactive_norender; - + prop = RNA_def_boolean(ot->srna, "reverse", 0, "Play in Reverse", "Animation is played backwards"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "sync", 0, "Sync", "Drop frames to maintain framerate"); @@ -3916,10 +3916,10 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot) ot->name = "Cancel Animation"; ot->description = "Cancel animation, returning to the original frame"; ot->idname = "SCREEN_OT_animation_cancel"; - + /* api callbacks */ ot->exec = screen_animation_cancel_exec; - + ot->poll = ED_operator_screenactive; RNA_def_boolean(ot->srna, "restore_frame", true, "Restore Frame", "Restore the frame when animation was initialized"); @@ -3931,7 +3931,7 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot) /** \name Border Select Operator (Template) * \{ */ -/* operator state vars used: (added by default WM callbacks) +/* operator state vars used: (added by default WM callbacks) * xmin, ymin * xmax, ymax * @@ -3953,14 +3953,14 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot) static int border_select_exec(bContext *C, wmOperator *op) { int event_type = RNA_int_get(op->ptr, "event_type"); - + if (event_type == LEFTMOUSE) printf("border select do select\n"); else if (event_type == RIGHTMOUSE) printf("border select deselect\n"); - else + else printf("border select do something\n"); - + return 1; } @@ -3969,15 +3969,15 @@ static void SCREEN_OT_border_select(wmOperatorType *ot) /* identifiers */ ot->name = "Border Select"; ot->idname = "SCREEN_OT_border_select"; - + /* api callbacks */ ot->exec = border_select_exec; ot->invoke = WM_gesture_border_invoke; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ED_operator_areaactive; - + /* rna */ RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX); WM_operator_properties_border(ot); @@ -3997,7 +3997,7 @@ static int fullscreen_back_exec(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); ScrArea *sa = NULL; - + /* search current screen for 'fullscreen' areas */ for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->full) break; @@ -4018,7 +4018,7 @@ static void SCREEN_OT_back_to_previous(struct wmOperatorType *ot) ot->name = "Back to Previous Screen"; ot->description = "Revert back to the original screen layout, before fullscreen area overlay"; ot->idname = "SCREEN_OT_back_to_previous"; - + /* api callbacks */ ot->exec = fullscreen_back_exec; ot->poll = ED_operator_screenactive; @@ -4034,7 +4034,7 @@ static int userpref_show_invoke(bContext *C, wmOperator *op, const wmEvent *even { int sizex = 800 * UI_DPI_FAC; int sizey = 480 * UI_DPI_FAC; - + /* changes context! */ if (WM_window_open_temp(C, event->x, event->y, sizex, sizey, WM_WINDOW_USERPREFS) != NULL) { return OPERATOR_FINISHED; @@ -4052,7 +4052,7 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot) ot->name = "Show User Preferences"; ot->description = "Show user preferences"; ot->idname = "SCREEN_OT_userpref_show"; - + /* api callbacks */ ot->invoke = userpref_show_invoke; ot->poll = ED_operator_screenactive; @@ -4068,10 +4068,10 @@ static int screen_new_exec(bContext *C, wmOperator *UNUSED(op)) { wmWindow *win = CTX_wm_window(C); bScreen *sc = CTX_wm_screen(C); - + sc = ED_screen_duplicate(win, sc); WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, sc); - + return OPERATOR_FINISHED; } @@ -4081,7 +4081,7 @@ static void SCREEN_OT_new(wmOperatorType *ot) ot->name = "New Screen"; ot->description = "Add a new screen"; ot->idname = "SCREEN_OT_new"; - + /* api callbacks */ ot->exec = screen_new_exec; ot->poll = WM_operator_winactive; @@ -4096,9 +4096,9 @@ static void SCREEN_OT_new(wmOperatorType *ot) static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) { bScreen *sc = CTX_wm_screen(C); - + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENDELETE, sc); - + return OPERATOR_FINISHED; } @@ -4108,7 +4108,7 @@ static void SCREEN_OT_delete(wmOperatorType *ot) ot->name = "Delete Screen"; ot->description = "Delete active screen"; ot->idname = "SCREEN_OT_delete"; - + /* api callbacks */ ot->exec = screen_delete_exec; } @@ -4140,11 +4140,11 @@ static int scene_new_exec(bContext *C, wmOperator *op) ED_object_single_users(bmain, newscene, true, true); } } - + ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - + WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, newscene); - + return OPERATOR_FINISHED; } @@ -4157,19 +4157,19 @@ static void SCENE_OT_new(wmOperatorType *ot) {SCE_COPY_LINK_DATA, "LINK_OBJECT_DATA", 0, "Link Object Data", "Copy objects linked to data from the current scene"}, {SCE_COPY_FULL, "FULL_COPY", 0, "Full Copy", "Make a full copy of the current scene"}, {0, NULL, 0, NULL, NULL}}; - + /* identifiers */ ot->name = "New Scene"; ot->description = "Add new scene by type"; ot->idname = "SCENE_OT_new"; - + /* api callbacks */ ot->exec = scene_new_exec; ot->invoke = WM_menu_invoke; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); } @@ -4202,10 +4202,10 @@ static void SCENE_OT_delete(wmOperatorType *ot) ot->name = "Delete Scene"; ot->description = "Delete active scene"; ot->idname = "SCENE_OT_delete"; - + /* api callbacks */ ot->exec = scene_delete_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -4243,7 +4243,7 @@ float ED_region_blend_factor(ARegion *ar) alpha = (float)ar->regiontimer->duration / TIMEOUT; /* makes sure the blend out works 100% - without area redraws */ if (rgi->hidden) alpha = 0.9f - TIMESTEP - alpha; - + CLAMP(alpha, 0.0f, 1.0f); return alpha; } @@ -4254,12 +4254,12 @@ float ED_region_blend_factor(ARegion *ar) static void region_blend_end(bContext *C, ARegion *ar, const bool is_running) { RegionAlphaInfo *rgi = ar->regiontimer->customdata; - + /* always send redraw */ ED_region_tag_redraw(ar); if (rgi->child_ar) ED_region_tag_redraw(rgi->child_ar); - + /* if running timer was hiding, the flag toggle went wrong */ if (is_running) { if (rgi->hidden) @@ -4283,14 +4283,14 @@ void region_blend_start(bContext *C, ScrArea *sa, ARegion *ar) wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); RegionAlphaInfo *rgi; - + /* end running timer */ if (ar->regiontimer) { region_blend_end(C, ar, true); } rgi = MEM_callocN(sizeof(RegionAlphaInfo), "RegionAlphaInfo"); - + rgi->hidden = ar->flag & RGN_FLAG_HIDDEN; rgi->sa = sa; rgi->ar = ar; @@ -4319,18 +4319,18 @@ static int region_blend_invoke(bContext *C, wmOperator *UNUSED(op), const wmEven { RegionAlphaInfo *rgi; wmTimer *timer = event->customdata; - + /* event type is TIMERREGION, but we better check */ if (event->type != TIMERREGION || timer == NULL) return OPERATOR_PASS_THROUGH; - + rgi = timer->customdata; - + /* always send redraws */ ED_region_tag_redraw(rgi->ar); if (rgi->child_ar) ED_region_tag_redraw(rgi->child_ar); - + /* end timer? */ if (rgi->ar->regiontimer->duration > (double)TIMEOUT) { region_blend_end(C, rgi->ar, false); @@ -4346,13 +4346,13 @@ static void SCREEN_OT_region_blend(wmOperatorType *ot) ot->name = "Region Alpha"; ot->idname = "SCREEN_OT_region_blend"; ot->description = "Blend in and out overlapping region"; - + /* api callbacks */ ot->invoke = region_blend_invoke; - + /* flags */ ot->flag = OPTYPE_INTERNAL; - + /* properties */ } @@ -4457,7 +4457,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_repeat_last); WM_operatortype_append(SCREEN_OT_repeat_history); WM_operatortype_append(SCREEN_OT_redo_last); - + /* screen tools */ WM_operatortype_append(SCREEN_OT_area_move); WM_operatortype_append(SCREEN_OT_area_split); @@ -4480,23 +4480,23 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_userpref_show); WM_operatortype_append(SCREEN_OT_region_blend); WM_operatortype_append(SCREEN_OT_space_context_cycle); - + /*frame changes*/ WM_operatortype_append(SCREEN_OT_frame_offset); WM_operatortype_append(SCREEN_OT_frame_jump); WM_operatortype_append(SCREEN_OT_keyframe_jump); WM_operatortype_append(SCREEN_OT_marker_jump); - + WM_operatortype_append(SCREEN_OT_animation_step); WM_operatortype_append(SCREEN_OT_animation_play); WM_operatortype_append(SCREEN_OT_animation_cancel); - + /* new/delete */ WM_operatortype_append(SCREEN_OT_new); WM_operatortype_append(SCREEN_OT_delete); WM_operatortype_append(SCENE_OT_new); WM_operatortype_append(SCENE_OT_delete); - + /* tools shared by more space types */ WM_operatortype_append(ED_OT_undo); WM_operatortype_append(ED_OT_undo_push); @@ -4505,7 +4505,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(ED_OT_undo_history); WM_operatortype_append(ED_OT_flush_edits); - + } /** \} */ @@ -4523,20 +4523,20 @@ static void keymap_modal_set(wmKeyConfig *keyconf) {KM_MODAL_SNAP_OFF, "SNAP_OFF", 0, "Snap off", ""}, {0, NULL, 0, NULL, NULL}}; wmKeyMap *keymap; - + /* Standard Modal keymap ------------------------------------------------ */ keymap = WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items); - + WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, KM_MODAL_APPLY); WM_modalkeymap_add_item(keymap, RETKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_APPLY); WM_modalkeymap_add_item(keymap, PADENTER, KM_PRESS, KM_ANY, 0, KM_MODAL_APPLY); - + WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_SNAP_ON); WM_modalkeymap_add_item(keymap, LEFTCTRLKEY, KM_RELEASE, KM_ANY, 0, KM_MODAL_SNAP_OFF); - + WM_modalkeymap_assign(keymap, "SCREEN_OT_area_move"); - + } static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNUSED(event)) @@ -4562,14 +4562,14 @@ void ED_keymap_screen(wmKeyConfig *keyconf) ListBase *lb; wmKeyMap *keymap; wmKeyMapItem *kmi; - + /* Screen Editing ------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "Screen Editing", 0, 0); - + RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "modifier", 2); - + /* screen tools */ WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE_AREA, 0, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE_AREA, 0, 0, 0); @@ -4580,7 +4580,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "use_hide_panels", true); /* area move after action zones */ WM_keymap_verify_item(keymap, "SCREEN_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0); - + WM_keymap_verify_item(keymap, "SCREEN_OT_area_options", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_header", F9KEY, KM_PRESS, KM_ALT, 0); @@ -4593,12 +4593,12 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* Screen General ------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "Screen", 0, 0); - + /* standard timers */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0); WM_keymap_add_item(keymap, "SCREEN_OT_region_blend", TIMERREGION, KM_ANY, KM_ANY, 0); - - + + RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1); WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0); @@ -4622,12 +4622,12 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "SCRIPT_OT_reload", F8KEY, KM_PRESS, 0, 0); - + /* files */ WM_keymap_add_item(keymap, "FILE_OT_execute", RETKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_execute", PADENTER, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0); - + /* undo */ #ifdef __APPLE__ WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0); @@ -4637,8 +4637,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); - - + + /* render */ kmi = WM_keymap_add_item(keymap, "RENDER_OT_render", F12KEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_viewport", true); @@ -4648,62 +4648,62 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "RENDER_OT_view_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "RENDER_OT_view_show", F11KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "RENDER_OT_play_rendered_anim", F11KEY, KM_PRESS, KM_CTRL, 0); - + /* user prefs */ #ifdef __APPLE__ WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0); #endif WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - - + + /* Anim Playback ------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "Frames", 0, 0); - + /* frame offsets */ RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", 10); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "delta", -10); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); - + RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELUPMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); - + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", true); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", false); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", true); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", false); - + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", UPARROWKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "next", true); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", DOWNARROWKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "next", false); - + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIALAST, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "next", true); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_keyframe_jump", MEDIAFIRST, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "next", false); - + /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", true); WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", MEDIASTOP, KM_PRESS, 0, 0); - + /* Alternative keys for animation and sequencer playing */ #if 0 /* XXX: disabled for restoring later... bad implementation */ keymap = WM_keymap_find(keyconf, "Frames", 0, 0); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "cycle_speed", true); - + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", LEFTARROWKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "reverse", true); RNA_boolean_set(kmi->ptr, "cycle_speed", true); - + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0); #endif diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 2dd7400bc37..8274ca68d7e 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -102,7 +102,7 @@ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy) *dumpsy = WM_window_pixels_y(win); if (*dumpsx && *dumpsy) { - + dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); glReadBuffer(GL_FRONT); screenshot_read_pixels(x, y, *dumpsx, *dumpsy, (unsigned char *)dumprect); @@ -120,13 +120,13 @@ static int screenshot_data_create(bContext *C, wmOperator *op) /* do redraw so we don't show popups/menus */ WM_redraw_windows(C); - + dumprect = screenshot(C, &dumpsx, &dumpsy); if (dumprect) { ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot"); ScrArea *sa = CTX_wm_area(C); - + scd->dumpsx = dumpsx; scd->dumpsy = dumpsy; scd->dumprect = dumprect; @@ -235,9 +235,9 @@ static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( BLI_replace_extension(filepath, sizeof(filepath), ""); /* strip '.blend' */ } RNA_string_set(op->ptr, "filepath", filepath); - + WM_event_add_fileselect(C, op); - + return OPERATOR_RUNNING_MODAL; } return OPERATOR_CANCELLED; @@ -289,16 +289,16 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->name = "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */ ot->idname = "SCREEN_OT_screenshot"; ot->description = "Capture a picture of the active area or whole Blender window"; - + ot->invoke = screenshot_invoke; ot->check = screenshot_check; ot->exec = screenshot_exec; ot->cancel = screenshot_cancel; ot->ui = screenshot_draw; ot->poll = screenshot_poll; - + ot->flag = 0; - + WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); @@ -326,7 +326,7 @@ typedef struct ScreenshotJob { static void screenshot_freejob(void *sjv) { ScreenshotJob *sj = sjv; - + if (sj->dumprect) MEM_freeN(sj->dumprect); @@ -345,11 +345,11 @@ static void screenshot_updatejob(void *sjv) { ScreenshotJob *sj = sjv; unsigned int *dumprect; - + if (sj->dumprect == NULL) { dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); screenshot_read_pixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, (unsigned char *)dumprect); - + sj->dumprect = dumprect; } } @@ -365,7 +365,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float /* we need this as local variables for renderdata */ rd.frs_sec = U.scrcastfps; rd.frs_sec_base = 1.0f; - + if (BKE_imtype_is_movie(rd.im_format.imtype)) { mh = BKE_movie_handle_get(sj->scene->r.im_format.imtype); if (mh == NULL) { @@ -380,16 +380,16 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float return; } } - + sj->stop = stop; sj->do_update = do_update; - + *do_update = true; /* wait for opengl rect */ - + while (*stop == 0) { - + if (sj->dumprect) { - + if (mh) { if (mh->append_movie(sj->movie_ctx, &rd, rd.sfra, rd.cfra, (int *)sj->dumprect, sj->dumpsx, sj->dumpsy, "", &sj->reports)) @@ -405,14 +405,14 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float ImBuf *ibuf = IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); char name[FILE_MAX]; int ok; - + BKE_image_path_from_imformat( name, rd.pic, sj->bmain->name, rd.cfra, &rd.im_format, (rd.scemode & R_EXTENSION) != 0, true, NULL); - + ibuf->rect = sj->dumprect; ok = BKE_imbuf_write(ibuf, name, &rd.im_format); - + if (ok == 0) { printf("Write error: cannot save %s\n", name); BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s", name); @@ -422,23 +422,23 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float printf("Saved file: %s\n", name); BKE_reportf(&sj->reports, RPT_INFO, "Saved file: %s", name); } - + /* imbuf knows which rects are not part of ibuf */ IMB_freeImBuf(ibuf); } - + MEM_freeN(sj->dumprect); sj->dumprect = NULL; - + *do_update = true; - + rd.cfra++; } - else + else PIL_sleep_ms(U.scrcastwait); } - + if (mh) { mh->end_movie(sj->movie_ctx); mh->context_free(sj->movie_ctx); @@ -451,24 +451,24 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float /* Helper callback for drawing the cursor itself */ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUSED(p_ptr)) { - + glPushMatrix(); - + glTranslatef((float)x, (float)y, 0.0f); - - + + glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + glColor4ub(0, 0, 0, 32); glutil_draw_filled_arc(0.0, M_PI * 2.0, 20, 40); - + glColor4ub(255, 255, 255, 128); glutil_draw_lined_arc(0.0, M_PI * 2.0, 20, 40); - + glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); - + glPopMatrix(); } @@ -476,7 +476,7 @@ static void screencast_draw_cursor(bContext *UNUSED(C), int x, int y, void *UNUS static void screencast_cursor_toggle(wmWindowManager *wm, short enable) { static void *cursor = NULL; - + if (cursor && !enable) { /* clear cursor */ WM_paint_cursor_end(wm, cursor); @@ -491,7 +491,7 @@ static void screencast_cursor_toggle(wmWindowManager *wm, short enable) static void screenshot_endjob(void *sjv) { ScreenshotJob *sj = sjv; - + screencast_cursor_toggle(sj->wm, 0); } @@ -507,10 +507,10 @@ static int screencast_exec(bContext *C, wmOperator *op) /* if called again, stop the running job */ if (WM_jobs_test(wm, screen, WM_JOB_TYPE_SCREENCAST)) WM_jobs_stop(wm, screen, screenshot_startjob); - + wm_job = WM_jobs_get(wm, win, screen, "Screencast", 0, WM_JOB_TYPE_SCREENCAST); sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); - + /* setup sj */ if (RNA_boolean_get(op->ptr, "full")) { sj->x = 0; @@ -528,20 +528,20 @@ static int screencast_exec(bContext *C, wmOperator *op) sj->bmain = CTX_data_main(C); sj->scene = CTX_data_scene(C); sj->wm = wm; - + BKE_reports_init(&sj->reports, RPT_PRINT); /* setup job */ WM_jobs_customdata_set(wm_job, sj, screenshot_freejob); WM_jobs_timer(wm_job, 0.1, 0, NC_SCREEN | ND_SCREENCAST); WM_jobs_callbacks(wm_job, screenshot_startjob, NULL, screenshot_updatejob, screenshot_endjob); - + WM_jobs_start(sj->wm, wm_job); - + screencast_cursor_toggle(sj->wm, 1); - + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen); - + return OPERATOR_FINISHED; } @@ -550,13 +550,13 @@ void SCREEN_OT_screencast(wmOperatorType *ot) ot->name = "Make Screencast"; ot->idname = "SCREEN_OT_screencast"; ot->description = "Capture a video of the active area or whole Blender window"; - + ot->invoke = WM_operator_confirm; ot->exec = screencast_exec; ot->poll = screenshot_poll; /* shared poll */ - + ot->flag = 0; - + RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Capture the whole window (otherwise only capture the active area)"); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index e6219b4fae1..3c3b9e91ab9 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -262,7 +262,7 @@ static int load_tex(Brush *br, ViewContext *vc, float zoom, bool col, bool prima target = (primary) ? &primary_snap : &secondary_snap; - refresh = + refresh = !target->overlay_texture || (invalid != 0) || !same_tex_snap(target, mtex, vc, col, zoom); @@ -967,7 +967,7 @@ static void paint_cursor_on_hit(UnifiedPaintSettings *ups, Brush *brush, ViewCon else projected_radius = BKE_brush_size_get(vc->scene, brush); } - + /* convert brush radius from 2D to 3D */ unprojected_radius = paint_calc_object_space_radius(vc, location, projected_radius); diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 120514762f4..44abdc34ffb 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -695,17 +695,17 @@ void PAINTCURVE_OT_draw(wmOperatorType *ot) static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) { ePaintMode mode = BKE_paintmode_get_active_from_context(C); - + switch (mode) { case ePaintTexture2D: { ARegion *ar = CTX_wm_region(C); SpaceImage *sima = CTX_wm_space_image(C); float location[2]; - + if (!sima) return OPERATOR_CANCELLED; - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &location[0], &location[1]); copy_v2_v2(sima->cursor, location); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); @@ -715,7 +715,7 @@ static int paintcurve_cursor_invoke(bContext *C, wmOperator *UNUSED(op), const w ED_view3d_cursor3d_update(C, event->mval); break; } - + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index e2b318710a8..0bec71f0566 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -101,7 +101,7 @@ static void partialvis_update_mesh(Object *ob, const int *vert_indices; int totvert, i; bool any_changed = false, any_visible = false; - + BKE_pbvh_node_num_verts(pbvh, node, NULL, &totvert); BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); @@ -153,7 +153,7 @@ static void partialvis_update_grids(Object *ob, &grids); grid_hidden = BKE_pbvh_grid_hidden(pbvh); BKE_pbvh_get_grid_key(pbvh, &key); - + sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); for (i = 0; i < totgrid; i++) { @@ -324,7 +324,7 @@ static void clip_planes_from_rect(bContext *C, ViewContext vc; BoundBox bb; bglMats mats = {{0}}; - + view3d_operator_needs_opengl(C); ED_view3d_viewcontext_init(C, &vc); view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); @@ -356,7 +356,7 @@ static void get_pbvh_nodes(PBVH *pbvh, case PARTIALVIS_MASKED: break; } - + BKE_pbvh_search_gather(pbvh, cb, clip_planes, nodes, totnode); } @@ -415,7 +415,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) if (nodes) MEM_freeN(nodes); - + /* end undo */ sculpt_undo_push_end(); @@ -426,7 +426,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) } ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -455,7 +455,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) {PARTIALVIS_MASKED, "MASKED", 0, "Masked", "Hide or show vertices that are masked (minimum mask value of 0.5)"}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Hide/Show"; ot->idname = "PAINT_OT_hide_show"; @@ -475,6 +475,6 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) "Action", "Whether to hide or show vertices"); RNA_def_enum(ot->srna, "area", area_items, PARTIALVIS_INSIDE, "Area", "Which vertices to hide or show"); - + WM_operator_properties_border(ot); } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index ef4f598a6b7..c2b1fcaf460 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -167,7 +167,7 @@ void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short te IMB_partial_display_buffer_update_delayed(ibuf, imapaintpartial.x1, imapaintpartial.y1, imapaintpartial.x2, imapaintpartial.y2); } - + if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; @@ -193,7 +193,7 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj) if (proj) { radius = 0.5f; - + side = kernel->side = 2; kernel->side_squared = kernel->side * kernel->side; kernel->wdata = MEM_mallocN(sizeof(float) * kernel->side_squared, "blur kernel data"); @@ -202,15 +202,15 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj) else { if (br->blur_kernel_radius <= 0) br->blur_kernel_radius = 1; - + radius = br->blur_kernel_radius; - + side = kernel->side = radius * 2 + 1; kernel->side_squared = kernel->side * kernel->side; kernel->wdata = MEM_mallocN(sizeof(float) * kernel->side_squared, "blur kernel data"); kernel->pixel_len = br->blur_kernel_radius; } - + switch (type) { case KERNEL_BOX: for (i = 0; i < kernel->side_squared; i++) @@ -219,9 +219,9 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj) case KERNEL_GAUSSIAN: { - /* at 3.0 standard deviations distance, kernel is about zero */ - float standard_dev = radius / 3.0f; - + /* at 3.0 standard deviations distance, kernel is about zero */ + float standard_dev = radius / 3.0f; + /* make the necessary adjustment to the value for use in the normal distribution formula */ standard_dev = -standard_dev * standard_dev * 2; @@ -230,7 +230,7 @@ BlurKernel *paint_new_blur_kernel(Brush *br, bool proj) float idist = radius - i; float jdist = radius - j; float value = exp((idist * idist + jdist * jdist) / standard_dev); - + kernel->wdata[i + j * side] = value; } } @@ -298,7 +298,7 @@ static int image_paint_2d_clone_poll(bContext *C) if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) if (brush->clone.image) return 1; - + return 0; } @@ -434,7 +434,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo BKE_paint_data_warning(op->reports, uvs, mat, tex, stencil); MEM_freeN(pop); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); - return NULL; + return NULL; } pop->mode = PAINT_MODE_3D_PROJECT; pop->custom_paint = paint_proj_new_stroke(C, ob, mouse, mode); @@ -452,7 +452,7 @@ static PaintOperation *texture_paint_init(bContext *C, wmOperator *op, const flo if ((brush->imagepaint_tool == PAINT_TOOL_FILL) && (brush->flag & BRUSH_USE_GRADIENT)) { pop->cursor = WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, gradient_draw_line, pop); } - + settings->imapaint.flag |= IMAGEPAINT_DRAWING; ED_image_undo_push_begin(op->type->name); @@ -815,7 +815,7 @@ void PAINT_OT_grab_clone(wmOperatorType *ot) ot->name = "Grab Clone"; ot->idname = "PAINT_OT_grab_clone"; ot->description = "Move the clone source image"; - + /* api callbacks */ ot->exec = grab_clone_exec; ot->invoke = grab_clone_invoke; @@ -880,7 +880,7 @@ static int sample_color_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); - + return OPERATOR_FINISHED; } @@ -987,7 +987,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) ot->name = "Sample Color"; ot->idname = "PAINT_OT_sample_color"; ot->description = "Use the mouse to sample a color in the image"; - + /* api callbacks */ ot->exec = sample_color_exec; ot->invoke = sample_color_invoke; @@ -1055,7 +1055,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) BKE_texpaint_slots_refresh_object(scene, ob); BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - + /* entering paint mode also sets image to editors */ if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { Material *ma = give_current_material(ob, ob->actcol); /* set the current material active paint slot on image editor */ @@ -1065,8 +1065,8 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) } else if (imapaint->mode == IMAGEPAINT_MODE_IMAGE) { ima = imapaint->canvas; - } - + } + if (ima) { for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; @@ -1075,7 +1075,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; - + if (!sima->pin) ED_space_image_set(bmain, sima, scene, scene->obedit, ima); } @@ -1083,7 +1083,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) } } } - + ob->mode |= mode_flag; BKE_paint_init(scene, ePaintTextureProjective, PAINT_CURSOR_TEXTURE_PAINT); @@ -1107,7 +1107,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) ot->name = "Texture Paint Toggle"; ot->idname = "PAINT_OT_texture_paint_toggle"; ot->description = "Toggle texture paint mode in 3D view"; - + /* api callbacks */ ot->exec = texture_paint_toggle_exec; ot->poll = texture_paint_toggle_poll; @@ -1127,7 +1127,7 @@ static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) br = image_paint_brush(C); } else { - /* At the moment, wpaint does not support the color flipper. + /* At the moment, wpaint does not support the color flipper. * So for now we're only handling vpaint */ ToolSettings *ts = CTX_data_tool_settings(C); VPaint *vp = ts->vpaint; @@ -1200,7 +1200,7 @@ static int texture_paint_poll(bContext *C) if (texture_paint_toggle_poll(C)) if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) return 1; - + return 0; } diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 37096f9e660..ec1a6ebf7ed 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -581,7 +581,7 @@ static void brush_painter_imbuf_partial_update(BrushPainter *painter, const floa destx = desty = 0; w = h = 0; } - + x1 = min_ii(destx, ibuf->x); y1 = min_ii(desty, ibuf->y); x2 = min_ii(destx + w, ibuf->x); @@ -1131,13 +1131,13 @@ static int paint_2d_op(void *state, ImBuf *ibufb, unsigned short *curveb, unsign paint_2d_set_region(region, bpos[0], bpos[1], 0, 0, frombuf->x, frombuf->y); tot = 1; } - + /* blend into canvas */ for (a = 0; a < tot; a++) { ED_imapaint_dirty_region(s->image, s->canvas, region[a].destx, region[a].desty, region[a].width, region[a].height, true); - + if (s->do_masking) { /* masking, find original pixels tiles from undo buffer to composite over */ int tilex, tiley, tilew, tileh; @@ -1231,7 +1231,7 @@ static int paint_2d_canvas_set(ImagePaintState *s, Image *ima) /* set masking */ s->do_masking = paint_use_opacity_masking(s->brush); - + return 1; } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index a284b17a0b4..8e1d47db61a 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1053,7 +1053,7 @@ static bool check_seam( /* set up the other face */ *other_face = tri_index; - + /* we check if difference is 1 here, else we might have a case of edge 2-0 for a tri */ *orig_fidx = (i1_fidx < i2_fidx && (i2_fidx - i1_fidx == 1)) ? i1_fidx : i2_fidx; @@ -2115,7 +2115,7 @@ static void project_bucket_clip_face( int inside_face_flag = 0; int flip; bool collinear = false; - + float bucket_bounds_ss[4][2]; /* detect pathological case where face the three vertices are almost collinear in screen space. @@ -2126,12 +2126,12 @@ static void project_bucket_clip_face( { collinear = true; } - + /* get the UV space bounding box */ inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v1coSS); inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v2coSS) << 1; inside_bucket_flag |= BLI_rctf_isect_pt_v(bucket_bounds, v3coSS) << 2; - + if (inside_bucket_flag == ISECT_ALL3) { /* is_flip_object is used here because we use the face winding */ flip = (((line_point_side_v2(v1coSS, v2coSS, v3coSS) > 0.0f) != is_flip_object) != @@ -2148,20 +2148,20 @@ static void project_bucket_clip_face( copy_v2_v2(bucket_bounds_uv[0], uv1co); copy_v2_v2(bucket_bounds_uv[1], uv2co); copy_v2_v2(bucket_bounds_uv[2], uv3co); - } - + } + *tot = 3; return; } /* handle pathological case here, no need for further intersections below since tringle area is almost zero */ if (collinear) { int flag; - + (*tot) = 0; if (cull) return; - + if (inside_bucket_flag & ISECT_1) { copy_v2_v2(bucket_bounds_uv[*tot], uv1co); (*tot)++; } flag = inside_bucket_flag & (ISECT_1 | ISECT_2); @@ -2169,9 +2169,9 @@ static void project_bucket_clip_face( if (line_rect_clip(bucket_bounds, v1coSS, v2coSS, uv1co, uv2co, bucket_bounds_uv[*tot], is_ortho)) (*tot)++; } - + if (inside_bucket_flag & ISECT_2) { copy_v2_v2(bucket_bounds_uv[*tot], uv2co); (*tot)++; } - + flag = inside_bucket_flag & (ISECT_2 | ISECT_3); if (flag && flag != (ISECT_2 | ISECT_3)) { if (line_rect_clip(bucket_bounds, v2coSS, v3coSS, uv2co, uv3co, bucket_bounds_uv[*tot], is_ortho)) @@ -2185,7 +2185,7 @@ static void project_bucket_clip_face( if (line_rect_clip(bucket_bounds, v3coSS, v1coSS, uv3co, uv1co, bucket_bounds_uv[*tot], is_ortho)) (*tot)++; } - + if ((*tot) < 3) { /* no intersections to speak of, but more probable is that all face is just outside the * rectangle and culled due to float precision issues. Since above tests have failed, @@ -2350,7 +2350,7 @@ static void project_bucket_clip_face( (*tot)--; } } - + /* its possible there is only a few left after remove doubles */ if ((*tot) < 3) { // printf("removed too many doubles B\n"); @@ -2991,7 +2991,7 @@ static bool project_bucket_face_isect(ProjPaintState *ps, int bucket_x, int buck int fidx; project_bucket_bounds(ps, bucket_x, bucket_y, &bucket_bounds); - + /* Is one of the faces verts in the bucket bounds? */ fidx = 2; @@ -3500,7 +3500,7 @@ static void proj_paint_layer_clone_init( /* get active instead */ mloopuv_clone_base = CustomData_get_layer(&ps->dm->loopData, CD_MLOOPUV); } - + } memset(layer_clone, 0, sizeof(*layer_clone)); @@ -3526,7 +3526,7 @@ static bool project_paint_clone_face_skip( if (ps->do_material_slots) { if (lc->slot_clone != lc->slot_last_clone) { - if (!slot->uvname || + if (!slot->uvname || !(lc->mloopuv_clone_base = CustomData_get_layer_named( &ps->dm->loopData, CD_MLOOPUV, lc->slot_clone->uvname))) @@ -3720,7 +3720,7 @@ static void project_paint_prepare_all_faces( ps->dm_mloopuv[lt->poly] = mloopuv_base; continue; } - + tpage = slot->ima; } } @@ -4412,7 +4412,7 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, con if (ps->is_texbrush) mul_v3_v3(rgba, texrgb); - + mul_v3_fl(rgba, mask); rgba[3] = mask; @@ -4621,7 +4621,7 @@ static void *do_projectpaint_thread(void *ph_v) projPixel->newColor.ch, ps->blend); } } - + if (lock_alpha) { if (is_floatbuf) { /* slightly more involved case since floats are in premultiplied space we need @@ -4699,7 +4699,7 @@ static void *do_projectpaint_thread(void *ph_v) /* masking to keep brush contribution to a pixel limited. note we do not do * a simple max(mask, mask_accum), as this is very sensitive to spacing and * gives poor results for strokes crossing themselves. - * + * * Instead we use a formula that adds up but approaches brush_alpha slowly * and never exceeds it, which gives nice smooth results. */ float mask_accum = *projPixel->mask_accum; @@ -4932,14 +4932,14 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po touch_any = 1; } } - + /* calculate pivot for rotation around seletion if needed */ if (U.uiflag & USER_ORBIT_SELECTION) { float w[3]; int tri_index; - + tri_index = project_paint_PickFace(ps, pos, w); - + if (tri_index != -1) { const MLoopTri *lt = &ps->dm_mlooptri[tri_index]; const int lt_vtri[3] = { PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt) }; @@ -4952,14 +4952,14 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po ps->dm_mvert[lt_vtri[1]].co, ps->dm_mvert[lt_vtri[2]].co, w); - + ups->average_stroke_counter++; mul_m4_v3(ps->obmat, world); add_v3_v3(ups->average_stroke_accum, world); ups->last_stroke_valid = true; } } - + return touch_any; } @@ -5095,9 +5095,9 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int ps->do_material_slots = (settings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL); ps->stencil_ima = settings->imapaint.stencil; - ps->canvas_ima = (!ps->do_material_slots) ? + ps->canvas_ima = (!ps->do_material_slots) ? settings->imapaint.canvas : NULL; - ps->clone_ima = (!ps->do_material_slots) ? + ps->clone_ima = (!ps->do_material_slots) ? settings->imapaint.clone : NULL; ps->do_mask_cavity = (settings->imapaint.paint.flags & PAINT_USE_CAVITY_MASK) ? true : false; @@ -5329,7 +5329,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) if (!BKE_paint_proj_mesh_data_check(scene, ob, &uvs, &mat, &tex, NULL)) { BKE_paint_data_warning(op->reports, uvs, mat, tex, true); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); - return OPERATOR_CANCELLED; + return OPERATOR_CANCELLED; } project_state_init(C, ob, &ps, BRUSH_STROKE_NORMAL); @@ -5528,7 +5528,7 @@ void PAINT_OT_image_from_view(wmOperatorType *ot) void BKE_paint_data_warning(struct ReportList *reports, bool uvs, bool mat, bool tex, bool stencil) { - BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!", + BKE_reportf(reports, RPT_WARNING, "Missing%s%s%s%s detected!", !uvs ? " UVs," : "", !mat ? " Materials," : "", !tex ? " Textures," : "", @@ -5549,7 +5549,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m bool hasuvs = true; imapaint->missing_data = 0; - + BLI_assert(ob->type == OB_MESH); if (imapaint->mode == IMAGEPAINT_MODE_MATERIAL) { @@ -5563,16 +5563,16 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m int i; hasmat = false; hastex = false; - + for (i = 1; i < ob->totcol + 1; i++) { Material *ma = give_current_material(ob, i); - + if (ma) { hasmat = true; if (!ma->texpaintslot) { /* refresh here just in case */ BKE_texpaint_slot_refresh_cache(scene, ma); - + /* if still no slots, we have to add */ if (ma->texpaintslot) { hastex = true; @@ -5592,7 +5592,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m hastex = false; } } - + me = BKE_mesh_from_object(ob); layernum = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); @@ -5613,7 +5613,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m if (!hasmat) imapaint->missing_data |= IMAGEPAINT_MISSING_MATERIAL; if (!hastex) imapaint->missing_data |= IMAGEPAINT_MISSING_TEX; if (!hasstencil) imapaint->missing_data |= IMAGEPAINT_MISSING_STENCIL; - + if (uvs) { *uvs = hasuvs; } @@ -5626,7 +5626,7 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m if (stencil) { *stencil = hasstencil; } - + return hasuvs && hasmat && hastex && hasstencil; } @@ -5672,7 +5672,7 @@ static Image *proj_paint_image_create(wmOperator *op, Main *bmain) } ima = BKE_image_add_generated(bmain, width, height, imagename, alpha ? 32 : 24, use_float, gen_type, color, false); - + return ima; } @@ -5700,17 +5700,17 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) ED_node_shader_default(C, &ma->id); ntree = ma->nodetree; } - + ma->use_nodes = true; - + /* try to add an image node */ imanode = nodeAddStaticNode(C, ntree, SH_NODE_TEX_IMAGE); - + ima = proj_paint_image_create(op, bmain); imanode->id = &ima->id; - + nodeSetActive(ntree, imanode); - + ntreeUpdateTree(CTX_data_main(C), ntree); } else { @@ -5738,20 +5738,20 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_TEXTURE | NA_ADDED, mtex->tex); } } - + if (ima) { BKE_texpaint_slot_refresh_cache(scene, ma); BKE_image_signal(ima, NULL, IMA_SIGNAL_USER_NEW_IMAGE); WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima); DAG_id_tag_update(&ma->id, 0); ED_area_tag_redraw(CTX_wm_area(C)); - + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - + return true; } } - + return false; } @@ -5779,7 +5779,7 @@ static int texture_paint_add_texture_paint_slot_invoke(bContext *C, wmOperator * /* no material found, just assign to first slot */ assign_material(bmain, ob, ma, ob->actcol, BKE_MAT_ASSIGN_USERPREF); } - + type = RNA_enum_from_value(layer_type_items, type); /* get the name of the texture layer type */ @@ -5837,28 +5837,28 @@ static int texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator Material *ma; bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene); TexPaintSlot *slot; - + /* not supported for node-based engines */ if (!ob || !is_bi) return OPERATOR_CANCELLED; - + ma = give_current_material(ob, ob->actcol); - + if (!ma->texpaintslot || ma->use_nodes) return OPERATOR_CANCELLED; - + slot = ma->texpaintslot + ma->paint_active_slot; - + if (ma->mtex[slot->index]->tex) { id_us_min(&ma->mtex[slot->index]->tex->id); - + if (ma->mtex[slot->index]->tex->ima) { id_us_min(&ma->mtex[slot->index]->tex->ima->id); } } MEM_freeN(ma->mtex[slot->index]); ma->mtex[slot->index] = NULL; - + BKE_texpaint_slot_refresh_cache(scene, ma); DAG_id_tag_update(&ma->id, 0); WM_event_add_notifier(C, NC_MATERIAL, ma); @@ -5917,7 +5917,7 @@ static int add_simple_uvs_exec(bContext *C, wmOperator *UNUSED(op)) scene->toolsettings->uv_flag |= UV_SYNC_SELECTION; BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - + DAG_id_tag_update(ob->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, scene); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 572d969dcca..f03c119a09e 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -87,10 +87,10 @@ static void BRUSH_OT_add(wmOperatorType *ot) ot->name = "Add Brush"; ot->description = "Add brush by mode type"; ot->idname = "BRUSH_OT_add"; - + /* api callbacks */ ot->exec = brush_add_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -144,10 +144,10 @@ static void BRUSH_OT_scale_size(wmOperatorType *ot) ot->name = "Scale Sculpt/Paint Brush Size"; ot->description = "Change brush size by a scalar"; ot->idname = "BRUSH_OT_scale_size"; - + /* api callbacks */ ot->exec = brush_scale_size_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -285,10 +285,10 @@ static void BRUSH_OT_reset(wmOperatorType *ot) ot->name = "Reset Brush"; ot->description = "Return brush to defaults based on current tool"; ot->idname = "BRUSH_OT_reset"; - + /* api callbacks */ ot->exec = brush_reset_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -353,7 +353,7 @@ static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool, /* store the previously-selected brush */ if (br) br->toggle_brush = brush_orig; - + return br; } else if (brush_orig->toggle_brush) { @@ -502,7 +502,7 @@ static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode, keymap_type, KM_PRESS, keymap_modifier, 0); RNA_enum_set(kmi->ptr, "paint_mode", paint_mode); - + switch (paint_mode) { case OB_MODE_SCULPT: RNA_enum_set(kmi->ptr, "sculpt_tool", tool); @@ -914,7 +914,7 @@ static int stencil_reset_transform_exec(bContext *C, wmOperator *op) if (!br) return OPERATOR_CANCELLED; - + if (do_mask) { br->mask_stencil_pos[0] = 256; br->mask_stencil_pos[1] = 256; @@ -1200,7 +1200,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p static void paint_partial_visibility_keys(wmKeyMap *keymap) { wmKeyMapItem *kmi; - + /* Partial visibility */ kmi = WM_keymap_add_item(keymap, "PAINT_OT_hide_show", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", PARTIALVIS_SHOW); @@ -1246,7 +1246,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) wmKeyMap *keymap; wmKeyMapItem *kmi; int i; - + keymap = WM_keymap_find(keyconf, "Paint Curve", 0, 0); keymap->poll = paint_curve_poll; @@ -1285,7 +1285,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCULPT_OT_dynamic_topology_toggle", DKEY, KM_PRESS, KM_CTRL, 0); /* Dynamic-topology detail size - * + * * This should be improved further, perhaps by showing a triangle * grid rather than brush alpha */ kmi = WM_keymap_add_item(keymap, "SCULPT_OT_set_detail_size", DKEY, KM_PRESS, KM_SHIFT, 0); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index e6a9fd9adf8..afd24f0fe90 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -125,7 +125,7 @@ typedef struct PaintStroke { float zoom_2d; int pen_flip; - + /* line constraint */ bool constrain_line; float constrained_pos[2]; @@ -711,10 +711,10 @@ PaintStroke *paint_stroke_new(bContext *C, /* initialize here */ ups->overlap_factor = 1.0; ups->stroke_active = true; - + zero_v3(ups->average_stroke_accum); ups->average_stroke_counter = 0; - + /* initialize here to avoid initialization conflict with threaded strokes */ curvemapping_initialize(br->curve); if (p->flags & PAINT_USE_CAVITY_MASK) @@ -904,11 +904,11 @@ static void paint_stroke_sample_average(const PaintStroke *stroke, PaintSample *average) { int i; - + memset(average, 0, sizeof(*average)); BLI_assert(stroke->num_samples > 0); - + for (i = 0; i < stroke->num_samples; i++) { add_v2_v2(average->mouse, stroke->samples[i].mouse); average->pressure += stroke->samples[i].pressure; @@ -1072,17 +1072,17 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2]) if (stroke->constrain_line) { float line[2]; float angle, len, res; - + sub_v2_v2v2(line, mouse, stroke->last_mouse_position); angle = atan2f(line[1], line[0]); len = len_v2(line); - + /* divide angle by PI/4 */ angle = 4.0f * angle / (float)M_PI; - + /* now take residue */ res = angle - floorf(angle); - + /* residue decides how close we are at a certain angle */ if (res <= 0.5f) { angle = floorf(angle) * (float)M_PI_4; @@ -1090,7 +1090,7 @@ static void paint_stroke_line_constrain(PaintStroke *stroke, float mouse[2]) else { angle = (floorf(angle) + 1.0f) * (float)M_PI_4; } - + mouse[0] = stroke->constrained_pos[0] = len * cosf(angle) + stroke->last_mouse_position[0]; mouse[1] = stroke->constrained_pos[1] = len * sinf(angle) + stroke->last_mouse_position[1]; } @@ -1185,12 +1185,12 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) else if (br->flag & BRUSH_LINE) { if (event->alt) stroke->constrain_line = true; - else + else stroke->constrain_line = false; copy_v2_fl2(mouse, event->mval[0], event->mval[1]); paint_stroke_line_constrain(stroke, mouse); - + if (stroke->stroke_started && (first_modal || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)))) { if ((br->mtex.brush_angle_mode & MTEX_ANGLE_RAKE) || (br->mask_mtex.brush_angle_mode & MTEX_ANGLE_RAKE)) { copy_v2_v2(stroke->ups->last_rake, stroke->last_mouse_position); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 70fd57830c0..77c9dcf8ac6 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -222,10 +222,10 @@ void paint_stroke_operator_properties(wmOperatorType *ot) prop = RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, + RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Stroke Mode", "Action taken when a paint stroke is made"); - + } /* 3D Paint */ @@ -436,7 +436,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr CLAMP(x, 0, ar->winx); CLAMP(y, 0, ar->winy); - + if (use_palette) { if (!palette) { palette = BKE_palette_add(CTX_data_main(C), "Palette"); @@ -471,12 +471,12 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) { Image *image; - - if (use_material) + + if (use_material) image = imapaint_face_image(ob, me, faceindex); else image = imapaint->canvas; - + if (image) { ImBuf *ibuf = BKE_image_acquire_ibuf(image, NULL, NULL); if (ibuf && ibuf->rect) { @@ -484,16 +484,16 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr float u, v; imapaint_pick_uv(scene, ob, faceindex, mval, uv); sample_success = true; - + u = fmodf(uv[0], 1.0f); v = fmodf(uv[1], 1.0f); - + if (u < 0.0f) u += 1.0f; if (v < 0.0f) v += 1.0f; - + u = u * ibuf->x; v = v * ibuf->y; - + if (ibuf->rect_float) { float rgba_f[4]; if (U.gameflags & USER_DISABLE_MIPMAP) @@ -525,7 +525,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr } } } - + BKE_image_release_ibuf(image, ibuf, NULL); } } @@ -547,7 +547,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr glReadBuffer(GL_BACK); } cp = (unsigned char *)&col; - + if (use_palette) { rgb_uchar_to_float(color->rgb, cp); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 4b2eb0fdd30..a496c4cb01d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2552,7 +2552,7 @@ static float tex_color_alpha_ubyte( } static void do_vpaint_brush_draw_task_cb_ex( - void *__restrict userdata, + void *__restrict userdata, const int n, const ParallelRangeTLS *__restrict UNUSED(tls)) { diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c index 4d70d82d5c6..197b16ffe6e 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_utils.c @@ -308,4 +308,4 @@ float ED_wpaint_blend_tool( } } -/** \} */ \ No newline at end of file +/** \} */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 605d72e1e20..ca4ad39d14e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -632,7 +632,7 @@ bool sculpt_brush_test_cube(SculptBrushTest *test, const float co[3], float loca if (local_co[0] <= side && local_co[1] <= side && local_co[2] <= side) { float p = 4.0f; - + test->dist = ((powf(local_co[0], p) + powf(local_co[1], p) + powf(local_co[2], p)) / powf(side, p)); @@ -731,7 +731,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, { float mirror[3]; float distsq; - + /* flip_v3_v3(mirror, cache->traced_location, symm); */ flip_v3_v3(mirror, cache->true_location, symm); @@ -1120,7 +1120,7 @@ static float brush_strength( case SCULPT_TOOL_DRAW: case SCULPT_TOOL_LAYER: return alpha * flip * pressure * overlap * feather; - + case SCULPT_TOOL_MASK: overlap = (1 + overlap) / 2; switch ((BrushMaskTool)brush->mask_tool) { @@ -1153,7 +1153,7 @@ static float brush_strength( } else { /* reduce strength for DEEPEN, PEAKS, and CONTRAST */ - return 0.5f * alpha * flip * pressure * overlap * feather; + return 0.5f * alpha * flip * pressure * overlap * feather; } case SCULPT_TOOL_SMOOTH: @@ -1210,7 +1210,7 @@ float tex_strength(SculptSession *ss, const Brush *br, avg = 1; } else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) { - /* Get strength by feeding the vertex + /* Get strength by feeding the vertex * location directly into a texture */ avg = BKE_brush_sample_tex_3D(scene, br, point, rgba, 0, ss->tex_pool); } @@ -1220,7 +1220,7 @@ float tex_strength(SculptSession *ss, const Brush *br, /* if the active area is being applied for symmetry, flip it * across the symmetry axis and rotate it back to the original - * position in order to project it. This insures that the + * position in order to project it. This insures that the * brush texture will be oriented correctly. */ flip_v3_v3(symm_point, point, cache->mirror_symmetry_pass); @@ -1280,16 +1280,16 @@ bool sculpt_search_sphere_cb(PBVHNode *node, void *data_v) BKE_pbvh_node_get_original_BB(node, bb_min, bb_max); else BKE_pbvh_node_get_BB(node, bb_min, bb_max); - + for (i = 0; i < 3; ++i) { if (bb_min[i] > center[i]) nearest[i] = bb_min[i]; else if (bb_max[i] < center[i]) nearest[i] = bb_max[i]; else - nearest[i] = center[i]; + nearest[i] = center[i]; } - + sub_v3_v3v3(t, center, nearest); return len_squared_v3(t) < data->radius_squared; @@ -1400,7 +1400,7 @@ static void update_sculpt_normal(Sculpt *sd, Object *ob, { const Brush *brush = BKE_paint_brush(&sd->paint); StrokeCache *cache = ob->sculpt->cache; - + if (cache->mirror_symmetry_pass == 0 && cache->radial_symmetry_pass == 0 && (cache->first_time || !(brush->flag & BRUSH_ORIGINAL_NORMAL))) @@ -2042,7 +2042,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) { SculptSession *ss = ob->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); - + switch ((BrushMaskTool)brush->mask_tool) { case BRUSH_MASK_DRAW: do_mask_brush_draw(sd, ob, nodes, totnode); @@ -2189,7 +2189,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_v3_v3fl(offset, ss->cache->sculpt_normal_symm, ss->cache->radius); mul_v3_v3(offset, ss->cache->scale); mul_v3_fl(offset, bstrength); - + /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor; brush_alpha = BKE_brush_alpha_get(scene, brush); @@ -4037,7 +4037,7 @@ static void do_symmetrical_brush_actions( cache->bstrength = brush_strength(sd, cache, feather, ups); cache->symmetry = symm; - /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ + /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ for (i = 0; i <= symm; ++i) { if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { cache->mirror_symmetry_pass = i; @@ -4172,14 +4172,14 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss) (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData *)md; - + if (mmd->flag & MOD_MIR_CLIPPING) { /* check each axis for mirroring */ for (i = 0; i < 3; ++i) { if (mmd->flag & (MOD_MIR_AXIS_X << i)) { /* enable sculpt clipping */ ss->cache->flag |= CLIP_X << i; - + /* update the clip tolerance */ if (mmd->tolerance > ss->cache->clip_tolerance[i]) @@ -4268,7 +4268,7 @@ static void sculpt_update_cache_invariants( Paint *p = &sd->paint; Brush *br; int size = BKE_brush_size_get(scene, brush); - + BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name)); @@ -4364,7 +4364,7 @@ static void sculpt_update_cache_invariants( #define PIXEL_INPUT_THRESHHOLD 5 if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) cache->dial = BLI_dial_initialize(cache->initial_mouse, PIXEL_INPUT_THRESHHOLD); - + #undef PIXEL_INPUT_THRESHHOLD } @@ -4943,7 +4943,7 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *UNUSED(st Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; const Brush *brush = BKE_paint_brush(&sd->paint); - + sculpt_stroke_modifiers_check(C, ob, brush); sculpt_update_cache_variants(C, sd, ob, itemptr); sculpt_restore_mesh(sd, ob); @@ -5042,7 +5042,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str sculpt_undo_push_end(); BKE_pbvh_update(ss->pbvh, PBVH_UpdateOriginalBB, NULL); - + if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) BKE_pbvh_bmesh_after_stroke(ss->pbvh); @@ -5086,7 +5086,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent paint_stroke_data_free(op); return OPERATOR_PASS_THROUGH; } - + if ((retval = op->type->modal(C, op, event)) == OPERATOR_FINISHED) { paint_stroke_data_free(op); return OPERATOR_FINISHED; @@ -5096,7 +5096,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, const wmEvent OPERATOR_RETVAL_CHECK(retval); BLI_assert(retval == OPERATOR_RUNNING_MODAL); - + return OPERATOR_RUNNING_MODAL; } @@ -5143,7 +5143,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) ot->name = "Sculpt"; ot->idname = "SCULPT_OT_brush_stroke"; ot->description = "Sculpt a stroke into the geometry"; - + /* api callbacks */ ot->invoke = sculpt_brush_stroke_invoke; ot->modal = paint_stroke_modal; @@ -5160,7 +5160,7 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) RNA_def_boolean(ot->srna, "ignore_background_click", 0, "Ignore Background Click", - "Clicks on the background do not start the stroke"); + "Clicks on the background do not start the stroke"); } /**** Reset the copy of the mesh that is being sculpted on (currently just for the layer brush) ****/ @@ -5184,11 +5184,11 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) ot->name = "Set Persistent Base"; ot->idname = "SCULPT_OT_set_persistent_base"; ot->description = "Reset the copy of the mesh that is being sculpted on"; - + /* api callbacks */ ot->exec = sculpt_set_persistent_base_exec; ot->poll = sculpt_mode_poll; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5290,7 +5290,7 @@ void sculpt_dynamic_topology_enable_ex( /* Enable dynamic topology */ me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY; - + /* Enable logging for undo/redo */ ss->bm_log = BM_log_create(ss->bm); @@ -5510,12 +5510,12 @@ static void SCULPT_OT_dynamic_topology_toggle(wmOperatorType *ot) ot->name = "Dynamic Topology Toggle"; ot->idname = "SCULPT_OT_dynamic_topology_toggle"; ot->description = "Dynamic topology alters the mesh topology while sculpting"; - + /* api callbacks */ ot->invoke = sculpt_dynamic_topology_toggle_invoke; ot->exec = sculpt_dynamic_topology_toggle_exec; ot->poll = sculpt_mode_poll; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5548,11 +5548,11 @@ static void SCULPT_OT_optimize(wmOperatorType *ot) ot->name = "Optimize"; ot->idname = "SCULPT_OT_optimize"; ot->description = "Recalculate the sculpt BVH to improve performance"; - + /* api callbacks */ ot->exec = sculpt_optimize_exec; ot->poll = sculpt_and_dynamic_topology_poll; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5602,7 +5602,7 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot) ot->name = "Symmetrize"; ot->idname = "SCULPT_OT_symmetrize"; ot->description = "Symmetrize the topology modifications"; - + /* api callbacks */ ot->exec = sculpt_symmetrize_exec; ot->poll = sculpt_and_dynamic_topology_poll; @@ -5745,7 +5745,7 @@ void ED_object_sculptmode_exit_ex( if (mmd) { multires_force_update(ob); } - + /* Not needed for now. */ #if 0 const int flush_recalc = ed_object_sculptmode_flush_recalc_flag(scene, ob, mmd); @@ -5819,11 +5819,11 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) ot->name = "Sculpt Mode"; ot->idname = "SCULPT_OT_sculptmode_toggle"; ot->description = "Toggle sculpt mode in 3D view"; - + /* api callbacks */ ot->exec = sculpt_mode_toggle_exec; ot->poll = ED_operator_object_active_editable_mesh; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index e46760258e1..1c94c1d9198 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -28,7 +28,7 @@ /** \file blender/editors/sculpt_paint/sculpt_intern.h * \ingroup edsculpt */ - + #ifndef __SCULPT_INTERN_H__ #define __SCULPT_INTERN_H__ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index e90d2b58c0c..cd03c3ec7e2 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -143,7 +143,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN SculptSession *ss = ob->sculpt; MVert *mvert; int *index; - + if (unode->maxvert) { /* regular mesh restore */ @@ -260,7 +260,7 @@ static bool sculpt_undo_restore_hidden( if (unode->maxvert) { MVert *mvert = ss->mvert; - + for (i = 0; i < unode->totvert; i++) { MVert *v = &mvert[unode->index[i]]; if ((BLI_BITMAP_TEST(unode->vert_hidden, i) != 0) != ((v->flag & ME_HIDE) != 0)) { @@ -272,12 +272,12 @@ static bool sculpt_undo_restore_hidden( } else if (unode->maxgrid && dm->getGridData) { BLI_bitmap **grid_hidden = dm->getGridHidden(dm); - + for (i = 0; i < unode->totgrid; i++) { SWAP(BLI_bitmap *, unode->grid_hidden[i], grid_hidden[unode->grids[i]]); - + } } @@ -291,7 +291,7 @@ static bool sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNod MVert *mvert; float *vmask; int *index, i, j; - + if (unode->maxvert) { /* regular mesh restore */ @@ -672,10 +672,10 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, NULL); - + unode->grid_hidden = MEM_mapallocN(sizeof(*unode->grid_hidden) * totgrid, "unode->grid_hidden"); - + for (i = 0; i < totgrid; i++) { if (grid_hidden[grid_indices[i]]) unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]); @@ -692,7 +692,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( SculptUndoNode *unode; SculptSession *ss = ob->sculpt; int totvert, allvert, totgrid, maxgrid, gridsize, *grids; - + unode = MEM_callocN(sizeof(SculptUndoNode), "SculptUndoNode"); BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname)); unode->type = type; @@ -707,7 +707,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( } else maxgrid = 0; - + /* we will use this while sculpting, is mapalloc slow to access then? */ /* general TODO, fix count_alloc */ @@ -723,7 +723,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode); else unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden"); - + break; case SCULPT_UNDO_MASK: unode->mask = MEM_mapallocN(sizeof(float) * allvert, "SculptUndoNode.mask"); @@ -737,7 +737,7 @@ static SculptUndoNode *sculpt_undo_alloc_node( BLI_assert(!"Dynamic topology should've already been handled"); break; } - + BLI_addtail(&usculpt->nodes, unode); if (maxgrid) { @@ -789,7 +789,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) const int *vert_indices; int allvert; int i; - + BKE_pbvh_node_num_verts(pbvh, node, NULL, &allvert); BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); for (i = 0; i < allvert; i++) { @@ -928,7 +928,7 @@ SculptUndoNode *sculpt_undo_push_node( } unode = sculpt_undo_alloc_node(ob, node, type); - + BLI_thread_unlock(LOCK_CUSTOM1); /* copy threaded, hopefully this is the performance critical part */ diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index e39750227c0..e93a68b9350 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -137,7 +137,7 @@ typedef struct UvSculptData { /* uvsmooth Paint for fast reference */ Paint *uvsculpt; - + /* tool to use. duplicating here to change if modifier keys are pressed */ char tool; diff --git a/source/blender/editors/space_action/action_buttons.c b/source/blender/editors/space_action/action_buttons.c index 003fd3b5bcf..b16d0543d0e 100644 --- a/source/blender/editors/space_action/action_buttons.c +++ b/source/blender/editors/space_action/action_buttons.c @@ -76,9 +76,9 @@ void action_buttons_register(ARegionType *UNUSED(art)) { #if 0 PanelType *pt; - + // TODO: AnimData / Actions List - + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties"); strcpy(pt->idname, "ACTION_PT_properties"); strcpy(pt->label, N_("Active F-Curve")); @@ -86,7 +86,7 @@ void action_buttons_register(ARegionType *UNUSED(art)) pt->draw = action_anim_panel_properties; pt->poll = action_anim_panel_poll; BLI_addtail(&art->paneltypes, pt); - + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel properties"); strcpy(pt->idname, "ACTION_PT_key_properties"); strcpy(pt->label, N_("Active Keyframe")); @@ -94,7 +94,7 @@ void action_buttons_register(ARegionType *UNUSED(art)) pt->draw = action_anim_panel_key_properties; pt->poll = action_anim_panel_poll; BLI_addtail(&art->paneltypes, pt); - + pt = MEM_callocN(sizeof(PanelType), "spacetype action panel modifiers"); strcpy(pt->idname, "ACTION_PT_modifiers"); strcpy(pt->label, N_("Modifiers")); @@ -109,7 +109,7 @@ static int action_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = action_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -121,7 +121,7 @@ void ACTION_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->idname = "ACTION_OT_properties"; ot->description = "Toggle the properties region visibility"; - + ot->exec = action_properties_toggle_exec; ot->poll = ED_operator_action_active; diff --git a/source/blender/editors/space_action/action_data.c b/source/blender/editors/space_action/action_data.c index 2bfe756f76e..74c9f2f8cfb 100644 --- a/source/blender/editors/space_action/action_data.c +++ b/source/blender/editors/space_action/action_data.c @@ -87,7 +87,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C) SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); Object *ob = CTX_data_active_object(C); AnimData *adt = NULL; - + /* Get AnimData block to use */ if (saction->mode == SACTCONT_ACTION) { /* Currently, "Action Editor" means object-level only... */ @@ -101,7 +101,7 @@ AnimData *ED_actedit_animdata_from_context(bContext *C) adt = key->adt; } } - + return adt; } @@ -112,7 +112,7 @@ static bAction *action_create_new(bContext *C, bAction *oldact) { ScrArea *sa = CTX_wm_area(C); bAction *action; - + /* create action - the way to do this depends on whether we've got an * existing one there already, in which case we make a copy of it * (which is useful for "versioning" actions within the same file) @@ -125,24 +125,24 @@ static bAction *action_create_new(bContext *C, bAction *oldact) /* just make a new (empty) action */ action = BKE_action_add(CTX_data_main(C), "Action"); } - - /* when creating new ID blocks, there is already 1 user (as for all new datablocks), + + /* when creating new ID blocks, there is already 1 user (as for all new datablocks), * but the RNA pointer code will assign all the proper users instead, so we compensate * for that here */ BLI_assert(action->id.us == 1); id_us_min(&action->id); - + /* set ID-Root type */ if (sa->spacetype == SPACE_ACTION) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - + if (saction->mode == SACTCONT_SHAPEKEY) action->idroot = ID_KE; else action->idroot = ID_OB; } - + return action; } @@ -151,17 +151,17 @@ static void actedit_change_action(bContext *C, bAction *act) { bScreen *screen = CTX_wm_screen(C); SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); - + PointerRNA ptr, idptr; PropertyRNA *prop; - + /* create RNA pointers and get the property */ RNA_pointer_create(&screen->id, &RNA_SpaceDopeSheetEditor, saction, &ptr); prop = RNA_struct_find_property(&ptr, "action"); - + /* NOTE: act may be NULL here, so better to just use a cast here */ RNA_id_pointer_create((ID *)act, &idptr); - + /* set the new pointer, and force a refresh */ RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); @@ -178,13 +178,13 @@ static void actedit_change_action(bContext *C, bAction *act) static int action_new_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - + /* Check tweakmode is off (as you don't want to be tampering with the action in that case) */ - /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */ + /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */ if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); Object *ob = CTX_data_active_object(C); - + /* For now, actions are only for the active object, and on object and shapekey levels... */ if (saction->mode == SACTCONT_ACTION) { /* XXX: This assumes that actions are assigned to the active object in this mode */ @@ -206,7 +206,7 @@ static int action_new_poll(bContext *C) return true; } } - + /* something failed... */ return false; } @@ -215,18 +215,18 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) { PointerRNA ptr, idptr; PropertyRNA *prop; - + /* hook into UI */ UI_context_active_but_prop_get_templateID(C, &ptr, &prop); - + if (prop) { bAction *action = NULL, *oldact = NULL; AnimData *adt = NULL; PointerRNA oldptr; - + oldptr = RNA_property_pointer_get(&ptr, prop); oldact = (bAction *)oldptr.id.data; - + /* stash the old action to prevent it from being lost */ if (ptr.type == &RNA_AnimData) { adt = ptr.data; @@ -234,7 +234,7 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) else if (ptr.type == &RNA_SpaceDopeSheetEditor) { adt = ED_actedit_animdata_from_context(C); } - + /* Perform stashing operation - But only if there is an action */ if (adt && oldact) { /* stash the action */ @@ -255,10 +255,10 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) //printf("WARNING: Failed to stash %s. It may already exist in the NLA stack though\n", oldact->id.name); } } - + /* create action */ action = action_create_new(C, oldact); - + /* set this new action * NOTE: we can't use actedit_change_action, as this function is also called from the NLA */ @@ -266,24 +266,24 @@ static int action_new_exec(bContext *C, wmOperator *UNUSED(op)) RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); } - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_new(wmOperatorType *ot) { /* identifiers */ ot->name = "New Action"; ot->idname = "ACTION_OT_new"; ot->description = "Create new action"; - + /* api callbacks */ ot->exec = action_new_exec; ot->poll = action_new_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -300,7 +300,7 @@ static int action_pushdown_poll(bContext *C) if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Check for AnimData, Actions, and that tweakmode is off */ if (adt && saction->action) { /* NOTE: We check this for the AnimData block in question and not the global flag, @@ -310,7 +310,7 @@ static int action_pushdown_poll(bContext *C) return true; } } - + /* something failed... */ return false; } @@ -319,7 +319,7 @@ static int action_pushdown_exec(bContext *C, wmOperator *op) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Do the deed... */ if (adt) { /* Perform the pushdown operation @@ -334,13 +334,13 @@ static int action_pushdown_exec(bContext *C, wmOperator *op) /* action can be safely added */ BKE_nla_action_pushdown(adt); } - + /* Stop displaying this action in this editor * NOTE: The editor itself doesn't set a user... */ saction->action = NULL; } - + /* Send notifiers that stuff has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); return OPERATOR_FINISHED; @@ -352,11 +352,11 @@ void ACTION_OT_push_down(wmOperatorType *ot) ot->name = "Push Down Action"; ot->idname = "ACTION_OT_push_down"; ot->description = "Push action down on to the NLA stack as a new strip"; - + /* callbacks */ ot->exec = action_pushdown_exec; ot->poll = action_pushdown_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -367,7 +367,7 @@ static int action_stash_exec(bContext *C, wmOperator *op) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Perform stashing operation */ if (adt) { /* don't do anything if this action is empty... */ @@ -390,12 +390,12 @@ static int action_stash_exec(bContext *C, wmOperator *op) /* action has already been added - simply warn about this, and clear */ BKE_report(op->reports, RPT_ERROR, "Action has already been stashed"); } - + /* clear action refs from editor, and then also the backing data (not necessary) */ actedit_change_action(C, NULL); } } - + /* Send notifiers that stuff has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); return OPERATOR_FINISHED; @@ -407,16 +407,16 @@ void ACTION_OT_stash(wmOperatorType *ot) ot->name = "Stash Action"; ot->idname = "ACTION_OT_stash"; ot->description = "Store this action in the NLA stack as a non-contributing strip for later use"; - + /* callbacks */ ot->exec = action_stash_exec; ot->poll = action_pushdown_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - ot->prop = RNA_def_boolean(ot->srna, "create_new", true, "Create New Action", + ot->prop = RNA_def_boolean(ot->srna, "create_new", true, "Create New Action", "Create a new action once the existing one has been safely stored"); } @@ -430,7 +430,7 @@ static int action_stash_create_poll(bContext *C) { if (ED_operator_action_active(C)) { AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Check tweakmode is off (as you don't want to be tampering with the action in that case) */ /* NOTE: unlike for pushdown, this operator needs to be run when creating an action from nothing... */ if (adt) { @@ -439,19 +439,19 @@ static int action_stash_create_poll(bContext *C) } else { /* There may not be any action/animdata yet, so, just fallback to the global setting - * (which may not be totally valid yet if the action editor was used and things are + * (which may not be totally valid yet if the action editor was used and things are * now in an inconsistent state) */ SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); Scene *scene = CTX_data_scene(C); - + if (!(scene->flag & SCE_NLA_EDIT_ON)) { /* For now, actions are only for the active object, and on object and shapekey levels... */ return ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY); } } } - + /* something failed... */ return false; } @@ -460,7 +460,7 @@ static int action_stash_create_exec(bContext *C, wmOperator *op) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Check for no action... */ if (saction->action == NULL) { /* just create a new action */ @@ -478,10 +478,10 @@ static int action_stash_create_exec(bContext *C, wmOperator *op) /* stash the action */ if (BKE_nla_action_stash(adt)) { bAction *new_action = NULL; - + /* create new action not based on the old one (since the "new" operator already does that) */ new_action = action_create_new(C, NULL); - + /* The stash operation will remove the user already, * so the flushing step later shouldn't double up * the usercount fixes. Hence, we must unset this ref @@ -497,7 +497,7 @@ static int action_stash_create_exec(bContext *C, wmOperator *op) } } } - + /* Send notifiers that stuff has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); return OPERATOR_FINISHED; @@ -509,11 +509,11 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot) ot->name = "Stash Action"; ot->idname = "ACTION_OT_stash_and_create"; ot->description = "Store this action in the NLA stack as a non-contributing strip for later use, and create a new action"; - + /* callbacks */ ot->exec = action_stash_create_exec; ot->poll = action_stash_create_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -533,7 +533,7 @@ void ACTION_OT_stash_and_create(wmOperatorType *ot) void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, ReportList *reports, bool force_delete) { ScrArea *sa = CTX_wm_area(C); - + /* If the old action only has a single user (that it's about to lose), * warn user about it * @@ -545,7 +545,7 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, "Action '%s' will not be saved, create Fake User or Stash in NLA Stack to retain", act->id.name + 2); } - + /* Clear Fake User and remove action stashing strip (if present) */ if (force_delete) { /* Remove stashed strip binding this action to this datablock */ @@ -556,18 +556,18 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, if (adt) { NlaTrack *nlt, *nlt_next; NlaStrip *strip, *nstrip; - + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt_next) { nlt_next = nlt->next; - + if (strstr(nlt->name, DATA_("[Action Stash]"))) { for (strip = nlt->strips.first; strip; strip = nstrip) { nstrip = strip->next; - + if (strip->act == act) { /* Remove this strip, and the track too if it doesn't have anything else */ BKE_nlastrip_free(&nlt->strips, strip); - + if (nlt->strips.first == NULL) { BLI_assert(nstrip == NULL); BKE_nlatrack_free(&adt->nla_tracks, nlt); @@ -577,18 +577,18 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, } } } - + /* Clear Fake User */ id_fake_user_clear(&act->id); } - - /* If in Tweak Mode, don't unlink. Instead, this + + /* If in Tweak Mode, don't unlink. Instead, this * becomes a shortcut to exit Tweak Mode instead */ if ((adt) && (adt->flag & ADT_NLA_EDIT_ON)) { /* Exit Tweak Mode */ BKE_nla_tweakmode_exit(adt); - + /* Flush this to the Action Editor (if that's where this change was initiated) */ if (sa->spacetype == SPACE_ACTION) { actedit_change_action(C, NULL); @@ -604,11 +604,11 @@ void ED_animedit_unlink_action(bContext *C, ID *id, AnimData *adt, bAction *act, /* clear AnimData -> action */ PointerRNA ptr; PropertyRNA *prop; - + /* create AnimData RNA pointers */ RNA_pointer_create(id, &RNA_AnimData, adt, &ptr); prop = RNA_struct_find_property(&ptr, "action"); - + /* clear... */ RNA_property_pointer_set(&ptr, prop, PointerRNA_NULL); RNA_property_update(C, &ptr, prop); @@ -623,12 +623,12 @@ static int action_unlink_poll(bContext *C) if (ED_operator_action_active(C)) { SpaceAction *saction = (SpaceAction *)CTX_wm_space_data(C); AnimData *adt = ED_actedit_animdata_from_context(C); - + /* Only when there's an active action, in the right modes... */ if (saction->action && adt) return true; } - + /* something failed... */ return false; } @@ -637,11 +637,11 @@ static int action_unlink_exec(bContext *C, wmOperator *op) { AnimData *adt = ED_actedit_animdata_from_context(C); bool force_delete = RNA_boolean_get(op->ptr, "force_delete"); - + if (adt && adt->action) { ED_animedit_unlink_action(C, NULL, adt, adt->action, op->reports, force_delete); } - + return OPERATOR_FINISHED; } @@ -655,17 +655,17 @@ static int action_unlink_invoke(bContext *C, wmOperator *op, const wmEvent *evt) void ACTION_OT_unlink(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Unlink Action"; ot->idname = "ACTION_OT_unlink"; ot->description = "Unlink this action from the active action slot (and/or exit Tweak Mode)"; - + /* callbacks */ ot->invoke = action_unlink_invoke; ot->exec = action_unlink_exec; ot->poll = action_unlink_poll; - + /* properties */ prop = RNA_def_boolean(ot->srna, "force_delete", false, "Force Delete", "Clear Fake User and remove " "copy stashed in this data-block's NLA stack"); @@ -679,7 +679,7 @@ void ACTION_OT_unlink(wmOperatorType *ot) static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime) { NlaStrip *strip; - + for (strip = strips->first; strip; strip = strip->next) { /* Can we use this? */ if (IN_RANGE_INCL(ctime, strip->start, strip->end)) { @@ -695,7 +695,7 @@ static NlaStrip *action_layer_get_nlastrip(ListBase *strips, float ctime) return strip; } } - + /* nothing suitable found... */ return NULL; } @@ -709,18 +709,18 @@ static void action_layer_switch_strip(AnimData *adt, * NOTE: We need to manually clear this stuff ourselves, as tweakmode exit doesn't do it */ BKE_nla_tweakmode_exit(adt); - + if (old_strip) { old_strip->flag &= ~(NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT); } if (old_track) { old_track->flag &= ~(NLATRACK_ACTIVE | NLATRACK_SELECTED); } - + /* Make this one the active one instead */ strip->flag |= (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT); nlt->flag |= NLATRACK_ACTIVE; - + /* Copy over "solo" flag - This is useful for stashed actions... */ if (old_track) { if (old_track->flag & NLATRACK_SOLO) { @@ -733,15 +733,15 @@ static void action_layer_switch_strip(AnimData *adt, if (adt->flag & ADT_NLA_EVAL_OFF) { /* disable NLA muting */ adt->flag &= ~ADT_NLA_EVAL_OFF; - + /* mark this track as being solo */ adt->flag |= ADT_NLA_SOLO_TRACK; nlt->flag |= NLATRACK_SOLO; - + // TODO: Needs restpose flushing (when we get reference track) } } - + /* Enter tweakmode again - hopefully we're now "it" */ BKE_nla_tweakmode_enter(adt); BLI_assert(adt->actstrip == strip); @@ -762,7 +762,7 @@ static int action_layer_next_poll(bContext *C) */ if (adt->nla_tracks.last) { NlaTrack *nlt = (NlaTrack *)adt->nla_tracks.last; - + if (nlt->flag & NLATRACK_DISABLED) { /* A disabled track will either be the track itself, * or one of the ones above it. @@ -780,7 +780,7 @@ static int action_layer_next_poll(bContext *C) } } } - + /* something failed... */ return false; } @@ -789,26 +789,26 @@ static int action_layer_next_exec(bContext *C, wmOperator *op) { AnimData *adt = ED_actedit_animdata_from_context(C); NlaTrack *act_track; - + Scene *scene = CTX_data_scene(C); float ctime = BKE_scene_frame_get(scene); - + /* Get active track */ act_track = BKE_nlatrack_find_tweaked(adt); - + if (act_track == NULL) { BKE_report(op->reports, RPT_ERROR, "Could not find current NLA Track"); return OPERATOR_CANCELLED; } - + /* Find next action, and hook it up */ if (act_track->next) { NlaTrack *nlt; - + /* Find next action to use */ for (nlt = act_track->next; nlt; nlt = nlt->next) { NlaStrip *strip = action_layer_get_nlastrip(&nlt->strips, ctime); - + if (strip) { action_layer_switch_strip(adt, act_track, adt->actstrip, nlt, strip); break; @@ -820,7 +820,7 @@ static int action_layer_next_exec(bContext *C, wmOperator *op) * NOTE: This will mean exiting tweakmode... */ BKE_nla_tweakmode_exit(adt); - + /* Deal with solo flags... * Assume: Solo Track == NLA Muting */ @@ -828,14 +828,14 @@ static int action_layer_next_exec(bContext *C, wmOperator *op) /* turn off solo flags on tracks */ act_track->flag &= ~NLATRACK_SOLO; adt->flag &= ~ADT_NLA_SOLO_TRACK; - + /* turn on NLA muting (to keep same effect) */ adt->flag |= ADT_NLA_EVAL_OFF; - + // TODO: Needs restpose flushing (when we get reference track) } } - + /* Update the action that this editor now uses * NOTE: The calls above have already handled the usercount/animdata side of things */ @@ -849,11 +849,11 @@ void ACTION_OT_layer_next(wmOperatorType *ot) ot->name = "Next Layer"; ot->idname = "ACTION_OT_layer_next"; ot->description = "Switch to editing action in animation layer above the current action in the NLA Stack"; - + /* callbacks */ ot->exec = action_layer_next_exec; ot->poll = action_layer_next_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -870,7 +870,7 @@ static int action_layer_prev_poll(bContext *C) /* Tweak Mode: We need to check if there are any tracks below the active one that we can move to */ if (adt->nla_tracks.first) { NlaTrack *nlt = (NlaTrack *)adt->nla_tracks.first; - + /* Since the first disabled track is the track being tweaked/edited, * we can simplify things by only checking the first track: * - If it is disabled, this is the track being tweaked, @@ -890,7 +890,7 @@ static int action_layer_prev_poll(bContext *C) } } } - + /* something failed... */ return false; } @@ -900,19 +900,19 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op) AnimData *adt = ED_actedit_animdata_from_context(C); NlaTrack *act_track; NlaTrack *nlt; - + Scene *scene = CTX_data_scene(C); float ctime = BKE_scene_frame_get(scene); - + /* Sanity Check */ if (adt == NULL) { BKE_report(op->reports, RPT_ERROR, "Internal Error: Could not find Animation Data/NLA Stack to use"); return OPERATOR_CANCELLED; } - + /* Get active track */ act_track = BKE_nlatrack_find_tweaked(adt); - + /* If there is no active track, that means we are using the active action... */ if (act_track) { /* Active Track - Start from the one below it */ @@ -922,17 +922,17 @@ static int action_layer_prev_exec(bContext *C, wmOperator *op) /* Active Action - Use the top-most track */ nlt = adt->nla_tracks.last; } - + /* Find previous action and hook it up */ for (; nlt; nlt = nlt->prev) { NlaStrip *strip = action_layer_get_nlastrip(&nlt->strips, ctime); - + if (strip) { action_layer_switch_strip(adt, act_track, adt->actstrip, nlt, strip); break; } } - + /* Update the action that this editor now uses * NOTE: The calls above have already handled the usercount/animdata side of things */ @@ -946,11 +946,11 @@ void ACTION_OT_layer_prev(wmOperatorType *ot) ot->name = "Previous Layer"; ot->idname = "ACTION_OT_layer_prev"; ot->description = "Switch to editing action in animation layer below the current action in the NLA Stack"; - + /* callbacks */ ot->exec = action_layer_prev_exec; ot->poll = action_layer_prev_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 0764f586de9..a7c94c072a4 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -49,7 +49,7 @@ #include "BKE_context.h" -/* Everything from source (BIF, BDR, BSE) ------------------------------ */ +/* Everything from source (BIF, BDR, BSE) ------------------------------ */ #include "BIF_gl.h" @@ -66,41 +66,41 @@ /* Channel List */ /* left hand part */ -void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) +void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + View2D *v2d = &ar->v2d; float y = 0.0f; size_t items; int height; - + /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac))); if (height > BLI_rcti_size_y(&v2d->mask)) { - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); } /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); - + /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - + y = (float)ACHANNEL_FIRST(ac); - + for (ale = anim_data.first; ale; ale = ale->next) { float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -108,7 +108,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); channel_index++; @@ -117,13 +117,13 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - + y = (float)ACHANNEL_FIRST(ac); - + for (ale = anim_data.first; ale; ale = ale->next) { float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -131,16 +131,16 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); channel_index++; } - + UI_block_end(C, block); UI_block_draw(C, block); } - + /* free tempolary channels */ ANIM_animdata_freelist(&anim_data); } @@ -157,73 +157,73 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + View2D *v2d = &ar->v2d; bDopeSheet *ads = &saction->ads; AnimData *adt = NULL; - + float act_start, act_end, y; size_t items; int height; - + unsigned char col1[3], col2[3]; unsigned char col1a[3], col2a[3]; unsigned char col1b[3], col2b[3]; - + const bool show_group_colors = !(saction->flag & SACTION_NODRAWGCOLORS); - - + + /* get theme colors */ UI_GetThemeColor3ubv(TH_BACK, col2); UI_GetThemeColor3ubv(TH_HILITE, col1); - + UI_GetThemeColor3ubv(TH_GROUP, col2a); UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a); - + UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELOB, col1b); UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELSUBOB, col2b); - + /* set view-mapping rect (only used for x-axis), for NLA-scaling mapping with less calculation */ /* if in NLA there's a strip active, map the view */ if (ac->datatype == ANIMCONT_ACTION) { /* adt = ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */ - + /* start and end of action itself */ calc_action_range(ac->data, &act_start, &act_end, 0); } - + /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + height = ((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac))); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); - + /* first backdrop strips */ y = (float)(-ACHANNEL_HEIGHT(ac)); glEnable(GL_BLEND); - + for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int sel = 0; - + /* determine if any need to draw channel */ if (ale->datatype != ALE_NONE) { /* determine if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); - + if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) { switch (ale->type) { case ANIMTYPE_SUMMARY: @@ -235,16 +235,16 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) case ANIMTYPE_SCENE: case ANIMTYPE_OBJECT: { - if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); - else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); + if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); + else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); break; } case ANIMTYPE_FILLACTD: case ANIMTYPE_DSSKEY: case ANIMTYPE_DSWOR: { - if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); - else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); + if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); + else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); break; } case ANIMTYPE_GROUP: @@ -271,7 +271,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) FCurve *fcu = ale->data; if (show_group_colors && fcu->grp && fcu->grp->customCol) { unsigned char *cp = (unsigned char *)fcu->grp->cs.active; - + if (sel) glColor4ub(cp[0], cp[1], cp[2], 0x65); else glColor4ub(cp[0], cp[1], cp[2], 0x0B); } @@ -288,10 +288,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) break; } } - + /* draw region twice: firstly backdrop, then the current range */ glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF(ac)); - + if (ac->datatype == ANIMCONT_ACTION) glRectf(act_start, (float)y - ACHANNEL_HEIGHT_HALF(ac), act_end, (float)y + ACHANNEL_HEIGHT_HALF(ac)); } @@ -300,7 +300,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF(ac), v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF(ac)); - + /* frames one and higher get a saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44); else glColor4ub(col2[0], col2[1], col2[2], 0x44); @@ -320,23 +320,23 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } } } - + /* Increment the step */ y -= ACHANNEL_STEP(ac); } glDisable(GL_BLEND); - - /* Draw keyframes + + /* Draw keyframes * 1) Only channels that are visible in the Action Editor get drawn/evaluated. * This is to try to optimize this for heavier data sets - * 2) Keyframes which are out of view horizontally are disregarded + * 2) Keyframes which are out of view horizontally are disregarded */ y = (float)(-ACHANNEL_HEIGHT(ac)); - + for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -344,7 +344,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* check if anything to show for this channel */ if (ale->datatype != ALE_NONE) { adt = ANIM_nla_mapping_get(ac, ale); - + /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { case ALE_ALL: @@ -374,17 +374,17 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } } } - + y -= ACHANNEL_STEP(ac); } - + /* free tempolary channels used for drawing */ ANIM_animdata_freelist(&anim_data); /* black line marking 'current frame' for Time-Slide transform mode */ if (saction->flag & SACTION_MOVING) { glColor3f(0.0f, 0.0f, 0.0f); - + glBegin(GL_LINES); glVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD); glVertex2f(saction->timeslide, v2d->cur.ymax); diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 1c15a7c5950..285e9afb8b4 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -95,56 +95,56 @@ static int act_markers_make_local_poll(bContext *C) { SpaceAction *sact = CTX_wm_space_action(C); - + /* 1) */ if (sact == NULL) return 0; - + /* 2) */ if (ELEM(sact->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) == 0) return 0; if (sact->action == NULL) return 0; - + /* 3) */ if (sact->flag & SACTION_POSEMARKERS_SHOW) return 0; - + /* 4) */ return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL; } static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op)) -{ +{ ListBase *markers = ED_context_get_markers(C); - + SpaceAction *sact = CTX_wm_space_action(C); bAction *act = (sact) ? sact->action : NULL; - + TimeMarker *marker, *markern = NULL; - + /* sanity checks */ if (ELEM(NULL, markers, act)) return OPERATOR_CANCELLED; - + /* migrate markers */ for (marker = markers->first; marker; marker = markern) { markern = marker->next; - + /* move if marker is selected */ if (marker->flag & SELECT) { BLI_remlink(markers, marker); BLI_addtail(&act->markers, marker); } } - + /* now enable the "show posemarkers only" setting, so that we can see that something did happen */ sact->flag |= SACTION_POSEMARKERS_SHOW; - + /* notifiers - both sets, as this change affects both */ WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); - + return OPERATOR_FINISHED; } @@ -154,11 +154,11 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot) ot->name = "Make Markers Local"; ot->idname = "ACTION_OT_markers_make_local"; ot->description = "Move selected scene markers to the active Action as local 'pose' markers"; - + /* callbacks */ ot->exec = act_markers_make_local_exec; ot->poll = act_markers_make_local_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -175,17 +175,17 @@ static bool get_keyframe_extents(bAnimContext *ac, float *min, float *max, const bAnimListElem *ale; int filter; bool found = false; - + /* get data to filter, from Action or Dopesheet */ /* XXX: what is sel doing here?! * Commented it, was breaking things (eg. the "auto preview range" tool). */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* set large values to try to override */ *min = 999999999.0f; *max = -999999999.0f; - + /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ @@ -268,7 +268,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) bAnimContext ac; Scene *scene; float min, max; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -276,7 +276,7 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; else scene = ac.scene; - + /* set the range directly */ get_keyframe_extents(&ac, &min, &max, false); scene->r.flag |= SCER_PRV_RANGE; @@ -286,25 +286,25 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) if (scene->r.psfra == scene->r.pefra) { scene->r.pefra = scene->r.psfra + 1; } - + /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); - + return OPERATOR_FINISHED; } - + void ACTION_OT_previewrange_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Auto-Set Preview Range"; ot->idname = "ACTION_OT_previewrange_set"; ot->description = "Set Preview Range based on extents of selected Keyframes"; - + /* api callbacks */ ot->exec = actkeys_previewrange_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -323,31 +323,31 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + short found = 0; /* NOTE: not bool, since we want prioritise individual channels over expanders */ float y; - + /* get all items - we need to do it this way */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through all channels, finding the first one that's selected */ y = (float)ACHANNEL_FIRST(ac); - + for (ale = anim_data.first; ale; ale = ale->next) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + /* must be selected... */ - if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && + if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ *min = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); *max = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* is this high enough priority yet? */ found = acf->channel_role; - + /* only stop our search when we've found an actual channel * - datablock expanders get less priority so that we don't abort prematurely */ @@ -355,14 +355,14 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *min, break; } } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); } - + /* free all temp data */ ANIM_animdata_freelist(&anim_data); - + return (found != 0); } @@ -372,12 +372,12 @@ static int actkeys_viewall(bContext *C, const bool only_sel) View2D *v2d; float extra, min, max; bool found; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; v2d = &ac.ar->v2d; - + /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ found = get_keyframe_extents(&ac, &min, &max, only_sel); @@ -390,7 +390,7 @@ static int actkeys_viewall(bContext *C, const bool only_sel) extra = 0.1f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - + /* set vertical range */ if (only_sel == false) { /* view all -> the summary channel is usually the shows everything, and resides right at the top... */ @@ -401,30 +401,30 @@ static int actkeys_viewall(bContext *C, const bool only_sel) /* locate first selected channel (or the active one), and frame those */ float ymin = v2d->cur.ymin; float ymax = v2d->cur.ymax; - + if (actkeys_channels_get_selected_extents(&ac, &ymin, &ymax)) { /* recenter the view so that this range is in the middle */ float ymid = (ymax - ymin) / 2.0f + ymin; float x_center; - + UI_view2d_center_get(v2d, &x_center, NULL); UI_view2d_center_set(v2d, x_center, ymid); } } - + /* do View2D syncing */ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); - + /* just redraw this view */ ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } /* ......... */ static int actkeys_viewall_exec(bContext *C, wmOperator *UNUSED(op)) -{ +{ /* whole range */ return actkeys_viewall(C, false); } @@ -443,11 +443,11 @@ void ACTION_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "ACTION_OT_view_all"; ot->description = "Reset viewable area to show full keyframe range"; - + /* api callbacks */ ot->exec = actkeys_viewall_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -458,11 +458,11 @@ void ACTION_OT_view_selected(wmOperatorType *ot) ot->name = "View Selected"; ot->idname = "ACTION_OT_view_selected"; ot->description = "Reset viewable area to show selected keyframes range"; - + /* api callbacks */ ot->exec = actkeys_viewsel_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -473,7 +473,7 @@ static int actkeys_view_frame_exec(bContext *C, wmOperator *op) { const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); ANIM_center_frame(C, smooth_viewtx); - + return OPERATOR_FINISHED; } @@ -483,11 +483,11 @@ void ACTION_OT_view_frame(wmOperatorType *ot) ot->name = "View Frame"; ot->idname = "ACTION_OT_view_frame"; ot->description = "Reset viewable area to show range around current frame"; - + /* api callbacks */ ot->exec = actkeys_view_frame_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -499,20 +499,20 @@ void ACTION_OT_view_frame(wmOperatorType *ot) /* NOTE: the backend code for this is shared with the graph editor */ static short copy_action_keys(bAnimContext *ac) -{ +{ ListBase anim_data = {NULL, NULL}; int filter, ok = 0; - + /* clear buffer first */ ANIM_fcurves_copybuf_free(); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* copy keyframes */ ok = copy_animedit_keys(ac, &anim_data); - + /* clean up */ ANIM_animdata_freelist(&anim_data); @@ -522,21 +522,21 @@ static short copy_action_keys(bAnimContext *ac) static short paste_action_keys(bAnimContext *ac, const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip) -{ +{ ListBase anim_data = {NULL, NULL}; int filter, ok = 0; - - /* filter data - * - First time we try to filter more strictly, allowing only selected channels + + /* filter data + * - First time we try to filter more strictly, allowing only selected channels * to allow copying animation between channels * - Second time, we loosen things up if nothing was found the first time, allowing * users to just paste keyframes back into the original curve again [#31670] */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); - + if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* paste keyframes */ ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip); @@ -551,7 +551,7 @@ static short paste_action_keys(bAnimContext *ac, static int actkeys_copy_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -574,17 +574,17 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } } - + return OPERATOR_FINISHED; } - + void ACTION_OT_copy(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy Keyframes"; ot->idname = "ACTION_OT_copy"; ot->description = "Copy selected keyframes to the copy/paste buffer"; - + /* api callbacks */ ot->exec = actkeys_copy_exec; ot->poll = ED_operator_action_active; @@ -600,14 +600,14 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); const bool flipped = RNA_boolean_get(op->ptr, "flipped"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* ac.reports by default will be the global reports list, which won't show warnings */ ac.reports = op->reports; - + /* paste keyframes */ if (ac.datatype == ANIMCONT_GPENCIL) { if (ED_gpencil_anim_copybuf_paste(&ac, offset_mode) == false) { @@ -629,10 +629,10 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_paste(wmOperatorType *ot) { PropertyRNA *prop; @@ -640,15 +640,15 @@ void ACTION_OT_paste(wmOperatorType *ot) ot->name = "Paste Keyframes"; ot->idname = "ACTION_OT_paste"; ot->description = "Paste keyframes from copy/paste buffer for the selected channels, starting on the current frame"; - + /* api callbacks */ // ot->invoke = WM_operator_props_popup; // better wait for action redo panel ot->exec = actkeys_paste_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_enum(ot->srna, "offset", rna_enum_keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); RNA_def_enum(ot->srna, "merge", rna_enum_keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); @@ -667,39 +667,39 @@ static const EnumPropertyItem prop_actkeys_insertkey_types[] = { }; /* this function is responsible for inserting new keyframes */ -static void insert_action_keys(bAnimContext *ac, short mode) +static void insert_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + ReportList *reports = ac->reports; Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; short flag = 0; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); if (mode == 2) filter |= ANIMFILTER_SEL; else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED; - + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* init keyframing flag */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* insert keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; float cfra; - + /* adjust current frame for NLA-scaling */ if (adt) cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + else cfra = (float)CFRA; - + /* read value from property the F-Curve represents, or from the curve only? * - ale->id != NULL: Typically, this means that we have enough info to try resolving the path * - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone, @@ -713,10 +713,10 @@ static void insert_action_keys(bAnimContext *ac, short mode) const float curval = evaluate_fcurve(fcu, cfra); insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0); } - + ale->update |= ANIM_UPDATE_DEFAULT; } - + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); } @@ -727,31 +727,31 @@ static void insert_gpencil_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; eGP_GetFrame_Mode add_frame_mode; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (mode == 2) filter |= ANIMFILTER_SEL; - + ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - + + /* add a copy or a blank frame? */ if (ts->gpencil_flags & GP_TOOL_FLAG_RETAIN_LAST) add_frame_mode = GP_GETFRAME_ADD_COPY; /* XXX: actframe may not be what we want? */ else add_frame_mode = GP_GETFRAME_ADD_NEW; - - + + /* insert gp frames */ for (ale = anim_data.first; ale; ale = ale->next) { bGPDlayer *gpl = (bGPDlayer *)ale->data; BKE_gpencil_layer_getframe(gpl, CFRA, add_frame_mode); } - + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); } @@ -762,19 +762,19 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ac.datatype == ANIMCONT_MASK) { BKE_report(op->reports, RPT_ERROR, "Insert Keyframes is not yet implemented for this mode"); return OPERATOR_CANCELLED; } - + /* what channels to affect? */ mode = RNA_enum_get(op->ptr, "type"); - + /* insert keyframes */ if (ac.datatype == ANIMCONT_GPENCIL) { insert_gpencil_keys(&ac, mode); @@ -785,7 +785,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } @@ -795,15 +795,15 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot) ot->name = "Insert Keyframes"; ot->idname = "ACTION_OT_keyframe_insert"; ot->description = "Insert keyframes for the specified channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_insertkey_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", ""); } @@ -815,14 +815,14 @@ static void duplicate_action_keys(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and delete selected keys */ for (ale = anim_data.first; ale; ale = ale->next) { if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) @@ -846,31 +846,31 @@ static void duplicate_action_keys(bAnimContext *ac) static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* duplicate keyframes */ duplicate_action_keys(&ac); /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_duplicate(wmOperatorType *ot) { /* identifiers */ ot->name = "Duplicate Keyframes"; ot->idname = "ACTION_OT_duplicate"; ot->description = "Make a copy of all selected keyframes"; - + /* api callbacks */ ot->exec = actkeys_duplicate_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -904,26 +904,26 @@ static bool delete_action_keys(bAnimContext *ac) else { FCurve *fcu = (FCurve *)ale->key_data; AnimData *adt = ale->adt; - + /* delete selected keyframes only */ changed = delete_fcurve_keys(fcu); - + /* Only delete curve too if it won't be doing anything anymore */ if ((fcu->totvert == 0) && (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0)) { ANIM_fcurve_delete_from_animdata(ac, adt, fcu); ale->key_data = NULL; } } - + if (changed) { ale->update |= ANIM_UPDATE_DEFAULT; changed_final = true; } } - + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + return changed_final; } @@ -932,33 +932,33 @@ static bool delete_action_keys(bAnimContext *ac) static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* delete keyframes */ if (!delete_action_keys(&ac)) return OPERATOR_CANCELLED; - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Keyframes"; ot->idname = "ACTION_OT_delete"; ot->description = "Remove all selected keyframes"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = actkeys_delete_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -966,15 +966,15 @@ void ACTION_OT_delete(wmOperatorType *ot) /* ******************** Clean Keyframes Operator ************************* */ static void clean_action_keys(bAnimContext *ac, float thresh, bool clean_chan) -{ +{ ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and clean curves */ for (ale = anim_data.first; ale; ale = ale->next) { clean_fcurve(ac, ale, thresh, clean_chan); @@ -993,44 +993,44 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op) bAnimContext ac; float thresh; bool clean_chan; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get cleaning threshold */ thresh = RNA_float_get(op->ptr, "threshold"); clean_chan = RNA_boolean_get(op->ptr, "channels"); - + /* clean keyframes */ clean_action_keys(&ac, thresh, clean_chan); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_clean(wmOperatorType *ot) { /* identifiers */ ot->name = "Clean Keyframes"; ot->idname = "ACTION_OT_clean"; ot->description = "Simplify F-Curves by removing closely spaced keyframes"; - + /* api callbacks */ - //ot->invoke = // XXX we need that number popup for this! + //ot->invoke = // XXX we need that number popup for this! ot->exec = actkeys_clean_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); RNA_def_boolean(ot->srna, "channels", false, "Channels", ""); @@ -1040,15 +1040,15 @@ void ACTION_OT_clean(wmOperatorType *ot) /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ static void sample_action_keys(bAnimContext *ac) -{ +{ ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and add keys between selected keyframes on every frame */ for (ale = anim_data.first; ale; ale = ale->next) { sample_fcurve((FCurve *)ale->key_data); @@ -1065,36 +1065,36 @@ static void sample_action_keys(bAnimContext *ac) static int actkeys_sample_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* sample keyframes */ sample_action_keys(&ac); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_sample(wmOperatorType *ot) { /* identifiers */ ot->name = "Sample Keyframes"; ot->idname = "ACTION_OT_sample"; ot->description = "Add keyframes on every frame between the selected keyframes"; - + /* api callbacks */ ot->exec = actkeys_sample_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1112,33 +1112,33 @@ void ACTION_OT_sample(wmOperatorType *ot) static const EnumPropertyItem prop_actkeys_expo_types[] = { {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"}, {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"}, - + {MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"}, {CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"}, {0, NULL, 0, NULL, NULL} }; /* this function is responsible for setting extrapolation mode for keyframes */ -static void setexpo_action_keys(bAnimContext *ac, short mode) +static void setexpo_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting mode per F-Curve */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - + if (mode >= 0) { /* just set mode setting */ fcu->extend = mode; } else { - /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation + /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation * without having to go through FModifier UI in Graph Editor to do so */ if (mode == MAKE_CYCLIC_EXPO) { @@ -1151,10 +1151,10 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ FModifier *fcm, *fcn = NULL; - + for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; - + if (fcm->type == FMODIFIER_TYPE_CYCLES) remove_fmodifier(&fcu->modifiers, fcm); } @@ -1174,43 +1174,43 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ setexpo_action_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_extrapolation_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Extrapolation"; ot->idname = "ACTION_OT_extrapolation_type"; ot->description = "Set extrapolation mode for selected F-Curves"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_expo_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", ""); } @@ -1218,17 +1218,17 @@ void ACTION_OT_extrapolation_type(wmOperatorType *ot) /* ******************** Set Interpolation-Type Operator *********************** */ /* this function is responsible for setting interpolation mode for keyframes */ -static void setipo_action_keys(bAnimContext *ac, short mode) +static void setipo_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ @@ -1248,43 +1248,43 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ setipo_action_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_interpolation_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Interpolation"; ot->idname = "ACTION_OT_interpolation_type"; ot->description = "Set interpolation mode for the F-Curve segments starting from the selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_ipo_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", ""); } @@ -1292,25 +1292,25 @@ void ACTION_OT_interpolation_type(wmOperatorType *ot) /* ******************** Set Handle-Type Operator *********************** */ /* this function is responsible for setting handle-type of selected keyframes */ -static void sethandles_action_keys(bAnimContext *ac, short mode) +static void sethandles_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode); KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - /* loop through setting flags for handles + + /* loop through setting flags for handles * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { /* change type of selected handles */ @@ -1330,43 +1330,43 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { BKE_report(op->reports, RPT_ERROR, "Not implemented"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ sethandles_action_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_handle_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Handle Type"; ot->idname = "ACTION_OT_handle_type"; ot->description = "Set type of handle for selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_handletype_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_keyframe_handle_type_items, 0, "Type", ""); } @@ -1374,17 +1374,17 @@ void ACTION_OT_handle_type(wmOperatorType *ot) /* ******************** Set Keyframe-Type Operator *********************** */ /* this function is responsible for setting keyframe type for keyframes */ -static void setkeytype_action_keys(bAnimContext *ac, short mode) +static void setkeytype_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ @@ -1404,11 +1404,11 @@ static void setkeytype_gpencil_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through each layer */ for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { @@ -1427,19 +1427,19 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ac.datatype == ANIMCONT_MASK) { BKE_report(op->reports, RPT_ERROR, "Not implemented for Masks"); return OPERATOR_PASS_THROUGH; } - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ if (ac.datatype == ANIMCONT_GPENCIL) { setkeytype_gpencil_keys(&ac, mode); @@ -1447,28 +1447,28 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) else { setkeytype_action_keys(&ac, mode); } - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_keyframe_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Type"; ot->idname = "ACTION_OT_keyframe_type"; ot->description = "Set type of keyframe for the selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_keytype_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_keyframe_type_items, 0, "Type", ""); } @@ -1495,39 +1495,39 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) bAnimListElem *ale; int filter; KeyframeEditData ked = {{NULL}}; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* init edit data */ /* loop over action data, averaging values */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); } - + ANIM_animdata_freelist(&anim_data); - + /* set the new current frame value, based on the average time */ if (ked.i1) { Scene *scene = ac.scene; CFRA = round_fl_to_int(ked.f1 / ked.i1); SUBFRA = 0.f; } - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); - + return OPERATOR_FINISHED; } @@ -1537,11 +1537,11 @@ void ACTION_OT_frame_jump(wmOperatorType *ot) ot->name = "Jump to Keyframes"; ot->idname = "ACTION_OT_frame_jump"; ot->description = "Set the current frame to the average frame value of selected keyframes"; - + /* api callbacks */ ot->exec = actkeys_framejump_exec; ot->poll = actkeys_framejump_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1562,22 +1562,22 @@ static const EnumPropertyItem prop_actkeys_snap_types[] = { }; /* this function is responsible for snapping keyframes to frame-times */ -static void snap_action_keys(bAnimContext *ac, short mode) +static void snap_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_snap(mode); @@ -1586,11 +1586,11 @@ static void snap_action_keys(bAnimContext *ac, short mode) ked.list.first = (ac->markers) ? ac->markers->first : NULL; ked.list.last = (ac->markers) ? ac->markers->last : NULL; } - + /* snap keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (ale->type == ANIMTYPE_GPLAYER) { ED_gplayer_snap_frames(ale->data, ac->scene, mode); } @@ -1598,7 +1598,7 @@ static void snap_action_keys(bAnimContext *ac, short mode) ED_masklayer_snap_frames(ale->data, ac->scene, mode); } else if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } @@ -1619,38 +1619,38 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get snapping mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* snap keyframes */ snap_action_keys(&ac, mode); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_snap(wmOperatorType *ot) { /* identifiers */ ot->name = "Snap Keys"; ot->idname = "ACTION_OT_snap"; ot->description = "Snap selected keyframes to the times specified"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_snap_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", ""); } @@ -1669,42 +1669,42 @@ static const EnumPropertyItem prop_actkeys_mirror_types[] = { }; /* this function is responsible for mirroring keyframes */ -static void mirror_action_keys(bAnimContext *ac, short mode) +static void mirror_action_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; - + /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_mirror(mode); ked.scene = ac->scene; - + /* for 'first selected marker' mode, need to find first selected marker first! */ /* XXX should this be made into a helper func in the API? */ if (mode == ACTKEYS_MIRROR_MARKER) { TimeMarker *marker = ED_markers_get_first_selected(ac->markers); - + if (marker) ked.f1 = (float)marker->frame; else return; } - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* mirror keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (ale->type == ANIMTYPE_GPLAYER) { ED_gplayer_mirror_frames(ale->data, ac->scene, mode); } @@ -1712,14 +1712,14 @@ static void mirror_action_keys(bAnimContext *ac, short mode) /* TODO */ } else if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } else { ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); } - + ale->update |= ANIM_UPDATE_DEFAULT; } @@ -1733,38 +1733,38 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get mirroring mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* mirror keyframes */ mirror_action_keys(&ac, mode); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_mirror(wmOperatorType *ot) { /* identifiers */ ot->name = "Mirror Keys"; ot->idname = "ACTION_OT_mirror"; ot->description = "Flip selected keyframes over the selected mirror line"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actkeys_mirror_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", ""); } diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 0b1502e8e76..f2588b8139e 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -51,7 +51,7 @@ void ACTION_OT_properties(struct wmOperatorType *ot); /* ***************************************** */ /* action_draw.c */ -void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar); +void draw_channel_names(struct bContext *C, struct bAnimContext *ac, struct ARegion *ar); void draw_channel_strips(struct bAnimContext *ac, struct SpaceAction *saction, struct ARegion *ar); /* ***************************************** */ @@ -122,7 +122,7 @@ void ACTION_OT_layer_prev(struct wmOperatorType *ot); void ACTION_OT_markers_make_local(struct wmOperatorType *ot); -/* defines for snap keyframes +/* defines for snap keyframes * NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h) */ enum eActKeys_Snap_Mode { @@ -132,7 +132,7 @@ enum eActKeys_Snap_Mode { ACTKEYS_SNAP_NEAREST_MARKER, }; -/* defines for mirror keyframes +/* defines for mirror keyframes * NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h) */ enum eActKeys_Mirror_Mode { @@ -141,7 +141,7 @@ enum eActKeys_Mirror_Mode { ACTKEYS_MIRROR_XAXIS, ACTKEYS_MIRROR_MARKER, }; - + /* ***************************************** */ /* action_ops.c */ void action_operatortypes(void); diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index 40ddcf4886a..25218358ed4 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -53,7 +53,7 @@ void action_operatortypes(void) { /* view */ WM_operatortype_append(ACTION_OT_properties); - + /* keyframes */ /* selection */ WM_operatortype_append(ACTION_OT_clickselect); @@ -66,7 +66,7 @@ void action_operatortypes(void) WM_operatortype_append(ACTION_OT_select_more); WM_operatortype_append(ACTION_OT_select_less); WM_operatortype_append(ACTION_OT_select_leftright); - + /* editing */ WM_operatortype_append(ACTION_OT_snap); WM_operatortype_append(ACTION_OT_mirror); @@ -82,17 +82,17 @@ void action_operatortypes(void) WM_operatortype_append(ACTION_OT_keyframe_insert); WM_operatortype_append(ACTION_OT_copy); WM_operatortype_append(ACTION_OT_paste); - + WM_operatortype_append(ACTION_OT_new); WM_operatortype_append(ACTION_OT_unlink); - + WM_operatortype_append(ACTION_OT_push_down); WM_operatortype_append(ACTION_OT_stash); WM_operatortype_append(ACTION_OT_stash_and_create); - + WM_operatortype_append(ACTION_OT_layer_next); WM_operatortype_append(ACTION_OT_layer_prev); - + WM_operatortype_append(ACTION_OT_previewrange_set); WM_operatortype_append(ACTION_OT_view_all); WM_operatortype_append(ACTION_OT_view_selected); @@ -105,7 +105,7 @@ void ED_operatormacros_action(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", "Make a copy of all selected keyframes and move them", OPTYPE_UNDO | OPTYPE_REGISTER); @@ -120,7 +120,7 @@ void ED_operatormacros_action(void) static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; - + /* action_select.c - selection tools */ /* click-select: keyframe (replace) */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); @@ -152,7 +152,7 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "extend", true); RNA_boolean_set(kmi->ptr, "column", false); RNA_boolean_set(kmi->ptr, "channel", true); - + /* click-select: left/right */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", false); @@ -160,71 +160,71 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); - + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); - + /* deselect all */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "invert", false); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "invert", true); - + /* borderselect */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "axis_range", false); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "axis_range", true); - + /* region select */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + WM_keymap_add_item(keymap, "ACTION_OT_select_circle", CKEY, KM_PRESS, 0, 0); - + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN); - + /* select more/less */ WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - + /* select linked */ WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0); - - + + /* action_edit.c */ /* jump to selected keyframes */ WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", GKEY, KM_PRESS, KM_CTRL, 0); - + /* menu + single-step transform */ WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); - + /* menu + set setting */ WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_interpolation_type", TKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); + /* destructive */ WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "DOPESHEET_MT_delete", DELKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "ACTION_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - + /* copy/paste */ WM_keymap_add_item(keymap, "ACTION_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); @@ -246,19 +246,19 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_frame", PAD0, KM_PRESS, 0, 0); - + /* animation module */ /* channels list * NOTE: these operators were originally for the channels list, but are added here too for convenience... */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); - + /* find (i.e. a shortcut for setting the name filter) */ WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); - + /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_ACTION); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_action"); @@ -271,20 +271,20 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) void action_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; - + /* keymap for all regions */ keymap = WM_keymap_find(keyconf, "Dopesheet Generic", SPACE_ACTION, 0); - + /* region management... */ WM_keymap_add_item(keymap, "ACTION_OT_properties", NKEY, KM_PRESS, 0, 0); - - + + /* channels */ - /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. + /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these * are all used for the Graph-Editor too. */ - + /* keyframes */ keymap = WM_keymap_find(keyconf, "Dopesheet", SPACE_ACTION, 0); action_keymap_keyframes(keyconf, keymap); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 4cc38741d3e..83bda4d63a5 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -89,22 +89,22 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc test_cb, sel_cb; - + /* determine type-based settings */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); - + /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* init BezTriple looping data */ test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); - + /* See if we should be selecting or deselecting */ if (test) { for (ale = anim_data.first; ale; ale = ale->next) { @@ -128,10 +128,10 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) } } } - + /* convert sel to selectmode, and use that to get editor */ sel_cb = ANIM_editkeyframes_select(sel); - + /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) @@ -139,9 +139,9 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) else if (ale->type == ANIMTYPE_MASKLAYER) ED_masklayer_frame_select_set(ale->data, sel); else - ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); + ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -151,37 +151,37 @@ static void deselect_action_keys(bAnimContext *ac, short test, short sel) static int actkeys_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* 'standard' behavior - check if selected, then apply relevant selection */ if (RNA_boolean_get(op->ptr, "invert")) deselect_action_keys(&ac, 0, SELECT_INVERT); else deselect_action_keys(&ac, 1, SELECT_ADD); - + /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "ACTION_OT_select_all_toggle"; ot->description = "Toggle selection of all keyframes"; - + /* api callbacks */ ot->exec = actkeys_deselectall_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); @@ -208,39 +208,39 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; rctf rectf; float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac)); - + /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get beztriple editing/validation funcs */ select_cb = ANIM_editkeyframes_select(selectmode); - + if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); else ok_cb = NULL; - + /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* get new vertical minimum extent of channel */ ymin = ymax - ACHANNEL_STEP(ac); - + /* set horizontal range (if applicable) */ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) { /* if channel is mapped in NLA, apply correction */ @@ -255,7 +255,7 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s ked.f2 = rectf.xmax; } } - + /* perform vertical suitability check (if applicable) */ if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) @@ -293,11 +293,11 @@ static void borderselect_action(bAnimContext *ac, const rcti rect, short mode, s break; } } - + /* set minimum extent to be the maximum of the next channel */ ymax = ymin; } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -311,7 +311,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) short mode = 0, selectmode = 0; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -320,7 +320,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) if (!extend) { deselect_action_keys(&ac, 1, SELECT_SUBTRACT); } - + /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); @@ -330,10 +330,10 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) else { selectmode = SELECT_SUBTRACT; } - + /* selection 'mode' depends on whether borderselect region only matters on one axis */ if (RNA_boolean_get(op->ptr, "axis_range")) { - /* mode depends on which axis of the range is larger to determine which axis to use + /* mode depends on which axis of the range is larger to determine which axis to use * - checking this in region-space is fine, as it's fundamentally still going to be a different rect size * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... @@ -343,17 +343,17 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) else mode = ACTKEYS_BORDERSEL_CHANNELS; } - else + else mode = ACTKEYS_BORDERSEL_ALLKEYS; - + /* apply borderselect action */ borderselect_action(&ac, rect, mode, selectmode); - + /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; -} +} void ACTION_OT_select_border(wmOperatorType *ot) { @@ -361,21 +361,21 @@ void ACTION_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "ACTION_OT_select_border"; ot->description = "Select all keyframes within the specified region"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = actkeys_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); - + ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); } @@ -390,24 +390,24 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; rctf rectf, scaled_rectf; float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF(ac)); - + /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get beztriple editing/validation funcs */ select_cb = ANIM_editkeyframes_select(selectmode); ok_cb = ANIM_editkeyframes_ok(mode); - + /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); if (mode == BEZT_OK_CHANNEL_LASSO) { @@ -423,17 +423,17 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, else { ked.data = &scaled_rectf; } - + /* loop over data, doing region select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* get new vertical minimum extent of channel */ ymin = ymax - ACHANNEL_STEP(ac); - + /* compute midpoint of channel (used for testing if the key is in the region or not) */ ked.channel_y = ymin + ACHANNEL_HEIGHT_HALF(ac); - + /* if channel is mapped in NLA, apply correction * - Apply to the bounds being checked, not all the keyframe points, * to avoid having scaling everything @@ -450,16 +450,16 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, ked.f1 = rectf.xmin; ked.f2 = rectf.xmax; } - + /* Update values for scaled_rectf - which is used to compute the mapping in the callbacks - * NOTE: Since summary tracks need late-binding remapping, the callbacks may overwrite these + * NOTE: Since summary tracks need late-binding remapping, the callbacks may overwrite these * with the properly remapped ked.f1/f2 values, when needed */ scaled_rectf.xmin = ked.f1; scaled_rectf.xmax = ked.f2; scaled_rectf.ymin = ymin; scaled_rectf.ymax = ymax; - + /* perform vertical suitability check (if applicable) */ if ((mode == ACTKEYS_BORDERSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) @@ -501,59 +501,59 @@ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, break; } } - + /* set minimum extent to be the maximum of the next channel */ ymax = ymin; } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } - + /* ----------------------------------- */ - + static int actkeys_lassoselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + KeyframeEdit_LassoData data_lasso; rcti rect; rctf rect_fl; - + short selectmode; bool extend; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data_lasso.rectf_view = &rect_fl; data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot); if (data_lasso.mcords == NULL) return OPERATOR_CANCELLED; - + /* clear all selection if not extending selection */ extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_action_keys(&ac, 1, SELECT_SUBTRACT); - + if (!RNA_boolean_get(op->ptr, "deselect")) selectmode = SELECT_ADD; else selectmode = SELECT_SUBTRACT; - + /* get settings from operator */ BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot); BLI_rctf_rcti_copy(&rect_fl, &rect); - + /* apply borderselect action */ region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_LASSO, selectmode, &data_lasso); - + MEM_freeN((void *)data_lasso.mcords); - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -563,17 +563,17 @@ void ACTION_OT_select_lasso(wmOperatorType *ot) ot->name = "Lasso Select"; ot->description = "Select keyframe points using lasso selection"; ot->idname = "ACTION_OT_select_lasso"; - + /* api callbacks */ ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = actkeys_lassoselect_exec; ot->poll = ED_operator_action_active; ot->cancel = WM_gesture_lasso_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_gesture_lasso_select(ot); } @@ -585,10 +585,10 @@ static int action_circle_select_exec(bContext *C, wmOperator *op) bAnimContext ac; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT; - + KeyframeEdit_CircleData data = {0}; rctf rect_fl; - + float x = RNA_int_get(op->ptr, "x"); float y = RNA_int_get(op->ptr, "y"); float radius = RNA_int_get(op->ptr, "radius"); @@ -596,23 +596,23 @@ static int action_circle_select_exec(bContext *C, wmOperator *op) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data.mval[0] = x; data.mval[1] = y; data.radius_squared = radius * radius; data.rectf_view = &rect_fl; - + rect_fl.xmin = x - radius; rect_fl.xmax = x + radius; rect_fl.ymin = y - radius; rect_fl.ymax = y + radius; - + /* apply region select action */ region_select_action_keys(&ac, &rect_fl, BEZT_OK_CHANNEL_CIRCLE, selectmode, &data); - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -621,13 +621,13 @@ void ACTION_OT_select_circle(wmOperatorType *ot) ot->name = "Circle Select"; ot->description = "Select keyframe points using circle selection"; ot->idname = "ACTION_OT_select_circle"; - + ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = action_circle_select_exec; ot->poll = ED_operator_action_active; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; @@ -652,7 +652,7 @@ static const EnumPropertyItem prop_column_select_types[] = { {0, NULL, 0, NULL, NULL} }; -/* ------------------- */ +/* ------------------- */ /* Selects all visible keyframes between the specified markers */ /* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c @@ -662,31 +662,31 @@ static void markers_selectkeys_between(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb, select_cb; KeyframeEditData ked = {{NULL}}; float min, max; - + /* get extreme markers */ ED_markers_get_minmax(ac->markers, 1, &min, &max); min -= 0.5f; max += 0.5f; - + /* get editing funcs + data */ ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); select_cb = ANIM_editkeyframes_select(SELECT_ADD); ked.f1 = min; ked.f2 = max; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* select keys in-between */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -702,7 +702,7 @@ static void markers_selectkeys_between(bAnimContext *ac) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -714,52 +714,52 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked = {{NULL}}; - + /* build list of columns */ switch (mode) { case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */ if (ac->datatype == ANIMCONT_GPENCIL) { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) ED_gplayer_make_cfra_list(ale->data, &ked.list, 1); } else { filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); } ANIM_animdata_freelist(&anim_data); break; - + case ACTKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); - + ce->cfra = (float)CFRA; break; - + case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT); break; - + default: /* invalid option */ return; } - + /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(SELECT_ADD); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); - + /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ @@ -768,10 +768,10 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ @@ -781,7 +781,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); else ked.f1 = ce->cfra; - + /* select elements with frame number matching cfraelem */ if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->data, ce->cfra, SELECT_ADD); @@ -791,7 +791,7 @@ static void columnselect_action_keys(bAnimContext *ac, short mode) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } - + /* free elements */ BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); @@ -803,39 +803,39 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* action to take depends on the mode */ mode = RNA_enum_get(op->ptr, "mode"); - + if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) markers_selectkeys_between(&ac); else columnselect_action_keys(&ac, mode); - + /* set notifier that keyframe selection have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + void ACTION_OT_select_column(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "ACTION_OT_select_column"; ot->description = "Select all keyframes on the specified frame(s)"; - + /* api callbacks */ ot->exec = actkeys_columnselect_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } @@ -845,38 +845,38 @@ void ACTION_OT_select_column(wmOperatorType *ot) static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* loop through all of the keys and select additional keyframes based on these */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* check if anything selected? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { /* select every keyframe in this curve then */ ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL); } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -886,11 +886,11 @@ void ACTION_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "ACTION_OT_select_linked"; ot->description = "Select keyframes occurring in the same F-Curves as selected ones"; - + /* api callbacks */ ot->exec = actkeys_select_linked_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -903,37 +903,37 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc build_cb; - - + + /* init selmap building data */ build_cb = ANIM_editkeyframes_buildselmap(mode); - + /* loop through all of the keys and select additional keyframes based on these */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* only continue if F-Curve has keyframes */ if (fcu->bezt == NULL) continue; - + /* build up map of whether F-Curve's keyframes should be selected or not */ ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more"); ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL); - + /* based on this map, adjust the selection status of the keyframes */ ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_selmap_flush, NULL); - + /* free the selmap used here */ MEM_freeN(ked.data); ked.data = NULL; } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -943,17 +943,17 @@ static void select_moreless_action_keys(bAnimContext *ac, short mode) static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform select changes */ select_moreless_action_keys(&ac, SELMAP_MORE); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -963,11 +963,11 @@ void ACTION_OT_select_more(wmOperatorType *ot) ot->name = "Select More"; ot->idname = "ACTION_OT_select_more"; ot->description = "Select keyframes beside already selected ones"; - + /* api callbacks */ ot->exec = actkeys_select_more_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -977,17 +977,17 @@ void ACTION_OT_select_more(wmOperatorType *ot) static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform select changes */ select_moreless_action_keys(&ac, SELMAP_LESS); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -997,11 +997,11 @@ void ACTION_OT_select_less(wmOperatorType *ot) ot->name = "Select Less"; ot->idname = "ACTION_OT_select_less"; ot->description = "Deselect keyframes on ends of selection islands"; - + /* api callbacks */ ot->exec = actkeys_select_less_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1024,25 +1024,25 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb, select_cb; KeyframeEditData ked = {{NULL}}; Scene *scene = ac->scene; - + /* if select mode is replace, deselect all keyframes (and channels) first */ if (select_mode == SELECT_REPLACE) { select_mode = SELECT_ADD; - + /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence */ deselect_action_keys(ac, 0, SELECT_SUBTRACT); } - + /* set callbacks and editing data */ ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); select_cb = ANIM_editkeyframes_select(select_mode); - + if (leftright == ACTKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; ked.f2 = (float)(CFRA + 0.1f); @@ -1051,18 +1051,18 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se ked.f1 = (float)(CFRA - 0.1f); ked.f2 = MAXFRAMEF; } - + /* filter data */ if (ELEM(ac->datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* select keys */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -1075,15 +1075,15 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } - + /* Sync marker support */ if (select_mode == SELECT_ADD) { SpaceAction *saction = (SpaceAction *)ac->sl; - + if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) { ListBase *markers = ED_animcontext_get_markers(ac); TimeMarker *marker; - + for (marker = markers->first; marker; marker = marker->next) { if (((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA))) @@ -1108,28 +1108,28 @@ static int actkeys_select_leftright_exec(bContext *C, wmOperator *op) bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); short selectmode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* if "test" mode is set, we don't have any info to set this with */ if (leftright == ACTKEYS_LRSEL_TEST) return OPERATOR_CANCELLED; - + /* do the selecting now */ actkeys_select_leftright(&ac, leftright, selectmode); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -1137,11 +1137,11 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* handle mode-based testing */ if (leftright == ACTKEYS_LRSEL_TEST) { Scene *scene = ac.scene; @@ -1156,7 +1156,7 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm else RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT); } - + /* perform selection */ return actkeys_select_leftright_exec(C, op); } @@ -1164,24 +1164,24 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, const wm void ACTION_OT_select_leftright(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Select Left/Right"; ot->idname = "ACTION_OT_select_leftright"; ot->description = "Select keyframes to the left or the right of the current frame"; - + /* api callbacks */ ot->invoke = actkeys_select_leftright_invoke; ot->exec = actkeys_select_leftright_exec; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_actkeys_leftright_select_types, ACTKEYS_LRSEL_TEST, "Mode", ""); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); - + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -1198,19 +1198,19 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) */ /* ------------------- */ - + /* option 1) select keyframe directly under mouse */ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx) { KeyframeEditData ked = {{NULL}}; KeyframeEditFunc select_cb, ok_cb; - + /* get functions for selecting keyframes */ select_cb = ANIM_editkeyframes_select(select_mode); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); ked.f1 = selx; ked.iterflags |= KED_F1_NLA_UNMAP; - + /* select the nominated keyframe on the given frame */ if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frame(ale->data, selx, select_mode); @@ -1224,10 +1224,10 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s { ListBase anim_data = {NULL, NULL}; int filter; - + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frame(ale->data, selx, select_mode); @@ -1236,7 +1236,7 @@ static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short s ED_mask_select_frame(ale->data, selx, select_mode); } } - + ANIM_animdata_freelist(&anim_data); } else { @@ -1254,14 +1254,14 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked = {{NULL}}; - + /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(select_mode); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); - + /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ @@ -1270,16 +1270,16 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se else filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* set frame for validation callback to refer to */ if (adt) ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else ked.f1 = selx; - + /* select elements with frame number matching cfra */ if (ale->type == ANIMTYPE_GPLAYER) ED_gpencil_select_frame(ale->key_data, selx, select_mode); @@ -1288,7 +1288,7 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } - + /* free elements */ BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); @@ -1298,10 +1298,10 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, short select_mode) { KeyframeEditFunc select_cb; - + /* get functions for selecting keyframes */ select_cb = ANIM_editkeyframes_select(select_mode); - + /* select all keyframes in this channel */ if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frames(ale->data, select_mode); @@ -1315,10 +1315,10 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s { ListBase anim_data = {NULL, NULL}; int filter; - + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { ED_gpencil_select_frames(ale->data, select_mode); @@ -1327,7 +1327,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s ED_mask_select_frames(ale->data, select_mode); } } - + ANIM_animdata_freelist(&anim_data); } else { @@ -1335,7 +1335,7 @@ static void actkeys_mselect_channel_only(bAnimContext *ac, bAnimListElem *ale, s } } } - + /* ------------------- */ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, bool column, bool same_channel) @@ -1344,7 +1344,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ DLRBT_Tree anim_keys; bAnimListElem *ale; int filter; - + View2D *v2d = &ac->ar->v2d; bDopeSheet *ads = NULL; int channel_index; @@ -1354,28 +1354,28 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ float key_hsize; float x, y; rctf rectf; - + /* get dopesheet info */ if (ac->datatype == ANIMCONT_DOPESHEET) ads = ac->data; - + /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, 0, ACHANNEL_STEP(ac), 0, (float)ACHANNEL_HEIGHT_HALF(ac), x, y, NULL, &channel_index); - + /* x-range to check is +/- 7px for standard keyframe under standard dpi/y-scale (in screen/region-space), * on either side of mouse click (size of keyframe icon) */ key_hsize = ACHANNEL_HEIGHT(ac) * 0.8f; /* standard channel height (to allow for some slop) */ key_hsize = roundf(key_hsize / 2.0f); /* half-size (for either side), but rounded up to nearest int (for easier targetting) */ - + UI_view2d_region_to_view(v2d, mval[0] - (int)key_hsize, mval[1], &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, mval[0] + (int)key_hsize, mval[1], &rectf.xmax, &rectf.ymax); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* try to get channel */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { @@ -1388,10 +1388,10 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* found match - must return here... */ AnimData *adt = ANIM_nla_mapping_get(ac, ale); ActKeyColumn *ak, *akn = NULL; - + /* make list of keyframes */ BLI_dlrbTree_init(&anim_keys); - + if (ale->key_data) { switch (ale->datatype) { case ALE_SCE: @@ -1443,7 +1443,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* start from keyframe at root of BST, traversing until we find one within the range that was clicked on */ for (ak = anim_keys.root; ak; ak = akn) { if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) { - /* set the frame to use, and apply inverse-correction for NLA-mapping + /* set the frame to use, and apply inverse-correction for NLA-mapping * so that the frame will get selected by the selection functions without * requiring to map each frame once again... */ @@ -1457,41 +1457,41 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ else akn = ak->left; } - + /* remove active channel from list of channels for separate treatment (since it's needed later on) */ BLI_remlink(&anim_data, ale); - + /* cleanup temporary lists */ BLI_dlrbTree_free(&anim_keys); - + /* free list of channels, since it's not used anymore */ ANIM_animdata_freelist(&anim_data); } - + /* for replacing selection, firstly need to clear existing selection */ if (select_mode == SELECT_REPLACE) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; - + /* deselect all keyframes */ deselect_action_keys(ac, 0, SELECT_SUBTRACT); - + /* highlight channel clicked on */ if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) { /* deselect all other channels first */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - + /* Highlight Action-Group or F-Curve? */ if (ale && ale->data) { if (ale->type == ANIMTYPE_GROUP) { bActionGroup *agrp = ale->data; - + agrp->flag |= AGRP_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); } else if (ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE)) { FCurve *fcu = ale->data; - + fcu->flag |= FCURVE_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ale->type); } @@ -1500,11 +1500,11 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ else if (ac->datatype == ANIMCONT_GPENCIL) { /* deselect all other channels first */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); - + /* Highlight GPencil Layer */ if ((ale && ale->data) && (ale->type == ANIMTYPE_GPLAYER)) { bGPDlayer *gpl = ale->data; - + gpl->flag |= GP_LAYER_SELECT; //gpencil_layer_setactive(gpd, gpl); } @@ -1522,28 +1522,28 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ } } } - + /* only select keyframes if we clicked on a valid channel and hit something */ if (ale) { if (found) { /* apply selection to keyframes */ if (column) { - /* select all keyframes in the same frame as the one we hit on the active channel + /* select all keyframes in the same frame as the one we hit on the active channel * [T41077]: "frame" not "selx" here (i.e. no NLA corrections yet) as the code here - * does that itself again as it needs to work on multiple datablocks + * does that itself again as it needs to work on multiple datablocks */ actkeys_mselect_column(ac, select_mode, frame); } else if (same_channel) { /* select all keyframes in the active channel */ - actkeys_mselect_channel_only(ac, ale, select_mode); + actkeys_mselect_channel_only(ac, ale, select_mode); } else { /* select the nominated keyframe on the given frame */ actkeys_mselect_single(ac, ale, select_mode, selx); } } - + /* free this channel */ MEM_freeN(ale); } @@ -1556,11 +1556,11 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent /* ARegion *ar; */ /* UNUSED */ short selectmode; bool column, channel; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get useful pointers from animation context data */ /* ar = ac.ar; */ /* UNUSED */ @@ -1569,48 +1569,48 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* column selection */ column = RNA_boolean_get(op->ptr, "column"); channel = RNA_boolean_get(op->ptr, "channel"); - + /* select keyframe(s) based upon mouse position*/ mouse_action_keys(&ac, event->mval, selectmode, column, channel); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + /* for tweak grab to work */ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } - + void ACTION_OT_clickselect(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Mouse Select Keys"; ot->idname = "ACTION_OT_clickselect"; ot->description = "Select keyframes by clicking on them"; - + /* callbacks */ ot->invoke = actkeys_clickselect_invoke; ot->poll = ED_operator_action_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ - prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - - prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", + + prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", "Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - - prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel", + + prop = RNA_def_boolean(ot->srna, "channel", 0, "Only Channel", "Select all the keyframes in the channel under the mouse"); // CTRLKEY + ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 9c387072945..0b7201c2857 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -65,24 +65,24 @@ ARegion *action_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after main */ ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); - + /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "buttons for action"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -94,56 +94,56 @@ static SpaceLink *action_new(const bContext *C) ScrArea *sa = CTX_wm_area(C); SpaceAction *saction; ARegion *ar; - + saction = MEM_callocN(sizeof(SpaceAction), "initaction"); saction->spacetype = SPACE_ACTION; - + saction->autosnap = SACTSNAP_FRAME; saction->mode = SACTCONT_DOPESHEET; - + saction->ads.filterflag |= ADS_FILTER_SUMMARY; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for action"); - + BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* channel list region */ ar = MEM_callocN(sizeof(ARegion), "channel region for action"); BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_CHANNELS; ar->alignment = RGN_ALIGN_LEFT; - + /* only need to set scroll settings, as this will use 'listview' v2d configuration */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - + /* ui buttons */ ar = MEM_callocN(sizeof(ARegion), "buttons region for action"); - + BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for action"); - + BLI_addtail(&saction->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + ar->v2d.tot.xmin = (float)(SFRA - 10); ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(EFRA + 10); ar->v2d.tot.ymax = 0.0f; - + ar->v2d.cur = ar->v2d.tot; - + ar->v2d.min[0] = 0.0f; ar->v2d.min[1] = 0.0f; - + ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = FLT_MAX; @@ -155,13 +155,13 @@ static SpaceLink *action_new(const bContext *C) ar->v2d.keepofs = V2D_KEEPOFS_Y; ar->v2d.align = V2D_ALIGN_NO_POS_Y; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - + return (SpaceLink *)saction; } /* not spacelink itself */ static void action_free(SpaceLink *UNUSED(sl)) -{ +{ // SpaceAction *saction = (SpaceAction *) sl; } @@ -176,9 +176,9 @@ static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *action_duplicate(SpaceLink *sl) { SpaceAction *sactionn = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ - + return (SpaceLink *)sactionn; } @@ -188,9 +188,9 @@ static SpaceLink *action_duplicate(SpaceLink *sl) static void action_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Dopesheet", SPACE_ACTION, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -207,37 +207,37 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) View2DGrid *grid; View2DScrollers *scrollers; short unit = 0, flag = 0; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* time grid */ unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* data */ if (ANIM_animdata_get_context(C, &ac)) { draw_channel_strips(&ac, saction, ar); } - + /* current frame */ if (saction->flag & SACTION_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); - + /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - + flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN; ED_markers_draw(C, flag); - + /* preview range */ UI_view2d_view_ortho(v2d); ANIM_draw_previewrange(C, v2d, 0); @@ -245,10 +245,10 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) /* callback */ UI_view2d_view_ortho(v2d); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -259,16 +259,16 @@ static void action_main_region_draw(const bContext *C, ARegion *ar) static void action_channel_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + /* ensure the 2d view sync works - main region has bottom scroller */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -278,21 +278,21 @@ static void action_channel_region_draw(const bContext *C, ARegion *ar) /* draw entirely, view changes should be handled here */ bAnimContext ac; View2D *v2d = &ar->v2d; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* data */ if (ANIM_animdata_get_context(C, &ac)) { draw_channel_names((bContext *)C, &ac, ar); } - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* no scrollers here */ } @@ -391,7 +391,7 @@ static void action_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; - + default: if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); @@ -403,7 +403,7 @@ static void action_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - + /* context changes */ switch (wmn->category) { case NC_GPENCIL: @@ -424,7 +424,7 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); } - /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears + /* autocolor only really needs to change when channels are added/removed, or previously hidden stuff appears * (assume for now that if just adding these works, that will be fine) */ else if (((wmn->data == ND_KEYFRAME) && ELEM(wmn->action, NA_ADDED, NA_REMOVED)) || @@ -432,7 +432,7 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) { ED_area_tag_refresh(sa); } - /* for simple edits to the curve data though (or just plain selections), a simple redraw should work + /* for simple edits to the curve data though (or just plain selections), a simple redraw should work * (see T39851 for an example of how this can go wrong) */ else { @@ -446,7 +446,7 @@ static void action_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); break; - + default: /* just redrawing the view will do */ ED_area_tag_redraw(sa); break; @@ -527,12 +527,12 @@ static void action_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s case NC_ANIMATION: switch (wmn->data) { case ND_ANIMCHAN: /* set of visible animchannels changed */ - /* NOTE: for now, this should usually just mean that the filters changed + /* NOTE: for now, this should usually just mean that the filters changed * It may be better if we had a dedicated flag for that though */ ED_region_tag_redraw(ar); break; - + case ND_KEYFRAME: /* new keyframed added -> active action may have changed */ //saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_region_tag_redraw(ar); @@ -547,9 +547,9 @@ static void action_header_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s static void action_buttons_area_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "Dopesheet Generic", SPACE_ACTION, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -594,19 +594,19 @@ static void action_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARe static void action_refresh(const bContext *C, ScrArea *sa) { SpaceAction *saction = (SpaceAction *)sa->spacedata.first; - - /* update the state of the animchannels in response to changes from the data they represent + + /* update the state of the animchannels in response to changes from the data they represent * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled */ if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) { ARegion *ar; - + /* Perform syncing of channel state incl. selection * Active action setting also occurs here (as part of anim channel filtering in anim_filter.c) */ ANIM_sync_animchannels_to_data(C); saction->flag &= ~SACTION_TEMP_NEEDCHANSYNC; - + /* Tag everything for redraw * - Regions (such as header) need to be manually tagged for redraw too * or else they don't update [#28962] @@ -615,7 +615,7 @@ static void action_refresh(const bContext *C, ScrArea *sa) for (ar = sa->regionbase.first; ar; ar = ar->next) ED_region_tag_redraw(ar); } - + /* region updates? */ // XXX re-sizing y-extents of tot should go here? } @@ -642,10 +642,10 @@ void ED_spacetype_action(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action"); ARegionType *art; - + st->spaceid = SPACE_ACTION; strncpy(st->name, "Action", BKE_ST_MAXNAME); - + st->new = action_new; st->free = action_free; st->init = action_init; @@ -665,31 +665,31 @@ void ED_spacetype_action(void) art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - + art->init = action_header_region_init; art->draw = action_header_region_draw; art->listener = action_header_region_listener; - + BLI_addhead(&st->regiontypes, art); - + /* regions: channels */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; - + art->init = action_channel_region_init; art->draw = action_channel_region_draw; art->listener = action_channel_region_listener; - + BLI_addhead(&st->regiontypes, art); - + /* regions: UI buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_UI; @@ -698,11 +698,11 @@ void ED_spacetype_action(void) art->listener = action_region_listener; art->init = action_buttons_area_init; art->draw = action_buttons_area_draw; - + BLI_addhead(&st->regiontypes, art); - + action_buttons_register(art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 441ee96e123..45b0fb36ecc 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -77,7 +77,7 @@ void ED_spacetypes_init(void) /* UI_UNIT_X is now a variable, is used in some spacetype inits? */ U.widget_unit = 20; - + /* create space types */ ED_spacetype_outliner(); ED_spacetype_time(); @@ -98,7 +98,7 @@ void ED_spacetypes_init(void) ED_spacetype_userpref(); ED_spacetype_clip(); // ... - + /* register operator types for screen and all spaces */ ED_operatortypes_screen(); ED_operatortypes_anim(); @@ -120,10 +120,10 @@ void ED_spacetypes_init(void) ED_operatortypes_logic(); ED_operatortypes_mask(); ED_operatortypes_io(); - + ED_operatortypes_view2d(); ED_operatortypes_ui(); - + /* register operators */ spacetypes = BKE_spacetypes_list(); for (type = spacetypes->first; type; type = type->next) { @@ -208,32 +208,32 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf) typedef struct RegionDrawCB { struct RegionDrawCB *next, *prev; - + void (*draw)(const struct bContext *, struct ARegion *, void *); void *customdata; - + int type; - + } RegionDrawCB; -void *ED_region_draw_cb_activate(ARegionType *art, +void *ED_region_draw_cb_activate(ARegionType *art, void (*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type) { RegionDrawCB *rdc = MEM_callocN(sizeof(RegionDrawCB), "RegionDrawCB"); - + BLI_addtail(&art->drawcalls, rdc); rdc->draw = draw; rdc->customdata = customdata; rdc->type = type; - + return rdc; } void ED_region_draw_cb_exit(ARegionType *art, void *handle) { RegionDrawCB *rdc; - + for (rdc = art->drawcalls.first; rdc; rdc = rdc->next) { if (rdc == (RegionDrawCB *)handle) { BLI_remlink(&art->drawcalls, rdc); @@ -251,7 +251,7 @@ void *ED_region_draw_cb_customdata(void *handle) void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type) { RegionDrawCB *rdc; - + for (rdc = ar->type->drawcalls.first; rdc; rdc = rdc->next) { if (rdc->type == type) { UI_reinit_gl_state(); @@ -281,17 +281,17 @@ static void xxx_free(SpaceLink *UNUSED(sl)) /* spacetype; init callback for usage, should be redoable */ static void xxx_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) { - + /* link area to SpaceXXX struct */ - + /* define how many regions, the order and types */ - + /* add types to regions */ } static SpaceLink *xxx_duplicate(SpaceLink *UNUSED(sl)) { - + return NULL; } @@ -309,16 +309,16 @@ static void xxx_keymap(wmKeyConfig *UNUSED(keyconf)) void ED_spacetype_xxx(void) { static SpaceType st; - + st.spaceid = SPACE_VIEW3D; - + st.new = xxx_new; st.free = xxx_free; st.init = xxx_init; st.duplicate = xxx_duplicate; st.operatortypes = xxx_operatortypes; st.keymap = xxx_keymap; - + BKE_spacetype_register(&st); } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index c46beba7ae1..f5e0ccb60c7 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -127,7 +127,7 @@ static int buttons_context_path_world(ButsContextPath *path) else if (buttons_context_path_scene(path)) { scene = path->ptr[path->len - 1].data; world = scene->world; - + if (world) { RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); path->len++; @@ -409,7 +409,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur if (!ct->user) return 0; - + id = ct->user->id; if (id) { @@ -643,7 +643,7 @@ static int buttons_shading_context(const bContext *C, int mainb) return 1; if (mainb == BCONTEXT_DATA && ob && ELEM(ob->type, OB_LAMP, OB_CAMERA)) return 1; - + return 0; } @@ -657,7 +657,7 @@ static int buttons_shading_new_context(const bContext *C, int flag) return BCONTEXT_DATA; else if (flag & (1 << BCONTEXT_WORLD)) return BCONTEXT_WORLD; - + return BCONTEXT_RENDER; } @@ -977,7 +977,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else if (CTX_data_equals(member, "particle_settings")) { /* only available when pinned */ PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSettings); - + if (ptr && ptr->data) { CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, ptr->data); return 1; @@ -985,7 +985,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else { /* get settings from active particle system instead */ ptr = get_pointer_type(path, &RNA_ParticleSystem); - + if (ptr && ptr->data) { ParticleSettings *part = ((ParticleSystem *)ptr->data)->part; CTX_data_pointer_set(result, ptr->id.data, &RNA_ParticleSettings, part); @@ -1025,7 +1025,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } } - + else if (CTX_data_equals(member, "smoke")) { PointerRNA *ptr = get_pointer_type(path, &RNA_Object); @@ -1082,7 +1082,7 @@ static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) } else sbuts->pinid = NULL; - + ED_area_tag_redraw(CTX_wm_area(C)); } diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 141f5abb1f0..53b541ad382 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -45,7 +45,7 @@ struct bNodeTree; struct uiLayout; struct wmOperatorType; -/* buts->scaflag */ +/* buts->scaflag */ #define BUTS_SENS_SEL 1 #define BUTS_SENS_ACT 2 #define BUTS_SENS_LINK 4 diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 8198650fd8a..813f4202a49 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -86,7 +86,7 @@ void BUTTONS_OT_toolbox(wmOperatorType *ot) ot->name = "Toolbox"; ot->description = "Display button panel toolbox"; ot->idname = "BUTTONS_OT_toolbox"; - + /* api callbacks */ ot->invoke = toolbox_invoke; ot->poll = ED_operator_buttons_active; @@ -106,10 +106,10 @@ static int file_browse_exec(bContext *C, wmOperator *op) ID *id; char *str, path[FILE_MAX]; const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - + if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) return OPERATOR_CANCELLED; - + str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); /* add slash for directories, important for some properties */ @@ -119,7 +119,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) BLI_strncpy(path, str, FILE_MAX); BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name); - + if (BLI_is_dir(path)) { /* do this first so '//' isnt converted to '//\' on windows */ BLI_add_slash(path); @@ -255,7 +255,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) ot->name = "Accept"; ot->description = "Open a file browser, Hold Shift to open the file, Alt to browse containing directory"; ot->idname = "BUTTONS_OT_file_browse"; - + /* api callbacks */ ot->invoke = file_browse_invoke; ot->exec = file_browse_exec; diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index 3a824ff883d..50791cf6bef 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -246,7 +246,7 @@ static void set_texture_context(const bContext *C, SpaceButs *sbuts) /************************* Texture User **************************/ -static void buttons_texture_user_property_add(ListBase *users, ID *id, +static void buttons_texture_user_property_add(ListBase *users, ID *id, PointerRNA ptr, PropertyRNA *prop, const char *category, int icon, const char *name) { @@ -263,7 +263,7 @@ static void buttons_texture_user_property_add(ListBase *users, ID *id, BLI_addtail(users, user); } -static void buttons_texture_user_node_add(ListBase *users, ID *id, +static void buttons_texture_user_node_add(ListBase *users, ID *id, bNodeTree *ntree, bNode *node, const char *category, int icon, const char *name) { @@ -290,10 +290,10 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { PointerRNA ptr; /* PropertyRNA *prop; */ /* UNUSED */ - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); /* prop = RNA_struct_find_property(&ptr, "texture"); */ /* UNUSED */ - + buttons_texture_user_node_add(users, id, ntree, node, category, RNA_struct_ui_icon(ptr.type), node->name); } @@ -646,7 +646,7 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p) for (user = ct->users.first; user; user = user->next) if (user->ptr.data == data_p && user->prop == prop_p) break; - + if (user) { /* select texture */ template_texture_select(C, user, NULL); @@ -676,12 +676,12 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope for (user = ct->users.first; user; user = user->next) if (user->ptr.data == ptr->data && user->prop == prop) break; - + /* draw button */ if (user) { uiBlock *block = uiLayoutGetBlock(layout); uiBut *but; - + but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Show texture in texture tab")); UI_but_func_set(but, template_texture_show, user->ptr.data, user->prop); diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 166857aad66..3df913c5f7e 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -55,18 +55,18 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceButs *sbuts; - + sbuts = MEM_callocN(sizeof(SpaceButs), "initbuts"); sbuts->spacetype = SPACE_BUTS; sbuts->align = BUT_VERTICAL; /* header */ ar = MEM_callocN(sizeof(ARegion), "header for buts"); - + BLI_addtail(&sbuts->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_TOP; - + #if 0 /* context region */ ar = MEM_callocN(sizeof(ARegion), "context region for buts"); @@ -77,7 +77,7 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for buts"); - + BLI_addtail(&sbuts->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; @@ -86,12 +86,12 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void buttons_free(SpaceLink *sl) -{ +{ SpaceButs *sbuts = (SpaceButs *) sl; if (sbuts->path) MEM_freeN(sbuts->path); - + if (sbuts->texuser) { ButsContextTexture *ct = sbuts->texuser; BLI_freelistN(&ct->users); @@ -116,11 +116,11 @@ static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *buttons_duplicate(SpaceLink *sl) { SpaceButs *sbutsn = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ sbutsn->path = NULL; sbutsn->texuser = NULL; - + return (SpaceLink *)sbutsn; } @@ -186,7 +186,7 @@ static void buttons_operatortypes(void) static void buttons_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Property Editor", SPACE_BUTS, 0); - + WM_keymap_add_item(keymap, "BUTTONS_OT_toolbox", RIGHTMOUSE, KM_PRESS, 0, 0); } @@ -211,7 +211,7 @@ static void buttons_header_region_draw(const bContext *C, ARegion *ar) static void buttons_area_redraw(ScrArea *sa, short buttons) { SpaceButs *sbuts = sa->spacedata.first; - + /* if the area's current button set is equal to the one to redraw */ if (sbuts->mainb == buttons) ED_area_tag_redraw(sa); @@ -449,10 +449,10 @@ void ED_spacetype_buttons(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype buttons"); ARegionType *art; - + st->spaceid = SPACE_BUTS; strncpy(st->name, "Buttons", BKE_ST_MAXNAME); - + st->new = buttons_new; st->free = buttons_free; st->init = buttons_init; @@ -472,13 +472,13 @@ void ED_spacetype_buttons(void) BLI_addhead(&st->regiontypes, art); buttons_context_register(art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - + art->init = buttons_header_region_init; art->draw = buttons_header_region_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 59dd755173f..2a218df2a44 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -297,7 +297,7 @@ bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *ar, int mval[2], float r ret = true; } } - + IMB_freeImBuf(ibuf); return ret; diff --git a/source/blender/editors/space_clip/tracking_ops_intern.h b/source/blender/editors/space_clip/tracking_ops_intern.h index 6ac9287c914..b53799b88d8 100644 --- a/source/blender/editors/space_clip/tracking_ops_intern.h +++ b/source/blender/editors/space_clip/tracking_ops_intern.h @@ -50,4 +50,4 @@ void clip_tracking_hide_cursor(struct bContext *C); void ed_tracking_delect_all_tracks(struct ListBase *tracks_base); void ed_tracking_delect_all_plane_tracks(struct ListBase *plane_tracks_base); -#endif /* __TRACKING_OPS_INTERN_H__ */ \ No newline at end of file +#endif /* __TRACKING_OPS_INTERN_H__ */ diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index 6396b390ca0..6ee658b744c 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -73,7 +73,7 @@ void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_du /* fake the edit line being in the scroll buffer */ ConsoleLine *cl = sc->history.last; int prompt_len = strlen(sc->prompt); - + cl_dummy->type = CONSOLE_LINE_INPUT; cl_dummy->len = prompt_len + cl->len; cl_dummy->len_alloc = cl_dummy->len + 1; @@ -82,7 +82,7 @@ void console_scrollback_prompt_begin(struct SpaceConsole *sc, ConsoleLine *cl_du memcpy(cl_dummy->line + prompt_len, cl->line, cl->len + 1); BLI_addtail(&sc->scrollback, cl_dummy); } -void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy) +void console_scrollback_prompt_end(struct SpaceConsole *sc, ConsoleLine *cl_dummy) { MEM_freeN(cl_dummy->line); BLI_remlink(&sc->scrollback, cl_dummy); @@ -97,10 +97,10 @@ static int console_textview_begin(TextViewContext *tvc) tvc->lheight = sc->lheight * UI_DPI_FAC; tvc->sel_start = sc->sel_start; tvc->sel_end = sc->sel_end; - + /* iterator */ tvc->iter = sc->scrollback.last; - + return (tvc->iter != NULL); } @@ -108,7 +108,7 @@ static void console_textview_end(TextViewContext *tvc) { SpaceConsole *sc = (SpaceConsole *)tvc->arg1; (void)sc; - + } static int console_textview_step(TextViewContext *tvc) @@ -193,7 +193,7 @@ static int console_textview_main__internal(struct SpaceConsole *sc, ARegion *ar, { ConsoleLine cl_dummy = {NULL}; int ret = 0; - + View2D *v2d = &ar->v2d; TextViewContext tvc = {0}; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index b740ff4b397..4867d42030c 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -92,9 +92,9 @@ void console_scrollback_free(SpaceConsole *sc, ConsoleLine *cl) static void console_scrollback_limit(SpaceConsole *sc) { int tot; - + if (U.scrollback < 32) U.scrollback = 256; // XXX - save in user defaults - + for (tot = BLI_listbase_count(&sc->scrollback); tot > U.scrollback; tot--) console_scrollback_free(sc, sc->scrollback.first); } @@ -122,16 +122,16 @@ static bool console_line_cursor_set(ConsoleLine *cl, int cursor) if (cursor < 0) cursor_new = 0; else if (cursor > cl->len) cursor_new = cl->len; else cursor_new = cursor; - + if (cursor_new == cl->cursor) { return false; } - + cl->cursor = cursor_new; return true; } -#if 0 // XXX unused +#if 0 // XXX unused static void console_lb_debug__internal(ListBase *lb) { ConsoleLine *cl; @@ -147,7 +147,7 @@ static void console_history_debug(const bContext *C) { SpaceConsole *sc = CTX_wm_space_console(C); - + console_lb_debug__internal(&sc->history); } #endif @@ -155,7 +155,7 @@ static void console_history_debug(const bContext *C) static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from) { ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); - + if (from) { BLI_assert(strlen(from->line) == from->len); ci->line = BLI_strdupn(from->line, from->len); @@ -168,7 +168,7 @@ static ConsoleLine *console_lb_add__internal(ListBase *lb, ConsoleLine *from) ci->len_alloc = 64; ci->len = 0; } - + BLI_addtail(lb, ci); return ci; } @@ -182,7 +182,7 @@ static ConsoleLine *console_history_add(SpaceConsole *sc, ConsoleLine *from) static ConsoleLine *console_scrollback_add(const bContext *C, ConsoleLine *from) { SpaceConsole *sc = CTX_wm_space_console(C); - + return console_lb_add__internal(&sc->scrollback, from); } #endif @@ -192,9 +192,9 @@ static ConsoleLine *console_lb_add_str__internal(ListBase *lb, char *str, bool o ConsoleLine *ci = MEM_callocN(sizeof(ConsoleLine), "ConsoleLine Add"); if (own) ci->line = str; else ci->line = BLI_strdup(str); - + ci->len = ci->len_alloc = strlen(str); - + BLI_addtail(lb, ci); return ci; } @@ -215,7 +215,7 @@ ConsoleLine *console_history_verify(const bContext *C) ConsoleLine *ci = sc->history.last; if (ci == NULL) ci = console_history_add(sc, NULL); - + return ci; } @@ -233,7 +233,7 @@ static void console_line_verify_length(ConsoleLine *ci, int len) char *new_line = MEM_callocN(new_len, "console line"); memcpy(new_line, ci->line, ci->len); MEM_freeN(ci->line); - + ci->line = new_line; ci->len_alloc = new_len; } @@ -242,7 +242,7 @@ static void console_line_verify_length(ConsoleLine *ci, int len) static int console_line_insert(ConsoleLine *ci, char *str) { int len = strlen(str); - + if (len > 0 && str[len - 1] == '\n') { /* stop new lines being pasted at the end of lines */ str[len - 1] = '\0'; len--; @@ -250,15 +250,15 @@ static int console_line_insert(ConsoleLine *ci, char *str) if (len == 0) return 0; - + console_line_verify_length(ci, len + ci->len); - + memmove(ci->line + ci->cursor + len, ci->line + ci->cursor, (ci->len - ci->cursor) + 1); memcpy(ci->line + ci->cursor, str, len); - + ci->len += len; ci->cursor += len; - + return len; } @@ -312,11 +312,11 @@ static const EnumPropertyItem console_move_type_items[] = { static int console_move_exec(bContext *C, wmOperator *op) { ConsoleLine *ci = console_history_verify(C); - + int type = RNA_enum_get(op->ptr, "type"); bool done = false; int pos; - + switch (type) { case LINE_BEGIN: pos = ci->cursor; @@ -364,7 +364,7 @@ static int console_move_exec(bContext *C, wmOperator *op) done = console_line_cursor_set(ci, pos); break; } - + if (done) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); @@ -383,7 +383,7 @@ void CONSOLE_OT_move(wmOperatorType *ot) ot->name = "Move Cursor"; ot->description = "Move cursor position"; ot->idname = "CONSOLE_OT_move"; - + /* api callbacks */ ot->exec = console_move_exec; ot->poll = ED_operator_console_active; @@ -410,9 +410,9 @@ static int console_insert_exec(bContext *C, wmOperator *op) } len = console_line_insert(ci, str); - + MEM_freeN(str); - + if (len == 0) { return OPERATOR_CANCELLED; } @@ -442,7 +442,7 @@ static int console_insert_invoke(bContext *C, wmOperator *op, const wmEvent *eve else { char str[BLI_UTF8_MAX + 1]; size_t len; - + if (event->utf8_buf[0]) { len = BLI_str_utf8_size_safe(event->utf8_buf); memcpy(str, event->utf8_buf, len); @@ -466,7 +466,7 @@ void CONSOLE_OT_insert(wmOperatorType *ot) ot->name = "Insert"; ot->description = "Insert text at cursor position"; ot->idname = "CONSOLE_OT_insert"; - + /* api callbacks */ ot->exec = console_insert_exec; ot->invoke = console_insert_invoke; @@ -588,11 +588,11 @@ static int console_delete_exec(bContext *C, wmOperator *op) const short type = RNA_enum_get(op->ptr, "type"); bool done = false; - + if (ci->len == 0) { return OPERATOR_CANCELLED; } - + switch (type) { case DEL_NEXT_CHAR: case DEL_NEXT_WORD: @@ -640,7 +640,7 @@ static int console_delete_exec(bContext *C, wmOperator *op) ED_area_tag_redraw(CTX_wm_area(C)); console_scroll_bottom(ar); - + return OPERATOR_FINISHED; } @@ -651,7 +651,7 @@ void CONSOLE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete text by cursor position"; ot->idname = "CONSOLE_OT_delete"; - + /* api callbacks */ ot->exec = console_delete_exec; ot->poll = ED_operator_console_active; @@ -700,17 +700,17 @@ static int console_clear_exec(bContext *C, wmOperator *op) { SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); - + const bool scrollback = RNA_boolean_get(op->ptr, "scrollback"); const bool history = RNA_boolean_get(op->ptr, "history"); - + /*ConsoleLine *ci = */ console_history_verify(C); - + if (scrollback) { /* last item in mistory */ while (sc->scrollback.first) console_scrollback_free(sc, sc->scrollback.first); } - + if (history) { while (sc->history.first) console_history_free(sc, sc->history.first); @@ -729,11 +729,11 @@ void CONSOLE_OT_clear(wmOperatorType *ot) ot->name = "Clear"; ot->description = "Clear text by type"; ot->idname = "CONSOLE_OT_clear"; - + /* api callbacks */ ot->exec = console_clear_exec; ot->poll = ED_operator_console_active; - + /* properties */ RNA_def_boolean(ot->srna, "scrollback", 1, "Scrollback", "Clear the scrollback history"); RNA_def_boolean(ot->srna, "history", 0, "History", "Clear the command history"); @@ -778,7 +778,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) console_history_add(sc, (ConsoleLine *)sc->history.last); } - + ci = sc->history.last; console_select_offset(sc, ci->len - prev_len); @@ -797,11 +797,11 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot) ot->name = "History Cycle"; ot->description = "Cycle through history"; ot->idname = "CONSOLE_OT_history_cycle"; - + /* api callbacks */ ot->exec = console_history_cycle_exec; ot->poll = ED_operator_console_active; - + /* properties */ RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "Reverse cycle history"); } @@ -852,11 +852,11 @@ void CONSOLE_OT_history_append(wmOperatorType *ot) ot->name = "History Append"; ot->description = "Append history at cursor position"; ot->idname = "CONSOLE_OT_history_append"; - + /* api callbacks */ ot->exec = console_history_append_exec; ot->poll = ED_operator_console_active; - + /* properties */ RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position"); RNA_def_int(ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000); @@ -870,15 +870,15 @@ static int console_scrollback_append_exec(bContext *C, wmOperator *op) SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); ConsoleLine *ci; - + char *str = RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, don't free */ int type = RNA_enum_get(op->ptr, "type"); console_history_verify(C); - + ci = console_scrollback_add_str(sc, str, 1); /* own the string */ ci->type = type; - + console_scrollback_limit(sc); /* 'ar' can be null depending on the operator that runs @@ -888,7 +888,7 @@ static int console_scrollback_append_exec(bContext *C, wmOperator *op) } ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } @@ -907,11 +907,11 @@ void CONSOLE_OT_scrollback_append(wmOperatorType *ot) ot->name = "Scrollback Append"; ot->description = "Append scrollback text by type"; ot->idname = "CONSOLE_OT_scrollback_append"; - + /* api callbacks */ ot->exec = console_scrollback_append_exec; ot->poll = ED_operator_console_active; - + /* properties */ RNA_def_string(ot->srna, "text", NULL, 0, "Text", "Text to insert at the cursor position"); RNA_def_enum(ot->srna, "type", console_line_type_items, CONSOLE_LINE_OUTPUT, "Type", "Console output type"); @@ -924,7 +924,7 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) DynStr *buf_dyn; char *buf_str; - + ConsoleLine *cl; int sel[2]; int offset = 0; @@ -1088,7 +1088,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, const wmEven sel_prev[0] = sc->sel_start; sel_prev[1] = sc->sel_end; - + console_cursor_set_to_pos(sc, ar, scu, mval, true); /* only redraw if the selection changed */ diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index b0d40d6fb38..2dfe02cc333 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -56,26 +56,26 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceConsole *sconsole; - + sconsole = MEM_callocN(sizeof(SpaceConsole), "initconsole"); sconsole->spacetype = SPACE_CONSOLE; - + sconsole->lheight = 14; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for console"); - + BLI_addtail(&sconsole->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - - + + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for text"); - + BLI_addtail(&sconsole->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + /* keep in sync with info */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT); ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */ @@ -94,10 +94,10 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) static void console_free(SpaceLink *sl) { SpaceConsole *sc = (SpaceConsole *) sl; - + while (sc->scrollback.first) console_scrollback_free(sc, sc->scrollback.first); - + while (sc->history.first) console_history_free(sc, sc->history.first); } @@ -112,13 +112,13 @@ static void console_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa) static SpaceLink *console_duplicate(SpaceLink *sl) { SpaceConsole *sconsolen = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ - + /* TODO - duplicate?, then we also need to duplicate the py namespace */ BLI_listbase_clear(&sconsolen->scrollback); BLI_listbase_clear(&sconsolen->history); - + return (SpaceLink *)sconsolen; } @@ -147,10 +147,10 @@ static void console_main_region_init(wmWindowManager *wm, ARegion *ar) /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + /* add drop boxes */ lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); - + WM_event_add_dropbox_handler(&ar->handlers, lb); } @@ -208,7 +208,7 @@ static void path_drop_copy(wmDrag *drag, wmDropBox *drop) static void console_dropboxes(void) { ListBase *lb = WM_dropboxmap_find("Console", SPACE_CONSOLE, RGN_TYPE_WINDOW); - + WM_dropbox_add(lb, "CONSOLE_OT_insert", id_drop_poll, id_drop_copy); WM_dropbox_add(lb, "CONSOLE_OT_insert", path_drop_poll, path_drop_copy); } @@ -236,10 +236,10 @@ static void console_main_region_draw(const bContext *C, ARegion *ar) console_history_verify(C); /* make sure we have some command line */ console_textview_main(sc, ar); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -255,9 +255,9 @@ static void console_operatortypes(void) WM_operatortype_append(CONSOLE_OT_indent); WM_operatortype_append(CONSOLE_OT_unindent); - + /* for use by python only */ - WM_operatortype_append(CONSOLE_OT_history_append); + WM_operatortype_append(CONSOLE_OT_history_append); WM_operatortype_append(CONSOLE_OT_scrollback_append); WM_operatortype_append(CONSOLE_OT_clear); @@ -273,7 +273,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Console", SPACE_CONSOLE, 0); wmKeyMapItem *kmi; - + #ifdef __APPLE__ RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_END); @@ -281,14 +281,14 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD); - + RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", false); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", true); @@ -296,17 +296,17 @@ static void console_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", false); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADMINUS, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", true); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_CHAR); - + RNA_boolean_set(WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "reverse", true); RNA_boolean_set(WM_keymap_add_item(keymap, "CONSOLE_OT_history_cycle", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "reverse", false); - + #if 0 RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", PREV_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", NEXT_WORD); @@ -315,7 +315,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEUPKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_PAGE); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_move", PAGEDOWNKEY, KM_PRESS, 0, 0)->ptr, "type", NEXT_PAGE); #endif - + RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_NEXT_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "type", DEL_PREV_CHAR); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */ @@ -331,7 +331,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "interactive", true); kmi = WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "interactive", true); - + //WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", TABKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */ WM_keymap_add_item(keymap, "CONSOLE_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); /* python operator - space_text.py */ #endif @@ -343,7 +343,7 @@ static void console_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CONSOLE_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "CONSOLE_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); #endif - + WM_keymap_add_item(keymap, "CONSOLE_OT_select_set", LEFTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "CONSOLE_OT_select_word", LEFTMOUSE, KM_DBL_CLICK, 0, 0); @@ -399,10 +399,10 @@ void ED_spacetype_console(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype console"); ARegionType *art; - + st->spaceid = SPACE_CONSOLE; strncpy(st->name, "Console", BKE_ST_MAXNAME); - + st->new = console_new; st->free = console_free; st->init = console_init; @@ -410,7 +410,7 @@ void ED_spacetype_console(void) st->operatortypes = console_operatortypes; st->keymap = console_keymap; st->dropboxes = console_dropboxes; - + /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype console region"); art->regionid = RGN_TYPE_WINDOW; @@ -420,20 +420,20 @@ void ED_spacetype_console(void) art->draw = console_main_region_draw; art->cursor = console_cursor; art->listener = console_main_region_listener; - - + + BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype console region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; - + art->init = console_header_region_init; art->draw = console_header_region_draw; - + BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index d604ce99019..befdf6751ee 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -82,7 +82,7 @@ static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char return BLI_strdup(dyn_tooltip); } -/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. +/* Note: This function uses pixelspace (0, 0, winx, winy), not view2d. * The controls are laid out as follows: * * ------------------------------------------- @@ -117,14 +117,14 @@ void file_draw_buttons(const bContext *C, ARegion *ar) int available_w = max_x - min_x; int line1_w = available_w; int line2_w = available_w; - + uiBut *but; uiBlock *block; SpaceFile *sfile = CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); ARegion *artmp; const bool is_browse_only = (sfile->op == NULL); - + /* Initialize UI block. */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar); block = UI_block_begin(C, ar, uiblockstr, UI_EMBOSS); @@ -208,11 +208,11 @@ void file_draw_buttons(const bContext *C, ARegion *ar) UI_but_flag_enable(but, UI_BUT_REDALERT); } } - + /* clear func */ UI_block_func_set(block, NULL, NULL, NULL); } - + /* Filename number increment / decrement buttons. */ if (fnumbuttons && (params->flag & FILE_DIRSEL_ONLY) == 0) { UI_block_align_begin(block); @@ -229,7 +229,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) RNA_int_set(UI_but_operator_ptr_get(but), "increment", 1); UI_block_align_end(block); } - + /* Execute / cancel buttons. */ if (loadbutton) { const struct FileDirEntry *file = sfile->files ? filelist_file(sfile->files, params->active_file) : NULL; @@ -250,7 +250,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar) uiDefButO(block, UI_BTYPE_BUT, "FILE_OT_cancel", WM_OP_EXEC_REGION_WIN, IFACE_("Cancel"), max_x - loadbutton, line2_y, loadbutton, btn_h, ""); } - + UI_block_end(C, block); UI_block_draw(C, block); } @@ -269,10 +269,10 @@ static void file_draw_icon(uiBlock *block, const char *path, int sx, int sy, int uiBut *but; int x, y; // float alpha = 1.0f; - + x = sx; y = sy - height; - + /*if (icon == ICON_FILE_BLANK) alpha = 0.375f;*/ but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, icon, x, y, width, height, NULL, 0.0f, 0.0f, 0.0f, 0.0f, NULL); @@ -317,7 +317,7 @@ void file_calc_previews(const bContext *C, ARegion *ar) { SpaceFile *sfile = CTX_wm_space_file(C); View2D *v2d = &ar->v2d; - + ED_fileselect_init_layout(sfile, ar); UI_view2d_totRect_set(v2d, sfile->layout->width, sfile->layout->height); } @@ -458,7 +458,7 @@ static void draw_background(FileLayout *layout, View2D *v2d) sy = (int)v2d->cur.ymax - i * (layout->tile_h + 2 * layout->tile_border_y) - layout->tile_border_y; glRectf(v2d->cur.xmin, (float)sy, v2d->cur.xmax, (float)(sy + layout->tile_h + 2 * layout->tile_border_y)); - + } } @@ -522,11 +522,11 @@ void file_draw_list(const bContext *C, ARegion *ar) const float thumb_icon_aspect = sqrtf(64.0f / (float)(params->thumbnail_size)); numfiles = filelist_files_ensure(files); - + if (params->display != FILE_IMGDISPLAY) { draw_background(layout, v2d); - + draw_dividers(layout, v2d); } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index e5abab12c23..828cca53012 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -75,7 +75,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const rcti *rect_region) { FileSelection sel; - + View2D *v2d = &ar->v2d; rcti rect_view; rctf rect_view_fl; @@ -92,7 +92,7 @@ static FileSelection find_file_mouse_rect(SpaceFile *sfile, ARegion *ar, const r (int)(v2d->tot.ymax - rect_view_fl.ymax)); sel = ED_fileselect_layout_offset_rect(sfile->layout, &rect_view); - + return sel; } @@ -101,14 +101,14 @@ static void file_deselect_all(SpaceFile *sfile, unsigned int flag) FileSelection sel; sel.first = 0; sel.last = filelist_files_ensure(sfile->files) - 1; - + filelist_entries_select_index_range_set(sfile->files, &sel, FILE_SEL_REMOVE, flag, CHECK_ALL); } typedef enum FileSelect { FILE_SELECT_NOTHING = 0, - FILE_SELECT_DIR = 1, - FILE_SELECT_FILE = 2 + FILE_SELECT_DIR = 1, + FILE_SELECT_FILE = 2 } FileSelect; static void clamp_to_filelist(int numfiles, FileSelection *sel) @@ -122,7 +122,7 @@ static void clamp_to_filelist(int numfiles, FileSelection *sel) sel->first = -1; sel->last = -1; } - + /* fix if last file invalid */ if ( (sel->first > 0) && (sel->last < 0) ) sel->last = numfiles - 1; @@ -298,10 +298,10 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, FileSelect retval = FILE_SELECT_NOTHING; FileSelection sel = file_selection_get(C, rect, fill); /* get the selection */ const FileCheckType check_type = (sfile->params->flag & FILE_DIRSEL_ONLY) ? CHECK_DIRS : CHECK_ALL; - + /* flag the files as selected in the filelist */ filelist_entries_select_index_range_set(sfile->files, &sel, select, FILE_SEL_SELECTED, check_type); - + /* Don't act on multiple selected files */ if (sel.first != sel.last) select = 0; @@ -333,7 +333,7 @@ static FileSelect file_select(bContext *C, const rcti *rect, FileSelType select, /* update operator for name change event */ file_draw_check(C); - + return retval; } @@ -460,7 +460,7 @@ void FILE_OT_select_border(wmOperatorType *ot) ot->name = "Activate/Select File"; ot->description = "Activate/select the file(s) contained in the border"; ot->idname = "FILE_OT_select_border"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = file_border_select_exec; @@ -529,7 +529,7 @@ void FILE_OT_select(wmOperatorType *ot) ot->name = "Activate/Select File"; ot->description = "Activate/select file"; ot->idname = "FILE_OT_select"; - + /* api callbacks */ ot->invoke = file_select_invoke; ot->poll = ED_operator_file_active; @@ -777,7 +777,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) const int numfiles = filelist_files_ensure(sfile->files); const bool has_selection = file_is_any_selected(sfile->files); - sel.first = 0; + sel.first = 0; sel.last = numfiles - 1; /* select all only if previously no file was selected */ @@ -813,7 +813,7 @@ void FILE_OT_select_all_toggle(wmOperatorType *ot) ot->name = "(De)select All Files"; ot->description = "Select or deselect all files"; ot->idname = "FILE_OT_select_all_toggle"; - + /* api callbacks */ ot->exec = file_select_all_exec; ot->poll = ED_operator_file_active; @@ -840,7 +840,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } - + return OPERATOR_FINISHED; } @@ -852,7 +852,7 @@ void FILE_OT_select_bookmark(wmOperatorType *ot) ot->name = "Select Directory"; ot->description = "Select a bookmarked directory"; ot->idname = "FILE_OT_select_bookmark"; - + /* api callbacks */ ot->exec = bookmark_select_exec; ot->poll = ED_operator_file_active; @@ -871,7 +871,7 @@ static int bookmark_add_exec(bContext *C, wmOperator *UNUSED(op)) if (params->dir[0] != '\0') { char name[FILE_MAX]; - + fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, params->dir, NULL, FS_INSERT_SAVE); BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); @@ -888,7 +888,7 @@ void FILE_OT_bookmark_add(wmOperatorType *ot) ot->name = "Add Bookmark"; ot->description = "Add a bookmark for the selected/active directory"; ot->idname = "FILE_OT_bookmark_add"; - + /* api callbacks */ ot->exec = bookmark_add_exec; ot->poll = ED_operator_file_active; @@ -913,7 +913,7 @@ static int bookmark_delete_exec(bContext *C, wmOperator *op) } if ((index > -1) && (index < nentries)) { char name[FILE_MAX]; - + fsmenu_remove_entry(fsmenu, FS_CATEGORY_BOOKMARKS, index); BLI_make_file_string("/", name, BKE_appdir_folder_id_create(BLENDER_USER_CONFIG, NULL), BLENDER_BOOKMARK_FILE); fsmenu_write_file(fsmenu, name); @@ -933,7 +933,7 @@ void FILE_OT_bookmark_delete(wmOperatorType *ot) ot->name = "Delete Bookmark"; ot->description = "Delete selected bookmark"; ot->idname = "FILE_OT_bookmark_delete"; - + /* api callbacks */ ot->exec = bookmark_delete_exec; ot->poll = ED_operator_file_active; @@ -1080,7 +1080,7 @@ static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); char name[FILE_MAX]; struct FSMenu *fsmenu = ED_fsmenu_get(); - + while (ED_fsmenu_get_entry(fsmenu, FS_CATEGORY_RECENT, 0) != NULL) { fsmenu_remove_entry(fsmenu, FS_CATEGORY_RECENT, 0); } @@ -1097,7 +1097,7 @@ void FILE_OT_reset_recent(wmOperatorType *ot) ot->name = "Reset Recent"; ot->description = "Reset Recent files"; ot->idname = "FILE_OT_reset_recent"; - + /* api callbacks */ ot->exec = reset_recent_exec; ot->poll = ED_operator_file_active; @@ -1148,7 +1148,7 @@ static int file_highlight_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv return OPERATOR_CANCELLED; ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } @@ -1158,7 +1158,7 @@ void FILE_OT_highlight(struct wmOperatorType *ot) ot->name = "Highlight File"; ot->description = "Highlight selected file(s)"; ot->idname = "FILE_OT_highlight"; - + /* api callbacks */ ot->invoke = file_highlight_invoke; ot->poll = ED_operator_file_active; @@ -1169,11 +1169,11 @@ int file_cancel_exec(bContext *C, wmOperator *UNUSED(unused)) wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; - + sfile->op = NULL; WM_event_fileselect_event(wm, op, EVT_FILESELECT_CANCEL); - + return OPERATOR_FINISHED; } @@ -1193,7 +1193,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot) ot->name = "Cancel File Load"; ot->description = "Cancel loading of selected file"; ot->idname = "FILE_OT_cancel"; - + /* api callbacks */ ot->exec = file_cancel_exec; ot->poll = file_operator_poll; @@ -1221,7 +1221,7 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath) if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { RNA_property_string_set(op->ptr, prop, filepath); } - + /* some ops have multiple files to select */ /* this is called on operators check() so clear collections first since * they may be already set. */ @@ -1259,7 +1259,7 @@ void file_sfile_to_operator_ex(wmOperator *op, SpaceFile *sfile, char *filepath) num_dirs++; } } - + /* make sure the directory specified in the button is added even if no directory selected */ if (0 == num_dirs) { RNA_property_collection_add(op->ptr, prop, &itemptr); @@ -1295,7 +1295,7 @@ void file_operator_to_sfile(SpaceFile *sfile, wmOperator *op) RNA_property_string_get(op->ptr, prop, sfile->params->dir); } } - + /* we could check for relative_path property which is used when converting * in the other direction but doesnt hurt to do this every time */ BLI_path_abs(sfile->params->dir, G.main->name); @@ -1331,11 +1331,11 @@ void file_draw_check(bContext *C) if (op) { /* fail on reload */ if (op->type->check) { file_sfile_to_operator(op, sfile); - + /* redraw */ if (op->type->check(C, op)) { file_operator_to_sfile(sfile, op); - + /* redraw, else the changed settings wont get updated */ ED_area_tag_redraw(CTX_wm_area(C)); } @@ -1394,13 +1394,13 @@ int file_exec(bContext *C, wmOperator *exec_op) /* opening file - sends events now, so things get handled on windowqueue level */ else if (sfile->op) { wmOperator *op = sfile->op; - - /* when used as a macro, for doubleclick, + + /* when used as a macro, for doubleclick, * to prevent closing when doubleclicking on .. item */ if (RNA_boolean_get(exec_op->ptr, "need_active")) { const int numfiles = filelist_files_ensure(sfile->files); int i, active = 0; - + for (i = 0; i < numfiles; i++) { if (filelist_entry_select_index_get(sfile->files, i, CHECK_ALL)) { active = 1; @@ -1410,7 +1410,7 @@ int file_exec(bContext *C, wmOperator *exec_op) if (active == 0) return OPERATOR_CANCELLED; } - + sfile->op = NULL; file_sfile_to_operator_ex(op, sfile, filepath); @@ -1438,10 +1438,10 @@ void FILE_OT_execute(struct wmOperatorType *ot) ot->name = "Execute File Window"; ot->description = "Execute selected file"; ot->idname = "FILE_OT_execute"; - + /* api callbacks */ ot->exec = file_exec; - ot->poll = file_operator_poll; + ot->poll = file_operator_poll; /* properties */ prop = RNA_def_boolean(ot->srna, "need_active", 0, "Need Active", @@ -1453,7 +1453,7 @@ void FILE_OT_execute(struct wmOperatorType *ot) int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) { SpaceFile *sfile = CTX_wm_space_file(C); - + if (sfile->params) { if (BLI_parent_dir(sfile->params->dir)) { BLI_cleanup_dir(G.main->name, sfile->params->dir); @@ -1466,7 +1466,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } } - + return OPERATOR_FINISHED; } @@ -1478,7 +1478,7 @@ void FILE_OT_parent(struct wmOperatorType *ot) ot->name = "Parent File"; ot->description = "Move to parent directory"; ot->idname = "FILE_OT_parent"; - + /* api callbacks */ ot->exec = file_parent_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -1509,7 +1509,7 @@ void FILE_OT_previous(struct wmOperatorType *ot) ot->name = "Previous Folder"; ot->description = "Move to previous folder"; ot->idname = "FILE_OT_previous"; - + /* api callbacks */ ot->exec = file_previous_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -1540,7 +1540,7 @@ void FILE_OT_next(struct wmOperatorType *ot) ot->name = "Next Folder"; ot->description = "Move to next folder"; ot->idname = "FILE_OT_next"; - + /* api callbacks */ ot->exec = file_next_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -1581,7 +1581,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w /* escape if not our timer */ if (sfile->smoothscroll_timer == NULL || sfile->smoothscroll_timer != event->customdata) return OPERATOR_PASS_THROUGH; - + numfiles = filelist_files_ensure(sfile->files); /* check if we are editing a name */ @@ -1621,9 +1621,9 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w if (sfile->scroll_offset <= offset) sfile->scroll_offset -= sfile->layout->columns; } } - + numfiles_layout = ED_fileselect_layout_numfiles(sfile->layout, ar); - + /* check if we have reached our final scroll position */ if ( (sfile->scroll_offset >= offset) && (sfile->scroll_offset < offset + numfiles_layout) ) { WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), sfile->smoothscroll_timer); @@ -1631,10 +1631,10 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w return OPERATOR_FINISHED; } - /* temporarily set context to the main window region, + /* temporarily set context to the main window region, * so the scroll operators work */ CTX_wm_region_set(C, ar); - + /* scroll one step in the desired direction */ if (sfile->scroll_offset < offset) { if (sfile->layout->flag & FILE_LAYOUT_HOR) { @@ -1643,7 +1643,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w else { WM_operator_name_call(C, "VIEW2D_OT_scroll_up", 0, NULL); } - + } else { if (sfile->layout->flag & FILE_LAYOUT_HOR) { @@ -1653,27 +1653,27 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w WM_operator_name_call(C, "VIEW2D_OT_scroll_down", 0, NULL); } } - + ED_region_tag_redraw(ar); - + /* and restore context */ CTX_wm_region_set(C, oldar); - + return OPERATOR_FINISHED; } void FILE_OT_smoothscroll(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Smooth Scroll"; ot->idname = "FILE_OT_smoothscroll"; ot->description = "Smooth scroll to make editable file visible"; - + /* api callbacks */ ot->invoke = file_smoothscroll_invoke; - + ot->poll = ED_operator_file_active; } @@ -1749,12 +1749,12 @@ int file_directory_new_exec(bContext *C, wmOperator *op) wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); ScrArea *sa = CTX_wm_area(C); - + if (!sfile->params) { BKE_report(op->reports, RPT_WARNING, "No parent directory given"); return OPERATOR_CANCELLED; } - + path[0] = '\0'; if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { @@ -1824,7 +1824,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) ot->name = "Create New Directory"; ot->description = "Create a new directory"; ot->idname = "FILE_OT_directory_new"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = file_directory_new_exec; @@ -1841,7 +1841,7 @@ void FILE_OT_directory_new(struct wmOperatorType *ot) static void file_expand_directory(bContext *C) { SpaceFile *sfile = CTX_wm_space_file(C); - + if (sfile->params) { if (BLI_path_is_rel(sfile->params->dir)) { /* Use of 'default' folder here is just to avoid an error message on '//' prefix. */ @@ -1899,7 +1899,7 @@ static bool can_create_dir(const char *dir) void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UNUSED(arg_but)) { SpaceFile *sfile = CTX_wm_space_file(C); - + if (sfile->params) { file_expand_directory(C); @@ -1995,7 +1995,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg if (matches) { /* replace the pattern (or filename that the user typed in, with the first selected file of the match */ BLI_strncpy(sfile->params->file, matched_file, sizeof(sfile->params->file)); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } @@ -2024,7 +2024,7 @@ void FILE_OT_refresh(struct wmOperatorType *ot) ot->name = "Refresh Filelist"; ot->description = "Refresh the file list"; ot->idname = "FILE_OT_refresh"; - + /* api callbacks */ ot->exec = file_refresh_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2035,13 +2035,13 @@ static int file_hidedot_exec(bContext *C, wmOperator *UNUSED(unused)) wmWindowManager *wm = CTX_wm_manager(C); SpaceFile *sfile = CTX_wm_space_file(C); ScrArea *sa = CTX_wm_area(C); - + if (sfile->params) { sfile->params->flag ^= FILE_HIDE_DOT; ED_fileselect_clear(wm, sa, sfile); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } - + return OPERATOR_FINISHED; } @@ -2052,7 +2052,7 @@ void FILE_OT_hidedot(struct wmOperatorType *ot) ot->name = "Toggle Hide Dot Files"; ot->description = "Toggle hide hidden dot files"; ot->idname = "FILE_OT_hidedot"; - + /* api callbacks */ ot->exec = file_hidedot_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2067,11 +2067,11 @@ ARegion *file_tools_region(ScrArea *sa) /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); - + /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "tools for file"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_TOOLS; @@ -2089,7 +2089,7 @@ static int file_bookmark_toggle_exec(bContext *C, wmOperator *UNUSED(unused)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = file_tools_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -2102,7 +2102,7 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) ot->name = "Toggle Bookmarks"; ot->description = "Toggle bookmarks display"; ot->idname = "FILE_OT_bookmark_toggle"; - + /* api callbacks */ ot->exec = file_bookmark_toggle_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2144,7 +2144,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op) { SpaceFile *sfile = CTX_wm_space_file(C); ScrArea *sa = CTX_wm_area(C); - + int inc = RNA_int_get(op->ptr, "increment"); if (sfile->params && (inc != 0)) { filenum_newname(sfile->params->file, sizeof(sfile->params->file), inc); @@ -2152,7 +2152,7 @@ static int file_filenum_exec(bContext *C, wmOperator *op) file_draw_check(C); // WM_event_add_notifier(C, NC_WINDOW, NULL); } - + return OPERATOR_FINISHED; } @@ -2163,7 +2163,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot) ot->name = "Increment Number in Filename"; ot->description = "Increment number in filename"; ot->idname = "FILE_OT_filenum"; - + /* api callbacks */ ot->exec = file_filenum_exec; ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ @@ -2176,7 +2176,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); SpaceFile *sfile = (SpaceFile *)CTX_wm_space_data(C); - + if (sfile->params) { int idx = sfile->params->highlight_file; int numfiles = filelist_files_ensure(sfile->files); @@ -2188,7 +2188,7 @@ static int file_rename_exec(bContext *C, wmOperator *UNUSED(op)) } ED_area_tag_redraw(sa); } - + return OPERATOR_FINISHED; } @@ -2232,10 +2232,10 @@ void FILE_OT_rename(struct wmOperatorType *ot) ot->name = "Rename File or Directory"; ot->description = "Rename file or file directory"; ot->idname = "FILE_OT_rename"; - + /* api callbacks */ ot->exec = file_rename_exec; - ot->poll = file_rename_poll; + ot->poll = file_rename_poll; } @@ -2262,7 +2262,7 @@ static int file_delete_poll(bContext *C) } else poll = 0; - + return poll; } @@ -2289,7 +2289,7 @@ int file_delete_exec(bContext *C, wmOperator *op) } } } - + if (report_error) { BKE_reportf(op->reports, RPT_ERROR, "Could not delete file: %s", @@ -2298,7 +2298,7 @@ int file_delete_exec(bContext *C, wmOperator *op) ED_fileselect_clear(wm, sa, sfile); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); - + return OPERATOR_FINISHED; } @@ -2309,7 +2309,7 @@ void FILE_OT_delete(struct wmOperatorType *ot) ot->name = "Delete Selected Files"; ot->description = "Delete selected files"; ot->idname = "FILE_OT_delete"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = file_delete_exec; @@ -2321,6 +2321,6 @@ void ED_operatormacros_file(void) { // wmOperatorType *ot; // wmOperatorTypeMacro *otmacro; - + /* future macros */ } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 343d09bd81c..c975479e402 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -43,7 +43,7 @@ #else # include # include -#endif +#endif #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" @@ -188,13 +188,13 @@ void folderlist_free(ListBase *folderlist) ListBase *folderlist_duplicate(ListBase *folderlist) { - + if (folderlist) { ListBase *folderlistn = MEM_callocN(sizeof(*folderlistn), __func__); FolderList *folder; - + BLI_duplicatelist(folderlistn, folderlist); - + for (folder = folderlistn->first; folder; folder = folder->next) { folder->foldername = MEM_dupallocN(folder->foldername); } @@ -404,7 +404,7 @@ static int compare_direntry_generic(const FileListInternEntry *entry1, const Fil if (FILENAME_IS_CURRENT(entry2->relpath)) return 1; if (FILENAME_IS_PARENT(entry1->relpath)) return -1; if (FILENAME_IS_PARENT(entry2->relpath)) return 1; - + return 0; } @@ -436,7 +436,7 @@ static int compare_date(void *UNUSED(user_data), const void *a1, const void *a2) if ((ret = compare_direntry_generic(entry1, entry2))) { return ret; } - + time1 = (int64_t)entry1->st.st_mtime; time2 = (int64_t)entry2->st.st_mtime; if (time1 < time2) return 1; @@ -459,7 +459,7 @@ static int compare_size(void *UNUSED(user_data), const void *a1, const void *a2) if ((ret = compare_direntry_generic(entry1, entry2))) { return ret; } - + size1 = entry1->st.st_size; size2 = entry2->st.st_size; if (size1 < size2) return 1; @@ -1347,7 +1347,7 @@ void filelist_free(struct FileList *filelist) printf("Attempting to delete empty filelist.\n"); return; } - + filelist_clear_ex(filelist, false, false); /* No need to clear cache & selection_state, we free them anyway. */ filelist_cache_free(&filelist->filelist_cache); @@ -1555,7 +1555,7 @@ FileDirEntry *filelist_file(struct FileList *filelist, int index) int filelist_file_findpath(struct FileList *filelist, const char *filename) { int fidx = -1; - + if (filelist->filelist.nbr_entries_filtered < 0) { return fidx; } @@ -1950,17 +1950,17 @@ static bool file_is_blend_backup(const char *str) } else { const char *loc; - + if (a > b + 1) b++; - + /* allow .blend1 .blend2 .blend32 */ loc = BLI_strcasestr(str + a - b, ".blend"); - + if (loc) retval = 1; } - + return (retval); } @@ -2024,7 +2024,7 @@ static int file_extension_type(const char *dir, const char *relpath) int ED_file_extension_icon(const char *path) { const int type = ED_path_extension_type(path); - + switch (type) { case FILE_TYPE_BLENDER: return ICON_FILE_BLEND; @@ -2319,7 +2319,7 @@ static void filelist_readjob_main_rec(struct FileList *filelist) FileDirEntry *files, *firstlib = NULL; ListBase *lb; int a, fake, idcode, ok, totlib, totbl; - + // filelist->type = FILE_MAIN; // XXX TODO: add modes to filebrowser BLI_assert(filelist->filelist.entries == NULL); @@ -2394,7 +2394,7 @@ static void filelist_readjob_main_rec(struct FileList *filelist) } files = filelist->filelist.entries; - + if (!(filelist->filter_data.flags & FLF_HIDE_PARENT)) { files->entry->relpath = BLI_strdup(FILENAME_PARENT); files->typeflag |= FILE_TYPE_DIR; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 7bd6e7a738e..99307b1961d 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -223,7 +223,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else { params->flag &= ~FILE_HIDE_DOT; } - + if (params->type == FILE_LOADLIB) { params->flag |= RNA_boolean_get(op->ptr, "link") ? FILE_LINK : 0; @@ -365,12 +365,12 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r if (layout == NULL) return sel; - + colmin = (rect->xmin) / (layout->tile_w + 2 * layout->tile_border_x); rowmin = (rect->ymin) / (layout->tile_h + 2 * layout->tile_border_y); colmax = (rect->xmax) / (layout->tile_w + 2 * layout->tile_border_x); rowmax = (rect->ymax) / (layout->tile_h + 2 * layout->tile_border_y); - + if (is_inside(colmin, rowmin, layout->columns, layout->rows) || is_inside(colmax, rowmax, layout->columns, layout->rows) ) { @@ -379,12 +379,12 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r CLAMP(colmax, 0, layout->columns - 1); CLAMP(rowmax, 0, layout->rows - 1); } - + if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) { sel.first = -1; } else { - if (layout->flag & FILE_LAYOUT_HOR) + if (layout->flag & FILE_LAYOUT_HOR) sel.first = layout->rows * colmin + rowmin; else sel.first = colmin + layout->columns * rowmin; @@ -393,7 +393,7 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r sel.last = -1; } else { - if (layout->flag & FILE_LAYOUT_HOR) + if (layout->flag & FILE_LAYOUT_HOR) sel.last = layout->rows * colmax + rowmax; else sel.last = colmax + layout->columns * rowmax; @@ -409,14 +409,14 @@ int ED_fileselect_layout_offset(FileLayout *layout, int x, int y) if (layout == NULL) return -1; - + offsetx = (x) / (layout->tile_w + 2 * layout->tile_border_x); offsety = (y) / (layout->tile_h + 2 * layout->tile_border_y); - + if (offsetx > layout->columns - 1) return -1; if (offsety > layout->rows - 1) return -1; - - if (layout->flag & FILE_LAYOUT_HOR) + + if (layout->flag & FILE_LAYOUT_HOR) active_file = layout->rows * offsetx + offsety; else active_file = offsetx + layout->columns * offsety; @@ -610,12 +610,12 @@ void ED_file_change_dir(bContext *C) int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matched_file) { int match = 0; - + int i; FileDirEntry *file; int n = filelist_files_ensure(sfile->files); - /* select any file that matches the pattern, this includes exact match + /* select any file that matches the pattern, this includes exact match * if the user selects a single file by entering the filename */ for (i = 0; i < n; i++) { @@ -644,7 +644,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) DIR *dir; struct dirent *de; - + BLI_split_dir_part(str, dirname, sizeof(dirname)); dir = opendir(dirname); @@ -659,7 +659,7 @@ int autocomplete_directory(struct bContext *C, char *str, void *UNUSED(arg_v)) else { char path[FILE_MAX]; BLI_stat_t status; - + BLI_join_dirfile(path, sizeof(path), dirname, de->d_name); if (BLI_stat(path, &status) == 0) { @@ -725,7 +725,7 @@ void ED_fileselect_exit(wmWindowManager *wm, ScrArea *sa, SpaceFile *sfile) folderlist_free(sfile->folders_prev); folderlist_free(sfile->folders_next); - + if (sfile->files) { ED_fileselect_clear(wm, sa, sfile); filelist_free(sfile->files); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index ee0ec3fda39..baa8e78572a 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -352,7 +352,7 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, FSMenuCategory category, int idx idx--; if (fsm_iter) { - /* you should only be able to remove entries that were + /* you should only be able to remove entries that were * not added by default, like windows drives. * also separators (where path == NULL) shouldn't be removed */ if (fsm_iter->save && fsm_iter->path) { @@ -512,18 +512,18 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) /* Get mounted volumes better method OSX 10.6 and higher, see: */ /*https://developer.apple.com/library/mac/#documentation/CoreFOundation/Reference/CFURLRef/Reference/reference.html*/ /* we get all volumes sorted including network and do not relay on user-defined finder visibility, less confusing */ - + CFURLRef cfURL = NULL; CFURLEnumeratorResult result = kCFURLEnumeratorSuccess; CFURLEnumeratorRef volEnum = CFURLEnumeratorCreateForMountedVolumes(NULL, kCFURLEnumeratorSkipInvisibles, NULL); - + while (result != kCFURLEnumeratorEnd) { char defPath[FILE_MAX]; result = CFURLEnumeratorGetNextURL(volEnum, &cfURL, NULL); if (result != kCFURLEnumeratorSuccess) continue; - + CFURLGetFileSystemRepresentation(cfURL, false, (UInt8 *)defPath, FILE_MAX); /* Add end slash for consistency with other platforms */ @@ -531,29 +531,29 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, defPath, NULL, FS_INSERT_SORTED); } - + CFRelease(volEnum); - + /* Finally get user favorite places */ if (read_bookmarks) { UInt32 seed; LSSharedFileListRef list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL); CFArrayRef pathesArray = LSSharedFileListCopySnapshot(list, &seed); CFIndex pathesCount = CFArrayGetCount(pathesArray); - + for (CFIndex i = 0; i < pathesCount; i++) { LSSharedFileListItemRef itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); - + CFURLRef cfURL = NULL; - OSErr err = LSSharedFileListItemResolve(itemRef, + OSErr err = LSSharedFileListItemResolve(itemRef, kLSSharedFileListNoUserInteraction | kLSSharedFileListDoNotMountVolumes, &cfURL, NULL); if (err != noErr || !cfURL) continue; - + CFStringRef pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle); - + if (pathString == NULL || !CFStringGetCString(pathString, line, sizeof(line), kCFStringEncodingUTF8)) continue; @@ -565,11 +565,11 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (!strstr(line, "myDocuments.cannedSearch") && (*line != '\0')) { fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, FS_INSERT_LAST); } - + CFRelease(pathString); CFRelease(cfURL); } - + CFRelease(pathesArray); CFRelease(list); } diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index 83ce4776a66..85804538e19 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -60,7 +60,7 @@ void fsmenu_remove_entry(struct FSMenu *fsmenu, enum FSMenuCategory category, /** saves the 'bookmarks' to the specified file */ void fsmenu_write_file(struct FSMenu *fsmenu, const char *filename); - + /** reads the 'bookmarks' from the specified file */ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename); diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index e46f8ce0f5a..8b681bd93c3 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -114,9 +114,9 @@ static SpaceLink *file_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void file_free(SpaceLink *sl) -{ +{ SpaceFile *sfile = (SpaceFile *) sl; - + BLI_assert(sfile->previews_timer == NULL); if (sfile->files) { @@ -184,7 +184,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl) { SpaceFile *sfileo = (SpaceFile *)sl; SpaceFile *sfilen = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ sfilen->op = NULL; /* file window doesn't own operators */ @@ -202,7 +202,7 @@ static SpaceLink *file_duplicate(SpaceLink *sl) if (sfileo->folders_next) sfilen->folders_next = folderlist_duplicate(sfileo->folders_next); - + if (sfileo->layout) { sfilen->layout = MEM_dupallocN(sfileo->layout); } @@ -326,9 +326,9 @@ static void file_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) static void file_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -372,9 +372,9 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); - + /* Allow dynamically sliders to be set, saves notifiers etc. */ - + if (params->display == FILE_IMGDISPLAY) { v2d->scroll = V2D_SCROLL_RIGHT; v2d->keepofs &= ~V2D_LOCKOFS_Y; @@ -384,7 +384,7 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) v2d->scroll = V2D_SCROLL_BOTTOM; v2d->keepofs &= ~V2D_LOCKOFS_X; v2d->keepofs |= V2D_LOCKOFS_Y; - + /* XXX this happens on scaling down Screen (like from startup.blend) */ /* view2d has no type specific for filewindow case, which doesnt scroll vertically */ if (v2d->cur.ymax < 0) { @@ -400,18 +400,18 @@ static void file_main_region_draw(const bContext *C, ARegion *ar) /* set view */ UI_view2d_view_ortho(v2d); - + /* on first read, find active file */ if (params->highlight_file == -1) { wmEvent *event = CTX_wm_window(C)->eventstate; file_highlight_set(sfile, ar, event->x, event->y); } - + file_draw_list(C, ar); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -565,8 +565,8 @@ static void file_keymap(struct wmKeyConfig *keyconf) RNA_int_set(kmi->ptr, "increment", -10); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADMINUS, KM_PRESS, KM_CTRL, 0); RNA_int_set(kmi->ptr, "increment", -100); - - + + /* keys for button region (top) */ keymap = WM_keymap_find(keyconf, "File Browser Buttons", SPACE_FILE, 0); kmi = WM_keymap_add_item(keymap, "FILE_OT_filenum", PADPLUSKEY, KM_PRESS, 0, 0); @@ -615,9 +615,9 @@ static void file_tools_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), static void file_header_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ED_region_header_init(ar); - + keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -706,10 +706,10 @@ void ED_spacetype_file(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype file"); ARegionType *art; - + st->spaceid = SPACE_FILE; strncpy(st->name, "File", BKE_ST_MAXNAME); - + st->new = file_new; st->free = file_free; st->init = file_init; @@ -729,7 +729,7 @@ void ED_spacetype_file(void) art->listener = file_main_region_listener; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_HEADER; @@ -739,7 +739,7 @@ void ED_spacetype_file(void) art->draw = file_header_region_draw; // art->listener = file_header_region_listener; BLI_addhead(&st->regiontypes, art); - + /* regions: ui */ art = MEM_callocN(sizeof(ARegionType), "spacetype file region"); art->regionid = RGN_TYPE_UI; @@ -800,7 +800,7 @@ void ED_file_exit(void) void ED_file_read_bookmarks(void) { const char * const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL); - + fsmenu_free(); fsmenu_read_system(ED_fsmenu_get(), true); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index fce1da8b486..d5586a51a40 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -81,25 +81,25 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** { bAnimContext ac; bAnimListElem *elem = NULL; - - /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) + + /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) * to work correctly is able to be correctly retrieved. There's no point showing empty panels? */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) return 0; - + /* try to find 'active' F-Curve */ elem = get_active_fcurve_channel(&ac); - if (elem == NULL) + if (elem == NULL) return 0; - + if (fcu) *fcu = (FCurve *)elem->data; if (ale) *ale = elem; else MEM_freeN(elem); - + return 1; } @@ -118,7 +118,7 @@ static void graph_panel_view(const bContext *C, Panel *pa) Scene *scene = CTX_data_scene(C); PointerRNA spaceptr, sceneptr; uiLayout *col, *sub, *row; - + /* get RNA pointers for use when creating the UI elements */ RNA_id_pointer_create(&scene->id, &sceneptr); RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); @@ -126,7 +126,7 @@ static void graph_panel_view(const bContext *C, Panel *pa) /* 2D-Cursor */ col = uiLayoutColumn(pa->layout, false); uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); - + sub = uiLayoutColumn(col, true); uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); @@ -139,7 +139,7 @@ static void graph_panel_view(const bContext *C, Panel *pa) else uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); - + row = uiLayoutSplit(sub, 0.7f, true); uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); @@ -160,14 +160,14 @@ static void graph_panel_properties(const bContext *C, Panel *pa) if (!graph_panel_context(C, &ale, &fcu)) return; - + // UNUSED // block = uiLayoutGetBlock(layout); // UI_block_func_handle_set(block, do_graph_region_buttons, NULL); - + /* F-Curve pointer */ RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr); - + /* user-friendly 'name' for F-Curve */ col = uiLayoutColumn(layout, false); if (ale->type == ANIMTYPE_FCURVE) { @@ -177,7 +177,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) else { /* NLA Control Curve, etc. */ const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + /* get name */ if (acf && acf->name) { acf->name(ale, name); @@ -186,26 +186,26 @@ static void graph_panel_properties(const bContext *C, Panel *pa) strcpy(name, IFACE_("")); icon = ICON_ERROR; } - + /* icon */ if (ale->type == ANIMTYPE_NLACURVE) icon = ICON_NLA; } uiItemL(col, name, icon); - + /* RNA-Path Editing - only really should be enabled when things aren't working */ col = uiLayoutColumn(layout, true); uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0); uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); - + /* color settings */ col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Display Color:"), ICON_NONE); - + row = uiLayoutRow(col, true); uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); - + sub = uiLayoutRow(row, true); uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM)); uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); @@ -225,31 +225,31 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT { BezTriple *b; int i; - + /* zero the pointers */ *bezt = *prevbezt = NULL; - + /* sanity checks */ if ((fcu->bezt == NULL) || (fcu->totvert == 0)) return 0; - - /* find first selected keyframe for now, and call it the active one - * - this is a reasonable assumption, given that whenever anyone + + /* find first selected keyframe for now, and call it the active one + * - this is a reasonable assumption, given that whenever anyone * wants to edit numerically, there is likely to only be 1 vert selected */ for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) { if (BEZT_ISSEL_ANY(b)) { - /* found + /* found * - 'previous' is either the one before, of the keyframe itself (which is still fine) * XXX: we can just make this null instead if needed */ *prevbezt = (i > 0) ? b - 1 : b; *bezt = b; - + return 1; } } - + /* not found */ return 0; } @@ -258,7 +258,7 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, void *UNUSED(bezt_ptr)) { FCurve *fcu = (FCurve *)fcu_ptr; - + /* make sure F-Curve and its handles are still valid after this editing */ sort_time_fcurve(fcu); calchandles_fcurve(fcu); @@ -268,8 +268,8 @@ static void graphedit_activekey_update_cb(bContext *UNUSED(C), void *fcu_ptr, vo static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bezt_ptr) { BezTriple *bezt = (BezTriple *)bezt_ptr; - - /* since editing the handles, make sure they're set to types which are receptive to editing + + /* since editing the handles, make sure they're set to types which are receptive to editing * see transform_conversions.c :: createTransGraphEditData(), last step in second loop */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { @@ -280,7 +280,7 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez else { BKE_nurb_bezt_handle_test(bezt, true); } - + /* now call standard updates */ graphedit_activekey_update_cb(C, fcu_ptr, bezt_ptr); } @@ -310,20 +310,20 @@ static void graphedit_activekey_left_handle_coord_cb(bContext *C, void *fcu_ptr, static void graphedit_activekey_right_handle_coord_cb(bContext *C, void *fcu_ptr, void *bezt_ptr) { BezTriple *bezt = (BezTriple *)bezt_ptr; - + /* original state of handle selection - to be restored after performing the recalculation */ const char f1 = bezt->f1; const char f3 = bezt->f3; - - /* temporarily make it so that only the right handle is selected, so that updates go correctly + + /* temporarily make it so that only the right handle is selected, so that updates go correctly * (i.e. it now acts as if we've just transforming the vert when it is selected by itself) */ bezt->f1 &= ~SELECT; bezt->f3 |= SELECT; - + /* perform normal updates NOW */ graphedit_activekey_handles_cb(C, fcu_ptr, bezt_ptr); - + /* restore selection state so that no-one notices this hack */ bezt->f1 = f1; bezt->f3 = f3; @@ -334,34 +334,34 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) bAnimListElem *ale; FCurve *fcu; BezTriple *bezt, *prevbezt; - + uiLayout *layout = pa->layout; uiLayout *col; uiBlock *block; if (!graph_panel_context(C, &ale, &fcu)) return; - + block = uiLayoutGetBlock(layout); /* UI_block_func_handle_set(block, do_graph_region_buttons, NULL); */ - + /* only show this info if there are keyframes to edit */ if (get_active_fcurve_keyframe_edit(fcu, &bezt, &prevbezt)) { PointerRNA bezt_ptr, id_ptr, fcu_prop_ptr; PropertyRNA *fcu_prop = NULL; uiBut *but; int unit = B_UNIT_NONE; - + /* RNA pointer to keyframe, to allow editing */ RNA_pointer_create(ale->id, &RNA_Keyframe, bezt, &bezt_ptr); - + /* get property that F-Curve affects, for some unit-conversion magic */ RNA_id_pointer_create(ale->id, &id_ptr); if (RNA_path_resolve_property(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop)) { /* determine the unit for this property */ unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop)); } - + /* interpolation */ col = uiLayoutColumn(layout, false); if (fcu->flag & FCURVE_DISCRETE_VALUES) { @@ -372,7 +372,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) else { uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); } - + /* easing type */ if (bezt->ipo > BEZT_IPO_BEZ) uiItemR(col, &bezt_ptr, "easing", 0, NULL, 0); @@ -391,8 +391,8 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) default: break; } - - /* numerical coordinate editing + + /* numerical coordinate editing * - we use the button-versions of the calls so that we can attach special update handlers * and unit conversion magic that cannot be achieved using a purely RNA-approach */ @@ -400,50 +400,50 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) /* keyframe itself */ { uiItemL(col, IFACE_("Key:"), ICON_NONE); - + but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, IFACE_("Frame:"), 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt); - + but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, IFACE_("Value:"), 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); UI_but_func_set(but, graphedit_activekey_update_cb, fcu, bezt); UI_but_unit_type_set(but, unit); } - + /* previous handle - only if previous was Bezier interpolation */ if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { uiItemL(col, IFACE_("Left Handle:"), ICON_NONE); - + but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt); - + but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); UI_but_func_set(but, graphedit_activekey_left_handle_coord_cb, fcu, bezt); UI_but_unit_type_set(but, unit); - + /* XXX: with label? */ but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_left_type", 0, 0, 0, -1, -1, "Type of left handle"); UI_but_func_set(but, graphedit_activekey_handles_cb, fcu, bezt); } - + /* next handle - only if current is Bezier interpolation */ if (bezt->ipo == BEZT_IPO_BEZ) { /* NOTE: special update callbacks are needed on the coords here due to T39911 */ uiItemL(col, IFACE_("Right Handle:"), ICON_NONE); - + but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "X:", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt); - + but = uiDefButR(block, UI_BTYPE_NUM, B_REDR, "Y:", 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); UI_but_func_set(but, graphedit_activekey_right_handle_coord_cb, fcu, bezt); UI_but_unit_type_set(but, unit); - + /* XXX: with label? */ but = uiDefButR(block, UI_BTYPE_MENU, B_REDR, NULL, 0, 0, UI_UNIT_X, UI_UNIT_Y, &bezt_ptr, "handle_right_type", 0, 0, 0, -1, -1, "Type of right handle"); @@ -464,7 +464,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) else uiItemL(layout, IFACE_("No active keyframe on F-Curve"), ICON_NONE); } - + MEM_freeN(ale); } @@ -476,7 +476,7 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - + switch (event) { case B_IPO_DEPCHANGE: { @@ -485,7 +485,7 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e break; } } - + /* default for now */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier } @@ -497,11 +497,11 @@ static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg)) ID *id = ale->id; FCurve *fcu = ale->data; ReportList *reports = CTX_wm_reports(C); - + /* try to get F-Curve that driver lives on, and ID block which has this AnimData */ if (ELEM(NULL, id, fcu)) return; - + /* call API method to remove this driver */ ANIM_remove_driver(reports, id, fcu->rna_path, fcu->array_index, 0); ED_undo_push(C, "Remove Driver"); @@ -511,7 +511,7 @@ static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg)) static void driver_add_var_cb(bContext *C, void *driver_v, void *UNUSED(arg)) { ChannelDriver *driver = (ChannelDriver *)driver_v; - + /* add a new variable */ driver_add_new_variable(driver); ED_undo_push(C, "Add Driver Variable"); @@ -522,7 +522,7 @@ static void driver_delete_var_cb(bContext *C, void *driver_v, void *dvar_v) { ChannelDriver *driver = (ChannelDriver *)driver_v; DriverVar *dvar = (DriverVar *)dvar_v; - + /* remove the active variable */ driver_free_variable_ex(driver, dvar); ED_undo_push(C, "Delete Driver Variable"); @@ -533,9 +533,9 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U { uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Invalid Variable Name"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); - + DriverVar *dvar = (DriverVar *)dvar_v; - + if (dvar->flag & DVAR_FLAG_INVALID_EMPTY) { uiItemL(layout, "It cannot be left blank", ICON_ERROR); } @@ -543,7 +543,7 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U uiItemL(layout, "It cannot start with a number", ICON_ERROR); } if (dvar->flag & DVAR_FLAG_INVALID_START_CHAR) { - uiItemL(layout, + uiItemL(layout, "It cannot start with a special character," " including '$', '@', '!', '~', '+', '-', '_', '.', or ' '", ICON_NONE); @@ -560,7 +560,7 @@ static void driver_dvar_invalid_name_query_cb(bContext *C, void *dvar_v, void *U if (dvar->flag & DVAR_FLAG_INVALID_PY_KEYWORD) { uiItemL(layout, "It cannot be a reserved keyword in Python", ICON_INFO); } - + UI_popup_menu_end(C, pup); } @@ -569,7 +569,7 @@ static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSE { FCurve *fcu = (FCurve *)fcu_v; ChannelDriver *driver = fcu->driver; - + /* clear invalid flags */ fcu->flag &= ~FCURVE_DISABLED; driver->flag &= ~DRIVER_FLAG_INVALID; @@ -592,22 +592,22 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa DriverTarget *dtar = &dvar->targets[0]; PointerRNA dtar_ptr; uiLayout *row, *col; - + /* initialize RNA pointer to the target */ - RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); - + RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); + /* Target ID */ row = uiLayoutRow(layout, false); uiLayoutSetRedAlert(row, ((dtar->flag & DTAR_FLAG_INVALID) && !dtar->id)); uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); - + /* Target Property */ if (dtar->id) { PointerRNA root_ptr; - + /* get pointer for resolving the property selected */ RNA_id_pointer_create(dtar->id, &root_ptr); - + /* rna path */ col = uiLayoutColumn(layout, true); uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); @@ -664,23 +664,23 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * Object *ob2 = (Object *)dtar2->id; PointerRNA dtar_ptr, dtar2_ptr; uiLayout *col; - + /* initialize RNA pointer to the target */ - RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); - RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); + RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); + RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Object 1 */ col = uiLayoutColumn(layout, true); uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */ uiItemR(col, &dtar_ptr, "id", 0, IFACE_("Object 1"), ICON_NONE); - + if (dtar->id && GS(dtar->id->name) == ID_OB && ob1->pose) { PointerRNA tar_ptr; - + RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA); } - + uiLayoutSetRedAlert(col, false); /* we can clear it again now - it's only needed when creating the ID/Bone fields */ uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); @@ -688,14 +688,14 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * col = uiLayoutColumn(layout, true); uiLayoutSetRedAlert(col, (dtar2->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */ uiItemR(col, &dtar2_ptr, "id", 0, IFACE_("Object 2"), ICON_NONE); - + if (dtar2->id && GS(dtar2->id->name) == ID_OB && ob2->pose) { PointerRNA tar_ptr; - + RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA); } - + uiLayoutSetRedAlert(col, false); /* we can clear it again now - it's only needed when creating the ID/Bone fields */ uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE); } @@ -707,22 +707,22 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar Object *ob = (Object *)dtar->id; PointerRNA dtar_ptr; uiLayout *col, *sub; - + /* initialize RNA pointer to the target */ - RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); - + RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); + /* properties */ col = uiLayoutColumn(layout, true); uiLayoutSetRedAlert(col, (dtar->flag & DTAR_FLAG_INVALID)); /* XXX: per field... */ uiItemR(col, &dtar_ptr, "id", 0, IFACE_("Object"), ICON_NONE); - + if (dtar->id && GS(dtar->id->name) == ID_OB && ob->pose) { PointerRNA tar_ptr; - + RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr); uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", IFACE_("Bone"), ICON_BONE_DATA); } - + sub = uiLayoutColumn(layout, true); uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); @@ -735,21 +735,21 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) FCurve *fcu; ChannelDriver *driver; DriverVar *dvar; - + PointerRNA driver_ptr; uiLayout *col; uiBlock *block; uiBut *but; - + /* Get settings from context */ if (!graph_panel_context(C, &ale, &fcu)) return; driver = fcu->driver; - + /* set event handler for panel */ block = uiLayoutGetBlock(pa->layout); // xxx? UI_block_func_handle_set(block, do_graph_region_driver_buttons, NULL); - + /* general actions - management */ col = uiLayoutColumn(pa->layout, false); block = uiLayoutGetBlock(col); @@ -764,10 +764,10 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); UI_but_funcN_set(but, driver_remove_cb, MEM_dupallocN(ale), NULL); - + /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); - + col = uiLayoutColumn(pa->layout, true); block = uiLayoutGetBlock(col); uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); @@ -776,10 +776,10 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) if (driver->type == DRIVER_TYPE_PYTHON) { bool bpy_data_expr_error = (strstr(driver->expression, "bpy.data.") != NULL); bool bpy_ctx_expr_error = (strstr(driver->expression, "bpy.context.") != NULL); - + /* expression */ uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE); - + /* errors? */ if ((G.f & G_SCRIPT_AUTOEXEC) == 0) { uiItemL(col, IFACE_("ERROR: Python auto-execution disabled"), ICON_CANCEL); @@ -787,12 +787,12 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) else if (driver->flag & DRIVER_FLAG_INVALID) { uiItemL(col, IFACE_("ERROR: Invalid Python expression"), ICON_CANCEL); } - + /* Explicit bpy-references are evil. Warn about these to prevent errors */ /* TODO: put these in a box? */ if (bpy_data_expr_error || bpy_ctx_expr_error) { uiItemL(col, IFACE_("WARNING: Driver expression may not work correctly"), ICON_HELP); - + if (bpy_data_expr_error) { uiItemL(col, IFACE_("TIP: Use variables instead of bpy.data paths (see below)"), ICON_ERROR); } @@ -805,7 +805,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* errors? */ if (driver->flag & DRIVER_FLAG_INVALID) uiItemL(col, IFACE_("ERROR: Invalid target channel(s)"), ICON_ERROR); - + /* Warnings about a lack of variables * NOTE: The lack of variables is generally a bad thing, since it indicates * that the driver doesn't work at all. This particular scenario arises @@ -814,14 +814,14 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) */ if (BLI_listbase_is_empty(&driver->variables)) { uiItemL(col, IFACE_("ERROR: Driver is useless without any inputs"), ICON_ERROR); - + if (!BLI_listbase_is_empty(&fcu->modifiers)) { uiItemL(col, IFACE_("TIP: Use F-Curves for procedural animation instead"), ICON_INFO); uiItemL(col, IFACE_("F-Modifiers can generate curves for those too"), ICON_INFO); } } } - + col = uiLayoutColumn(pa->layout, true); if (driver->type == DRIVER_TYPE_PYTHON) { @@ -830,22 +830,22 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* debug setting */ uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); - + /* value of driver */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { uiLayout *row = uiLayoutRow(col, true); char valBuf[32]; - + uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); - + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); uiItemL(row, valBuf, ICON_NONE); } - + /* add/copy/paste driver variables */ { uiLayout *row; - + /* add driver variable */ row = uiLayoutRow(pa->layout, false); block = uiLayoutGetBlock(row); @@ -854,62 +854,62 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) NULL, 0.0, 0.0, 0, 0, TIP_("Driver variables ensure that all dependencies will be accounted for and that drivers will update correctly")); UI_but_func_set(but, driver_add_var_cb, driver, NULL); - + /* copy/paste (as sub-row) */ row = uiLayoutRow(row, true); block = uiLayoutGetBlock(row); - + uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_driver_variables_copy"); uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_driver_variables_paste"); } - + /* loop over targets, drawing them */ for (dvar = driver->variables.first; dvar; dvar = dvar->next) { PointerRNA dvar_ptr; uiLayout *box, *row; uiLayout *subrow, *sub; - + /* sub-layout column for this variable's settings */ col = uiLayoutColumn(pa->layout, true); - + /* 1) header panel */ box = uiLayoutBox(col); RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); - + row = uiLayoutRow(box, false); block = uiLayoutGetBlock(row); - + /* 1.1) variable type and name */ subrow = uiLayoutRow(row, true); - + /* 1.1.1) variable type */ sub = uiLayoutRow(subrow, true); /* HACK: special group just for the enum, otherwise we */ uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); /* we get ugly layout with text included too... */ - + uiItemR(sub, &dvar_ptr, "type", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); - + /* 1.1.2) variable name */ sub = uiLayoutRow(subrow, true); /* HACK: special group to counteract the effects of the previous */ uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND); /* enum, which now pushes everything too far right */ - + uiItemR(sub, &dvar_ptr, "name", 0, "", ICON_NONE); - + /* 1.2) invalid name? */ UI_block_emboss_set(block, UI_EMBOSS_NONE); - + if (dvar->flag & DVAR_FLAG_INVALID_NAME) { but = uiDefIconBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_ERROR, 290, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Invalid variable name, click here for details")); UI_but_func_set(but, driver_dvar_invalid_name_query_cb, dvar, NULL); // XXX: reports? } - + /* 1.3) remove button */ but = uiDefIconBut(block, UI_BTYPE_BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); UI_but_func_set(but, driver_delete_var_cb, driver, dvar); UI_block_emboss_set(block, UI_EMBOSS); - - + + /* 2) variable type settings */ box = uiLayoutBox(col); /* controls to draw depends on the type of variable */ @@ -927,15 +927,15 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) graph_panel_driverVar__transChan(box, ale->id, dvar); break; } - + /* 3) value of variable */ if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { char valBuf[32]; - + box = uiLayoutBox(col); row = uiLayoutRow(box, true); uiItemL(row, IFACE_("Value:"), ICON_NONE); - + if ((dvar->type == DVAR_TYPE_ROT_DIFF) || (dvar->type == DVAR_TYPE_TRANSFORM_CHAN && dvar->targets[0].transChan >= DTAR_TRANSCHAN_ROTX && @@ -946,11 +946,11 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) else { BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); } - + uiItemL(row, valBuf, ICON_NONE); } } - + /* cleanup */ MEM_freeN(ale); } @@ -969,7 +969,7 @@ static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int } } -static void graph_panel_modifiers(const bContext *C, Panel *pa) +static void graph_panel_modifiers(const bContext *C, Panel *pa) { bAnimListElem *ale; FCurve *fcu; @@ -977,37 +977,37 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) uiLayout *col, *row; uiBlock *block; bool active; - + if (!graph_panel_context(C, &ale, &fcu)) return; - + block = uiLayoutGetBlock(pa->layout); UI_block_func_handle_set(block, do_graph_region_modifier_buttons, NULL); - + /* 'add modifier' button at top of panel */ { row = uiLayoutRow(pa->layout, false); - - /* this is an operator button which calls a 'add modifier' operator... + + /* this is an operator button which calls a 'add modifier' operator... * a menu might be nicer but would be tricky as we need some custom filtering */ uiItemMenuEnumO(row, (bContext *)C, "GRAPH_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE); - + /* copy/paste (as sub-row) */ row = uiLayoutRow(row, true); uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); } - + active = !(fcu->flag & FCURVE_MOD_OFF); /* draw each modifier */ for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { col = uiLayoutColumn(pa->layout, true); uiLayoutSetActive(col, active); - + ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } - + MEM_freeN(ale); } @@ -1025,7 +1025,7 @@ void graph_buttons_register(ARegionType *art) pt->draw = graph_panel_properties; pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); - + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); strcpy(pt->idname, "GRAPH_PT_key_properties"); strcpy(pt->label, N_("Active Keyframe")); @@ -1053,7 +1053,7 @@ void graph_buttons_register(ARegionType *art) pt->draw = graph_panel_modifiers; pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); - + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel view"); strcpy(pt->idname, "GRAPH_PT_view"); strcpy(pt->label, N_("View Properties")); @@ -1067,7 +1067,7 @@ static int graph_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = graph_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -1079,7 +1079,7 @@ void GRAPH_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->idname = "GRAPH_OT_properties"; ot->description = "Toggle the properties region visibility"; - + ot->exec = graph_properties_toggle_exec; ot->poll = ED_operator_graphedit_active; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index f6e182e02ec..9a94bb9072b 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -61,7 +61,7 @@ /* *************************** */ /* Utility Drawing Defines */ -/* determine the alpha value that should be used when +/* determine the alpha value that should be used when * drawing components for some F-Curve (fcu) * - selected F-Curves should be more visible than partially visible ones */ @@ -82,27 +82,27 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) FCM_EnvelopeData *fed; const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur); int i; - + /* draw two black lines showing the standard reference levels */ glColor3f(0.0f, 0.0f, 0.0f); glLineWidth(1); setlinestyle(5); - + glBegin(GL_LINES); glVertex2f(v2d->cur.xmin, env->midval + env->min); glVertex2f(v2d->cur.xmax, env->midval + env->min); - + glVertex2f(v2d->cur.xmin, env->midval + env->max); glVertex2f(v2d->cur.xmax, env->midval + env->max); glEnd(); setlinestyle(0); - + /* set size of vertices (non-adjustable for now) */ glPointSize(2.0f); - + /* for now, point color is fixed, and is white */ glColor3f(1.0f, 1.0f, 1.0f); - + glBegin(GL_POINTS); for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* only draw if visible @@ -127,18 +127,18 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), BezTriple *bezt = fcu->bezt; const float fac = 0.05f * BLI_rctf_size_x(&v2d->cur); int i; - + glBegin(GL_POINTS); - + for (i = 0; i < fcu->totvert; i++, bezt++) { - /* as an optimization step, only draw those in view + /* as an optimization step, only draw those in view * - we apply a correction factor to ensure that points don't pop in/out due to slight twitches of view size */ if (IN_RANGE(bezt->vec[1][0], (v2d->cur.xmin - fac), (v2d->cur.xmax + fac))) { if (edit) { /* 'Keyframe' vertex only, as handle lines and handles have already been drawn * - only draw those with correct selection state for the current drawing color - * - + * - */ if ((bezt->f2 & SELECT) == sel) glVertex3fv(bezt->vec[1]); @@ -150,41 +150,41 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), } } } - + glEnd(); } -/* helper func - draw handle vertex for an F-Curve as a round unfilled circle +/* helper func - draw handle vertex for an F-Curve as a round unfilled circle * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't * have a consistent appearance (due to off-pixel alignments)... */ static void draw_fcurve_handle_control(float x, float y, float xscale, float yscale, float hsize) { static GLuint displist = 0; - + /* initialize round circle shape */ if (displist == 0) { GLUquadricObj *qobj; - + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - + qobj = gluNewQuadric(); - gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0, 0.7, 8, 1); - gluDeleteQuadric(qobj); - + gluDeleteQuadric(qobj); + glEndList(); } - + /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); - + /* draw! */ glCallList(displist); - + /* restore view transform */ glScalef(xscale / hsize, yscale / hsize, 1.0); glTranslatef(-x, -y, 0.0f); @@ -197,24 +197,24 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2 BezTriple *prevbezt = NULL; float hsize, xscale, yscale; int i; - + /* get view settings */ hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize; UI_view2d_scale_get(v2d, &xscale, &yscale); /* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */ yscale *= units_scale; - + /* set handle color */ if (sel) UI_ThemeColor(TH_HANDLE_VERTEX_SELECT); else UI_ThemeColor(TH_HANDLE_VERTEX); - + /* anti-aliased lines for more consistent appearance */ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + for (i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) { - /* Draw the editmode handles for a bezier curve (others don't have handles) + /* Draw the editmode handles for a bezier curve (others don't have handles) * if their selection status matches the selection status we're drawing for * - first handle only if previous beztriple was bezier-mode * - second handle only if current beztriple is bezier-mode @@ -227,14 +227,14 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2 if ((bezt->f1 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/ draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize); } - + if (bezt->ipo == BEZT_IPO_BEZ) { if ((bezt->f3 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/ draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize); } } } - + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -244,11 +244,11 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel) { /* Fade the 'intensity' of the vertices based on the selection of the curves too */ int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255); - + /* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */ if ((fcu->flag & FCURVE_PROTECTED) == 0) { /* Curve's points ARE BEING edited */ - if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset); + if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset); else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset); } else { @@ -262,29 +262,29 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel) static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only, float units_scale) { View2D *v2d = &ar->v2d; - - /* only draw points if curve is visible + + /* only draw points if curve is visible * - draw unselected points before selected points as separate passes to minimize color-changing overhead - * (XXX dunno if this is faster than drawing all in one pass though) + * (XXX dunno if this is faster than drawing all in one pass though) * and also to make sure in the case of overlapping points that the selected is always visible * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) */ - + glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); - + /* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */ if (do_handles) { set_fcurve_vertex_color(fcu, 0); draw_fcurve_vertices_handles(fcu, sipo, v2d, 0, sel_handle_only, units_scale); - + set_fcurve_vertex_color(fcu, 1); draw_fcurve_vertices_handles(fcu, sipo, v2d, 1, sel_handle_only, units_scale); } - + /* draw keyframes over the handles */ set_fcurve_vertex_color(fcu, 0); draw_fcurve_vertices_keyframes(fcu, sipo, v2d, !(fcu->flag & FCURVE_PROTECTED), 0); - + set_fcurve_vertex_color(fcu, 1); draw_fcurve_vertices_keyframes(fcu, sipo, v2d, !(fcu->flag & FCURVE_PROTECTED), 1); } @@ -315,14 +315,14 @@ static bool draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu) static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) { int sel, b; - + /* a single call to GL_LINES here around these calls should be sufficient to still * get separate line segments, but which aren't wrapped with GL_LINE_STRIP every time we * want a single line */ glBegin(GL_LINES); - - /* slightly hacky, but we want to draw unselected points before selected ones + + /* slightly hacky, but we want to draw unselected points before selected ones * so that selected points are clearly visible */ for (sel = 0; sel < 2; sel++) { @@ -330,35 +330,35 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; const float *fp; unsigned char col[4]; - + for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) { - /* if only selected keyframes can get their handles shown, + /* if only selected keyframes can get their handles shown, * check that keyframe is selected */ if (sipo->flag & SIPO_SELVHANDLESONLY) { if (BEZT_ISSEL_ANY(bezt) == 0) continue; } - + /* draw handle with appropriate set of colors if selection is ok */ if ((bezt->f2 & SELECT) == sel) { fp = bezt->vec[0]; - + /* only draw first handle if previous segment had handles */ if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { UI_GetThemeColor3ubv(basecol + bezt->h1, col); col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - + glVertex2fv(fp); glVertex2fv(fp + 3); } - + /* only draw second handle if this segment is bezier */ if (bezt->ipo == BEZT_IPO_BEZ) { UI_GetThemeColor3ubv(basecol + bezt->h2, col); col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - + glVertex2fv(fp + 3); glVertex2fv(fp + 6); } } @@ -371,10 +371,10 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) UI_GetThemeColor3ubv(basecol + bezt->h1, col); col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - + glVertex2fv(fp); glVertex2fv(fp + 3); } - + /* only draw second handle if this segment is bezier, and selection is ok */ if (((bezt->f3 & SELECT) == sel) && (bezt->ipo == BEZT_IPO_BEZ)) @@ -383,49 +383,49 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) UI_GetThemeColor3ubv(basecol + bezt->h2, col); col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - + glVertex2fv(fp); glVertex2fv(fp + 3); } } } } - + glEnd(); /* GL_LINES */ } /* Samples ---------------- */ -/* helper func - draw sample-range marker for an F-Curve as a cross +/* helper func - draw sample-range marker for an F-Curve as a cross * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't * have a consistent appearance (due to off-pixel alignments)... */ static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize) { static GLuint displist = 0; - + /* initialize X shape */ if (displist == 0) { displist = glGenLists(1); glNewList(displist, GL_COMPILE); - + glBegin(GL_LINES); glVertex2f(-0.7f, -0.7f); glVertex2f(+0.7f, +0.7f); - + glVertex2f(-0.7f, +0.7f); glVertex2f(+0.7f, -0.7f); glEnd(); /* GL_LINES */ - + glEndList(); } - + /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); - + /* draw! */ glCallList(displist); - + /* restore view transform */ glScalef(xscale / hsize, yscale / hsize, 1.0); glTranslatef(-x, -y, 0.0f); @@ -436,28 +436,28 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) { FPoint *first, *last; float hsize, xscale, yscale; - + /* get view settings */ hsize = UI_GetThemeValuef(TH_VERTEX_SIZE); UI_view2d_scale_get(&ar->v2d, &xscale, &yscale); - + /* set vertex color */ if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); - + /* get verts */ first = fcu->fpt; last = (first) ? (first + (fcu->totvert - 1)) : (NULL); - + /* draw */ if (first && last) { /* anti-aliased lines for more consistent appearance */ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize); draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize); - + glDisable(GL_BLEND); if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); } @@ -487,10 +487,10 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d /* disable any drivers temporarily */ driver = fcu->driver; fcu->driver = NULL; - + /* compute unit correction factor */ unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); - + /* Note about sampling frequency: * Ideally, this is chosen such that we have 1-2 pixels = 1 segment * which means that our curves can be as smooth as possible. However, @@ -506,10 +506,10 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d /* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */ /* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */ samplefreq = dx / (U.v2d_min_gridsize * U.pixelsize); - + if (sipo->flag & SIPO_BEAUTYDRAW_OFF) { /* Low Precision = coarse lower-bound clamping - * + * * Although the "Beauty Draw" flag was originally for AA'd * line drawing, the sampling rate here has a much greater * impact on performance (e.g. for T40372)! @@ -525,27 +525,27 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d if (samplefreq < 0.00001f) samplefreq = 0.00001f; } - - + + /* the start/end times are simply the horizontal extents of the 'cur' rect */ stime = v2d->cur.xmin; etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */ - - - /* at each sampling interval, add a new vertex - * - apply the unit correction factor to the calculated values so that + + + /* at each sampling interval, add a new vertex + * - apply the unit correction factor to the calculated values so that * the displayed values appear correctly in the viewport */ glBegin(GL_LINE_STRIP); - + n = (etime - stime) / samplefreq + 0.5f; for (i = 0; i <= n; i++) { float ctime = stime + i * samplefreq; glVertex2f(ctime, (evaluate_fcurve(fcu, ctime) + offset) * unitFac); } - + glEnd(); - + /* restore driver */ fcu->driver = driver; } @@ -567,11 +567,11 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie glTranslatef(0.0f, offset, 0.0f); glBegin(GL_LINE_STRIP); - + /* extrapolate to left? - left-side of view comes before first keyframe? */ if (prevfpt->vec[0] > v2d->cur.xmin) { v[0] = v2d->cur.xmin; - + /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ @@ -583,33 +583,33 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie if (fac) fac = 1.0f / fac; v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } - + glVertex2fv(v); } - + /* if only one sample, add it now */ if (fcu->totvert == 1) glVertex2fv(prevfpt->vec); - + /* loop over samples, drawing segments */ /* draw curve between first and last keyframe (if there are enough to do so) */ while (b--) { /* Linear interpolation: just add one point (which should add a new line segment) */ glVertex2fv(prevfpt->vec); - + /* get next pointers */ prevfpt = fpt; fpt++; - + /* last point? */ if (b == 0) glVertex2fv(prevfpt->vec); } - + /* extrapolate to right? (see code for left-extrapolation above too) */ if (prevfpt->vec[0] < v2d->cur.xmax) { v[0] = v2d->cur.xmax; - + /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* based on last keyframe's value */ @@ -622,28 +622,28 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie if (fac) fac = 1.0f / fac; v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } - + glVertex2fv(v); } - + glEnd(); glPopMatrix(); } -/* helper func - check if the F-Curve only contains easily drawable segments +/* helper func - check if the F-Curve only contains easily drawable segments * (i.e. no easing equation interpolations) */ static bool fcurve_can_use_simple_bezt_drawing(FCurve *fcu) { BezTriple *bezt; int i; - + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (ELEM(bezt->ipo, BEZT_IPO_CONST, BEZT_IPO_LIN, BEZT_IPO_BEZ) == false) { return false; } } - + return true; } @@ -659,7 +659,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 int resol; float unit_scale, offset; short mapping_flag = ANIM_get_normalization_flags(ac); - + /* apply unit mapping */ glPushMatrix(); unit_scale = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); @@ -667,12 +667,12 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 glTranslatef(0.0f, offset, 0.0f); glBegin(GL_LINE_STRIP); - + /* extrapolate to left? */ if (prevbezt->vec[1][0] > v2d->cur.xmin) { /* left-side of view comes before first keyframe, so need to extend as not cyclic */ v1[0] = v2d->cur.xmin; - + /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ @@ -690,17 +690,17 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 if (fac) fac = 1.0f / fac; v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]); } - + glVertex2fv(v1); } - + /* if only one keyframe, add it now */ if (fcu->totvert == 1) { v1[0] = prevbezt->vec[1][0]; v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } - + /* draw curve between first and last keyframe (if there are enough to do so) */ /* TODO: optimize this to not have to calc stuff out of view too? */ while (b--) { @@ -709,7 +709,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 v1[0] = prevbezt->vec[1][0]; v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); - + v1[0] = bezt->vec[1][0]; v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); @@ -721,10 +721,10 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 glVertex2fv(v1); } else if (prevbezt->ipo == BEZT_IPO_BEZ) { - /* Bezier-Interpolation: draw curve as series of segments between keyframes + /* Bezier-Interpolation: draw curve as series of segments between keyframes * - resol determines number of points to sample in between keyframes */ - + /* resol depends on distance between points (not just horizontal) OR is a fixed high res */ /* TODO: view scale should factor into this someday too... */ if (fcu->driver) { @@ -733,7 +733,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 else { resol = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1])); } - + if (resol < 2) { /* only draw one */ v1[0] = prevbezt->vec[1][0]; @@ -744,31 +744,31 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 /* clamp resolution to max of 32 */ /* NOTE: higher values will crash */ if (resol > 32) resol = 32; - + v1[0] = prevbezt->vec[1][0]; v1[1] = prevbezt->vec[1][1]; v2[0] = prevbezt->vec[2][0]; v2[1] = prevbezt->vec[2][1]; - + v3[0] = bezt->vec[0][0]; v3[1] = bezt->vec[0][1]; v4[0] = bezt->vec[1][0]; v4[1] = bezt->vec[1][1]; - + correct_bezpart(v1, v2, v3, v4); - + BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3); BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3); - + for (fp = data; resol; resol--, fp += 3) glVertex2fv(fp); } } - + /* get next pointers */ prevbezt = bezt; bezt++; - + /* last point? */ if (b == 0) { v1[0] = prevbezt->vec[1][0]; @@ -776,11 +776,11 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 glVertex2fv(v1); } } - + /* extrapolate to right? (see code for left-extrapolation above too) */ if (prevbezt->vec[1][0] < v2d->cur.xmax) { v1[0] = v2d->cur.xmax; - + /* y-value depends on the interpolation */ if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* based on last keyframe's value */ @@ -799,17 +799,17 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 if (fac) fac = 1.0f / fac; v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]); } - + glVertex2fv(v1); } - + glEnd(); glPopMatrix(); } /* Debugging -------------------------------- */ -/* Draw indicators which show the value calculated from the driver, +/* Draw indicators which show the value calculated from the driver, * and how this is mapped to the value that comes out of it. This * is handy for helping users better understand how to interpret * the graphs, and also facilitates debugging. @@ -821,93 +821,93 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) short mapping_flag = ANIM_get_normalization_flags(ac); float offset; float unitfac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, mapping_flag, &offset); - + /* for now, only show when debugging driver... */ //if ((driver->flag & DRIVER_FLAG_SHOWDEBUG) == 0) // return; - + /* No curve to modify/visualize the result? - * => We still want to show the 1-1 default... + * => We still want to show the 1-1 default... */ if ((fcu->totvert == 0) && BLI_listbase_is_empty(&fcu->modifiers)) { float t; - + /* draw with thin dotted lines in style of what curve would have been */ glColor3fv(fcu->color); - + setlinestyle(20); glLineWidth(2.0f); - - /* draw 1-1 line, stretching just past the screen limits + + /* draw 1-1 line, stretching just past the screen limits * NOTE: we need to scale the y-values to be valid for the units */ glBegin(GL_LINES); { t = v2d->cur.xmin; glVertex2f(t, (t + offset) * unitfac); - + t = v2d->cur.xmax; glVertex2f(t, (t + offset) * unitfac); } glEnd(); - + /* cleanup line drawing */ setlinestyle(0); } - + /* draw driver only if actually functional */ if ((driver->flag & DRIVER_FLAG_INVALID) == 0) { /* grab "coordinates" for driver outputs */ float x = driver->curval; float y = fcu->curval * unitfac; - + /* only draw indicators if the point is in range*/ if (x >= v2d->cur.xmin) { float co[2]; - + /* draw dotted lines leading towards this point from both axes ....... */ glColor3f(0.9f, 0.9f, 0.9f); setlinestyle(5); - + glBegin(GL_LINES); { /* x-axis lookup */ co[0] = x; - + if (y >= v2d->cur.ymin) { co[1] = v2d->cur.ymin - 1.0f; glVertex2fv(co); - + co[1] = y; glVertex2fv(co); } - + /* y-axis lookup */ co[1] = y; - + co[0] = v2d->cur.xmin - 1.0f; glVertex2fv(co); - + co[0] = x; glVertex2fv(co); } glEnd(); - + setlinestyle(0); - + /* x marks the spot .................................................... */ /* -> outer frame */ glColor3f(0.9f, 0.9f, 0.9f); glPointSize(7.0); - + glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); - + /* inner frame */ glColor3f(0.9f, 0.0f, 0.0f); glPointSize(3.0); - + glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); @@ -917,36 +917,36 @@ static void graph_draw_driver_debug(bAnimContext *ac, ID *id, FCurve *fcu) /* Public Curve-Drawing API ---------------- */ -/* Draw the 'ghost' F-Curves (i.e. snapshots of the curve) +/* Draw the 'ghost' F-Curves (i.e. snapshots of the curve) * NOTE: unit mapping has already been applied to the values, so do not try and apply again */ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) { FCurve *fcu; - + /* draw with thick dotted lines */ setlinestyle(10); glLineWidth(3.0f); - + /* anti-aliased lines for less jagged appearance */ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + /* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */ for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) { - /* set whatever color the curve has set + /* set whatever color the curve has set * - this is set by the function which creates these * - draw with a fixed opacity of 2 */ glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f); - + /* simply draw the stored samples */ draw_fcurve_curve_samples(ac, NULL, fcu, &ar->v2d); } - + /* restore settings */ setlinestyle(0); - + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -959,32 +959,32 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* build list of curves to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL)); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* for each curve: - * draw curve, then handle-lines, and finally vertices in this order so that + * draw curve, then handle-lines, and finally vertices in this order so that * the data will be layered correctly */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; FModifier *fcm = find_active_fmodifier(&fcu->modifiers); AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* map keyframes for drawing if scaled F-Curve */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); - + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + /* draw curve: * - curve line may be result of one or more destructive modifiers or just the raw data, * so we need to check which method should be used * - controls from active modifier take precedence over keyframes * (XXX! editing tools need to take this into account!) */ - + /* 1) draw curve line */ { /* set color/drawing style for curve itself */ @@ -998,12 +998,12 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid UI_ThemeColorShade(TH_HEADER, 50); } else { - /* set whatever color the curve has set + /* set whatever color the curve has set * - unselected curves draw less opaque to help distinguish the selected ones */ glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], fcurve_display_alpha(fcu)); } - + /* draw active F-Curve thicker than the rest to make it stand out */ if (fcu->flag & FCURVE_ACTIVE) { glLineWidth(2.0); @@ -1011,15 +1011,15 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid else { glLineWidth(1.0); } - + /* anti-aliased lines for less jagged appearance */ if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + /* draw F-Curve */ if ((fcu->modifiers.first) || (fcu->flag & FCURVE_INT_VALUES)) { - /* draw a curve affected by modifiers or only allowed to have integer values - * by sampling it at various small-intervals over the visible region + /* draw a curve affected by modifiers or only allowed to have integer values + * by sampling it at various small-intervals over the visible region */ draw_fcurve_curve(ac, ale->id, fcu, &ar->v2d, grid); } @@ -1035,15 +1035,15 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid draw_fcurve_curve_samples(ac, ale->id, fcu, &ar->v2d); } } - + /* restore settings */ setlinestyle(0); - + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - - /* 2) draw handles and vertices as appropriate based on active + + /* 2) draw handles and vertices as appropriate based on active * - if the option to only show controls if the F-Curve is selected is enabled, we must obey this */ if (!(sipo->flag & SIPO_SELCUVERTSONLY) || (fcu->flag & FCURVE_SELECTED)) { @@ -1061,46 +1061,46 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid short mapping_flag = ANIM_get_normalization_flags(ac); float offset; float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); - + /* apply unit-scaling to all values via OpenGL */ glPushMatrix(); glScalef(1.0f, unit_scale, 1.0f); glTranslatef(0.0f, offset, 0.0f); - + /* set this once and for all - all handles and handle-verts should use the same thickness */ glLineWidth(1.0); - + if (fcu->bezt) { bool do_handles = draw_fcurve_handles_check(sipo, fcu); - + if (do_handles) { /* only draw handles/vertices on keyframes */ glEnable(GL_BLEND); draw_fcurve_handles(sipo, fcu); glDisable(GL_BLEND); } - + draw_fcurve_vertices(sipo, ar, fcu, do_handles, (sipo->flag & SIPO_SELVHANDLESONLY), unit_scale); } else { /* samples: only draw two indicators at either end as indicators */ draw_fcurve_samples(sipo, ar, fcu); } - + glPopMatrix(); } } - + /* 3) draw driver debugging stuff */ if ((ac->datatype == ANIMCONT_DRIVERS) && (fcu->flag & FCURVE_ACTIVE)) { graph_draw_driver_debug(ac, ale->id, fcu); } - + /* undo mapping of keyframes for drawing if scaled F-Curve */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } - + /* free list of curves */ ANIM_animdata_freelist(&anim_data); } @@ -1109,40 +1109,40 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid /* Channel List */ /* left hand part */ -void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) +void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + View2D *v2d = &ar->v2d; float y = 0.0f, height; size_t items; int i = 0; - + /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first - * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for + * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ height = (float)((items * ACHANNEL_STEP(ac)) + (ACHANNEL_HEIGHT(ac) * 2)); UI_view2d_totRect_set(v2d, BLI_rcti_size_x(&ar->v2d.mask), height); - + /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - + y = (float)ACHANNEL_FIRST(ac); - + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -1150,7 +1150,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); channel_index++; @@ -1159,17 +1159,17 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - + y = (float)ACHANNEL_FIRST(ac); - + /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF(ac)); const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF(ac)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -1177,18 +1177,18 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= ACHANNEL_STEP(ac); channel_index++; } - + UI_block_end(C, block); UI_block_draw(C, block); - + glDisable(GL_BLEND); } - + /* free tempolary channels */ ANIM_animdata_freelist(&anim_data); } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 12d24502ad6..0370a9149bf 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -82,36 +82,36 @@ /* Get the min/max keyframes*/ /* note: it should return total boundbox, filter for selection only can be argument... */ -void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, +void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const bool do_sel_only, const bool include_handles) { Scene *scene = ac->scene; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get data to filter, from Dopesheet */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* set large values initial values that will be easy to override */ if (xmin) *xmin = 999999999.0f; if (xmax) *xmax = -999999999.0f; if (ymin) *ymin = 999999999.0f; if (ymax) *ymax = -999999999.0f; - + /* check if any channels to set range with */ if (anim_data.first) { bool foundBounds = false; - + /* go through channels, finding max extents */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; float txmin, txmax, tymin, tymax; float unitFac, offset; - + /* get range */ if (calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax, do_sel_only, include_handles)) { short mapping_flag = ANIM_get_normalization_flags(ac); @@ -121,24 +121,24 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); txmax = BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP); } - + /* apply unit corrections */ unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); tymin += offset; tymax += offset; tymin *= unitFac; tymax *= unitFac; - + /* try to set cur using these values, if they're more extreme than previously set values */ if ((xmin) && (txmin < *xmin)) *xmin = txmin; if ((xmax) && (txmax > *xmax)) *xmax = txmax; if ((ymin) && (tymin < *ymin)) *ymin = tymin; if ((ymax) && (tymax > *ymax)) *ymax = tymax; - + foundBounds = true; } } - + /* ensure that the extents are not too extreme that view implodes...*/ if (foundBounds) { if ((xmin && xmax) && (fabsf(*xmax - *xmin) < 0.001f)) { @@ -156,7 +156,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa if (ymin) *ymin = -5; if (ymax) *ymax = 5; } - + /* free memory */ ANIM_animdata_freelist(&anim_data); } @@ -170,7 +170,7 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa if (xmin) *xmin = -5; if (xmax) *xmax = 100; } - + if (ymin) *ymin = -5; if (ymax) *ymax = 5; } @@ -183,7 +183,7 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) bAnimContext ac; Scene *scene; float min, max; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -191,31 +191,31 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; else scene = ac.scene; - + /* set the range directly */ get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, false, false); scene->r.flag |= SCER_PRV_RANGE; scene->r.psfra = round_fl_to_int(min); scene->r.pefra = round_fl_to_int(max); - + /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_previewrange_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Auto-Set Preview Range"; ot->idname = "GRAPH_OT_previewrange_set"; ot->description = "Automatically set Preview Range based on range of keyframes"; - + /* api callbacks */ ot->exec = graphkeys_previewrange_exec; ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -227,11 +227,11 @@ static int graphkeys_viewall(bContext *C, const bool do_sel_only, const bool inc { bAnimContext ac; rctf cur_new; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_graph_keyframe_extents(&ac, &cur_new.xmin, &cur_new.xmax, @@ -239,9 +239,9 @@ static int graphkeys_viewall(bContext *C, const bool do_sel_only, const bool inc do_sel_only, include_handles); BLI_rctf_scale(&cur_new, 1.1f); - + UI_view2d_smooth_view(C, ac.ar, &cur_new, smooth_viewtx); - + return OPERATOR_FINISHED; } @@ -251,16 +251,16 @@ static int graphkeys_viewall_exec(bContext *C, wmOperator *op) { const bool include_handles = RNA_boolean_get(op->ptr, "include_handles"); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - + /* whole range */ return graphkeys_viewall(C, false, include_handles, smooth_viewtx); } - + static int graphkeys_view_selected_exec(bContext *C, wmOperator *op) { const bool include_handles = RNA_boolean_get(op->ptr, "include_handles"); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - + /* only selected */ return graphkeys_viewall(C, true, include_handles, smooth_viewtx); } @@ -273,16 +273,16 @@ void GRAPH_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "GRAPH_OT_view_all"; ot->description = "Reset viewable area to show full keyframe range"; - + /* api callbacks */ ot->exec = graphkeys_viewall_exec; ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */ - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ - ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles", + ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles", "Include handles of keyframes when calculating extents"); } @@ -299,9 +299,9 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ - ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles", + ot->prop = RNA_def_boolean(ot->srna, "include_handles", true, "Include Handles", "Include handles of keyframes when calculating extents"); } @@ -320,11 +320,11 @@ void GRAPH_OT_view_frame(wmOperatorType *ot) ot->name = "View Frame"; ot->idname = "GRAPH_OT_view_frame"; ot->description = "Reset viewable area to show range around current frame"; - + /* api callbacks */ ot->exec = graphkeys_view_frame_exec; ot->poll = ED_operator_graphedit_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -336,25 +336,25 @@ void GRAPH_OT_view_frame(wmOperatorType *ot) /* Bake each F-Curve into a set of samples, and store as a ghost curve */ static void create_ghost_curves(bAnimContext *ac, int start, int end) -{ +{ SpaceIpo *sipo = (SpaceIpo *)ac->sl; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* free existing ghost curves */ free_fcurves(&sipo->ghostCurves); - + /* sanity check */ if (start >= end) { printf("Error: Frame range for Ghost F-Curve creation is inappropriate\n"); return; } - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and add keys between selected keyframes on every frame */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; @@ -365,41 +365,41 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end) float unitFac, offset; int cfra; short mapping_flag = ANIM_get_normalization_flags(ac); - + /* disable driver so that it don't muck up the sampling process */ fcu->driver = NULL; - + /* calculate unit-mapping factor */ unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); - - /* create samples, but store them in a new curve - * - we cannot use fcurve_store_samples() as that will only overwrite the original curve + + /* create samples, but store them in a new curve + * - we cannot use fcurve_store_samples() as that will only overwrite the original curve */ gcu->fpt = fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "Ghost FPoint Samples"); gcu->totvert = end - start + 1; - + /* use the sampling callback at 1-frame intervals from start to end frames */ for (cfra = start; cfra <= end; cfra++, fpt++) { float cfrae = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); - + fpt->vec[0] = cfrae; fpt->vec[1] = (fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) + offset) * unitFac; } - - /* set color of ghost curve + + /* set color of ghost curve * - make the color slightly darker */ gcu->color[0] = fcu->color[0] - 0.07f; gcu->color[1] = fcu->color[1] - 0.07f; gcu->color[2] = fcu->color[2] - 0.07f; - + /* store new ghost curve */ BLI_addtail(&sipo->ghostCurves, gcu); - + /* restore driver */ fcu->driver = driver; } - + /* admin and redraws */ ANIM_animdata_freelist(&anim_data); } @@ -411,39 +411,39 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op) bAnimContext ac; View2D *v2d; int start, end; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* ghost curves are snapshots of the visible portions of the curves, so set range to be the visible range */ v2d = &ac.ar->v2d; start = (int)v2d->cur.xmin; end = (int)v2d->cur.xmax; - + /* bake selected curves into a ghost curve */ create_ghost_curves(&ac, start, end); - + /* update this editor only */ ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_ghost_curves_create(wmOperatorType *ot) { /* identifiers */ ot->name = "Create Ghost Curves"; ot->idname = "GRAPH_OT_ghost_curves_create"; ot->description = "Create snapshot (Ghosts) of selected F-Curves as background aid for active Graph Editor"; - + /* api callbacks */ ot->exec = graphkeys_create_ghostcurves_exec; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + // todo: add props for start/end frames } @@ -454,36 +454,36 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; SpaceIpo *sipo; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; sipo = (SpaceIpo *)ac.sl; - + /* if no ghost curves, don't do anything */ if (BLI_listbase_is_empty(&sipo->ghostCurves)) return OPERATOR_CANCELLED; - + /* free ghost curves */ free_fcurves(&sipo->ghostCurves); - + /* update this editor only */ ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_ghost_curves_clear(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Ghost Curves"; ot->idname = "GRAPH_OT_ghost_curves_clear"; ot->description = "Clear F-Curve snapshots (Ghosts) for active Graph Editor"; - + /* api callbacks */ ot->exec = graphkeys_clear_ghostcurves_exec; ot->poll = ED_operator_graphedit_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -516,26 +516,26 @@ static const EnumPropertyItem prop_graphkeys_insertkey_types[] = { }; /* this function is responsible for snapping keyframes to frame-times */ -static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) +static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; size_t num_items; - + ReportList *reports = ac->reports; SpaceIpo *sipo = (SpaceIpo *)ac->sl; Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; short flag = 0; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (mode & GRAPHKEYS_INSERTKEY_SEL) filter |= ANIMFILTER_SEL; else if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) filter |= ANIMFILTER_ACTIVE; - + num_items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); if (num_items == 0) { if (mode & GRAPHKEYS_INSERTKEY_ACTIVE) @@ -544,26 +544,26 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) BKE_report(reports, RPT_ERROR, "No selected F-Curves to add keyframes to"); else BKE_report(reports, RPT_ERROR, "No channels to add keyframes to"); - + return; } - + /* init keyframing flag */ flag = ANIM_get_keyframing_flags(scene, 1); - + /* insert keyframes */ if (mode & GRAPHKEYS_INSERTKEY_CURSOR) { for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; - + short mapping_flag = ANIM_get_normalization_flags(ac); float offset; float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag, &offset); - + float x, y; - - + + /* perform time remapping for x-coordinate (if necessary) */ if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) x = sipo->cursorTime; @@ -571,16 +571,16 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) x = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); else x = (float)CFRA; - + /* normalise units of cursor's value */ if (sipo) y = (sipo->cursorVal / unit_scale) - offset; else y = 0.0f; - + /* insert keyframe directly into the F-Curve */ insert_vert_fcurve(fcu, x, y, ts->keyframe_type, 0); - + ale->update |= ANIM_UPDATE_DEFAULT; } } @@ -589,15 +589,15 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; float cfra; - + /* adjust current frame for NLA-mapping */ if ((sipo) && (sipo->mode == SIPO_MODE_DRIVERS)) cfra = sipo->cursorTime; else if (adt) cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); - else + else cfra = (float)CFRA; - + /* read value from property the F-Curve represents, or from the curve only? * - ale->id != NULL: Typically, this means that we have enough info to try resolving the path * - ale->owner != NULL: If this is set, then the path may not be resolvable from the ID alone, @@ -613,11 +613,11 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) const float curval = evaluate_fcurve(fcu, cfra); insert_vert_fcurve(fcu, cfra, curval, ts->keyframe_type, 0); } - + ale->update |= ANIM_UPDATE_DEFAULT; } } - + ANIM_animdata_update(ac, &anim_data); ANIM_animdata_freelist(&anim_data); } @@ -628,20 +628,20 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op) { bAnimContext ac; eGraphKeys_InsertKey_Types mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* which channels to affect? */ mode = RNA_enum_get(op->ptr, "type"); - + /* insert keyframes */ insert_graph_keys(&ac, mode); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } @@ -651,15 +651,15 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot) ot->name = "Insert Keyframes"; ot->idname = "GRAPH_OT_keyframe_insert"; ot->description = "Insert keyframes for the specified channels"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graphkeys_insertkey_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", ""); } @@ -673,11 +673,11 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) AnimData *adt; FCurve *fcu; float frame, val; - + /* get animation context */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get active F-Curve 'anim-list-element' */ ale = get_active_fcurve_channel(&ac); if (ELEM(NULL, ale, ale->data)) { @@ -685,17 +685,17 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } fcu = ale->data; - + /* when there are F-Modifiers on the curve, only allow adding * keyframes if these will be visible after doing so... */ if (fcurve_is_keyframable(fcu)) { ListBase anim_data; ToolSettings *ts = ac.scene->toolsettings; - + short mapping_flag = ANIM_get_normalization_flags(&ac); float scale, offset; - + /* preserve selection? */ if (RNA_boolean_get(op->ptr, "extend") == false) { /* deselect all keyframes first, so that we can immediately start manipulating the newly added one(s) @@ -703,28 +703,28 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) */ deselect_graph_keys(&ac, false, SELECT_SUBTRACT, false); } - + /* get frame and value from props */ frame = RNA_float_get(op->ptr, "frame"); val = RNA_float_get(op->ptr, "value"); - + /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */ adt = ANIM_nla_mapping_get(&ac, ale); frame = BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); - + /* apply inverse unit-mapping to value to get correct value for F-Curves */ scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, mapping_flag | ANIM_UNITCONV_RESTORE, &offset); - + val = val * scale - offset; - + /* insert keyframe on the specified frame + value */ insert_vert_fcurve(fcu, frame, val, ts->keyframe_type, 0); - + ale->update |= ANIM_UPDATE_DEPS; - + BLI_listbase_clear(&anim_data); BLI_addtail(&anim_data, ale); - + ANIM_animdata_update(&ac, &anim_data); } else { @@ -736,13 +736,13 @@ static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) else BKE_report(op->reports, RPT_ERROR, "Remove F-Modifiers from F-Curve to add keyframes"); } - + /* free temp data */ MEM_freeN(ale); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -754,23 +754,23 @@ static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, const wmEv View2D *v2d; int mval[2]; float x, y; - + /* get animation context */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* store mouse coordinates in View2D space, into the operator's properties */ ar = ac.ar; v2d = &ar->v2d; - + mval[0] = (event->x - ar->winrct.xmin); mval[1] = (event->y - ar->winrct.ymin); - + UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); - + RNA_float_set(op->ptr, "frame", x); RNA_float_set(op->ptr, "value", y); - + /* run exec now */ return graphkeys_click_insert_exec(C, op); } @@ -781,19 +781,19 @@ void GRAPH_OT_click_insert(wmOperatorType *ot) ot->name = "Click-Insert Keyframes"; ot->idname = "GRAPH_OT_click_insert"; ot->description = "Insert new keyframe at the cursor position for the active F-Curve"; - + /* api callbacks */ ot->invoke = graphkeys_click_insert_invoke; ot->exec = graphkeys_click_insert_exec; ot->poll = graphop_active_fcurve_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_float(ot->srna, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame Number", "Frame to insert keyframe on", 0, 100); RNA_def_float(ot->srna, "value", 1.0f, -FLT_MAX, FLT_MAX, "Value", "Value for keyframe on", 0, 100); - + RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); } @@ -801,20 +801,20 @@ void GRAPH_OT_click_insert(wmOperatorType *ot) /* NOTE: the backend code for this is shared with the dopesheet editor */ static short copy_graph_keys(bAnimContext *ac) -{ +{ ListBase anim_data = {NULL, NULL}; int filter, ok = 0; - + /* clear buffer first */ ANIM_fcurves_copybuf_free(); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* copy keyframes */ ok = copy_animedit_keys(ac, &anim_data); - + /* clean up */ ANIM_animdata_freelist(&anim_data); @@ -823,21 +823,21 @@ static short copy_graph_keys(bAnimContext *ac) static short paste_graph_keys(bAnimContext *ac, const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode, bool flip) -{ +{ ListBase anim_data = {NULL, NULL}; int filter, ok = 0; - - /* filter data - * - First time we try to filter more strictly, allowing only selected channels + + /* filter data + * - First time we try to filter more strictly, allowing only selected channels * to allow copying animation between channels * - Second time, we loosen things up if nothing was found the first time, allowing * users to just paste keyframes back into the original curve again [#31670] */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); - + if (ANIM_animdata_filter(ac, &anim_data, filter | ANIMFILTER_SEL, ac->data, ac->datatype) == 0) ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* paste keyframes */ ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode, flip); @@ -852,32 +852,32 @@ static short paste_graph_keys(bAnimContext *ac, static int graphkeys_copy_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* copy keyframes */ if (copy_graph_keys(&ac)) { BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer"); return OPERATOR_CANCELLED; } - + /* just return - no operator needed here (no changes) */ return OPERATOR_FINISHED; } - + void GRAPH_OT_copy(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy Keyframes"; ot->idname = "GRAPH_OT_copy"; ot->description = "Copy selected keyframes to the copy/paste buffer"; - + /* api callbacks */ ot->exec = graphkeys_copy_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -891,11 +891,11 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); const bool flipped = RNA_boolean_get(op->ptr, "flipped"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* ac.reports by default will be the global reports list, which won't show warnings */ ac.reports = op->reports; @@ -903,30 +903,30 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) if (paste_graph_keys(&ac, offset_mode, merge_mode, flipped)) { return OPERATOR_CANCELLED; } - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_paste(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Paste Keyframes"; ot->idname = "GRAPH_OT_paste"; ot->description = "Paste keyframes from copy/paste buffer for the selected channels, starting on the current frame"; - + /* api callbacks */ // ot->invoke = WM_operator_props_popup; // better wait for graph redo panel ot->exec = graphkeys_paste_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_enum(ot->srna, "offset", rna_enum_keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); RNA_def_enum(ot->srna, "merge", rna_enum_keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); @@ -941,11 +941,11 @@ static void duplicate_graph_keys(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and delete selected keys */ for (ale = anim_data.first; ale; ale = ale->next) { duplicate_fcurve_keys((FCurve *)ale->key_data); @@ -962,17 +962,17 @@ static void duplicate_graph_keys(bAnimContext *ac) static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* duplicate keyframes */ duplicate_graph_keys(&ac); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_ADDED, NULL); - + return OPERATOR_FINISHED; } @@ -982,14 +982,14 @@ void GRAPH_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Keyframes"; ot->idname = "GRAPH_OT_duplicate"; ot->description = "Make a copy of all selected keyframes"; - + /* api callbacks */ ot->exec = graphkeys_duplicate_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* to give to transform */ RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", ""); } @@ -1002,17 +1002,17 @@ static bool delete_graph_keys(bAnimContext *ac) bAnimListElem *ale; int filter; bool changed_final = false; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and delete selected keys */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; AnimData *adt = ale->adt; bool changed; - + /* delete selected keyframes only */ changed = delete_fcurve_keys(fcu); @@ -1020,7 +1020,7 @@ static bool delete_graph_keys(bAnimContext *ac) ale->update |= ANIM_UPDATE_DEFAULT; changed_final = true; } - + /* Only delete curve too if it won't be doing anything anymore */ if ((fcu->totvert == 0) && (list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE) == 0) && @@ -1042,33 +1042,33 @@ static bool delete_graph_keys(bAnimContext *ac) static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* delete keyframes */ if (!delete_graph_keys(&ac)) return OPERATOR_CANCELLED; - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_REMOVED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Keyframes"; ot->idname = "GRAPH_OT_delete"; ot->description = "Remove all selected keyframes"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = graphkeys_delete_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1076,15 +1076,15 @@ void GRAPH_OT_delete(wmOperatorType *ot) /* ******************** Clean Keyframes Operator ************************* */ static void clean_graph_keys(bAnimContext *ac, float thresh, bool clean_chan) -{ +{ ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and clean curves */ for (ale = anim_data.first; ale; ale = ale->next) { clean_fcurve(ac, ale, thresh, clean_chan); @@ -1103,38 +1103,38 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op) bAnimContext ac; float thresh; bool clean_chan; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get cleaning threshold */ thresh = RNA_float_get(op->ptr, "threshold"); clean_chan = RNA_boolean_get(op->ptr, "channels"); /* clean keyframes */ clean_graph_keys(&ac, thresh, clean_chan); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_clean(wmOperatorType *ot) { /* identifiers */ ot->name = "Clean Keyframes"; ot->idname = "GRAPH_OT_clean"; ot->description = "Simplify F-Curves by removing closely spaced keyframes"; - + /* api callbacks */ - //ot->invoke = // XXX we need that number popup for this! + //ot->invoke = // XXX we need that number popup for this! ot->exec = graphkeys_clean_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); RNA_def_boolean(ot->srna, "channels", false, "Channels", ""); @@ -1145,26 +1145,26 @@ void GRAPH_OT_clean(wmOperatorType *ot) /* Bake each F-Curve into a set of samples */ static void bake_graph_curves(bAnimContext *ac, int start, int end) -{ +{ ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and add keys between selected keyframes on every frame */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; ChannelDriver *driver = fcu->driver; - + /* disable driver so that it don't muck up the sampling process */ fcu->driver = NULL; - + /* create samples */ fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve); - + /* restore driver */ fcu->driver = driver; @@ -1182,42 +1182,42 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) bAnimContext ac; Scene *scene = NULL; int start, end; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* for now, init start/end from preview-range extents */ - // TODO: add properties for this + // TODO: add properties for this scene = ac.scene; start = PSFRA; end = PEFRA; - + /* bake keyframes */ bake_graph_curves(&ac, start, end); - + /* set notifier that keyframes have changed */ // NOTE: some distinction between order/number of keyframes and type should be made? WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_bake(wmOperatorType *ot) { /* identifiers */ ot->name = "Bake Curve"; ot->idname = "GRAPH_OT_bake"; ot->description = "Bake selected F-Curves to a set of sampled points defining a similar curve"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; // FIXME... ot->exec = graphkeys_bake_exec; - ot->poll = graphop_selected_fcurve_poll; - + ot->poll = graphop_selected_fcurve_poll; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + // todo: add props for start/end frames } @@ -1310,7 +1310,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) /* loop through all selected F-Curves, replacing its data with the sound samples */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* sample the sound */ fcurve_store_samples(fcu, &sbi, start, end, fcurve_samplingcb_sound); @@ -1401,15 +1401,15 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot) /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ static void sample_graph_keys(bAnimContext *ac) -{ +{ ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through filtered data and add keys between selected keyframes on every frame */ for (ale = anim_data.first; ale; ale = ale->next) { sample_fcurve((FCurve *)ale->key_data); @@ -1426,31 +1426,31 @@ static void sample_graph_keys(bAnimContext *ac) static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* sample keyframes */ sample_graph_keys(&ac); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_sample(wmOperatorType *ot) { /* identifiers */ ot->name = "Sample Keyframes"; ot->idname = "GRAPH_OT_sample"; ot->description = "Add keyframes on every frame between the selected keyframes"; - + /* api callbacks */ ot->exec = graphkeys_sample_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1469,27 +1469,27 @@ void GRAPH_OT_sample(wmOperatorType *ot) static const EnumPropertyItem prop_graphkeys_expo_types[] = { {FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", "Values on endpoint keyframes are held"}, {FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", "Straight-line slope of end segments are extended past the endpoint keyframes"}, - + {MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"}, {CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"}, {0, NULL, 0, NULL, NULL} }; /* this function is responsible for setting extrapolation mode for keyframes */ -static void setexpo_graph_keys(bAnimContext *ac, short mode) +static void setexpo_graph_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting mode per F-Curve */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - + if (mode >= 0) { /* just set mode setting */ fcu->extend = mode; @@ -1497,7 +1497,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) ale->update |= ANIM_UPDATE_HANDLES; } else { - /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation + /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation * without having to go through FModifier UI in Graph Editor to do so */ if (mode == MAKE_CYCLIC_EXPO) { @@ -1510,10 +1510,10 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ FModifier *fcm, *fcn = NULL; - + for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; - + if (fcm->type == FMODIFIER_TYPE_CYCLES) remove_fmodifier(&fcu->modifiers, fcm); } @@ -1533,38 +1533,38 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ setexpo_graph_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_extrapolation_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Extrapolation"; ot->idname = "GRAPH_OT_extrapolation_type"; ot->description = "Set extrapolation mode for selected F-Curves"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graphkeys_expo_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", ""); } @@ -1572,17 +1572,17 @@ void GRAPH_OT_extrapolation_type(wmOperatorType *ot) /* ******************** Set Interpolation-Type Operator *********************** */ /* this function is responsible for setting interpolation mode for keyframes */ -static void setipo_graph_keys(bAnimContext *ac, short mode) +static void setipo_graph_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ @@ -1602,38 +1602,38 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ setipo_graph_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_interpolation_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Interpolation"; ot->idname = "GRAPH_OT_interpolation_type"; ot->description = "Set interpolation mode for the F-Curve segments starting from the selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graphkeys_ipo_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_mode_items, 0, "Type", ""); } @@ -1646,11 +1646,11 @@ static void seteasing_graph_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; KeyframeEditFunc set_cb = ANIM_editkeyframes_easing(mode); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through setting BezTriple easing * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ @@ -1668,20 +1668,20 @@ static int graphkeys_easing_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ seteasing_graph_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } @@ -1691,15 +1691,15 @@ void GRAPH_OT_easing_type(wmOperatorType *ot) ot->name = "Set Keyframe Easing Type"; ot->idname = "GRAPH_OT_easing_type"; ot->description = "Set easing type for the F-Curve segments starting from the selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graphkeys_easing_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_beztriple_interpolation_easing_items, 0, "Type", ""); } @@ -1707,25 +1707,25 @@ void GRAPH_OT_easing_type(wmOperatorType *ot) /* ******************** Set Handle-Type Operator *********************** */ /* this function is responsible for setting handle-type of selected keyframes */ -static void sethandles_graph_keys(bAnimContext *ac, short mode) +static void sethandles_graph_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode); KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - - /* loop through setting flags for handles + + /* loop through setting flags for handles * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { /* change type of selected handles */ @@ -1744,38 +1744,38 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get handle setting mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* set handle type */ sethandles_graph_keys(&ac, mode); - + /* set notifier that keyframe properties have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_handle_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Handle Type"; ot->idname = "GRAPH_OT_handle_type"; ot->description = "Set type of handle for selected keyframes"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graphkeys_handletype_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_keyframe_handle_type_items, 0, "Type", ""); } @@ -1793,43 +1793,43 @@ void GRAPH_OT_handle_type(wmOperatorType *ot) /* set of three euler-rotation F-Curves */ typedef struct tEulerFilter { struct tEulerFilter *next, *prev; - + ID *id; /* ID-block which owns the channels */ FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */ const char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */ } tEulerFilter; - + static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + ListBase eulers = {NULL, NULL}; tEulerFilter *euf = NULL; int groups = 0, failed = 0; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* The process is done in two passes: * 1) Sets of three related rotation curves are identified from the selected channels, * and are stored as a single 'operation unit' for the next step * 2) Each set of three F-Curves is processed for each keyframe, with the values being * processed as necessary */ - + /* step 1: extract only the rotation f-curves */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - - /* check if this is an appropriate F-Curve + + /* check if this is an appropriate F-Curve * - only rotation curves * - for pchan curves, make sure we're only using the euler curves */ @@ -1841,9 +1841,9 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) (ale->id) ? ale->id->name : TIP_(""), fcu->rna_path, fcu->array_index); continue; } - + /* optimization: assume that xyz curves will always be stored consecutively, - * so if the paths or the ID's don't match up, then a curve needs to be added + * so if the paths or the ID's don't match up, then a curve needs to be added * to a new group */ if ((euf) && (euf->id == ale->id) && (STREQ(euf->rna_path, fcu->rna_path))) { @@ -1855,7 +1855,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter"); BLI_addtail(&eulers, euf); groups++; - + euf->id = ale->id; euf->rna_path = fcu->rna_path; /* this should be safe, since we're only using it for a short time */ euf->fcurves[fcu->array_index] = fcu; @@ -1869,13 +1869,13 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No Euler Rotation F-Curves to fix up"); return OPERATOR_CANCELLED; } - - /* step 2: go through each set of curves, processing the values at each keyframe + + /* step 2: go through each set of curves, processing the values at each keyframe * - it is assumed that there must be a full set of keyframes at each keyframe position */ for (euf = eulers.first; euf; euf = euf->next) { int f; - + /* sanity check: ensure that there are enough F-Curves to work on in this group */ /* TODO: also enforce assumption that there be a full set of keyframes at each position by ensuring that totvert counts are same? */ if (ELEM(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) { @@ -1886,7 +1886,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) (euf->fcurves[1] == NULL) ? "Y" : "", (euf->fcurves[2] == NULL) ? "Z" : "", euf->id->name, euf->rna_path); - + /* keep track of number of failed sets, and carry on to next group */ failed++; continue; @@ -1898,21 +1898,21 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) FCurve *fcu = euf->fcurves[f]; BezTriple *bezt, *prev; unsigned int i; - + /* skip if not enough vets to do a decent analysis of... */ if (fcu->totvert <= 2) continue; - + /* prev follows bezt, bezt = "current" point to be fixed */ /* our method depends on determining a "difference" from the previous vert */ for (i = 1, prev = fcu->bezt, bezt = fcu->bezt + 1; i < fcu->totvert; i++, prev = bezt++) { const float sign = (prev->vec[1][1] > bezt->vec[1][1]) ? 1.0f : -1.0f; - + /* > 180 degree flip? */ if ((sign * (prev->vec[1][1] - bezt->vec[1][1])) >= (float)M_PI) { /* 360 degrees to add/subtract frame value until difference is acceptably small that there's no more flip */ const float fac = sign * 2.0f * (float)M_PI; - + while ((sign * (prev->vec[1][1] - bezt->vec[1][1])) >= (float)M_PI) { bezt->vec[0][1] += fac; bezt->vec[1][1] += fac; @@ -1923,13 +1923,13 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) } } BLI_freelistN(&eulers); - + ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); /* updates + finishing warnings */ if (failed == groups) { - BKE_report(op->reports, RPT_ERROR, + BKE_report(op->reports, RPT_ERROR, "No Euler Rotations could be corrected, ensure each rotation has keys for all components, " "and that F-Curves for these are in consecutive XYZ order and selected"); return OPERATOR_CANCELLED; @@ -1941,15 +1941,15 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) "ensure each rotation has keys for all components, and that F-Curves for these are in " "consecutive XYZ order and selected"); } - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + /* done at last */ return OPERATOR_FINISHED; } } - + void GRAPH_OT_euler_filter(wmOperatorType *ot) { /* identifiers */ @@ -1958,11 +1958,11 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot) ot->description = "Fix large jumps and flips in the selected " "Euler Rotation F-Curves arising from rotation " "values being clipped when baking physics"; - + /* api callbacks */ ot->exec = graphkeys_euler_filter_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1986,18 +1986,18 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) bAnimListElem *ale; int filter; KeyframeEditData ked; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* init edit data */ memset(&ked, 0, sizeof(KeyframeEditData)); - + /* loop over action data, averaging values */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(&ac, ale); short mapping_flag = ANIM_get_normalization_flags(&ac); @@ -2008,9 +2008,9 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) memset(¤t_ked, 0, sizeof(current_ked)); if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(¤t_ked, ale->key_data, NULL, bezt_calc_average, NULL); - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } else ANIM_fcurve_keyframes_loop(¤t_ked, ale->key_data, NULL, bezt_calc_average, NULL); @@ -2020,14 +2020,14 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) ked.f2 += (current_ked.f2 + offset) * unit_scale; ked.i2 += current_ked.i2; } - + ANIM_animdata_freelist(&anim_data); - + /* set the new current frame and cursor values, based on the average time and value */ if (ked.i1) { SpaceIpo *sipo = (SpaceIpo *)ac.sl; Scene *scene = ac.scene; - + /* take the average values, rounding to the nearest int as necessary for int results */ if (sipo->mode == SIPO_MODE_DRIVERS) { /* Drivers Mode - Affects cursor (float) */ @@ -2041,10 +2041,10 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) sipo->cursorVal = ked.f2 / (float)ked.i1; } } - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); - + return OPERATOR_FINISHED; } @@ -2054,11 +2054,11 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot) ot->name = "Jump to Keyframes"; ot->idname = "GRAPH_OT_frame_jump"; ot->description = "Place the cursor on the midpoint of selected keyframes"; - + /* api callbacks */ ot->exec = graphkeys_framejump_exec; ot->poll = graphkeys_framejump_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2083,23 +2083,23 @@ static const EnumPropertyItem prop_graphkeys_snap_types[] = { }; /* this function is responsible for snapping keyframes to frame-times */ -static void snap_graph_keys(bAnimContext *ac, short mode) +static void snap_graph_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked; KeyframeEditFunc edit_cb; float cursor_value = 0.0f; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* init custom data for iterating over keyframes */ - memset(&ked, 0, sizeof(KeyframeEditData)); + memset(&ked, 0, sizeof(KeyframeEditData)); ked.scene = ac->scene; if (mode == GRAPHKEYS_SNAP_NEAREST_MARKER) { ked.list.first = (ac->markers) ? ac->markers->first : NULL; @@ -2117,32 +2117,32 @@ static void snap_graph_keys(bAnimContext *ac, short mode) mode = SNAP_KEYS_TIME; } } - + /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_snap(mode); - + /* snap keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* normalise cursor value (for normalised F-Curves display) */ if (mode == GRAPHKEYS_SNAP_VALUE) { short mapping_flag = ANIM_get_normalization_flags(ac); float offset; float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag, &offset); - + ked.f1 = (cursor_value / unit_scale) - offset; } - + /* perform snapping */ if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } - else + else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); - + ale->update |= ANIM_UPDATE_DEFAULT; } @@ -2156,38 +2156,38 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get snapping mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* snap keyframes */ snap_graph_keys(&ac, mode); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_snap(wmOperatorType *ot) { /* identifiers */ ot->name = "Snap Keys"; ot->idname = "GRAPH_OT_snap"; ot->description = "Snap selected keyframes to the chosen times/values"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graphkeys_snap_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_snap_types, 0, "Type", ""); } @@ -2210,28 +2210,28 @@ static const EnumPropertyItem prop_graphkeys_mirror_types[] = { }; /* this function is responsible for mirroring keyframes */ -static void mirror_graph_keys(bAnimContext *ac, short mode) +static void mirror_graph_keys(bAnimContext *ac, short mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked; KeyframeEditFunc edit_cb; float cursor_value = 0.0f; /* init custom data for looping over keyframes */ - memset(&ked, 0, sizeof(KeyframeEditData)); + memset(&ked, 0, sizeof(KeyframeEditData)); ked.scene = ac->scene; - + /* store mode-specific custom data... */ if (mode == GRAPHKEYS_MIRROR_MARKER) { TimeMarker *marker = NULL; - + /* find first selected marker */ marker = ED_markers_get_first_selected(ac->markers); - + /* store marker's time (if available) */ if (marker) ked.f1 = (float)marker->frame; @@ -2250,36 +2250,36 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) mode = MIRROR_KEYS_TIME; } } - + /* get beztriple editing callbacks */ edit_cb = ANIM_editkeyframes_mirror(mode); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* mirror keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* apply unit corrections */ if (mode == GRAPHKEYS_MIRROR_VALUE) { short mapping_flag = ANIM_get_normalization_flags(ac); float offset; float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, ale->key_data, mapping_flag | ANIM_UNITCONV_ONLYKEYS, &offset); - + ked.f1 = (cursor_value + offset) * unit_scale; } - + /* perform actual mirroring */ if (adt) { - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } - else + else ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); - + ale->update |= ANIM_UPDATE_DEFAULT; } @@ -2293,38 +2293,38 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get mirroring mode */ mode = RNA_enum_get(op->ptr, "type"); - + /* mirror keyframes */ mirror_graph_keys(&ac, mode); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_mirror(wmOperatorType *ot) { /* identifiers */ ot->name = "Mirror Keys"; ot->idname = "GRAPH_OT_mirror"; ot->description = "Flip selected keyframes over the selected mirror line"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graphkeys_mirror_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_mirror_types, 0, "Type", ""); } @@ -2337,15 +2337,15 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op)) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* smooth keyframes */ for (ale = anim_data.first; ale; ale = ale->next) { /* For now, we can only smooth by flattening handles AND smoothing curve values. @@ -2359,24 +2359,24 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_smooth(wmOperatorType *ot) { /* identifiers */ ot->name = "Smooth Keys"; ot->idname = "GRAPH_OT_smooth"; ot->description = "Apply weighted moving means to make selected F-Curves less bumpy"; - + /* api callbacks */ ot->exec = graphkeys_smooth_exec; ot->poll = graphop_editable_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2391,29 +2391,29 @@ static const EnumPropertyItem *graph_fmodifier_itemf(bContext *C, PointerRNA *UN EnumPropertyItem *item = NULL; int totitem = 0; int i = 0; - + if (C == NULL) { return rna_enum_fmodifier_type_items; } - + /* start from 1 to skip the 'Invalid' modifier type */ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i); int index; - + /* check if modifier is valid for this context */ if (fmi == NULL) continue; - + index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type); if (index != -1) { /* Not all types are implemented yet... */ RNA_enum_item_add(&item, &totitem, &rna_enum_fmodifier_type_items[index]); } } - + RNA_enum_item_end(&item, &totitem); *r_free = true; - + return item; } @@ -2424,14 +2424,14 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) bAnimListElem *ale; int filter; short type; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get type of modifier to add */ type = RNA_enum_get(op->ptr, "type"); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (RNA_boolean_get(op->ptr, "only_active")) @@ -2439,12 +2439,12 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) else filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* add f-modifier to each curve */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; FModifier *fcm; - + /* add F-Modifier of specified type to active F-Curve, and make it the active one */ fcm = add_fmodifier(&fcu->modifiers, type, fcu); if (fcm) { @@ -2454,41 +2454,41 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Modifier could not be added (see console for details)"); break; } - + ale->update |= ANIM_UPDATE_DEPS; } - + ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_fmodifier_add(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Add F-Curve Modifier"; ot->idname = "GRAPH_OT_fmodifier_add"; ot->description = "Add F-Modifier to the active/selected F-Curves"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = graph_fmodifier_add_exec; - ot->poll = graphop_selected_fcurve_poll; - + ot->poll = graphop_selected_fcurve_poll; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ prop = RNA_def_enum(ot->srna, "type", rna_enum_fmodifier_type_items, 0, "Type", ""); RNA_def_enum_funcs(prop, graph_fmodifier_itemf); ot->prop = prop; - + RNA_def_boolean(ot->srna, "only_active", 1, "Only Active", "Only add F-Modifier to active F-Curve"); } @@ -2499,28 +2499,28 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op) bAnimContext ac; bAnimListElem *ale; bool ok = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* clear buffer first */ ANIM_fmodifiers_copybuf_free(); - + /* get the active F-Curve */ ale = get_active_fcurve_channel(&ac); - + /* if this exists, call the copy F-Modifiers API function */ if (ale && ale->data) { FCurve *fcu = (FCurve *)ale->data; - + /* TODO: when 'active' vs 'all' boolean is added, change last param! */ ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0); - + /* free temp data now */ MEM_freeN(ale); } - + /* successful or not? */ if (ok == 0) { BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied"); @@ -2529,21 +2529,21 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op) else return OPERATOR_FINISHED; } - + void GRAPH_OT_fmodifier_copy(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy F-Modifiers"; ot->idname = "GRAPH_OT_fmodifier_copy"; ot->description = "Copy the F-Modifier(s) of the active F-Curve"; - + /* api callbacks */ ot->exec = graph_fmodifier_copy_exec; - ot->poll = graphop_active_fcurve_poll; - + ot->poll = graphop_active_fcurve_poll; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one"); } @@ -2553,18 +2553,18 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot) static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + const bool replace = RNA_boolean_get(op->ptr, "replace"); bool ok = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* filter data */ if (RNA_boolean_get(op->ptr, "only_active")) { /* This should be the default (for buttons) - Just paste to the active FCurve */ @@ -2574,32 +2574,32 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) /* This is only if the operator gets called from a hotkey or search - Paste to all visible curves */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); } - + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* paste modifiers */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; int tot; - + tot = ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, replace, fcu); - + if (tot) { ale->update |= ANIM_UPDATE_DEPS; ok = true; } } - + if (ok) { ANIM_animdata_update(&ac, &anim_data); } ANIM_animdata_freelist(&anim_data); - + /* successful or not? */ if (ok) { /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } else { @@ -2607,24 +2607,24 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } } - + void GRAPH_OT_fmodifier_paste(wmOperatorType *ot) { /* identifiers */ ot->name = "Paste F-Modifiers"; ot->idname = "GRAPH_OT_fmodifier_paste"; ot->description = "Add copied F-Modifiers to the selected F-Curves"; - + /* api callbacks */ ot->exec = graph_fmodifier_paste_exec; ot->poll = graphop_active_fcurve_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only paste F-Modifiers on active F-Curve"); - RNA_def_boolean(ot->srna, "replace", false, "Replace Existing", + RNA_def_boolean(ot->srna, "replace", false, "Replace Existing", "Replace existing F-Modifiers, instead of just appending to the end of the existing list"); } @@ -2638,45 +2638,45 @@ static int graph_driver_vars_copy_exec(bContext *C, wmOperator *op) bAnimContext ac; bAnimListElem *ale; bool ok = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* clear buffer first */ ANIM_driver_vars_copybuf_free(); - + /* get the active F-Curve */ ale = get_active_fcurve_channel(&ac); - + /* if this exists, call the copy driver vars API function */ if (ale && ale->data) { FCurve *fcu = (FCurve *)ale->data; - + ok = ANIM_driver_vars_copy(op->reports, fcu); - + /* free temp data now */ MEM_freeN(ale); } - + /* successful or not? */ if (ok) return OPERATOR_FINISHED; else return OPERATOR_CANCELLED; } - + void GRAPH_OT_driver_variables_copy(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy Driver Variables"; ot->idname = "GRAPH_OT_driver_variables_copy"; ot->description = "Copy the driver variables of the active F-Curve"; - + /* api callbacks */ ot->exec = graph_driver_vars_copy_exec; - ot->poll = graphop_active_fcurve_poll; - + ot->poll = graphop_active_fcurve_poll; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2686,62 +2686,62 @@ void GRAPH_OT_driver_variables_copy(wmOperatorType *ot) static int graph_driver_vars_paste_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + const bool replace = RNA_boolean_get(op->ptr, "replace"); bool ok = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* paste variables */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; ok |= ANIM_driver_vars_paste(op->reports, fcu, replace); } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); - + /* successful or not? */ if (ok) { /* rebuild depsgraph, now that there are extra deps here */ DAG_relations_tag_update(CTX_data_main(C)); - + /* set notifier that keyframes have changed */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, CTX_data_scene(C)); - + return OPERATOR_FINISHED; } else { return OPERATOR_CANCELLED; } } - + void GRAPH_OT_driver_variables_paste(wmOperatorType *ot) { /* identifiers */ ot->name = "Paste Driver Variables"; ot->idname = "GRAPH_OT_driver_variables_paste"; ot->description = "Add copied driver variables to the active driver"; - + /* api callbacks */ ot->exec = graph_driver_vars_paste_exec; ot->poll = graphop_active_fcurve_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ - RNA_def_boolean(ot->srna, "replace", false, "Replace Existing", + RNA_def_boolean(ot->srna, "replace", false, "Replace Existing", "Replace existing driver variables, instead of just appending to the end of the existing list"); } diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index d0241f09f04..da352d4ea06 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -87,7 +87,7 @@ enum eGraphKeys_ColumnSelect_Mode { /* ***************************************** */ /* graph_edit.c */ -void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, +void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const bool do_selected, const bool include_handles); void GRAPH_OT_previewrange_set(struct wmOperatorType *ot); @@ -119,7 +119,7 @@ void GRAPH_OT_frame_jump(struct wmOperatorType *ot); void GRAPH_OT_snap(struct wmOperatorType *ot); void GRAPH_OT_mirror(struct wmOperatorType *ot); -/* defines for snap keyframes +/* defines for snap keyframes * NOTE: keep in sync with eEditKeyframes_Snap (in ED_keyframes_edit.h) */ enum eGraphKeys_Snap_Mode { @@ -131,7 +131,7 @@ enum eGraphKeys_Snap_Mode { GRAPHKEYS_SNAP_VALUE, }; -/* defines for mirror keyframes +/* defines for mirror keyframes * NOTE: keep in sync with eEditKeyframes_Mirror (in ED_keyframes_edit.h) */ enum eGraphKeys_Mirror_Mode { diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 48d4e9ff8eb..b90fdd9ac67 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -83,19 +83,19 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); SpaceIpo *sipo = CTX_wm_space_graph(C); float frame = RNA_float_get(op->ptr, "frame"); /* this isn't technically "frame", but it'll do... */ - + /* adjust the frame or the cursor x-value */ if (sipo->mode == SIPO_MODE_DRIVERS) { /* adjust cursor x-value */ sipo->cursorTime = frame; } else { - /* adjust the frame + /* adjust the frame * NOTE: sync this part of the code with ANIM_OT_change_frame */ /* 1) frame is rounded to the nearest int, since frames are ints */ CFRA = round_fl_to_int(frame); - + if (scene->r.flag & SCER_LOCK_FRAME_SELECTION) { /* Clip to preview range * NOTE: Preview range won't go into negative values, @@ -107,14 +107,14 @@ static void graphview_cursor_apply(bContext *C, wmOperator *op) /* Prevent negative frames */ FRAMENUMBER_MIN_CLAMP(CFRA); } - + SUBFRA = 0.0f; BKE_sound_seek_scene(bmain, scene); } - + /* set the cursor value */ sipo->cursorVal = RNA_float_get(op->ptr, "value"); - + /* send notifiers - notifiers for frame should force an update for both vars ok... */ WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } @@ -135,14 +135,14 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent { ARegion *ar = CTX_wm_region(C); float viewx, viewy; - + /* abort if not active region (should not really be possible) */ if (ar == NULL) return; - + /* convert from region coordinates to View2D 'tot' space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); - + /* store the values in the operator properties */ /* NOTE: we don't clamp frame here, as it might be used for the drivers cursor */ RNA_float_set(op->ptr, "frame", viewx); @@ -153,18 +153,18 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, const wmEvent static int graphview_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event) { bScreen *screen = CTX_wm_screen(C); - + /* Change to frame that mouse is over before adding modal handler, * as user could click on a single frame (jump to frame) as well as * click-dragging over a range (modal scrubbing). Apply this change. */ graphview_cursor_setprops(C, op, event); graphview_cursor_apply(C, op); - + /* Signal that a scrubbing operating is starting */ if (screen) screen->scrubbing = true; - + /* add temp handler */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -175,32 +175,32 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, const wmEvent *ev { bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); - + /* execute the events */ switch (event->type) { case ESCKEY: if (screen) screen->scrubbing = false; - + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; - + case MOUSEMOVE: /* set the new values */ graphview_cursor_setprops(C, op, event); graphview_cursor_apply(C, op); break; - - case LEFTMOUSE: + + case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: - /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init + /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ if (event->val == KM_RELEASE) { if (screen) screen->scrubbing = false; - + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -216,13 +216,13 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot) ot->name = "Set Cursor"; ot->idname = "GRAPH_OT_cursor_set"; ot->description = "Interactively set the current frame and value cursor"; - + /* api callbacks */ ot->exec = graphview_cursor_exec; ot->invoke = graphview_cursor_invoke; ot->modal = graphview_cursor_modal; ot->poll = graphview_cursor_poll; - + /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; @@ -241,39 +241,39 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) bAnimListElem *ale; int filter; const bool unselected = RNA_boolean_get(op->ptr, "unselected"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - - /* get list of all channels that selection may need to be flushed to + + /* get list of all channels that selection may need to be flushed to * - hierarchy must not affect what we have access to here... */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); - + /* filter data - * - of the remaining visible curves, we want to hide the ones that are - * selected/unselected (depending on "unselected" prop) + * - of the remaining visible curves, we want to hide the ones that are + * selected/unselected (depending on "unselected" prop) */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); if (unselected) filter |= ANIMFILTER_UNSEL; else filter |= ANIMFILTER_SEL; - + ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ /* TODO: find out why this is the case, and fix that */ if (ale->type == ANIMTYPE_OBJECT) continue; - + /* change the hide setting, and unselect it... */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR); ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_SELECT, ACHANNEL_SETFLAG_CLEAR); - + /* now, also flush selection status up/down as appropriate */ ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR); } @@ -281,7 +281,7 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) /* cleanup */ ANIM_animdata_freelist(&anim_data); BLI_freelistN(&all_data); - + /* unhide selected */ if (unselected) { /* turn off requirement for visible */ @@ -295,21 +295,21 @@ static int graphview_curves_hide_exec(bContext *C, wmOperator *op) /* TODO: find out why this is the case, and fix that */ if (ale->type == ANIMTYPE_OBJECT) continue; - + /* change the hide setting, and unselect it... */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_SELECT, ACHANNEL_SETFLAG_ADD); - + /* now, also flush selection status up/down as appropriate */ ANIM_flush_setting_anim_channels(&ac, &anim_data, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); } - ANIM_animdata_freelist(&anim_data); + ANIM_animdata_freelist(&anim_data); } - - + + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -319,14 +319,14 @@ static void GRAPH_OT_hide(wmOperatorType *ot) ot->name = "Hide Curves"; ot->idname = "GRAPH_OT_hide"; ot->description = "Hide selected curves from Graph Editor view"; - + /* api callbacks */ ot->exec = graphview_curves_hide_exec; ot->poll = ED_operator_graphedit_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected curves"); } @@ -341,50 +341,50 @@ static int graphview_curves_reveal_exec(bContext *C, wmOperator *op) bAnimListElem *ale; int filter; const bool select = RNA_boolean_get(op->ptr, "select"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - - /* get list of all channels that selection may need to be flushed to + + /* get list of all channels that selection may need to be flushed to * - hierarchy must not affect what we have access to here... */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); - + /* filter data * - just go through all visible channels, ensuring that everything is set to be curve-visible */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ /* TODO: find out why this is the case, and fix that */ if (ale->type == ANIMTYPE_OBJECT) continue; - + /* select if it is not visible */ if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE) == 0) { ANIM_channel_setting_set( &ac, ale, ACHANNEL_SETTING_SELECT, select ? ACHANNEL_SETFLAG_ADD : ACHANNEL_SETFLAG_CLEAR); } - + /* change the visibility setting */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_ADD); - + /* now, also flush selection status up/down as appropriate */ ANIM_flush_setting_anim_channels(&ac, &all_data, ale, ACHANNEL_SETTING_VISIBLE, true); } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); BLI_freelistN(&all_data); - + /* send notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); - + return OPERATOR_FINISHED; } @@ -394,11 +394,11 @@ static void GRAPH_OT_reveal(wmOperatorType *ot) ot->name = "Reveal Curves"; ot->idname = "GRAPH_OT_reveal"; ot->description = "Make previously hidden curves visible again in Graph Editor view"; - + /* api callbacks */ ot->exec = graphview_curves_reveal_exec; ot->poll = ED_operator_graphedit_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -411,19 +411,19 @@ void graphedit_operatortypes(void) { /* view */ WM_operatortype_append(GRAPH_OT_cursor_set); - + WM_operatortype_append(GRAPH_OT_previewrange_set); WM_operatortype_append(GRAPH_OT_view_all); WM_operatortype_append(GRAPH_OT_view_selected); WM_operatortype_append(GRAPH_OT_properties); WM_operatortype_append(GRAPH_OT_view_frame); - + WM_operatortype_append(GRAPH_OT_ghost_curves_create); WM_operatortype_append(GRAPH_OT_ghost_curves_clear); - + WM_operatortype_append(GRAPH_OT_hide); WM_operatortype_append(GRAPH_OT_reveal); - + /* keyframes */ /* selection */ WM_operatortype_append(GRAPH_OT_clickselect); @@ -436,7 +436,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_select_more); WM_operatortype_append(GRAPH_OT_select_less); WM_operatortype_append(GRAPH_OT_select_leftright); - + /* editing */ WM_operatortype_append(GRAPH_OT_snap); WM_operatortype_append(GRAPH_OT_mirror); @@ -453,18 +453,18 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_euler_filter); WM_operatortype_append(GRAPH_OT_delete); WM_operatortype_append(GRAPH_OT_duplicate); - + WM_operatortype_append(GRAPH_OT_copy); WM_operatortype_append(GRAPH_OT_paste); - + WM_operatortype_append(GRAPH_OT_keyframe_insert); WM_operatortype_append(GRAPH_OT_click_insert); - + /* F-Curve Modifiers */ WM_operatortype_append(GRAPH_OT_fmodifier_add); WM_operatortype_append(GRAPH_OT_fmodifier_copy); WM_operatortype_append(GRAPH_OT_fmodifier_paste); - + /* Drivers */ WM_operatortype_append(GRAPH_OT_driver_variables_copy); WM_operatortype_append(GRAPH_OT_driver_variables_paste); @@ -475,7 +475,7 @@ void ED_operatormacros_graph(void) { wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - + ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", "Make a copy of all selected keyframes and move them", OPTYPE_UNDO | OPTYPE_REGISTER); @@ -491,7 +491,7 @@ void ED_operatormacros_graph(void) static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; - + /* view */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.show_handles"); @@ -500,8 +500,8 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) * This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values */ WM_keymap_add_item(keymap, "GRAPH_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); - - + + /* graph_select.c - selection tools */ /* click-select: keyframe (replace) */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); @@ -533,7 +533,7 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "extend", true); RNA_boolean_set(kmi->ptr, "curves", true); RNA_boolean_set(kmi->ptr, "column", false); - + /* click-select left/right */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", false); @@ -541,20 +541,20 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); - + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); - + /* deselect all */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "invert", false); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "invert", true); - + /* borderselect */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "axis_range", false); @@ -562,68 +562,68 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "axis_range", true); RNA_boolean_set(kmi->ptr, "include_handles", false); - + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "axis_range", false); RNA_boolean_set(kmi->ptr, "include_handles", true); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "axis_range", true); RNA_boolean_set(kmi->ptr, "include_handles", true); - + /* region select */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "deselect", true); - + WM_keymap_add_item(keymap, "GRAPH_OT_select_circle", CKEY, KM_PRESS, 0, 0); - + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN); - + /* select more/less */ WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - + /* select linked */ WM_keymap_add_item(keymap, "GRAPH_OT_select_linked", LKEY, KM_PRESS, 0, 0); - - + + /* graph_edit.c */ /* jump to selected keyframes */ WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", GKEY, KM_PRESS, KM_CTRL, 0); - + /* menu + single-step transform */ WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "GRAPH_OT_handle_type", VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_interpolation_type", TKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_easing_type", EKEY, KM_PRESS, KM_CTRL, 0); - + /* destructive */ WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "GRAPH_OT_bake", CKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_menu(keymap, "GRAPH_MT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "GRAPH_MT_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - + /* insertkey */ WM_keymap_add_item(keymap, "GRAPH_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", false); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", ACTIONMOUSE, KM_CLICK, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); - + /* copy/paste */ WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); @@ -648,16 +648,16 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) /* F-Modifiers */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "only_active", false); - + /* animation module */ /* channels list * NOTE: these operators were originally for the channels list, but are added here too for convenience... */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); - + /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_IPO); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_proportional_fcurve"); @@ -665,15 +665,15 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point"); RNA_string_set(kmi->ptr, "value", "BOUNDING_BOX_CENTER"); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point"); RNA_string_set(kmi->ptr, "value", "CURSOR"); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", PERIODKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point"); RNA_string_set(kmi->ptr, "value", "INDIVIDUAL_ORIGINS"); - + /* special markers hotkeys for anim editors: see note in definition of this function */ ED_marker_keymap_animedit_conflictfree(keymap); } @@ -684,33 +684,33 @@ void graphedit_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + /* keymap for all regions */ keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0); WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0); - + /* extrapolation works on channels, not keys */ WM_keymap_add_item(keymap, "GRAPH_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); - + /* find (i.e. a shortcut for setting the name filter) */ WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); - + /* hide/reveal selected curves */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_hide", HKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "unselected", false); - + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "unselected", true); - + WM_keymap_add_item(keymap, "GRAPH_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); - - + + /* channels */ - /* Channels are not directly handled by the Graph Editor module, but are inherited from the Animation module. + /* Channels are not directly handled by the Graph Editor module, but are inherited from the Animation module. * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these * are all used for the Graph Editor too. */ - + /* keyframes */ keymap = WM_keymap_find(keyconf, "Graph Editor", SPACE_IPO, 0); graphedit_keymap_keyframes(keyconf, keymap); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 98cd847b427..ed9bed19d20 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -88,20 +88,20 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked = {{NULL}}; KeyframeEditFunc test_cb, sel_cb; - + /* determine type-based settings */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); - + /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* init BezTriple looping data */ test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); - + /* See if we should be selecting or deselecting */ if (test) { for (ale = anim_data.first; ale; ale = ale->next) { @@ -111,17 +111,17 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel } } } - + /* convert sel to selectmode, and use that to get editor */ sel_cb = ANIM_editkeyframes_select(sel); - + /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* Keyframes First */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); - + /* affect channel selection status? */ if (do_channels) { /* only change selection of channel when the visibility of keyframes doesn't depend on this */ @@ -129,17 +129,17 @@ void deselect_graph_keys(bAnimContext *ac, bool test, short sel, bool do_channel /* deactivate the F-Curve, and deselect if deselecting keyframes. * otherwise select the F-Curve too since we've selected all the keyframes */ - if (sel == SELECT_SUBTRACT) + if (sel == SELECT_SUBTRACT) fcu->flag &= ~FCURVE_SELECTED; else fcu->flag |= FCURVE_SELECTED; } - + /* always deactivate all F-Curves if we perform batch ops for selection */ fcu->flag &= ~FCURVE_ACTIVE; } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -150,56 +150,56 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; bAnimListElem *ale_active = NULL; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - - /* find active F-Curve, and preserve this for later + + /* find active F-Curve, and preserve this for later * or else it becomes annoying with the current active * curve keeps fading out even while you're editing it */ ale_active = get_active_fcurve_channel(&ac); - + /* 'standard' behavior - check if selected, then apply relevant selection */ if (RNA_boolean_get(op->ptr, "invert")) deselect_graph_keys(&ac, 0, SELECT_INVERT, true); else deselect_graph_keys(&ac, 1, SELECT_ADD, true); - + /* restore active F-Curve... */ if (ale_active) { FCurve *fcu = (FCurve *)ale_active->data; - - /* all others should not be disabled, so we should be able to just set this directly... + + /* all others should not be disabled, so we should be able to just set this directly... * - selection needs to be set too, or else this won't work... */ fcu->flag |= (FCURVE_SELECTED | FCURVE_ACTIVE); - + MEM_freeN(ale_active); ale_active = NULL; } - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "GRAPH_OT_select_all_toggle"; ot->description = "Toggle selection of all keyframes"; - + /* api callbacks */ ot->exec = graphkeys_deselectall_exec; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); } @@ -226,24 +226,24 @@ static void borderselect_graphkeys( ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter, mapping_flag; - + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; View2D *v2d = &ac->ar->v2d; rctf rectf, scaled_rectf; - + /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ UI_view2d_region_to_view_rctf(v2d, rectf_view, &rectf); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get beztriple editing/validation funcs */ select_cb = ANIM_editkeyframes_select(selectmode); ok_cb = ANIM_editkeyframes_ok(mode); - + /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); if (mode == BEZT_OK_REGION_LASSO) { @@ -259,7 +259,7 @@ static void borderselect_graphkeys( else { ked.data = &scaled_rectf; } - + /* treat handles separately? */ if (incl_handles) { ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES; @@ -267,29 +267,29 @@ static void borderselect_graphkeys( } else mapping_flag = ANIM_UNITCONV_ONLYKEYS; - + mapping_flag |= ANIM_get_normalization_flags(ac); - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); FCurve *fcu = (FCurve *)ale->key_data; float offset; float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); - + /* apply NLA mapping to all the keyframes, since it's easier than trying to * guess when a callback might use something different */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0); - + scaled_rectf.xmin = rectf.xmin; scaled_rectf.xmax = rectf.xmax; scaled_rectf.ymin = rectf.ymin / unit_scale - offset; scaled_rectf.ymax = rectf.ymax / unit_scale - offset; - - /* set horizontal range (if applicable) - * NOTE: these values are only used for x-range and y-range but not region + + /* set horizontal range (if applicable) + * NOTE: these values are only used for x-range and y-range but not region * (which uses ked.data, i.e. rectf) */ if (mode != BEZT_OK_VALUERANGE) { @@ -300,12 +300,12 @@ static void borderselect_graphkeys( ked.f1 = rectf.ymin; ked.f2 = rectf.ymax; } - + /* firstly, check if any keyframes will be hit by this */ if (ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, ok_cb, NULL)) { /* select keyframes that are in the appropriate places */ ANIM_fcurve_keyframes_loop(&ked, fcu, ok_cb, select_cb, NULL); - + /* only change selection of channel when the visibility of keyframes doesn't depend on this */ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) { /* select the curve too now that curve will be touched */ @@ -313,12 +313,12 @@ static void borderselect_graphkeys( fcu->flag |= FCURVE_SELECTED; } } - + /* un-apply NLA mapping from all the keyframes */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0); } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -334,7 +334,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) bool incl_handles; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -344,7 +344,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) if (!extend) deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true); - /* get select mode + /* get select mode * - 'include_handles' from the operator specifies whether to include handles in the selection */ if (select) { @@ -353,15 +353,15 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) else { selectmode = SELECT_SUBTRACT; } - + incl_handles = RNA_boolean_get(op->ptr, "include_handles"); - + /* get settings from operator */ WM_operator_properties_border_to_rcti(op, &rect); - + /* selection 'mode' depends on whether borderselect region only matters on one axis */ if (RNA_boolean_get(op->ptr, "axis_range")) { - /* mode depends on which axis of the range is larger to determine which axis to use + /* mode depends on which axis of the range is larger to determine which axis to use * - checking this in region-space is fine, as it's fundamentally still going to be a different rect size * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... @@ -371,19 +371,19 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) else mode = BEZT_OK_VALUERANGE; } - else + else mode = BEZT_OK_REGION; BLI_rctf_rcti_copy(&rect_fl, &rect); /* apply borderselect action */ borderselect_graphkeys(&ac, &rect_fl, mode, selectmode, incl_handles, NULL); - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; -} +} void GRAPH_OT_select_border(wmOperatorType *ot) { @@ -391,21 +391,21 @@ void GRAPH_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "GRAPH_OT_select_border"; ot->description = "Select all keyframes within the specified region"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = graphkeys_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); - + ot->prop = RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); RNA_def_boolean(ot->srna, "include_handles", 0, "Include Handles", "Are handles tested individually against the selection criteria"); } @@ -416,34 +416,34 @@ void GRAPH_OT_select_border(wmOperatorType *ot) static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + KeyframeEdit_LassoData data_lasso = {0}; rcti rect; rctf rect_fl; - + short selectmode; bool incl_handles; bool extend; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data_lasso.rectf_view = &rect_fl; data_lasso.mcords = WM_gesture_lasso_path_to_array(C, op, &data_lasso.mcords_tot); if (data_lasso.mcords == NULL) return OPERATOR_CANCELLED; - + /* clear all selection if not extending selection */ extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, true); - + if (!RNA_boolean_get(op->ptr, "deselect")) selectmode = SELECT_ADD; else selectmode = SELECT_SUBTRACT; - + { SpaceIpo *sipo = (SpaceIpo *)ac.sl; if (selectmode == SELECT_ADD) { @@ -454,19 +454,19 @@ static int graphkeys_lassoselect_exec(bContext *C, wmOperator *op) incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0; } } - + /* get settings from operator */ BLI_lasso_boundbox(&rect, data_lasso.mcords, data_lasso.mcords_tot); BLI_rctf_rcti_copy(&rect_fl, &rect); - + /* apply borderselect action */ borderselect_graphkeys(&ac, &rect_fl, BEZT_OK_REGION_LASSO, selectmode, incl_handles, &data_lasso); - + MEM_freeN((void *)data_lasso.mcords); - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -476,17 +476,17 @@ void GRAPH_OT_select_lasso(wmOperatorType *ot) ot->name = "Lasso Select"; ot->description = "Select keyframe points using lasso selection"; ot->idname = "GRAPH_OT_select_lasso"; - + /* api callbacks */ ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = graphkeys_lassoselect_exec; ot->poll = graphop_visible_keyframes_poll; ot->cancel = WM_gesture_lasso_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_gesture_lasso_select(ot); } @@ -499,10 +499,10 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op) const bool select = !RNA_boolean_get(op->ptr, "deselect"); const short selectmode = select ? SELECT_ADD : SELECT_SUBTRACT; bool incl_handles = false; - + KeyframeEdit_CircleData data = {0}; rctf rect_fl; - + float x = RNA_int_get(op->ptr, "x"); float y = RNA_int_get(op->ptr, "y"); float radius = RNA_int_get(op->ptr, "radius"); @@ -510,17 +510,17 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + data.mval[0] = x; data.mval[1] = y; data.radius_squared = radius * radius; data.rectf_view = &rect_fl; - + rect_fl.xmin = x - radius; rect_fl.xmax = x + radius; rect_fl.ymin = y - radius; rect_fl.ymax = y + radius; - + { SpaceIpo *sipo = (SpaceIpo *)ac.sl; if (selectmode == SELECT_ADD) { @@ -531,13 +531,13 @@ static int graph_circle_select_exec(bContext *C, wmOperator *op) incl_handles = (sipo->flag & SIPO_NOHANDLES) == 0; } } - + /* apply borderselect action */ borderselect_graphkeys(&ac, &rect_fl, BEZT_OK_REGION_CIRCLE, selectmode, incl_handles, &data); - + /* send notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -546,13 +546,13 @@ void GRAPH_OT_select_circle(wmOperatorType *ot) ot->name = "Circle Select"; ot->description = "Select keyframe points using circle selection"; ot->idname = "GRAPH_OT_select_circle"; - + ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = graph_circle_select_exec; ot->poll = graphop_visible_keyframes_poll; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; @@ -577,7 +577,7 @@ static const EnumPropertyItem prop_column_select_types[] = { {0, NULL, 0, NULL, NULL} }; -/* ------------------- */ +/* ------------------- */ /* Selects all visible keyframes between the specified markers */ /* TODO, this is almost an _exact_ duplicate of a function of the same name in action_select.c @@ -587,27 +587,27 @@ static void markers_selectkeys_between(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb, select_cb; KeyframeEditData ked = {{NULL}}; float min, max; - + /* get extreme markers */ ED_markers_get_minmax(ac->markers, 1, &min, &max); min -= 0.5f; max += 0.5f; - + /* get editing funcs + data */ ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); select_cb = ANIM_editkeyframes_select(SELECT_ADD); ked.f1 = min; ked.f2 = max; - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* select keys in-between */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); @@ -621,7 +621,7 @@ static void markers_selectkeys_between(bAnimContext *ac) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -633,56 +633,56 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked; - + /* initialize keyframe editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - + /* build list of columns */ switch (mode) { case GRAPHKEYS_COLUMNSEL_KEYS: /* list of selected keys */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); - + ANIM_animdata_freelist(&anim_data); break; - + case GRAPHKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); - + ce->cfra = (float)CFRA; break; - + case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ ED_markers_make_cfra_list(ac->markers, &ked.list, SELECT); break; - + default: /* invalid option */ return; } - + /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(SELECT_ADD); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); - + /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ @@ -694,7 +694,7 @@ static void columnselect_graph_keys(bAnimContext *ac, short mode) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } } - + /* free elements */ BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); @@ -706,39 +706,39 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* action to take depends on the mode */ mode = RNA_enum_get(op->ptr, "mode"); - + if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN) markers_selectkeys_between(&ac); else columnselect_graph_keys(&ac, mode); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + void GRAPH_OT_select_column(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; ot->idname = "GRAPH_OT_select_column"; ot->description = "Select all keyframes on the specified frame(s)"; - + /* api callbacks */ ot->exec = graphkeys_columnselect_exec; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); } @@ -748,38 +748,38 @@ void GRAPH_OT_select_column(wmOperatorType *ot) static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); KeyframeEditFunc sel_cb = ANIM_editkeyframes_select(SELECT_ADD); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* loop through all of the keys and select additional keyframes based on these */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* check if anything selected? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { /* select every keyframe in this curve then */ ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL); } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -789,11 +789,11 @@ void GRAPH_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "GRAPH_OT_select_linked"; ot->description = "Select keyframes occurring in the same F-Curves as selected ones"; - + /* api callbacks */ ot->exec = graphkeys_select_linked_exec; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -806,38 +806,38 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked; KeyframeEditFunc build_cb; - - + + /* init selmap building data */ build_cb = ANIM_editkeyframes_buildselmap(mode); - memset(&ked, 0, sizeof(KeyframeEditData)); - + memset(&ked, 0, sizeof(KeyframeEditData)); + /* loop through all of the keys and select additional keyframes based on these */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; - + /* only continue if F-Curve has keyframes */ if (fcu->bezt == NULL) continue; - + /* build up map of whether F-Curve's keyframes should be selected or not */ ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit"); ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL); - + /* based on this map, adjust the selection status of the keyframes */ ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, bezt_selmap_flush, NULL); - + /* free the selmap used here */ MEM_freeN(ked.data); ked.data = NULL; } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -847,17 +847,17 @@ static void select_moreless_graph_keys(bAnimContext *ac, short mode) static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform select changes */ select_moreless_graph_keys(&ac, SELMAP_MORE); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -867,11 +867,11 @@ void GRAPH_OT_select_more(wmOperatorType *ot) ot->name = "Select More"; ot->idname = "GRAPH_OT_select_more"; ot->description = "Select keyframes beside already selected ones"; - + /* api callbacks */ ot->exec = graphkeys_select_more_exec; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -881,17 +881,17 @@ void GRAPH_OT_select_more(wmOperatorType *ot) static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform select changes */ select_moreless_graph_keys(&ac, SELMAP_LESS); - + /* set notifier that keyframe selection has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -901,11 +901,11 @@ void GRAPH_OT_select_less(wmOperatorType *ot) ot->name = "Select Less"; ot->idname = "GRAPH_OT_select_less"; ot->description = "Deselect keyframes on ends of selection islands"; - + /* api callbacks */ ot->exec = graphkeys_select_less_exec; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -928,25 +928,25 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc ok_cb, select_cb; KeyframeEditData ked = {{NULL}}; Scene *scene = ac->scene; - + /* if select mode is replace, deselect all keyframes (and channels) first */ if (select_mode == SELECT_REPLACE) { select_mode = SELECT_ADD; - + /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence */ deselect_graph_keys(ac, 0, SELECT_SUBTRACT, false); } - + /* set callbacks and editing data */ ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); select_cb = ANIM_editkeyframes_select(select_mode); - + if (leftright == GRAPHKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; ked.f2 = (float)(CFRA + 0.1f); @@ -955,15 +955,15 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short ked.f1 = (float)(CFRA - 0.1f); ked.f2 = MAXFRAMEF; } - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* select keys */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -984,28 +984,28 @@ static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op) bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); short selectmode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* if "test" mode is set, we don't have any info to set this with */ if (leftright == GRAPHKEYS_LRSEL_TEST) return OPERATOR_CANCELLED; - + /* do the selecting now */ graphkeys_select_leftright(&ac, leftright, selectmode); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -1013,11 +1013,11 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* handle mode-based testing */ if (leftright == GRAPHKEYS_LRSEL_TEST) { Scene *scene = ac.scene; @@ -1032,7 +1032,7 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const else RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); } - + /* perform selection */ return graphkeys_select_leftright_exec(C, op); } @@ -1040,24 +1040,24 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, const void GRAPH_OT_select_leftright(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Select Left/Right"; ot->idname = "GRAPH_OT_select_leftright"; ot->description = "Select keyframes to the left or the right of the current frame"; - + /* api callbacks */ ot->invoke = graphkeys_select_leftright_invoke; ot->exec = graphkeys_select_leftright_exec; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_graphkeys_leftright_select_types, GRAPHKEYS_LRSEL_TEST, "Mode", ""); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); - + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -1075,18 +1075,18 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot) /* temp info for caching handle vertices close */ typedef struct tNearestVertInfo { struct tNearestVertInfo *next, *prev; - + FCurve *fcu; /* F-Curve that keyframe comes from */ - + BezTriple *bezt; /* keyframe to consider */ FPoint *fpt; /* sample point to consider */ - + short hpoint; /* the handle index that we hit (eHandleIndex) */ short sel; /* whether the handle is selected or not */ int dist; /* distance from mouse to vert */ - + eAnim_ChannelType ctype; /* type of animation channel this FCurve comes from */ - + float frame; /* frame that point was on when it matched (global time) */ } tNearestVertInfo; @@ -1095,7 +1095,7 @@ typedef enum eGraphVertIndex { NEAREST_HANDLE_LEFT = -1, NEAREST_HANDLE_KEY, NEAREST_HANDLE_RIGHT -} eGraphVertIndex; +} eGraphVertIndex; /* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */ // TODO: perhaps this should depend a bit on the size that the user set the vertices to be? @@ -1121,9 +1121,9 @@ static void nearest_fcurve_vert_store( /* Keyframes or Samples? */ if (bezt) { int screen_co[2], dist; - - /* convert from data-space to screen coordinates - * NOTE: hpoint+1 gives us 0,1,2 respectively for each handle, + + /* convert from data-space to screen coordinates + * NOTE: hpoint+1 gives us 0,1,2 respectively for each handle, * needed to access the relevant vertex coordinates in the 3x3 * 'vec' matrix */ @@ -1135,7 +1135,7 @@ static void nearest_fcurve_vert_store( { tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last; bool replace = false; - + /* if there is already a point for the F-Curve, check if this point is closer than that was */ if ((nvi) && (nvi->fcu == fcu)) { /* replace if we are closer, or if equal and that one wasn't selected but we are... */ @@ -1145,19 +1145,19 @@ static void nearest_fcurve_vert_store( /* add new if not replacing... */ if (replace == 0) nvi = MEM_callocN(sizeof(tNearestVertInfo), "Nearest Graph Vert Info - Bezt"); - + /* store values */ nvi->fcu = fcu; nvi->ctype = ctype; - + nvi->bezt = bezt; nvi->hpoint = hpoint; nvi->dist = dist; - + nvi->frame = bezt->vec[1][0]; /* currently in global time... */ - + nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead? - + /* add to list of matches if appropriate... */ if (replace == 0) BLI_addtail(matches, nvi); @@ -1174,12 +1174,12 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceIpo *sipo = (SpaceIpo *)ac->sl; View2D *v2d = &ac->ar->v2d; short mapping_flag = 0; - - /* get curves to search through + + /* get curves to search through * - if the option to only show keyframes that belong to selected F-Curves is enabled, * include the 'only selected' flag... */ @@ -1188,32 +1188,32 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L filter |= ANIMFILTER_SEL; mapping_flag |= ANIM_get_normalization_flags(ac); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->key_data; AnimData *adt = ANIM_nla_mapping_get(ac, ale); float offset; float unit_scale = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, mapping_flag, &offset); - + /* apply NLA mapping to all the keyframes */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); - + if (fcu->bezt) { BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL; int i; - + for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) { /* keyframe */ nearest_fcurve_vert_store(matches, v2d, fcu, ale->type, bezt1, NULL, NEAREST_HANDLE_KEY, mval, unit_scale, offset); - + /* handles - only do them if they're visible */ if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) { /* first handle only visible if previous segment had handles */ if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { nearest_fcurve_vert_store(matches, v2d, fcu, ale->type, bezt1, NULL, NEAREST_HANDLE_LEFT, mval, unit_scale, offset); } - + /* second handle only visible if this segment is bezier */ if (bezt1->ipo == BEZT_IPO_BEZ) { nearest_fcurve_vert_store(matches, v2d, fcu, ale->type, bezt1, NULL, NEAREST_HANDLE_RIGHT, mval, unit_scale, offset); @@ -1223,14 +1223,14 @@ static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], L } else if (fcu->fpt) { // TODO; do this for samples too - + } - + /* un-apply NLA mapping from all the keyframes */ if (adt) ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0); } - + /* free channels */ ANIM_animdata_freelist(&anim_data); } @@ -1240,22 +1240,22 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) { tNearestVertInfo *nvi = NULL; short found = 0; - + /* abort if list is empty */ if (BLI_listbase_is_empty(matches)) return NULL; - + /* if list only has 1 item, remove it from the list and return */ if (BLI_listbase_is_single(matches)) { /* need to remove from the list, otherwise it gets freed and then we can't return it */ return BLI_pophead(matches); } - + /* try to find the first selected F-Curve vert, then take the one after it */ for (nvi = matches->first; nvi; nvi = nvi->next) { /* which mode of search are we in: find first selected, or find vert? */ if (found) { - /* just take this vert now that we've found the selected one + /* just take this vert now that we've found the selected one * - we'll need to remove this from the list so that it can be returned to the original caller */ BLI_remlink(matches, nvi); @@ -1267,29 +1267,29 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) found = 1; } } - + /* if we're still here, this means that we failed to find anything appropriate in the first pass, * so just take the first item now... */ return BLI_pophead(matches); } -/* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates) +/* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates) * NOTE: the match info found must still be freed */ static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2]) { ListBase matches = {NULL, NULL}; tNearestVertInfo *nvi; - + /* step 1: get the nearest verts */ get_nearest_fcurve_verts_list(ac, mval, &matches); - + /* step 2: find the best vert */ nvi = get_best_nearest_fcurve_vert(&matches); - + BLI_freelistN(&matches); - + /* return the best vert found */ return nvi; } @@ -1302,30 +1302,30 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m SpaceIpo *sipo = (SpaceIpo *)ac->sl; tNearestVertInfo *nvi; BezTriple *bezt = NULL; - + /* find the beztriple that we're selecting, and the handle that was clicked on */ nvi = find_nearest_fcurve_vert(ac, mval); - + /* check if anything to select */ if (nvi == NULL) return; - + /* deselect all other curves? */ if (select_mode == SELECT_REPLACE) { /* reset selection mode */ select_mode = SELECT_ADD; - + /* deselect all other keyframes (+ F-Curves too) */ deselect_graph_keys(ac, 0, SELECT_SUBTRACT, true); - - /* deselect other channels too, but only only do this if - * selection of channel when the visibility of keyframes - * doesn't depend on this + + /* deselect other channels too, but only only do this if + * selection of channel when the visibility of keyframes + * doesn't depend on this */ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); } - + /* if points can be selected on this F-Curve */ // TODO: what about those with no keyframes? if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) { @@ -1343,7 +1343,7 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m BEZT_SEL_ALL(bezt); } } - + /* handles - toggle selection of relevant handle */ else if (nvi->hpoint == NEAREST_HANDLE_LEFT) { /* toggle selection */ @@ -1360,9 +1360,9 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m BEZT_SEL_ALL(bezt); } /* otherwise, select the handle that applied */ - else if (nvi->hpoint == NEAREST_HANDLE_LEFT) + else if (nvi->hpoint == NEAREST_HANDLE_LEFT) bezt->f1 |= SELECT; - else + else bezt->f3 |= SELECT; } } @@ -1373,22 +1373,22 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m else { KeyframeEditFunc select_cb; KeyframeEditData ked; - + /* initialize keyframe editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - + /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(select_mode); - + /* select all keyframes */ ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, NULL, select_cb, NULL); } - + /* only change selection of channel when the visibility of keyframes doesn't depend on this */ if ((sipo->flag & SIPO_SELCUVERTSONLY) == 0) { /* select or deselect curve? */ if (bezt) { - /* take selection status from item that got hit, to prevent flip/flop on channel + /* take selection status from item that got hit, to prevent flip/flop on channel * selection status when shift-selecting (i.e. "SELECT_INVERT") points */ if (BEZT_ISSEL_ANY(bezt)) @@ -1425,66 +1425,66 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked; tNearestVertInfo *nvi; float selx = (float)ac->scene->r.cfra; - + /* find the beztriple that we're selecting, and the handle that was clicked on */ nvi = find_nearest_fcurve_vert(ac, mval); - + /* check if anything to select */ if (nvi == NULL) return; - + /* get frame number on which elements should be selected */ // TODO: should we restrict to integer frames only? selx = nvi->frame; - + /* if select mode is replace, deselect all keyframes first */ if (select_mode == SELECT_REPLACE) { /* reset selection mode to add to selection */ select_mode = SELECT_ADD; - + /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence */ deselect_graph_keys(ac, 0, SELECT_SUBTRACT, false); } - + /* initialize keyframe editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - + /* set up BezTriple edit callbacks */ select_cb = ANIM_editkeyframes_select(select_mode); ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); - + /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); - + /* set frame for validation callback to refer to */ if (adt) ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else ked.f1 = selx; - + /* select elements with frame number matching cfra */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } - + /* free elements */ MEM_freeN(nvi); BLI_freelistN(&ked.list); ANIM_animdata_freelist(&anim_data); } - + /* ------------------- */ /* handle clicking */ @@ -1502,7 +1502,7 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* figure out action to take */ if (RNA_boolean_get(op->ptr, "column")) { /* select all keyframes in the same frame as the one that was under the mouse */ @@ -1516,41 +1516,41 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, const wmEve /* select keyframe under mouse */ mouse_graph_keys(&ac, event->mval, selectmode, 0); } - + /* set notifier that keyframe selection (and also channel selection in some cases) has changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + /* for tweak grab to work */ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } - + void GRAPH_OT_clickselect(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Mouse Select Keys"; ot->idname = "GRAPH_OT_clickselect"; ot->description = "Select keyframes by clicking on them"; - + /* callbacks */ ot->invoke = graphkeys_clickselect_invoke; ot->poll = graphop_visible_keyframes_poll; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "Toggle keyframe selection instead of leaving newly selected keyframes only"); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - - prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", + + prop = RNA_def_boolean(ot->srna, "column", 0, "Column Select", "Select all keyframes that occur on the same frame as the one under the mouse"); // ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); - - prop = RNA_def_boolean(ot->srna, "curves", 0, "Only Curves", + + prop = RNA_def_boolean(ot->srna, "curves", 0, "Only Curves", "Select all the keyframes in the curve"); // CTRLKEY + ALTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); } diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index fc20a62c3d6..f55a5511e2d 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -57,7 +57,7 @@ /* ************************************************************** */ /* Active F-Curve */ -/* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change). +/* Find 'active' F-Curve. It must be editable, since that's the purpose of these buttons (subject to change). * We return the 'wrapper' since it contains valuable context info (about hierarchy), which will need to be freed * when the caller is done with it. * @@ -68,20 +68,20 @@ bAnimListElem *get_active_fcurve_channel(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE); size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* We take the first F-Curve only, since some other ones may have had 'active' flag set * if they were from linked data. */ if (items) { bAnimListElem *ale = (bAnimListElem *)anim_data.first; - + /* remove first item from list, then free the rest of the list and return the stored one */ BLI_remlink(&anim_data, ale); ANIM_animdata_freelist(&anim_data); - + return ale; } - + /* no active F-Curve */ return NULL; } @@ -99,30 +99,30 @@ int graphop_visible_keyframes_poll(bContext *C) size_t items; int filter; short found = 0; - + /* firstly, check if in Graph Editor */ // TODO: also check for region? if ((sa == NULL) || (sa->spacetype != SPACE_IPO)) return 0; - + /* try to init Anim-Context stuff ourselves and check */ if (ANIM_animdata_get_context(C, &ac) == 0) return 0; - + /* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable * stopping on the first successful match */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - if (items == 0) + if (items == 0) return 0; - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - + /* visible curves for selection must fulfill the following criteria: * - it has bezier keyframes - * - F-Curve modifiers do not interfere with the result too much + * - F-Curve modifiers do not interfere with the result too much * (i.e. the modifier-control drawing check returns false) */ if (fcu->bezt == NULL) @@ -132,7 +132,7 @@ int graphop_visible_keyframes_poll(bContext *C) break; } } - + /* cleanup and return findings */ ANIM_animdata_freelist(&anim_data); return found; @@ -148,27 +148,27 @@ int graphop_editable_keyframes_poll(bContext *C) size_t items; int filter; short found = 0; - + /* firstly, check if in Graph Editor */ // TODO: also check for region? if ((sa == NULL) || (sa->spacetype != SPACE_IPO)) return 0; - + /* try to init Anim-Context stuff ourselves and check */ if (ANIM_animdata_get_context(C, &ac) == 0) return 0; - + /* loop over the editable F-Curves, and see if they're suitable * stopping on the first successful match */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - if (items == 0) + if (items == 0) return 0; - + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; - + /* editable curves must fulfill the following criteria: * - it has bezier keyframes * - it must not be protected from editing (this is already checked for with the edit flag @@ -182,7 +182,7 @@ int graphop_editable_keyframes_poll(bContext *C) break; } } - + /* cleanup and return findings */ ANIM_animdata_freelist(&anim_data); return found; @@ -195,21 +195,21 @@ int graphop_active_fcurve_poll(bContext *C) bAnimListElem *ale; ScrArea *sa = CTX_wm_area(C); bool has_fcurve = 0; - + /* firstly, check if in Graph Editor */ // TODO: also check for region? if ((sa == NULL) || (sa->spacetype != SPACE_IPO)) return 0; - + /* try to init Anim-Context stuff ourselves and check */ if (ANIM_animdata_get_context(C, &ac) == 0) return 0; - + /* try to get the Active F-Curve */ ale = get_active_fcurve_channel(&ac); if (ale == NULL) return 0; - + /* do we have a suitable F-Curves? * - For most cases, NLA Control Curves are sufficiently similar to NLA curves to serve this role too. * Under the hood, they are F-Curves too. The only problems which will arise here are if these need to be @@ -220,10 +220,10 @@ int graphop_active_fcurve_poll(bContext *C) FCurve *fcu = (FCurve *)ale->data; has_fcurve = (fcu->flag & FCURVE_VISIBLE) != 0; } - + /* free temp data... */ MEM_freeN(ale); - + /* return success */ return has_fcurve; } @@ -236,24 +236,24 @@ int graphop_selected_fcurve_poll(bContext *C) ScrArea *sa = CTX_wm_area(C); size_t items; int filter; - + /* firstly, check if in Graph Editor */ // TODO: also check for region? if ((sa == NULL) || (sa->spacetype != SPACE_IPO)) return 0; - + /* try to init Anim-Context stuff ourselves and check */ if (ANIM_animdata_get_context(C, &ac) == 0) return 0; - - /* get the editable + selected F-Curves, and as long as we got some, we can return + + /* get the editable + selected F-Curves, and as long as we got some, we can return * NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - if (items == 0) + if (items == 0) return 0; - + /* cleanup and return findings */ ANIM_animdata_freelist(&anim_data); return 1; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 2193a027f99..383c2b5b220 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -68,7 +68,7 @@ ARegion *graph_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; @@ -77,15 +77,15 @@ ARegion *graph_has_buttons_region(ScrArea *sa) /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "buttons for graph"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -97,82 +97,82 @@ static SpaceLink *graph_new(const bContext *C) Scene *scene = CTX_data_scene(C); ARegion *ar; SpaceIpo *sipo; - + /* Graph Editor - general stuff */ sipo = MEM_callocN(sizeof(SpaceIpo), "init graphedit"); sipo->spacetype = SPACE_IPO; - + sipo->autosnap = SACTSNAP_FRAME; - + /* allocate DopeSheet data for Graph Editor */ sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); sipo->ads->source = (ID *)scene; - + /* settings for making it easier by default to just see what you're interested in tweaking */ sipo->ads->filterflag |= ADS_FILTER_ONLYSEL; sipo->flag |= SIPO_SELVHANDLESONLY; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for graphedit"); - + BLI_addtail(&sipo->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* channels */ ar = MEM_callocN(sizeof(ARegion), "channels region for graphedit"); - + BLI_addtail(&sipo->regionbase, ar); ar->regiontype = RGN_TYPE_CHANNELS; ar->alignment = RGN_ALIGN_LEFT; - + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); - + /* ui buttons */ ar = MEM_callocN(sizeof(ARegion), "buttons region for graphedit"); - + BLI_addtail(&sipo->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for graphedit"); - + BLI_addtail(&sipo->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + ar->v2d.tot.xmin = 0.0f; ar->v2d.tot.ymin = (float)scene->r.sfra - 10.0f; ar->v2d.tot.xmax = (float)scene->r.efra; ar->v2d.tot.ymax = 10.0f; - + ar->v2d.cur = ar->v2d.tot; - + ar->v2d.min[0] = FLT_MIN; ar->v2d.min[1] = FLT_MIN; ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = FLT_MAX; - + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL); - + ar->v2d.keeptot = 0; - + return (SpaceLink *)sipo; } /* not spacelink itself */ static void graph_free(SpaceLink *sl) -{ +{ SpaceIpo *si = (SpaceIpo *)sl; - + if (si->ads) { BLI_freelistN(&si->ads->chanbase); MEM_freeN(si->ads); } - + if (si->ghostCurves.first) free_fcurves(&si->ghostCurves); } @@ -182,13 +182,13 @@ static void graph_free(SpaceLink *sl) static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; - + /* init dopesheet data if non-existent (i.e. for old files) */ if (sipo->ads == NULL) { sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... } - + /* force immediate init of any invalid F-Curve colors */ /* XXX: but, don't do SIPO_TEMP_NEEDCHANSYNC (i.e. channel select state sync) * as this is run on each region resize; setting this here will cause selection @@ -200,11 +200,11 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *graph_duplicate(SpaceLink *sl) { SpaceIpo *sipon = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves); sipon->ads = MEM_dupallocN(sipon->ads); - + return (SpaceLink *)sipon; } @@ -212,9 +212,9 @@ static SpaceLink *graph_duplicate(SpaceLink *sl) static void graph_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Graph Editor", SPACE_IPO, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -232,45 +232,45 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) View2DScrollers *scrollers; float col[3]; short unitx = 0, unity = V2D_UNIT_VALUES, flag = 0; - + /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* grid */ unitx = ((sipo->mode == SIPO_MODE_ANIMATION) && (sipo->flag & SIPO_DRAWTIME)) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* draw data */ if (ANIM_animdata_get_context(C, &ac)) { /* draw ghost curves */ graph_draw_ghost_curves(&ac, sipo, ar); - + /* draw curves twice - unselected, then selected, so that the are fewer occlusion problems */ graph_draw_curves(&ac, sipo, ar, grid, 0); graph_draw_curves(&ac, sipo, ar, grid, 1); - + /* XXX the slow way to set tot rect... but for nice sliders needed (ton) */ get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax, false, true); /* extra offset so that these items are visible */ v2d->tot.xmin -= 10.0f; v2d->tot.xmax += 10.0f; } - + /* only free grid after drawing data, as we need to use it to determine sampling rate */ UI_view2d_grid_free(grid); - + /* horizontal component of value-cursor (value line before the current frame line) */ if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) { float y = sipo->cursorVal; - + /* Draw a green line to indicate the cursor value */ UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50); glEnable(GL_BLEND); @@ -283,17 +283,17 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) glDisable(GL_BLEND); } - + /* current frame or vertical component of vertical component of the cursor */ if (sipo->mode == SIPO_MODE_DRIVERS) { /* cursor x-value */ float x = sipo->cursorTime; - + /* to help differentiate this from the current frame, draw slightly darker like the horizontal one */ UI_ThemeColorShadeAlpha(TH_CFRAME, -40, -50); glEnable(GL_BLEND); glLineWidth(2.0); - + glBegin(GL_LINES); glVertex2f(x, v2d->cur.ymin); glVertex2f(x, v2d->cur.ymax); @@ -307,22 +307,22 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) if ((sipo->flag & SIPO_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); } - + /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); ED_markers_draw(C, DRAW_MARKERS_MARGIN); - + /* preview range */ UI_view2d_view_ortho(v2d); ANIM_draw_previewrange(C, v2d, 0); - + /* callback */ UI_view2d_view_ortho(v2d); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ // FIXME: args for scrollers depend on the type of data being shown... scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); @@ -333,15 +333,15 @@ static void graph_main_region_draw(const bContext *C, ARegion *ar) static void graph_channel_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + /* make sure we keep the hide flags */ ar->v2d.scroll |= V2D_SCROLL_RIGHT; ar->v2d.scroll &= ~(V2D_SCROLL_LEFT | V2D_SCROLL_TOP | V2D_SCROLL_BOTTOM); /* prevent any noise of past */ ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE; ar->v2d.scroll |= V2D_SCROLL_VERTICAL_HIDE; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -355,22 +355,22 @@ static void graph_channel_region_draw(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; View2DScrollers *scrollers; float col[3]; - + /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* draw channels */ if (ANIM_animdata_get_context(C, &ac)) { graph_draw_channel_names((bContext *)C, &ac, ar); } - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -392,7 +392,7 @@ static void graph_header_region_draw(const bContext *C, ARegion *ar) static void graph_buttons_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ED_region_panels_init(wm, ar); keymap = WM_keymap_find(wm->defaultconf, "Graph Editor Generic", SPACE_IPO, 0); @@ -454,7 +454,7 @@ static void graph_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), AReg if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); break; - + } } @@ -462,7 +462,7 @@ static void graph_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), AReg static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) { SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; - + /* context changes */ switch (wmn->category) { case NC_ANIMATION: @@ -479,7 +479,7 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); break; - + default: /* just redrawing the view will do */ ED_area_tag_redraw(sa); break; @@ -494,7 +494,7 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) break; case ND_TRANSFORM: break; /*do nothing*/ - + default: /* just redrawing the view will do */ ED_area_tag_redraw(sa); break; @@ -517,7 +517,7 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); } break; - + // XXX: restore the case below if not enough updates occur... //default: // if (wmn->data == ND_KEYS) @@ -529,29 +529,29 @@ static void graph_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) static void graph_refresh_fcurve_colors(const bContext *C) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; size_t items; int filter; int i; - + if (ANIM_animdata_get_context(C, &ac) == false) return; - + UI_SetTheme(SPACE_IPO, RGN_TYPE_WINDOW); - + /* build list of F-Curves which will be visible as channels in channel-region * - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a * mismatch between channel-colors and the drawn curves */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop over F-Curves, assigning colors */ for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { FCurve *fcu = (FCurve *)ale->data; - + /* set color of curve here */ switch (fcu->color_mode) { case FCURVE_COLOR_CUSTOM: @@ -563,11 +563,11 @@ static void graph_refresh_fcurve_colors(const bContext *C) } case FCURVE_COLOR_AUTO_RGB: { - /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors. + /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors. * TODO: find a way to module the hue so that not all curves have same color... */ float *col = fcu->color; - + switch (fcu->array_index) { case 0: UI_GetThemeColor3fv(TH_AXIS_X, col); @@ -589,7 +589,7 @@ static void graph_refresh_fcurve_colors(const bContext *C) { /* Like FCURVE_COLOR_AUTO_RGB, except this is for quaternions... */ float *col = fcu->color; - + switch (fcu->array_index) { case 1: UI_GetThemeColor3fv(TH_AXIS_X, col); @@ -600,29 +600,29 @@ static void graph_refresh_fcurve_colors(const bContext *C) case 3: UI_GetThemeColor3fv(TH_AXIS_Z, col); break; - + case 0: { /* Special Case: "W" channel should be yellowish, so blend X and Y channel colors... */ float c1[3], c2[3]; float h1[3], h2[3]; float hresult[3]; - + /* - get colors (rgb) */ UI_GetThemeColor3fv(TH_AXIS_X, c1); UI_GetThemeColor3fv(TH_AXIS_Y, c2); - + /* - perform blending in HSV space (to keep brightness similar) */ rgb_to_hsv_v(c1, h1); rgb_to_hsv_v(c2, h2); - + interp_v3_v3v3(hresult, h1, h2, 0.5f); - + /* - convert back to RGB for display */ hsv_to_rgb_v(hresult, col); break; } - + default: /* 'unknown' color - bluish so as to not conflict with handles */ col[0] = 0.3f; col[1] = 0.8f; col[2] = 1.0f; @@ -641,7 +641,7 @@ static void graph_refresh_fcurve_colors(const bContext *C) } } } - + /* free temp list */ ANIM_animdata_freelist(&anim_data); } @@ -649,24 +649,24 @@ static void graph_refresh_fcurve_colors(const bContext *C) static void graph_refresh(const bContext *C, ScrArea *sa) { SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; - + /* updates to data needed depends on Graph Editor mode... */ switch (sipo->mode) { case SIPO_MODE_ANIMATION: /* all animation */ { break; } - + case SIPO_MODE_DRIVERS: /* drivers only */ { break; } } - + /* region updates? */ // XXX re-sizing y-extents of tot should go here? - - /* update the state of the animchannels in response to changes from the data they represent + + /* update the state of the animchannels in response to changes from the data they represent * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled */ if (sipo->flag & SIPO_TEMP_NEEDCHANSYNC) { @@ -674,7 +674,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) sipo->flag &= ~SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_redraw(sa); } - + /* init/adjust F-Curve colors */ graph_refresh_fcurve_colors(C); } @@ -682,7 +682,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) static void graph_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceIpo *sgraph = (SpaceIpo *)slink; - + if (sgraph->ads) { if ((ID *)sgraph->ads->filter_grp == old_id) { sgraph->ads->filter_grp = (Group *)new_id; @@ -698,10 +698,10 @@ void ED_spacetype_ipo(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo"); ARegionType *art; - + st->spaceid = SPACE_IPO; strncpy(st->name, "Graph", BKE_ST_MAXNAME); - + st->new = graph_new; st->free = graph_free; st->init = graph_init; @@ -721,7 +721,7 @@ void ED_spacetype_ipo(void) art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_HEADER; @@ -730,9 +730,9 @@ void ED_spacetype_ipo(void) art->listener = graph_region_listener; art->init = graph_header_region_init; art->draw = graph_header_region_draw; - + BLI_addhead(&st->regiontypes, art); - + /* regions: channels */ art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_CHANNELS; @@ -741,9 +741,9 @@ void ED_spacetype_ipo(void) art->listener = graph_region_listener; art->init = graph_channel_region_init; art->draw = graph_channel_region_draw; - + BLI_addhead(&st->regiontypes, art); - + /* regions: UI buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_UI; @@ -752,11 +752,11 @@ void ED_spacetype_ipo(void) art->listener = graph_region_listener; art->init = graph_buttons_region_init; art->draw = graph_buttons_region_draw; - + BLI_addhead(&st->regiontypes, art); graph_buttons_register(art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index c105f40f1d6..8b8aabb2ce0 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -134,7 +134,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) { bNode *node; - + if (ntree) for (node = ntree->nodes.first; node; node = node->next) if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) @@ -147,7 +147,7 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) /* ************ panel stuff ************* */ #if 0 -/* 0: disable preview +/* 0: disable preview * otherwise refresh preview * * XXX if you put this back, also check XXX in image_main_region_draw() */ @@ -155,7 +155,7 @@ struct ImageUser *ntree_get_active_iuser(bNodeTree *ntree) void image_preview_event(int event) { int exec = 0; - + if (event == 0) { G.scene->r.scemode &= ~R_COMP_CROP; exec = 1; @@ -168,27 +168,27 @@ void image_preview_event(int event) else G.scene->r.scemode &= ~R_COMP_CROP; } - + if (exec && G.scene->nodetree) { Scene *scene = G.scene; /* should work when no node editor in screen..., so we execute right away */ - + ntreeCompositTagGenerators(G.scene->nodetree); G.is_break = false; G.scene->nodetree->timecursor = set_timecursor; G.scene->nodetree->test_break = BKE_blender_test_break; - + BIF_store_spare(); - + ntreeCompositExecTree(scene->nodetree, &scene->r, 1, &scene->view_settings, &scene->display_settings); /* 1 is do_previews */ - + G.scene->nodetree->timecursor = NULL; G.scene->nodetree->test_break = NULL; - + scrarea_do_windraw(curarea); waitcursor(0); - + WM_event_add_notifier(C, NC_IMAGE, ima_v); } } @@ -203,20 +203,20 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) int winx = (G.scene->r.size * G.scene->r.xsch) / 100; int winy = (G.scene->r.size * G.scene->r.ysch) / 100; int mval[2]; - + if (G.scene->r.mode & R_BORDER) { winx *= BLI_rcti_size_x(&G.scene->r.border); winy *= BLI_rctf_size_y(&G.scene->r.border); } - + /* while dragging we need to update the rects, otherwise it doesn't end with correct one */ BLI_rctf_init(&dispf, 15.0f, BLI_rcti_size_x(&block->rect) - 15.0f, 15.0f, (BLI_rctf_size_y(&block->rect)) - 15.0f); ui_graphics_to_window_rct(sa->win, &dispf, disprect); - + /* correction for gla draw */ BLI_rcti_translate(disprect, -curarea->winrct.xmin, -curarea->winrct.ymin); - + calc_image_view(sima, 'p'); // printf("winrct %d %d %d %d\n", disprect->xmin, disprect->ymin, disprect->xmax, disprect->ymax); /* map to image space coordinates */ @@ -224,13 +224,13 @@ static void preview_cb(ScrArea *sa, struct uiBlock *block) areamouseco_to_ipoco(v2d, mval, &dispf.xmin, &dispf.ymin); mval[0] = disprect->xmax; mval[1] = disprect->ymax; areamouseco_to_ipoco(v2d, mval, &dispf.xmax, &dispf.ymax); - + /* map to render coordinates */ disprect->xmin = dispf.xmin; disprect->xmax = dispf.xmax; disprect->ymin = dispf.ymin; disprect->ymax = dispf.ymax; - + CLAMP(disprect->xmin, 0, winx); CLAMP(disprect->xmax, 0, winx); CLAMP(disprect->ymin, 0, winy); @@ -254,7 +254,7 @@ static bool is_preview_allowed(ScrArea *cur) /* check image type */ if (sima->image == NULL || sima->image->type != IMA_TYPE_COMPOSITE) return 0; - + return 1; } @@ -264,23 +264,23 @@ static void image_panel_preview(ScrArea *sa, short cntrl) // IMAGE_HANDLER_PRE uiBlock *block; SpaceImage *sima = sa->spacedata.first; int ofsx, ofsy; - + if (is_preview_allowed(sa) == 0) { rem_blockhandler(sa, IMAGE_HANDLER_PREVIEW); G.scene->r.scemode &= ~R_COMP_CROP; /* quite weak */ return; } - + block = UI_block_begin(C, ar, __func__, UI_EMBOSS); uiPanelControl(UI_PNL_SOLID | UI_PNL_CLOSE | UI_PNL_SCALE | cntrl); uiSetPanelHandler(IMAGE_HANDLER_PREVIEW); // for close and esc - + ofsx = -150 + (sa->winx / 2) / sima->blockscale; ofsy = -100 + (sa->winy / 2) / sima->blockscale; if (uiNewPanel(C, ar, block, "Preview", "Image", ofsx, ofsy, 300, 200) == 0) return; - + UI_but_func_drawextra_set(block, preview_cb); - + } #endif @@ -660,7 +660,7 @@ static void image_multiview_cb(bContext *C, void *rnd_pt, void *UNUSED(arg_v)) } #if 0 -static void image_freecache_cb(bContext *C, void *ima_v, void *unused) +static void image_freecache_cb(bContext *C, void *ima_v, void *unused) { Scene *scene = CTX_data_scene(C); BKE_image_free_anim_ibufs(ima_v, scene->r.cfra); @@ -898,7 +898,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiDefIconTextBut(block, UI_BTYPE_BUT, B_SIMA_PLAY, ICON_PLAY, "Play", 110, 120, 100, 20, 0, 0, 0, 0, 0, ""); but = uiDefBut(block, UI_BTYPE_BUT, B_NOP, "Free Cache", 210, 120, 100, 20, 0, 0, 0, 0, 0, ""); UI_but_func_set(but, image_freecache_cb, ima, NULL); - + if (iuser->frames) BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr); else strcpy(str, "Frames:"); @@ -929,7 +929,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char uiItemO(row, "", ICON_PACKAGE, "image.unpack"); else uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack"); - + row = uiLayoutRow(row, true); uiLayoutSetEnabled(row, BKE_image_has_packedfile(ima) == false); uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE); @@ -1043,7 +1043,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char col = uiLayoutColumn(split, true); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); - + uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1077,7 +1077,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man col = uiLayoutColumn(layout, false); split = uiLayoutSplit(col, 0.5f, false); - + uiItemR(split, imfptr, "file_format", 0, "", ICON_NONE); sub = uiLayoutRow(split, false); uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); @@ -1109,7 +1109,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man if (ELEM(imf->imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { uiItemR(col, imfptr, "exr_codec", 0, NULL, ICON_NONE); } - + row = uiLayoutRow(col, false); if (BKE_imtype_supports_zbuf(imf->imtype)) { uiItemR(row, imfptr, "use_zbuffer", 0, NULL, ICON_NONE); @@ -1126,7 +1126,7 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man row = uiLayoutRow(col, false); uiItemR(row, imfptr, "use_jpeg2k_cinema_preset", 0, NULL, ICON_NONE); uiItemR(row, imfptr, "use_jpeg2k_cinema_48", 0, NULL, ICON_NONE); - + uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE); } @@ -1297,14 +1297,14 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i void image_buttons_register(ARegionType *UNUSED(art)) { - + } static int image_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = image_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -1316,10 +1316,10 @@ void IMAGE_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->idname = "IMAGE_OT_properties"; ot->description = "Toggle the properties region visibility"; - + ot->exec = image_properties_toggle_exec; ot->poll = ED_operator_image_active; - + /* flags */ ot->flag = 0; } @@ -1328,10 +1328,10 @@ static int image_scopes_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = image_has_tools_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); - + return OPERATOR_FINISHED; } @@ -1343,7 +1343,7 @@ void IMAGE_OT_toolshelf(wmOperatorType *ot) ot->exec = image_scopes_toggle_exec; ot->poll = ED_operator_image_active; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 594938b82aa..c358b38520a 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -221,7 +221,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); - + glColor3ubv(green); if (fp) BLI_snprintf(str, sizeof(str), " G:%-.5f", fp[1]); @@ -232,7 +232,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); - + glColor3ubv(blue); if (fp) BLI_snprintf(str, sizeof(str), " B:%-.5f", fp[2]); @@ -243,7 +243,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str, sizeof(str)); - + if (channels == 4) { glColor3ub(255, 255, 255); if (fp) @@ -277,7 +277,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d dx += BLF_width(blf_mono_font, str, sizeof(str)); } } - + /* color rectangle */ if (channels == 1) { if (fp) { @@ -366,7 +366,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d rgb_to_hsv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &hue, &sat, &val); rgb_to_yuv((float)cp[0] / 255.0f, (float)cp[0] / 255.0f, (float)cp[0] / 255.0f, &lum, &u, &v, BLI_YUV_ITU_BT709); } - + BLI_snprintf(str, sizeof(str), "V:%-.4f", val); BLF_position(blf_mono_font, dx, dy, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); @@ -409,7 +409,7 @@ void ED_image_draw_info(Scene *scene, ARegion *ar, bool color_manage, bool use_d static void sima_draw_alpha_pixels(float x1, float y1, int rectx, int recty, unsigned int *recti) { - + /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ if (ENDIAN_ORDER == B_ENDIAN) glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); @@ -422,10 +422,10 @@ static void sima_draw_alpha_pixelsf(float x1, float y1, int rectx, int recty, fl { float *trectf = MEM_mallocN(rectx * recty * 4, "temp"); int a, b; - + for (a = rectx * recty - 1, b = 4 * a + 3; a >= 0; a--, b -= 4) trectf[a] = rectf[b]; - + glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, trectf); MEM_freeN(trectf); /* ogl trick below is slower... (on ATI 9600) */ @@ -447,9 +447,9 @@ static void sima_draw_zbuf_pixels(float x1, float y1, int rectx, int recty, int glPixelTransferf(GL_RED_BIAS, 0.5f); glPixelTransferf(GL_GREEN_BIAS, 0.5f); glPixelTransferf(GL_BLUE_BIAS, 0.5f); - + glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_INT, recti); - + glPixelTransferf(GL_RED_SCALE, 1.0f); glPixelTransferf(GL_GREEN_SCALE, 1.0f); glPixelTransferf(GL_BLUE_SCALE, 1.0f); @@ -462,7 +462,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec { float bias, scale, *rectf, clipend; int a; - + if (scene->camera && scene->camera->type == OB_CAMERA) { bias = ((Camera *)scene->camera->data)->clipsta; clipend = ((Camera *)scene->camera->data)->clipend; @@ -473,7 +473,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec scale = 0.01f; clipend = 100.0f; } - + rectf = MEM_mallocN(rectx * recty * 4, "temp"); for (a = rectx * recty - 1; a >= 0; a--) { if (rect_float[a] > clipend) @@ -486,7 +486,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, float x1, float y1, int rec } } glaDrawPixelsSafe(x1, y1, rectx, recty, rectx, GL_LUMINANCE, GL_FLOAT, rectf); - + MEM_freeN(rectf); } @@ -511,7 +511,7 @@ static void draw_image_buffer(const bContext *C, SpaceImage *sima, ARegion *ar, glPixelZoom(zoomx, zoomy); glaDefine2DArea(&ar->winrct); - + /* find window pixel coordinates of origin */ UI_view2d_view_to_region(&ar->v2d, fx, fy, &x, &y); @@ -586,7 +586,7 @@ static unsigned int *get_part_from_buffer(unsigned int *buffer, int width, short heigth = (endy - starty); rp = rectmain = MEM_mallocN(heigth * len * sizeof(int), "rect"); - + for (y = 0; y < heigth; y++) { memcpy(rp, rt, len * 4); rt += width; @@ -619,14 +619,14 @@ static void draw_image_buffer_tiled(SpaceImage *sima, ARegion *ar, Scene *scene, if (sima->curtile >= ima->xrep * ima->yrep) sima->curtile = ima->xrep * ima->yrep - 1; - + /* retrieve part of image buffer */ dx = max_ii(ibuf->x / ima->xrep, 1); dy = max_ii(ibuf->y / ima->yrep, 1); sx = (sima->curtile % ima->xrep) * dx; sy = (sima->curtile / ima->xrep) * dy; rect = get_part_from_buffer((unsigned int *)display_buffer, ibuf->x, sx, sy, sx + dx, sy + dy); - + /* draw repeated */ if ((sima->flag & (SI_SHOW_R | SI_SHOW_G | SI_SHOW_B)) != 0) { channel_offset = draw_image_channel_offset(sima); @@ -690,7 +690,7 @@ void draw_image_grease_pencil(bContext *C, bool onlyv2d) else { /* assume that UI_view2d_restore(C) has been called... */ //SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); - + /* draw grease-pencil ('screen' strokes) */ ED_gpencil_draw_view2d(C, 0); } @@ -735,7 +735,7 @@ static void draw_image_view_tool(Scene *scene) } else if (settings->imapaint.flag & IMAGEPAINT_DRAW_TOOL) draw = 1; - + if (draw) { getmouseco_areawin(mval); @@ -762,7 +762,7 @@ static unsigned char *get_alpha_clone_image(const bContext *C, Scene *scene, int if (!brush || !brush->clone.image) return NULL; - + ibuf = BKE_image_acquire_ibuf(brush->clone.image, NULL, NULL); if (!ibuf) @@ -848,10 +848,10 @@ void draw_image_main(const bContext *C, ARegion *ar) /* XXX can we do this in refresh? */ #if 0 what_image(sima); - + if (sima->image) { ED_image_get_aspect(sima->image, &xuser_asp, &yuser_asp); - + /* UGLY hack? until now iusers worked fine... but for flipbook viewer we need this */ if (sima->image->type == IMA_TYPE_COMPOSITE) { ImageUser *iuser = ntree_get_active_iuser(scene->nodetree); @@ -906,7 +906,7 @@ void draw_image_main(const bContext *C, ARegion *ar) draw_image_buffer_tiled(sima, ar, scene, ima, ibuf, 0.0f, 0.0, zoomx, zoomy); else draw_image_buffer(C, sima, ar, scene, ibuf, 0.0f, 0.0f, zoomx, zoomy); - + if (sima->flag & SI_DRAW_METADATA) { int x, y; rctf frame; @@ -928,7 +928,7 @@ void draw_image_main(const bContext *C, ARegion *ar) #if 0 if (ibuf) { float xoffs = 0.0f, yoffs = 0.0f; - + if (image_preview_active(sa, &xim, &yim)) { xoffs = scene->r.disprect.xmin; yoffs = scene->r.disprect.ymin; diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 383303c9ad0..39a029fb9f0 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -324,7 +324,7 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - + /* scope update can be expensive, don't update during paint modes */ if (sima->mode == SI_MODE_PAINT) return; @@ -340,7 +340,7 @@ void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage *s return; } } - + scopes_update(&sima->scopes, ibuf, use_view_settings ? &scene->view_settings : NULL, &scene->display_settings); } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 0e553b11919..dea1f761073 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -364,7 +364,7 @@ static int image_view_pan_exec(bContext *C, wmOperator *op) image_preview_event(2); } #endif - + return OPERATOR_FINISHED; } @@ -373,7 +373,7 @@ static int image_view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *eve if (event->type == MOUSEPAN) { SpaceImage *sima = CTX_wm_space_image(C); float offset[2]; - + offset[0] = (event->prevx - event->x) / sima->zoom; offset[1] = (event->prevy - event->y) / sima->zoom; RNA_float_set_array(op->ptr, "offset", offset); @@ -424,7 +424,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot) ot->name = "View Pan"; ot->idname = "IMAGE_OT_view_pan"; ot->description = "Pan the view"; - + /* api callbacks */ ot->exec = image_view_pan_exec; ot->invoke = image_view_pan_invoke; @@ -434,7 +434,7 @@ void IMAGE_OT_view_pan(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_LOCK_BYPASS; - + /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, "Offset", "Offset in floating point units, 1.0 is the width and height of the image", -FLT_MAX, FLT_MAX); @@ -519,7 +519,7 @@ static int image_view_zoom_exec(bContext *C, wmOperator *op) image_preview_event(2); } #endif - + return OPERATOR_FINISHED; } @@ -547,7 +547,7 @@ static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev RNA_float_set(op->ptr, "factor", factor); sima_zoom_set(sima, ar, sima->zoom * factor, location); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } else { @@ -640,7 +640,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot) ot->name = "View Zoom"; ot->idname = "IMAGE_OT_view_zoom"; ot->description = "Zoom in/out the image"; - + /* api callbacks */ ot->exec = image_view_zoom_exec; ot->invoke = image_view_zoom_invoke; @@ -650,7 +650,7 @@ void IMAGE_OT_view_zoom(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR | OPTYPE_LOCK_BYPASS; - + /* properties */ prop = RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX, "Factor", "Zoom factor, values higher than 1.0 zoom in, lower values zoom out", -FLT_MAX, FLT_MAX); @@ -699,7 +699,7 @@ void IMAGE_OT_view_ndof(wmOperatorType *ot) ot->name = "NDOF Pan/Zoom"; ot->idname = "IMAGE_OT_view_ndof"; ot->description = "Use a 3D mouse device to pan/zoom the view"; - + /* api callbacks */ ot->invoke = image_view_ndof_invoke; ot->poll = space_image_main_region_poll; @@ -732,7 +732,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op) w = width * aspx; h = height * aspy; - + /* check if the image will fit in the image with (zoom == 1) */ width = BLI_rcti_size_x(&ar->winrct) + 1; height = BLI_rcti_size_y(&ar->winrct) + 1; @@ -760,7 +760,7 @@ static int image_view_all_exec(bContext *C, wmOperator *op) sima->xof = sima->yof = 0.0f; ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -772,7 +772,7 @@ void IMAGE_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "IMAGE_OT_view_all"; ot->description = "View the entire image"; - + /* api callbacks */ ot->exec = image_view_all_exec; ot->poll = space_image_main_region_poll; @@ -826,7 +826,7 @@ static int image_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) sima_zoom_set_from_bounds(sima, ar, &bounds); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -841,7 +841,7 @@ void IMAGE_OT_view_selected(wmOperatorType *ot) ot->name = "View Center"; ot->idname = "IMAGE_OT_view_selected"; ot->description = "View all selected UVs"; - + /* api callbacks */ ot->exec = image_view_selected_exec; ot->poll = image_view_selected_poll; @@ -854,13 +854,13 @@ static int image_view_zoom_in_exec(bContext *C, wmOperator *op) SpaceImage *sima = CTX_wm_space_image(C); ARegion *ar = CTX_wm_region(C); float location[2]; - + RNA_float_get_array(op->ptr, "location", location); sima_zoom_set_factor(sima, ar, powf(2.0f, 1.0f / 3.0f), location); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -883,7 +883,7 @@ void IMAGE_OT_view_zoom_in(wmOperatorType *ot) ot->name = "View Zoom In"; ot->idname = "IMAGE_OT_view_zoom_in"; ot->description = "Zoom in the image (centered around 2D cursor)"; - + /* api callbacks */ ot->invoke = image_view_zoom_in_invoke; ot->exec = image_view_zoom_in_exec; @@ -903,13 +903,13 @@ static int image_view_zoom_out_exec(bContext *C, wmOperator *op) SpaceImage *sima = CTX_wm_space_image(C); ARegion *ar = CTX_wm_region(C); float location[2]; - + RNA_float_get_array(op->ptr, "location", location); sima_zoom_set_factor(sima, ar, powf(0.5f, 1.0f / 3.0f), location); - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -932,7 +932,7 @@ void IMAGE_OT_view_zoom_out(wmOperatorType *ot) ot->name = "View Zoom Out"; ot->idname = "IMAGE_OT_view_zoom_out"; ot->description = "Zoom out the image (centered around 2D cursor)"; - + /* api callbacks */ ot->invoke = image_view_zoom_out_invoke; ot->exec = image_view_zoom_out_exec; @@ -955,7 +955,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); sima_zoom_set(sima, ar, RNA_float_get(op->ptr, "ratio"), NULL); - + /* ensure pixel exact locations for draw */ sima->xof = (int)sima->xof; sima->yof = (int)sima->yof; @@ -970,7 +970,7 @@ static int image_view_zoom_ratio_exec(bContext *C, wmOperator *op) #endif ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -980,7 +980,7 @@ void IMAGE_OT_view_zoom_ratio(wmOperatorType *ot) ot->name = "View Zoom Ratio"; ot->idname = "IMAGE_OT_view_zoom_ratio"; ot->description = "Set zoom ratio of the view"; - + /* api callbacks */ ot->exec = image_view_zoom_ratio_exec; ot->poll = space_image_main_region_poll; @@ -1053,7 +1053,7 @@ void IMAGE_OT_view_zoom_border(wmOperatorType *ot) static void image_filesel(bContext *C, wmOperator *op, const char *path) { RNA_string_set(op->ptr, "filepath", path); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); } /******************** open image operator ********************/ @@ -1342,10 +1342,10 @@ static int image_open_exec(bContext *C, wmOperator *op) /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), bmain); - + BKE_image_signal(ima, iuser, IMA_SIGNAL_RELOAD); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); - + MEM_freeN(op->customdata); return OPERATOR_FINISHED; @@ -1393,7 +1393,7 @@ static int image_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( if (RNA_struct_property_is_set(op->ptr, "filepath")) return image_open_exec(C, op); - + image_open_init(C, op); /* show multiview save options only if scene has multiviews */ @@ -1442,7 +1442,7 @@ void IMAGE_OT_open(wmOperatorType *ot) ot->name = "Open Image"; ot->description = "Open image"; ot->idname = "IMAGE_OT_open"; - + /* api callbacks */ ot->exec = image_open_exec; ot->invoke = image_open_invoke; @@ -1481,7 +1481,7 @@ static int image_match_len_exec(bContext *C, wmOperator *UNUSED(op)) ima = sima->image; iuser = &sima->iuser; } - + } if (!ima || !iuser || !BKE_image_has_anim(ima)) @@ -1503,7 +1503,7 @@ void IMAGE_OT_match_movie_length(wmOperatorType *ot) ot->name = "Match Movie Length"; ot->description = "Set image's user's length to the one of this video"; ot->idname = "IMAGE_OT_match_movie_length"; - + /* api callbacks */ ot->exec = image_match_len_exec; @@ -1520,7 +1520,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) if (!sima->image) return OPERATOR_CANCELLED; - + RNA_string_get(op->ptr, "filepath", str); /* we cant do much if the str is longer then FILE_MAX :/ */ @@ -1530,7 +1530,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) sima->image->source = IMA_SRC_FILE; BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_SRC_CHANGE); } - + if (BLI_testextensie_array(str, imb_ext_movie)) sima->image->source = IMA_SRC_MOVIE; else @@ -1538,7 +1538,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + BKE_icon_changed(BKE_icon_id_ensure(&sima->image->id)); BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_RELOAD); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, sima->image); @@ -1570,7 +1570,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) ot->name = "Replace Image"; ot->idname = "IMAGE_OT_replace"; ot->description = "Replace current image by another one from disk"; - + /* api callbacks */ ot->exec = image_replace_exec; ot->invoke = image_replace_invoke; @@ -2174,7 +2174,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) ot->name = "Save As Image"; ot->idname = "IMAGE_OT_save_as"; ot->description = "Save the image with another name and/or settings"; - + /* api callbacks */ ot->exec = image_save_as_exec; ot->check = image_save_as_check; @@ -2229,7 +2229,7 @@ void IMAGE_OT_save(wmOperatorType *ot) ot->name = "Save Image"; ot->idname = "IMAGE_OT_save"; ot->description = "Save the image with current name and settings"; - + /* api callbacks */ ot->exec = image_save_exec; ot->poll = space_image_file_exists_poll; @@ -2248,7 +2248,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) int tot = 0; char di[FILE_MAX]; struct MovieCacheIter *iter; - + if (sima->image == NULL) return OPERATOR_CANCELLED; @@ -2261,7 +2261,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "Cannot save multilayer sequences"); return OPERATOR_CANCELLED; } - + /* get total dirty buffers and first dirty buffer which is used for menu */ ibuf = NULL; if (sima->image->cache != NULL) { @@ -2278,7 +2278,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) } IMB_moviecacheIter_free(iter); } - + if (tot == 0) { BKE_report(op->reports, RPT_WARNING, "No images have been changed"); return OPERATOR_CANCELLED; @@ -2320,7 +2320,7 @@ void IMAGE_OT_save_sequence(wmOperatorType *ot) ot->name = "Save Sequence"; ot->idname = "IMAGE_OT_save_sequence"; ot->description = "Save a sequence of images"; - + /* api callbacks */ ot->exec = image_save_sequence_exec; ot->poll = space_image_buffer_exists_poll; @@ -2341,13 +2341,13 @@ static int image_reload_exec(bContext *C, wmOperator *UNUSED(op)) /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + // XXX other users? BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_RELOAD); DAG_id_tag_update(&ima->id, 0); WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); - + return OPERATOR_FINISHED; } @@ -2357,7 +2357,7 @@ void IMAGE_OT_reload(wmOperatorType *ot) ot->name = "Reload Image"; ot->idname = "IMAGE_OT_reload"; ot->description = "Reload current image from disk"; - + /* api callbacks */ ot->exec = image_reload_exec; @@ -2440,12 +2440,12 @@ static int image_new_exec(bContext *C, wmOperator *op) else if (gen_context == GEN_CONTEXT_PAINT_CANVAS) { bScreen *sc; Object *ob = CTX_data_active_object(C); - - GPU_drawobject_free(ob->derivedFinal); + + GPU_drawobject_free(ob->derivedFinal); if (scene->toolsettings->imapaint.canvas) id_us_min(&scene->toolsettings->imapaint.canvas->id); scene->toolsettings->imapaint.canvas = ima; - + for (sc = bmain->screen.first; sc; sc = sc->id.next) { ScrArea *sa; for (sa = sc->areabase.first; sa; sa = sa->next) { @@ -2453,7 +2453,7 @@ static int image_new_exec(bContext *C, wmOperator *op) for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima_other = (SpaceImage *)sl; - + if (!sima_other->pin) { ED_space_image_set(bmain, sima_other, scene, scene->obedit, ima); } @@ -2469,8 +2469,8 @@ static int image_new_exec(bContext *C, wmOperator *op) if (scene->toolsettings->imapaint.stencil) id_us_min(&scene->toolsettings->imapaint.stencil->id); scene->toolsettings->imapaint.stencil = ima; - BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); - WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); } else { Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; @@ -2483,9 +2483,9 @@ static int image_new_exec(bContext *C, wmOperator *op) } BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE); - + WM_event_add_notifier(C, NC_IMAGE | NA_ADDED, ima); - + return OPERATOR_FINISHED; } @@ -2556,17 +2556,17 @@ void IMAGE_OT_new(wmOperatorType *ot) {GEN_CONTEXT_PAINT_STENCIL, "PAINT_STENCIL", 0, "Paint Stencil", ""}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "New Image"; ot->description = "Create a new image"; ot->idname = "IMAGE_OT_new"; - + /* api callbacks */ ot->exec = image_new_exec; ot->invoke = image_new_invoke; ot->ui = image_new_draw; - + /* flags */ ot->flag = OPTYPE_UNDO; @@ -2628,7 +2628,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) } /* TODO: make this into an IMB_invert_channels(ibuf,r,g,b,a) method!? */ if (ibuf->rect_float) { - + float *fp = (float *) ibuf->rect_float; for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, fp += 4) { if (r) fp[0] = 1.0f - fp[0]; @@ -2642,7 +2642,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) } } else if (ibuf->rect) { - + char *cp = (char *) ibuf->rect; for (i = ((size_t)ibuf->x) * ibuf->y; i > 0; i--, cp += 4) { if (r) cp[0] = 255 - cp[0]; @@ -2683,11 +2683,11 @@ void IMAGE_OT_invert(wmOperatorType *ot) ot->name = "Invert Channels"; ot->idname = "IMAGE_OT_invert"; ot->description = "Invert image's channels"; - + /* api callbacks */ ot->exec = image_invert_exec; ot->poll = image_invert_poll; - + /* properties */ prop = RNA_def_boolean(ot->srna, "invert_r", 0, "Red", "Invert Red Channel"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -2697,7 +2697,7 @@ void IMAGE_OT_invert(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_SKIP_SAVE); prop = RNA_def_boolean(ot->srna, "invert_a", 0, "Alpha", "Invert Alpha Channel"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2731,7 +2731,7 @@ static int image_pack_exec(bContext *C, wmOperator *op) if (!image_pack_test(C, op)) return OPERATOR_CANCELLED; - + if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG"); return OPERATOR_CANCELLED; @@ -2783,9 +2783,9 @@ void IMAGE_OT_pack(wmOperatorType *ot) { /* identifiers */ ot->name = "Pack Image"; - ot->description = "Pack an image as embedded data into the .blend file"; + ot->description = "Pack an image as embedded data into the .blend file"; ot->idname = "IMAGE_OT_pack"; - + /* api callbacks */ ot->exec = image_pack_exec; ot->invoke = image_pack_invoke; @@ -2811,7 +2811,7 @@ static int image_unpack_exec(bContext *C, wmOperator *op) ima = BLI_findstring(&CTX_data_main(C)->image, imaname, offsetof(ID, name) + 2); if (!ima) ima = CTX_data_edit_image(C); } - + if (!ima || !BKE_image_has_packedfile(ima)) return OPERATOR_CANCELLED; @@ -2822,12 +2822,12 @@ static int image_unpack_exec(bContext *C, wmOperator *op) if (G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save"); - + /* XXX unpackImage frees image buffers */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + unpackImage(CTX_data_main(C), op->reports, ima, method); - + WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, ima); return OPERATOR_FINISHED; @@ -2839,7 +2839,7 @@ static int image_unpack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE if (RNA_struct_property_is_set(op->ptr, "id")) return image_unpack_exec(C, op); - + if (!ima || !BKE_image_has_packedfile(ima)) return OPERATOR_CANCELLED; @@ -2860,16 +2860,16 @@ void IMAGE_OT_unpack(wmOperatorType *ot) { /* identifiers */ ot->name = "Unpack Image"; - ot->description = "Save an image packed in the .blend file to disk"; + ot->description = "Save an image packed in the .blend file to disk"; ot->idname = "IMAGE_OT_unpack"; - + /* api callbacks */ ot->exec = image_unpack_exec; ot->invoke = image_unpack_invoke; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_enum(ot->srna, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack"); RNA_def_string(ot->srna, "id", NULL, MAX_ID_NAME - 2, "Image Name", "Image data-block name to unpack"); /* XXX, weark!, will fail with library, name collisions */ @@ -3072,7 +3072,7 @@ static void image_sample_apply(bContext *C, wmOperator *op, const wmEvent *event #if 0 { ScrArea *sa, *cur = curarea; - + node_curvemap_sample(fp); /* sends global to node editor */ for (sa = G.curscreen->areabase.first; sa; sa = sa->next) { if (sa->spacetype == SPACE_NODE) { @@ -3116,7 +3116,7 @@ static int image_sample_invoke(bContext *C, wmOperator *op, const wmEvent *event if (!ED_space_image_has_buffer(sima)) return OPERATOR_CANCELLED; - + info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo"); info->art = ar->type; info->draw_handle = ED_region_draw_cb_activate(ar->type, image_sample_draw, info, REGION_DRAW_POST_PIXEL); @@ -3158,7 +3158,7 @@ void IMAGE_OT_sample(wmOperatorType *ot) ot->name = "Sample Color"; ot->idname = "IMAGE_OT_sample"; ot->description = "Use mouse to sample a color in current image"; - + /* api callbacks */ ot->invoke = image_sample_invoke; ot->modal = image_sample_modal; @@ -3180,13 +3180,13 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) int y_start = RNA_int_get(op->ptr, "ystart"); int x_end = RNA_int_get(op->ptr, "xend"); int y_end = RNA_int_get(op->ptr, "yend"); - + void *lock; ImBuf *ibuf = ED_space_image_acquire_buffer(sima, &lock); Histogram *hist = &sima->sample_line_hist; - + float x1f, y1f, x2f, y2f; - + if (ibuf == NULL) { ED_space_image_release_buffer(sima, ibuf, lock); return OPERATOR_CANCELLED; @@ -3196,7 +3196,7 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) ED_space_image_release_buffer(sima, ibuf, lock); return OPERATOR_CANCELLED; } - + UI_view2d_region_to_view(&ar->v2d, x_start, y_start, &x1f, &y1f); UI_view2d_region_to_view(&ar->v2d, x_end, y_end, &x2f, &y2f); @@ -3209,14 +3209,14 @@ static int image_sample_line_exec(bContext *C, wmOperator *op) hist->flag |= HISTO_FLAG_SAMPLELINE; BKE_histogram_update_sample_line(hist, ibuf, &scene->view_settings, &scene->display_settings); - + /* reset y zoom */ hist->ymax = 1.0f; ED_space_image_release_buffer(sima, ibuf, lock); - + ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } @@ -3229,7 +3229,7 @@ static int image_sample_line_invoke(bContext *C, wmOperator *op, const wmEvent * if (!ED_space_image_has_buffer(sima)) return OPERATOR_CANCELLED; - + return WM_gesture_straightline_invoke(C, op, event); } @@ -3239,17 +3239,17 @@ void IMAGE_OT_sample_line(wmOperatorType *ot) ot->name = "Sample Line"; ot->idname = "IMAGE_OT_sample_line"; ot->description = "Sample a line and show it in Scope panels"; - + /* api callbacks */ ot->invoke = image_sample_line_invoke; ot->modal = WM_gesture_straightline_modal; ot->exec = image_sample_line_exec; ot->poll = space_image_main_region_poll; ot->cancel = WM_gesture_straightline_cancel; - + /* flags */ ot->flag = 0; /* no undo/register since this operates on the space */ - + WM_operator_properties_gesture_straightline(ot, CURSOR_EDIT); } @@ -3270,7 +3270,7 @@ void IMAGE_OT_curves_point_set(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->invoke = image_sample_invoke; ot->modal = image_sample_modal; @@ -3296,19 +3296,19 @@ static int image_record_composite_apply(bContext *C, wmOperator *op) RecordCompositeData *rcd = op->customdata; Scene *scene = CTX_data_scene(C); ImBuf *ibuf; - + WM_cursor_time(CTX_wm_window(C), scene->r.cfra); // XXX scene->nodetree->test_break = BKE_blender_test_break; // XXX scene->nodetree->test_break = NULL; - + BKE_image_all_free_anim_ibufs(scene->r.cfra); ntreeCompositTagAnimated(scene->nodetree); ntreeCompositExecTree(scene->nodetree, &scene->r, 0, scene->r.cfra != rcd->old_cfra, &scene->view_settings, &scene->display_settings); /* 1 is no previews */ ED_area_tag_redraw(CTX_wm_area(C)); - + ibuf = BKE_image_acquire_ibuf(sima->image, &sima->iuser, NULL); /* save memory in flipbooks */ if (ibuf) @@ -3331,7 +3331,7 @@ static int image_record_composite_init(bContext *C, wmOperator *op) return 0; if (scene->nodetree == NULL) return 0; - + op->customdata = rcd = MEM_callocN(sizeof(RecordCompositeData), "ImageRecordCompositeData"); rcd->old_cfra = scene->r.cfra; @@ -3367,18 +3367,18 @@ static int image_record_composite_exec(bContext *C, wmOperator *op) { if (!image_record_composite_init(C, op)) return OPERATOR_CANCELLED; - + while (image_record_composite_apply(C, op)) {} - + image_record_composite_exit(C, op); - + return OPERATOR_FINISHED; } static int image_record_composite_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { RecordCompositeData *rcd; - + if (!image_record_composite_init(C, op)) return OPERATOR_CANCELLED; @@ -3424,7 +3424,7 @@ void IMAGE_OT_record_composite(wmOperatorType *ot) /* identifiers */ ot->name = "Record Composite"; ot->idname = "IMAGE_OT_record_composite"; - + /* api callbacks */ ot->exec = image_record_composite_exec; ot->invoke = image_record_composite_invoke; @@ -3458,7 +3458,7 @@ static int image_cycle_render_slot_exec(bContext *C, wmOperator *op) /* no undo push for browsing existing */ if (ima->renders[ima->render_slot] || ima->render_slot == ima->last_render_slot) return OPERATOR_CANCELLED; - + return OPERATOR_FINISHED; } @@ -3468,7 +3468,7 @@ void IMAGE_OT_cycle_render_slot(wmOperatorType *ot) ot->name = "Cycle Render Slot"; ot->idname = "IMAGE_OT_cycle_render_slot"; ot->description = "Cycle through all non-void render slots"; - + /* api callbacks */ ot->exec = image_cycle_render_slot_exec; ot->poll = image_cycle_render_slot_poll; diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index d179020b978..dbe7ae578c7 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -110,21 +110,21 @@ ARegion *image_has_buttons_region(ScrArea *sa) ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "buttons for image"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -140,17 +140,17 @@ ARegion *image_has_tools_region(ScrArea *sa) /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "scopes for image"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_TOOLS; arnew->alignment = RGN_ALIGN_LEFT; - + arnew->flag = RGN_FLAG_HIDDEN; image_scopes_tag_refresh(sa); - + return arnew; } @@ -160,7 +160,7 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceImage *simage; - + simage = MEM_callocN(sizeof(SpaceImage), "initimage"); simage->spacetype = SPACE_IMAGE; simage->zoom = 1.0f; @@ -177,22 +177,22 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) /* header */ ar = MEM_callocN(sizeof(ARegion), "header for image"); - + BLI_addtail(&simage->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* buttons/list view */ ar = MEM_callocN(sizeof(ARegion), "buttons for image"); - + BLI_addtail(&simage->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* scopes/uv sculpt/paint */ ar = MEM_callocN(sizeof(ARegion), "buttons for image"); - + BLI_addtail(&simage->regionbase, ar); ar->regiontype = RGN_TYPE_TOOLS; ar->alignment = RGN_ALIGN_LEFT; @@ -200,16 +200,16 @@ static SpaceLink *image_new(const bContext *UNUSED(C)) /* main area */ ar = MEM_callocN(sizeof(ARegion), "main area for image"); - + BLI_addtail(&simage->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + return (SpaceLink *)simage; } /* not spacelink itself */ static void image_free(SpaceLink *sl) -{ +{ SpaceImage *simage = (SpaceImage *) sl; scopes_free(&simage->scopes); @@ -223,13 +223,13 @@ static void image_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) /* add drop boxes */ WM_event_add_dropbox_handler(&sa->handlers, lb); - + } static SpaceLink *image_duplicate(SpaceLink *sl) { SpaceImage *simagen = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ scopes_new(&simagen->scopes); @@ -261,7 +261,7 @@ static void image_operatortypes(void) WM_operatortype_append(IMAGE_OT_save_sequence); WM_operatortype_append(IMAGE_OT_pack); WM_operatortype_append(IMAGE_OT_unpack); - + WM_operatortype_append(IMAGE_OT_invert); WM_operatortype_append(IMAGE_OT_cycle_render_slot); @@ -285,7 +285,7 @@ static void image_keymap(struct wmKeyConfig *keyconf) wmKeyMap *keymap = WM_keymap_find(keyconf, "Image Generic", SPACE_IMAGE, 0); wmKeyMapItem *kmi; int i; - + WM_keymap_add_item(keymap, "IMAGE_OT_new", NKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_open", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "IMAGE_OT_reload", RKEY, KM_PRESS, KM_ALT, 0); @@ -297,9 +297,9 @@ static void image_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "IMAGE_OT_cycle_render_slot", JKEY, KM_PRESS, KM_ALT, 0)->ptr, "reverse", true); - + keymap = WM_keymap_find(keyconf, "Image", SPACE_IMAGE, 0); - + WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "IMAGE_OT_view_all", HOMEKEY, KM_PRESS, KM_SHIFT, 0); @@ -392,7 +392,7 @@ static void image_drop_copy(wmDrag *drag, wmDropBox *drop) static void image_dropboxes(void) { ListBase *lb = WM_dropboxmap_find("Image", SPACE_IMAGE, 0); - + WM_dropbox_add(lb, "IMAGE_OT_open", image_drop_poll, image_drop_copy); } @@ -410,7 +410,7 @@ static void image_refresh(const bContext *C, ScrArea *sa) ima = ED_space_image(sima); BKE_image_user_check_frame_calc(&sima->iuser, scene->r.cfra, 0); - + /* check if we have to set the image from the editmesh */ if (ima && (ima->source == IMA_SRC_VIEWER && sima->mode == SI_MODE_MASK)) { if (scene->nodetree) { @@ -439,7 +439,7 @@ static void image_refresh(const bContext *C, ScrArea *sa) if (EDBM_uv_active_face_get(em, sloppy, selected, &tf)) { /* don't need to check for pin here, see above */ sima->image = tf->tpage; - + if ((sima->flag & SI_EDITTILE) == 0) { sima->curtile = tf->tile; } @@ -453,7 +453,7 @@ static void image_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn) { Scene *scene = sc->scene; SpaceImage *sima = (SpaceImage *)sa->spacedata.first; - + /* context changes */ switch (wmn->category) { case NC_WINDOW: @@ -604,7 +604,7 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar) Image *ima = ED_space_image(sima); float x1, y1, w, h; int width, height, winx, winy; - + #if 0 if (image_preview_active(curarea, &width, &height)) {} else @@ -613,18 +613,18 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar) w = width; h = height; - + if (ima) h *= ima->aspy / ima->aspx; winx = BLI_rcti_size_x(&ar->winrct) + 1; winy = BLI_rcti_size_y(&ar->winrct) + 1; - + ar->v2d.tot.xmin = 0; ar->v2d.tot.ymin = 0; ar->v2d.tot.xmax = w; ar->v2d.tot.ymax = h; - + ar->v2d.mask.xmin = ar->v2d.mask.ymin = 0; ar->v2d.mask.xmax = winx; ar->v2d.mask.ymax = winy; @@ -635,15 +635,15 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar) x1 -= sima->zoom * sima->xof; y1 -= sima->zoom * sima->yof; - + /* relative display right */ ar->v2d.cur.xmin = ((ar->winrct.xmin - (float)x1) / sima->zoom); ar->v2d.cur.xmax = ar->v2d.cur.xmin + ((float)winx / sima->zoom); - + /* relative display left */ ar->v2d.cur.ymin = ((ar->winrct.ymin - (float)y1) / sima->zoom); ar->v2d.cur.ymax = ar->v2d.cur.ymin + ((float)winy / sima->zoom); - + /* normalize 0.0..1.0 */ ar->v2d.cur.xmin /= w; ar->v2d.cur.xmax /= w; @@ -655,7 +655,7 @@ static void image_main_region_set_view2d(SpaceImage *sima, ARegion *ar) static void image_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + // image space manages own v2d // UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); @@ -675,7 +675,7 @@ static void image_main_region_init(wmWindowManager *wm, ARegion *ar) keymap = WM_keymap_find(wm->defaultconf, "UV Editor", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "UV Sculpt", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -702,7 +702,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) /* XXX not supported yet, disabling for now */ scene->r.scemode &= ~R_COMP_CROP; - + /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); @@ -834,7 +834,7 @@ static void image_buttons_region_init(wmWindowManager *wm, ARegion *ar) ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -883,10 +883,10 @@ static void image_buttons_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s static void image_tools_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "Image Generic", SPACE_IMAGE, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -913,7 +913,7 @@ static void image_tools_region_draw(const bContext *C, ARegion *ar) } } ED_space_image_release_buffer(sima, ibuf, lock); - + ED_region_panels(C, ar, NULL, -1, true); } @@ -946,7 +946,7 @@ static void image_tools_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa) case NC_NODE: ED_region_tag_redraw(ar); break; - + } } @@ -1023,10 +1023,10 @@ void ED_spacetype_image(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype image"); ARegionType *art; - + st->spaceid = SPACE_IMAGE; strncpy(st->name, "Image", BKE_ST_MAXNAME); - + st->new = image_new; st->free = image_free; st->init = image_init; @@ -1048,7 +1048,7 @@ void ED_spacetype_image(void) art->listener = image_main_region_listener; BLI_addhead(&st->regiontypes, art); - + /* regions: listview/buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype image region"); art->regionid = RGN_TYPE_UI; @@ -1080,9 +1080,9 @@ void ED_spacetype_image(void) art->listener = image_header_region_listener; art->init = image_header_region_init; art->draw = image_header_region_draw; - + BLI_addhead(&st->regiontypes, art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 6f8d380d231..9421567b6ba 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -236,7 +236,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, Re int draw, int mval[2], void **mouse_pick, int *pos_pick) { int ret = 0; - + View2D *v2d = &ar->v2d; TextViewContext tvc = {0}; @@ -260,7 +260,7 @@ static int info_textview_main__internal(struct SpaceInfo *sinfo, ARegion *ar, Re tvc.winx = ar->winx - V2D_SCROLL_WIDTH; ret = textview_draw(&tvc, draw, mval, mouse_pick, pos_pick); - + return ret; } diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 4b70daa3649..981630e96f6 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -87,7 +87,7 @@ void FILE_OT_pack_libraries(wmOperatorType *ot) ot->name = "Pack Blender Libraries"; ot->idname = "FILE_OT_pack_libraries"; ot->description = "Pack all used Blender library files into the current .blend"; - + /* api callbacks */ ot->exec = pack_libraries_exec; @@ -98,9 +98,9 @@ void FILE_OT_pack_libraries(wmOperatorType *ot) static int unpack_libraries_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - + unpackLibraries(bmain, op->reports); - + return OPERATOR_FINISHED; } @@ -115,11 +115,11 @@ void FILE_OT_unpack_libraries(wmOperatorType *ot) ot->name = "Unpack Blender Libraries"; ot->idname = "FILE_OT_unpack_libraries"; ot->description = "Unpack all used Blender library files from this .blend file"; - + /* api callbacks */ ot->invoke = unpack_libraries_invoke; ot->exec = unpack_libraries_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -131,13 +131,13 @@ static int autopack_toggle_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); if (G.fileflags & G_AUTOPACK) { - G.fileflags &= ~G_AUTOPACK; + G.fileflags &= ~G_AUTOPACK; } else { packAll(bmain, op->reports, true); G.fileflags |= G_AUTOPACK; } - + return OPERATOR_FINISHED; } @@ -147,10 +147,10 @@ void FILE_OT_autopack_toggle(wmOperatorType *ot) ot->name = "Automatically Pack Into .blend"; ot->idname = "FILE_OT_autopack_toggle"; ot->description = "Automatically pack all external files into the .blend file"; - + /* api callbacks */ ot->exec = autopack_toggle_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -160,9 +160,9 @@ void FILE_OT_autopack_toggle(wmOperatorType *ot) static int pack_all_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - + packAll(bmain, op->reports, true); - + return OPERATOR_FINISHED; } @@ -171,25 +171,25 @@ static int pack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(ev Main *bmain = CTX_data_main(C); Image *ima; ImBuf *ibuf; - + // first check for dirty images for (ima = bmain->image.first; ima; ima = ima->id.next) { if (BKE_image_has_loaded_ibuf(ima)) { /* XXX FIX */ ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL); - + if (ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) { BKE_image_release_ibuf(ima, ibuf, NULL); break; } - + BKE_image_release_ibuf(ima, ibuf, NULL); } } - + if (ima) { return WM_operator_confirm_message(C, op, "Some images are painted on. These changes will be lost. Continue?"); } - + return pack_all_exec(C, op); } @@ -199,11 +199,11 @@ void FILE_OT_pack_all(wmOperatorType *ot) ot->name = "Pack All Into .blend"; ot->idname = "FILE_OT_pack_all"; ot->description = "Pack all used external files into the .blend"; - + /* api callbacks */ ot->exec = pack_all_exec; ot->invoke = pack_all_invoke; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -238,9 +238,9 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( uiLayout *layout; char title[64]; int count = 0; - + count = countPackedFiles(bmain); - + if (!count) { BKE_report(op->reports, RPT_WARNING, "No packed files to unpack"); G.fileflags &= ~G_AUTOPACK; @@ -251,7 +251,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( BLI_strncpy(title, IFACE_("Unpack 1 File"), sizeof(title)); else BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count); - + pup = UI_popup_menu_begin(C, title, ICON_NONE); layout = UI_popup_menu_layout(pup); @@ -269,7 +269,7 @@ void FILE_OT_unpack_all(wmOperatorType *ot) ot->name = "Unpack All Into Files"; ot->idname = "FILE_OT_unpack_all"; ot->description = "Unpack all files packed into this .blend to external ones"; - + /* api callbacks */ ot->exec = unpack_all_exec; ot->invoke = unpack_all_invoke; @@ -307,12 +307,12 @@ static int unpack_item_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "No packed file"); return OPERATOR_CANCELLED; } - + if (method != PF_KEEP) BKE_unpack_id(bmain, id, op->reports, method); /* XXX PF_ASK can't work here */ - + G.fileflags &= ~G_AUTOPACK; - + return OPERATOR_FINISHED; } @@ -320,15 +320,15 @@ static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED { uiPopupMenu *pup; uiLayout *layout; - + pup = UI_popup_menu_begin(C, IFACE_("Unpack"), ICON_NONE); layout = UI_popup_menu_layout(pup); - + uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); uiItemsFullEnumO(layout, op->type->idname, "method", op->ptr->data, WM_OP_EXEC_REGION_WIN, 0); - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -338,14 +338,14 @@ void FILE_OT_unpack_item(wmOperatorType *ot) ot->name = "Unpack Item"; ot->idname = "FILE_OT_unpack_item"; ot->description = "Unpack this file to an external file"; - + /* api callbacks */ ot->exec = unpack_item_exec; ot->invoke = unpack_item_invoke; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ RNA_def_enum(ot->srna, "method", unpack_item_method_items, PF_USE_LOCAL, "Method", "How to unpack"); RNA_def_string(ot->srna, "id_name", NULL, BKE_ST_MAXNAME, "ID name", "Name of ID block to unpack"); @@ -378,7 +378,7 @@ void FILE_OT_make_paths_relative(wmOperatorType *ot) ot->name = "Make All Paths Relative"; ot->idname = "FILE_OT_make_paths_relative"; ot->description = "Make all paths to external files relative to current .blend"; - + /* api callbacks */ ot->exec = make_paths_relative_exec; @@ -411,7 +411,7 @@ void FILE_OT_make_paths_absolute(wmOperatorType *ot) ot->name = "Make All Paths Absolute"; ot->idname = "FILE_OT_make_paths_absolute"; ot->description = "Make all paths to external files absolute"; - + /* api callbacks */ ot->exec = make_paths_absolute_exec; @@ -427,7 +427,7 @@ static int report_missing_files_exec(bContext *C, wmOperator *op) /* run the missing file check */ BKE_bpath_missing_files_check(bmain, op->reports); - + return OPERATOR_FINISHED; } @@ -437,7 +437,7 @@ void FILE_OT_report_missing_files(wmOperatorType *ot) ot->name = "Report Missing Files"; ot->idname = "FILE_OT_report_missing_files"; ot->description = "Report all missing external files"; - + /* api callbacks */ ot->exec = report_missing_files_exec; @@ -462,7 +462,7 @@ static int find_missing_files_exec(bContext *C, wmOperator *op) static int find_missing_files_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { /* XXX file open button text "Find Missing Files" */ - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -472,7 +472,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) ot->name = "Find Missing Files"; ot->idname = "FILE_OT_find_missing_files"; ot->description = "Try to find missing external files"; - + /* api callbacks */ ot->exec = find_missing_files_exec; ot->invoke = find_missing_files_invoke; @@ -490,7 +490,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) /********************* report box operator *********************/ -/* Hard to decide whether to keep this as an operator, +/* Hard to decide whether to keep this as an operator, * or turn it into a hardcoded ui control feature, * handling TIMER events for all regions in interface_handlers.c * Not sure how good that is to be accessing UI data from @@ -513,7 +513,7 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co float neutral_gray = 0.6; float timeout = 0.0, color_timeout = 0.0; int send_note = 0; - + /* escape if not our timer */ if ((reports->reporttimer == NULL) || (reports->reporttimer != event->customdata) || @@ -524,17 +524,17 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co } rti = (ReportTimerInfo *)reports->reporttimer->customdata; - + timeout = (report->type & RPT_ERROR_ALL) ? ERROR_TIMEOUT : INFO_TIMEOUT; color_timeout = (report->type & RPT_ERROR_ALL) ? ERROR_COLOR_TIMEOUT : INFO_COLOR_TIMEOUT; - + /* clear the report display after timeout */ if ((float)reports->reporttimer->duration > timeout) { WM_event_remove_timer(wm, NULL, reports->reporttimer); reports->reporttimer = NULL; - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL); - + return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH); } @@ -558,14 +558,14 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co rti->grayscale = 0.75; rti->widthfac = 1.0; } - + progress = (float)reports->reporttimer->duration / timeout; color_progress = (float)reports->reporttimer->duration / color_timeout; - + /* save us from too many draws */ if (color_progress <= 1.0f) { send_note = 1; - + /* fade colors out sharply according to progress through fade-out duration */ interp_v3_v3v3(rti->col, rti->col, neutral_col, color_progress); rti->grayscale = interpf(neutral_gray, rti->grayscale, color_progress); @@ -577,11 +577,11 @@ static int update_reports_display_invoke(bContext *C, wmOperator *UNUSED(op), co rti->widthfac = 1.0f - rti->widthfac; send_note = 1; } - + if (send_note) { WM_event_add_notifier(C, NC_SPACE | ND_SPACE_INFO, NULL); } - + return (OPERATOR_FINISHED | OPERATOR_PASS_THROUGH); } @@ -591,13 +591,13 @@ void INFO_OT_reports_display_update(wmOperatorType *ot) ot->name = "Update Reports Display"; ot->idname = "INFO_OT_reports_display_update"; ot->description = "Update the display of reports in Blender UI (internal use)"; - + /* api callbacks */ ot->invoke = update_reports_display_invoke; - + /* flags */ ot->flag = 0; - + /* properties */ } diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 31df9b199ea..10d92366606 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -135,7 +135,7 @@ static int select_report_pick_invoke(bContext *C, wmOperator *op, const wmEvent /* uses opengl */ wmSubWindowSet(CTX_wm_window(C), ar->swinid); - + report = info_text_pick(sinfo, ar, reports, event->mval[1]); RNA_int_set(op->ptr, "report_index", BLI_findindex(&reports->list, report)); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 3e4fa3a1470..b00cb1fc585 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -67,7 +67,7 @@ typedef struct SceneStats { int totface, totfacesel; int totbone, totbonesel; int totobj, totobjsel; - int totlamp, totlampsel; + int totlamp, totlampsel; int tottri; char infostr[MAX_INFO_LEN]; @@ -151,10 +151,10 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) stats->totvert = em->bm->totvert; stats->totvertsel = em->bm->totvertsel; - + stats->totedge = em->bm->totedge; stats->totedgesel = em->bm->totedgesel; - + stats->totface = em->bm->totface; stats->totfacesel = em->bm->totfacesel; @@ -167,15 +167,15 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { stats->totbone++; - + if ((ebo->flag & BONE_CONNECTED) && ebo->parent) stats->totvert--; - + if (ebo->flag & BONE_TIPSEL) stats->totvertsel++; if (ebo->flag & BONE_ROOTSEL) stats->totvertsel++; - + if (ebo->flag & BONE_SELECTED) stats->totbonesel++; /* if this is a connected child and it's parent is being moved, remove our root */ @@ -224,7 +224,7 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) /* MetaBall Edit */ MetaBall *mball = obedit->data; MetaElem *ml; - + for (ml = mball->editelems->first; ml; ml = ml->next) { stats->totvert++; if (ml->flag & SELECT) stats->totvertsel++; @@ -238,7 +238,7 @@ static void stats_object_edit(Object *obedit, SceneStats *stats) int a; bp = editlatt->def; - + a = editlatt->pntsu * editlatt->pntsv * editlatt->pntsw; while (a--) { stats->totvert++; @@ -288,7 +288,7 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) else if (part->draw_as == PART_DRAW_GR && part->dup_group) { GroupObject *go; int tot, totgroup = 0, cur = 0; - + for (go = part->dup_group->gobject.first; go; go = go->next) totgroup++; @@ -299,7 +299,7 @@ static void stats_dupli_object(Base *base, Object *ob, SceneStats *stats) } } } - + stats_object(ob, base->flag & SELECT, 1, stats); stats->totobj++; } @@ -349,7 +349,7 @@ static void stats_update(Scene *scene) SceneStats stats = {0}; Object *ob = (scene->basact) ? scene->basact->object : NULL; Base *base; - + if (scene->obedit) { /* Edit Mode */ stats_object_edit(scene->obedit, &stats); diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 092a009512e..92b1be066b0 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -64,7 +64,7 @@ static SpaceLink *info_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceInfo *sinfo; - + sinfo = MEM_callocN(sizeof(SpaceInfo), "initinfo"); sinfo->spacetype = SPACE_INFO; @@ -72,17 +72,17 @@ static SpaceLink *info_new(const bContext *UNUSED(C)) /* header */ ar = MEM_callocN(sizeof(ARegion), "header for info"); - + BLI_addtail(&sinfo->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for info"); - + BLI_addtail(&sinfo->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + /* keep in sync with console */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT); ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */ @@ -93,15 +93,15 @@ static SpaceLink *info_new(const bContext *UNUSED(C)) /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); - + return (SpaceLink *)sinfo; } /* not spacelink itself */ static void info_free(SpaceLink *UNUSED(sl)) -{ +{ // SpaceInfo *sinfo = (SpaceInfo *) sl; - + } @@ -114,9 +114,9 @@ static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *info_duplicate(SpaceLink *sl) { SpaceInfo *sinfon = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ - + return (SpaceLink *)sinfon; } @@ -129,7 +129,7 @@ static void info_main_region_init(wmWindowManager *wm, ARegion *ar) /* force it on init, for old files, until it becomes config */ ar->v2d.scroll = (V2D_SCROLL_RIGHT); - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); /* own keymap */ @@ -159,7 +159,7 @@ static void info_main_region_draw(const bContext *C, ARegion *ar) /* quick way to avoid drawing if not bug enough */ if (ar->winy < 16) return; - + info_textview_update_rect(C, ar); /* worlks best with no view2d matrix set */ @@ -169,7 +169,7 @@ static void info_main_region_draw(const bContext *C, ARegion *ar) /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -184,7 +184,7 @@ static void info_operatortypes(void) WM_operatortype_append(FILE_OT_unpack_all); WM_operatortype_append(FILE_OT_unpack_item); WM_operatortype_append(FILE_OT_unpack_libraries); - + WM_operatortype_append(FILE_OT_make_paths_relative); WM_operatortype_append(FILE_OT_make_paths_absolute); WM_operatortype_append(FILE_OT_report_missing_files); @@ -204,13 +204,13 @@ static void info_operatortypes(void) static void info_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0); - + WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMERREPORT, KM_ANY, KM_ANY, 0); /* info space */ keymap = WM_keymap_find(keyconf, "Info", SPACE_INFO, 0); - - + + /* report selection */ WM_keymap_add_item(keymap, "INFO_OT_select_pick", SELECTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "INFO_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); @@ -276,7 +276,7 @@ static void info_header_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegi ED_region_tag_redraw(ar); break; } - + } static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu) @@ -313,17 +313,17 @@ void ED_spacetype_info(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype info"); ARegionType *art; - + st->spaceid = SPACE_INFO; strncpy(st->name, "Info", BKE_ST_MAXNAME); - + st->new = info_new; st->free = info_free; st->init = info_init; st->duplicate = info_duplicate; st->operatortypes = info_operatortypes; st->keymap = info_keymap; - + /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype info region"); art->regionid = RGN_TYPE_WINDOW; @@ -334,19 +334,19 @@ void ED_spacetype_info(void) art->listener = info_main_region_listener; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype info region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; - + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->listener = info_header_listener; art->init = info_header_region_init; art->draw = info_header_region_draw; - + BLI_addhead(&st->regiontypes, art); - + recent_files_menu_register(); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index c801a736e31..334106ff08d 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -61,7 +61,7 @@ typedef struct ConsoleDrawContext { int ymin, ymax; int *xy; // [2] int *sel; // [2] - int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. + int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. const int *mval; // [2] int draw; } ConsoleDrawContext; @@ -173,14 +173,14 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str size_t len = str_len - initial_offset; const char *s = str + initial_offset; int i; - + int sel_orig[2]; copy_v2_v2_int(sel_orig, cdc->sel); /* invert and swap for wrapping */ cdc->sel[0] = str_len - sel_orig[1]; cdc->sel[1] = str_len - sel_orig[0]; - + if (bg) { glColor3ubv(bg); glRecti(0, cdc->xy[1], cdc->winx, (cdc->xy[1] + (cdc->lheight * tot_lines))); @@ -207,7 +207,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str BLF_position(cdc->font_id, cdc->xy[0], cdc->lofs + cdc->xy[1], 0); BLF_draw_mono(cdc->font_id, s, len, cdc->cwidth); - + if (cdc->sel[0] != cdc->sel[1]) { console_step_sel(cdc, len); // glColor4ub(0, 255, 0, 96); // debug @@ -216,7 +216,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str } cdc->xy[1] += cdc->lheight; - + /* check if were out of view bounds */ if (cdc->xy[1] > cdc->ymax) { MEM_freeN(offsets); @@ -238,7 +238,7 @@ static int console_draw_string(ConsoleDrawContext *cdc, const char *str, int str BLF_position(cdc->font_id, cdc->xy[0], cdc->lofs + cdc->xy[1], 0); BLF_draw_mono(cdc->font_id, str, str_len, cdc->cwidth); - + if (cdc->sel[0] != cdc->sel[1]) { int isel[2]; diff --git a/source/blender/editors/space_info/textview.h b/source/blender/editors/space_info/textview.h index 2f9e518ed47..55f69fbf444 100644 --- a/source/blender/editors/space_info/textview.h +++ b/source/blender/editors/space_info/textview.h @@ -37,7 +37,7 @@ typedef struct TextViewContext { int winx; int ymin, ymax; - + /* callbacks */ int (*begin)(struct TextViewContext *tvc); void (*end)(struct TextViewContext *tvc); diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index 54e6e217b77..9de3daa41ca 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -53,7 +53,7 @@ static int logic_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = logic_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -65,10 +65,10 @@ void LOGIC_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->description = "Toggle the properties region visibility"; ot->idname = "LOGIC_OT_properties"; - + ot->exec = logic_properties_toggle_exec; ot->poll = ED_operator_logic_active; - + /* flags */ ot->flag = 0; } @@ -102,11 +102,11 @@ static int cut_links_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; int i = 0; - + RNA_BEGIN (op->ptr, itemptr, "path") { float loc[2]; - + RNA_float_get_array(&itemptr, "loc", loc); UI_view2d_region_to_view(&ar->v2d, (int)loc[0], (int)loc[1], @@ -145,17 +145,17 @@ void LOGIC_OT_links_cut(wmOperatorType *ot) ot->name = "Cut Links"; ot->idname = "LOGIC_OT_links_cut"; ot->description = "Remove logic brick connections"; - + ot->invoke = WM_gesture_lines_invoke; ot->modal = WM_gesture_lines_modal; ot->exec = cut_links_exec; ot->cancel = WM_gesture_lines_cancel; - + ot->poll = ED_operator_logic_active; - + /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - + /* properties */ PropertyRNA *prop; prop = RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index 8982eeabf2b..143583a9600 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -95,19 +95,19 @@ static void edit_sensor_properties(wmOperatorType *ot) static int edit_sensor_invoke_properties(bContext *C, wmOperator *op) { PointerRNA ptr = CTX_data_pointer_get_type(C, "sensor", &RNA_Sensor); - + if (RNA_struct_property_is_set(op->ptr, "sensor") && RNA_struct_property_is_set(op->ptr, "object") ) return 1; - + if (ptr.data) { bSensor *sens = ptr.data; Object *ob = ptr.id.data; - + RNA_string_set(op->ptr, "sensor", sens->name); RNA_string_set(op->ptr, "object", ob->id.name + 2); return 1; } - + return 0; } @@ -132,12 +132,12 @@ static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **o { char sensor_name[MAX_NAME]; bSensor *sens; - + RNA_string_get(op->ptr, "sensor", sensor_name); *ob = edit_object_property_get(C, op); if (!*ob) return NULL; - + sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name)); return sens; } @@ -151,19 +151,19 @@ static void edit_controller_properties(wmOperatorType *ot) static int edit_controller_invoke_properties(bContext *C, wmOperator *op) { PointerRNA ptr = CTX_data_pointer_get_type(C, "controller", &RNA_Controller); - + if (RNA_struct_property_is_set(op->ptr, "controller") && RNA_struct_property_is_set(op->ptr, "object") ) return 1; - + if (ptr.data) { bController *cont = ptr.data; Object *ob = ptr.id.data; - + RNA_string_set(op->ptr, "controller", cont->name); RNA_string_set(op->ptr, "object", ob->id.name + 2); return 1; } - + return 0; } @@ -171,12 +171,12 @@ static bController *edit_controller_property_get(bContext *C, wmOperator *op, Ob { char controller_name[MAX_NAME]; bController *cont; - + RNA_string_get(op->ptr, "controller", controller_name); *ob = edit_object_property_get(C, op); if (!*ob) return NULL; - + cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name)); return cont; } @@ -190,19 +190,19 @@ static void edit_actuator_properties(wmOperatorType *ot) static int edit_actuator_invoke_properties(bContext *C, wmOperator *op) { PointerRNA ptr = CTX_data_pointer_get_type(C, "actuator", &RNA_Actuator); - + if (RNA_struct_property_is_set(op->ptr, "actuator") && RNA_struct_property_is_set(op->ptr, "object") ) return 1; - + if (ptr.data) { bActuator *act = ptr.data; Object *ob = ptr.id.data; - + RNA_string_set(op->ptr, "actuator", act->name); RNA_string_set(op->ptr, "object", ob->id.name + 2); return 1; } - + return 0; } @@ -210,12 +210,12 @@ static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object { char actuator_name[MAX_NAME]; bActuator *act; - + RNA_string_get(op->ptr, "actuator", actuator_name); *ob = edit_object_property_get(C, op); if (!*ob) return NULL; - + act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name)); return act; } @@ -236,15 +236,15 @@ static int sensor_remove_exec(bContext *C, wmOperator *op) { Object *ob = NULL; bSensor *sens = edit_sensor_property_get(C, op, &ob); - + if (!sens) return OPERATOR_CANCELLED; - + BLI_remlink(&(ob->sensors), sens); free_sensor(sens); - + WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } @@ -261,11 +261,11 @@ static void LOGIC_OT_sensor_remove(wmOperatorType *ot) ot->name = "Remove Sensor"; ot->description = "Remove a sensor from the active object"; ot->idname = "LOGIC_OT_sensor_remove"; - + ot->invoke = sensor_remove_invoke; ot->exec = sensor_remove_exec; ot->poll = edit_sensor_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_sensor_properties(ot); @@ -287,7 +287,7 @@ static int sensor_add_exec(bContext *C, wmOperator *op) sens = new_sensor(type); BLI_addtail(&(ob->sensors), sens); - + /* set the sensor name based on rna type enum */ RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &sens_ptr); prop = RNA_struct_find_property(&sens_ptr, "type"); @@ -305,27 +305,27 @@ static int sensor_add_exec(bContext *C, wmOperator *op) ob->scaflag |= OB_SHOWSENS; WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } static void LOGIC_OT_sensor_add(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Add Sensor"; ot->description = "Add a sensor to the active object"; ot->idname = "LOGIC_OT_sensor_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = sensor_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ ot->prop = prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, SENS_ALWAYS, "Type", "Type of sensor to add"); RNA_def_enum_funcs(prop, rna_Sensor_type_itemf); @@ -341,16 +341,16 @@ static int controller_remove_exec(bContext *C, wmOperator *op) { Object *ob = NULL; bController *cont = edit_controller_property_get(C, op, &ob); - + if (!cont) return OPERATOR_CANCELLED; - + BLI_remlink(&(ob->controllers), cont); unlink_controller(cont); free_controller(cont); - + WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } @@ -367,11 +367,11 @@ static void LOGIC_OT_controller_remove(wmOperatorType *ot) ot->name = "Remove Controller"; ot->description = "Remove a controller from the active object"; ot->idname = "LOGIC_OT_controller_remove"; - + ot->invoke = controller_remove_invoke; ot->exec = controller_remove_exec; ot->poll = edit_controller_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_controller_properties(ot); @@ -391,10 +391,10 @@ static int controller_add_exec(bContext *C, wmOperator *op) ob = edit_object_property_get(C, op); if (!ob) return OPERATOR_CANCELLED; - + cont = new_controller(type); BLI_addtail(&(ob->controllers), cont); - + /* set the controller name based on rna type enum */ RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &cont_ptr); prop = RNA_struct_find_property(&cont_ptr, "type"); @@ -422,11 +422,11 @@ static int controller_add_exec(bContext *C, wmOperator *op) /* shouldn't happen, object state is never 0 */ cont->state_mask = 1; } - + ob->scaflag |= OB_SHOWCONT; - + WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } @@ -438,15 +438,15 @@ static void LOGIC_OT_controller_add(wmOperatorType *ot) ot->name = "Add Controller"; ot->description = "Add a controller to the active object"; ot->idname = "LOGIC_OT_controller_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = controller_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_controller_type_items, CONT_LOGIC_AND, "Type", "Type of controller to add"); prop = RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the Controller to add"); @@ -461,16 +461,16 @@ static int actuator_remove_exec(bContext *C, wmOperator *op) { Object *ob = NULL; bActuator *act = edit_actuator_property_get(C, op, &ob); - + if (!act) return OPERATOR_CANCELLED; - + BLI_remlink(&(ob->actuators), act); unlink_actuator(act); free_actuator(act); - + WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } @@ -487,11 +487,11 @@ static void LOGIC_OT_actuator_remove(wmOperatorType *ot) ot->name = "Remove Actuator"; ot->description = "Remove an actuator from the active object"; ot->idname = "LOGIC_OT_actuator_remove"; - + ot->invoke = actuator_remove_invoke; ot->exec = actuator_remove_exec; ot->poll = edit_actuator_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; edit_actuator_properties(ot); @@ -506,14 +506,14 @@ static int actuator_add_exec(bContext *C, wmOperator *op) const char *act_name; char name[MAX_NAME]; int type = RNA_enum_get(op->ptr, "type"); - + ob = edit_object_property_get(C, op); if (!ob) return OPERATOR_CANCELLED; act = new_actuator(type); BLI_addtail(&(ob->actuators), act); - + /* set the actuator name based on rna type enum */ RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &act_ptr); prop = RNA_struct_find_property(&act_ptr, "type"); @@ -529,29 +529,29 @@ static int actuator_add_exec(bContext *C, wmOperator *op) BLI_uniquename(&ob->actuators, act, DATA_("Actuator"), '.', offsetof(bActuator, name), sizeof(act->name)); ob->scaflag |= OB_SHOWACT; - + WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } static void LOGIC_OT_actuator_add(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Add Actuator"; ot->description = "Add an actuator to the active object"; ot->idname = "LOGIC_OT_actuator_add"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = actuator_add_exec; ot->poll = ED_operator_object_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ ot->prop = prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, CONT_LOGIC_AND, "Type", "Type of actuator to add"); RNA_def_enum_funcs(prop, rna_Actuator_type_itemf); @@ -574,14 +574,14 @@ static int sensor_move_exec(bContext *C, wmOperator *op) Object *ob = NULL; bSensor *sens = edit_sensor_property_get(C, op, &ob); int move_up = logicbricks_move_property_get(op); - + if (!sens) return OPERATOR_CANCELLED; sca_move_sensor(sens, ob, move_up); WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } @@ -600,15 +600,15 @@ static void LOGIC_OT_sensor_move(wmOperatorType *ot) ot->name = "Move Sensor"; ot->description = "Move Sensor"; ot->idname = "LOGIC_OT_sensor_move"; - + /* api callbacks */ ot->invoke = sensor_move_invoke; ot->exec = sensor_move_exec; ot->poll = edit_sensor_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ edit_sensor_properties(ot); RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down"); @@ -619,14 +619,14 @@ static int controller_move_exec(bContext *C, wmOperator *op) Object *ob = NULL; bController *cont = edit_controller_property_get(C, op, &ob); int move_up = logicbricks_move_property_get(op); - + if (!cont) return OPERATOR_CANCELLED; sca_move_controller(cont, ob, move_up); WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } @@ -645,15 +645,15 @@ static void LOGIC_OT_controller_move(wmOperatorType *ot) ot->name = "Move Controller"; ot->description = "Move Controller"; ot->idname = "LOGIC_OT_controller_move"; - + /* api callbacks */ ot->invoke = controller_move_invoke; ot->exec = controller_move_exec; ot->poll = edit_controller_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ edit_controller_properties(ot); RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down"); @@ -671,7 +671,7 @@ static int actuator_move_exec(bContext *C, wmOperator *op) sca_move_actuator(act, ob, move_up); WM_event_add_notifier(C, NC_LOGIC, NULL); - + return OPERATOR_FINISHED; } @@ -690,15 +690,15 @@ static void LOGIC_OT_actuator_move(wmOperatorType *ot) ot->name = "Move Actuator"; ot->description = "Move Actuator"; ot->idname = "LOGIC_OT_actuator_move"; - + /* api callbacks */ ot->invoke = actuator_move_invoke; ot->exec = actuator_move_exec; ot->poll = edit_actuator_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; - + /* properties */ edit_actuator_properties(ot); RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down"); @@ -712,10 +712,10 @@ static int logic_view_all_exec(bContext *C, wmOperator *op) rctf cur_new = ar->v2d.tot; float aspect = BLI_rctf_size_y(&ar->v2d.cur) / BLI_rctf_size_x(&ar->v2d.cur); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - + /* force the view2d code to zoom to width, not height */ cur_new.ymin = cur_new.ymax - BLI_rctf_size_x(&cur_new) * aspect; - + UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx); return OPERATOR_FINISHED; @@ -727,11 +727,11 @@ static void LOGIC_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "LOGIC_OT_view_all"; ot->description = "Resize view so you can see all logic bricks"; - + /* api callbacks */ ot->exec = logic_view_all_exec; ot->poll = ED_operator_logic_active; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 22c409636c1..c3729dd588e 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -104,10 +104,10 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) bActuator *act; Object *ob; int didit, bit; - + ob= CTX_data_active_object(C); if (ob==NULL) return; - + switch (event) { case B_SETPROP: @@ -120,7 +120,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) case B_SETMAINACTOR: ob->gameflag &= ~(OB_SECTOR|OB_PROP); break; - + case B_ADD_SENS: for (ob=bmain->object.first; ob; ob=ob->id.next) { if (ob->scaflag & OB_ADDSENS) { @@ -131,7 +131,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) ob->scaflag |= OB_SHOWSENS; } } - + ED_undo_push(C, "Add sensor"); break; @@ -148,7 +148,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) } } break; - + case B_DEL_SENS: for (ob=bmain->object.first; ob; ob=ob->id.next) { sens= ob->sensors.first; @@ -163,7 +163,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) } ED_undo_push(C, "Delete sensor"); break; - + case B_ADD_CONT: for (ob=bmain->object.first; ob; ob=ob->id.next) { if (ob->scaflag & OB_ADDCONT) { @@ -222,7 +222,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) } } break; - + case B_DEL_CONT: for (ob=bmain->object.first; ob; ob=ob->id.next) { @@ -282,7 +282,7 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) } ED_undo_push(C, "Delete actuator"); break; - + case B_SOUNDACT_BROWSE: /* since we don't know which... */ didit= 0; @@ -307,16 +307,16 @@ static void do_logic_buts(bContext *C, void *UNUSED(arg), int event) nr++; sound= sound->next; } - + if (sa->sound) id_us_min(((ID *)sa->sound)); - + sa->sound= (struct bSound *)sound; - + if (sound) { id_us_plus(sound); } - + sa->sndnr= 0; didit= 1; } @@ -469,25 +469,25 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf bController *cont; unsigned int lay; int a, nr, do_it; - + /* we need a sorted object list */ /* set scavisflags flags in Objects to indicate these should be evaluated */ /* also hide ob pointers in ->new entries of controllerss/actuators */ - + *count= 0; - + if (scene==NULL) return NULL; - + ob= bmain->object.first; while (ob) { ob->scavisflag= 0; set_sca_ob(ob); ob= ob->id.next; } - + /* XXX here it checked 3d lay */ lay= scene->lay; - + base= FIRSTBASE; while (base) { if (base->lay & lay) { @@ -505,16 +505,16 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf if (scavisflag & BUTS_CONT_ACT) obact->scavisflag |= OB_VIS_CONT; if (scavisflag & BUTS_ACT_ACT) obact->scavisflag |= OB_VIS_ACT; } - + /* BUTS_XXX_STATE are similar to BUTS_XXX_LINK for selecting the object */ if (scavisflag & (BUTS_SENS_LINK|BUTS_CONT_LINK|BUTS_ACT_LINK|BUTS_SENS_STATE|BUTS_ACT_STATE)) { do_it = true; while (do_it) { do_it = false; - + ob= bmain->object.first; while (ob) { - + /* 1st case: select sensor when controller selected */ if ((scavisflag & (BUTS_SENS_LINK|BUTS_SENS_STATE)) && (ob->scavisflag & OB_VIS_SENS)==0) { sens= ob->sensors.first; @@ -533,7 +533,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf sens= sens->next; } } - + /* 2nd case: select cont when act selected */ if ((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_CONT)==0) { cont= ob->controllers.first; @@ -552,7 +552,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf cont= cont->next; } } - + /* 3rd case: select controller when sensor selected */ if ((scavisflag & BUTS_CONT_LINK) && (ob->scavisflag & OB_VIS_SENS)) { sens= ob->sensors.first; @@ -569,7 +569,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf sens= sens->next; } } - + /* 4th case: select actuator when controller selected */ if ((scavisflag & (BUTS_ACT_LINK|BUTS_ACT_STATE)) && (ob->scavisflag & OB_VIS_CONT)) { cont= ob->controllers.first; @@ -585,13 +585,13 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf } cont= cont->next; } - + } ob= ob->id.next; } } } - + /* now we count */ ob= bmain->object.first; while (ob) { @@ -601,9 +601,9 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf if (*count == 0) return NULL; if (*count > 24) *count = 24; /* temporal */ - + idar= MEM_callocN((*count)*sizeof(void *), "idar"); - + ob= bmain->object.first; nr= 0; @@ -621,10 +621,10 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf if (nr >= 24) break; ob= ob->id.next; } - + /* just to be sure... these were set in set_sca_done_ob() */ clear_sca_new_poins(); - + return idar; } @@ -644,21 +644,21 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co } static void do_sensor_menu(bContext *C, void *UNUSED(arg), int event) -{ +{ SpaceLogic *slogic= CTX_wm_space_logic(C); ID **idar; Object *ob; bSensor *sens; short count, a; - + idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - + for (a=0; ascaflag |= OB_SHOWSENS; else if (event==1) ob->scaflag &= ~OB_SHOWSENS; } - + for (a=0; asensors.first; @@ -676,10 +676,10 @@ static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) { uiBlock *block; int yco=0; - + block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN); UI_block_func_butmenu_set(block, do_sensor_menu, NULL); - + uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -688,20 +688,20 @@ static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) UI_block_direction_set(block, UI_DIR_UP); UI_block_end(C, block); - + return block; } static void do_controller_menu(bContext *C, void *UNUSED(arg), int event) -{ +{ SpaceLogic *slogic= CTX_wm_space_logic(C); ID **idar; Object *ob; bController *cont; short count, a; - + idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - + for (a=0; ascaflag |= OB_SHOWCONT; @@ -725,10 +725,10 @@ static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) { uiBlock *block; int yco=0; - + block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN); UI_block_func_butmenu_set(block, do_controller_menu, NULL); - + uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -737,20 +737,20 @@ static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) UI_block_direction_set(block, UI_DIR_UP); UI_block_end(C, block); - + return block; } static void do_actuator_menu(bContext *C, void *UNUSED(arg), int event) -{ +{ SpaceLogic *slogic= CTX_wm_space_logic(C); ID **idar; Object *ob; bActuator *act; short count, a; - + idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - + for (a=0; ascaflag |= OB_SHOWACT; @@ -774,10 +774,10 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) { uiBlock *block; int xco=0; - + block= UI_block_begin(C, ar, __func__, UI_EMBOSS_PULLDOWN); UI_block_func_butmenu_set(block, do_actuator_menu, NULL); - + uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Show Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); uiDefBut(block, UI_BTYPE_BUT_MENU, 1, IFACE_("Hide Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, UI_BTYPE_SEPR_LINE, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -786,7 +786,7 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) UI_block_direction_set(block, UI_DIR_UP); UI_block_end(C, block); - + return block; } @@ -794,7 +794,7 @@ static void check_controller_state_mask(bContext *UNUSED(C), void *arg1_but, voi { unsigned int *cont_mask = arg2_mask; uiBut *but = arg1_but; - + /* a controller is always in a single state */ *cont_mask = (1<retval); but->retval = B_REDR; @@ -812,7 +812,7 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c /* use this for a fake extra empy space around the buttons */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, ""); - + for (offset=0; offset<15; offset += 5) { UI_block_align_begin(block); for (stbit=0; stbit<5; stbit++) { @@ -851,10 +851,10 @@ static void draw_sensor_header(uiLayout *layout, PointerRNA *ptr, PointerRNA *lo { uiLayout *box, *row, *sub; bSensor *sens= (bSensor *)ptr->data; - + box = uiLayoutBox(layout); row = uiLayoutRow(box, false); - + sub = uiLayoutRow(row, false); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active")); uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); @@ -895,7 +895,7 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) box = uiLayoutBox(layout); uiLayoutSetActive(box, RNA_boolean_get(ptr, "active")); split = uiLayoutSplit(box, 0.45f, false); - + row = uiLayoutRow(split, true); uiItemR(row, ptr, "use_pulse_true_level", 0, "", ICON_DOTSUP); uiItemR(row, ptr, "use_pulse_false_level", 0, "", ICON_DOTSDOWN); @@ -904,11 +904,11 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") || RNA_boolean_get(ptr, "use_pulse_false_level"))); uiItemR(sub, ptr, "tick_skip", 0, IFACE_("Skip"), ICON_NONE); - + row = uiLayoutRow(split, true); uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - + uiItemR(split, ptr, "invert", UI_ITEM_R_TOGGLE, IFACE_("Invert"), ICON_NONE); } /* sensors in alphabetical order */ @@ -977,7 +977,7 @@ static void draw_sensor_collision(uiLayout *layout, PointerRNA *ptr, bContext *C static void draw_sensor_delay(uiLayout *layout, PointerRNA *ptr) { uiLayout *row; - + row = uiLayoutRow(layout, false); uiItemR(row, ptr, "delay", 0, NULL, ICON_NONE); @@ -1039,13 +1039,13 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE); col = uiLayoutColumn(row, false); uiItemR(col, ptr, "use_all_keys", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, false); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == false); row = uiLayoutRow(col, false); uiItemL(row, IFACE_("First Modifier:"), ICON_NONE); uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE); - + row = uiLayoutRow(col, false); uiItemL(row, IFACE_("Second Modifier:"), ICON_NONE); uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE); @@ -1169,12 +1169,12 @@ static void draw_sensor_ray(uiLayout *layout, PointerRNA *ptr, bContext *C) static void draw_brick_sensor(uiLayout *layout, PointerRNA *ptr, bContext *C) { uiLayout *box; - + if (!RNA_boolean_get(ptr, "show_expanded")) return; draw_sensor_internal_header(layout, ptr); - + box = uiLayoutBox(layout); uiLayoutSetActive(box, RNA_boolean_get(ptr, "active")); @@ -1232,10 +1232,10 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i char state[3]; BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states")); - + box = uiLayoutBox(layout); row = uiLayoutRow(box, false); - + sub = uiLayoutRow(row, false); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "active")); uiItemR(sub, ptr, "show_expanded", UI_ITEM_R_NO_BG, "", ICON_NONE); @@ -1299,15 +1299,15 @@ static void draw_controller_state(uiLayout *UNUSED(layout), PointerRNA *UNUSED(p static void draw_brick_controller(uiLayout *layout, PointerRNA *ptr) { uiLayout *box; - + if (!RNA_boolean_get(ptr, "show_expanded")) return; - + box = uiLayoutBox(layout); uiLayoutSetActive(box, RNA_boolean_get(ptr, "active")); draw_controller_state(box, ptr); - + switch (RNA_enum_get(ptr, "type")) { case CONT_LOGIC_AND: break; @@ -1335,7 +1335,7 @@ static void draw_actuator_header(uiLayout *layout, PointerRNA *ptr, PointerRNA * { uiLayout *box, *row, *sub; bActuator *act= (bActuator *)ptr->data; - + box = uiLayoutBox(layout); row = uiLayoutRow(box, false); @@ -1435,14 +1435,14 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) uiItemL(layout, IFACE_("Actuator only available for armatures"), ICON_NONE); return; } - + if (ob->pose) { RNA_pointer_create((ID *)ob, &RNA_Pose, ob->pose, &pose_ptr); bones_prop = RNA_struct_find_property(&pose_ptr, "bones"); } - + uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); - + switch (RNA_enum_get(ptr, "mode")) { case ACT_ARM_RUN: break; @@ -1458,7 +1458,7 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) case ACT_ARM_SETTARGET: if (ob->pose) { uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA); - + if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr)) uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE); } @@ -1474,7 +1474,7 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) case ACT_ARM_SETWEIGHT: if (ob->pose) { uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA); - + if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr)) uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE); } @@ -1484,7 +1484,7 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) case ACT_ARM_SETINFLUENCE: if (ob->pose) { uiItemPointerR(layout, ptr, "bone", &pose_ptr, "bones", NULL, ICON_BONE_DATA); - + if (RNA_property_collection_lookup_string(&pose_ptr, bones_prop, aa->posechannel, &pchan_ptr)) uiItemPointerR(layout, ptr, "constraint", &pchan_ptr, "constraints", NULL, ICON_CONSTRAINT_BONE); } @@ -1733,9 +1733,9 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) ob = (Object *)ptr->id.data; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); physics_type = RNA_enum_get(&settings_ptr, "physics_type"); - + uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); - + switch (RNA_enum_get(ptr, "mode")) { case ACT_OBJECT_NORMAL: split = uiLayoutSplit(layout, 0.9, false); @@ -1747,7 +1747,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) row = uiLayoutRow(split, false); uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - + if (ELEM(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) { uiItemL(layout, IFACE_("Dynamic Object Settings:"), ICON_NONE); split = uiLayoutSplit(layout, 0.9, false); @@ -2030,7 +2030,7 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) uiItemR(row, ptr, "pitch", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_sound_3d", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, false); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_sound_3d") == true); @@ -2185,13 +2185,13 @@ static void draw_actuator_mouse(uiLayout *layout, PointerRNA *ptr) static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C) { uiLayout *box; - + if (!RNA_boolean_get(ptr, "show_expanded")) return; - + box = uiLayoutBox(layout); uiLayoutSetActive(box, RNA_boolean_get(ptr, "active")); - + switch (RNA_enum_get(ptr, "type")) { case ACT_ACTION: draw_actuator_action(box, ptr); @@ -2265,17 +2265,17 @@ void logic_buttons(bContext *C, ARegion *ar) char uiblockstr[32]; short a, count; int xco, yco, width, height; - + if (ob==NULL) return; - + RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr); idar= get_selected_and_linked_obs(C, &count, slogic->scaflag); - + BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar); block= UI_block_begin(C, ar, uiblockstr, UI_EMBOSS); UI_block_func_handle_set(block, do_logic_buts, NULL); UI_block_bounds_set_normal(block, U.widget_unit/2); - + /* loop over all objects and set visible/linked flags for the logic bricks */ for (a=0; aactuators.first; while (act) { @@ -2316,15 +2316,15 @@ void logic_buttons(bContext *C, ARegion *ar) cont = cont->next; } } - + /* ****************** Controllers ****************** */ - + xco= 21 * U.widget_unit; yco= - U.widget_unit / 2; width= 15 * U.widget_unit; layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get()); row = uiLayoutRow(layout, true); - + uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco - U.widget_unit / 2, yco, width, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ - + uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, IFACE_("Sel"), ICON_NONE); uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, IFACE_("Act"), ICON_NONE); uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, IFACE_("Link"), ICON_NONE); @@ -2334,14 +2334,14 @@ void logic_buttons(bContext *C, ARegion *ar) PointerRNA ptr; uiLayout *split, *subsplit, *col; - + ob= (Object *)idar[a]; /* only draw the controller common header if "use_visible" */ if ( (ob->scavisflag & OB_VIS_CONT) == 0) { continue; } - + /* Drawing the Controller Header common to all Selected Objects */ RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); @@ -2381,19 +2381,19 @@ void logic_buttons(bContext *C, ARegion *ar) /* End of Drawing the Controller Header common to all Selected Objects */ if ((ob->scaflag & OB_SHOWCONT) == 0) continue; - + uiItemS(layout); - + for (cont= ob->controllers.first; cont; cont=cont->next) { RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &ptr); - + if (!(ob->scaflag & OB_ALLSTATE) && !(ob->state & cont->state_mask)) continue; - + /* use two nested splits to align inlinks/links properly */ split = uiLayoutSplit(layout, 0.05f, false); - + /* put inlink button to the left */ col = uiLayoutColumn(split, false); uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); @@ -2402,21 +2402,21 @@ void logic_buttons(bContext *C, ARegion *ar) if (!RNA_boolean_get(&ptr, "active")) { UI_but_flag_enable(but, UI_BUT_SCA_LINK_GREY); } - + //col = uiLayoutColumn(split, true); /* nested split for middle and right columns */ subsplit = uiLayoutSplit(split, 0.95f, false); - + col = uiLayoutColumn(subsplit, true); uiLayoutSetContextPointer(col, "controller", &ptr); - + /* should make UI template for controller header.. function will do for now */ // draw_controller_header(col, &ptr); draw_controller_header(col, &ptr, xco, width, yco); //provisory for 2.50 beta /* draw the brick contents */ draw_brick_controller(col, &ptr); - + /* put link button to the right */ col = uiLayoutColumn(subsplit, false); uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); @@ -2432,24 +2432,24 @@ void logic_buttons(bContext *C, ARegion *ar) } UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */ height = yco; - + /* ****************** Sensors ****************** */ - + xco= U.widget_unit / 2; yco= -U.widget_unit / 2; width= 17 * U.widget_unit; layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get()); row = uiLayoutRow(layout, true); - + uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ - + uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, IFACE_("Sel"), ICON_NONE); uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, IFACE_("Act"), ICON_NONE); uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, IFACE_("Link"), ICON_NONE); uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, IFACE_("State"), ICON_NONE); - + for (a=0; ascaflag & OB_SHOWSENS) == 0) continue; - + uiItemS(layout); - + for (sens= ob->sensors.first; sens; sens=sens->next) { RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &ptr); - + if ((ob->scaflag & OB_ALLSTATE) || !(slogic->scaflag & BUTS_SENS_STATE) || (sens->totlinks == 0) || /* always display sensor without links so that is can be edited */ @@ -2484,13 +2484,13 @@ void logic_buttons(bContext *C, ARegion *ar) split = uiLayoutSplit(layout, 0.95f, false); col = uiLayoutColumn(split, true); uiLayoutSetContextPointer(col, "sensor", &ptr); - + /* should make UI template for sensor header.. function will do for now */ draw_sensor_header(col, &ptr, &logic_ptr); - + /* draw the brick contents */ draw_brick_sensor(col, &ptr, C); - + /* put link button to the right */ col = uiLayoutColumn(split, false); uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); @@ -2506,24 +2506,24 @@ void logic_buttons(bContext *C, ARegion *ar) } UI_block_layout_resolve(block, NULL, &yco); /* stores final height in yco */ height = MIN2(height, yco); - + /* ****************** Actuators ****************** */ - + xco= 40 * U.widget_unit; yco= -U.widget_unit / 2; width= 17 * U.widget_unit; layout= UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, 0, UI_style_get()); row = uiLayoutRow(layout, true); - + uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco - U.widget_unit / 2, yco, 15 * U.widget_unit, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ - + uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, IFACE_("Sel"), ICON_NONE); uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, IFACE_("Act"), ICON_NONE); uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, IFACE_("Link"), ICON_NONE); uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, IFACE_("State"), ICON_NONE); - + for (a=0; ascaflag & OB_SHOWACT) == 0) continue; - + uiItemS(layout); - + for (act= ob->actuators.first; act; act=act->next) { - + RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &ptr); - + if ((ob->scaflag & OB_ALLSTATE) || !(slogic->scaflag & BUTS_ACT_STATE) || !(act->flag & ACT_LINKED) || /* always display actuators without links so that is can be edited */ @@ -2554,12 +2554,12 @@ void logic_buttons(bContext *C, ARegion *ar) ) { // gotta check if the current state is visible or not uiLayout *split, *col; - + /* make as visible, for move operator */ act->flag |= ACT_VISIBLE; split = uiLayoutSplit(layout, 0.05f, false); - + /* put inlink button to the left */ col = uiLayoutColumn(split, false); uiLayoutSetActive(col, RNA_boolean_get(&ptr, "active")); @@ -2570,13 +2570,13 @@ void logic_buttons(bContext *C, ARegion *ar) col = uiLayoutColumn(split, true); uiLayoutSetContextPointer(col, "actuator", &ptr); - + /* should make UI template for actuator header.. function will do for now */ draw_actuator_header(col, &ptr, &logic_ptr); - + /* draw the brick contents */ draw_brick_actuator(col, &ptr, C); - + } } } @@ -2584,18 +2584,18 @@ void logic_buttons(bContext *C, ARegion *ar) height = MIN2(height, yco); UI_view2d_totRect_set(&ar->v2d, 57.5f * U.widget_unit, height - U.widget_unit); - + /* set the view */ UI_view2d_view_ortho(&ar->v2d); UI_block_links_compose(block); - + UI_block_end(C, block); UI_block_draw(C, block); - + /* restore view matrix */ UI_view2d_view_restore(C); - + if (idar) MEM_freeN(idar); } diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 9416b21941f..5bc5be28e41 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -66,21 +66,21 @@ ARegion *logic_has_buttons_region(ScrArea *sa) ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ if (ar == NULL) return NULL; - + arnew= MEM_callocN(sizeof(ARegion), "buttons for image"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -91,34 +91,34 @@ static SpaceLink *logic_new(const bContext *C) ScrArea *sa= CTX_wm_area(C); ARegion *ar; SpaceLogic *slogic; - + slogic= MEM_callocN(sizeof(SpaceLogic), "initlogic"); slogic->spacetype= SPACE_LOGIC; - + /* default options */ slogic->scaflag = ((BUTS_SENS_SEL|BUTS_SENS_ACT|BUTS_SENS_LINK) | (BUTS_CONT_SEL|BUTS_CONT_ACT|BUTS_CONT_LINK) | (BUTS_ACT_SEL|BUTS_ACT_ACT|BUTS_ACT_LINK) | (BUTS_SENS_STATE|BUTS_ACT_STATE)); - - + + /* header */ ar= MEM_callocN(sizeof(ARegion), "header for logic"); - + BLI_addtail(&slogic->regionbase, ar); ar->regiontype= RGN_TYPE_HEADER; ar->alignment= RGN_ALIGN_BOTTOM; - + /* buttons/list view */ ar= MEM_callocN(sizeof(ARegion), "buttons for logic"); - + BLI_addtail(&slogic->regionbase, ar); ar->regiontype= RGN_TYPE_UI; ar->alignment= RGN_ALIGN_RIGHT; - + /* main region */ ar= MEM_callocN(sizeof(ARegion), "main region for logic"); - + BLI_addtail(&slogic->regionbase, ar); ar->regiontype= RGN_TYPE_WINDOW; @@ -126,35 +126,35 @@ static SpaceLink *logic_new(const bContext *C) ar->v2d.tot.ymax = 0.0f; ar->v2d.tot.xmax = 1150.0f; ar->v2d.tot.ymin = ( 1150.0f/(float)sa->winx ) * (float)-sa->winy; - + ar->v2d.cur = ar->v2d.tot; - + ar->v2d.min[0] = 1.0f; ar->v2d.min[1] = 1.0f; - + ar->v2d.max[0] = 32000.0f; ar->v2d.max[1] = 32000.0f; - + ar->v2d.minzoom = 0.5f; ar->v2d.maxzoom = 1.5f; - + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.keepzoom = V2D_KEEPZOOM | V2D_LIMITZOOM | V2D_KEEPASPECT; ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS; ar->v2d.align = V2D_ALIGN_NO_POS_Y | V2D_ALIGN_NO_NEG_X; ar->v2d.keepofs = V2D_KEEPOFS_Y; - + return (SpaceLink *)slogic; } /* not spacelink itself */ static void logic_free(SpaceLink *UNUSED(sl)) -{ +{ // Spacelogic *slogic= (SpaceLogic *) sl; - + // if (slogic->gpd) // XXX BKE_gpencil_free(slogic->gpd); - + } @@ -167,7 +167,7 @@ static void logic_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *logic_duplicate(SpaceLink *sl) { SpaceLogic *slogicn= MEM_dupallocN(sl); - + return (SpaceLink *)slogicn; } @@ -180,11 +180,11 @@ static void logic_operatortypes(void) static void logic_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Logic Editor", SPACE_LOGIC, 0); - + WM_keymap_add_item(keymap, "LOGIC_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "LOGIC_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_menu(keymap, "LOGIC_MT_logicbricks_add", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "LOGIC_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "LOGIC_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); @@ -210,7 +210,7 @@ static void logic_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar case ND_FRAME: ED_region_tag_redraw(ar); break; - + case ND_OB_ACTIVE: ED_region_tag_redraw(ar); break; @@ -238,9 +238,9 @@ static int logic_context(const bContext *UNUSED(C), const char *UNUSED(member), static void logic_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymaps */ keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -252,23 +252,23 @@ static void logic_main_region_draw(const bContext *C, ARegion *ar) // SpaceLogic *slogic= CTX_wm_space_logic(C); View2D *v2d= &ar->v2d; View2DScrollers *scrollers; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + logic_buttons((bContext *)C, ar); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); - + } @@ -280,7 +280,7 @@ static void logic_buttons_region_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "Logic Editor", SPACE_LOGIC, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -325,10 +325,10 @@ void ED_spacetype_logic(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype logic"); ARegionType *art; - + st->spaceid = SPACE_LOGIC; strncpy(st->name, "Logic", BKE_ST_MAXNAME); - + st->new = logic_new; st->free = logic_free; st->init = logic_init; @@ -348,7 +348,7 @@ void ED_spacetype_logic(void) art->listener = logic_listener; BLI_addhead(&st->regiontypes, art); - + /* regions: listview/buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype logic region"); art->regionid = RGN_TYPE_UI; @@ -366,9 +366,9 @@ void ED_spacetype_logic(void) art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->init = logic_header_region_init; art->draw = logic_header_region_draw; - + BLI_addhead(&st->regiontypes, art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index c173aac1a26..a26e6b0280e 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -87,27 +87,27 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p ListBase anim_data = {NULL, NULL}; short found = 0; /* not bool, since we need to indicate "found but not ideal" status */ int filter; - - /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) + + /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) * to work correctly is able to be correctly retrieved. There's no point showing empty panels? */ - if (ANIM_animdata_get_context(C, &ac) == 0) + if (ANIM_animdata_get_context(C, &ac) == 0) return false; - - /* extract list of active channel(s), of which we should only take the first one + + /* extract list of active channel(s), of which we should only take the first one * - we need the channels flag to get the active AnimData block when there are no NLA Tracks */ // XXX: double-check active! filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_NLATRACK: /* NLA Track - The primary data type which should get caught */ { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; - + /* found it, now set the pointers */ if (adt_ptr) { /* AnimData pointer */ @@ -122,7 +122,7 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p NlaStrip *strip = BKE_nlastrip_find_active(nlt); RNA_pointer_create(ale->id, &RNA_NlaStrip, strip, strip_ptr); } - + found = 1; break; } @@ -149,7 +149,7 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p /* for these channels, we only do AnimData */ if (ale->adt && adt_ptr) { ID *id; - + if ((ale->data == NULL) || (ale->type == ANIMTYPE_OBJECT)) { /* ale->data is not an ID block! */ id = ale->id; @@ -158,13 +158,13 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p /* ale->data is always the proper ID block we need, but ale->id may not be (i.e. for textures) */ id = (ID *)ale->data; } - + /* AnimData pointer */ if (adt_ptr) { RNA_pointer_create(id, &RNA_AnimData, ale->adt, adt_ptr); } - - /* set found status to -1, since setting to 1 would break the loop + + /* set found status to -1, since setting to 1 would break the loop * and potentially skip an active NLA-Track in some cases... */ found = -1; @@ -172,14 +172,14 @@ bool nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_p break; } } - + if (found > 0) break; } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + return (found != 0); } @@ -212,12 +212,12 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt) { PointerRNA ptr; NlaStrip *strip; - + if (!nla_panel_context(C, NULL, NULL, &ptr)) return 0; if (ptr.data == NULL) return 0; - + strip = ptr.data; return (strip->type == NLASTRIP_TYPE_CLIP); } @@ -226,17 +226,17 @@ static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) { PointerRNA ptr; NlaStrip *strip; - + if (!nla_panel_context(C, NULL, NULL, &ptr)) return 0; if (ptr.data == NULL) return 0; - + strip = ptr.data; - + if (strip->type == NLASTRIP_TYPE_SOUND) return 0; - + return 1; } @@ -250,53 +250,53 @@ static void nla_panel_animdata(const bContext *C, Panel *pa) uiLayout *layout = pa->layout; uiLayout *row; uiBlock *block; - + /* check context and also validity of pointer */ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) return; /* adt = adt_ptr.data; */ - + block = uiLayoutGetBlock(layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); - + /* AnimData Source Properties ----------------------------------- */ - - /* icon + id-block name of block where AnimData came from to prevent + + /* icon + id-block name of block where AnimData came from to prevent * accidentally changing the properties of the wrong action */ if (adt_ptr.id.data) { ID *id = adt_ptr.id.data; PointerRNA id_ptr; - + RNA_id_pointer_create(id, &id_ptr); - + /* ID-block name > AnimData */ row = uiLayoutRow(layout, true); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); - + uiItemL(row, id->name + 2, RNA_struct_ui_icon(id_ptr.type)); /* id-block (src) */ uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); /* expander */ uiItemL(row, IFACE_("Animation Data"), ICON_ANIM_DATA); /* animdata */ - + uiItemS(layout); } - + /* Active Action Properties ------------------------------------- */ /* action */ row = uiLayoutRow(layout, true); uiTemplateID( row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, "NLA_OT_action_unlink", UI_TEMPLATE_ID_FILTER_ALL); - + /* extrapolation */ row = uiLayoutRow(layout, true); uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); - + /* blending */ row = uiLayoutRow(layout, true); uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); - + /* influence */ row = uiLayoutRow(layout, true); uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); @@ -309,14 +309,14 @@ static void nla_panel_track(const bContext *C, Panel *pa) uiLayout *layout = pa->layout; uiLayout *row; uiBlock *block; - + /* check context and also validity of pointer */ if (!nla_panel_context(C, NULL, &nlt_ptr, NULL)) return; - + block = uiLayoutGetBlock(layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); - + /* Info - Active NLA-Context:Track ---------------------- */ row = uiLayoutRow(layout, true); uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); @@ -330,41 +330,41 @@ static void nla_panel_properties(const bContext *C, Panel *pa) uiLayout *column, *row, *sub; uiBlock *block; short showEvalProps = 1; - + if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - + block = uiLayoutGetBlock(layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); - + /* Strip Properties ------------------------------------- */ /* strip type */ row = uiLayoutColumn(layout, true); uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); - + /* strip extents */ column = uiLayoutColumn(layout, true); uiItemL(column, IFACE_("Strip Extents:"), ICON_NONE); uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); - + /* Evaluation-Related Strip Properties ------------------ */ - + /* sound properties strips don't have these settings */ if (RNA_enum_get(&strip_ptr, "type") == NLASTRIP_TYPE_SOUND) showEvalProps = 0; - + /* only show if allowed to... */ if (showEvalProps) { /* extrapolation */ row = uiLayoutRow(layout, true); uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); - + /* blending */ row = uiLayoutRow(layout, true); uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); - + /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ @@ -376,7 +376,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == false); uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); - + /* settings */ column = uiLayoutColumn(layout, true); uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); @@ -398,27 +398,27 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) /* check context and also validity of pointer */ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - + block = uiLayoutGetBlock(layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); - + /* Strip Properties ------------------------------------- */ /* action pointer */ row = uiLayoutRow(layout, true); uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); - + /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? column = uiLayoutColumn(layout, true); uiItemL(column, IFACE_("Action Extents:"), ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_start", 0, IFACE_("Start Frame"), ICON_NONE); uiItemR(column, &strip_ptr, "action_frame_end", 0, IFACE_("End Frame"), ICON_NONE); - + // XXX: this layout may actually be too abstract and confusing, and may be better using standard column layout row = uiLayoutRow(layout, false); uiItemR(row, &strip_ptr, "use_sync_length", 0, IFACE_("Sync Length"), ICON_NONE); uiItemO(row, IFACE_("Now"), ICON_FILE_REFRESH, "NLA_OT_action_sync_length"); - + /* action usage */ column = uiLayoutColumn(layout, true); uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == false); @@ -438,13 +438,13 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) /* check context and also validity of pointer */ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - + block = uiLayoutGetBlock(layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); - + col = uiLayoutColumn(layout, true); uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - + sub = uiLayoutColumn(col, true); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); @@ -472,28 +472,28 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; strip = strip_ptr.data; - + block = uiLayoutGetBlock(pa->layout); UI_block_func_handle_set(block, do_nla_region_buttons, NULL); - + /* 'add modifier' button at top of panel */ { row = uiLayoutRow(pa->layout, false); block = uiLayoutGetBlock(row); - + // FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected) uiItemMenuEnumO(row, (bContext *)C, "NLA_OT_fmodifier_add", "type", IFACE_("Add Modifier"), ICON_NONE); - + /* copy/paste (as sub-row) */ row = uiLayoutRow(row, true); uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); } - + /* draw each modifier */ for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { col = uiLayoutColumn(pa->layout, true); - + ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm); } } @@ -565,7 +565,7 @@ static int nla_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = nla_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -577,7 +577,7 @@ void NLA_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->idname = "NLA_OT_properties"; ot->description = "Toggle the properties region visibility"; - + ot->exec = nla_properties_toggle_exec; ot->poll = ED_operator_nla_active; diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 9ca52764b24..8fdba4ce60d 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -79,26 +79,26 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + View2D *v2d = &ac->ar->v2d; int notifierFlags = 0; - + /* get the channel that was clicked on */ /* filter channels */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* get channel from index */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) printf("Error: animation channel (index = %d) not found in mouse_anim_channels()\n", channel_index); - + ANIM_animdata_freelist(&anim_data); return 0; } - + /* action to take depends on what channel we've got */ // WARNING: must keep this in sync with the equivalent function in anim_channels_edit.c switch (ale->type) { @@ -106,7 +106,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe { Scene *sce = (Scene *)ale->data; AnimData *adt = sce->adt; - + /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ @@ -117,7 +117,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe sce->flag |= SCE_DS_SELECTED; if (adt) adt->flag |= ADT_UI_SELECTED; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } @@ -128,19 +128,19 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe Base *base = (Base *)ale->data; Object *ob = base->object; AnimData *adt = ob->adt; - + if (nlaedit_is_tweakmode_on(ac) == 0 && (ob->restrictflag & OB_RESTRICT_SELECT) == 0) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ base->flag ^= SELECT; ob->flag = base->flag; - + if (adt) adt->flag ^= ADT_UI_SELECTED; } else { Base *b; - + /* deselect all */ /* TODO: should this deselect all other types of channels too? */ for (b = sce->base.first; b; b = b->next) { @@ -148,19 +148,19 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe b->object->flag = b->flag; if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); } - + /* select object now */ base->flag |= SELECT; ob->flag |= SELECT; if (adt) adt->flag |= ADT_UI_SELECTED; } - + /* change active object - regardless of whether it is now selected [T37883] */ ED_base_object_activate(C, base); /* adds notifier */ - + if ((adt) && (adt->flag & ADT_UI_SELECTED)) adt->flag |= ADT_UI_ACTIVE; - + /* notifiers - channel was selected */ notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } @@ -197,12 +197,12 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); ale->adt->flag |= ADT_UI_SELECTED; } - + /* set active? */ if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) ale->adt->flag |= ADT_UI_ACTIVE; } - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); break; } @@ -211,7 +211,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; short offset; - + /* offset for start of channel (on LHS of channel-list) */ if (ale->id) { /* special exception for materials and particles */ @@ -222,25 +222,25 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe } else offset = 0; - + if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { /* toggle protection (only if there's a toggle there) */ nlt->flag ^= NLATRACK_PROTECTED; - + /* notifier flags - channel was edited */ notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } else if (x >= (v2d->cur.xmax - 2 * NLACHANNEL_BUTTON_WIDTH)) { /* toggle mute */ nlt->flag ^= NLATRACK_MUTED; - + /* notifier flags - channel was edited */ notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } else if (x <= ((NLACHANNEL_BUTTON_WIDTH * 2) + offset)) { /* toggle 'solo' */ BKE_nlatrack_solo_toggle(adt, nlt); - + /* notifier flags - channel was edited */ notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } @@ -255,11 +255,11 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); nlt->flag |= NLATRACK_SELECTED; } - + /* if NLA-Track is selected now, make NLA-Track the 'active' one in the visible list */ if (nlt->flag & NLATRACK_SELECTED) ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK); - + /* notifier flags - channel was selected */ notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } @@ -268,7 +268,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe case ANIMTYPE_NLAACTION: { AnimData *adt = BKE_animdata_from_id(ale->id); - + /* button region... */ if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { @@ -281,13 +281,13 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe /* when in tweakmode, this button becomes the toggle for mapped editing */ adt->flag ^= ADT_NLA_EDIT_NOMAP; } - + /* changes to NLA-Action occurred */ notifierFlags |= ND_NLA_ACTCHANGE; } /* OR rest of name... */ else { - /* NOTE: rest of NLA-Action name doubles for operating on the AnimData block + /* NOTE: rest of NLA-Action name doubles for operating on the AnimData block * - this is useful when there's no clear divider, and makes more sense in * the case of users trying to use this to change actions * - in tweakmode, clicking here gets us out of tweakmode, as changing selection @@ -298,7 +298,7 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe if (nlaedit_is_tweakmode_on(ac)) { /* exit tweakmode immediately */ nlaedit_disable_tweakmode(ac, true); - + /* changes to NLA-Action occurred */ notifierFlags |= ND_NLA_ACTCHANGE; } @@ -313,11 +313,11 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); adt->flag |= ADT_UI_SELECTED; } - + /* set active? */ if (adt->flag & ADT_UI_SELECTED) adt->flag |= ADT_UI_ACTIVE; - + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } } @@ -328,10 +328,10 @@ static int mouse_nla_channels(bContext *C, bAnimContext *ac, float x, int channe printf("Error: Invalid channel type in mouse_nla_channels()\n"); break; } - + /* free channels */ ANIM_animdata_freelist(&anim_data); - + /* return the notifier-flags set */ return notifierFlags; } @@ -349,55 +349,55 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmEv int notifierFlags = 0; short selectmode; float x, y; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get useful pointers from animation context data */ snla = (SpaceNla *)ac.sl; ar = ac.ar; v2d = &ar->v2d; - + /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - - /* figure out which channel user clicked in + + /* figure out which channel user clicked in * Note: although channels technically start at y= NLACHANNEL_FIRST, we need to adjust by half a channel's height * so that the tops of channels get caught ok. Since NLACHANNEL_FIRST is really NLACHANNEL_HEIGHT, we simply use * NLACHANNEL_HEIGHT_HALF. */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); - + /* handle mouse-click in the relevant channel then */ notifierFlags = mouse_nla_channels(C, &ac, x, channel_index, selectmode); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); - + return OPERATOR_FINISHED; } - + void NLA_OT_channels_click(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Mouse Click on NLA Channels"; ot->idname = "NLA_OT_channels_click"; ot->description = "Handle clicks to select NLA channels"; - + /* api callbacks */ ot->invoke = nlachannels_mouseclick_invoke; ot->poll = ED_operator_nla_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* props */ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -413,15 +413,15 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op) bAnimContext ac; AnimData *adt = NULL; int channel_index = RNA_int_get(op->ptr, "channel_index"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get anim-channel to use (or more specifically, the animdata block behind it) */ if (channel_index == -1) { PointerRNA adt_ptr = {{NULL}}; - + /* active animdata block */ if (nla_panel_context(C, &adt_ptr, NULL, NULL) == 0 || (adt_ptr.data == NULL)) { BKE_report(op->reports, RPT_ERROR, "No active AnimData block to use " @@ -437,11 +437,11 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* filter channels */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* get channel from index */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { @@ -454,14 +454,14 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op) ANIM_animdata_freelist(&anim_data); return OPERATOR_CANCELLED; } - + /* grab AnimData from the channel */ adt = ale->adt; - + /* we don't need anything here anymore, so free it all */ ANIM_animdata_freelist(&anim_data); } - + /* double-check that we are free to push down here... */ if (adt == NULL) { BKE_report(op->reports, RPT_WARNING, "Internal Error - AnimData block is not valid"); @@ -480,7 +480,7 @@ static int nlachannels_pushdown_exec(bContext *C, wmOperator *op) /* 'push-down' action - only usable when not in TweakMode */ BKE_nla_action_pushdown(adt); } - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); return OPERATOR_FINISHED; @@ -492,14 +492,14 @@ void NLA_OT_action_pushdown(wmOperatorType *ot) ot->name = "Push Down Action"; ot->idname = "NLA_OT_action_pushdown"; ot->description = "Push action down onto the top of the NLA stack as a new strip"; - + /* callbacks */ ot->exec = nlachannels_pushdown_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_int(ot->srna, "channel_index", -1, -1, INT_MAX, "Channel Index", "Index of NLA action channel to perform pushdown operation on", @@ -514,7 +514,7 @@ static int nla_action_unlink_poll(bContext *C) if (ED_operator_nla_active(C)) { return nla_panel_context(C, NULL, NULL, NULL); } - + /* something failed... */ return false; } @@ -523,22 +523,22 @@ static int nla_action_unlink_exec(bContext *C, wmOperator *op) { PointerRNA adt_ptr; AnimData *adt; - + /* check context and also validity of pointer */ if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) return OPERATOR_CANCELLED; - + /* get animdata */ adt = adt_ptr.data; if (adt == NULL) return OPERATOR_CANCELLED; - + /* do unlinking */ if (adt && adt->action) { bool force_delete = RNA_boolean_get(op->ptr, "force_delete"); ED_animedit_unlink_action(C, adt_ptr.id.data, adt, adt->action, op->reports, force_delete); } - + return OPERATOR_FINISHED; } @@ -552,19 +552,19 @@ static int nla_action_unlink_invoke(bContext *C, wmOperator *op, const wmEvent * void NLA_OT_action_unlink(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Unlink Action"; ot->idname = "NLA_OT_action_unlink"; ot->description = "Unlink this action from the active action slot (and/or exit Tweak Mode)"; - + /* callbacks */ ot->invoke = nla_action_unlink_invoke; ot->exec = nla_action_unlink_exec; ot->poll = nla_action_unlink_poll; - + /* properties */ - prop = RNA_def_boolean(ot->srna, "force_delete", false, "Force Delete", + prop = RNA_def_boolean(ot->srna, "force_delete", false, "Force Delete", "Clear Fake User and remove copy stashed in this datablock's NLA stack"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -580,17 +580,17 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel) int filter; AnimData *lastAdt = NULL; bool added = false; - + /* get a list of the (selected) NLA Tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* add tracks... */ for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; - + /* check if just adding a new track above this one, * or whether we're adding a new one to the top of the stack that this one belongs to */ @@ -607,10 +607,10 @@ bool nlaedit_add_tracks_existing(bAnimContext *ac, bool above_sel) } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + return added; } @@ -621,18 +621,18 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac) bAnimListElem *ale; int filter; bool added = false; - + /* get a list of the selected AnimData blocks in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* check if selected AnimData blocks are empty, and add tracks if so... */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ale->adt; - + /* sanity check */ BLI_assert(adt->flag & ADT_UI_SELECTED); - + /* ensure it is empty */ if (BLI_listbase_is_empty(&adt->nla_tracks)) { /* add new track to this AnimData block then */ @@ -640,10 +640,10 @@ bool nlaedit_add_tracks_empty(bAnimContext *ac) added = true; } } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); - + return added; } @@ -654,20 +654,20 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) bAnimContext ac; bool above_sel = RNA_boolean_get(op->ptr, "above_selected"); bool op_done = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform adding in two passes - existing first so that we don't double up for empty */ op_done |= nlaedit_add_tracks_existing(&ac, above_sel); op_done |= nlaedit_add_tracks_empty(&ac); - + /* done? */ if (op_done) { /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -675,7 +675,7 @@ static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) /* failed to add any tracks */ BKE_report(op->reports, RPT_WARNING, "Select an existing NLA Track or an empty action line first"); - + /* not done */ return OPERATOR_CANCELLED; } @@ -687,14 +687,14 @@ void NLA_OT_tracks_add(wmOperatorType *ot) ot->name = "Add Tracks"; ot->idname = "NLA_OT_tracks_add"; ot->description = "Add NLA-Tracks above/after the selected tracks"; - + /* api callbacks */ ot->exec = nlaedit_add_tracks_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "above_selected", 0, "Above Selected", "Add a new NLA Track above every existing selected one"); } @@ -705,42 +705,42 @@ void NLA_OT_tracks_add(wmOperatorType *ot) static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the AnimData blocks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* delete tracks */ for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; - + /* if track is currently 'solo', then AnimData should have its * 'has solo' flag disabled */ if (nlt->flag & NLATRACK_SOLO) adt->flag &= ~ADT_NLA_SOLO_TRACK; - + /* call delete on this track - deletes all strips too */ BKE_nlatrack_free(&adt->nla_tracks, nlt); } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -751,11 +751,11 @@ void NLA_OT_tracks_delete(wmOperatorType *ot) ot->name = "Delete Tracks"; ot->idname = "NLA_OT_tracks_delete"; ot->description = "Delete selected NLA-Tracks and the strips they contain"; - + /* api callbacks */ ot->exec = nlaedit_delete_tracks_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -764,7 +764,7 @@ void NLA_OT_tracks_delete(wmOperatorType *ot) /* AnimData Related Operators */ /* ******************** Include Objects Operator ***************************** */ -/* Include selected objects in NLA Editor, by giving them AnimData blocks +/* Include selected objects in NLA Editor, by giving them AnimData blocks * NOTE: This doesn't help for non-object AnimData, where we do not have any effective * selection mechanism in place. Unfortunately, this means that non-object AnimData * once again becomes a second-class citizen here. However, at least for the most @@ -775,28 +775,28 @@ static int nlaedit_objects_add_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; SpaceNla *snla; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* ensure that filters are set so that the effect will be immediately visible */ snla = (SpaceNla *)ac.sl; if (snla && snla->ads) { snla->ads->filterflag &= ~ADS_FILTER_NLA_NOACT; } - - /* operate on selected objects... */ + + /* operate on selected objects... */ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { /* ensure that object has AnimData... that's all */ BKE_animdata_add_id(&ob->id); } CTX_DATA_END; - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -807,11 +807,11 @@ void NLA_OT_selected_objects_add(wmOperatorType *ot) ot->name = "Include Selected Objects"; ot->idname = "NLA_OT_selected_objects_add"; ot->description = "Make selected objects appear in NLA Editor by adding Animation Data"; - + /* api callbacks */ ot->exec = nlaedit_objects_add_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 910b8b3c08b..5d138a939de 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -71,7 +71,7 @@ /* Action-Line ---------------------- */ -/* get colors for drawing Action-Line +/* get colors for drawing Action-Line * NOTE: color returned includes fine-tuned alpha! */ void nla_action_get_color(AnimData *adt, bAction *act, float color[4]) @@ -90,7 +90,7 @@ void nla_action_get_color(AnimData *adt, bAction *act, float color[4]) UI_GetThemeColor4fv(TH_ANIM_INACTIVE, color); } } - + /* when an NLA track is tagged "solo", action doesn't contribute, so shouldn't be as prominent */ if (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) color[3] *= 0.15f; @@ -103,44 +103,44 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d, ActKeyColumn *ak; float xscale, f1, f2; float color[4]; - + /* get a list of the keyframes with NLA-scaling applied */ BLI_dlrbTree_init(&keys); action_to_keylist(adt, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); - + if (ELEM(NULL, act, keys.first)) return; - - /* draw a darkened region behind the strips - * - get and reset the background color, this time without the alpha to stand out better + + /* draw a darkened region behind the strips + * - get and reset the background color, this time without the alpha to stand out better * (amplified alpha is used instead) */ nla_action_get_color(adt, act, color); color[3] *= 2.5f; - + glColor4fv(color); /* - draw a rect from the first to the last frame (no extra overlaps for now) * that is slightly stumpier than the track background (hardcoded 2-units here) */ f1 = ((ActKeyColumn *)keys.first)->cfra; f2 = ((ActKeyColumn *)keys.last)->cfra; - + glRectf(f1, ymin + 2, f2, ymax - 2); - - + + /* get View2D scaling factor */ UI_view2d_scale_get(v2d, &xscale, NULL); - + /* for now, color is hardcoded to be black */ glColor3f(0.0f, 0.0f, 0.0f); - - /* just draw each keyframe as a simple dot (regardless of the selection status) + + /* just draw each keyframe as a simple dot (regardless of the selection status) * - size is 3.0f which is smaller than the editable keyframes, so that there is a distinction */ for (ak = keys.first; ak; ak = ak->next) draw_keyframe_shape(ak->cfra, y, xscale, 3.0f, 0, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f); - + /* free icons */ BLI_dlrbTree_free(&keys); } @@ -152,14 +152,14 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax { bAction *act = strip->act; TimeMarker *marker; - + if (ELEM(NULL, strip->act, strip->act->markers.first)) return; - + for (marker = act->markers.first; marker; marker = marker->next) { if ((marker->frame > strip->actstart) && (marker->frame < strip->actend)) { float frame = nlastrip_get_frame(strip, marker->frame, NLATIME_CONVERT_MAP); - + /* just a simple line for now */ // XXX: draw a triangle instead... fdrawline(frame, yminc + 1, frame, ymaxc - 1); @@ -171,25 +171,25 @@ static void nla_actionclip_draw_markers(NlaStrip *strip, float yminc, float ymax static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) { glLineWidth(2.0); - + if (strip->type == NLASTRIP_TYPE_CLIP) { /* try not to be too conspicuous, while being visible enough when transforming */ if (strip->flag & NLASTRIP_FLAG_SELECT) UI_ThemeColorShade(TH_STRIP_SELECT, -60); else UI_ThemeColorShade(TH_STRIP_SELECT, -40); - + setlinestyle(3); - + /* just draw the markers in this clip */ nla_actionclip_draw_markers(strip, yminc, ymaxc); - + setlinestyle(0); } else if (strip->flag & NLASTRIP_FLAG_TEMP_META) { /* just a solid color, so that it is very easy to spot */ UI_ThemeColorShade(TH_STRIP_SELECT, 20); - + /* draw the markers in the first level of strips only (if they are actions) */ for (NlaStrip *nls = strip->strips.first; nls; nls = nls->next) { if (nls->type == NLASTRIP_TYPE_CLIP) { @@ -197,7 +197,7 @@ static void nla_strip_draw_markers(NlaStrip *strip, float yminc, float ymaxc) } } } - + glLineWidth(1.0); } @@ -269,25 +269,25 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) { const float yheight = ymaxc - yminc; - + /* drawing color is simply a light-gray */ // TODO: is this color suitable? // XXX nasty hacked color for now... which looks quite bad too... glColor3f(0.7f, 0.7f, 0.7f); - + /* draw with AA'd line */ glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - + /* influence -------------------------- */ if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) { FCurve *fcu = list_find_fcurve(&strip->fcurves, "influence", 0); float cfra; - + /* plot the curve (over the strip's main region) */ if (fcu) { glBegin(GL_LINE_STRIP); - + /* sample at 1 frame intervals, and draw * - min y-val is yminc, max is y-maxc, so clamp in those regions */ @@ -296,7 +296,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) CLAMP(y, 0.0f, 1.0f); glVertex2f(cfra, ((y * yheight) + yminc)); } - + glEnd(); // GL_LINE_STRIP } } @@ -311,7 +311,7 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) } else glVertex2f(strip->start, ymaxc); - + /* end of strip */ if (IS_EQF(strip->blendout, 0.0f) == 0) { glVertex2f(strip->end - strip->blendout, ymaxc); @@ -322,10 +322,10 @@ static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) glEnd(); // GL_LINE_STRIP } } - + /* time -------------------------- */ // XXX do we want to draw this curve? in a different color too? - + /* turn off AA'd lines */ glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -336,10 +336,10 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri { const bool non_solo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); float color[3]; - + /* get color of strip */ nla_strip_get_color_inside(adt, strip, color); - + /* draw extrapolation info first (as backdrop) * - but this should only be drawn if track has some contribution */ @@ -347,17 +347,17 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri /* enable transparency... */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + switch (strip->extendmode) { /* since this does both sides, only do the 'before' side, and leave the rest to the next case */ - case NLASTRIP_EXTEND_HOLD: - /* only need to draw here if there's no strip before since - * it only applies in such a situation + case NLASTRIP_EXTEND_HOLD: + /* only need to draw here if there's no strip before since + * it only applies in such a situation */ if (strip->prev == NULL) { /* set the drawing color to the color of the strip, but with very faint alpha */ glColor4f(color[0], color[1], color[2], 0.15f); - + /* draw the rect to the edge of the screen */ glBegin(GL_QUADS); glVertex2f(v2d->cur.xmin, yminc); @@ -369,17 +369,17 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri ATTR_FALLTHROUGH; /* this only draws after the strip */ - case NLASTRIP_EXTEND_HOLD_FORWARD: + case NLASTRIP_EXTEND_HOLD_FORWARD: /* only need to try and draw if the next strip doesn't occur immediately after */ if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) { /* set the drawing color to the color of the strip, but this time less faint */ glColor4f(color[0], color[1], color[2], 0.3f); - + /* draw the rect to the next strip or the edge of the screen */ glBegin(GL_QUADS); glVertex2f(strip->end, yminc); glVertex2f(strip->end, ymaxc); - + if (strip->next) { glVertex2f(strip->next->start, ymaxc); glVertex2f(strip->next->start, yminc); @@ -392,41 +392,41 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri } break; } - + glDisable(GL_BLEND); } - - + + /* draw 'inside' of strip itself */ if (non_solo == 0) { /* strip is in normal track */ glColor3fv(color); UI_draw_roundbox_corner_set(UI_CNR_ALL); /* all corners rounded */ - + UI_draw_roundbox_shade_x(GL_POLYGON, strip->start, yminc, strip->end, ymaxc, 0.0, 0.5, 0.1); } else { /* strip is in disabled track - make less visible */ glColor4f(color[0], color[1], color[2], 0.1f); - + glEnable(GL_BLEND); glRectf(strip->start, yminc, strip->end, ymaxc); glDisable(GL_BLEND); } - - + + /* draw strip's control 'curves' * - only if user hasn't hidden them... */ if ((snla->flag & SNLA_NOSTRIPCURVES) == 0) nla_draw_strip_curves(strip, yminc, ymaxc); - - + + /* draw markings indicating locations of local markers (useful for lining up different actions) */ if ((snla->flag & SNLA_NOLOCALMARKERS) == 0) nla_strip_draw_markers(strip, yminc, ymaxc); - - /* draw strip outline + + /* draw strip outline * - color used here is to indicate active vs non-active */ if (strip->flag & NLASTRIP_FLAG_ACTIVE) { @@ -437,25 +437,25 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri /* strip should appear to stand out, so draw a dark border around it */ glColor3f(0.0f, 0.0f, 0.0f); } - + /* - line style: dotted for muted */ if ((nlt->flag & NLATRACK_MUTED) || (strip->flag & NLASTRIP_FLAG_MUTED)) setlinestyle(4); - + /* draw outline */ UI_draw_roundbox_shade_x(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1); - + /* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */ if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) { float repeatLen = (strip->actend - strip->actstart) * strip->scale; int i; - + /* only draw lines for whole-numbered repeats, starting from the first full-repeat * up to the last full repeat (but not if it lies on the end of the strip) */ for (i = 1; i < strip->repeat; i++) { float repeatPos = strip->start + (repeatLen * i); - + /* don't draw if line would end up on or after the end of the strip */ if (repeatPos < strip->end) fdrawline(repeatPos, yminc + 4, repeatPos, ymaxc - 4); @@ -465,26 +465,26 @@ static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStri else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) { NlaStrip *cs; float y = (ymaxc - yminc) / 2.0f + yminc; - + /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ for (cs = strip->strips.first; cs; cs = cs->next) { - /* draw start-line if not same as end of previous (and only if not the first strip) + /* draw start-line if not same as end of previous (and only if not the first strip) * - on upper half of strip */ if ((cs->prev) && IS_EQF(cs->prev->end, cs->start) == 0) fdrawline(cs->start, y, cs->start, ymaxc); - + /* draw end-line if not the last strip * - on lower half of strip */ - if (cs->next) + if (cs->next) fdrawline(cs->end, yminc, cs->end, y); } } - + /* reset linestyle */ setlinestyle(0); -} +} /* add the relevant text to the cache of text-strings to draw in pixelspace */ static void nla_draw_strip_text( @@ -496,7 +496,7 @@ static void nla_draw_strip_text( size_t str_len; char col[4]; rctf rect; - + /* just print the name and the range */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) { str_len = BLI_snprintf_rlen(str, sizeof(str), "%d) Temp-Meta", index); @@ -504,7 +504,7 @@ static void nla_draw_strip_text( else { str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str)); } - + /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_TWEAKUSER)) { col[0] = col[1] = col[2] = 0; @@ -512,14 +512,14 @@ static void nla_draw_strip_text( else { col[0] = col[1] = col[2] = 255; } - + /* text opacity depends on whether if there's a solo'd track, this isn't it */ if (non_solo == 0) col[3] = 255; else col[3] = 128; - /* set bounding-box for text + /* set bounding-box for text * - padding of 2 'units' on either side */ // TODO: make this centered? @@ -527,7 +527,7 @@ static void nla_draw_strip_text( rect.ymin = yminc; rect.xmax = xmaxc; rect.ymax = ymaxc; - + /* add this string to the cache of texts to draw */ UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col); } @@ -541,18 +541,18 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V const char col[4] = {220, 220, 220, 255}; /* light gray */ char numstr[32]; size_t numstr_len; - - + + /* Always draw times above the strip, whereas sequencer drew below + above. - * However, we should be fine having everything on top, since these tend to be - * quite spaced out. + * However, we should be fine having everything on top, since these tend to be + * quite spaced out. * - 1 dp is compromise between lack of precision (ints only, as per sequencer) * while also preserving some accuracy, since we do use floats */ /* start frame */ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->start); UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, numstr_len, col); - + /* end frame */ numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->end); UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, numstr_len, col); @@ -565,37 +565,37 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + View2D *v2d = &ar->v2d; float y = 0.0f; size_t items; int height; const float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); const float text_margin_x = (8 * UI_DPI_FAC) * pixelx; - + /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first - * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for + * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); - + /* loop through channels, and set up drawing depending on their type */ y = (float)(-NLACHANNEL_HEIGHT(snla)); - + for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -608,7 +608,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; int index; - + /* draw each strip in the track (if visible) */ for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) { if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) { @@ -617,13 +617,13 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw the visualization of the strip */ nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); - + /* add the text for this strip to the cache */ if (xminc < xmaxc) { nla_draw_strip_text(adt, nlt, strip, index, v2d, xminc, xmaxc, yminc, ymaxc); } - - /* if transforming strips (only real reason for temp-metas currently), + + /* if transforming strips (only real reason for temp-metas currently), * add to the cache the frame numbers of the strip's extents */ if (strip->flag & NLASTRIP_FLAG_TEMP_META) @@ -636,48 +636,48 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) { AnimData *adt = ale->adt; float color[4]; - + /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, * and a second darker rect within which we draw keyframe indicator dots if there's data */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + /* get colors for drawing */ nla_action_get_color(adt, ale->data, color); glColor4fv(color); - + /* draw slightly shifted up for greater separation from standard channels, * but also slightly shorter for some more contrast when viewing the strips */ glRectf(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); - + /* draw keyframes in the action */ nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP); - + /* draw 'embossed' lines above and below the strip for effect */ /* white base-lines */ glLineWidth(2.0f); glColor4f(1.0f, 1.0f, 1.0f, 0.3); fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); - + /* black top-lines */ glLineWidth(1.0f); glColor3f(0.0f, 0.0f, 0.0f); fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); - + glDisable(GL_BLEND); break; } } } - + /* adjust y-position for next one */ y -= NLACHANNEL_STEP(snla); } - + /* free tempolary channels */ ANIM_animdata_freelist(&anim_data); } @@ -690,41 +690,41 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ar->v2d; float y = 0.0f; size_t items; int height; - + /* build list of channels to draw */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first - * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for + * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); - /* don't use totrect set, as the width stays the same - * (NOTE: this is ok here, the configuration is pretty straightforward) + /* don't use totrect set, as the width stays the same + * (NOTE: this is ok here, the configuration is pretty straightforward) */ v2d->tot.ymin = (float)(-height); /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); - + /* draw channels */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - + y = (float)(-NLACHANNEL_HEIGHT(snla)); - + for (ale = anim_data.first; ale; ale = ale->next) { float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -732,7 +732,7 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= NLACHANNEL_STEP(snla); channel_index++; @@ -741,18 +741,18 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) { /* second pass: UI widgets */ uiBlock *block = UI_block_begin(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - + y = (float)(-NLACHANNEL_HEIGHT(snla)); - + /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + /* loop through channels, and set up drawing depending on their type */ for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); - + /* check if visible */ if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) @@ -760,18 +760,18 @@ void draw_nla_channel_list(const bContext *C, bAnimContext *ac, ARegion *ar) /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); } - + /* adjust y-position for next one */ y -= NLACHANNEL_STEP(snla); channel_index++; } - + UI_block_end(C, block); UI_block_draw(C, block); - + glDisable(GL_BLEND); } - + /* free temporary channels */ ANIM_animdata_freelist(&anim_data); } diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 4fabd1ded46..26ac06446c4 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -83,15 +83,15 @@ void ED_nla_postop_refresh(bAnimContext *ac) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); - + /* get blocks to work on */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + for (ale = anim_data.first; ale; ale = ale->next) { /* performing auto-blending, extend-mode validation, etc. */ BKE_nla_validate_state(ale->data); } - + /* free temp memory */ ANIM_animdata_freelist(&anim_data); } @@ -100,62 +100,62 @@ void ED_nla_postop_refresh(bAnimContext *ac) /* 'Special' Editing */ /* ******************** Tweak-Mode Operators ***************************** */ -/* 'Tweak mode' allows the action referenced by the active NLA-strip to be edited +/* 'Tweak mode' allows the action referenced by the active NLA-strip to be edited * as if it were the normal Active-Action of its AnimData block. */ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action"); bool ok = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the AnimData blocks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* if no blocks, popup error? */ if (BLI_listbase_is_empty(&anim_data)) { BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for"); return OPERATOR_CANCELLED; } - + /* for each AnimData block with NLA-data, try setting it in tweak-mode */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ale->data; - + /* try entering tweakmode if valid */ ok |= BKE_nla_tweakmode_enter(adt); - + /* mark the active track as being "solo"? */ if (do_solo && adt->actstrip) { NlaTrack *nlt = BKE_nlatrack_find_tweaked(adt); - + if (nlt && !(nlt->flag & NLATRACK_SOLO)) { BKE_nlatrack_solo_toggle(adt, nlt); } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - - /* if we managed to enter tweakmode on at least one AnimData block, + + /* if we managed to enter tweakmode on at least one AnimData block, * set the flag for this in the active scene and send notifiers */ if (ac.scene && ok) { /* set editing flag */ ac.scene->flag |= SCE_NLA_EDIT_ON; - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); } @@ -163,27 +163,27 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweak mode on"); return OPERATOR_CANCELLED; } - + /* done */ return OPERATOR_FINISHED; } - + void NLA_OT_tweakmode_enter(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Enter Tweak Mode"; ot->idname = "NLA_OT_tweakmode_enter"; ot->description = "Enter tweaking mode for the action referenced by the active strip to edit its keyframes"; - + /* api callbacks */ ot->exec = nlaedit_enable_tweakmode_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_boolean(ot->srna, "isolate_action", 0, "Isolate Action", "Enable 'solo' on the NLA Track containing the active strip, " @@ -198,47 +198,47 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter; - + int filter; + /* get a list of the AnimData blocks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* if no blocks, popup error? */ if (BLI_listbase_is_empty(&anim_data)) { BKE_report(ac->reports, RPT_ERROR, "No AnimData blocks in tweak mode to exit from"); return false; } - + /* for each AnimData block with NLA-data, try exitting tweak-mode */ for (ale = anim_data.first; ale; ale = ale->next) { AnimData *adt = ale->data; - + /* clear solo flags */ if ((do_solo) & (adt->flag & ADT_NLA_SOLO_TRACK) && - (adt->flag & ADT_NLA_EDIT_ON)) + (adt->flag & ADT_NLA_EDIT_ON)) { BKE_nlatrack_solo_toggle(adt, NULL); } - + /* to be sure that we're doing everything right, just exit tweakmode... */ BKE_nla_tweakmode_exit(adt); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - - /* if we managed to enter tweakmode on at least one AnimData block, + + /* if we managed to enter tweakmode on at least one AnimData block, * set the flag for this in the active scene and send notifiers */ if (ac->scene) { /* clear editing flag */ ac->scene->flag &= ~SCE_NLA_EDIT_ON; - + /* set notifier that things have changed */ WM_main_add_notifier(NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); } - + /* done */ return true; } @@ -247,40 +247,40 @@ bool nlaedit_disable_tweakmode(bAnimContext *ac, bool do_solo) static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + const bool do_solo = RNA_boolean_get(op->ptr, "isolate_action"); bool ok = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* perform operation */ ok = nlaedit_disable_tweakmode(&ac, do_solo); - + /* success? */ if (ok) return OPERATOR_FINISHED; else return OPERATOR_CANCELLED; } - + void NLA_OT_tweakmode_exit(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Exit Tweak Mode"; ot->idname = "NLA_OT_tweakmode_exit"; ot->description = "Exit tweaking mode for the action referenced by the active strip"; - + /* api callbacks */ ot->exec = nlaedit_disable_tweakmode_exec; ot->poll = nlaop_poll_tweakmode_on; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ prop = RNA_def_boolean(ot->srna, "isolate_action", 0, "Isolate Action", "Disable 'solo' on any of the NLA Tracks after exiting tweak mode " @@ -300,38 +300,38 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const bAnimListElem *ale; int filter; bool found_bounds = false; - + /* get data to filter */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* set large values to try to override */ *min = 999999999.0f; *max = -999999999.0f; - + /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.first; strip; strip = strip->next) { /* only consider selected strips? */ if ((only_sel == false) || (strip->flag & NLASTRIP_FLAG_SELECT)) { /* extend range if appropriate */ *min = min_ff(*min, strip->start); *max = max_ff(*max, strip->end); - + found_bounds = true; } } } - + /* free memory */ ANIM_animdata_freelist(&anim_data); } - + /* set default range if nothing happened */ if (found_bounds == false) { if (ac->scene) { @@ -352,40 +352,40 @@ static int nlaedit_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) bAnimContext ac; Scene *scene; float min, max; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + if (ac.scene == NULL) return OPERATOR_CANCELLED; else scene = ac.scene; - + /* set the range directly */ get_nlastrip_extents(&ac, &min, &max, true); scene->r.flag |= SCER_PRV_RANGE; scene->r.psfra = round_fl_to_int(min); scene->r.pefra = round_fl_to_int(max); - + /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); - + return OPERATOR_FINISHED; } - + void NLA_OT_previewrange_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Auto-Set Preview Range"; ot->idname = "NLA_OT_previewrange_set"; ot->description = "Automatically set Preview Range based on range of keyframes"; - + /* api callbacks */ ot->exec = nlaedit_previewrange_exec; ot->poll = ED_operator_nla_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -404,33 +404,33 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceNla *snla = (SpaceNla *)ac->sl; const float half_height = NLACHANNEL_HEIGHT_HALF(snla); short found = 0; /* NOTE: not bool, since we want prioritise individual channels over expanders */ float y; - + /* get all items - we need to do it this way */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* loop through all channels, finding the first one that's selected */ y = (float)NLACHANNEL_FIRST; - + for (ale = anim_data.first; ale; ale = ale->next) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); - + /* must be selected... */ - if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && + if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ *min = (float)(y - half_height); *max = (float)(y + half_height); - + /* is this high enough priority yet? */ found = acf->channel_role; - + /* only stop our search when we've found an actual channel * - datablock expanders get less priority so that we don't abort prematurely */ @@ -438,14 +438,14 @@ static bool nla_channels_get_selected_extents(bAnimContext *ac, float *min, floa break; } } - + /* adjust y-position for next one */ y -= NLACHANNEL_STEP(snla); } - + /* free all temp data */ ANIM_animdata_freelist(&anim_data); - + return (found != 0); } @@ -454,19 +454,19 @@ static int nlaedit_viewall(bContext *C, const bool only_sel) bAnimContext ac; View2D *v2d; float extra; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; v2d = &ac.ar->v2d; - + /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, only_sel); - + extra = 0.1f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - + /* set vertical range */ if (only_sel == false) { /* view all -> the summary channel is usually the shows everything, and resides right at the top... */ @@ -477,30 +477,30 @@ static int nlaedit_viewall(bContext *C, const bool only_sel) /* locate first selected channel (or the active one), and frame those */ float ymin = v2d->cur.ymin; float ymax = v2d->cur.ymax; - + if (nla_channels_get_selected_extents(&ac, &ymin, &ymax)) { /* recenter the view so that this range is in the middle */ float ymid = (ymax - ymin) / 2.0f + ymin; float x_center; - + UI_view2d_center_get(v2d, &x_center, NULL); UI_view2d_center_set(v2d, x_center, ymid); } } - + /* do View2D syncing */ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY); - + /* just redraw this view */ ED_area_tag_redraw(CTX_wm_area(C)); - + return OPERATOR_FINISHED; } /* ......... */ static int nlaedit_viewall_exec(bContext *C, wmOperator *UNUSED(op)) -{ +{ /* whole range */ return nlaedit_viewall(C, false); } @@ -510,18 +510,18 @@ static int nlaedit_viewsel_exec(bContext *C, wmOperator *UNUSED(op)) /* only selected */ return nlaedit_viewall(C, true); } - + void NLA_OT_view_all(wmOperatorType *ot) { /* identifiers */ ot->name = "View All"; ot->idname = "NLA_OT_view_all"; ot->description = "Reset viewable area to show full strips range"; - + /* api callbacks */ ot->exec = nlaedit_viewall_exec; ot->poll = ED_operator_nla_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -532,11 +532,11 @@ void NLA_OT_view_selected(wmOperatorType *ot) ot->name = "View Selected"; ot->idname = "NLA_OT_view_selected"; ot->description = "Reset viewable area to show selected strips range"; - + /* api callbacks */ ot->exec = nlaedit_viewsel_exec; ot->poll = ED_operator_nla_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -556,11 +556,11 @@ void NLA_OT_view_frame(wmOperatorType *ot) ot->name = "View Frame"; ot->idname = "NLA_OT_view_frame"; ot->description = "Reset viewable area to show range around current frame"; - + /* api callbacks */ ot->exec = nlaedit_viewframe_exec; ot->poll = ED_operator_nla_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -577,7 +577,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) { bAnimContext ac; Scene *scene; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; size_t items; @@ -586,17 +586,17 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) bAction *act; float cfra; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + scene = ac.scene; cfra = (float)CFRA; - + /* get action to use */ act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); - + if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid action to add"); //printf("Add strip - actname = '%s'\n", actname); @@ -610,68 +610,68 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) "for this action to avoid future problems)", act->id.name + 2); } - + /* add tracks to empty but selected animdata blocks so that strips can be added to those directly * without having to manually add tracks first */ nlaedit_add_tracks_empty(&ac); - + /* get a list of the editable tracks being shown in the NLA - * - this is limited to active ones for now, but could be expanded to + * - this is limited to active ones for now, but could be expanded to */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + if (items == 0) { - BKE_report(op->reports, RPT_ERROR, + BKE_report(op->reports, RPT_ERROR, "No active track(s) to add strip to, select an existing track or add one before trying again"); return OPERATOR_CANCELLED; } - + /* for every active track, try to add strip to free space in track or to the top of the stack if no space */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; NlaStrip *strip = NULL; - - /* sanity check: only apply actions of the right type for this ID + + /* sanity check: only apply actions of the right type for this ID * NOTE: in the case that this hasn't been set, we've already warned the user about this already */ if ((act->idroot) && (act->idroot != GS(ale->id->name))) { - BKE_reportf(op->reports, RPT_ERROR, + BKE_reportf(op->reports, RPT_ERROR, "Could not add action '%s' as it cannot be used relative to ID-blocks of type '%s'", act->id.name + 2, ale->id->name); continue; } - + /* create a new strip, and offset it to start on the current frame */ strip = BKE_nlastrip_new(act); - + strip->end += (cfra - strip->start); strip->start = cfra; - + /* firstly try adding strip to our current track, but if that fails, add to a new track */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { - /* trying to add to the current failed (no space), + /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ nlt = BKE_nlatrack_add(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } - + /* auto-name it */ BKE_nlastrip_validate_name(adt, strip); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -684,15 +684,15 @@ void NLA_OT_actionclip_add(wmOperatorType *ot) ot->name = "Add Action Strip"; ot->idname = "NLA_OT_actionclip_add"; ot->description = "Add an Action-Clip strip (i.e. an NLA Strip referencing an Action) to the active track"; - + /* api callbacks */ ot->invoke = WM_enum_search_invoke; ot->exec = nlaedit_add_actionclip_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* props */ // TODO: this would be nicer as an ID-pointer... prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); @@ -707,45 +707,45 @@ void NLA_OT_actionclip_add(wmOperatorType *ot) static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + bool done = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each track, find pairs of strips to add transitions to */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; NlaStrip *s1, *s2; - + /* get initial pair of strips */ if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) continue; s1 = nlt->strips.first; s2 = s1->next; - + /* loop over strips */ for (; s1 && s2; s1 = s2, s2 = s2->next) { NlaStrip *strip; - + /* check if both are selected */ if (ELEM(0, (s1->flag & NLASTRIP_FLAG_SELECT), (s2->flag & NLASTRIP_FLAG_SELECT))) continue; /* check if there's space between the two */ if (IS_EQF(s1->end, s2->start)) continue; - /* make sure neither one is a transition - * - although this is impossible to create with the standard tools, + /* make sure neither one is a transition + * - although this is impossible to create with the standard tools, * the user may have altered the settings */ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) @@ -753,48 +753,48 @@ static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) /* also make sure neither one is a soundclip */ if (ELEM(NLASTRIP_TYPE_SOUND, s1->type, s2->type)) continue; - + /* allocate new strip */ strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip"); BLI_insertlinkafter(&nlt->strips, s1, strip); - + /* set the type */ strip->type = NLASTRIP_TYPE_TRANSITION; - - /* generic settings + + /* generic settings * - selected flag to highlight this to the user - * - auto-blends to ensure that blend in/out values are automatically + * - auto-blends to ensure that blend in/out values are automatically * determined by overlaps of strips */ strip->flag = NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_AUTO_BLENDS; - + /* range is simply defined as the endpoints of the adjacent strips */ strip->start = s1->end; strip->end = s2->start; - + /* scale and repeat aren't of any use, but shouldn't ever be 0 */ strip->scale = 1.0f; strip->repeat = 1.0f; - + /* auto-name it */ BKE_nlastrip_validate_name(adt, strip); - + /* make note of this */ done = true; } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* was anything added? */ if (done) { /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -810,11 +810,11 @@ void NLA_OT_transition_add(wmOperatorType *ot) ot->name = "Add Transition"; ot->idname = "NLA_OT_transition_add"; ot->description = "Add a transition strip between two adjacent selected strips"; - + /* api callbacks */ ot->exec = nlaedit_add_transition_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -825,66 +825,66 @@ void NLA_OT_transition_add(wmOperatorType *ot) static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene; int cfra; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + scene = ac.scene; cfra = CFRA; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each track, add sound clips if it belongs to a speaker */ // TODO: what happens if there aren't any tracks... well that's a more general problem for later for (ale = anim_data.first; ale; ale = ale->next) { Object *ob = (Object *)ale->id; /* may not be object until we actually check! */ - + AnimData *adt = ale->adt; NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* does this belong to speaker - assumed to live on Object level only */ if ((GS(ale->id->name) != ID_OB) || (ob->type != OB_SPEAKER)) continue; - + /* create a new strip, and offset it to start on the current frame */ strip = BKE_nla_add_soundstrip(ac.scene, ob->data); - + strip->start += cfra; strip->end += cfra; - + /* firstly try adding strip to our current track, but if that fails, add to a new track */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { - /* trying to add to the current failed (no space), + /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ nlt = BKE_nlatrack_add(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } - + /* auto-name it */ BKE_nlastrip_validate_name(adt, strip); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -895,11 +895,11 @@ void NLA_OT_soundclip_add(wmOperatorType *ot) ot->name = "Add Sound Clip"; ot->idname = "NLA_OT_soundclip_add"; ot->description = "Add a strip for controlling when speaker plays its sound clip"; - + /* api callbacks */ ot->exec = nlaedit_add_sound_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -911,28 +911,28 @@ void NLA_OT_soundclip_add(wmOperatorType *ot) static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each track, find pairs of strips to add transitions to */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; NlaStrip *strip; - + /* create meta-strips from the continuous chains of selected strips */ BKE_nlastrips_make_metas(&nlt->strips, 0); - + /* name the metas */ for (strip = nlt->strips.first; strip; strip = strip->next) { /* auto-name this strip if selected (that means it is a meta) */ @@ -940,13 +940,13 @@ static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op)) BKE_nlastrip_validate_name(adt, strip); } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -957,11 +957,11 @@ void NLA_OT_meta_add(wmOperatorType *ot) ot->name = "Add Meta-Strips"; ot->idname = "NLA_OT_meta_add"; ot->description = "Add new meta-strips incorporating the selected strips"; - + /* api callbacks */ ot->exec = nlaedit_add_meta_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -972,33 +972,33 @@ void NLA_OT_meta_add(wmOperatorType *ot) static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each track, find pairs of strips to add transitions to */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; - + /* clear all selected meta-strips, regardless of whether they are temporary or not */ BKE_nlastrips_clear_metas(&nlt->strips, 1, 0); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1009,11 +1009,11 @@ void NLA_OT_meta_remove(wmOperatorType *ot) ot->name = "Remove Meta-Strips"; ot->idname = "NLA_OT_meta_remove"; ot->description = "Separate out the strips held by the selected meta-strips"; - + /* api callbacks */ ot->exec = nlaedit_remove_meta_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1022,27 +1022,27 @@ void NLA_OT_meta_remove(wmOperatorType *ot) /* Duplicates the selected NLA-Strips, putting them on new tracks above the one * the originals were housed in. */ - + static int nlaedit_duplicate_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + bool linked = RNA_boolean_get(op->ptr, "linked"); bool done = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - - /* duplicate strips in tracks starting from the last one so that we're + + /* duplicate strips in tracks starting from the last one so that we're * less likely to duplicate strips we just duplicated... */ for (ale = anim_data.last; ale; ale = ale->prev) { @@ -1050,46 +1050,46 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op) AnimData *adt = ale->adt; NlaStrip *strip, *nstrip, *next; NlaTrack *track; - + for (strip = nlt->strips.first; strip; strip = next) { next = strip->next; - + /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* make a copy (assume that this is possible) */ nstrip = BKE_nlastrip_copy(strip, linked); - + /* in case there's no space in the track above, or we haven't got a reference to it yet, try adding */ if (BKE_nlatrack_add_strip(nlt->next, nstrip) == 0) { /* need to add a new track above the one above the current one - * - if the current one is the last one, nlt->next will be NULL, which defaults to adding + * - if the current one is the last one, nlt->next will be NULL, which defaults to adding * at the top of the stack anyway... */ track = BKE_nlatrack_add(adt, nlt->next); BKE_nlatrack_add_strip(track, nstrip); } - + /* deselect the original and the active flag */ strip->flag &= ~(NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE); - + /* auto-name newly created strip */ BKE_nlastrip_validate_name(adt, nstrip); - + done = true; } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + if (done) { /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1100,7 +1100,7 @@ static int nlaedit_duplicate_exec(bContext *C, wmOperator *op) static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { nlaedit_duplicate_exec(C, op); - + RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); WM_operator_name_call(C, "TRANSFORM_OT_transform", WM_OP_INVOKE_REGION_WIN, op->ptr); @@ -1113,18 +1113,18 @@ void NLA_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Strips"; ot->idname = "NLA_OT_duplicate"; ot->description = "Duplicate selected NLA-Strips, adding the new strips in new tracks above the originals"; - + /* api callbacks */ ot->invoke = nlaedit_duplicate_invoke; ot->exec = nlaedit_duplicate_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* own properties */ ot->prop = RNA_def_boolean(ot->srna, "linked", false, "Linked", "When duplicating strips, assign new copies of the actions they use"); - + /* to give to transform */ RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", ""); } @@ -1135,52 +1135,52 @@ void NLA_OT_duplicate(wmOperatorType *ot) static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, delete all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip, *nstrip; - + for (strip = nlt->strips.first; strip; strip = nstrip) { nstrip = strip->next; - + /* if selected, delete */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* if a strip either side of this was a transition, delete those too */ - if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) + if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) BKE_nlastrip_free(&nlt->strips, strip->prev); if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) { nstrip = nstrip->next; BKE_nlastrip_free(&nlt->strips, strip->next); } - + /* finally, delete this strip */ BKE_nlastrip_free(&nlt->strips, strip); } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1191,18 +1191,18 @@ void NLA_OT_delete(wmOperatorType *ot) ot->name = "Delete Strips"; ot->idname = "NLA_OT_delete"; ot->description = "Delete selected strips"; - + /* api callbacks */ ot->exec = nlaedit_delete_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Split Strips Operator ***************************** */ /* Splits the selected NLA-Strips into two strips at the midpoint of the strip */ -// TODO's? +// TODO's? // - multiple splits // - variable-length splits? @@ -1211,9 +1211,9 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip * { NlaStrip *nstrip; float splitframe, splitaframe; - - /* calculate the frames to do the splitting at - * - use current frame if within extents of strip + + /* calculate the frames to do the splitting at + * - use current frame if within extents of strip */ if ((cfra > strip->start) && (cfra < strip->end)) { /* use the current frame */ @@ -1223,14 +1223,14 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip * else { /* split in the middle */ float len; - + /* strip extents */ len = strip->end - strip->start; if (IS_EQF(len, 0.0f)) return; else splitframe = strip->start + (len / 2.0f); - + /* action range */ len = strip->actend - strip->actstart; if (IS_EQF(len, 0.0f)) @@ -1238,28 +1238,28 @@ static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip * else splitaframe = strip->actstart + (len / 2.0f); } - + /* make a copy (assume that this is possible) and append * it immediately after the current strip */ nstrip = BKE_nlastrip_copy(strip, true); BLI_insertlinkafter(&nlt->strips, strip, nstrip); - - /* set the endpoint of the first strip and the start of the new strip + + /* set the endpoint of the first strip and the start of the new strip * to the splitframe values calculated above */ strip->end = splitframe; nstrip->start = splitframe; - + if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) { /* only do this if we're splitting down the middle... */ strip->actend = splitaframe; nstrip->actstart = splitaframe; } - + /* clear the active flag from the copy */ nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE; - + /* auto-name the new strip */ BKE_nlastrip_validate_name(adt, nstrip); } @@ -1276,28 +1276,28 @@ static void nlaedit_split_strip_meta(NlaTrack *nlt, NlaStrip *strip) static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, split all selected strips into two strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; AnimData *adt = ale->adt; NlaStrip *strip, *next; - + for (strip = nlt->strips.first; strip; strip = next) { next = strip->next; - + /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* splitting method depends on the type of strip */ @@ -1305,27 +1305,27 @@ static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op)) case NLASTRIP_TYPE_CLIP: /* action-clip */ nlaedit_split_strip_actclip(adt, nlt, strip, (float)ac.scene->r.cfra); break; - + case NLASTRIP_TYPE_META: /* meta-strips need special handling */ nlaedit_split_strip_meta(nlt, strip); break; - + default: /* for things like Transitions, do not split! */ break; } } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1336,11 +1336,11 @@ void NLA_OT_split(wmOperatorType *ot) ot->name = "Split Strips"; ot->idname = "NLA_OT_split"; ot->description = "Split selected strips at their midpoints"; - + /* api callbacks */ ot->exec = nlaedit_split_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1351,34 +1351,34 @@ void NLA_OT_split(wmOperatorType *ot) static int nlaedit_bake_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; // int flag = 0; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each AnimData block, bake strips to animdata... */ for (ale = anim_data.first; ale; ale = ale->next) { //BKE_nla_bake(ac.scene, ale->id, ale->data, flag); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1390,11 +1390,11 @@ static void UNUSED_FUNCTION(NLA_OT_bake)(wmOperatorType *ot) ot->name = "Bake Strips"; ot->idname = "NLA_OT_bake"; ot->description = "Bake all strips of selected AnimData blocks"; - + /* api callbacks */ ot->exec = nlaedit_bake_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1408,44 +1408,44 @@ static void UNUSED_FUNCTION(NLA_OT_bake)(wmOperatorType *ot) static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* go over all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* for every selected strip, toggle muting */ for (strip = nlt->strips.first; strip; strip = strip->next) { if (strip->flag & NLASTRIP_FLAG_SELECT) { /* just flip the mute flag for now */ // TODO: have a pre-pass to check if mute all or unmute all? strip->flag ^= NLASTRIP_FLAG_MUTED; - + /* tag AnimData to get recalculated */ ale->update |= ANIM_UPDATE_DEPS; } } } - + /* cleanup */ ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1456,11 +1456,11 @@ void NLA_OT_mute_toggle(wmOperatorType *ot) ot->name = "Toggle Muting"; ot->idname = "NLA_OT_mute_toggle"; ot->description = "Mute or un-mute selected strips"; - + /* api callbacks */ ot->exec = nlaedit_toggle_mute_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1471,35 +1471,35 @@ void NLA_OT_mute_toggle(wmOperatorType *ot) static int nlaedit_swap_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* consider each track in turn */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; - + NlaStrip *strip, *stripN = NULL; NlaStrip *sa = NULL, *sb = NULL; - + /* make temporary metastrips so that entire islands of selections can be moved around */ BKE_nlastrips_make_metas(&nlt->strips, 1); - - /* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this, + + /* special case: if there is only 1 island (i.e. temp meta BUT NOT unselected/normal/normal-meta strips) left after this, * and this island has two strips inside it, then we should be able to just swap these still... */ if (BLI_listbase_is_empty(&nlt->strips) == false) { NlaStrip *mstrip = (NlaStrip *)nlt->strips.first; - + if ((mstrip->flag & NLASTRIP_FLAG_TEMP_META) && (BLI_listbase_count_at_most(&mstrip->strips, 3) == 2)) { @@ -1507,13 +1507,13 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); } } - + /* get two selected strips only (these will be metas due to prev step) to operate on * - only allow swapping 2, as with more the context becomes unclear */ for (strip = nlt->strips.first; strip; strip = stripN) { stripN = strip->next; - + if (strip->flag & NLASTRIP_FLAG_SELECT) { /* first or second strip? */ if (sa == NULL) { @@ -1530,10 +1530,10 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) } } } - + if (strip) { /* too many selected warning */ - BKE_reportf(op->reports, RPT_WARNING, + BKE_reportf(op->reports, RPT_WARNING, "Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", nlt->name); } @@ -1548,11 +1548,11 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) } else { float nsa[2], nsb[2]; - + /* remove these strips from the track, so that we can test if they can fit in the proposed places */ BLI_remlink(&nlt->strips, sa); BLI_remlink(&nlt->strips, sb); - + /* calculate new extents for strips */ /* a --> b */ nsa[0] = sb->start; @@ -1560,16 +1560,16 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) /* b --> a */ nsb[0] = sa->start; nsb[1] = sa->start + (sb->end - sb->start); - + /* check if the track has room for the strips to be swapped */ - if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) && + if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) && BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) { /* set new extents for strips then */ sa->start = nsa[0]; sa->end = nsa[1]; BKE_nlameta_flush_transforms(sa); - + sb->start = nsb[0]; sb->end = nsb[1]; BKE_nlameta_flush_transforms(sb); @@ -1586,25 +1586,25 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) sa->name, sb->name); } } - + /* add strips back to track now */ BKE_nlatrack_add_strip(nlt, sa); BKE_nlatrack_add_strip(nlt, sb); } - + /* clear (temp) metastrips */ BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1615,11 +1615,11 @@ void NLA_OT_swap(wmOperatorType *ot) ot->name = "Swap Strips"; ot->idname = "NLA_OT_swap"; ot->description = "Swap order of selected strips within tracks"; - + /* api callbacks */ ot->exec = nlaedit_swap_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1630,19 +1630,19 @@ void NLA_OT_swap(wmOperatorType *ot) static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* since we're potentially moving strips from lower tracks to higher tracks, we should * loop over the tracks in reverse order to avoid moving earlier strips up multiple tracks */ @@ -1650,15 +1650,15 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) NlaTrack *nlt = (NlaTrack *)ale->data; NlaTrack *nltn = nlt->next; NlaStrip *strip, *stripn; - + /* if this track has no tracks after it, skip for now... */ if (nltn == NULL) continue; - + /* for every selected strip, try to move */ for (strip = nlt->strips.first; strip; strip = stripn) { stripn = strip->next; - + if (strip->flag & NLASTRIP_FLAG_SELECT) { /* check if the track above has room for this strip */ if (BKE_nlatrack_has_space(nltn, strip->start, strip->end)) { @@ -1669,16 +1669,16 @@ static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1689,11 +1689,11 @@ void NLA_OT_move_up(wmOperatorType *ot) ot->name = "Move Strips Up"; ot->idname = "NLA_OT_move_up"; ot->description = "Move selected strips up a track if there's room"; - + /* api callbacks */ ot->exec = nlaedit_move_up_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1704,19 +1704,19 @@ void NLA_OT_move_up(wmOperatorType *ot) static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* loop through the tracks in normal order, since we're pushing strips down, * strips won't get operated on twice */ @@ -1724,15 +1724,15 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) NlaTrack *nlt = (NlaTrack *)ale->data; NlaTrack *nltp = nlt->prev; NlaStrip *strip, *stripn; - + /* if this track has no tracks before it, skip for now... */ if (nltp == NULL) continue; - + /* for every selected strip, try to move */ for (strip = nlt->strips.first; strip; strip = stripn) { stripn = strip->next; - + if (strip->flag & NLASTRIP_FLAG_SELECT) { /* check if the track below has room for this strip */ if (BKE_nlatrack_has_space(nltp, strip->start, strip->end)) { @@ -1743,16 +1743,16 @@ static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1763,11 +1763,11 @@ void NLA_OT_move_down(wmOperatorType *ot) ot->name = "Move Strips Down"; ot->idname = "NLA_OT_move_down"; ot->description = "Move selected strips down a track if there's room"; - + /* api callbacks */ ot->exec = nlaedit_move_down_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1778,26 +1778,26 @@ void NLA_OT_move_down(wmOperatorType *ot) static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; const bool active_only = RNA_boolean_get(op->ptr, "active"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); if (active_only) filter |= ANIMFILTER_ACTIVE; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, apply scale of all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip selection/active status check */ if (active_only) { @@ -1808,27 +1808,27 @@ static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op) if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) continue; } - + /* must be action-clip only (transitions don't have scale) */ if (strip->type == NLASTRIP_TYPE_CLIP) { - if (strip->act == NULL) + if (strip->act == NULL) continue; - + /* recalculate the length of the action */ calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); - + /* adjust the strip extents in response to this */ BKE_nlastrip_recalculate_bounds(strip); } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1839,14 +1839,14 @@ void NLA_OT_action_sync_length(wmOperatorType *ot) ot->name = "Sync Action Length"; ot->idname = "NLA_OT_action_sync_length"; ot->description = "Synchronize the length of the referenced Action with the length used in the strip"; - + /* api callbacks */ ot->exec = nlaedit_sync_actlen_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_boolean(ot->srna, "active", 1, "Active Strip Only", "Only sync the active length for the active strip"); } @@ -1858,19 +1858,19 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* Ensure that each action used only has a single user * - This is done in reverse order so that the original strips are * likely to still get to keep their action @@ -1878,34 +1878,34 @@ static int nlaedit_make_single_user_exec(bContext *C, wmOperator *UNUSED(op)) for (ale = anim_data.last; ale; ale = ale->prev) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.last; strip; strip = strip->prev) { /* must be action-clip only (as only these have actions) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { - if (strip->act == NULL) + if (strip->act == NULL) continue; - + /* multi-user? */ if (ID_REAL_USERS(strip->act) > 1) { /* make a new copy of the action for us to use (it will have 1 user already) */ bAction *new_action = BKE_action_copy(bmain, strip->act); - + /* decrement user count of our existing action */ id_us_min(&strip->act->id); - + /* switch to the new copy */ strip->act = new_action; } } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -1916,12 +1916,12 @@ void NLA_OT_make_single_user(wmOperatorType *ot) ot->name = "Make Single User"; ot->idname = "NLA_OT_make_single_user"; ot->description = "Ensure that each action is only used once in the set of strips selected"; - + /* api callbacks */ ot->invoke = WM_operator_confirm; ot->exec = nlaedit_make_single_user_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1934,12 +1934,12 @@ static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt) { /* NLA-strip which has this scaling is stored in ked->data */ NlaStrip *strip = (NlaStrip *)ked->data; - + /* adjust all the times */ bezt->vec[0][0] = nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP); bezt->vec[1][0] = nlastrip_get_frame(strip, bezt->vec[1][0], NLATIME_CONVERT_MAP); bezt->vec[2][0] = nlastrip_get_frame(strip, bezt->vec[2][0], NLATIME_CONVERT_MAP); - + /* nothing to return or else we exit */ return 0; } @@ -1948,61 +1948,61 @@ static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + KeyframeEditData ked = {{NULL}}; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, apply scale of all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip must be selected, and must be action-clip only (transitions don't have scale) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { /* if the referenced action is used by other strips, make this strip use its own copy */ - if (strip->act == NULL) + if (strip->act == NULL) continue; if (strip->act->id.us > 1) { /* make a copy of the Action to work on */ bAction *act = BKE_action_copy(bmain, strip->act); - + /* set this as the new referenced action, decrementing the users of the old one */ id_us_min(&strip->act->id); strip->act = act; } - + /* setup iterator, and iterate over all the keyframes in the action, applying this scaling */ ked.data = strip; ANIM_animchanneldata_keyframes_loop(&ked, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, calchandles_fcurve); - + /* clear scale of strip now that it has been applied, * and recalculate the extents of the action now that it has been scaled - * but leave everything else alone + * but leave everything else alone */ strip->scale = 1.0f; calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -2013,11 +2013,11 @@ void NLA_OT_apply_scale(wmOperatorType *ot) ot->name = "Apply Scale"; ot->idname = "NLA_OT_apply_scale"; ot->description = "Apply scaling of selected strips to their referenced Actions"; - + /* api callbacks */ ot->exec = nlaedit_apply_scale_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2028,44 +2028,44 @@ void NLA_OT_apply_scale(wmOperatorType *ot) static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, reset scale of all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip must be selected, and must be action-clip only (transitions don't have scale) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { PointerRNA strip_ptr; - + RNA_pointer_create(NULL, &RNA_NlaStrip, strip, &strip_ptr); RNA_float_set(&strip_ptr, "scale", 1.0f); } } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -2076,11 +2076,11 @@ void NLA_OT_clear_scale(wmOperatorType *ot) ot->name = "Clear Scale"; ot->idname = "NLA_OT_clear_scale"; ot->description = "Reset scaling of selected strips"; - + /* api callbacks */ ot->exec = nlaedit_clear_scale_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2100,27 +2100,27 @@ static const EnumPropertyItem prop_nlaedit_snap_types[] = { static int nlaedit_snap_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene; int mode = RNA_enum_get(op->ptr, "type"); float secf; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* get some necessary vars */ scene = ac.scene; secf = (float)FPS; - + /* since we may add tracks, perform this in reverse order */ for (ale = anim_data.last; ale; ale = ale->prev) { ListBase tmp_strips = {NULL, NULL}; @@ -2128,23 +2128,23 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op) NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip, *stripn; NlaTrack *track; - + /* create meta-strips from the continuous chains of selected strips */ BKE_nlastrips_make_metas(&nlt->strips, 1); - + /* apply the snapping to all the temp meta-strips, then put them in a separate list to be added * back to the original only if they still fit */ for (strip = nlt->strips.first; strip; strip = stripn) { stripn = strip->next; - + if (strip->flag & NLASTRIP_FLAG_TEMP_META) { float start, end; - + /* get the existing end-points */ start = strip->start; end = strip->end; - + /* calculate new start position based on snapping mode */ switch (mode) { case NLAEDIT_SNAP_CFRA: /* to current frame */ @@ -2163,54 +2163,54 @@ static int nlaedit_snap_exec(bContext *C, wmOperator *op) strip->start = start; break; } - + /* get new endpoint based on start-point (and old length) */ strip->end = strip->start + (end - start); - + /* apply transforms to meta-strip to its children */ BKE_nlameta_flush_transforms(strip); - + /* remove strip from track, and add to the temp buffer */ BLI_remlink(&nlt->strips, strip); BLI_addtail(&tmp_strips, strip); } } - + /* try adding each meta-strip back to the track one at a time, to make sure they'll fit */ for (strip = tmp_strips.first; strip; strip = stripn) { stripn = strip->next; - + /* remove from temp-strips list */ BLI_remlink(&tmp_strips, strip); - + /* in case there's no space in the current track, try adding */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* need to add a new track above the current one */ track = BKE_nlatrack_add(adt, nlt); BKE_nlatrack_add_strip(track, strip); - + /* clear temp meta-strips on this new track, as we may not be able to get back to it */ BKE_nlastrips_clear_metas(&track->strips, 0, 1); } } - + /* remove the meta-strips now that we're done */ BKE_nlastrips_clear_metas(&nlt->strips, 0, 1); - + /* tag for recalculating the animation */ ale->update |= ANIM_UPDATE_DEPS; } - + /* cleanup */ ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* refresh auto strip properties */ ED_nla_postop_refresh(&ac); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } @@ -2221,15 +2221,15 @@ void NLA_OT_snap(wmOperatorType *ot) ot->name = "Snap Strips"; ot->idname = "NLA_OT_snap"; ot->description = "Move start of strips to specified time"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = nlaedit_snap_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_nlaedit_snap_types, 0, "Type", ""); } @@ -2244,31 +2244,31 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C, PointerRNA *UNUS EnumPropertyItem *item = NULL; int totitem = 0; int i = 0; - + if (C == NULL) { return rna_enum_fmodifier_type_items; } - + /* start from 1 to skip the 'Invalid' modifier type */ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i); int index; - + /* check if modifier is valid for this context */ if (fmi == NULL) continue; if (i == FMODIFIER_TYPE_CYCLES) /* we already have repeat... */ continue; - + index = RNA_enum_from_value(rna_enum_fmodifier_type_items, fmi->type); if (index != -1) { /* Not all types are implemented yet... */ RNA_enum_item_add(&item, &totitem, &rna_enum_fmodifier_type_items[index]); } } - + RNA_enum_item_end(&item, &totitem); *r_free = true; - + return item; } @@ -2276,28 +2276,28 @@ static const EnumPropertyItem *nla_fmodifier_itemf(bContext *C, PointerRNA *UNUS static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + FModifier *fcm; int type = RNA_enum_get(op->ptr, "type"); const bool active_only = RNA_boolean_get(op->ptr, "only_active"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, add the specified modifier to all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.first; strip; strip = strip->next) { /* can F-Modifier be added to the current strip? */ if (active_only) { @@ -2310,14 +2310,14 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) continue; } - + /* sound clips are not affected by FModifiers */ if (strip->type == NLASTRIP_TYPE_SOUND) continue; - + /* add F-Modifier of specified type to selected, and make it the active one */ fcm = add_fmodifier(&strip->modifiers, type, NULL); - + if (fcm) { set_active_fmodifier(&strip->modifiers, fcm); ale->update |= ANIM_UPDATE_DEPS; @@ -2329,37 +2329,37 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) } } } - + /* free temp data */ ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); - + /* done */ return OPERATOR_FINISHED; } - + void NLA_OT_fmodifier_add(wmOperatorType *ot) { /* identifiers */ ot->name = "Add F-Modifier"; ot->idname = "NLA_OT_fmodifier_add"; ot->description = "Add F-Modifier to the active/selected NLA-Strips"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = nla_fmodifier_add_exec; - ot->poll = nlaop_poll_tweakmode_off; - + ot->poll = nlaop_poll_tweakmode_off; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", rna_enum_fmodifier_type_items, 0, "Type", ""); RNA_def_enum_funcs(ot->prop, nla_fmodifier_itemf); - + RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only add a F-Modifier of the specified type to the active strip"); } @@ -2372,36 +2372,36 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) bAnimListElem *ale; int filter; bool ok = false; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* clear buffer first */ ANIM_fmodifiers_copybuf_free(); - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, add the specified modifier to all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.first; strip; strip = strip->next) { /* only add F-Modifier if on active strip? */ if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) continue; - + // TODO: when 'active' vs 'all' boolean is added, change last param! ok |= ANIM_fmodifiers_copy_to_buf(&strip->modifiers, 0); } } - + /* free temp data */ ANIM_animdata_freelist(&anim_data); - + /* successful or not? */ if (ok == 0) { BKE_report(op->reports, RPT_ERROR, "No F-Modifiers available to be copied"); @@ -2412,21 +2412,21 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } } - + void NLA_OT_fmodifier_copy(wmOperatorType *ot) { /* identifiers */ ot->name = "Copy F-Modifiers"; ot->idname = "NLA_OT_fmodifier_copy"; ot->description = "Copy the F-Modifier(s) of the active NLA-Strip"; - + /* api callbacks */ ot->exec = nla_fmodifier_copy_exec; - ot->poll = nlaop_poll_tweakmode_off; - + ot->poll = nlaop_poll_tweakmode_off; + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* id-props */ //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one"); } @@ -2439,23 +2439,23 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter, ok = 0; - + const bool active_only = RNA_boolean_get(op->ptr, "only_active"); const bool replace = RNA_boolean_get(op->ptr, "replace"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get a list of the editable tracks being shown in the NLA */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - + /* for each NLA-Track, add the specified modifier to all selected strips */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + for (strip = nlt->strips.first; strip; strip = strip->next) { /* can F-Modifier be added to the current strip? */ if (active_only) { @@ -2468,17 +2468,17 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) continue; } - + /* paste FModifiers from buffer */ ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, replace, NULL); ale->update |= ANIM_UPDATE_DEPS; } } - + /* clean up */ ANIM_animdata_update(&ac, &anim_data); ANIM_animdata_freelist(&anim_data); - + /* successful or not? */ if (ok) { WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); @@ -2489,24 +2489,24 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } } - + void NLA_OT_fmodifier_paste(wmOperatorType *ot) { /* identifiers */ ot->name = "Paste F-Modifiers"; ot->idname = "NLA_OT_fmodifier_paste"; ot->description = "Add copied F-Modifiers to the selected NLA-Strips"; - + /* api callbacks */ ot->exec = nla_fmodifier_paste_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "only_active", true, "Only Active", "Only paste F-Modifiers on active strip"); - RNA_def_boolean(ot->srna, "replace", false, "Replace Existing", + RNA_def_boolean(ot->srna, "replace", false, "Replace Existing", "Replace existing F-Modifiers, instead of just appending to the end of the existing list"); } diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 921d2e9c088..0c087fa67b9 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -55,21 +55,21 @@ int nlaop_poll_tweakmode_off(bContext *C) { Scene *scene; - - /* for now, we check 2 things: + + /* for now, we check 2 things: * 1) active editor must be NLA - * 2) tweakmode is currently set as a 'per-scene' flag + * 2) tweakmode is currently set as a 'per-scene' flag * so that it will affect entire NLA data-sets, - * but not all AnimData blocks will be in tweakmode for + * but not all AnimData blocks will be in tweakmode for * various reasons */ if (ED_operator_nla_active(C) == 0) return 0; - + scene = CTX_data_scene(C); if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) return 0; - + return 1; } @@ -77,21 +77,21 @@ int nlaop_poll_tweakmode_off(bContext *C) int nlaop_poll_tweakmode_on(bContext *C) { Scene *scene; - - /* for now, we check 2 things: + + /* for now, we check 2 things: * 1) active editor must be NLA - * 2) tweakmode is currently set as a 'per-scene' flag + * 2) tweakmode is currently set as a 'per-scene' flag * so that it will affect entire NLA data-sets, - * but not all AnimData blocks will be in tweakmode for + * but not all AnimData blocks will be in tweakmode for * various reasons */ if (ED_operator_nla_active(C) == 0) return 0; - + scene = CTX_data_scene(C); if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) return 0; - + return 1; } @@ -109,61 +109,61 @@ void nla_operatortypes(void) { /* view */ WM_operatortype_append(NLA_OT_properties); - + /* channels */ WM_operatortype_append(NLA_OT_channels_click); - + WM_operatortype_append(NLA_OT_action_pushdown); WM_operatortype_append(NLA_OT_action_unlink); - + WM_operatortype_append(NLA_OT_tracks_add); WM_operatortype_append(NLA_OT_tracks_delete); - + WM_operatortype_append(NLA_OT_selected_objects_add); - + /* select */ WM_operatortype_append(NLA_OT_click_select); WM_operatortype_append(NLA_OT_select_border); WM_operatortype_append(NLA_OT_select_all_toggle); WM_operatortype_append(NLA_OT_select_leftright); - + /* view */ WM_operatortype_append(NLA_OT_view_all); WM_operatortype_append(NLA_OT_view_selected); WM_operatortype_append(NLA_OT_view_frame); - + WM_operatortype_append(NLA_OT_previewrange_set); - + /* edit */ WM_operatortype_append(NLA_OT_tweakmode_enter); WM_operatortype_append(NLA_OT_tweakmode_exit); - + WM_operatortype_append(NLA_OT_actionclip_add); WM_operatortype_append(NLA_OT_transition_add); WM_operatortype_append(NLA_OT_soundclip_add); - + WM_operatortype_append(NLA_OT_meta_add); WM_operatortype_append(NLA_OT_meta_remove); - + WM_operatortype_append(NLA_OT_duplicate); WM_operatortype_append(NLA_OT_delete); WM_operatortype_append(NLA_OT_split); - + WM_operatortype_append(NLA_OT_mute_toggle); - + WM_operatortype_append(NLA_OT_swap); WM_operatortype_append(NLA_OT_move_up); WM_operatortype_append(NLA_OT_move_down); - + WM_operatortype_append(NLA_OT_action_sync_length); - + WM_operatortype_append(NLA_OT_make_single_user); - + WM_operatortype_append(NLA_OT_apply_scale); WM_operatortype_append(NLA_OT_clear_scale); - + WM_operatortype_append(NLA_OT_snap); - + WM_operatortype_append(NLA_OT_fmodifier_add); WM_operatortype_append(NLA_OT_fmodifier_copy); WM_operatortype_append(NLA_OT_fmodifier_paste); @@ -176,7 +176,7 @@ static void nla_keymap_channels(wmKeyMap *keymap) wmKeyMapItem *kmi; /* keymappings here are NLA-specific (different to standard channels keymap) */ - + /* selection --------------------------------------------------------------------- */ /* click-select */ // XXX for now, only leftmouse.... @@ -184,14 +184,14 @@ static void nla_keymap_channels(wmKeyMap *keymap) RNA_boolean_set(kmi->ptr, "extend", false); kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); - + /* channel operations ------------------------------------------------------------ */ /* add tracks */ kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "above_selected", false); kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "above_selected", true); - + /* delete tracks */ WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_tracks_delete", DELKEY, KM_PRESS, 0, 0); @@ -200,14 +200,14 @@ static void nla_keymap_channels(wmKeyMap *keymap) static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; - + /* selection ------------------------------------------------ */ /* click select */ kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); - + /* select left/right */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", false); @@ -215,92 +215,92 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", true); RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); - + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", false); RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT); - - + + /* deselect all */ /* TODO: uniformize with other select_all ops? */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "invert", false); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "invert", true); - + /* borderselect */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "axis_range", false); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "axis_range", true); - + /* view ---------------------------------------------------- */ /* auto-set range */ WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - + WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "NLA_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); #endif WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_view_frame", PAD0, KM_PRESS, 0, 0); - + /* editing ------------------------------------------------ */ - + /* add strips */ WM_keymap_add_item(keymap, "NLA_OT_actionclip_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_transition_add", TKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0); - + /* meta-strips */ WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0); - + /* duplicate */ kmi = WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "linked", false); - + kmi = WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "linked", true); - + /* single user */ WM_keymap_add_item(keymap, "NLA_OT_make_single_user", UKEY, KM_PRESS, 0, 0); - + /* delete */ WM_keymap_add_item(keymap, "NLA_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_delete", DELKEY, KM_PRESS, 0, 0); /* split */ WM_keymap_add_item(keymap, "NLA_OT_split", YKEY, KM_PRESS, 0, 0); - + /* toggles */ WM_keymap_add_item(keymap, "NLA_OT_mute_toggle", HKEY, KM_PRESS, 0, 0); - + /* swap */ WM_keymap_add_item(keymap, "NLA_OT_swap", FKEY, KM_PRESS, KM_ALT, 0); - + /* move up */ WM_keymap_add_item(keymap, "NLA_OT_move_up", PAGEUPKEY, KM_PRESS, 0, 0); /* move down */ WM_keymap_add_item(keymap, "NLA_OT_move_down", PAGEDOWNKEY, KM_PRESS, 0, 0); - + /* apply scale */ WM_keymap_add_item(keymap, "NLA_OT_apply_scale", AKEY, KM_PRESS, KM_CTRL, 0); /* clear scale */ WM_keymap_add_item(keymap, "NLA_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0); - + /* snap */ WM_keymap_add_item(keymap, "NLA_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - + /* add f-modifier */ WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - + /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_NLA); - + /* special markers hotkeys for anim editors: see note in definition of this function */ ED_marker_keymap_animedit_conflictfree(keymap); } @@ -311,35 +311,35 @@ void nla_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + /* keymap for all regions ------------------------------------------- */ keymap = WM_keymap_find(keyconf, "NLA Generic", SPACE_NLA, 0); - + /* region management */ WM_keymap_add_item(keymap, "NLA_OT_properties", NKEY, KM_PRESS, 0, 0); - + /* tweakmode * - enter and exit are separate operators with the same hotkey... * This works as they use different poll()'s */ WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, 0, 0); - + /* tweakmode for stashed actions * - similar to normal tweakmode, except we mark the tracks as being "solo" * too so that the action can be edited in isolation */ kmi = WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "isolate_action", true); - + kmi = WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "isolate_action", true); - + /* find (i.e. a shortcut for setting the name filter) */ WM_keymap_add_item(keymap, "ANIM_OT_channels_find", FKEY, KM_PRESS, KM_CTRL, 0); - + /* channels ---------------------------------------------------------- */ - /* Channels are not directly handled by the NLA Editor module, but are inherited from the Animation module. + /* Channels are not directly handled by the NLA Editor module, but are inherited from the Animation module. * Most of the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as there * are many similarities with the other Animation Editors. * @@ -347,7 +347,7 @@ void nla_keymap(wmKeyConfig *keyconf) */ keymap = WM_keymap_find(keyconf, "NLA Channels", SPACE_NLA, 0); nla_keymap_channels(keymap); - + /* data ------------------------------------------------------------- */ keymap = WM_keymap_find(keyconf, "NLA Editor", SPACE_NLA, 0); nla_keymap_main(keyconf, keymap); diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 2057fe5c022..8c9372f0612 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -89,7 +89,7 @@ enum { DESELECT_STRIPS_TEST, DESELECT_STRIPS_CLEARACTIVE, } /*eDeselectNlaStrips*/; - + /* Deselects strips in the NLA Editor * - This is called by the deselect all operator, as well as other ones! * @@ -105,20 +105,20 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel) bAnimListElem *ale; int filter; short smode; - + /* determine type-based settings */ // FIXME: double check whether ANIMFILTER_LIST_VISIBLE is needed! filter = (ANIMFILTER_DATA_VISIBLE); - + /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* See if we should be selecting or deselecting */ if (test == DESELECT_STRIPS_TEST) { for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* if any strip is selected, break out, since we should now be deselecting */ for (strip = nlt->strips.first; strip; strip = strip->next) { if (strip->flag & NLASTRIP_FLAG_SELECT) { @@ -126,32 +126,32 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel) break; } } - + if (sel == SELECT_SUBTRACT) break; } } - + /* convert selection modes to selection modes */ smode = selmodes_to_flagmodes(sel); - + /* Now set the flags */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* apply same selection to all strips */ for (strip = nlt->strips.first; strip; strip = strip->next) { /* set selection */ if (test != DESELECT_STRIPS_CLEARACTIVE) ACHANNEL_SET_FLAG(strip, smode, NLASTRIP_FLAG_SELECT); - + /* clear active flag */ // TODO: for clear active, do we want to limit this to only doing this on a certain set of tracks though? strip->flag &= ~NLASTRIP_FLAG_ACTIVE; } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -161,37 +161,37 @@ static void deselect_nla_strips(bAnimContext *ac, short test, short sel) static int nlaedit_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* 'standard' behavior - check if selected, then apply relevant selection */ if (RNA_boolean_get(op->ptr, "invert")) deselect_nla_strips(&ac, DESELECT_STRIPS_NOTEST, SELECT_INVERT); else deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } - + void NLA_OT_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "(De)select All"; ot->idname = "NLA_OT_select_all_toggle"; ot->description = "Select or deselect all NLA-Strips"; - + /* api callbacks */ ot->exec = nlaedit_deselectall_exec; ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; - + /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); @@ -218,27 +218,27 @@ static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, sho ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ac->ar->v2d; rctf rectf; float ymin /* =(float)(-NLACHANNEL_HEIGHT(snla)) */ /* UNUSED */, ymax = 0; - + /* convert border-region to view coordinates */ UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin); UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* convert selection modes to selection modes */ selectmode = selmodes_to_flagmodes(selectmode); - + /* loop over data, doing border select */ for (ale = anim_data.first; ale; ale = ale->next) { ymin = ymax - NLACHANNEL_STEP(snla); - + /* perform vertical suitability check (if applicable) */ if ((mode == NLA_BORDERSEL_FRAMERANGE) || !((ymax < rectf.ymin) || (ymin > rectf.ymax))) @@ -247,7 +247,7 @@ static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, sho if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* only select strips if they fall within the required ranges (if applicable) */ for (strip = nlt->strips.first; strip; strip = strip->next) { if ((mode == NLA_BORDERSEL_CHANNELS) || @@ -255,18 +255,18 @@ static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, sho { /* set selection */ ACHANNEL_SET_FLAG(strip, selectmode, NLASTRIP_FLAG_SELECT); - + /* clear active flag */ strip->flag &= ~NLASTRIP_FLAG_ACTIVE; } } } } - + /* set minimum extent to be the maximum of the next channel */ ymax = ymin; } - + /* cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -280,7 +280,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) short mode = 0, selectmode = 0; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; @@ -302,7 +302,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) /* selection 'mode' depends on whether borderselect region only matters on one axis */ if (RNA_boolean_get(op->ptr, "axis_range")) { - /* mode depends on which axis of the range is larger to determine which axis to use + /* mode depends on which axis of the range is larger to determine which axis to use * - checking this in region-space is fine, as it's fundamentally still going to be a different rect size * - the frame-range select option is favored over the channel one (x over y), as frame-range one is often * used for tweaking timing when "blocking", while channels is not that useful... @@ -312,17 +312,17 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) else mode = NLA_BORDERSEL_CHANNELS; } - else + else mode = NLA_BORDERSEL_ALLSTRIPS; - + /* apply borderselect action */ borderselect_nla_strips(&ac, rect, mode, selectmode); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; -} +} void NLA_OT_select_border(wmOperatorType *ot) { @@ -330,21 +330,21 @@ void NLA_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "NLA_OT_select_border"; ot->description = "Use box selection to grab NLA-Strips"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = nlaedit_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = nlaop_poll_tweakmode_off; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); - + RNA_def_boolean(ot->srna, "axis_range", 0, "Axis Range", ""); } @@ -366,24 +366,24 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - + Scene *scene = ac->scene; float xmin, xmax; - + /* if currently in tweakmode, exit tweakmode first */ if (scene->flag & SCE_NLA_EDIT_ON) WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL); - + /* if select mode is replace, deselect all keyframes (and channels) first */ if (select_mode == SELECT_REPLACE) { select_mode = SELECT_ADD; - + /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence */ deselect_nla_strips(ac, 0, SELECT_SUBTRACT); } - + /* get range, and get the right flag-setting mode */ if (leftright == NLAEDIT_LRSEL_LEFT) { xmin = MINAFRAMEF; @@ -393,19 +393,19 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri xmin = (float)(CFRA - 0.1f); xmax = MAXFRAMEF; } - + select_mode = selmodes_to_flagmodes(select_mode); - - + + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* select strips on the side where most data occurs */ for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - + /* check each strip to see if it is appropriate */ for (strip = nlt->strips.first; strip; strip = strip->next) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) { @@ -413,7 +413,7 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri } } } - + /* Cleanup */ ANIM_animdata_freelist(&anim_data); } @@ -425,28 +425,28 @@ static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op) bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); short selectmode; - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* if "test" mode is set, we don't have any info to set this with */ if (leftright == NLAEDIT_LRSEL_TEST) return OPERATOR_CANCELLED; - + /* do the selecting now */ nlaedit_select_leftright(C, &ac, leftright, selectmode); - + /* set notifier that keyframe selection (and channels too) have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); - + return OPERATOR_FINISHED; } @@ -454,18 +454,18 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); - + /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* handle mode-based testing */ if (leftright == NLAEDIT_LRSEL_TEST) { Scene *scene = ac.scene; ARegion *ar = ac.ar; View2D *v2d = &ar->v2d; float x; - + /* determine which side of the current frame mouse is on */ x = UI_view2d_region_to_view_x(v2d, event->mval[0]); if (x < CFRA) @@ -473,7 +473,7 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm else RNA_enum_set(op->ptr, "mode", NLAEDIT_LRSEL_RIGHT); } - + /* perform selection */ return nlaedit_select_leftright_exec(C, op); } @@ -481,24 +481,24 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, const wm void NLA_OT_select_leftright(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Select Left/Right"; ot->idname = "NLA_OT_select_leftright"; ot->description = "Select strips to the left or the right of the current frame"; - + /* api callbacks */ ot->invoke = nlaedit_select_leftright_invoke; ot->exec = nlaedit_select_leftright_exec; ot->poll = ED_operator_nla_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_nlaedit_leftright_select_types, NLAEDIT_LRSEL_TEST, "Mode", ""); RNA_def_property_flag(ot->prop, PROP_SKIP_SAVE); - + prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); } @@ -512,7 +512,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s ListBase anim_data = {NULL, NULL}; bAnimListElem *ale = NULL; int filter; - + SpaceNla *snla = (SpaceNla *)ac->sl; View2D *v2d = &ac->ar->v2d; Scene *scene = ac->scene; @@ -520,22 +520,22 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s int channel_index; float xmin, xmax; float x, y; - - + + /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, 0, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); - - /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click - * (that is the size of keyframe icons, so user should be expecting similar tolerances) + + /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click + * (that is the size of keyframe icons, so user should be expecting similar tolerances) */ xmin = UI_view2d_region_to_view_x(v2d, mval[0] - 7); xmax = UI_view2d_region_to_view_x(v2d, mval[0] + 7); - + /* filter data */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - + /* try to get channel */ ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { @@ -548,65 +548,65 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s /* found some channel - we only really should do somethign when its an Nla-Track */ if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; - + /* loop over NLA-strips in this track, trying to find one which occurs in the necessary bounds */ for (strip = nlt->strips.first; strip; strip = strip->next) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) break; } } - + /* remove active channel from list of channels for separate treatment (since it's needed later on) */ BLI_remlink(&anim_data, ale); - + /* free list of channels, since it's not used anymore */ ANIM_animdata_freelist(&anim_data); } - + /* if currently in tweakmode, exit tweakmode before changing selection states * now that we've found our target... */ if (scene->flag & SCE_NLA_EDIT_ON) WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL); - + /* for replacing selection, firstly need to clear existing selection */ if (select_mode == SELECT_REPLACE) { /* reset selection mode for next steps */ select_mode = SELECT_ADD; - + /* deselect all strips */ deselect_nla_strips(ac, 0, SELECT_SUBTRACT); - + /* deselect all other channels first */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); } - + /* only select strip if we clicked on a valid channel and hit something */ if (ale) { /* select the strip accordingly (if a matching one was found) */ if (strip) { select_mode = selmodes_to_flagmodes(select_mode); ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT); - + /* if we selected it, we can make it active too - * - we always need to clear the active strip flag though... + * - we always need to clear the active strip flag though... * - as well as selecting its track... */ deselect_nla_strips(ac, DESELECT_STRIPS_CLEARACTIVE, 0); - + if (strip->flag & NLASTRIP_FLAG_SELECT) { strip->flag |= NLASTRIP_FLAG_ACTIVE; - + /* Highlight NLA-Track */ if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; - + nlt->flag |= NLATRACK_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK); } } } - + /* free this channel */ MEM_freeN(ale); } @@ -626,7 +626,7 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - + /* get useful pointers from animation context data */ /* scene= ac.scene; */ /* UNUSED */ /* ar= ac.ar; */ /* UNUSED */ @@ -637,33 +637,33 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, const wmEvent selectmode = SELECT_INVERT; else selectmode = SELECT_REPLACE; - + /* select strips based upon mouse position */ mouse_nla_strips(C, &ac, event->mval, selectmode); - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); - + /* for tweak grab to work */ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } - + void NLA_OT_click_select(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Mouse Select"; ot->idname = "NLA_OT_click_select"; ot->description = "Handle clicks to select NLA Strips"; - + /* api callbacks - absolutely no exec() this yet... */ ot->invoke = nlaedit_clickselect_invoke; ot->poll = ED_operator_nla_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ prop = RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY RNA_def_property_flag(prop, PROP_SKIP_SAVE); diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 2df8643f850..88ef4a18142 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -75,15 +75,15 @@ ARegion *nla_has_buttons_region(ScrArea *sa) /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "buttons for nla"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -97,58 +97,58 @@ static SpaceLink *nla_new(const bContext *C) ScrArea *sa = CTX_wm_area(C); ARegion *ar; SpaceNla *snla; - + snla = MEM_callocN(sizeof(SpaceNla), "initnla"); snla->spacetype = SPACE_NLA; - + /* allocate DopeSheet data for NLA Editor */ snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); snla->ads->source = (ID *)scene; - + /* set auto-snapping settings */ snla->autosnap = SACTSNAP_FRAME; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for nla"); - + BLI_addtail(&snla->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* channel list region */ ar = MEM_callocN(sizeof(ARegion), "channel list for nla"); BLI_addtail(&snla->regionbase, ar); ar->regiontype = RGN_TYPE_CHANNELS; ar->alignment = RGN_ALIGN_LEFT; - + /* only need to set these settings since this will use the 'stack' configuration */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - + /* ui buttons */ ar = MEM_callocN(sizeof(ARegion), "buttons region for nla"); - + BLI_addtail(&snla->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for nla"); - + BLI_addtail(&snla->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + ar->v2d.tot.xmin = (float)(SFRA - 10); ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(EFRA + 10); ar->v2d.tot.ymax = 0.0f; - + ar->v2d.cur = ar->v2d.tot; - + ar->v2d.min[0] = 0.0f; ar->v2d.min[1] = 0.0f; - + ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = 10000.0f; @@ -160,15 +160,15 @@ static SpaceLink *nla_new(const bContext *C) ar->v2d.keepofs = V2D_KEEPOFS_Y; ar->v2d.align = V2D_ALIGN_NO_POS_Y; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - + return (SpaceLink *)snla; } /* not spacelink itself */ static void nla_free(SpaceLink *sl) -{ +{ SpaceNla *snla = (SpaceNla *) sl; - + if (snla->ads) { BLI_freelistN(&snla->ads->chanbase); MEM_freeN(snla->ads); @@ -180,7 +180,7 @@ static void nla_free(SpaceLink *sl) static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { SpaceNla *snla = (SpaceNla *)sa->spacedata.first; - + /* init dopesheet data if non-existent (i.e. for old files) */ if (snla->ads == NULL) { snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); @@ -193,10 +193,10 @@ static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *nla_duplicate(SpaceLink *sl) { SpaceNla *snlan = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ snlan->ads = MEM_dupallocN(snlan->ads); - + return (SpaceLink *)snlan; } @@ -204,12 +204,12 @@ static SpaceLink *nla_duplicate(SpaceLink *sl) static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + /* ensure the 2d view sync works - main region has bottom scroller */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymap */ /* own channels map first to override some channel keymaps */ keymap = WM_keymap_find(wm->defaultconf, "NLA Channels", SPACE_NLA, 0); @@ -217,7 +217,7 @@ static void nla_channel_region_init(wmWindowManager *wm, ARegion *ar) /* now generic channels map for everything else that can apply */ keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -228,21 +228,21 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar) bAnimContext ac; View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* data */ if (ANIM_animdata_get_context(C, &ac)) { draw_nla_channel_list(C, &ac, ar); } - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -254,9 +254,9 @@ static void nla_channel_region_draw(const bContext *C, ARegion *ar) static void nla_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "NLA Editor", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -273,52 +273,52 @@ static void nla_main_region_draw(const bContext *C, ARegion *ar) View2DGrid *grid; View2DScrollers *scrollers; short unit = 0, flag = 0; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* time grid */ unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* data */ if (ANIM_animdata_get_context(C, &ac)) { /* strips and backdrops */ draw_nla_main_data(&ac, snla, ar); - + /* text draw cached, in pixelspace now */ UI_view2d_text_cache_draw(ar); } - + UI_view2d_view_ortho(v2d); - + /* current frame */ if (snla->flag & SNLA_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); - + /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); ED_markers_draw(C, DRAW_MARKERS_MARGIN); - + /* preview range */ UI_view2d_view_ortho(v2d); ANIM_draw_previewrange(C, v2d, 0); - + /* callback */ UI_view2d_view_ortho(v2d); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -341,9 +341,9 @@ static void nla_header_region_draw(const bContext *C, ARegion *ar) static void nla_buttons_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "NLA Generic", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -505,7 +505,7 @@ static void nla_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) static void nla_id_remap(ScrArea *UNUSED(sa), SpaceLink *slink, ID *old_id, ID *new_id) { SpaceNla *snla = (SpaceNla *)slink; - + if (snla->ads) { if ((ID *)snla->ads->filter_grp == old_id) { snla->ads->filter_grp = (Group *)new_id; @@ -521,10 +521,10 @@ void ED_spacetype_nla(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla"); ARegionType *art; - + st->spaceid = SPACE_NLA; strncpy(st->name, "NLA", BKE_ST_MAXNAME); - + st->new = nla_new; st->free = nla_free; st->init = nla_init; @@ -543,30 +543,30 @@ void ED_spacetype_nla(void) art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - + art->init = nla_header_region_init; art->draw = nla_header_region_draw; - + BLI_addhead(&st->regiontypes, art); - + /* regions: channels */ art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; - + art->init = nla_channel_region_init; art->draw = nla_channel_region_draw; art->listener = nla_channel_region_listener; - + BLI_addhead(&st->regiontypes, art); - + /* regions: UI buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_UI; @@ -575,11 +575,11 @@ void ED_spacetype_nla(void) art->listener = nla_region_listener; art->init = nla_buttons_region_init; art->draw = nla_buttons_region_draw; - + BLI_addhead(&st->regiontypes, art); nla_buttons_register(art); - - + + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index d7fd808917a..4d12ebfb16b 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -87,7 +87,7 @@ static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, Poin static void node_draw_socket_new(bNodeSocket *sock, float size) { float x = sock->locx, y = sock->locy; - + /* 16 values of sin function */ static float si[16] = { 0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f, @@ -103,14 +103,14 @@ static void node_draw_socket_new(bNodeSocket *sock, float size) 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f, }; int a; - + glColor3ub(180, 180, 180); - + glBegin(GL_POLYGON); for (a = 0; a < 16; a++) glVertex2f(x + size * si[a], y + size * co[a]); glEnd(); - + glColor4ub(0, 0, 0, 150); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -132,7 +132,7 @@ static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *p bNodeSocket *output = node->outputs.first; PointerRNA sockptr; RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); - + uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE); } @@ -144,14 +144,14 @@ static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr PointerRNA sockptr; uiLayout *col; RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); - + col = uiLayoutColumn(layout, false); uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0); uiItemR(col, &sockptr, "default_value", UI_ITEM_R_SLIDER, "", ICON_NONE); } static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *row, *col; bNodeTree *ntree = (bNodeTree *)ptr->id.data; @@ -172,7 +172,7 @@ static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt /* XXX no context access here .. */ bNode *node = ptr->data; CurveMapping *cumap = node->storage; - + if (cumap) { cumap->flag |= CUMA_DRAW_CFRA; if (node->custom1 < node->custom2) @@ -232,7 +232,7 @@ static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA * bNodeSocket *output = node->outputs.first; PointerRNA sockptr; RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); - + uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE); } @@ -243,9 +243,9 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) bNodeTree *ntree = ntree_v; bNode *node = node_v; Tex *tex; - + if (node->menunr < 1) return; - + if (node->id) { id_us_min(node->id); node->id = NULL; @@ -255,16 +255,16 @@ static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v) node->id = &tex->id; id_us_plus(node->id); BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name)); - + nodeSetActive(ntree, node); - + if (ntree->type == NTREE_TEXTURE) ntreeTexCheckCyclics(ntree); - + // allqueue(REDRAWBUTSSHADING, 0); // allqueue(REDRAWNODE, 0); - NodeTagChanged(ntree, node); - + NodeTagChanged(ntree, node); + node->menunr = 0; } #endif @@ -279,9 +279,9 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA (node->type != CMP_NODE_TEXTURE) && (node->type != TEX_NODE_TEXTURE) ); - + uiItemR(layout, ptr, "texture", 0, "", ICON_NONE); - + if (multi) { /* Number Drawing not optimal here, better have a list*/ uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE); @@ -289,7 +289,7 @@ static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA } static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE); } @@ -309,7 +309,7 @@ static int node_resize_area_default(bNode *node, int x, int y) const float size = 10.0f; rctf totr = node->totr; int dir = 0; - + if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) dir |= NODE_RESIZE_RIGHT; if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) @@ -338,11 +338,11 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bNode *tnode; rctf rect, noderect; float xmax, ymax; - + /* init rect from current frame size */ node_to_view(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax); node_to_view(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin); - + /* frame can be resized manually only if shrinking is disabled or no children are attached */ data->flag |= NODE_FRAME_RESIZEABLE; /* for shrinking bbox, initialize the rect from first child node */ @@ -351,14 +351,14 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->parent != node) continue; - + /* add margin to node rect */ noderect = tnode->totr; noderect.xmin -= margin; noderect.xmax += margin; noderect.ymin -= margin; noderect.ymax += margin; - + /* first child initializes frame */ if (bbinit) { bbinit = 0; @@ -368,13 +368,13 @@ static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, else BLI_rctf_union(&rect, &noderect); } - + /* now adjust the frame size from view-space bounding box */ node_from_view(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety); node_from_view(node, rect.xmax, rect.ymin, &xmax, &ymax); node->width = xmax - node->offsetx; node->height = -ymax + node->offsety; - + node->totr = rect; } @@ -398,14 +398,14 @@ static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float asp BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, aspect, aspect, 1.0f); BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */ - + /* title color */ UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); width = BLF_width(fontid, label, sizeof(label)); ascender = BLF_ascender(fontid); label_height = ((margin / aspect) + (ascender * aspect)); - + /* 'x' doesn't need aspect correction */ x = BLI_rctf_cent_x(rct) - (0.5f * width); y = rct->ymax - label_height; @@ -467,7 +467,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, int color_id = node_get_colorid(node); unsigned char color[4]; float alpha; - + /* skip if out of view */ if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) { UI_block_end(C, node->block); @@ -477,10 +477,10 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, UI_GetThemeColor4ubv(TH_NODE_FRAME, color); alpha = (float)(color[3]) / 255.0f; - + /* shadow */ node_draw_shadow(snode, node, BASIS_RAD, alpha); - + /* body */ if (node->flag & NODE_CUSTOM_COLOR) glColor4f(node->color[0], node->color[1], node->color[2], alpha); @@ -495,7 +495,7 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, if (node->flag & SELECT) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else @@ -504,16 +504,16 @@ static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - + /* label */ node_draw_frame_label(ntree, node, snode->aspect); - + UI_ThemeClearColor(color_id); - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -525,11 +525,11 @@ static int node_resize_area_frame(bNode *node, int x, int y) NodeFrame *data = (NodeFrame *)node->storage; rctf totr = node->totr; int dir = 0; - + /* shrinking frame size is determined by child nodes */ if (!(data->flag & NODE_FRAME_RESIZEABLE)) return 0; - + if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax) dir |= NODE_RESIZE_RIGHT; if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax) @@ -538,7 +538,7 @@ static int node_resize_area_frame(bNode *node, int x, int y) dir |= NODE_RESIZE_TOP; if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size) dir |= NODE_RESIZE_BOTTOM; - + return dir; } @@ -557,10 +557,10 @@ static void node_draw_reroute_prepare(const bContext *UNUSED(C), bNodeTree *UNUS bNodeSocket *nsock; float locx, locy; float size = NODE_REROUTE_SIZE; - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); - + /* reroute node has exactly one input and one output, both in the same place */ nsock = node->outputs.first; nsock->locx = locx; @@ -653,7 +653,7 @@ static int node_tweak_area_reroute(bNode *node, int x, int y) { /* square of tweak radius */ const float tweak_radius_sq = SQUARE(24); - + bNodeSocket *sock = node->inputs.first; float dx = sock->locx - x; float dy = sock->locy - y; @@ -693,9 +693,9 @@ static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr, return; col = uiLayoutColumn(layout, false); - + uiItemR(col, imaptr, "source", 0, "", ICON_NONE); - + source = RNA_enum_get(imaptr, "source"); if (source == IMA_SRC_SEQUENCE) { @@ -732,11 +732,11 @@ static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA { bNode *node = ptr->data; uiLayout *col; - + uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL); - + if (!node->id) return; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE); @@ -779,12 +779,12 @@ static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), Poin } static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "operation", 0, "", ICON_NONE); } static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE); uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE); @@ -915,7 +915,7 @@ static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, P } static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "sky_type", 0, "", ICON_NONE); uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE); uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE); @@ -937,11 +937,11 @@ static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), Po static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); @@ -1203,15 +1203,15 @@ static void node_shader_set_butfunc(bNodeType *ntype) case SH_NODE_VALTORGB: ntype->draw_buttons = node_buts_colorramp; break; - case SH_NODE_MATH: + case SH_NODE_MATH: ntype->draw_buttons = node_buts_math; - break; - case SH_NODE_VECT_MATH: + break; + case SH_NODE_VECT_MATH: ntype->draw_buttons = node_shader_buts_vect_math; - break; - case SH_NODE_VECT_TRANSFORM: + break; + case SH_NODE_VECT_TRANSFORM: ntype->draw_buttons = node_shader_buts_vect_transform; - break; + break; case SH_NODE_GEOMETRY: ntype->draw_buttons = node_shader_buts_geometry; break; @@ -1338,14 +1338,14 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * { bNode *node = ptr->data; PointerRNA imaptr, iuserptr; - + RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr); uiLayoutSetContextPointer(layout, "image_user", &iuserptr); uiTemplateID( layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); if (!node->id) return; - + imaptr = RNA_pointer_get(ptr, "image"); node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr, true); @@ -1374,17 +1374,17 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point char scene_name[MAX_ID_NAME - 2]; uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL, UI_TEMPLATE_ID_FILTER_ALL); - + if (!node->id) return; col = uiLayoutColumn(layout, false); row = uiLayoutRow(col, true); uiItemR(row, ptr, "layer", 0, "", ICON_NONE); - + prop = RNA_struct_find_property(ptr, "layer"); if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name))) return; - + scn_ptr = RNA_pointer_get(ptr, "scene"); RNA_string_get(&scn_ptr, "name", scene_name); @@ -1399,7 +1399,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point uiLayout *col, *row; int reference; int filter; - + col = uiLayoutColumn(layout, false); filter = RNA_enum_get(ptr, "filter_type"); reference = RNA_boolean_get(ptr, "use_variable_size"); @@ -1412,14 +1412,14 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point } uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE); } - + uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE); - + if (RNA_boolean_get(ptr, "use_relative")) { uiItemL(col, IFACE_("Aspect Correction"), ICON_NONE); row = uiLayoutRow(layout, true); uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE); @@ -1435,31 +1435,31 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Center:"), ICON_NONE); uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE); uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE); - + uiItemS(layout); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE); - + uiItemS(layout); - + uiItemR(layout, ptr, "spin", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "zoom", 0, NULL, ICON_NONE); } static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE); uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE); @@ -1469,7 +1469,7 @@ static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED( static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA *ptr) { uiLayout *sub, *col; - + col = uiLayoutColumn(layout, false); uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE); uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE); @@ -1498,17 +1498,17 @@ static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA /* qdn: glare node */ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE); uiItemR(layout, ptr, "quality", 0, "", ICON_NONE); if (RNA_enum_get(ptr, "glare_type") != 1) { uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE); - + if (RNA_enum_get(ptr, "glare_type") != 0) uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } - + uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE); @@ -1518,7 +1518,7 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin } if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) { uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - + if (RNA_enum_get(ptr, "glare_type") == 0) uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE); } @@ -1528,7 +1528,7 @@ static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), Poin } static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; col = uiLayoutColumn(layout, false); @@ -1562,11 +1562,11 @@ static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), P static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE); uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Speed:"), ICON_NONE); uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE); @@ -1610,7 +1610,7 @@ static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), Point static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row, *col; - + col = uiLayoutColumn(layout, false); row = uiLayoutRow(col, false); uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1640,17 +1640,17 @@ static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *sub, *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE); uiItemR(col, ptr, "size", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE); sub = uiLayoutColumn(col, false); uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min")); uiItemR(sub, ptr, "min", 0, "", ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE); sub = uiLayoutColumn(col, false); @@ -1659,18 +1659,18 @@ static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), } static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE); uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE); } static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_antialias_z", 0, NULL, ICON_NONE); @@ -1707,7 +1707,7 @@ static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1716,7 +1716,7 @@ static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col, *row; - + col = uiLayoutColumn(layout, true); uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); @@ -1730,7 +1730,7 @@ static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row, *col; - + uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE); row = uiLayoutRow(layout, false); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -1756,11 +1756,11 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C) static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE); uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, true); /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */ uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1770,7 +1770,7 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1778,7 +1778,7 @@ static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C) } static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiLayout *col, *row; uiItemL(layout, IFACE_("Color Space:"), ICON_NONE); @@ -1806,7 +1806,7 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED( static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -1844,22 +1844,22 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi int active_index; const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER; const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0; - + node_composit_buts_file_output(layout, C, ptr); uiTemplateImageSettings(layout, &imfptr, false); - + /* disable stereo output for multilayer, too much work for something that no one will use */ /* if someone asks for that we can implement it */ if (is_multiview) uiTemplateImageFormatViews(layout, &imfptr, NULL); uiItemS(layout); - + uiItemO(layout, IFACE_("Add Input"), ICON_ZOOMIN, "NODE_OT_output_file_add_socket"); - + row = uiLayoutRow(layout, false); col = uiLayoutColumn(row, true); - + active_index = RNA_int_get(ptr, "active_input_index"); /* using different collection properties if multilayer format is enabled */ if (multilayer) { @@ -1876,18 +1876,18 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi } /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ active_input_ptr.id.data = ptr->id.data; - + col = uiLayoutColumn(row, true); ot = WM_operatortype_find("NODE_OT_output_file_move_active_socket", false); uiItemFullO_ptr(col, ot, "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); RNA_enum_set(&op_ptr, "direction", 1); uiItemFullO_ptr(col, ot, "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, 0, &op_ptr); RNA_enum_set(&op_ptr, "direction", 2); - + if (active_input_ptr.data) { if (multilayer) { col = uiLayoutColumn(layout, true); - + uiItemL(col, IFACE_("Layer:"), ICON_NONE); row = uiLayoutRow(col, false); uiItemR(row, &active_input_ptr, "name", 0, "", ICON_NONE); @@ -1896,20 +1896,20 @@ static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, Poi } else { col = uiLayoutColumn(layout, true); - + uiItemL(col, IFACE_("File Subpath:"), ICON_NONE); row = uiLayoutRow(col, false); uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY, NULL); - + /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); - + col = uiLayoutColumn(layout, true); uiItemL(col, IFACE_("Format:"), ICON_NONE); uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(layout, false); uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == false); uiTemplateImageSettings(col, &imfptr, false); @@ -1941,7 +1941,7 @@ static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), Poi static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, false); uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE); uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE); @@ -1960,22 +1960,22 @@ static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C) static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *split, *col, *row; - + uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE); - + if (RNA_enum_get(ptr, "correction_method") == 0) { - + split = uiLayoutSplit(layout, 0.0f, false); col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "lift", 1, 1, 0, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "gamma", 1, 1, 1, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "gain", 1, 1, 1, 1); row = uiLayoutRow(col, false); @@ -1983,19 +1983,19 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C } else { - + split = uiLayoutSplit(layout, 0.0f, false); col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "offset", 1, 1, 0, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE); uiItemR(col, ptr, "offset_basis", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "power", 1, 1, 0, 1); row = uiLayoutRow(col, false); uiItemR(row, ptr, "power", 0, NULL, ICON_NONE); - + col = uiLayoutColumn(split, false); uiTemplateColorPicker(col, ptr, "slope", 1, 1, 0, 1); row = uiLayoutRow(col, false); @@ -2048,7 +2048,7 @@ static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), } static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ +{ uiItemR(layout, ptr, "mode", 0, "", ICON_NONE); } @@ -2111,7 +2111,7 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - + row = uiLayoutRow(layout, false); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); @@ -2165,7 +2165,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - + row = uiLayoutRow(layout, false); uiItemR(row, ptr, "red", 0, NULL, ICON_NONE); uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); @@ -2194,7 +2194,7 @@ static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UN uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - + uiItemL(row, IFACE_("Lift"), ICON_NONE); uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2221,11 +2221,11 @@ static void node_composit_buts_switch_view_ex(uiLayout *layout, bContext *UNUSED static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *row; - + row = uiLayoutRow(layout, true); uiItemR(row, ptr, "x", 0, NULL, ICON_NONE); uiItemR(row, ptr, "y", 0, NULL, ICON_NONE); - + row = uiLayoutRow(layout, true); uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2376,7 +2376,7 @@ static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), Poi static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "tile_order") == 0) { @@ -2774,11 +2774,11 @@ static void node_composit_set_butfunc(bNodeType *ntype) static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE); uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE); - + col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE); uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE); @@ -2791,7 +2791,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe ID *id = ptr->id.data; Tex *tex = (Tex *)node->storage; uiLayout *col, *row; - + RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr); col = uiLayoutColumn(layout, false); @@ -2835,7 +2835,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING))); uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); break; - + case TEX_CLOUDS: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); row = uiLayoutRow(col, false); @@ -2844,7 +2844,7 @@ static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), Pointe uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE); break; - + case TEX_DISTNOISE: uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE); uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE); @@ -2945,7 +2945,7 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket { StructRNA *srna = ntype->ext.srna; PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier); - + if (prop) RNA_def_property_update_runtime(prop, node_property_update_default); } @@ -2953,7 +2953,7 @@ static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocket static void node_template_properties_update(bNodeType *ntype) { bNodeSocketTemplate *stemp; - + if (ntype->inputs) { for (stemp = ntype->inputs; stemp->type >= 0; ++stemp) node_socket_template_properties_update(ntype, stemp); @@ -2999,7 +2999,7 @@ void ED_node_init_butfuncs(void) /*extern bNodeTreeType NodeTreeTypeUndefined;*/ extern bNodeType NodeTypeUndefined; extern bNodeSocketType NodeSocketTypeUndefined; - + /* default ui functions */ NodeTypeUndefined.draw_nodetype = node_draw_default; NodeTypeUndefined.draw_nodetype_prepare = node_update_default; @@ -3008,12 +3008,12 @@ void ED_node_init_butfuncs(void) NodeTypeUndefined.draw_buttons = NULL; NodeTypeUndefined.draw_buttons_ex = NULL; NodeTypeUndefined.resize_area_func = node_resize_area_default; - + NodeSocketTypeUndefined.draw = node_socket_undefined_draw; NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color; NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw; NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color; - + /* node type ui functions */ NODE_TYPES_BEGIN(ntype) /* default ui functions */ @@ -3024,17 +3024,17 @@ void ED_node_init_butfuncs(void) ntype->draw_buttons = NULL; ntype->draw_buttons_ex = NULL; ntype->resize_area_func = node_resize_area_default; - + node_common_set_butfunc(ntype); - + node_composit_set_butfunc(ntype); node_shader_set_butfunc(ntype); node_texture_set_butfunc(ntype); - + /* define update callbacks for socket properties */ node_template_properties_update(ntype); NODE_TYPES_END - + /* tree type icons */ ntreeType_Composite->ui_icon = ICON_RENDERLAYERS; ntreeType_Shader->ui_icon = ICON_MATERIAL; @@ -3091,16 +3091,16 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR uiLayout *row; PointerRNA inputptr, imfptr; int imtype; - + row = uiLayoutRow(layout, false); - + imfptr = RNA_pointer_get(node_ptr, "format"); imtype = RNA_enum_get(&imfptr, "file_format"); if (imtype == R_IMF_IMTYPE_MULTILAYER) { NodeImageMultiFileSocket *input = sock->storage; RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); - + uiItemL(row, input->layer, ICON_NONE); } else { @@ -3109,12 +3109,12 @@ static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerR const char *imtype_name; uiBlock *block; RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); - + uiItemL(row, input->path, ICON_NONE); - + if (!RNA_boolean_get(&inputptr, "use_node_format")) imfptr = RNA_pointer_get(&inputptr, "format"); - + imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); @@ -3131,7 +3131,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, bNodeSocket *sock = ptr->data; int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ - + /* XXX not nice, eventually give this node its own socket type ... */ if (node->type == CMP_NODE_OUTPUT_FILE) { node_file_output_socket_draw(C, layout, ptr, node_ptr); @@ -3142,7 +3142,7 @@ static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, node_socket_button_label(C, layout, ptr, node_ptr, text); return; } - + switch (type) { case SOCK_FLOAT: case SOCK_INT: @@ -3171,7 +3171,7 @@ static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout bNodeSocket *sock = ptr->data; int type = sock->typeinfo->type; /*int subtype = sock->typeinfo->subtype;*/ - + switch (type) { case SOCK_FLOAT: { @@ -3238,40 +3238,40 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b Image *ima; void *lock; ImBuf *ibuf; - + if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode)) return; - + if (parent_key.value != active_viewer_key.value) return; - + ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock); if (ibuf) { - float x, y; - + float x, y; + glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); glPushMatrix(); - + /* somehow the offset has to be calculated inverse */ - + glaDefine2DArea(&ar->winrct); wmOrtho2_region_pixelspace(ar); - + x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof; y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof; - + if (ibuf->rect || ibuf->rect_float) { unsigned char *display_buffer = NULL; void *cache_handle = NULL; - + if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) { int ofs; - + display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - + #ifdef __BIG_ENDIAN__ if (snode->flag & SNODE_SHOW_R) ofs = 0; else if (snode->flag & SNODE_SHOW_G) ofs = 1; @@ -3281,25 +3281,25 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b else if (snode->flag & SNODE_SHOW_G) ofs = 2; else ofs = 3; #endif - + glPixelZoom(snode->zoom, snode->zoom); /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ - + glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer - (4 - ofs)); - + glPixelZoom(1.0f, 1.0f); } else if (snode->flag & SNODE_SHOW_ALPHA) { display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle); - + glPixelZoom(snode->zoom, snode->zoom); /* swap bytes, so alpha is most significant one, then just draw it as luminance int */ #ifdef __BIG_ENDIAN__ glPixelStorei(GL_UNPACK_SWAP_BYTES, 1); #endif glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer); - + #ifdef __BIG_ENDIAN__ glPixelStorei(GL_UNPACK_SWAP_BYTES, 0); #endif @@ -3309,24 +3309,24 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glPixelZoom(snode->zoom, snode->zoom); - + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); - + glPixelZoom(1.0f, 1.0f); glDisable(GL_BLEND); } else { glPixelZoom(snode->zoom, snode->zoom); - + glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST); - + glPixelZoom(1.0f, 1.0f); } - + if (cache_handle) IMB_display_buffer_release(cache_handle); } - + /** \note draw selected info on backdrop */ if (snode->edittree) { bNode *node = snode->edittree->nodes.first; @@ -3339,7 +3339,7 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b } node = node->next; } - + if ((snode->nodetree->flag & NTREE_VIEWER_BORDER) && viewer_border->xmin < viewer_border->xmax && viewer_border->ymin < viewer_border->ymax) @@ -3354,13 +3354,13 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b glaDrawBorderCorners(&pixel_border, 1.0f, 1.0f); } } - + glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); } - + BKE_image_release_ibuf(ima, ibuf, lock); } @@ -3372,14 +3372,14 @@ bool node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, flo float deltax, deltay; float cursor[2] = {0.0f, 0.0f}; int toreroute, fromreroute; - + /* this function can be called with snode null (via cut_links_intersect) */ /* XXX map snode->cursor back to view space */ if (snode) { cursor[0] = snode->cursor[0] * UI_DPI_FAC; cursor[1] = snode->cursor[1] * UI_DPI_FAC; } - + /* in v0 and v3 we put begin/end points */ if (link->fromsock) { vec[0][0] = link->fromsock->locx; @@ -3448,7 +3448,7 @@ bool node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, flo coord_array[0] + 0, resol, sizeof(float) * 2); BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0] + 1, resol, sizeof(float) * 2); - + return 1; } return 0; @@ -3461,7 +3461,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, bool do_shaded, int th_col2, bool do_triple, int th_col3) { float coord_array[LINK_RESOL + 1][2]; - + if (node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) { float dist, spline_step = 0.0f; int i; @@ -3470,12 +3470,12 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, float linew; float arrow[2], arrow1[2], arrow2[2]; glGetFloatv(GL_LINE_WIDTH, &linew); - + /* we can reuse the dist variable here to increment the GL curve eval amount*/ dist = 1.0f / (float)LINK_RESOL; - + glEnable(GL_LINE_SMOOTH); - + drawarrow = ((link->tonode && (link->tonode->type == NODE_REROUTE)) && (link->fromnode && (link->fromnode->type == NODE_REROUTE))); @@ -3496,7 +3496,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, if (do_triple) { UI_ThemeColorShadeAlpha(th_col3, -80, -120); glLineWidth(4.0f); - + glBegin(GL_LINE_STRIP); for (i = 0; i <= LINK_RESOL; i++) { glVertex2fv(coord_array[i]); @@ -3510,7 +3510,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, glEnd(); } } - + /* XXX using GL_LINES for shaded node lines is a workaround * for Intel hardware, this breaks with GL_LINE_STRIP and * changing color in begin/end blocks. @@ -3521,10 +3521,10 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, for (i = 0; i < LINK_RESOL; i++) { UI_ThemeColorBlend(th_col1, th_col2, spline_step); glVertex2fv(coord_array[i]); - + UI_ThemeColorBlend(th_col1, th_col2, spline_step + dist); glVertex2fv(coord_array[i + 1]); - + spline_step += dist; } glEnd(); @@ -3537,7 +3537,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, } glEnd(); } - + if (drawarrow) { glBegin(GL_LINE_STRIP); glVertex2fv(arrow1); @@ -3545,7 +3545,7 @@ void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, glVertex2fv(arrow2); glEnd(); } - + glDisable(GL_LINE_SMOOTH); } } @@ -3578,24 +3578,24 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, { float coord_array[2][2]; int i; - + node_link_straight_points(v2d, snode, link, coord_array); - + glEnable(GL_LINE_SMOOTH); - + if (do_triple) { UI_ThemeColorShadeAlpha(th_col3, -80, -120); glLineWidth(4.0f); - + glBegin(GL_LINES); glVertex2fv(coord_array[0]); glVertex2fv(coord_array[1]); glEnd(); } - + UI_ThemeColor(th_col1); glLineWidth(1.5f); - + /* XXX using GL_LINES for shaded node lines is a workaround * for Intel hardware, this breaks with GL_LINE_STRIP and * changing color in begin/end blocks. @@ -3607,7 +3607,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, UI_ThemeColorBlend(th_col1, th_col2, t); glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]); - + t = (float)(i + 1) / (float)(LINK_RESOL - 1); UI_ThemeColorBlend(th_col1, th_col2, t); glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0], @@ -3624,7 +3624,7 @@ void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, } glEnd(); } - + glDisable(GL_LINE_SMOOTH); } #endif @@ -3635,10 +3635,10 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) bool do_shaded = false; bool do_triple = false; int th_col1 = TH_WIRE_INNER, th_col2 = TH_WIRE_INNER, th_col3 = TH_WIRE; - + if (link->fromsock == NULL && link->tosock == NULL) return; - + /* new connection */ if (!link->fromsock || !link->tosock) { th_col1 = TH_ACTIVE; @@ -3678,7 +3678,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border) { glBegin(GL_LINES); - + if (border & (NODE_LEFT | NODE_RIGHT)) { glVertex2f(cent[0], v2d->cur.ymin); glVertex2f(cent[0], v2d->cur.ymax); @@ -3687,7 +3687,7 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder glVertex2f(cent[0], cent[1] - size); glVertex2f(cent[0], cent[1] + size); } - + if (border & (NODE_TOP | NODE_BOTTOM)) { glVertex2f(v2d->cur.xmin, cent[1]); glVertex2f(v2d->cur.xmax, cent[1]); @@ -3696,6 +3696,6 @@ void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder glVertex2f(cent[0] - size, cent[1]); glVertex2f(cent[0] + size, cent[1]); } - + glEnd(); } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 2dcc69122dd..edd19617a0f 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -70,32 +70,32 @@ bNode *node_add_node(const bContext *C, const char *idname, int type, float locx SpaceNode *snode = CTX_wm_space_node(C); Main *bmain = CTX_data_main(C); bNode *node = NULL; - + node_deselect_all(snode); - + if (idname) node = nodeAddNode(C, snode->edittree, idname); else node = nodeAddStaticNode(C, snode->edittree, type); BLI_assert(node && node->typeinfo); - + /* generics */ node->locx = locx; node->locy = locy + 60.0f; /* arbitrary... so its visible, (0,0) is top of node */ nodeSetSelected(node, true); - + node->locx = locx; node->locy = locy + 60.0f; - + ntreeUpdateTree(bmain, snode->edittree); ED_node_set_active(bmain, snode->edittree, node); - + snode_update(snode, node); - + if (snode->nodetree->type == NTREE_TEXTURE) { ntreeTexCheckCyclics(snode->edittree); } - + return node; } @@ -122,7 +122,7 @@ static bool add_reroute_intersect_check(bNodeLink *link, float mcoords[][2], int typedef struct bNodeSocketLink { struct bNodeSocketLink *next, *prev; - + struct bNodeSocket *sock; struct bNodeLink *link; float point[2]; @@ -131,12 +131,12 @@ typedef struct bNodeSocketLink { static bNodeSocketLink *add_reroute_insert_socket_link(ListBase *lb, bNodeSocket *sock, bNodeLink *link, const float point[2]) { bNodeSocketLink *socklink, *prev; - + socklink = MEM_callocN(sizeof(bNodeSocketLink), "socket link"); socklink->sock = sock; socklink->link = link; copy_v2_v2(socklink->point, point); - + for (prev = lb->last; prev; prev = prev->prev) { if (prev->sock == sock) break; @@ -153,18 +153,18 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi bNodeSocket *cursock = socklink->sock; float insert_point[2]; int num_links; - + zero_v2(insert_point); num_links = 0; - + while (socklink && socklink->sock == cursock) { if (!(socklink->link->flag & NODE_LINK_TEST)) { socklink->link->flag |= NODE_LINK_TEST; - + /* create the reroute node for this cursock */ if (!reroute_node) { reroute_node = nodeAddStaticNode(C, ntree, NODE_REROUTE); - + /* add a single link to/from the reroute node to replace multiple links */ if (in_out == SOCK_OUT) { nodeAddLink(ntree, socklink->link->fromnode, socklink->link->fromsock, reroute_node, reroute_node->inputs.first); @@ -173,7 +173,7 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi nodeAddLink(ntree, reroute_node, reroute_node->outputs.first, socklink->link->tonode, socklink->link->tosock); } } - + /* insert the reroute node into the link */ if (in_out == SOCK_OUT) { socklink->link->fromnode = reroute_node; @@ -183,21 +183,21 @@ static bNodeSocketLink *add_reroute_do_socket_section(bContext *C, bNodeSocketLi socklink->link->tonode = reroute_node; socklink->link->tosock = reroute_node->inputs.first; } - + add_v2_v2(insert_point, socklink->point); num_links++; } socklink = socklink->next; } - + if (num_links > 0) { /* average cut point from shared links */ mul_v2_fl(insert_point, 1.0f / num_links); - + reroute_node->locx = insert_point[0] / UI_DPI_FAC; reroute_node->locy = insert_point[1] / UI_DPI_FAC; } - + return socklink; } @@ -208,7 +208,7 @@ static int add_reroute_exec(bContext *C, wmOperator *op) bNodeTree *ntree = snode->edittree; float mcoords[256][2]; int i = 0; - + /* Get the cut path */ RNA_BEGIN (op->ptr, itemptr, "path") { @@ -227,12 +227,12 @@ static int add_reroute_exec(bContext *C, wmOperator *op) bNodeLink *link; bNodeSocketLink *socklink; float insert_point[2]; - + /* always first */ ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + node_deselect_all(snode); - + /* Find cut links and sort them by sockets */ BLI_listbase_clear(&output_links); BLI_listbase_clear(&input_links); @@ -243,12 +243,12 @@ static int add_reroute_exec(bContext *C, wmOperator *op) if (add_reroute_intersect_check(link, mcoords, i, insert_point)) { add_reroute_insert_socket_link(&output_links, link->fromsock, link, insert_point); add_reroute_insert_socket_link(&input_links, link->tosock, link, insert_point); - + /* Clear flag */ link->flag &= ~NODE_LINK_TEST; } } - + /* Create reroute nodes for intersected links. * Only one reroute if links share the same input/output socket. */ @@ -260,18 +260,18 @@ static int add_reroute_exec(bContext *C, wmOperator *op) while (socklink) { socklink = add_reroute_do_socket_section(C, socklink, SOCK_IN); } - + BLI_freelistN(&output_links); BLI_freelistN(&input_links); - + /* always last */ ntreeUpdateTree(CTX_data_main(C), ntree); snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } @@ -330,16 +330,16 @@ static int node_add_file_exec(bContext *C, wmOperator *op) default: return OPERATOR_CANCELLED; } - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + node = node_add_node(C, NULL, type, snode->cursor[0], snode->cursor[1]); - + if (!node) { BKE_report(op->reports, RPT_WARNING, "Could not add an image node"); return OPERATOR_CANCELLED; } - + if (type == SH_NODE_TEXTURE) { Tex *tex = BKE_texture_add(CTX_data_main(C), DATA_(ima->id.name)); tex->ima = ima; @@ -359,7 +359,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } @@ -367,11 +367,11 @@ static int node_add_file_invoke(bContext *C, wmOperator *op, const wmEvent *even { ARegion *ar = CTX_wm_region(C); SpaceNode *snode = CTX_wm_space_node(C); - + /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &snode->cursor[0], &snode->cursor[1]); - + if (RNA_struct_property_is_set(op->ptr, "filepath") || RNA_struct_property_is_set(op->ptr, "name")) return node_add_file_exec(C, op); else @@ -471,7 +471,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) const char *idname; char treename_buf[MAX_ID_NAME - 2]; const char *treename; - + if (RNA_struct_property_is_set(op->ptr, "type")) { prop = RNA_struct_find_property(op->ptr, "type"); RNA_property_enum_identifier(C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &idname); @@ -480,7 +480,7 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) idname = snode->tree_idname; else return OPERATOR_CANCELLED; - + if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", treename_buf); treename = treename_buf; @@ -488,14 +488,14 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) else { treename = DATA_("NodeTree"); } - + if (!ntreeTypeFind(idname)) { BKE_reportf(op->reports, RPT_ERROR, "Node tree type %s undefined", idname); return OPERATOR_CANCELLED; } - + ntree = ntreeAddTree(bmain, treename, idname); - + /* hook into UI */ UI_context_active_but_prop_get_templateID(C, &ptr, &prop); @@ -511,10 +511,10 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) } else if (snode) { snode->nodetree = ntree; - + ED_node_tree_update(C); } - + return OPERATOR_FINISHED; } @@ -526,18 +526,18 @@ static const EnumPropertyItem *new_node_tree_type_itemf(bContext *UNUSED(C), Poi void NODE_OT_new_node_tree(wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "New Node Tree"; ot->idname = "NODE_OT_new_node_tree"; ot->description = "Create a new node tree"; - + /* api callbacks */ ot->exec = new_node_tree_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Tree Type", ""); RNA_def_enum_funcs(prop, new_node_tree_type_itemf); RNA_def_string(ot->srna, "name", "NodeTree", MAX_ID_NAME - 2, "Name", ""); diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index 564176edc7e..0a656ee1deb 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -62,7 +62,7 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - + return (snode && snode->nodetree); } #endif @@ -70,7 +70,7 @@ static int active_nodetree_poll(const bContext *C, PanelType *UNUSED(pt)) static int node_sockets_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - + return (snode && snode->nodetree && G.debug_value == 777); } @@ -82,10 +82,10 @@ static void node_sockets_panel(const bContext *C, Panel *pa) bNodeSocket *sock; uiLayout *layout = pa->layout, *split; char name[UI_MAX_NAME_STR]; - + if (ELEM(NULL, ntree, node)) return; - + for (sock = node->inputs.first; sock; sock = sock->next) { BLI_snprintf(name, sizeof(name), "%s:", sock->name); @@ -98,7 +98,7 @@ static void node_sockets_panel(const bContext *C, Panel *pa) static int node_tree_interface_poll(const bContext *C, PanelType *UNUSED(pt)) { SpaceNode *snode = CTX_wm_space_node(C); - + return (snode && snode->edittree && (snode->edittree->inputs.first || snode->edittree->outputs.first)); } @@ -119,7 +119,7 @@ static bool node_tree_find_active_socket(bNodeTree *ntree, bNodeSocket **r_sock, return true; } } - + *r_sock = NULL; *r_in_out = 0; return false; @@ -137,14 +137,14 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa) if (!ntree) return; - + RNA_id_pointer_create((ID *)ntree, &ptr); - + node_tree_find_active_socket(ntree, &sock, &in_out); RNA_pointer_create((ID *)ntree, &RNA_NodeSocketInterface, sock, &sockptr); - + row = uiLayoutRow(layout, false); - + split = uiLayoutRow(row, true); col = uiLayoutColumn(split, true); ot = WM_operatortype_find("NODE_OT_tree_socket_add", false); @@ -153,26 +153,26 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa) NULL, 0, 0, 0, 0); uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "in_out", SOCK_IN); - + col = uiLayoutColumn(split, true); uiItemL(col, IFACE_("Outputs:"), ICON_NONE); uiTemplateList(col, (bContext *)C, "NODE_UL_interface_sockets", "outputs", &ptr, "outputs", &ptr, "active_output", NULL, 0, 0, 0, 0); uiItemFullO_ptr(col, ot, "", ICON_PLUS, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "in_out", SOCK_OUT); - + ot = WM_operatortype_find("NODE_OT_tree_socket_move", false); col = uiLayoutColumn(row, true); uiItemFullO_ptr(col, ot, "", ICON_TRIA_UP, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "direction", 1); uiItemFullO_ptr(col, ot, "", ICON_TRIA_DOWN, NULL, WM_OP_EXEC_DEFAULT, 0, &opptr); RNA_enum_set(&opptr, "direction", 2); - + if (sock) { row = uiLayoutRow(layout, true); uiItemR(row, &sockptr, "name", 0, NULL, ICON_NONE); uiItemO(row, "", ICON_X, "NODE_OT_tree_socket_remove"); - + if (sock->typeinfo->interface_draw) { uiItemS(layout); sock->typeinfo->interface_draw((bContext *)C, layout, &sockptr); @@ -185,7 +185,7 @@ static void node_tree_interface_panel(const bContext *C, Panel *pa) void node_buttons_register(ARegionType *art) { PanelType *pt; - + pt = MEM_callocN(sizeof(PanelType), "spacetype node panel node sockets"); strcpy(pt->idname, "NODE_PT_sockets"); strcpy(pt->label, N_("Sockets")); @@ -208,7 +208,7 @@ static int node_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = node_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -227,10 +227,10 @@ void NODE_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->description = "Toggle the properties region visibility"; ot->idname = "NODE_OT_properties"; - + ot->exec = node_properties_toggle_exec; ot->poll = node_properties_poll; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 58034f23351..d1374aab02c 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -95,7 +95,7 @@ static bNodeTree *node_tree_from_ID(ID *id) { if (id) { short idtype = GS(id->name); - + switch (idtype) { case ID_NT: return (bNodeTree *)id; @@ -113,7 +113,7 @@ static bNodeTree *node_tree_from_ID(ID *id) return ((FreestyleLineStyle *)id)->nodetree; } } - + return NULL; } @@ -132,7 +132,7 @@ void ED_node_tag_update_id(ID *id) if (ntree->type == NTREE_SHADER) { DAG_id_tag_update(id, 0); - + if (GS(id->name) == ID_MA) WM_main_add_notifier(NC_MATERIAL | ND_SHADING, id); else if (GS(id->name) == ID_LA) @@ -186,7 +186,7 @@ static bool compare_nodes(const bNode *a, const bNode *b) */ bool a_select = (a->flag & NODE_SELECT) != 0, b_select = (b->flag & NODE_SELECT) != 0; bool a_active = (a->flag & NODE_ACTIVE) != 0, b_active = (b->flag & NODE_ACTIVE) != 0; - + /* if one is an ancestor of the other */ /* XXX there might be a better sorting algorithm for stable topological sort, this is O(n^2) worst case */ for (parent = a->parent; parent; parent = parent->parent) { @@ -215,13 +215,13 @@ static bool compare_nodes(const bNode *a, const bNode *b) return 0; else if (!(a->flag & NODE_BACKGROUND) && (b->flag & NODE_BACKGROUND)) return 1; - + /* if one has a higher selection state (active > selected > nothing) */ if (!b_active && a_active) return 1; else if (!b_select && (a_active || a_select)) return 1; - + return 0; } @@ -234,11 +234,11 @@ void ED_node_sort(bNodeTree *ntree) bNode *first_a, *first_b, *node_a, *node_b, *tmp; int totnodes = BLI_listbase_count(&ntree->nodes); int k, a, b; - + k = 1; while (k < totnodes) { first_a = first_b = ntree->nodes.first; - + do { /* setup first_b pointer */ for (b = 0; b < k && first_b; ++b) { @@ -247,7 +247,7 @@ void ED_node_sort(bNodeTree *ntree) /* all batches merged? */ if (first_b == NULL) break; - + /* merge batches */ node_a = first_a; node_b = first_b; @@ -276,7 +276,7 @@ void ED_node_sort(bNodeTree *ntree) } first_a = first_b; } while (first_b); - + k = k << 1; } } @@ -295,9 +295,9 @@ static void node_uiblocks_init(const bContext *C, bNodeTree *ntree) { bNode *node; char uiblockstr[32]; - + /* add node uiBlocks in drawing order - prevents events going to overlapping nodes */ - + for (node = ntree->nodes.first; node; node = node->next) { /* ui block */ BLI_snprintf(uiblockstr, sizeof(uiblockstr), "node buttons %p", (void *)node); @@ -339,52 +339,52 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) float locx, locy; float dy; int buty; - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); dy = locy; - + /* header */ dy -= NODE_DY; - + /* little bit space in top */ if (node->outputs.first) dy -= NODE_DYS / 2; - + /* output sockets */ bool add_output_space = false; for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (nodeSocketIsHidden(nsock)) continue; - + RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); - + layout = UI_block_layout( node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get()); /* context pointers for current node and socket */ uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - + /* align output buttons to the right */ row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_RIGHT); - + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + /* ensure minimum socket height in case layout is empty */ buty = min_ii(buty, dy - NODE_DY); - + nsock->locx = locx + NODE_WIDTH(node); /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); - + dy = buty; if (nsock->next) dy -= NODE_SOCKDY; @@ -402,28 +402,28 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) /* preview rect? */ if (node->flag & NODE_PREVIEW) { float aspect = 1.0f; - - if (node->preview_xsize && node->preview_ysize) + + if (node->preview_xsize && node->preview_ysize) aspect = (float)node->preview_ysize / (float)node->preview_xsize; - + dy -= NODE_DYS / 2; node->prvr.ymax = dy; - + if (aspect <= 1.0f) node->prvr.ymin = dy - aspect * (NODE_WIDTH(node) - NODE_DY); else { /* width correction of image */ /* XXX huh? (ton) */ float dx = (NODE_WIDTH(node) - NODE_DYS) - (NODE_WIDTH(node) - NODE_DYS) / aspect; - + node->prvr.ymin = dy - (NODE_WIDTH(node) - NODE_DY); - + node->prvr.xmin += 0.5f * dx; node->prvr.xmax -= 0.5f * dx; } - + dy = node->prvr.ymin - NODE_DYS / 2; - + /* make sure that maximums are bigger or equal to minimums */ if (node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin); if (node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin); @@ -438,18 +438,18 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->butr.xmax = NODE_WIDTH(node) - 2 * NODE_DYS; node->butr.ymin = 0; node->butr.ymax = 0; - - + + layout = UI_block_layout( node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, locx + NODE_DYS, dy, node->butr.xmax, 0, 0, UI_style_get()); uiLayoutSetContextPointer(layout, "node", &nodeptr); - + node->typeinfo->draw_buttons(layout, (bContext *)C, &nodeptr); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + dy = buty - NODE_DYS / 2; } @@ -457,35 +457,35 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (nodeSocketIsHidden(nsock)) continue; - + RNA_pointer_create(&ntree->id, &RNA_NodeSocket, nsock, &sockptr); - + layout = UI_block_layout( node->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, locx + NODE_DYS, dy, NODE_WIDTH(node) - NODE_DY, NODE_DY, 0, UI_style_get()); /* context pointers for current node and socket */ uiLayoutSetContextPointer(layout, "node", &nodeptr); uiLayoutSetContextPointer(layout, "socket", &sockptr); - + row = uiLayoutRow(layout, 1); - + nsock->typeinfo->draw((bContext *)C, row, &sockptr, &nodeptr, IFACE_(nsock->name)); - + UI_block_align_end(node->block); UI_block_layout_resolve(node->block, NULL, &buty); - + /* ensure minimum socket height in case layout is empty */ buty = min_ii(buty, dy - NODE_DY); - + nsock->locx = locx; /* place the socket circle in the middle of the layout */ nsock->locy = 0.5f * (dy + buty); - + dy = buty; if (nsock->next) dy -= NODE_SOCKDY; } - + /* little bit space in end */ if (node->inputs.first || (node->flag & (NODE_OPTIONS | NODE_PREVIEW)) == 0) dy -= NODE_DYS / 2; @@ -494,7 +494,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->totr.xmax = locx + NODE_WIDTH(node); node->totr.ymax = locy; node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY); - + /* Set the block bounds to clip mouse events from underlying nodes. * Add a margin for sockets on each side. */ @@ -513,7 +513,7 @@ static void node_update_hidden(bNode *node) float locx, locy; float rad, drad, hiddenrad = HIDDEN_RAD; int totin = 0, totout = 0, tot; - + /* get "global" coords */ node_to_view(node, 0.0f, 0.0f, &locx, &locy); @@ -524,20 +524,20 @@ static void node_update_hidden(bNode *node) for (nsock = node->outputs.first; nsock; nsock = nsock->next) if (!nodeSocketIsHidden(nsock)) totout++; - + tot = MAX2(totin, totout); if (tot > 4) { hiddenrad += 5.0f * (float)(tot - 4); } - + node->totr.xmin = locx; node->totr.xmax = locx + 3 * hiddenrad + node->miniwidth; node->totr.ymax = locy + (hiddenrad - 0.5f * NODE_DY); node->totr.ymin = node->totr.ymax - 2 * hiddenrad; - + /* output sockets */ rad = drad = (float)M_PI / (1.0f + (float)totout); - + for (nsock = node->outputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { nsock->locx = node->totr.xmax - hiddenrad + sinf(rad) * hiddenrad; @@ -545,10 +545,10 @@ static void node_update_hidden(bNode *node) rad += drad; } } - + /* input sockets */ rad = drad = -(float)M_PI / (1.0f + (float)totin); - + for (nsock = node->inputs.first; nsock; nsock = nsock->next) { if (!nodeSocketIsHidden(nsock)) { nsock->locx = node->totr.xmin + hiddenrad + sinf(rad) * hiddenrad; @@ -664,7 +664,7 @@ void node_socket_draw(const bContext *C, bNodeTree *ntree, bNode *node, bNodeSoc { PointerRNA ptr, node_ptr; float color[4]; - + RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &ptr); RNA_pointer_create((ID *)ntree, &RNA_Node, node, &node_ptr); sock->typeinfo->draw_color((bContext *)C, &ptr, &node_ptr, color); @@ -729,12 +729,12 @@ void node_socket_draw(const bContext *C, bNodeTree *ntree, bNode *node, bNodeSoc static void node_draw_preview_background(float tile, rctf *rect) { float x, y; - + /* draw checkerboard backdrop to show alpha */ glColor3ub(120, 120, 120); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); glColor3ub(160, 160, 160); - + for (y = rect->ymin; y < rect->ymax; y += tile * 2) { for (x = rect->xmin; x < rect->xmax; x += tile * 2) { float tilex = tile, tiley = tile; @@ -770,7 +770,7 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) float yscale = yrect / ((float)preview->ysize); float scale; rctf draw_rect; - + /* uniform scale and offset */ draw_rect = *prv; if (xscale < yscale) { @@ -785,17 +785,17 @@ static void node_draw_preview(bNodePreview *preview, rctf *prv) draw_rect.xmax -= offset; scale = yscale; } - + node_draw_preview_background(BLI_rctf_size_x(prv) / 10.0f, &draw_rect); - + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* premul graphics */ - + glColor4f(1.0, 1.0, 1.0, 1.0); glPixelZoom(scale, scale); glaDrawPixelsTex(draw_rect.xmin, draw_rect.ymin, preview->xsize, preview->ysize, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, preview->rect); glPixelZoom(1.0f, 1.0f); - + glDisable(GL_BLEND); UI_ThemeColorShadeAlpha(TH_BACK, -15, +100); @@ -807,23 +807,23 @@ static void node_toggle_button_cb(struct bContext *C, void *node_argv, void *op_ { bNode *node = (bNode *)node_argv; const char *opname = (const char *)op_argv; - + /* select & activate only the button's node */ node_select_single(C, node); - + WM_operator_name_call(C, opname, WM_OP_INVOKE_DEFAULT, NULL); } void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) { rctf *rct = &node->totr; - + UI_draw_roundbox_corner_set(UI_CNR_ALL); if (node->parent == NULL) ui_draw_dropshadow(rct, radius, snode->aspect, alpha, node->flag & SELECT); else { const float margin = 3.0f; - + glColor4f(0.0f, 0.0f, 0.0f, 0.33f); glEnable(GL_BLEND); UI_draw_roundbox(rct->xmin - margin, rct->ymin - margin, @@ -843,21 +843,21 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN int color_id = node_get_colorid(node); char showname[128]; /* 128 used below */ View2D *v2d = &ar->v2d; - + /* XXX hack: copy values from linked ID data where displayed as sockets */ if (node->block) nodeSynchronizeID(node, false); - + /* skip if out of view */ if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) { UI_block_end(C, node->block); node->block = NULL; return; } - + /* shadow */ node_draw_shadow(snode, node, BASIS_RAD, 1.0f); - + /* header uses color from backdrop, but we make it opaqie */ if (color_id == TH_NODE) { float col[3]; @@ -866,19 +866,19 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } else UI_ThemeColor(color_id); - + if (node->flag & NODE_MUTED) UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); - + glLineWidth(1.0f); UI_draw_roundbox_corner_set(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); UI_draw_roundbox(rct->xmin, rct->ymax - NODE_DY, rct->xmax, rct->ymax, BASIS_RAD); - + /* show/hide icons */ iconofs = rct->xmax - 0.35f * U.widget_unit; - + /* preview */ if (node->typeinfo->flag & NODE_PREVIEW) { uiBut *but; @@ -905,13 +905,13 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_group_edit"); UI_block_emboss_set(node->block, UI_EMBOSS); } - + /* title */ - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); - + /* open/close entirely? */ { uiBut *but; @@ -923,24 +923,24 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN but_size, but_size, NULL, 0, 0, 0, 0, ""); UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); - + /* custom draw function for this button */ UI_draw_icon_tri(rct->xmin + 0.5f * U.widget_unit, rct->ymax - NODE_DY / 2.0f, 'v'); } - + /* this isn't doing anything for the label, so commenting out */ #if 0 - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); #endif - + nodeLabel(ntree, node, showname, sizeof(showname)); - + //if (node->flag & NODE_MUTED) // BLI_snprintf(showname, sizeof(showname), "[%s]", showname); /* XXX - don't print into self! */ - + uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname, (int)(rct->xmin + (NODE_MARGIN_X)), (int)(rct->ymax - NODE_DY), (short)(iconofs - rct->xmin - 18.0f), (short)NODE_DY, @@ -960,43 +960,43 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN /* outline active and selected emphasis */ if (node->flag & SELECT) { - + glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); - + UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } - + /* disable lines */ if (node->flag & NODE_MUTED) node_draw_mute_line(v2d, snode, node); - + /* socket inputs, buttons */ for (sock = node->inputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; - + node_socket_draw(C, ntree, node, sock, NODE_SOCKSIZE, sock->flag & SELECT); } - + /* socket outputs */ for (sock = node->outputs.first; sock; sock = sock->next) { if (nodeSocketIsHidden(sock)) continue; - + node_socket_draw(C, ntree, node, sock, NODE_SOCKSIZE, sock->flag & SELECT); } - + /* preview */ if (node->flag & NODE_PREVIEW && previews) { bNodePreview *preview = BKE_node_instance_hash_lookup(previews, key); @@ -1006,9 +1006,9 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN } } } - + UI_ThemeClearColor(color_id); - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -1023,7 +1023,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b float socket_size = NODE_SOCKSIZE; int color_id = node_get_colorid(node); char showname[128]; /* 128 is used below */ - + /* shadow */ node_draw_shadow(snode, node, hiddenrad, 1.0f); @@ -1033,18 +1033,18 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f); UI_draw_roundbox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); - + /* outline active and selected emphasis */ if (node->flag & SELECT) { glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - + if (node->flag & NODE_ACTIVE) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40); else UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40); UI_draw_roundbox_gl_mode(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, hiddenrad); - + glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -1062,11 +1062,11 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b } /* title */ - if (node->flag & SELECT) + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.4f, 10); - + /* open entirely icon */ { uiBut *but; @@ -1078,20 +1078,20 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b but_size, but_size, NULL, 0, 0, 0, 0, ""); UI_but_func_set(but, node_toggle_button_cb, node, (void *)"NODE_OT_hide_toggle"); UI_block_emboss_set(node->block, UI_EMBOSS); - + /* custom draw function for this button */ UI_draw_icon_tri(rct->xmin + 10.0f, centy, 'h'); } - + /* disable lines */ if (node->flag & NODE_MUTED) node_draw_mute_line(&ar->v2d, snode, node); - - if (node->flag & SELECT) + + if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); else UI_ThemeColor(TH_TEXT); - + if (node->miniwidth > 0.0f) { nodeLabel(ntree, node, showname, sizeof(showname)); @@ -1109,7 +1109,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b dx = 10.0f; fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); fdrawline(rct->xmax - dx - 3.0f * snode->aspect, centy - 4.0f, rct->xmax - dx - 3.0f * snode->aspect, centy + 4.0f); - + UI_ThemeColorShade(color_id, +30); dx -= snode->aspect; fdrawline(rct->xmax - dx, centy - 4.0f, rct->xmax - dx, centy + 4.0f); @@ -1121,13 +1121,13 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b node_socket_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); } } - + for (sock = node->outputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { node_socket_draw(C, ntree, node, sock, socket_size, sock->flag & SELECT); } } - + UI_block_end(C, node->block); UI_block_draw(C, node->block); node->block = NULL; @@ -1151,7 +1151,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) bNode *node; bNodeSocket *sock; int wmcursor = CURSOR_STD; - + if (ntree) { if (node_find_indicated_socket(snode, &node, &sock, cursor, SOCK_IN | SOCK_OUT)) { /* pass */ @@ -1168,7 +1168,7 @@ void node_set_cursor(wmWindow *win, SpaceNode *snode, float cursor[2]) } } } - + WM_cursor_set(win, wmcursor); } @@ -1189,10 +1189,10 @@ static void node_update(const bContext *C, bNodeTree *ntree, bNode *node) void node_update_nodetree(const bContext *C, bNodeTree *ntree) { bNode *node; - + /* make sure socket "used" tags are correct, for displaying value buttons */ ntreeTagUsedSockets(ntree); - + /* update nodes front to back, so children sizes get updated before parents */ for (node = ntree->nodes.last; node; node = node->prev) { node_update(C, ntree, node); @@ -1212,7 +1212,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT bNode *node; bNodeLink *link; int a; - + if (ntree == NULL) return; /* groups... */ #ifdef USE_DRAW_TOT_UPDATE @@ -1238,7 +1238,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT node->nr = a; /* index of node in list, used for exec event code */ node_draw(C, ar, snode, ntree, node, key); } - + /* node lines */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1248,7 +1248,7 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT } glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); - + /* draw foreground nodes, last nodes in front */ for (a = 0, node = ntree->nodes.first; node; node = node->next, a++) { bNodeInstanceKey key; @@ -1265,9 +1265,9 @@ void node_draw_nodetree(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeT static void draw_tree_path(SpaceNode *snode) { char info[256]; - + ED_node_tree_path_get_fixedbuf(snode, info, sizeof(info)); - + UI_ThemeColor(TH_TEXT_HI); BLF_draw_default(1.5f * UI_UNIT_X, 1.5f * UI_UNIT_Y, 0.0f, info, sizeof(info)); } @@ -1275,11 +1275,11 @@ static void draw_tree_path(SpaceNode *snode) static void snode_setup_v2d(SpaceNode *snode, ARegion *ar, const float center[2]) { View2D *v2d = &ar->v2d; - + /* shift view to node tree center */ UI_view2d_center_set(v2d, center[0], center[1]); UI_view2d_view_ortho(v2d); - + /* aspect+font, set each time */ snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx; // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); @@ -1301,14 +1301,14 @@ static void draw_group_overlay(const bContext *C, ARegion *ar) View2D *v2d = &ar->v2d; rctf rect = v2d->cur; uiBlock *block; - + /* shade node groups to separate them visually */ UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70); glEnable(GL_BLEND); UI_draw_roundbox_corner_set(UI_CNR_NONE); UI_draw_roundbox_gl_mode(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, 0); glDisable(GL_BLEND); - + /* set the block bounds to clip mouse events from underlying nodes */ block = UI_block_begin(C, ar, "node tree bounds block", UI_EMBOSS); UI_block_bounds_set_explicit(block, rect.xmin, rect.ymin, rect.xmax, rect.ymax); @@ -1327,22 +1327,22 @@ void drawnodespace(const bContext *C, ARegion *ar) glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(v2d); - + /* XXX snode->cursor set in coordspace for placing new nodes, used for drawing noodles too */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->cursor[0], &snode->cursor[1]); snode->cursor[0] /= UI_DPI_FAC; snode->cursor[1] /= UI_DPI_FAC; - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* only set once */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_MAP1_VERTEX_3); - + /* nodes */ snode_set_context(C); - + /* draw parent node trees */ if (snode->treepath.last) { static const int max_depth = 2; @@ -1352,56 +1352,56 @@ void drawnodespace(const bContext *C, ARegion *ar) bNodeTree *ntree; bNodeLinkDrag *nldrag; LinkData *linkdata; - + path = snode->treepath.last; - + /* update tree path name (drawn in the bottom left) */ ID *name_id = (path->nodetree && path->nodetree != snode->nodetree) ? &path->nodetree->id : snode->id; if (name_id && UNLIKELY(!STREQ(path->node_name, name_id->name + 2))) { BLI_strncpy(path->node_name, name_id->name + 2, sizeof(path->node_name)); } - + /* current View2D center, will be set temporarily for parent node trees */ UI_view2d_center_get(v2d, ¢er[0], ¢er[1]); - + /* store new view center in path and current edittree */ copy_v2_v2(path->view_center, center); if (snode->edittree) copy_v2_v2(snode->edittree->view_center, center); - + depth = 0; while (path->prev && depth < max_depth) { path = path->prev; ++depth; } - + /* parent node trees in the background */ for (curdepth = depth; curdepth > 0; path = path->next, --curdepth) { ntree = path->nodetree; if (ntree) { snode_setup_v2d(snode, ar, path->view_center); - + draw_nodetree(C, ar, ntree, path->parent_key); - + draw_group_overlay(C, ar); } } - + /* top-level edit tree */ ntree = path->nodetree; if (ntree) { snode_setup_v2d(snode, ar, center); - + /* grid, uses theme color based on node path depth */ UI_view2d_multi_grid_draw(v2d, (depth > 0 ? TH_NODE_GROUP : TH_BACK), ED_node_grid_size(), NODE_GRID_STEPS, 2); - + /* backdrop */ draw_nodespace_back_pix(C, ar, snode, path->parent_key); - + draw_nodetree(C, ar, ntree, path->parent_key); } - + /* temporary links */ glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); @@ -1411,7 +1411,7 @@ void drawnodespace(const bContext *C, ARegion *ar) } glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); - + if (snode->flag & SNODE_SHOW_GPENCIL) { /* draw grease-pencil ('canvas' strokes) */ ED_gpencil_draw_view2d(C, true); @@ -1420,16 +1420,16 @@ void drawnodespace(const bContext *C, ARegion *ar) else { /* default grid */ UI_view2d_multi_grid_draw(v2d, TH_BACK, ED_node_grid_size(), NODE_GRID_STEPS, 2); - + /* backdrop */ draw_nodespace_back_pix(C, ar, snode, NODE_INSTANCE_KEY_NONE); } - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); - + /* reset view matrix */ UI_view2d_view_restore(C); - + if (snode->treepath.last) { if (snode->flag & SNODE_SHOW_GPENCIL) { /* draw grease-pencil (screen strokes, and also paintbuffer) */ @@ -1439,7 +1439,7 @@ void drawnodespace(const bContext *C, ARegion *ar) /* tree path info */ draw_tree_path(snode); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, 10, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index d353ea2cba4..59cfbac2e25 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -151,7 +151,7 @@ static int compo_get_recalc_flags(const bContext *C) static int compo_breakjob(void *cjv) { CompoJob *cj = cjv; - + /* without G.is_break 'ESC' wont quit - which annoys users */ return (*(cj->stop) #ifdef USE_ESC_COMPO @@ -165,7 +165,7 @@ static int compo_breakjob(void *cjv) static void compo_statsdrawjob(void *cjv, const char *UNUSED(str)) { CompoJob *cj = cjv; - + *(cj->do_update) = true; } @@ -173,7 +173,7 @@ static void compo_statsdrawjob(void *cjv, const char *UNUSED(str)) static void compo_redrawjob(void *cjv) { CompoJob *cj = cjv; - + *(cj->do_update) = true; } @@ -208,7 +208,7 @@ static void compo_updatejob(void *UNUSED(cjv)) static void compo_progressjob(void *cjv, float progress) { CompoJob *cj = cjv; - + *(cj->progress) = progress; } @@ -222,7 +222,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog if (scene->use_nodes == false) return; - + cj->stop = stop; cj->do_update = do_update; cj->progress = progress; @@ -388,7 +388,7 @@ void ED_node_shader_default(const bContext *C, ID *id) bNodeTree *ntree; int output_type, shader_type; float color[4] = { 0.0f, 0.0f, 0.0f, 1.0f }, strength = 1.0f; - + ntree = ntreeAddTree(NULL, "Shader Nodetree", ntreeType_Shader->idname); switch (GS(id->name)) { @@ -441,14 +441,14 @@ void ED_node_shader_default(const bContext *C, ID *id) printf("ED_node_shader_default called on wrong ID type.\n"); return; } - + out = nodeAddStaticNode(C, ntree, output_type); out->locx = 300.0f; out->locy = 300.0f; - + in = nodeAddStaticNode(C, ntree, shader_type); in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(ntree, in); - + /* only a link from color to color */ fromsock = in->outputs.first; tosock = out->inputs.first; @@ -459,7 +459,7 @@ void ED_node_shader_default(const bContext *C, ID *id) PointerRNA sockptr; sock = in->inputs.first; RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, sock, &sockptr); - + RNA_float_set_array(&sockptr, "default_value", color); if (strength != 0.0f) { @@ -468,7 +468,7 @@ void ED_node_shader_default(const bContext *C, ID *id) RNA_float_set(&sockptr, "default_value", strength); } } - + ntreeUpdateTree(CTX_data_main(C), ntree); } @@ -478,32 +478,32 @@ void ED_node_composit_default(const bContext *C, struct Scene *sce) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - + /* but lets check it anyway */ if (sce->nodetree) { if (G.debug & G_DEBUG) printf("error in composite initialize\n"); return; } - + sce->nodetree = ntreeAddTree(NULL, "Compositing Nodetree", ntreeType_Composite->idname); - + sce->nodetree->chunksize = 256; sce->nodetree->edit_quality = NTREE_QUALITY_HIGH; sce->nodetree->render_quality = NTREE_QUALITY_HIGH; - + out = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_COMPOSITE); out->locx = 300.0f; out->locy = 400.0f; - + in = nodeAddStaticNode(C, sce->nodetree, CMP_NODE_R_LAYERS); in->locx = 10.0f; in->locy = 400.0f; nodeSetActive(sce->nodetree, in); - + /* links from color to color */ fromsock = in->outputs.first; tosock = out->inputs.first; nodeAddLink(sce->nodetree, in, fromsock, out, tosock); - + ntreeUpdateTree(CTX_data_main(C), sce->nodetree); } @@ -513,27 +513,27 @@ void ED_node_texture_default(const bContext *C, Tex *tx) { bNode *in, *out; bNodeSocket *fromsock, *tosock; - + /* but lets check it anyway */ if (tx->nodetree) { if (G.debug & G_DEBUG) printf("error in texture initialize\n"); return; } - + tx->nodetree = ntreeAddTree(NULL, "Texture Nodetree", ntreeType_Texture->idname); - + out = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_OUTPUT); out->locx = 300.0f; out->locy = 300.0f; - + in = nodeAddStaticNode(C, tx->nodetree, TEX_NODE_CHECKER); in->locx = 10.0f; in->locy = 300.0f; nodeSetActive(tx->nodetree, in); - + fromsock = in->outputs.first; tosock = out->inputs.first; nodeAddLink(tx->nodetree, in, fromsock, out, tosock); - + ntreeUpdateTree(CTX_data_main(C), tx->nodetree); } @@ -544,13 +544,13 @@ void snode_set_context(const bContext *C) bNodeTreeType *treetype = ntreeTypeFind(snode->tree_idname); bNodeTree *ntree = snode->nodetree; ID *id = snode->id, *from = snode->from; - + /* we use this to signal warnings, when node shaders are drawn in wrong render engine */ if (BKE_scene_use_new_shading_nodes(CTX_data_scene(C))) snode->flag |= SNODE_NEW_SHADERS; else snode->flag &= ~SNODE_NEW_SHADERS; - + /* check the tree type */ if (!treetype || (treetype->poll && !treetype->poll(C, treetype))) @@ -561,25 +561,25 @@ void snode_set_context(const bContext *C) */ return; } - + if (snode->nodetree && !STREQ(snode->nodetree->idname, snode->tree_idname)) { /* current tree does not match selected type, clear tree path */ ntree = NULL; id = NULL; from = NULL; } - + if (!(snode->flag & SNODE_PIN) || ntree == NULL) { if (treetype->get_from_context) { /* reset and update from context */ ntree = NULL; id = NULL; from = NULL; - + treetype->get_from_context(C, treetype, &ntree, &id, &from); } } - + if (snode->nodetree != ntree || snode->id != id || snode->from != from || (snode->treepath.last == NULL && ntree)) { @@ -590,12 +590,12 @@ void snode_set_context(const bContext *C) void snode_update(SpaceNode *snode, bNode *node) { bNodeTreePath *path; - + /* XXX this only updates nodes in the current node space tree path. * The function supposedly should update any potential group node linking to changed tree, * this really requires a working depsgraph ... */ - + /* update all edited group nodes */ path = snode->treepath.last; if (path) { @@ -615,38 +615,38 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) const bool was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE) != 0; nodeSetActive(ntree, node); - + if (node->type != NODE_GROUP) { const bool was_output = (node->flag & NODE_DO_OUTPUT) != 0; bool do_update = false; - + /* generic node group output: set node as active output */ if (node->type == NODE_GROUP_OUTPUT) { bNode *tnode; for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == NODE_GROUP_OUTPUT) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (!was_output) do_update = 1; } - + /* tree specific activate calls */ if (ntree->type == NTREE_SHADER) { /* when we select a material, active texture is cleared, for buttons */ if (node->id && ELEM(GS(node->id->name), ID_MA, ID_LA, ID_WO)) nodeClearActiveID(ntree, ID_TE); - + if (ELEM(node->type, SH_NODE_OUTPUT, SH_NODE_OUTPUT_MATERIAL, SH_NODE_OUTPUT_WORLD, SH_NODE_OUTPUT_LAMP, SH_NODE_OUTPUT_LINESTYLE)) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == node->type) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (was_output == 0) ED_node_tag_update_nodetree(bmain, ntree, node); @@ -666,7 +666,7 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) for (wo = bmain->world.first; wo; wo = wo->id.next) if (wo->nodetree && wo->use_nodes && ntreeHasTree(wo->nodetree, ntree)) GPU_material_free(&wo->gpumaterial); - + WM_main_add_notifier(NC_IMAGE, NULL); } @@ -676,16 +676,16 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) /* make active viewer, currently only 1 supported... */ if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; if (was_output == 0) ED_node_tag_update_nodetree(bmain, ntree, node); - + /* addnode() doesnt link this yet... */ node->id = (ID *)BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node"); } @@ -708,11 +708,11 @@ void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) else if (node->type == CMP_NODE_COMPOSITE) { if (was_output == 0) { bNode *tnode; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) if (tnode->type == CMP_NODE_COMPOSITE) tnode->flag &= ~NODE_DO_OUTPUT; - + node->flag |= NODE_DO_OUTPUT; ED_node_tag_update_nodetree(bmain, ntree, node); } @@ -767,13 +767,13 @@ static int edit_node_invoke_properties(bContext *C, wmOperator *op) else RNA_string_set(op->ptr, "node", node->name); } - + if (!RNA_struct_property_is_set(op->ptr, "in_out")) RNA_enum_set(op->ptr, "in_out", SOCK_IN); - + if (!RNA_struct_property_is_set(op->ptr, "socket")) RNA_int_set(op->ptr, "socket", 0); - + return 1; } @@ -784,18 +784,18 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r char nodename[MAX_NAME]; int sockindex; int in_out; - + RNA_string_get(op->ptr, "node", nodename); node = nodeFindNodebyName(ntree, nodename); - + in_out = RNA_enum_get(op->ptr, "in_out"); - + sockindex = RNA_int_get(op->ptr, "socket"); switch (in_out) { case SOCK_IN: sock = BLI_findlink(&node->inputs, sockindex); break; case SOCK_OUT: sock = BLI_findlink(&node->outputs, sockindex); break; } - + if (rnode) *rnode = node; if (rsock) @@ -811,7 +811,7 @@ static void edit_node_properties_get(wmOperator *op, bNodeTree *ntree, bNode **r static bNode *visible_node(SpaceNode *snode, const rctf *rct) { bNode *node; - + for (node = snode->edittree->nodes.last; node; node = node->prev) { if (BLI_rctf_isect(&node->totr, rct, NULL)) break; @@ -833,13 +833,13 @@ typedef struct NodeSizeWidget { static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED(event), bNode *node, int dir) { SpaceNode *snode = CTX_wm_space_node(C); - + NodeSizeWidget *nsw = MEM_callocN(sizeof(NodeSizeWidget), "size widget op data"); - + op->customdata = nsw; nsw->mxstart = snode->cursor[0]; nsw->mystart = snode->cursor[1]; - + /* store old */ nsw->oldlocx = node->locx; nsw->oldlocy = node->locy; @@ -849,7 +849,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED( nsw->oldheight = node->height; nsw->oldminiwidth = node->miniwidth; nsw->directions = dir; - + WM_cursor_modal_set(CTX_wm_window(C), node_get_resize_cursor(dir)); /* add modal handler */ WM_event_add_modal_handler(C, op); @@ -858,7 +858,7 @@ static void node_resize_init(bContext *C, wmOperator *op, const wmEvent *UNUSED( static void node_resize_exit(bContext *C, wmOperator *op, bool UNUSED(cancel)) { WM_cursor_modal_restore(CTX_wm_window(C)); - + MEM_freeN(op->customdata); op->customdata = NULL; } @@ -870,14 +870,14 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) bNode *node = nodeGetActive(snode->edittree); NodeSizeWidget *nsw = op->customdata; float mx, my, dx, dy; - + switch (event->type) { case MOUSEMOVE: - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); dx = (mx - nsw->mxstart) / UI_DPI_FAC; dy = (my - nsw->mystart) / UI_DPI_FAC; - + if (node) { /* width can use node->width or node->miniwidth (hidden nodes) */ float *pwidth; @@ -895,7 +895,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) widthmin = node->typeinfo->minwidth; } widthmax = node->typeinfo->maxwidth; - + { if (nsw->directions & NODE_RESIZE_RIGHT) { *pwidth = oldwidth + dx; @@ -903,20 +903,20 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (nsw->directions & NODE_RESIZE_LEFT) { float locmax = nsw->oldlocx + oldwidth; - + node->locx = nsw->oldlocx + dx; CLAMP(node->locx, locmax - widthmax, locmax - widthmin); *pwidth = locmax - node->locx; } } - + /* height works the other way round ... */ { float heightmin = UI_DPI_FAC * node->typeinfo->minheight; float heightmax = UI_DPI_FAC * node->typeinfo->maxheight; if (nsw->directions & NODE_RESIZE_TOP) { float locmin = nsw->oldlocy - nsw->oldheight; - + node->locy = nsw->oldlocy + dy; CLAMP(node->locy, locmin + heightmin, locmin + heightmax); node->height = node->locy - locmin; @@ -926,7 +926,7 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) CLAMP(node->height, heightmin, heightmax); } } - + /* XXX make callback? */ if (node->type == NODE_FRAME) { /* keep the offset symmetric around center point */ @@ -948,21 +948,21 @@ static int node_resize_modal(bContext *C, wmOperator *op, const wmEvent *event) } } } - + ED_region_tag_redraw(ar); break; - + case LEFTMOUSE: case MIDDLEMOUSE: case RIGHTMOUSE: - + node_resize_exit(C, op, false); ED_node_post_apply_transform(C, snode->edittree); - + return OPERATOR_FINISHED; } - + return OPERATOR_RUNNING_MODAL; } @@ -972,7 +972,7 @@ static int node_resize_invoke(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); bNode *node = nodeGetActive(snode->edittree); int dir; - + if (node) { /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], @@ -997,13 +997,13 @@ void NODE_OT_resize(wmOperatorType *ot) ot->name = "Resize Node"; ot->idname = "NODE_OT_resize"; ot->description = "Resize a node"; - + /* api callbacks */ ot->invoke = node_resize_invoke; ot->modal = node_resize_modal; ot->poll = ED_operator_node_active; ot->cancel = node_resize_cancel; - + /* flags */ ot->flag = OPTYPE_BLOCKING; } @@ -1014,7 +1014,7 @@ void NODE_OT_resize(wmOperatorType *ot) int node_has_hidden_sockets(bNode *node) { bNodeSocket *sock; - + for (sock = node->inputs.first; sock; sock = sock->next) if (sock->flag & SOCK_HIDDEN) return 1; @@ -1055,10 +1055,10 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so bNode *node; bNodeSocket *sock; rctf rect; - + *nodep = NULL; *sockp = NULL; - + /* check if we click in a socket */ for (node = snode->edittree->nodes.first; node; node = node->next) { @@ -1075,7 +1075,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so rect.xmin -= NODE_SOCKSIZE; } } - + if (in_out & SOCK_IN) { for (sock = node->inputs.first; sock; sock = sock->next) { if (!nodeSocketIsHidden(sock)) { @@ -1103,7 +1103,7 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so } } } - + return 0; } @@ -1112,9 +1112,9 @@ int node_find_indicated_socket(SpaceNode *snode, bNode **nodep, bNodeSocket **so static void node_duplicate_reparent_recursive(bNode *node) { bNode *parent; - + node->flag |= NODE_TEST; - + /* find first selected parent */ for (parent = node->parent; parent; parent = parent->parent) { if (parent->flag & SELECT) { @@ -1140,12 +1140,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) bool do_tag_update = false; ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + lastnode = ntree->nodes.last; for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { newnode = nodeCopyNode(ntree, node); - + if (newnode->id) { /* simple id user adjustment, node internal functions don't touch this * but operators and readfile.c do. */ @@ -1154,12 +1154,12 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) ED_node_tag_update_id(snode->id); } } - + /* make sure we don't copy new nodes again! */ if (node == lastnode) break; } - + /* copy links between selected nodes * NB: this depends on correct node->new_node and sock->new_sock pointers from above copy! */ @@ -1184,15 +1184,15 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) newlink->fromnode = link->fromnode; newlink->fromsock = link->fromsock; } - + BLI_addtail(&ntree->links, newlink); } - + /* make sure we don't copy new links again! */ if (link == lastlink) break; } - + /* clear flags for recursive depth-first iteration */ for (node = ntree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; @@ -1200,32 +1200,32 @@ static int node_duplicate_exec(bContext *C, wmOperator *op) for (node = ntree->nodes.first; node; node = node->next) { if ((node->flag & SELECT) && !(node->flag & NODE_TEST)) node_duplicate_reparent_recursive(node); - + /* only has to check old nodes */ if (node == lastnode) break; } - + /* deselect old nodes, select the copies instead */ for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { /* has been set during copy above */ newnode = node->new_node; - + nodeSetSelected(node, false); node->flag &= ~NODE_ACTIVE; nodeSetSelected(newnode, true); do_tag_update |= (do_tag_update || node_connected_to_output(ntree, newnode)); } - + /* make sure we don't copy new nodes again! */ if (node == lastnode) break; } - + ntreeUpdateTree(CTX_data_main(C), snode->edittree); - + snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); @@ -1240,14 +1240,14 @@ void NODE_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Nodes"; ot->description = "Duplicate selected nodes"; ot->idname = "NODE_OT_duplicate"; - + /* api callbacks */ ot->exec = node_duplicate_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "keep_inputs", 0, "Keep Inputs", "Keep the input links to duplicated nodes"); } @@ -1294,7 +1294,7 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + snode_notify(C, snode); snode_dag_update(C, snode); @@ -1303,15 +1303,15 @@ static int node_read_renderlayers_exec(bContext *C, wmOperator *UNUSED(op)) void NODE_OT_read_renderlayers(wmOperatorType *ot) { - + ot->name = "Read Render Layers"; ot->idname = "NODE_OT_read_renderlayers"; ot->description = "Read all render layers of all used scenes"; - + ot->exec = node_read_renderlayers_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1337,15 +1337,15 @@ static int node_read_fullsamplelayers_exec(bContext *C, wmOperator *UNUSED(op)) void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) { - + ot->name = "Read Full Sample Layers"; ot->idname = "NODE_OT_read_fullsamplelayers"; ot->description = "Read all render layers of current scene, in full sample"; - + ot->exec = node_read_fullsamplelayers_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1354,7 +1354,7 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *sce = CTX_data_scene(C); bNode *node; - + for (node = sce->nodetree->nodes.first; node; node = node->next) { if (node->id == (ID *)sce && node->need_exec) { break; @@ -1362,21 +1362,21 @@ int node_render_changed_exec(bContext *C, wmOperator *UNUSED(op)) } if (node) { SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); - + if (srl) { PointerRNA op_ptr; - + WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); RNA_string_set(&op_ptr, "layer", srl->name); RNA_string_set(&op_ptr, "scene", sce->id.name + 2); - + /* to keep keypositions */ sce->r.scemode |= R_NO_FRAME_UPDATE; - + WM_operator_name_call(C, "RENDER_OT_render", WM_OP_INVOKE_DEFAULT, &op_ptr); WM_operator_properties_free(&op_ptr); - + return OPERATOR_FINISHED; } } @@ -1388,11 +1388,11 @@ void NODE_OT_render_changed(wmOperatorType *ot) ot->name = "Render Changed Layer"; ot->idname = "NODE_OT_render_changed"; ot->description = "Render current scene, when input node's layer has been changed"; - + ot->exec = node_render_changed_exec; - + ot->poll = composite_node_active; - + /* flags */ ot->flag = 0; } @@ -1411,12 +1411,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) */ for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; - + if (node->flag & toggle_flag) tot_eq++; else @@ -1425,12 +1425,12 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) } for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { - + if (toggle_flag == NODE_PREVIEW && (node->typeinfo->flag & NODE_PREVIEW) == 0) continue; if (toggle_flag == NODE_OPTIONS && !(node->typeinfo->draw_buttons || node->typeinfo->draw_buttons_ex)) continue; - + if ((tot_eq && tot_neq) || tot_eq == 0) node->flag |= toggle_flag; else @@ -1442,11 +1442,11 @@ static void node_flag_toggle_exec(SpaceNode *snode, int toggle_flag) static int node_hide_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceNode *snode = CTX_wm_space_node(C); - + /* sanity checking (poll callback checks this already) */ if ((snode == NULL) || (snode->edittree == NULL)) return OPERATOR_CANCELLED; - + node_flag_toggle_exec(snode, NODE_HIDDEN); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); @@ -1460,7 +1460,7 @@ void NODE_OT_hide_toggle(wmOperatorType *ot) ot->name = "Hide"; ot->description = "Toggle hiding of selected nodes"; ot->idname = "NODE_OT_hide_toggle"; - + /* callbacks */ ot->exec = node_hide_toggle_exec; ot->poll = ED_operator_node_active; @@ -1553,7 +1553,7 @@ static int node_socket_toggle_exec(bContext *C, wmOperator *UNUSED(op)) } } } - + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { node_set_hidden_sockets(snode, node, !hidden); @@ -1600,12 +1600,12 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) do_tag_update |= (do_tag_update || node_connected_to_output(snode->edittree, node)); } } - + snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + return OPERATOR_FINISHED; } @@ -1615,11 +1615,11 @@ void NODE_OT_mute_toggle(wmOperatorType *ot) ot->name = "Toggle Node Mute"; ot->description = "Toggle muting of the nodes"; ot->idname = "NODE_OT_mute_toggle"; - + /* callbacks */ ot->exec = node_mute_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1644,14 +1644,14 @@ static int node_delete_exec(bContext *C, wmOperator *UNUSED(op)) nodeFreeNode(snode->edittree, node); } } - + ntreeUpdateTree(CTX_data_main(C), snode->edittree); snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + return OPERATOR_FINISHED; } @@ -1661,11 +1661,11 @@ void NODE_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->description = "Delete selected nodes"; ot->idname = "NODE_OT_delete"; - + /* api callbacks */ ot->exec = node_delete_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1730,7 +1730,7 @@ static int node_delete_reconnect_exec(bContext *C, wmOperator *UNUSED(op)) next = node->next; if (node->flag & SELECT) { nodeInternalRelink(snode->edittree, node); - + /* check id user here, nodeFreeNode is called for free dbase too */ if (node->id) id_us_min(node->id); @@ -1818,7 +1818,7 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U PointerRNA ptr = CTX_data_pointer_get(C, "node"); bNodeTree *ntree = NULL; bNode *node = NULL; - + if (ptr.data) { node = ptr.data; ntree = ptr.id.data; @@ -1830,12 +1830,12 @@ static int node_output_file_remove_active_socket_exec(bContext *C, wmOperator *U if (!node || node->type != CMP_NODE_OUTPUT_FILE) return OPERATOR_CANCELLED; - + if (!ntreeCompositOutputFileRemoveActiveSocket(ntree, node)) return OPERATOR_CANCELLED; - + snode_notify(C, snode); - + return OPERATOR_FINISHED; } @@ -1845,11 +1845,11 @@ void NODE_OT_output_file_remove_active_socket(wmOperatorType *ot) ot->name = "Remove File Node Socket"; ot->description = "Remove active input from a file output node"; ot->idname = "NODE_OT_output_file_remove_active_socket"; - + /* callbacks */ ot->exec = node_output_file_remove_active_socket_exec; ot->poll = composite_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1864,7 +1864,7 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) NodeImageMultiFile *nimf; bNodeSocket *sock; int direction; - + if (ptr.data) node = ptr.data; else if (snode && snode->edittree) @@ -1874,13 +1874,13 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; nimf = node->storage; - + sock = BLI_findlink(&node->inputs, nimf->active_input); if (!sock) return OPERATOR_CANCELLED; - + direction = RNA_enum_get(op->ptr, "direction"); - + if (direction == 1) { bNodeSocket *before = sock->prev; if (!before) @@ -1897,9 +1897,9 @@ static int node_output_file_move_active_socket_exec(bContext *C, wmOperator *op) BLI_insertlinkafter(&node->inputs, after, sock); nimf->active_input++; } - + snode_notify(C, snode); - + return OPERATOR_FINISHED; } @@ -1910,19 +1910,19 @@ void NODE_OT_output_file_move_active_socket(wmOperatorType *ot) {2, "DOWN", 0, "Down", ""}, { 0, NULL, 0, NULL, NULL } }; - + /* identifiers */ ot->name = "Move File Node Socket"; ot->description = "Move the active input of a file output node up or down the list"; ot->idname = "NODE_OT_output_file_move_active_socket"; - + /* callbacks */ ot->exec = node_output_file_move_active_socket_exec; ot->poll = composite_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "direction", direction_items, 2, "Direction", ""); } @@ -1933,13 +1933,13 @@ static int node_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNode *node, *tnode; - + if (!ntree) return OPERATOR_CANCELLED; node = nodeGetActive(ntree); if (!node) return OPERATOR_CANCELLED; - + for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) { if (tnode->flag & NODE_SELECT && tnode != node) { if (node->flag & NODE_CUSTOM_COLOR) { @@ -1998,7 +1998,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op)) for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & SELECT) { bNode *new_node = node->new_node; - + /* ensure valid pointers */ if (new_node->parent) { /* parent pointer must be redirected to new node or detached if parent is not copied */ @@ -2117,7 +2117,7 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) /* pasted nodes are selected */ nodeSetSelected(new_node, true); } - + /* reparent copied nodes */ for (node = clipboard_nodes_lb->first; node; node = node->next) { bNode *new_node = node->new_node; @@ -2172,9 +2172,9 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) PointerRNA ntree_ptr; bNodeSocket *sock, *tsock, *active_sock; const char *default_name; - + RNA_id_pointer_create((ID *)ntree, &ntree_ptr); - + if (in_out == SOCK_IN) { active_sock = ntree_get_active_interface_socket(&ntree->inputs); default_name = "Input"; @@ -2183,7 +2183,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) active_sock = ntree_get_active_interface_socket(&ntree->outputs); default_name = "Output"; } - + if (active_sock) { /* insert a copy of the active socket right after it */ sock = ntreeInsertSocketInterface(ntree, in_out, active_sock->idname, active_sock->next, active_sock->name); @@ -2194,7 +2194,7 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) /* XXX TODO define default socket type for a tree! */ sock = ntreeAddSocketInterface(ntree, in_out, "NodeSocketFloat", default_name); } - + /* deactivate sockets (has to check both lists) */ for (tsock = ntree->inputs.first; tsock; tsock = tsock->next) tsock->flag &= ~SELECT; @@ -2202,11 +2202,11 @@ static int ntree_socket_add_exec(bContext *C, wmOperator *op) tsock->flag &= ~SELECT; /* make the new socket active */ sock->flag |= SELECT; - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2216,14 +2216,14 @@ void NODE_OT_tree_socket_add(wmOperatorType *ot) ot->name = "Add Node Tree Interface Socket"; ot->description = "Add an input or output socket to the current node tree"; ot->idname = "NODE_OT_tree_socket_add"; - + /* api callbacks */ ot->exec = ntree_socket_add_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "in_out", rna_enum_node_socket_in_out_items, SOCK_IN, "Socket Type", ""); } @@ -2234,25 +2234,25 @@ static int ntree_socket_remove_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeTree *ntree = snode->edittree; bNodeSocket *iosock, *active_sock; - + iosock = ntree_get_active_interface_socket(&ntree->inputs); if (!iosock) iosock = ntree_get_active_interface_socket(&ntree->outputs); if (!iosock) return OPERATOR_CANCELLED; - + /* preferably next socket becomes active, otherwise try previous socket */ active_sock = (iosock->next ? iosock->next : iosock->prev); ntreeRemoveSocketInterface(ntree, iosock); - + /* set active socket */ if (active_sock) active_sock->flag |= SELECT; - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2262,11 +2262,11 @@ void NODE_OT_tree_socket_remove(wmOperatorType *ot) ot->name = "Remove Node Tree Interface Socket"; ot->description = "Remove an input or output socket to the current node tree"; ot->idname = "NODE_OT_tree_socket_remove"; - + /* api callbacks */ ot->exec = ntree_socket_remove_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2286,7 +2286,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) int direction = RNA_enum_get(op->ptr, "direction"); bNodeSocket *iosock; ListBase *lb; - + lb = &ntree->inputs; iosock = ntree_get_active_interface_socket(lb); if (!iosock) { @@ -2295,7 +2295,7 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) } if (!iosock) return OPERATOR_CANCELLED; - + switch (direction) { case 1: { /* up */ @@ -2318,11 +2318,11 @@ static int ntree_socket_move_exec(bContext *C, wmOperator *op) break; } } - + ntreeUpdateTree(CTX_data_main(C), ntree); WM_event_add_notifier(C, NC_NODE | ND_DISPLAY, NULL); - + return OPERATOR_FINISHED; } @@ -2332,14 +2332,14 @@ void NODE_OT_tree_socket_move(wmOperatorType *ot) ot->name = "Move Node Tree Socket"; ot->description = "Move a socket up or down in the current node tree's sockets stack"; ot->idname = "NODE_OT_tree_socket_move"; - + /* api callbacks */ ot->exec = ntree_socket_move_exec; ot->poll = ED_operator_node_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "direction", move_direction_items, 1, "Direction", ""); } @@ -2386,9 +2386,9 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende { bool found = false; bNode *node; - + ntree->done = true; - + /* update each script that is using this text datablock */ for (node = ntree->nodes.first; node; node = node->next) { if (node->type == NODE_GROUP) { @@ -2401,7 +2401,7 @@ static bool node_shader_script_update_text_recursive(RenderEngine *engine, Rende found = true; } } - + return found; } @@ -2448,7 +2448,7 @@ static int node_shader_script_update_exec(bContext *C, wmOperator *op) if (ntree->type == NTREE_SHADER) ntree->done = false; } FOREACH_NODETREE_END - + FOREACH_NODETREE(bmain, ntree, id) { if (ntree->type == NTREE_SHADER) { if (!ntree->done) diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 7eaf35c6c4f..7da3d0bf93d 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -69,7 +69,7 @@ static int node_group_operator_active(bContext *C) { if (ED_operator_node_active(C)) { SpaceNode *snode = CTX_wm_space_node(C); - + /* Group operators only defined for standard node tree types. * Disabled otherwise to allow pynodes define their own operators * with same keymap. @@ -88,7 +88,7 @@ static int node_group_operator_editable(bContext *C) { if (ED_operator_node_editable(C)) { SpaceNode *snode = CTX_wm_space_node(C); - + /* Group operators only defined for standard node tree types. * Disabled otherwise to allow pynodes define their own operators * with same keymap. @@ -112,14 +112,14 @@ static const char *group_ntree_idname(bContext *C) static const char *group_node_idname(bContext *C) { SpaceNode *snode = CTX_wm_space_node(C); - + if (ED_node_is_shader(snode)) return "ShaderNodeGroup"; else if (ED_node_is_compositor(snode)) return "CompositorNodeGroup"; else if (ED_node_is_texture(snode)) return "TextureNodeGroup"; - + return ""; } @@ -127,7 +127,7 @@ static bNode *node_group_get_active(bContext *C, const char *node_idname) { SpaceNode *snode = CTX_wm_space_node(C); bNode *node = nodeGetActive(snode->edittree); - + if (node && STREQ(node->idname, node_idname)) return node; else @@ -142,22 +142,22 @@ static int node_group_edit_exec(bContext *C, wmOperator *op) const char *node_idname = group_node_idname(C); bNode *gnode; const bool exit = RNA_boolean_get(op->ptr, "exit"); - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + gnode = node_group_get_active(C, node_idname); - + if (gnode && !exit) { bNodeTree *ngroup = (bNodeTree *)gnode->id; - + if (ngroup) ED_node_tree_push(snode, ngroup, gnode); } else ED_node_tree_pop(snode); - + WM_event_add_notifier(C, NC_SCENE | ND_NODES, NULL); - + return OPERATOR_FINISHED; } @@ -167,14 +167,14 @@ void NODE_OT_group_edit(wmOperatorType *ot) ot->name = "Edit Group"; ot->description = "Edit node group"; ot->idname = "NODE_OT_group_edit"; - + /* api callbacks */ ot->exec = node_group_edit_exec; ot->poll = node_group_operator_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "exit", false, "Exit", ""); } @@ -188,24 +188,24 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) bNodeTree *ngroup, *wgroup; ListBase anim_basepaths = {NULL, NULL}; LinkNode *nodes_delayed_free = NULL; - + ngroup = (bNodeTree *)gnode->id; - + /* clear new pointers, set in copytree */ for (node = ntree->nodes.first; node; node = node->next) node->new_node = NULL; - + /* wgroup is a temporary copy of the NodeTree we're merging in * - all of wgroup's nodes are transferred across to their new home * - ngroup (i.e. the source NodeTree) is left unscathed * - temp copy. don't change ID usercount */ wgroup = ntreeCopyTree_ex(ngroup, G.main, false); - + /* Add the nodes into the ntree */ for (node = wgroup->nodes.first; node; node = nextnode) { nextnode = node->next; - + /* Remove interface nodes. * This also removes remaining links to and from interface nodes. */ @@ -213,43 +213,43 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* We must delay removal since sockets will reference this node. see: T52092 */ BLI_linklist_prepend(&nodes_delayed_free, node); } - - /* keep track of this node's RNA "base" path (the part of the path identifying the node) + + /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node */ if (wgroup->adt) { PointerRNA ptr; char *path; - + RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - + if (path) BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); } - + /* migrate node */ BLI_remlink(&wgroup->nodes, node); BLI_addtail(&ntree->nodes, node); - + /* ensure unique node name in the node tree */ nodeUniqueName(ntree, node); - + if (!node->parent) { node->locx += gnode->locx; node->locy += gnode->locy; } - + node->flag |= NODE_SELECT; } - + /* Add internal links to the ntree */ for (link = wgroup->links.first; link; link = linkn) { linkn = link->next; BLI_remlink(&wgroup->links, link); BLI_addtail(&ntree->links, link); } - + /* and copy across the animation, * note that the animation data's action can be NULL here */ if (wgroup->adt) { @@ -258,39 +258,39 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ waction = wgroup->adt->action = BKE_action_copy(G.main, wgroup->adt->action); - + /* now perform the moving */ BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths); - + /* paths + their wrappers need to be freed */ for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; - + MEM_freeN(ld->data); BLI_freelinkN(&anim_basepaths, ld); } - + /* free temp action too */ if (waction) { BKE_libblock_free(G.main, waction); wgroup->adt->action = NULL; } } - + /* free the group tree (takes care of user count) */ BKE_libblock_free(G.main, wgroup); - + /* restore external links to and from the gnode */ /* note: the nodes have been copied to intermediate wgroup first (so need to use new_node), * then transferred to ntree (new_node pointers remain valid). */ - + /* input links */ for (link = ngroup->links.first; link; link = link->next) { if (link->fromnode->type == NODE_GROUP_INPUT) { const char *identifier = link->fromsock->identifier; int num_external_links = 0; - + /* find external links to this input */ for (tlink = ntree->links.first; tlink; tlink = tlink->next) { if (tlink->tonode == gnode && STREQ(tlink->tosock->identifier, identifier)) { @@ -298,24 +298,24 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) ++num_external_links; } } - + /* if group output is not externally linked, * convert the constant input value to ensure somewhat consistent behavior */ if (num_external_links == 0) { /* XXX TODO bNodeSocket *sock = node_group_find_input_socket(gnode, identifier); BLI_assert(sock);*/ - + /* XXX TODO nodeSocketCopy(ntree, link->tosock->new_sock, link->tonode->new_node, ntree, sock, gnode);*/ } } } - + /* output links */ for (link = ntree->links.first; link; link = link->next) { if (link->fromnode == gnode) { const char *identifier = link->fromsock->identifier; int num_internal_links = 0; - + /* find internal links to this output */ for (tlink = ngroup->links.first; tlink; tlink = tlink->next) { /* only use active output node */ @@ -326,18 +326,18 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) } } } - + /* if group output is not internally linked, * convert the constant output value to ensure somewhat consistent behavior */ if (num_internal_links == 0) { /* XXX TODO bNodeSocket *sock = node_group_find_output_socket(gnode, identifier); BLI_assert(sock);*/ - + /* XXX TODO nodeSocketCopy(ntree, link->tosock, link->tonode, ntree, sock, gnode); */ } } } - + while (nodes_delayed_free) { node = BLI_linklist_pop(&nodes_delayed_free); nodeFreeNode(ntree, node); @@ -345,9 +345,9 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* delete the group instance */ nodeFreeNode(ntree, gnode); - + ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; - + return 1; } @@ -363,7 +363,7 @@ static int node_group_ungroup_exec(bContext *C, wmOperator *op) gnode = node_group_get_active(C, node_idname); if (!gnode) return OPERATOR_CANCELLED; - + if (gnode->id && node_group_ungroup(snode->edittree, gnode)) { ntreeUpdateTree(CTX_data_main(C), snode->nodetree); } @@ -384,11 +384,11 @@ void NODE_OT_group_ungroup(wmOperatorType *ot) ot->name = "Ungroup"; ot->description = "Ungroup selected nodes"; ot->idname = "NODE_OT_group_ungroup"; - + /* api callbacks */ ot->exec = node_group_ungroup_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -401,27 +401,27 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo bNodeLink *link, *link_next; bNode *node, *node_next, *newnode; ListBase anim_basepaths = {NULL, NULL}; - + /* deselect all nodes in the target tree */ for (node = ntree->nodes.first; node; node = node->next) nodeSetSelected(node, false); - + /* clear new pointers, set in nodeCopyNode */ for (node = ngroup->nodes.first; node; node = node->next) node->new_node = NULL; - + /* add selected nodes into the ntree */ for (node = ngroup->nodes.first; node; node = node_next) { node_next = node->next; if (!(node->flag & NODE_SELECT)) continue; - + /* ignore interface nodes */ if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) { nodeSetSelected(node, false); continue; } - + if (make_copy) { /* make a copy */ newnode = nodeCopyNode(ngroup, node); @@ -430,44 +430,44 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo /* use the existing node */ newnode = node; } - - /* keep track of this node's RNA "base" path (the part of the path identifying the node) + + /* keep track of this node's RNA "base" path (the part of the path identifying the node) * if the old nodetree has animation data which potentially covers this node */ if (ngroup->adt) { PointerRNA ptr; char *path; - + RNA_pointer_create(&ngroup->id, &RNA_Node, newnode, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - + if (path) BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); } - + /* ensure valid parent pointers, detach if parent stays inside the group */ if (newnode->parent && !(newnode->parent->flag & NODE_SELECT)) nodeDetachNode(newnode); - + /* migrate node */ BLI_remlink(&ngroup->nodes, newnode); BLI_addtail(&ntree->nodes, newnode); - + /* ensure unique node name in the node tree */ nodeUniqueName(ntree, newnode); if (!newnode->parent) { newnode->locx += offx; - newnode->locy += offy; + newnode->locy += offy; } } - + /* add internal links to the ntree */ for (link = ngroup->links.first; link; link = link_next) { const bool fromselect = (link->fromnode && (link->fromnode->flag & NODE_SELECT)); const bool toselect = (link->tonode && (link->tonode->flag & NODE_SELECT)); link_next = link->next; - + if (make_copy) { /* make a copy of internal links */ if (fromselect && toselect) @@ -484,28 +484,28 @@ static int node_group_separate_selected(bNodeTree *ntree, bNodeTree *ngroup, flo } } } - + /* and copy across the animation, * note that the animation data's action can be NULL here */ if (ngroup->adt) { LinkData *ld, *ldn = NULL; - + /* now perform the moving */ BKE_animdata_separate_by_basepath(&ngroup->id, &ntree->id, &anim_basepaths); - + /* paths + their wrappers need to be freed */ for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; - + MEM_freeN(ld->data); BLI_freelinkN(&anim_basepaths, ld); } } - + ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; if (!make_copy) ngroup->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; - + return 1; } @@ -539,7 +539,7 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) } /* get node tree offset */ snode_group_offset(snode, &offx, &offy); - + switch (type) { case NODE_GS_COPY: if (!node_group_separate_selected(nparent, ngroup, offx, offy, 1)) { @@ -554,12 +554,12 @@ static int node_group_separate_exec(bContext *C, wmOperator *op) } break; } - + /* switch to parent tree */ ED_node_tree_pop(snode); - + ntreeUpdateTree(CTX_data_main(C), snode->nodetree); - + snode_notify(C, snode); snode_dag_update(C, snode); @@ -570,13 +570,13 @@ static int node_group_separate_invoke(bContext *C, wmOperator *UNUSED(op), const { uiPopupMenu *pup = UI_popup_menu_begin(C, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Separate"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); - + uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_COPY); uiItemEnumO(layout, "NODE_OT_group_separate", NULL, 0, "type", NODE_GS_MOVE); - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } @@ -586,15 +586,15 @@ void NODE_OT_group_separate(wmOperatorType *ot) ot->name = "Separate"; ot->description = "Separate selected nodes from the node group"; ot->idname = "NODE_OT_group_separate"; - + /* api callbacks */ ot->invoke = node_group_separate_invoke; ot->exec = node_group_separate_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_enum(ot->srna, "type", node_group_separate_types, NODE_GS_COPY, "Type", ""); } @@ -613,10 +613,10 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const bNode *node; bNodeLink *link; int ok = true; - + /* make a local pseudo node tree to pass to the node poll functions */ ngroup = ntreeAddTree(NULL, "Pseudo Node Group", ntree_idname); - + /* check poll functions for selected nodes */ for (node = ntree->nodes.first; node; node = node->next) { if (node_group_make_use_node(node, gnode)) { @@ -629,13 +629,13 @@ static bool node_group_make_test_selected(bNodeTree *ntree, bNode *gnode, const node->done = 0; } - + /* free local pseudo node tree again */ ntreeFreeTree(ngroup); MEM_freeN(ngroup); if (!ok) return false; - + /* check if all connections are OK, no unselected node has both * inputs and outputs to a selection */ for (link = ntree->links.first; link; link = link->next) { @@ -660,7 +660,7 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, bNode *node; float loc[2]; int totselect = 0; - + INIT_MINMAX2(min, max); for (node = ntree->nodes.first; node; node = node->next) { if (node_group_make_use_node(node, gnode)) { @@ -669,12 +669,12 @@ static int node_get_selected_minmax(bNodeTree *ntree, bNode *gnode, float *min, ++totselect; } } - + /* sane min/max if no selected nodes */ if (totselect == 0) { min[0] = min[1] = max[0] = max[1] = 0.0f; } - + return totselect; } @@ -689,89 +689,89 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, int totselect; bool expose_all = false; bNode *input_node, *output_node; - + /* XXX rough guess, not nice but we don't have access to UI constants here ... */ static const float offsetx = 200; static const float offsety = 0.0f; - + /* deselect all nodes in the target tree */ for (node = ngroup->nodes.first; node; node = node->next) nodeSetSelected(node, false); - + totselect = node_get_selected_minmax(ntree, gnode, min, max); add_v2_v2v2(center, min, max); mul_v2_fl(center, 0.5f); - + /* auto-add interface for "solo" nodes */ if (totselect == 1) expose_all = true; - + /* move nodes over */ for (node = ntree->nodes.first; node; node = nextn) { nextn = node->next; if (node_group_make_use_node(node, gnode)) { - /* keep track of this node's RNA "base" path (the part of the pat identifying the node) + /* keep track of this node's RNA "base" path (the part of the pat identifying the node) * if the old nodetree has animation data which potentially covers this node */ if (ntree->adt) { PointerRNA ptr; char *path; - + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); path = RNA_path_from_ID_to_struct(&ptr); - + if (path) BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); } - + /* ensure valid parent pointers, detach if parent stays outside the group */ if (node->parent && !(node->parent->flag & NODE_SELECT)) nodeDetachNode(node); - + /* change node-collection membership */ BLI_remlink(&ntree->nodes, node); BLI_addtail(&ngroup->nodes, node); - + /* ensure unique node name in the ngroup */ nodeUniqueName(ngroup, node); } } - + /* move animation data over */ if (ntree->adt) { LinkData *ld, *ldn = NULL; - + BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); - + /* paths + their wrappers need to be freed */ for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; - + MEM_freeN(ld->data); BLI_freelinkN(&anim_basepaths, ld); } } - + /* node groups don't use internal cached data */ ntreeFreeCache(ngroup); - + /* create input node */ input_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_INPUT); input_node->locx = min[0] - center[0] - offsetx; input_node->locy = -offsety; - + /* create output node */ output_node = nodeAddStaticNode(C, ngroup, NODE_GROUP_OUTPUT); output_node->locx = max[0] - center[0] + offsetx; output_node->locy = -offsety; - + /* relink external sockets */ for (link = ntree->links.first; link; link = linkn) { int fromselect = node_group_make_use_node(link->fromnode, gnode); int toselect = node_group_make_use_node(link->tonode, gnode); - + linkn = link->next; - + if ((fromselect && link->tonode == gnode) || (toselect && link->fromnode == gnode)) { /* remove all links to/from the gnode. * this can remove link information, but there's no general way to preserve it. @@ -785,17 +785,17 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, else if (toselect) { bNodeSocket *iosock = ntreeAddSocketInterfaceFromSocket(ngroup, link->tonode, link->tosock); bNodeSocket *input_sock; - + /* update the group node and interface node sockets, * so the new interface socket can be linked. */ node_group_verify(ntree, gnode, (ID *)ngroup); node_group_input_verify(ngroup, input_node, (ID *)ngroup); - + /* create new internal link */ input_sock = node_group_input_find_socket(input_node, iosock->identifier); nodeAddLink(ngroup, input_node, input_sock, link->tonode, link->tosock); - + /* redirect external link */ link->tonode = gnode; link->tosock = node_group_find_input_socket(gnode, iosock->identifier); @@ -842,7 +842,7 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, node->locy -= center[1]; } } - + /* expose all unlinked sockets too */ if (expose_all) { for (node = ngroup->nodes.first; node; node = node->next) { @@ -858,16 +858,16 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, } if (skip) continue; - + iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - + node_group_input_verify(ngroup, input_node, (ID *)ngroup); - + /* create new internal link */ input_sock = node_group_input_find_socket(input_node, iosock->identifier); nodeAddLink(ngroup, input_node, input_sock, node, sock); } - + for (sock = node->outputs.first; sock; sock = sock->next) { bNodeSocket *iosock, *output_sock; bool skip = false; @@ -876,11 +876,11 @@ static void node_group_make_insert_selected(const bContext *C, bNodeTree *ntree, skip = true; if (skip) continue; - + iosock = ntreeAddSocketInterfaceFromSocket(ngroup, node, sock); - + node_group_output_verify(ngroup, output_node, (ID *)ngroup); - + /* create new internal link */ output_sock = node_group_output_find_socket(output_node, iosock->identifier); nodeAddLink(ngroup, node, sock, output_node, output_sock); @@ -902,22 +902,22 @@ static bNode *node_group_make_from_selected(const bContext *C, bNodeTree *ntree, bNodeTree *ngroup; float min[2], max[2]; int totselect; - + totselect = node_get_selected_minmax(ntree, NULL, min, max); /* don't make empty group */ if (totselect == 0) return NULL; - + /* new nodetree */ ngroup = ntreeAddTree(bmain, "NodeGroup", ntreetype); - + /* make group node */ gnode = nodeAddNode(C, ntree, ntype); gnode->id = (ID *)ngroup; - + gnode->locx = 0.5f * (min[0] + max[0]); gnode->locy = 0.5f * (min[1] + max[1]); - + node_group_make_insert_selected(C, ntree, gnode); /* update of the tree containing the group instance node */ @@ -935,29 +935,29 @@ static int node_group_make_exec(bContext *C, wmOperator *op) bNodeTree *ngroup; bNode *gnode; Main *bmain = CTX_data_main(C); - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + if (!node_group_make_test_selected(ntree, NULL, ntree_idname, op->reports)) return OPERATOR_CANCELLED; - + gnode = node_group_make_from_selected(C, ntree, node_idname, ntree_idname); - + if (gnode) { ngroup = (bNodeTree *)gnode->id; - + nodeSetActive(ntree, gnode); if (ngroup) { ED_node_tree_push(snode, ngroup, gnode); ntreeUpdateTree(bmain, ngroup); } } - + ntreeUpdateTree(bmain, ntree); snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } @@ -967,11 +967,11 @@ void NODE_OT_group_make(wmOperatorType *ot) ot->name = "Make Group"; ot->description = "Make group from selected nodes"; ot->idname = "NODE_OT_group_make"; - + /* api callbacks */ ot->exec = node_group_make_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -986,29 +986,29 @@ static int node_group_insert_exec(bContext *C, wmOperator *op) const char *node_idname = group_node_idname(C); bNode *gnode; Main *bmain = CTX_data_main(C); - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + gnode = node_group_get_active(C, node_idname); - + if (!gnode || !gnode->id) return OPERATOR_CANCELLED; - + ngroup = (bNodeTree *)gnode->id; if (!node_group_make_test_selected(ntree, gnode, ngroup->idname, op->reports)) return OPERATOR_CANCELLED; - + node_group_make_insert_selected(C, ntree, gnode); - + nodeSetActive(ntree, gnode); ED_node_tree_push(snode, ngroup, gnode); ntreeUpdateTree(bmain, ngroup); - + ntreeUpdateTree(bmain, ntree); - + snode_notify(C, snode); snode_dag_update(C, snode); - + return OPERATOR_FINISHED; } @@ -1018,11 +1018,11 @@ void NODE_OT_group_insert(wmOperatorType *ot) ot->name = "Group Insert"; ot->description = "Insert selected nodes into a node group"; ot->idname = "NODE_OT_group_insert"; - + /* api callbacks */ ot->exec = node_group_insert_exec; ot->poll = node_group_operator_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 951257dfd78..f2ed1d1b4ec 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -50,7 +50,7 @@ struct wmKeyConfig; /* temp data to pass on to modal */ typedef struct bNodeLinkDrag { struct bNodeLinkDrag *next, *prev; - + /* List of links dragged by the operator. * Note: This is a list of LinkData structs on top of the actual bNodeLinks. * This way the links can be added to the node tree while being stored in this list. diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index bdbf6c94001..d7ded62a988 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -50,7 +50,7 @@ void node_operatortypes(void) { WM_operatortype_append(NODE_OT_properties); WM_operatortype_append(NODE_OT_toolbar); - + WM_operatortype_append(NODE_OT_select); WM_operatortype_append(NODE_OT_select_all); WM_operatortype_append(NODE_OT_select_linked_to); @@ -60,9 +60,9 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_select_lasso); WM_operatortype_append(NODE_OT_select_grouped); WM_operatortype_append(NODE_OT_select_same_type_step); - + WM_operatortype_append(NODE_OT_find_node); - + WM_operatortype_append(NODE_OT_view_all); WM_operatortype_append(NODE_OT_view_selected); @@ -72,12 +72,12 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_options_toggle); WM_operatortype_append(NODE_OT_hide_socket_toggle); WM_operatortype_append(NODE_OT_node_copy_color); - + WM_operatortype_append(NODE_OT_duplicate); WM_operatortype_append(NODE_OT_delete); WM_operatortype_append(NODE_OT_delete_reconnect); WM_operatortype_append(NODE_OT_resize); - + WM_operatortype_append(NODE_OT_link); WM_operatortype_append(NODE_OT_link_make); WM_operatortype_append(NODE_OT_links_cut); @@ -89,37 +89,37 @@ void node_operatortypes(void) WM_operatortype_append(NODE_OT_group_ungroup); WM_operatortype_append(NODE_OT_group_separate); WM_operatortype_append(NODE_OT_group_edit); - + WM_operatortype_append(NODE_OT_link_viewer); - + WM_operatortype_append(NODE_OT_insert_offset); - + WM_operatortype_append(NODE_OT_read_renderlayers); WM_operatortype_append(NODE_OT_read_fullsamplelayers); WM_operatortype_append(NODE_OT_render_changed); - + WM_operatortype_append(NODE_OT_backimage_move); WM_operatortype_append(NODE_OT_backimage_zoom); WM_operatortype_append(NODE_OT_backimage_fit); WM_operatortype_append(NODE_OT_backimage_sample); - + WM_operatortype_append(NODE_OT_add_file); WM_operatortype_append(NODE_OT_add_mask); - + WM_operatortype_append(NODE_OT_new_node_tree); - + WM_operatortype_append(NODE_OT_output_file_add_socket); WM_operatortype_append(NODE_OT_output_file_remove_active_socket); WM_operatortype_append(NODE_OT_output_file_move_active_socket); - + WM_operatortype_append(NODE_OT_parent_set); WM_operatortype_append(NODE_OT_join); WM_operatortype_append(NODE_OT_attach); WM_operatortype_append(NODE_OT_detach); - + WM_operatortype_append(NODE_OT_clipboard_copy); WM_operatortype_append(NODE_OT_clipboard_paste); - + WM_operatortype_append(NODE_OT_shader_script_update); WM_operatortype_append(NODE_OT_viewer_border); @@ -136,7 +136,7 @@ void ED_operatormacros_node(void) { wmOperatorType *ot; wmOperatorTypeMacro *mot; - + ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", "Select node and link it to a viewer node", OPTYPE_UNDO); @@ -150,7 +150,7 @@ void ED_operatormacros_node(void) RNA_boolean_set(mot->ptr, "release_confirm", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); WM_operatortype_macro_define(ot, "NODE_OT_insert_offset"); - + /* NODE_OT_translate_attach with remove_on_canel set to true */ ot = WM_operatortype_append_macro("NODE_OT_translate_attach_remove_on_cancel", "Move and Attach", "Move nodes and attach to frame", @@ -213,7 +213,7 @@ static void node_select_keymap(wmKeyMap *keymap, int extend) const int *mod = (extend ? mod_extend : mod_single); wmKeyMapItem *kmi; int i; - + for (i = 0; mod[i] >= 0; ++i) { kmi = WM_keymap_add_item(keymap, "NODE_OT_select", ACTIONMOUSE, KM_PRESS, mod[i], 0); RNA_boolean_set(kmi->ptr, "extend", extend); @@ -226,17 +226,17 @@ void node_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + /* Entire Editor only ----------------- */ keymap = WM_keymap_find(keyconf, "Node Generic", SPACE_NODE, 0); - + WM_keymap_add_item(keymap, "NODE_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_toolbar", TKEY, KM_PRESS, 0, 0); - + /* Main Region only ----------------- */ keymap = WM_keymap_find(keyconf, "Node Editor", SPACE_NODE, 0); - - /* mouse select in nodes used to be both keys, but perhaps this should be reduced? + + /* mouse select in nodes used to be both keys, but perhaps this should be reduced? * NOTE: mouse-clicks on left-mouse will fall through to allow transform-tweak, but also link/resize * NOTE 2: socket select is part of the node select operator, to handle overlapping cases * NOTE 3: select op is registered for various combinations of modifier key, so the specialized @@ -244,10 +244,10 @@ void node_keymap(struct wmKeyConfig *keyconf) */ node_select_keymap(keymap, false); node_select_keymap(keymap, true); - + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_border", EVT_TWEAK_S, KM_ANY, 0, 0); RNA_boolean_set(kmi->ptr, "tweak", true); - + kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_ALT, 0); RNA_boolean_set(kmi->ptr, "deselect", false); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_CTRL | KM_SHIFT | KM_ALT, 0); @@ -260,13 +260,13 @@ void node_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "detach", false); kmi = WM_keymap_add_item(keymap, "NODE_OT_link", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "detach", true); - + WM_keymap_add_item(keymap, "NODE_OT_resize", LEFTMOUSE, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "NODE_OT_add_reroute", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_links_cut", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_select_link_viewer", LEFTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_backimage_move", MIDDLEMOUSE, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "NODE_OT_backimage_zoom", VKEY, KM_PRESS, 0, 0); RNA_float_set(kmi->ptr, "factor", 0.83333f); @@ -284,16 +284,16 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); /* modified operator call for duplicating with input links */ WM_keymap_add_item(keymap, "NODE_OT_duplicate_move_keep_inputs", DKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_detach", PKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "NODE_OT_join", JKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_hide_toggle", HKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_mute_toggle", MKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NODE_OT_preview_toggle", HKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_hide_socket_toggle", HKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "NODE_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); #ifdef WITH_INPUT_NDOF WM_keymap_add_item(keymap, "NODE_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0); @@ -323,9 +323,9 @@ void node_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "prev", false); kmi = WM_keymap_add_item(keymap, "NODE_OT_select_same_type_step", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "prev", true); - + WM_keymap_add_item(keymap, "NODE_OT_find_node", FKEY, KM_PRESS, KM_CTRL, 0); - + /* node group operators */ WM_keymap_add_item(keymap, "NODE_OT_group_make", GKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_group_ungroup", GKEY, KM_PRESS, KM_ALT, 0); @@ -338,7 +338,7 @@ void node_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "NODE_OT_read_renderlayers", RKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_read_fullsamplelayers", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NODE_OT_render_changed", ZKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "NODE_OT_clipboard_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "NODE_OT_clipboard_paste", VKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index 70f7553cf41..b0d8b51f8e2 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -556,12 +556,12 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link) bNodeLink *tlink, *tlink_next; int to_count = node_count_links(ntree, to); int from_count = node_count_links(ntree, from); - + for (tlink = ntree->links.first; tlink; tlink = tlink_next) { tlink_next = tlink->next; if (tlink == link) continue; - + if (tlink && tlink->fromsock == from) { if (from_count > from->limit) { nodeRemLink(ntree, tlink); @@ -569,7 +569,7 @@ static void node_remove_extra_links(SpaceNode *snode, bNodeLink *link) --from_count; } } - + if (tlink && tlink->tosock == to) { if (to_count > to->limit) { nodeRemLink(ntree, tlink); @@ -607,15 +607,15 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links) link->fromnode->typeinfo->insert_link(ntree, link->fromnode, link); if (link->tonode->typeinfo->insert_link) link->tonode->typeinfo->insert_link(ntree, link->tonode, link); - + /* add link to the node tree */ BLI_addtail(&ntree->links, link); - + ntree->update |= NTREE_UPDATE_LINKS; - + /* tag tonode for update */ link->tonode->update |= NODE_UPDATE; - + /* we might need to remove a link */ node_remove_extra_links(snode, link); @@ -628,13 +628,13 @@ static void node_link_exit(bContext *C, wmOperator *op, bool apply_links) } } ntree->is_updating = false; - + ntreeUpdateTree(CTX_data_main(C), ntree); snode_notify(C, snode); if (do_tag_update) { snode_dag_update(C, snode); } - + BLI_remlink(&snode->linkdrag, nldrag); /* links->data pointers are either held by the tree or freed already */ BLI_freelistN(&nldrag->links); @@ -653,14 +653,14 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_IN)) { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + /* skip if this is already the target socket */ if (link->tosock == tsock) continue; /* skip if socket is on the same node as the fromsock */ if (tnode && link->fromnode == tnode) continue; - + /* attach links to the socket */ link->tonode = tnode; link->tosock = tsock; @@ -669,7 +669,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) else { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + link->tonode = NULL; link->tosock = NULL; } @@ -679,14 +679,14 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) if (node_find_indicated_socket(snode, &tnode, &tsock, cursor, SOCK_OUT)) { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + /* skip if this is already the target socket */ if (link->fromsock == tsock) continue; /* skip if socket is on the same node as the fromsock */ if (tnode && link->tonode == tnode) continue; - + /* attach links to the socket */ link->fromnode = tnode; link->fromsock = tsock; @@ -695,7 +695,7 @@ static void node_link_find_socket(bContext *C, wmOperator *op, float cursor[2]) else { for (linkdata = nldrag->links.first; linkdata; linkdata = linkdata->next) { bNodeLink *link = linkdata->data; - + link->fromnode = NULL; link->fromsock = NULL; } @@ -710,30 +710,30 @@ static int node_link_modal(bContext *C, wmOperator *op, const wmEvent *event) bNodeLinkDrag *nldrag = op->customdata; ARegion *ar = CTX_wm_region(C); float cursor[2]; - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &cursor[0], &cursor[1]); - + switch (event->type) { case MOUSEMOVE: node_link_find_socket(C, op, cursor); - + node_link_update_header(C, nldrag); ED_region_tag_redraw(ar); break; - + case LEFTMOUSE: case RIGHTMOUSE: case MIDDLEMOUSE: { node_link_exit(C, op, true); - + ED_area_headerprint(CTX_wm_area(C), NULL); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } } - + return OPERATOR_RUNNING_MODAL; } @@ -822,7 +822,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det BLI_addtail(&nldrag->links, linkdata); nodeRemLink(snode->edittree, link); - + /* send changed event to original link->tonode */ if (node) snode_update(snode, node); @@ -846,7 +846,7 @@ static bNodeLinkDrag *node_link_init(SpaceNode *snode, float cursor[2], bool det BLI_addtail(&nldrag->links, linkdata); } } - + return nldrag; } @@ -856,7 +856,7 @@ static int node_link_invoke(bContext *C, wmOperator *op, const wmEvent *event) ARegion *ar = CTX_wm_region(C); bNodeLinkDrag *nldrag; float cursor[2]; - + bool detach = RNA_boolean_get(op->ptr, "detach"); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], @@ -989,9 +989,9 @@ static int cut_links_exec(bContext *C, wmOperator *op) if (i > 1) { bool found = false; bNodeLink *link, *next; - + ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); - + for (link = snode->edittree->links.first; link; link = next) { next = link->next; if (nodeLinkIsHidden(link)) @@ -1294,7 +1294,7 @@ void NODE_OT_attach(wmOperatorType *ot) ot->idname = "NODE_OT_attach"; /* api callbacks */ - + ot->invoke = node_attach_invoke; ot->poll = ED_operator_node_editable; @@ -1413,7 +1413,7 @@ static bool ed_node_link_conditions(ScrArea *sa, bool test, SpaceNode **r_snode, for (link = snode->edittree->links.first; link; link = link->next) { if (nodeLinkIsHidden(link)) continue; - + if (link->tonode == select || link->fromnode == select) return false; } @@ -1847,18 +1847,18 @@ void ED_node_link_insert(ScrArea *sa) if (link) { bNodeSocket *best_input = socket_best_match(&select->inputs); bNodeSocket *best_output = socket_best_match(&select->outputs); - + if (best_input && best_output) { node = link->tonode; sockto = link->tosock; - + link->tonode = select; link->tosock = best_input; node_remove_extra_links(snode, link); link->flag &= ~NODE_LINKFLAG_HILITE; - + nodeAddLink(snode->edittree, select, best_output, node, sockto); - + /* set up insert offset data, it needs stuff from here */ if ((snode->flag & SNODE_SKIP_INSOFFSET) == 0) { NodeInsertOfsData *iofsd = MEM_callocN(sizeof(NodeInsertOfsData), __func__); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index b1656ac89ee..3ae542c48db 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -65,7 +65,7 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my) { bNode *node; - + for (node = ntree->nodes.last; node; node = node->prev) { if (node->typeinfo->select_area_func) { if (node->typeinfo->select_area_func(node, mx, my)) @@ -78,7 +78,7 @@ static bNode *node_under_mouse_select(bNodeTree *ntree, int mx, int my) static bNode *node_under_mouse_tweak(bNodeTree *ntree, int mx, int my) { bNode *node; - + for (node = ntree->nodes.last; node; node = node->prev) { if (node->typeinfo->tweak_area_func) { if (node->typeinfo->tweak_area_func(node, mx, my)) @@ -96,7 +96,7 @@ static void node_toggle(bNode *node) void node_socket_select(bNode *node, bNodeSocket *sock) { sock->flag |= SELECT; - + /* select node too */ if (node) node->flag |= SELECT; @@ -105,10 +105,10 @@ void node_socket_select(bNode *node, bNodeSocket *sock) void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_node) { sock->flag &= ~SELECT; - + if (node && deselect_node) { bool sel = 0; - + /* if no selected sockets remain, also deselect the node */ for (sock = node->inputs.first; sock; sock = sock->next) { if (sock->flag & SELECT) { @@ -122,7 +122,7 @@ void node_socket_deselect(bNode *node, bNodeSocket *sock, const bool deselect_no break; } } - + if (!sel) node->flag &= ~SELECT; } @@ -140,7 +140,7 @@ static void node_socket_toggle(bNode *node, bNodeSocket *sock, int deselect_node void node_deselect_all(SpaceNode *snode) { bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) nodeSetSelected(node, false); } @@ -149,18 +149,18 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes { bNode *node; bNodeSocket *sock; - + /* XXX not calling node_socket_deselect here each time, because this does iteration * over all node sockets internally to check if the node stays selected. * We can do that more efficiently here. */ - + for (node = snode->edittree->nodes.first; node; node = node->next) { int sel = 0; - + for (sock = node->inputs.first; sock; sock = sock->next) sock->flag &= ~SELECT; - + /* if no selected sockets remain, also deselect the node */ if (deselect_nodes) { for (sock = node->outputs.first; sock; sock = sock->next) { @@ -169,7 +169,7 @@ void node_deselect_all_input_sockets(SpaceNode *snode, const bool deselect_nodes break; } } - + if (!sel) node->flag &= ~SELECT; } @@ -180,18 +180,18 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node { bNode *node; bNodeSocket *sock; - + /* XXX not calling node_socket_deselect here each time, because this does iteration * over all node sockets internally to check if the node stays selected. * We can do that more efficiently here. */ - + for (node = snode->edittree->nodes.first; node; node = node->next) { bool sel = false; - + for (sock = node->outputs.first; sock; sock = sock->next) sock->flag &= ~SELECT; - + /* if no selected sockets remain, also deselect the node */ if (deselect_nodes) { for (sock = node->inputs.first; sock; sock = sock->next) { @@ -200,7 +200,7 @@ void node_deselect_all_output_sockets(SpaceNode *snode, const bool deselect_node break; } } - + if (!sel) node->flag &= ~SELECT; } @@ -364,32 +364,32 @@ void node_select_single(bContext *C, bNode *node) Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); bNode *tnode; - + for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) if (tnode != node) nodeSetSelected(tnode, false); nodeSetSelected(node, true); - + ED_node_set_active(bmain, snode->edittree, node); ED_node_set_active_viewer_key(snode); - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); } /* ****** Click Select ****** */ - + static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const int mval[2], short extend) { bNode *node, *tnode; bNodeSocket *sock, *tsock; float cursor[2]; int selected = 0; - + /* get mouse coordinates in view2d space */ UI_view2d_region_to_view(&ar->v2d, mval[0], mval[1], &cursor[0], &cursor[1]); - + if (extend) { /* first do socket selection, these generally overlap with nodes. * socket selection only in extend mode. @@ -417,7 +417,7 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i else { /* find the closest visible node */ node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]); - + if (node) { if ((node->flag & SELECT) && (node->flag & NODE_ACTIVE) == 0) { /* if node is selected but not active make it active @@ -435,10 +435,10 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i } } else { /* extend == 0 */ - + /* find the closest visible node */ node = node_under_mouse_select(snode->edittree, cursor[0], cursor[1]); - + if (node) { for (tnode = snode->edittree->nodes.first; tnode; tnode = tnode->next) { nodeSetSelected(tnode, false); @@ -448,13 +448,13 @@ static int node_mouse_select(Main *bmain, SpaceNode *snode, ARegion *ar, const i selected = 1; } } - + /* update node order */ if (selected) { ED_node_set_active_viewer_key(snode); ED_node_sort(snode->edittree); } - + return selected; } @@ -465,18 +465,18 @@ static int node_select_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); int mval[2]; short extend; - + /* get settings from RNA properties for operator */ mval[0] = RNA_int_get(op->ptr, "mouse_x"); mval[1] = RNA_int_get(op->ptr, "mouse_y"); - + extend = RNA_boolean_get(op->ptr, "extend"); - + /* perform the select */ if (node_mouse_select(bmain, snode, ar, mval, extend)) { /* send notifiers */ WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); - + /* allow tweak event to work too */ return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } @@ -501,15 +501,15 @@ void NODE_OT_select(wmOperatorType *ot) ot->name = "Select"; ot->idname = "NODE_OT_select"; ot->description = "Select the node under the cursor"; - + /* api callbacks */ ot->invoke = node_select_invoke; ot->exec = node_select_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_int(ot->srna, "mouse_x", 0, INT_MIN, INT_MAX, "Mouse X", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "mouse_y", 0, INT_MIN, INT_MAX, "Mouse Y", "", INT_MIN, INT_MAX); @@ -526,10 +526,10 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) rctf rectf; const bool select = !RNA_boolean_get(op->ptr, "deselect"); const bool extend = RNA_boolean_get(op->ptr, "extend"); - + WM_operator_properties_border_to_rctf(op, &rectf); UI_view2d_region_to_view_rctf(&ar->v2d, &rectf, &rectf); - + for (node = snode->edittree->nodes.first; node; node = node->next) { bool is_inside; if (node->type == NODE_FRAME) { @@ -546,9 +546,9 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) nodeSetSelected(node, false); } } - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; @@ -557,7 +557,7 @@ static int node_borderselect_exec(bContext *C, wmOperator *op) static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent *event) { const bool tweak = RNA_boolean_get(op->ptr, "tweak"); - + if (tweak) { /* prevent initiating the border select if the mouse is over a node */ /* this allows border select on empty space, but drag-translate on nodes */ @@ -566,11 +566,11 @@ static int node_border_select_invoke(bContext *C, wmOperator *op, const wmEvent float mx, my; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &mx, &my); - + if (node_under_mouse_tweak(snode->edittree, mx, my)) return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH; } - + return WM_gesture_border_invoke(C, op, event); } @@ -580,18 +580,18 @@ void NODE_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "NODE_OT_select_border"; ot->description = "Use box selection to select nodes"; - + /* api callbacks */ ot->invoke = node_border_select_invoke; ot->exec = node_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); RNA_def_boolean(ot->srna, "tweak", 0, "Tweak", "Only activate when mouse is not over a node - useful for tweak gesture"); @@ -767,7 +767,7 @@ static int node_select_all_exec(bContext *C, wmOperator *op) } ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -778,11 +778,11 @@ void NODE_OT_select_all(wmOperatorType *ot) ot->name = "(De)select All"; ot->description = "(De)select all nodes"; ot->idname = "NODE_OT_select_all"; - + /* api callbacks */ ot->exec = node_select_all_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -796,7 +796,7 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeLink *link; bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; @@ -806,14 +806,14 @@ static int node_select_linked_to_exec(bContext *C, wmOperator *UNUSED(op)) if (link->fromnode && link->tonode && (link->fromnode->flag & NODE_SELECT)) link->tonode->flag |= NODE_TEST; } - + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & NODE_TEST) nodeSetSelected(node, true); } - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -824,11 +824,11 @@ void NODE_OT_select_linked_to(wmOperatorType *ot) ot->name = "Select Linked To"; ot->description = "Select nodes linked to the selected ones"; ot->idname = "NODE_OT_select_linked_to"; - + /* api callbacks */ ot->exec = node_select_linked_to_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -840,7 +840,7 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op)) SpaceNode *snode = CTX_wm_space_node(C); bNodeLink *link; bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) node->flag &= ~NODE_TEST; @@ -850,14 +850,14 @@ static int node_select_linked_from_exec(bContext *C, wmOperator *UNUSED(op)) if (link->fromnode && link->tonode && (link->tonode->flag & NODE_SELECT)) link->fromnode->flag |= NODE_TEST; } - + for (node = snode->edittree->nodes.first; node; node = node->next) { if (node->flag & NODE_TEST) nodeSetSelected(node, true); } - + ED_node_sort(snode->edittree); - + WM_event_add_notifier(C, NC_NODE | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -868,11 +868,11 @@ void NODE_OT_select_linked_from(wmOperatorType *ot) ot->name = "Select Linked From"; ot->description = "Select nodes linked from the selected ones"; ot->idname = "NODE_OT_select_linked_from"; - + /* api callbacks */ ot->exec = node_select_linked_from_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -886,29 +886,29 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) int totnodes; const bool revert = RNA_boolean_get(op->ptr, "prev"); const bool same_type = 1; - + ntreeGetDependencyList(snode->edittree, &node_array, &totnodes); - + if (totnodes > 1) { int a; - + for (a = 0; a < totnodes; a++) { if (node_array[a] == active) break; } - + if (same_type) { bNode *node = NULL; - + while (node == NULL) { if (revert) a--; else a++; - + if (a < 0 || a >= totnodes) break; - + node = node_array[a]; - + if (node->type == active->type) break; else node = NULL; @@ -930,7 +930,7 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) active = node_array[a + 1]; } } - + node_select_single(C, active); /* is note outside view? */ @@ -941,10 +941,10 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op) space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx); } } - + if (node_array) MEM_freeN(node_array); - + return OPERATOR_FINISHED; } @@ -954,14 +954,14 @@ void NODE_OT_select_same_type_step(wmOperatorType *ot) ot->name = "Activate Same Type Next/Prev"; ot->description = "Activate and view same node type, step by step"; ot->idname = "NODE_OT_select_same_type_step"; - + /* api callbacks */ ot->exec = node_select_same_type_step_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "prev", 0, "Previous", ""); } @@ -973,12 +973,12 @@ static void node_find_cb(const struct bContext *C, void *UNUSED(arg), const char { SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - + for (node = snode->edittree->nodes.first; node; node = node->next) { - + if (BLI_strcasestr(node->name, str) || BLI_strcasestr(node->label, str)) { char name[256]; - + if (node->label[0]) BLI_snprintf(name, 256, "%s (%s)", node->name, node->label); else @@ -993,11 +993,11 @@ static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2 { SpaceNode *snode = CTX_wm_space_node(C); bNode *active = arg2; - + if (active) { ARegion *ar = CTX_wm_region(C); node_select_single(C, active); - + /* is note outside view? */ if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax || active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax) @@ -1016,18 +1016,18 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op) uiBlock *block; uiBut *but; wmOperator *op = (wmOperator *)arg_op; - + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); - + but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); UI_but_func_search_set(but, NULL, node_find_cb, op->type, node_find_call_cb, NULL); - + /* fake button, it holds space for search items */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 10 - UI_searchbox_size_y(), UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); - + UI_block_bounds_set_popup(block, 6, 0, -UI_UNIT_Y); /* move it downwards, mouse over button */ - + // UI_but_active_only(C, ar, block, but); XXX using this here makes Blender hang - investigate wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; @@ -1035,7 +1035,7 @@ static uiBlock *node_find_menu(bContext *C, ARegion *ar, void *arg_op) event.customdata = but; event.customdatafree = false; wm_event_add(win, &event); - + return block; } @@ -1053,16 +1053,16 @@ void NODE_OT_find_node(wmOperatorType *ot) ot->name = "Find Node"; ot->description = "Search for named node and allow to select and activate it"; ot->idname = "NODE_OT_find_node"; - + /* api callbacks */ ot->invoke = node_find_node_invoke; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "prev", 0, "Previous", ""); - + } diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index fcfde6f87bf..7788c3938e1 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -64,7 +64,7 @@ typedef struct NodeLinkItem { int socket_type; /* socket type for compatibility check */ const char *socket_name; /* ui label of the socket */ const char *node_name; /* ui label of the node */ - + /* extra settings */ bNodeTree *ngroup; /* group node tree */ } NodeLinkItem; @@ -91,7 +91,7 @@ static void node_link_item_apply(bNode *node, NodeLinkItem *item) else { /* nothing to do for now */ } - + if (node->id) id_us_plus(node->id); } @@ -232,7 +232,7 @@ static void node_socket_add_replace(const bContext *C, bNodeTree *ntree, bNode * node_from->locx = node_to->locx - (node_from->typeinfo->width + 50); node_from->locy = node_to->locy - (node_from->typeinfo->height * index); } - + node_link_item_apply(node_from, item); } @@ -307,19 +307,19 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it /* XXX this should become a callback for node types! */ NodeLinkItem *items = NULL; int totitems = 0; - + if (arg->node_type->type == NODE_GROUP) { bNodeTree *ngroup; int i; - + for (ngroup = arg->bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) { ListBase *lb = ((in_out == SOCK_IN) ? &ngroup->inputs : &ngroup->outputs); totitems += BLI_listbase_count(lb); } - + if (totitems > 0) { items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items"); - + i = 0; for (ngroup = arg->bmain->nodetree.first; ngroup; ngroup = ngroup->id.next) { ListBase *lb = (in_out == SOCK_IN ? &ngroup->inputs : &ngroup->outputs); @@ -327,7 +327,7 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it int index; for (stemp = lb->first, index = 0; stemp; stemp = stemp->next, ++index, ++i) { NodeLinkItem *item = &items[i]; - + item->socket_index = index; /* note: int stemp->type is not fully reliable, not used for node group * interface sockets. use the typeinfo->type instead. @@ -344,17 +344,17 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it bNodeSocketTemplate *socket_templates = (in_out == SOCK_IN ? arg->node_type->inputs : arg->node_type->outputs); bNodeSocketTemplate *stemp; int i; - + for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp) ++totitems; - + if (totitems > 0) { items = MEM_callocN(sizeof(NodeLinkItem) * totitems, "ui node link items"); - + i = 0; for (stemp = socket_templates; stemp && stemp->type != -1; ++stemp, ++i) { NodeLinkItem *item = &items[i]; - + item->socket_index = i; item->socket_type = stemp->type; item->socket_name = stemp->name; @@ -362,7 +362,7 @@ static void ui_node_link_items(NodeLinkArg *arg, int in_out, NodeLinkItem **r_it } } } - + *r_items = items; *r_totitems = totitems; } @@ -446,7 +446,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) NodeLinkArg *argN; int first = 1; int compatibility = 0; - + if (ntree->type == NTREE_SHADER) { if (BKE_scene_use_new_shading_nodes(arg->scene)) compatibility = NODE_NEW_SHADING; @@ -486,29 +486,29 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) const char *cur_node_name = NULL; int i, num = 0; int icon = ICON_NONE; - + arg->node_type = ntype; - + ui_node_link_items(arg, SOCK_OUT, &items, &totitems); - + for (i = 0; i < totitems; ++i) if (ui_compatible_sockets(items[i].socket_type, sock->type)) num++; - + for (i = 0; i < totitems; ++i) { if (!ui_compatible_sockets(items[i].socket_type, sock->type)) continue; - + if (first) { column = uiLayoutColumn(layout, 0); UI_block_layout_set_current(block, column); - + uiItemL(column, IFACE_(cname), ICON_NODE); but = block->buttons.last; - + first = 0; } - + if (num > 1) { if (!cur_node_name || !STREQ(cur_node_name, items[i].node_name)) { cur_node_name = items[i].node_name; @@ -524,15 +524,15 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) BLI_strncpy(name, IFACE_(items[i].node_name), UI_MAX_NAME_STR); icon = ICON_NONE; } - + but = uiDefIconTextBut(block, UI_BTYPE_BUT, 0, icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Add node to input")); - + argN = MEM_dupallocN(arg); argN->item = items[i]; UI_but_funcN_set(but, ui_node_link, argN, NULL); } - + if (items) MEM_freeN(items); } @@ -739,7 +739,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, col = uiLayoutColumn(row, false); uiItemR(col, &inputptr, "default_value", 0, "", ICON_NONE); break; - + default: row = uiLayoutRow(split, false); break; diff --git a/source/blender/editors/space_node/node_toolbar.c b/source/blender/editors/space_node/node_toolbar.c index 2656c519624..21278dd9fa5 100644 --- a/source/blender/editors/space_node/node_toolbar.c +++ b/source/blender/editors/space_node/node_toolbar.c @@ -55,7 +55,7 @@ static int node_toolbar_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = node_has_tools_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -74,10 +74,10 @@ void NODE_OT_toolbar(wmOperatorType *ot) ot->name = "Tool Shelf"; ot->description = "Toggles tool shelf display"; ot->idname = "NODE_OT_toolbar"; - + ot->exec = node_toolbar_toggle_exec; ot->poll = node_toolbar_poll; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c index b85ef02b971..1cf377643a3 100644 --- a/source/blender/editors/space_node/node_view.c +++ b/source/blender/editors/space_node/node_view.c @@ -73,7 +73,7 @@ int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, float oldasp, asp; int tot = 0; bool has_frame = false; - + oldwidth = BLI_rctf_size_x(&ar->v2d.cur); oldheight = BLI_rctf_size_y(&ar->v2d.cur); @@ -154,11 +154,11 @@ void NODE_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "NODE_OT_view_all"; ot->description = "Resize view so you can see all nodes"; - + /* api callbacks */ ot->exec = node_view_all_exec; ot->poll = ED_operator_node_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -394,7 +394,7 @@ typedef struct ImageSampleInfo { unsigned char col[4]; float colf[4]; float linearcol[4]; - + int z; float zf; @@ -545,7 +545,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) info->color_manage = true; } - + if (ibuf->zbuf) { info->z = ibuf->zbuf[y * ibuf->x + x]; info->zp = &info->z; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 2267316d257..c954ebad4c9 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -70,30 +70,30 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) MEM_freeN(path); } BLI_listbase_clear(&snode->treepath); - + if (ntree) { path = MEM_callocN(sizeof(bNodeTreePath), "node tree path"); path->nodetree = ntree; path->parent_key = NODE_INSTANCE_KEY_BASE; - + /* copy initial offset from bNodeTree */ copy_v2_v2(path->view_center, ntree->view_center); - + if (id) BLI_strncpy(path->node_name, id->name + 2, sizeof(path->node_name)); - + BLI_addtail(&snode->treepath, path); - + id_us_ensure_real(&ntree->id); } - + /* update current tree */ snode->nodetree = snode->edittree = ntree; snode->id = id; snode->from = from; - + ED_node_set_active_viewer_key(snode); - + WM_main_add_notifier(NC_SCENE | ND_NODES, NULL); } @@ -107,44 +107,44 @@ void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode) path->parent_key = BKE_node_instance_key(prev_path->parent_key, prev_path->nodetree, gnode); else path->parent_key = NODE_INSTANCE_KEY_BASE; - + BLI_strncpy(path->node_name, gnode->name, sizeof(path->node_name)); } else path->parent_key = NODE_INSTANCE_KEY_BASE; - + /* copy initial offset from bNodeTree */ copy_v2_v2(path->view_center, ntree->view_center); - + BLI_addtail(&snode->treepath, path); - + id_us_ensure_real(&ntree->id); - + /* update current tree */ snode->edittree = ntree; - + ED_node_set_active_viewer_key(snode); - + WM_main_add_notifier(NC_SCENE | ND_NODES, NULL); } void ED_node_tree_pop(SpaceNode *snode) { bNodeTreePath *path = snode->treepath.last; - + /* don't remove root */ if (path == snode->treepath.first) return; - + BLI_remlink(&snode->treepath, path); MEM_freeN(path); - + /* update current tree */ path = snode->treepath.last; snode->edittree = path->nodetree; - + ED_node_set_active_viewer_key(snode); - + /* listener updates the View2D center from edittree */ WM_main_add_notifier(NC_SCENE | ND_NODES, NULL); } @@ -182,7 +182,7 @@ void ED_node_tree_path_get(SpaceNode *snode, char *value) { bNodeTreePath *path; int i; - + value[0] = '\0'; for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) { if (i == 0) { @@ -200,7 +200,7 @@ void ED_node_tree_path_get_fixedbuf(SpaceNode *snode, char *value, int max_lengt { bNodeTreePath *path; int size, i; - + value[0] = '\0'; for (path = snode->treepath.first, i = 0; path; path = path->next, ++i) { if (i == 0) { @@ -227,7 +227,7 @@ void ED_node_set_active_viewer_key(SpaceNode *snode) void snode_group_offset(SpaceNode *snode, float *x, float *y) { bNodeTreePath *path = snode->treepath.last; - + if (path && path->prev) { float dcenter[2]; sub_v2_v2v2(dcenter, path->view_center, path->prev->view_center); @@ -267,24 +267,24 @@ ARegion *node_has_buttons_region(ScrArea *sa) ARegion *node_has_tools_region(ScrArea *sa) { ARegion *ar, *arnew; - + ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS); if (ar) return ar; - + /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); - + /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "node tools"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_TOOLS; arnew->alignment = RGN_ALIGN_LEFT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -399,7 +399,7 @@ static void node_area_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn) /* shift view to node tree center */ if (ar && path) UI_view2d_center_set(&ar->v2d, path->view_center[0], path->view_center[1]); - + ED_area_tag_refresh(sa); break; } @@ -524,7 +524,7 @@ static void node_area_refresh(const struct bContext *C, ScrArea *sa) { /* default now: refresh node is starting preview */ SpaceNode *snode = sa->spacedata.first; - + snode_set_context(C); if (snode->nodetree) { @@ -625,14 +625,14 @@ static void node_cursor(wmWindow *win, ScrArea *sa, ARegion *ar) /* convert mouse coordinates to v2d space */ UI_view2d_region_to_view(&ar->v2d, win->eventstate->x - ar->winrct.xmin, win->eventstate->y - ar->winrct.ymin, &snode->cursor[0], &snode->cursor[1]); - + /* here snode->cursor is used to detect the node edge for sizing */ node_set_cursor(win, snode, snode->cursor); /* XXX snode->cursor is in placing new nodes space */ snode->cursor[0] /= UI_DPI_FAC; snode->cursor[1] /= UI_DPI_FAC; - + } /* Initialize main region, setting handlers. */ @@ -963,7 +963,7 @@ void ED_spacetype_node(void) art->init = node_toolbar_region_init; art->draw = node_toolbar_region_draw; BLI_addhead(&st->regiontypes, art); - + node_toolbar_register(art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 58c2deaf6df..0ea69164034 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -102,7 +102,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) TreeElement *te = lb->first; while (te) { // TreeStoreElem *tselem = TREESTORE(te); - + // XXX fixme... te->xend is not set yet if (!TSELEM_OPEN(tselem, soops)) { if (te->xend > *w) @@ -142,7 +142,7 @@ static void restrictbutton_recursive_ebone(bContext *C, EditBone *ebone_parent, Object *obedit = CTX_data_edit_object(C); bArmature *arm = obedit->data; EditBone *ebone; - + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (ED_armature_ebone_is_child_recursive(ebone_parent, ebone)) { if (set_flag) { @@ -228,12 +228,12 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) { Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; - + if (!common_restrict_check(C, ob)) return; - + /* deselect objects that are invisible */ if (ob->restrictflag & OB_RESTRICT_VIEW) { - /* Ouch! There is no backwards pointer from Object to Base, + /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } @@ -251,12 +251,12 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) { Scene *scene = (Scene *)poin; Object *ob = (Object *)poin2; - + if (!common_restrict_check(C, ob)) return; - + /* if select restriction has just been turned on */ if (ob->restrictflag & OB_RESTRICT_SELECT) { - /* Ouch! There is no backwards pointer from Object to Base, + /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } @@ -290,7 +290,7 @@ static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2) static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) { Object *ob = (Object *)poin2; - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); } @@ -405,7 +405,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) continue; gob->ob->restrictflag &= ~flag; - + if (flag == OB_RESTRICT_VIEW) if (gob->ob->flag & SELECT) ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT); @@ -428,7 +428,7 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) } } } -} +} static void restrictbutton_gr_restrict_view(bContext *C, void *poin, void *poin2) { @@ -450,9 +450,9 @@ static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poi static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void *UNUSED(poin2)) { ID *id = (ID *)poin; - + BLI_assert(id != NULL); - + if (id->flag & LIB_FAKEUSER) { id_us_plus(id); } @@ -470,13 +470,13 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) Object *obedit = CTX_data_edit_object(C); BLI_mempool *ts = soops->treestore; TreeStoreElem *tselem = tsep; - + if (ts && tselem) { TreeElement *te = outliner_find_tree_element(&soops->tree, tselem); - + if (tselem->type == 0) { BLI_libblock_ensure_unique_name(bmain, tselem->id->name); - + switch (GS(tselem->id->name)) { case ID_MA: WM_event_add_notifier(C, NC_MATERIAL, NULL); break; @@ -538,11 +538,11 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) Bone *bone = te->directdata; Object *ob; char newname[sizeof(bone->name)]; - + /* always make current object active */ tree_element_active(C, scene, soops, te, OL_SETSEL_NORMAL, true); ob = OBACT; - + /* restore bone name */ BLI_strncpy(newname, bone->name, sizeof(bone->name)); BLI_strncpy(bone->name, oldname, sizeof(bone->name)); @@ -555,13 +555,13 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) bPoseChannel *pchan = te->directdata; Object *ob; char newname[sizeof(pchan->name)]; - + /* always make current pose-bone active */ tree_element_active(C, scene, soops, te, OL_SETSEL_NORMAL, true); ob = OBACT; BLI_assert(ob->type == OB_ARMATURE); - + /* restore bone name */ BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); @@ -573,7 +573,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) { Object *ob = (Object *)tselem->id; // id = object bActionGroup *grp = te->directdata; - + BLI_uniquename(&ob->pose->agroups, grp, CTX_DATA_(BLT_I18NCONTEXT_ID_ACTION, "Group"), '.', offsetof(bActionGroup, name), sizeof(grp->name)); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); @@ -583,7 +583,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) { bGPdata *gpd = (bGPdata *)tselem->id; // id = GP Datablock bGPDlayer *gpl = te->directdata; - + // XXX: name needs translation stuff BLI_uniquename(&gpd->layers, gpl, "GP Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); @@ -599,7 +599,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) } static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, ListBase *lb) -{ +{ uiBut *bt; TreeElement *te; TreeStoreElem *tselem; @@ -632,23 +632,23 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict viewport visibility (Ctrl - Recursive)")); UI_but_func_set(bt, restrictbutton_view_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_SELECT_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &ptr, object_prop_hide_select, -1, 0, 0, -1, -1, TIP_("Restrict viewport selection (Ctrl - Recursive)")); UI_but_func_set(bt, restrictbutton_sel_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButR_prop(block, UI_BTYPE_ICON_TOGGLE, 0, ICON_RESTRICT_RENDER_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, &ptr, object_prop_hide_render, -1, 0, 0, -1, -1, TIP_("Restrict rendering (Ctrl - Recursive)")); UI_but_func_set(bt, restrictbutton_rend_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + UI_block_emboss_set(block, UI_EMBOSS); - + } if (tselem->type == 0 && te->idcode == ID_GR) { int restrict_bool; @@ -657,7 +657,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar if (ID_IS_LINKED(gr)) but_flag |= UI_BUT_DISABLED; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); @@ -686,28 +686,28 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar /* scene render layers and passes have toggle-able flags too! */ else if (tselem->type == TSE_R_LAYER) { UI_block_emboss_set(block, UI_EMBOSS_NONE); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT - 1, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, te->directdata, 0, 0, 0, 0, TIP_("Render this RenderLayer")); UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + UI_block_emboss_set(block, UI_EMBOSS); } else if (tselem->type == TSE_R_PASS) { int *layflag = te->directdata; int passflag = 1 << tselem->nr; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); - - + + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, passflag, 0, ICON_CHECKBOX_HLT - 1, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, layflag, 0, 0, 0, 0, TIP_("Render this Pass")); UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + layflag++; /* is lay_xor */ if (ELEM(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) @@ -718,13 +718,13 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar UI_but_func_set(bt, restrictbutton_r_lay_cb, tselem->id, NULL); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); } - + UI_block_emboss_set(block, UI_EMBOSS); } else if (tselem->type == TSE_MODIFIER) { ModifierData *md = (ModifierData *)te->directdata; ob = (Object *)tselem->id; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, @@ -732,7 +732,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_modifier_cb, scene, ob); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE_N, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, &(md->mode), 0, 0, 0, 0, TIP_("Restrict/Allow renderability")); @@ -745,7 +745,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar bPoseChannel *pchan = (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; ob = (Object *)tselem->id; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, @@ -753,7 +753,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_bone_visibility_cb, ob->data, bone); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &(bone->flag), 0, 0, 0, 0, @@ -765,7 +765,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar } else if (tselem->type == TSE_EBONE) { EditBone *ebone = (EditBone *)te->directdata; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, @@ -773,7 +773,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_ebone_visibility_cb, NULL, ebone); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitI(block, UI_BTYPE_ICON_TOGGLE, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &(ebone->flag), 0, 0, 0, 0, @@ -785,29 +785,29 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar } else if (tselem->type == TSE_GP_LAYER) { bGPDlayer *gpl = (bGPDlayer *)te->directdata; - + UI_block_emboss_set(block, UI_EMBOSS_NONE); - + bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_HIDE, 0, ICON_RESTRICT_VIEW_OFF, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X, UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0, TIP_("Restrict/Allow visibility in the 3D View")); UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_LOCKED, 0, ICON_UNLOCKED, (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0, TIP_("Restrict/Allow editing of strokes and keyframes in this layer")); UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl); UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK); - + /* TODO: visibility in renders */ - + UI_block_emboss_set(block, UI_EMBOSS); } } - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_restrictbuts(block, scene, ar, soops, &te->subtree); } } @@ -846,16 +846,16 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops &id->flag, 0, 0, 0, 0, tip); UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL); UI_but_flag_enable(bt, but_flag); - - + + BLI_str_format_int_grouped(buf, id->us); - bt = uiDefBut(block, UI_BTYPE_BUT, 1, buf, - (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, + bt = uiDefBut(block, UI_BTYPE_BUT, 1, buf, + (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, TIP_("Number of users of this data-block")); UI_but_flag_enable(bt, but_flag); - - + + bt = uiDefButBitS(block, UI_BTYPE_TOGGLE, LIB_FAKEUSER, 1, (id->flag & LIB_FAKEUSER) ? "F" : " ", (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX), te->ys, UI_UNIT_X, UI_UNIT_Y, &id->flag, 0, 0, 0, 0, @@ -863,11 +863,11 @@ static void outliner_draw_userbuts(uiBlock *block, ARegion *ar, SpaceOops *soops "even if nothing else uses it")); UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL); UI_but_flag_enable(bt, but_flag); - + UI_block_emboss_set(block, UI_EMBOSS); } } - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_userbuts(block, ar, soops, &te->subtree); } } @@ -926,12 +926,12 @@ static void outliner_draw_rnabuts(uiBlock *block, ARegion *ar, SpaceOops *soops, else if (tselem->type == TSE_RNA_ARRAY_ELEM) { ptr = &te->rnaptr; prop = te->directdata; - + uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } } - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_rnabuts(block, ar, soops, sizex, &te->subtree); } @@ -995,7 +995,7 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) uiBut *but = uiDefIconBut(arg->block, UI_BTYPE_LABEL, 0, icon, arg->xb, arg->yb, UI_UNIT_X, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && ID_IS_LINKED(arg->id)) ? arg->id->lib->name : ""); - + if (arg->id) UI_but_drag_set_id(but, arg->id); } @@ -1019,17 +1019,17 @@ static void UNUSED_FUNCTION(tselem_draw_gp_icon_uibut)(struct DrawIconArg *arg, RNA_pointer_create(id, &RNA_GPencilLayer, gpl, &ptr); UI_block_align_begin(arg->block); - + UI_block_emboss_set(arg->block, is_stroke_visible ? UI_EMBOSS : UI_EMBOSS_NONE); uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb, arg->yb, w, h, &ptr, "color", -1, 0, 0, 0, 0, NULL); - + UI_block_emboss_set(arg->block, is_fill_visible ? UI_EMBOSS : UI_EMBOSS_NONE); uiDefButR(arg->block, UI_BTYPE_COLOR, 1, "", arg->xb + w, arg->yb, w, h, &ptr, "fill_color", -1, 0, 0, 0, 0, NULL); - + UI_block_emboss_set(arg->block, UI_EMBOSS_NONE); UI_block_align_end(arg->block); } @@ -1040,7 +1040,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto { struct DrawIconArg arg; float aspect; - + /* make function calls a bit compacter */ arg.block = block; arg.id = tselem->id; @@ -1048,7 +1048,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto arg.xb = x; /* for ui buttons */ arg.yb = y; arg.alpha = alpha; - + /* placement of icons, copied from interface_widgets.c */ aspect = (0.8f * UI_UNIT_Y) / ICON_DEFAULT_HEIGHT; x += 2.0f * aspect; @@ -1086,29 +1086,29 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto Object *ob = (Object *)tselem->id; ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); switch ((ModifierType)md->type) { - case eModifierType_Subsurf: + case eModifierType_Subsurf: UI_icon_draw(x, y, ICON_MOD_SUBSURF); break; - case eModifierType_Armature: + case eModifierType_Armature: UI_icon_draw(x, y, ICON_MOD_ARMATURE); break; - case eModifierType_Lattice: + case eModifierType_Lattice: UI_icon_draw(x, y, ICON_MOD_LATTICE); break; - case eModifierType_Curve: + case eModifierType_Curve: UI_icon_draw(x, y, ICON_MOD_CURVE); break; - case eModifierType_Build: + case eModifierType_Build: UI_icon_draw(x, y, ICON_MOD_BUILD); break; - case eModifierType_Mirror: + case eModifierType_Mirror: UI_icon_draw(x, y, ICON_MOD_MIRROR); break; - case eModifierType_Decimate: + case eModifierType_Decimate: UI_icon_draw(x, y, ICON_MOD_DECIM); break; - case eModifierType_Wave: + case eModifierType_Wave: UI_icon_draw(x, y, ICON_MOD_WAVE); break; - case eModifierType_Hook: + case eModifierType_Hook: UI_icon_draw(x, y, ICON_HOOK); break; - case eModifierType_Softbody: + case eModifierType_Softbody: UI_icon_draw(x, y, ICON_MOD_SOFT); break; - case eModifierType_Boolean: + case eModifierType_Boolean: UI_icon_draw(x, y, ICON_MOD_BOOLEAN); break; - case eModifierType_ParticleSystem: + case eModifierType_ParticleSystem: UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; case eModifierType_ParticleInstance: UI_icon_draw(x, y, ICON_MOD_PARTICLES); break; @@ -1362,13 +1362,13 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa eOLDrawState active; for (te = lb->first; te; te = te->next) { - + /* exit drawing early */ if ((*offsx) - UI_UNIT_X > xmax) break; tselem = TREESTORE(te); - + /* object hierarchy always, further constrained on level */ if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { @@ -1401,32 +1401,32 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa (float)UI_UNIT_Y / 2.0f - ufac); glEnable(GL_BLEND); /* roundbox disables */ } - + tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); te->xs = *offsx; te->ys = ys; te->xend = (short)*offsx + UI_UNIT_X; te->flag |= TE_ICONROW; // for click - + (*offsx) += UI_UNIT_X; } - + /* this tree element always has same amount of branches, so don't draw */ if (tselem->type != TSE_R_LAYER) outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level + 1, xmax, offsx, ys); } - + } /* closed tree element */ static void outliner_set_coord_tree_element(TreeElement *te, int startx, int starty) { TreeElement *ten; - + /* store coord and continue, we need coordinates for elements outside view too */ te->xs = startx; te->ys = starty; - + for (ten = te->subtree.first; ten; ten = ten->next) { outliner_set_coord_tree_element(ten, startx + UI_UNIT_X, starty); } @@ -1442,13 +1442,13 @@ static void outliner_draw_tree_element( float ufac = UI_UNIT_X / 20.0f; int offsx = 0; eOLDrawState active = OL_DRAWSEL_NONE; - + tselem = TREESTORE(te); if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { int xmax = ar->v2d.cur.xmax; unsigned char alpha = 128; - + if ((tselem->flag & TSE_TEXTBUT) && (*te_edit == NULL)) { *te_edit = te; } @@ -1456,12 +1456,12 @@ static void outliner_draw_tree_element( /* icons can be ui buts, we don't want it to overlap with restrict */ if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) xmax -= OL_TOGW + UI_UNIT_X; - + glEnable(GL_BLEND); - /* start by highlighting search matches - * we don't expand items when searching in the datablocks but we - * still want to highlight any filter matches. + /* start by highlighting search matches + * we don't expand items when searching in the datablocks but we + * still want to highlight any filter matches. */ if ((SEARCHING_OUTLINER(soops) || (soops->outlinevis == SO_DATABLOCKS && soops->search_string[0] != 0)) && (tselem->flag & TSE_SEARCHMATCH)) @@ -1475,7 +1475,7 @@ static void outliner_draw_tree_element( /* colors for active/selected data */ if (tselem->type == 0) { - + if (te->idcode == ID_SCE) { if (tselem->id == (ID *)scene) { glColor4ub(255, 255, 255, alpha); @@ -1489,35 +1489,35 @@ static void outliner_draw_tree_element( UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); col[3] = alpha; glColor4ubv((GLubyte *)col); - + active = OL_DRAWSEL_ACTIVE; } } else if (te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; - + if (ob == OBACT || (ob->flag & SELECT)) { char col[4] = {0, 0, 0, 0}; - + /* outliner active ob: always white text, circle color now similar to view3d */ - + active = OL_DRAWSEL_ACTIVE; if (ob == OBACT) { if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); col[3] = alpha; } - + active = OL_DRAWSEL_NORMAL; } else if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); col[3] = alpha; } - + glColor4ubv((GLubyte *)col); } - + } else if (scene->obedit && scene->obedit->data == tselem->id) { glColor4ub(255, 255, 255, alpha); @@ -1536,7 +1536,7 @@ static void outliner_draw_tree_element( } glColor4ub(220, 220, 255, alpha); } - + /* active circle */ if (active != OL_DRAWSEL_NONE) { UI_draw_roundbox_corner_set(UI_CNR_ALL); @@ -1547,15 +1547,15 @@ static void outliner_draw_tree_element( (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 1.0f * ufac); glEnable(GL_BLEND); /* roundbox disables it */ - + te->flag |= TE_ACTIVE; // for lookup in display hierarchies } - + /* open/close icon, only when sublevels, except for scene */ if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { int icon_x; icon_x = startx; - + // icons a bit higher if (TSELEM_OPEN(tselem, soops)) UI_icon_draw((float)icon_x + 2 * ufac, (float)*starty + 1 * ufac, ICON_DISCLOSURE_TRI_DOWN); @@ -1563,18 +1563,18 @@ static void outliner_draw_tree_element( UI_icon_draw((float)icon_x + 2 * ufac, (float)*starty + 1 * ufac, ICON_DISCLOSURE_TRI_RIGHT); } offsx += UI_UNIT_X; - + /* datatype icon */ - + if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { - + tselem_draw_icon(block, xmax, (float)startx + offsx, (float)*starty, tselem, te, 1.0f); - + offsx += UI_UNIT_X + 2 * ufac; } else offsx += 2 * ufac; - + if (tselem->type == 0 && ID_IS_LINKED(tselem->id)) { glPixelTransferf(GL_ALPHA_SCALE, 0.5f); if (tselem->id->tag & LIB_TAG_MISSING) { @@ -1590,7 +1590,7 @@ static void outliner_draw_tree_element( offsx += UI_UNIT_X + 2 * ufac; } glDisable(GL_BLEND); - + /* name */ if ((tselem->flag & TSE_TEXTBUT) == 0) { if (active == OL_DRAWSEL_NORMAL) { @@ -1605,9 +1605,9 @@ static void outliner_draw_tree_element( UI_fontstyle_draw_simple(fstyle, startx + offsx, *starty + 5 * ufac, te->name); } - + offsx += (int)(UI_UNIT_X + UI_fontstyle_string_width(fstyle, te->name)); - + /* closed item, we draw the icons, not when it's a scene, or master-server list though */ if (!TSELEM_OPEN(tselem, soops)) { if (te->subtree.first) { @@ -1618,19 +1618,19 @@ static void outliner_draw_tree_element( /* this tree element always has same amount of branches, so don't draw */ int tempx = startx + offsx; - + /* divider */ UI_ThemeColorShade(TH_BACK, -40); glRecti(tempx - 10.0f * ufac, *starty + 4.0f * ufac, tempx - 8.0f * ufac, *starty + UI_UNIT_Y - 4.0f * ufac); - + glEnable(GL_BLEND); glPixelTransferf(GL_ALPHA_SCALE, 0.5); - + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty); - + glPixelTransferf(GL_ALPHA_SCALE, 1.0); glDisable(GL_BLEND); } @@ -1641,7 +1641,7 @@ static void outliner_draw_tree_element( te->xs = startx; te->ys = *starty; te->xend = startx + offsx; - + if (TSELEM_OPEN(tselem, soops)) { *starty -= UI_UNIT_Y; @@ -1653,7 +1653,7 @@ static void outliner_draw_tree_element( for (ten = te->subtree.first; ten; ten = ten->next) { outliner_set_coord_tree_element(ten, startx, *starty); } - + *starty -= UI_UNIT_Y; } } @@ -1663,30 +1663,30 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, TreeElement *te; TreeStoreElem *tselem; int y1, y2; - + if (BLI_listbase_is_empty(lb)) return; - + y1 = y2 = *starty; /* for vertical lines between objects */ for (te = lb->first; te; te = te->next) { y2 = *starty; tselem = TREESTORE(te); - + /* horizontal line? */ if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) glRecti(startx, *starty, startx + UI_UNIT_X, *starty - 1); - + *starty -= UI_UNIT_Y; - + if (TSELEM_OPEN(tselem, soops)) outliner_draw_hierarchy(soops, &te->subtree, startx + UI_UNIT_X, starty); } - + /* vertical line */ te = lb->last; if (te->parent || lb->first != lb->last) { tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) { - + glRecti(startx, y1 + UI_UNIT_Y, startx + 1, y2); } } @@ -1696,10 +1696,10 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + /* selection status */ if (TSELEM_OPEN(tselem, soops)) if (tselem->type == TSE_RNA_STRUCT) @@ -1718,10 +1718,10 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + /* selection status */ if (tselem->flag & TSE_SELECTED) { glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); @@ -1739,9 +1739,9 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio TreeElement *te; int starty, startx; float col[3]; - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // only once - + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* struct marks */ UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); @@ -1749,19 +1749,19 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); } - + /* always draw selection fill before hierarchy */ UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col); glColor3fv(col); starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); - + // gray hierarchy lines UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; startx = UI_UNIT_X / 2 - 1.0f; outliner_draw_hierarchy(soops, &soops->tree, startx, &starty); - + // items themselves starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; startx = 0; @@ -1774,11 +1774,11 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio static void outliner_back(ARegion *ar) { int ystart; - + UI_ThemeColorShade(TH_BACK, 6); ystart = (int)ar->v2d.tot.ymax; ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { glRecti(0, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y); ystart -= 2 * UI_UNIT_Y; @@ -1788,21 +1788,21 @@ static void outliner_back(ARegion *ar) static void outliner_draw_restrictcols(ARegion *ar) { int ystart; - + /* background underneath */ UI_ThemeColor(TH_BACK); glRecti((int)(ar->v2d.cur.xmax - OL_TOGW), (int)(ar->v2d.cur.ymin - 1), (int)ar->v2d.cur.xmax, (int)ar->v2d.cur.ymax); - + UI_ThemeColorShade(TH_BACK, 6); ystart = (int)ar->v2d.tot.ymax; ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { glRecti((int)ar->v2d.cur.xmax - OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y); ystart -= 2 * UI_UNIT_Y; } - + UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* view */ @@ -1829,7 +1829,7 @@ static void outliner_draw_restrictcols(ARegion *ar) void draw_outliner(const bContext *C) { - Main *mainvar = CTX_data_main(C); + Main *mainvar = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; @@ -1839,7 +1839,7 @@ void draw_outliner(const bContext *C) TreeElement *te_edit = NULL; outliner_build_tree(mainvar, scene, soops); // always - + /* get extents of data */ outliner_height(soops, &soops->tree, &sizey); @@ -1851,11 +1851,11 @@ void draw_outliner(const bContext *C) * * (*) XXX max width for now is a fixed factor of (UI_UNIT_X * (max_indention + 100)) */ - + /* get actual width of column 1 */ outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); - + /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; } @@ -1864,14 +1864,14 @@ void draw_outliner(const bContext *C) //outliner_width(soops, &soops->tree, &sizex); // XXX should use outliner_width instead when te->xend will be set correctly... outliner_rna_width(soops, &soops->tree, &sizex, 0); - + /* constant offset for restriction columns */ // XXX this isn't that great yet... if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) sizex += OL_TOGW * 3; - + } - + /* adds vertical offset */ sizey += OL_Y_OFFSET; @@ -1887,7 +1887,7 @@ void draw_outliner(const bContext *C) outliner_back(ar); block = UI_block_begin(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops, &te_edit); - + if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { /* draw rna buttons */ outliner_draw_rnacols(ar, sizex_rna); @@ -1914,4 +1914,4 @@ void draw_outliner(const bContext *C) /* clear flag that allows quick redraws */ soops->storeflag &= ~SO_TREESTORE_REDRAW; -} +} diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index aed4b874886..7d5ff560b28 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -96,19 +96,19 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { /* check if this tree-element was the one we're seeking */ if (te == teFind) { *found = 1; return; } - + /* try to see if sub-tree contains it then */ outliner_open_reveal(soops, &te->subtree, teFind, found); if (*found) { tselem = TREESTORE(te); - if (tselem->flag & TSE_CLOSED) + if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; return; } @@ -154,10 +154,10 @@ TreeElement *outliner_dropzone_find(const SpaceOops *soops, const float fmval[2] static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, const bool all, const float mval[2]) { - + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { TreeStoreElem *tselem = TREESTORE(te); - + /* all below close/open? */ if (all) { tselem->flag &= ~TSE_CLOSED; @@ -167,16 +167,16 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } - + return 1; } - + for (te = te->subtree.first; te; te = te->next) { - if (do_outliner_item_openclose(C, soops, te, all, mval)) + if (do_outliner_item_openclose(C, soops, te, all, mval)) return 1; } return 0; - + } /* event can enterkey, then it opens/closes */ @@ -187,16 +187,16 @@ static int outliner_item_openclose(bContext *C, wmOperator *op, const wmEvent *e TreeElement *te; float fmval[2]; const bool all = RNA_boolean_get(op->ptr, "all"); - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - + for (te = soops->tree.first; te; te = te->next) { - if (do_outliner_item_openclose(C, soops, te, all, fmval)) + if (do_outliner_item_openclose(C, soops, te, all, fmval)) break; } ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -205,11 +205,11 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) ot->name = "Open/Close Item"; ot->idname = "OUTLINER_OT_item_openclose"; ot->description = "Toggle whether item under cursor is enabled or closed"; - + ot->invoke = outliner_item_openclose; - + ot->poll = ED_operator_outliner_active; - + RNA_def_boolean(ot->srna, "all", 1, "All", "Close or open all items"); } @@ -253,7 +253,7 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement { if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { TreeStoreElem *tselem = TREESTORE(te); - + /* click on name */ if (mval[0] > te->xs + UI_UNIT_X * 2 && mval[0] < te->xend) { do_item_rename(ar, te, tselem, reports); @@ -261,7 +261,7 @@ static int do_outliner_item_rename(ReportList *reports, ARegion *ar, TreeElement } return 0; } - + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_rename(reports, ar, te, mval)) return 1; } @@ -275,16 +275,16 @@ static int outliner_item_rename(bContext *C, wmOperator *op, const wmEvent *even TreeElement *te; float fmval[2]; bool changed = false; - + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_rename(op->reports, ar, te, fmval)) { changed = true; break; } } - + return changed ? OPERATOR_FINISHED : OPERATOR_PASS_THROUGH; } @@ -294,9 +294,9 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) ot->name = "Rename Item"; ot->idname = "OUTLINER_OT_item_rename"; ot->description = "Rename item under cursor"; - + ot->invoke = outliner_item_rename; - + ot->poll = ED_operator_outliner_active; } @@ -718,9 +718,9 @@ static int outliner_count_levels(ListBase *lb, const int curlevel) { TreeElement *te; int level = curlevel, lev; - + for (te = lb->first; te; te = te->next) { - + lev = outliner_count_levels(&te->subtree, curlevel + 1); if (lev > level) level = lev; } @@ -732,11 +732,11 @@ int outliner_has_one_flag(ListBase *lb, short flag, const int curlevel) TreeElement *te; TreeStoreElem *tselem; int level; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & flag) return curlevel; - + level = outliner_has_one_flag(&te->subtree, flag, curlevel + 1); if (level) return level; } @@ -747,7 +747,7 @@ void outliner_set_flag(ListBase *lb, short flag, short set) { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (set == 0) tselem->flag &= ~flag; @@ -776,7 +776,7 @@ int common_restrict_check(bContext *C, Object *ob) ob->restrictflag &= ~OB_RESTRICT_SELECT; return 0; } - + return 1; } @@ -799,7 +799,7 @@ void object_toggle_visibility_cb( /* add check for edit mode */ if (!common_restrict_check(C, ob)) return; - + if (base || (base = BKE_scene_base_find(scene, ob))) { if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); @@ -821,13 +821,13 @@ static int outliner_toggle_visibility_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); - + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_visibility_cb); - + DAG_id_type_tag(bmain, ID_OB); WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -837,11 +837,11 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) ot->name = "Toggle Visibility"; ot->idname = "OUTLINER_OT_visibility_toggle"; ot->description = "Toggle the visibility of selected items"; - + /* callbacks */ ot->exec = outliner_toggle_visibility_exec; ot->poll = ED_operator_outliner_active_no_editobject; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -877,12 +877,12 @@ static int outliner_toggle_selectability_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); - + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_selectability_cb); - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -892,11 +892,11 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) ot->name = "Toggle Selectability"; ot->idname = "OUTLINER_OT_selectability_toggle"; ot->description = "Toggle the selectability"; - + /* callbacks */ ot->exec = outliner_toggle_selectability_exec; ot->poll = ED_operator_outliner_active_no_editobject; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -932,12 +932,12 @@ static int outliner_toggle_renderability_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); - + outliner_do_object_operation(C, op->reports, scene, soops, &soops->tree, object_toggle_renderability_cb); - + DAG_id_type_tag(bmain, ID_OB); WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); - + return OPERATOR_FINISHED; } @@ -947,11 +947,11 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) ot->name = "Toggle Renderability"; ot->idname = "OUTLINER_OT_renderability_toggle"; ot->description = "Toggle the renderability of selected items"; - + /* callbacks */ ot->exec = outliner_toggle_renderability_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -964,14 +964,14 @@ static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) { SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); - + if (outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1)) outliner_set_flag(&soops->tree, TSE_CLOSED, 0); - else + else outliner_set_flag(&soops->tree, TSE_CLOSED, 1); - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -981,11 +981,11 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) ot->name = "Expand/Collapse All"; ot->idname = "OUTLINER_OT_expanded_toggle"; ot->description = "Expand/Collapse all items"; - + /* callbacks */ ot->exec = outliner_toggle_expanded_exec; ot->poll = ED_operator_outliner_active; - + /* no undo or registry, UI option */ } @@ -996,17 +996,17 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); - + if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1)) outliner_set_flag(&soops->tree, TSE_SELECTED, 0); - else + else outliner_set_flag(&soops->tree, TSE_SELECTED, 1); - + soops->storeflag |= SO_TREESTORE_REDRAW; - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1016,11 +1016,11 @@ void OUTLINER_OT_selected_toggle(wmOperatorType *ot) ot->name = "Toggle Selected"; ot->idname = "OUTLINER_OT_selected_toggle"; ot->description = "Toggle the Outliner selection of items"; - + /* callbacks */ ot->exec = outliner_toggle_selected_exec; ot->poll = ED_operator_outliner_active; - + /* no undo or registry, UI option */ } @@ -1079,7 +1079,7 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); ARegion *ar = CTX_wm_region(C); View2D *v2d = &ar->v2d; - + TreeElement *te; int xdelta, ytop; @@ -1118,20 +1118,20 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) /* make te->ys center of view */ ytop = te->ys + BLI_rcti_size_y(&v2d->mask) / 2; if (ytop > 0) ytop = 0; - + v2d->cur.ymax = (float)ytop; v2d->cur.ymin = (float)(ytop - BLI_rcti_size_y(&v2d->mask)); - + /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - v2d->cur.xmin); v2d->cur.xmin += xdelta; v2d->cur.xmax += xdelta; - + so->storeflag |= SO_TREESTORE_REDRAW; } - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1141,7 +1141,7 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) ot->name = "Show Active"; ot->idname = "OUTLINER_OT_show_active"; ot->description = "Open up the tree and adjust the view so that the active Object is shown centered"; - + /* callbacks */ ot->exec = outliner_show_active_exec; ot->poll = ED_operator_outliner_active; @@ -1154,16 +1154,16 @@ static int outliner_scroll_page_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); int dy = BLI_rcti_size_y(&ar->v2d.mask); int up = 0; - + if (RNA_boolean_get(op->ptr, "up")) up = 1; if (up == 0) dy = -dy; ar->v2d.cur.ymin += dy; ar->v2d.cur.ymax += dy; - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1176,11 +1176,11 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot) ot->name = "Scroll Page"; ot->idname = "OUTLINER_OT_scroll_page"; ot->description = "Scroll page up or down"; - + /* callbacks */ ot->exec = outliner_scroll_page_exec; ot->poll = ED_operator_outliner_active; - + /* properties */ prop = RNA_def_boolean(ot->srna, "up", 0, "Up", "Scroll up one page"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -1196,14 +1196,14 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam TreeElement *prev, int *prevFound) { TreeElement *te, *tes; - + for (te = lb->first; te; te = te->next) { int found = outliner_filter_has_name(te, name, flags); - + if (found) { /* name is right, but is element the previous one? */ if (prev) { - if ((te != prev) && (*prevFound)) + if ((te != prev) && (*prevFound)) return te; if (te == prev) { *prevFound = 1; @@ -1212,7 +1212,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam else return te; } - + tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound); if (tes) return tes; } @@ -1221,7 +1221,7 @@ static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *nam return NULL; } -static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) +static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) { ReportList *reports = NULL; // CTX_wm_reports(C); TreeElement *te = NULL; @@ -1229,16 +1229,16 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so TreeStoreElem *tselem; int ytop, xdelta, prevFound = 0; char name[sizeof(soops->search_string)]; - + /* get last found tree-element based on stored search_tse */ last_find = outliner_find_tse(soops, &soops->search_tse); - + /* determine which type of search to do */ if (again && last_find) { /* no popup panel - previous + user wanted to search for next after previous */ BLI_strncpy(name, soops->search_string, sizeof(name)); flags = soops->search_flags; - + /* try to find matching element */ te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); if (te == NULL) { @@ -1263,28 +1263,28 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so /* expand branches so that it will be visible, we need to get correct coordinates */ if (outliner_open_back(soops, te)) outliner_set_coordinates(ar, soops); - + /* deselect all visible, and select found element */ outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; - + /* make te->ys center of view */ ytop = (int)(te->ys + BLI_rctf_size_y(&ar->v2d.mask) / 2); if (ytop > 0) ytop = 0; ar->v2d.cur.ymax = (float)ytop; ar->v2d.cur.ymin = (float)(ytop - BLI_rctf_size_y(&ar->v2d.mask)); - + /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - ar->v2d.cur.xmin); ar->v2d.cur.xmin += xdelta; ar->v2d.cur.xmax += xdelta; - + /* store selection */ soops->search_tse = *tselem; - + BLI_strncpy(soops->search_string, name, sizeof(soops->search_string)); soops->search_flags = flags; - + /* redraw */ soops->storeflag |= SO_TREESTORE_REDRAW; } @@ -1303,17 +1303,17 @@ static void outliner_openclose_level(ListBase *lb, int curlevel, int level, int { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + if (open) { if (curlevel <= level) tselem->flag &= ~TSE_CLOSED; } else { if (curlevel >= level) tselem->flag |= TSE_CLOSED; } - + outliner_openclose_level(&te->subtree, curlevel + 1, level, open); } } @@ -1324,7 +1324,7 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); const bool add = RNA_boolean_get(op->ptr, "open"); int level; - + level = outliner_has_one_flag(&soops->tree, TSE_CLOSED, 1); if (add == 1) { if (level) outliner_openclose_level(&soops->tree, 1, level, 1); @@ -1333,9 +1333,9 @@ static int outliner_one_level_exec(bContext *C, wmOperator *op) if (level == 0) level = outliner_count_levels(&soops->tree, 0); if (level) outliner_openclose_level(&soops->tree, 1, level - 1, 0); } - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1347,13 +1347,13 @@ void OUTLINER_OT_show_one_level(wmOperatorType *ot) ot->name = "Show/Hide One Level"; ot->idname = "OUTLINER_OT_show_one_level"; ot->description = "Expand/collapse all entries by one level"; - + /* callbacks */ ot->exec = outliner_one_level_exec; ot->poll = ED_operator_outliner_active; - + /* no undo or registry, UI option */ - + /* properties */ prop = RNA_def_boolean(ot->srna, "open", 1, "Open", "Expand all entries one level deep"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); @@ -1366,7 +1366,7 @@ static int subtree_has_objects(ListBase *lb) { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == ID_OB) return 1; @@ -1384,7 +1384,7 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase /* open all object elems, close others */ for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); - + if (tselem->type == 0) { if (te->idcode == ID_SCE) { if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED; @@ -1411,12 +1411,12 @@ static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) SpaceOops *soops = CTX_wm_space_outliner(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); - + /* recursively open/close levels */ tree_element_show_hierarchy(scene, soops, &soops->tree); - + ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -1426,11 +1426,11 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) ot->name = "Show Hierarchy"; ot->idname = "OUTLINER_OT_show_hierarchy"; ot->description = "Open all object entries and close all others"; - + /* callbacks */ ot->exec = outliner_show_hierarchy_exec; ot->poll = ED_operator_outliner_active; // TODO: shouldn't be allowed in RNA views... - + /* no undo or registry, UI option */ } @@ -1450,7 +1450,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C) } -/* Helper func to extract an RNA path from selected tree element +/* Helper func to extract an RNA path from selected tree element * NOTE: the caller must zero-out all values of the pointers that it passes here first, as * this function does not do that yet */ @@ -1464,29 +1464,29 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, PointerRNA *ptr, *nextptr; PropertyRNA *prop; char *newpath = NULL; - + /* optimize tricks: * - Don't do anything if the selected item is a 'struct', but arrays are allowed */ if (tselem->type == TSE_RNA_STRUCT) return; - + /* Overview of Algorithm: * 1. Go up the chain of parents until we find the 'root', taking note of the * levels encountered in reverse-order (i.e. items are added to the start of the list * for more convenient looping later) * 2. Walk down the chain, adding from the first ID encountered - * (which will become the 'ID' for the KeyingSet Path), and build a + * (which will become the 'ID' for the KeyingSet Path), and build a * path as we step through the chain */ - + /* step 1: flatten out hierarchy of parents into a flat chain */ for (tem = te->parent; tem; tem = tem->parent) { ld = MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); ld->data = tem; BLI_addhead(&hierarchy, ld); } - + /* step 2: step down hierarchy building the path * (NOTE: addhead in previous loop was needed so that we can loop like this) */ for (ld = hierarchy.first; ld; ld = ld->next) { @@ -1495,10 +1495,10 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, tse = TREESTORE(tem); ptr = &tem->rnaptr; prop = tem->directdata; - + /* check if we're looking for first ID, or appending to path */ if (*id) { - /* just 'append' property to path + /* just 'append' property to path * - to prevent memory leaks, we must write to newpath not path, then free old path + swap them */ if (tse->type == TSE_RNA_PROPERTY) { @@ -1508,35 +1508,35 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, } else if (RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - + temnext = (TreeElement *)(ld->next->data); /* tsenext = TREESTORE(temnext); */ /* UNUSED */ - + nextptr = &temnext->rnaptr; name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); - + if (name) { /* if possible, use name as a key in the path */ newpath = RNA_path_append(*path, NULL, prop, 0, name); - + if (name != buf) MEM_freeN(name); } else { /* otherwise use index */ int index = 0; - + for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) if (temsub == temnext) break; - + newpath = RNA_path_append(*path, NULL, prop, index, NULL); } - + ld = ld->next; } } - + if (newpath) { if (*path) MEM_freeN(*path); *path = newpath; @@ -1550,7 +1550,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, * since ptr->data is sometimes the owner of this ID? */ if (RNA_struct_is_ID(ptr->type)) { *id = (ID *)ptr->data; - + /* clear path */ if (*path) { MEM_freeN(*path); @@ -1566,7 +1566,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* add the active property to the path */ ptr = &te->rnaptr; prop = te->directdata; - + /* array checks */ if (tselem->type == TSE_RNA_ARRAY_ELEM) { /* item is part of an array, so must set the array_index */ @@ -1576,7 +1576,7 @@ static void tree_element_to_path(TreeElement *te, TreeStoreElem *tselem, /* entire array was selected, so keyframe all */ *flag |= KSP_FLAG_WHOLE_ARRAY; } - + /* path */ newpath = RNA_path_append(*path, NULL, prop, 0, NULL); if (*path) MEM_freeN(*path); @@ -1598,17 +1598,17 @@ enum { DRIVERS_EDITMODE_REMOVE, } /*eDrivers_EditModes*/; -/* Utilities ---------------------------------- */ +/* Utilities ---------------------------------- */ /* Recursively iterate over tree, finding and working on selected items */ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportList *reports, short mode) { TreeElement *te; TreeStoreElem *tselem; - + for (te = tree->first; te; te = te->next) { tselem = TREESTORE(te); - + /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { ID *id = NULL; @@ -1616,7 +1616,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL int array_index = 0; short flag = 0; short groupmode = KSP_GROUP_KSNAME; - + /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) @@ -1625,12 +1625,12 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); } - + /* only if ID and path were set, should we perform any actions */ if (id && path) { short dflags = CREATEDRIVER_WITH_DEFAULT_DVAR; int arraylen = 1; - + /* array checks */ if (flag & KSP_FLAG_WHOLE_ARRAY) { /* entire array was selected, so add drivers for all */ @@ -1638,11 +1638,11 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL } else arraylen = array_index; - + /* we should do at least one step */ if (arraylen == array_index) arraylen++; - + /* for each array element we should affect, add driver */ for (; array_index < arraylen; array_index++) { /* action depends on mode */ @@ -1661,14 +1661,14 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL } } } - + /* free path, since it had to be generated */ MEM_freeN(path); } - - + + } - + /* go over sub-tree */ if (TSELEM_OPEN(tselem, soops)) do_outliner_drivers_editop(soops, &te->subtree, reports, mode); @@ -1680,17 +1680,17 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) { SpaceOops *soutliner = CTX_wm_space_outliner(C); - + /* check for invalid states */ if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); - + /* send notifiers */ WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX - + return OPERATOR_FINISHED; } @@ -1700,11 +1700,11 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_drivers_add_selected"; ot->name = "Add Drivers for Selected"; ot->description = "Add drivers to selected items"; - + /* api callbacks */ ot->exec = outliner_drivers_addsel_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1715,17 +1715,17 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) { SpaceOops *soutliner = CTX_wm_space_outliner(C); - + /* check for invalid states */ if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_REMOVE); - + /* send notifiers */ WM_event_add_notifier(C, ND_KEYS, NULL); // XXX - + return OPERATOR_FINISHED; } @@ -1735,11 +1735,11 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_drivers_delete_selected"; ot->name = "Delete Drivers for Selected"; ot->description = "Delete drivers assigned to selected items"; - + /* api callbacks */ ot->exec = outliner_drivers_deletesel_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1755,29 +1755,29 @@ enum { KEYINGSET_EDITMODE_REMOVE, } /*eKeyingSet_EditModes*/; -/* Utilities ---------------------------------- */ - +/* Utilities ---------------------------------- */ + /* find the 'active' KeyingSet, and add if not found (if adding is allowed) */ // TODO: should this be an API func? static KeyingSet *verify_active_keyingset(Scene *scene, short add) { KeyingSet *ks = NULL; - + /* sanity check */ if (scene == NULL) return NULL; - + /* try to find one from scene */ if (scene->active_keyingset > 0) ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); - + /* add if none found */ // XXX the default settings have yet to evolve if ((add) && (ks == NULL)) { ks = BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset = BLI_listbase_count(&scene->keyingsets); } - + return ks; } @@ -1786,10 +1786,10 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa { TreeElement *te; TreeStoreElem *tselem; - + for (te = tree->first; te; te = te->next) { tselem = TREESTORE(te); - + /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { ID *id = NULL; @@ -1797,7 +1797,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa int array_index = 0; short flag = 0; short groupmode = KSP_GROUP_KSNAME; - + /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) @@ -1806,7 +1806,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa tree_element_to_path(te, tselem, &id, &path, &array_index, &flag, &groupmode); } - + /* only if ID and path were set, should we perform any actions */ if (id && path) { /* action depends on mode */ @@ -1824,7 +1824,7 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa { /* find the relevant path, then remove it from the KeyingSet */ KS_Path *ksp = BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); - + if (ksp) { /* free path's data */ BKE_keyingset_free_path(ks, ksp); @@ -1834,12 +1834,12 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa break; } } - + /* free path, since it had to be generated */ MEM_freeN(path); } } - + /* go over sub-tree */ if (TSELEM_OPEN(tselem, soops)) do_outliner_keyingset_editop(soops, ks, &te->subtree, mode); @@ -1853,7 +1853,7 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) SpaceOops *soutliner = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = verify_active_keyingset(scene, 1); - + /* check for invalid states */ if (ks == NULL) { BKE_report(op->reports, RPT_ERROR, "Operation requires an active keying set"); @@ -1861,13 +1861,13 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) } if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + return OPERATOR_FINISHED; } @@ -1877,11 +1877,11 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_keyingset_add_selected"; ot->name = "Keying Set Add Selected"; ot->description = "Add selected items (blue-gray rows) to active Keying Set"; - + /* api callbacks */ ot->exec = outliner_keyingset_additems_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1894,17 +1894,17 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o SpaceOops *soutliner = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = verify_active_keyingset(scene, 1); - + /* check for invalid states */ if (soutliner == NULL) return OPERATOR_CANCELLED; - + /* recursively go into tree, adding selected items */ do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); - + /* send notifiers */ WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); - + return OPERATOR_FINISHED; } @@ -1914,11 +1914,11 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) ot->idname = "OUTLINER_OT_keyingset_remove_selected"; ot->name = "Keying Set Remove Selected"; ot->description = "Remove selected items (blue-gray rows) from active Keying Set"; - + /* api callbacks */ ot->exec = outliner_keyingset_removeitems_exec; ot->poll = ed_operator_outliner_datablocks_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1954,7 +1954,7 @@ static int outliner_orphans_purge_exec(bContext *C, wmOperator *UNUSED(op)) * are retained... */ WM_operator_name_call(C, "WM_OT_save_mainfile", WM_OP_EXEC_DEFAULT, NULL); - + /* Now, reload the file to get rid of the orphans... */ WM_operator_name_call(C, "WM_OT_revert_mainfile", WM_OP_EXEC_DEFAULT, NULL); return OPERATOR_FINISHED; @@ -1967,12 +1967,12 @@ void OUTLINER_OT_orphans_purge(wmOperatorType *ot) ot->name = "Purge All"; ot->description = "Clear all orphaned data-blocks without any users from the file " "(cannot be undone, saves to current .blend file)"; - + /* callbacks */ ot->invoke = outliner_orphans_purge_invoke; ot->exec = outliner_orphans_purge_exec; ot->poll = ed_operator_outliner_id_orphans_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2036,7 +2036,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname); RNA_string_get(op->ptr, "parent", parname); par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname); - + if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); return OPERATOR_CANCELLED; @@ -2048,7 +2048,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) BKE_report(op->reports, RPT_INFO, "Can't edit library linked object"); return OPERATOR_CANCELLED; } - + scene = (Scene *)outliner_search_back(soops, te, ID_SCE); if (scene == NULL) { @@ -2073,7 +2073,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); PointerRNA ptr; - + /* Cannot use uiItemEnumO()... have multiple properties to set. */ uiItemFullO_ptr(layout, ot, IFACE_("Object"), 0, NULL, WM_OP_EXEC_DEFAULT, 0, &ptr); RNA_string_set(&ptr, "parent", parname); @@ -2129,9 +2129,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) RNA_string_set(&ptr, "child", childname); RNA_enum_set(&ptr, "type", PAR_LATTICE); } - + UI_popup_menu_end(C, pup); - + return OPERATOR_INTERFACE; } } diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 674a2bceccc..9bf2231b313 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -85,7 +85,7 @@ typedef enum { OL_SETSEL_EXTEND = 2, /* select the item and extend (also toggles selection) */ } eOLSetState; -/* get TreeStoreElem associated with a TreeElement +/* get TreeStoreElem associated with a TreeElement * < a: (TreeElement) tree element to find stored element for */ #define TREESTORE(a) ((a)->store_elem) diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 36b5da72e91..ad2b8008db6 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -66,20 +66,20 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_show_active); WM_operatortype_append(OUTLINER_OT_show_hierarchy); WM_operatortype_append(OUTLINER_OT_scroll_page); - + WM_operatortype_append(OUTLINER_OT_selected_toggle); WM_operatortype_append(OUTLINER_OT_expanded_toggle); - + WM_operatortype_append(OUTLINER_OT_renderability_toggle); WM_operatortype_append(OUTLINER_OT_selectability_toggle); WM_operatortype_append(OUTLINER_OT_visibility_toggle); - + WM_operatortype_append(OUTLINER_OT_keyingset_add_selected); WM_operatortype_append(OUTLINER_OT_keyingset_remove_selected); - + WM_operatortype_append(OUTLINER_OT_drivers_add_selected); WM_operatortype_append(OUTLINER_OT_drivers_delete_selected); - + WM_operatortype_append(OUTLINER_OT_orphans_purge); WM_operatortype_append(OUTLINER_OT_parent_drop); @@ -93,7 +93,7 @@ void outliner_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Outliner", SPACE_OUTLINER, 0); wmKeyMapItem *kmi; - + WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_DBL_CLICK, 0, 0); kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_activate", LEFTMOUSE, KM_CLICK, 0, 0); @@ -114,44 +114,44 @@ void outliner_keymap(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OUTLINER_OT_select_border", BKEY, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "all", false); kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_item_openclose", RETKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "all", true); - + WM_keymap_add_item(keymap, "OUTLINER_OT_item_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_operation", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_show_hierarchy", HOMEKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PERIODKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "OUTLINER_OT_show_active", PADPERIOD, KM_PRESS, 0, 0); - + kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEDOWNKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "up", false); kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_scroll_page", PAGEUPKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "up", true); - + WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADPLUSKEY, KM_PRESS, 0, 0); /* open */ kmi = WM_keymap_add_item(keymap, "OUTLINER_OT_show_one_level", PADMINUS, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "open", false); /* close */ - + WM_keymap_verify_item(keymap, "OUTLINER_OT_selected_toggle", AKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_expanded_toggle", AKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_verify_item(keymap, "OUTLINER_OT_renderability_toggle", RKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_selectability_toggle", SKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_visibility_toggle", VKEY, KM_PRESS, 0, 0); - - + + /* keying sets - only for databrowse */ WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_add_selected", KKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_keyingset_remove_selected", KKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete", IKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_add_selected", DKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete_selected", DKEY, KM_PRESS, KM_ALT, 0); } diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 199043fc39a..5149715740f 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -76,26 +76,26 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se TreeElement *te; TreeStoreElem *tselem; bool changed = false; - + for (te = lb->first; te && *index >= 0; te = te->next, (*index)--) { tselem = TREESTORE(te); - + /* if we've encountered the right item, set its 'Outliner' selection status */ if (*index == 0) { /* this should be the last one, so no need to do anything with index */ if ((te->flag & TE_ICONROW) == 0) { /* -1 value means toggle testing for now... */ if (*selecting == -1) { - if (tselem->flag & TSE_SELECTED) + if (tselem->flag & TSE_SELECTED) *selecting = 0; - else + else *selecting = 1; } - + /* set selection */ - if (*selecting) + if (*selecting) tselem->flag |= TSE_SELECTED; - else + else tselem->flag &= ~TSE_SELECTED; changed |= true; @@ -125,12 +125,12 @@ static eOLDrawState tree_element_active_renderlayer( bContext *C, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { Scene *sce; - + /* paranoia check */ if (te->idcode != ID_SCE) return OL_DRAWSEL_NONE; sce = (Scene *)tselem->id; - + if (set != OL_SETSEL_NONE) { sce->r.actlay = tselem->nr; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce); @@ -191,7 +191,7 @@ static eOLDrawState tree_element_set_active_object( Scene *sce; Base *base; Object *ob = NULL; - + /* if id is not object, we search back */ if (te->idcode == ID_OB) { ob = (Object *)tselem->id; @@ -205,13 +205,13 @@ static eOLDrawState tree_element_set_active_object( if (ob == NULL) { return OL_DRAWSEL_NONE; } - + sce = (Scene *)outliner_search_back(soops, te, ID_SCE); if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); scene = sce; } - + /* find associated base in current scene */ base = BKE_scene_base_find(scene, ob); @@ -220,7 +220,7 @@ static eOLDrawState tree_element_set_active_object( /* swap select */ if (base->flag & SELECT) ED_base_object_select(base, BA_DESELECT); - else + else ED_base_object_select(base, BA_SELECT); } else { @@ -239,10 +239,10 @@ static eOLDrawState tree_element_set_active_object( WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } - + if (ob != scene->obedit) ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); - + return OL_DRAWSEL_NORMAL; } @@ -252,14 +252,14 @@ static eOLDrawState tree_element_active_material( { TreeElement *tes; Object *ob; - + /* we search for the object parent */ ob = (Object *)outliner_search_back(soops, te, ID_OB); // note: ob->matbits can be NULL when a local object points to a library mesh. if (ob == NULL || ob != OBACT || ob->matbits == NULL) { return OL_DRAWSEL_NONE; /* just paranoia */ } - + /* searching in ob mat array? */ tes = te->parent; if (tes->idcode == ID_OB) { @@ -307,21 +307,21 @@ static eOLDrawState tree_element_active_texture( TreeStoreElem /* *tselem,*/ *tselemp; Object *ob = OBACT; SpaceButs *sbuts = NULL; - + if (ob == NULL) { /* no active object */ return OL_DRAWSEL_NONE; } - + /*tselem = TREESTORE(te);*/ /*UNUSED*/ - + /* find buttons region (note, this is undefined really still, needs recode in blender) */ /* XXX removed finding sbuts */ - + /* where is texture linked to? */ tep = te->parent; tselemp = TREESTORE(tep); - + if (tep->idcode == ID_WO) { World *wrld = (World *)tselemp->id; @@ -366,7 +366,7 @@ static eOLDrawState tree_element_active_texture( } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture ma->texact = (char)te->index; - + /* also set active material */ ob->actcol = tep->index + 1; } @@ -376,7 +376,7 @@ static eOLDrawState tree_element_active_texture( } } } - + if (set != OL_SETSEL_NONE) { WM_event_add_notifier(C, NC_TEXTURE, NULL); } @@ -391,21 +391,21 @@ static eOLDrawState tree_element_active_lamp( TreeElement *te, const eOLSetState set) { Object *ob; - + /* we search for the object parent */ ob = (Object *)outliner_search_back(soops, te, ID_OB); if (ob == NULL || ob != OBACT) { /* just paranoia */ return OL_DRAWSEL_NONE; } - + if (set != OL_SETSEL_NONE) { // XXX extern_set_butspace(F5KEY, 0); } else { return OL_DRAWSEL_NORMAL; } - + return OL_DRAWSEL_NONE; } @@ -429,21 +429,21 @@ static eOLDrawState tree_element_active_world( TreeElement *tep; TreeStoreElem *tselem = NULL; Scene *sce = NULL; - + tep = te->parent; if (tep) { tselem = TREESTORE(tep); if (tselem->type == 0) sce = (Scene *)tselem->id; } - + if (set != OL_SETSEL_NONE) { /* make new scene active */ if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } } - + if (tep == NULL || tselem->id == (ID *)scene) { if (set != OL_SETSEL_NONE) { // XXX extern_set_butspace(F8KEY, 0); @@ -459,7 +459,7 @@ static eOLDrawState tree_element_active_defgroup( bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { Object *ob; - + /* id in tselem is object */ ob = (Object *)tselem->id; if (set != OL_SETSEL_NONE) { @@ -483,7 +483,7 @@ static eOLDrawState tree_element_active_posegroup( bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, const eOLSetState set) { Object *ob = (Object *)tselem->id; - + if (set != OL_SETSEL_NONE) { if (ob->pose) { ob->pose->active_group = te->index + 1; @@ -506,10 +506,10 @@ static eOLDrawState tree_element_active_posechannel( Object *ob = (Object *)tselem->id; bArmature *arm = ob->data; bPoseChannel *pchan = te->directdata; - + if (set != OL_SETSEL_NONE) { if (!(pchan->bone->flag & BONE_HIDDEN_P)) { - + if (set != OL_SETSEL_EXTEND) { bPoseChannel *pchannel; /* single select forces all other bones to get unselected */ @@ -549,7 +549,7 @@ static eOLDrawState tree_element_active_bone( { bArmature *arm = (bArmature *)tselem->id; Bone *bone = te->directdata; - + if (set != OL_SETSEL_NONE) { if (!(bone->flag & BONE_HIDDEN_P)) { Object *ob = OBACT; @@ -562,7 +562,7 @@ static eOLDrawState tree_element_active_bone( } } } - + if (set == OL_SETSEL_EXTEND && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; } @@ -576,13 +576,13 @@ static eOLDrawState tree_element_active_bone( do_outliner_bone_select_recursive(arm, bone, (bone->flag & BONE_SELECTED) != 0); } - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob); } } else { Object *ob = OBACT; - + if (ob && ob->data == arm) { if (bone->flag & BONE_SELECTED) { return OL_DRAWSEL_NORMAL; @@ -658,12 +658,12 @@ static eOLDrawState tree_element_active_modifier( { if (set != OL_SETSEL_NONE) { Object *ob = (Object *)tselem->id; - + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); // XXX extern_set_butspace(F9KEY, 0); } - + return OL_DRAWSEL_NONE; } @@ -672,12 +672,12 @@ static eOLDrawState tree_element_active_psys( { if (set != OL_SETSEL_NONE) { Object *ob = (Object *)tselem->id; - + WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); - + // XXX extern_set_butspace(F7KEY, 0); } - + return OL_DRAWSEL_NONE; } @@ -686,11 +686,11 @@ static int tree_element_active_constraint( { if (set != OL_SETSEL_NONE) { Object *ob = (Object *)tselem->id; - + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); // XXX extern_set_butspace(F7KEY, 0); } - + return OL_DRAWSEL_NONE; } @@ -717,7 +717,7 @@ static eOLDrawState tree_element_active_pose( if (scene->obedit) { ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); } - + if (ob->mode & OB_MODE_POSE) { ED_object_posemode_exit(C, ob); } @@ -798,7 +798,7 @@ static eOLDrawState tree_element_active_keymap_item( bContext *UNUSED(C), TreeElement *te, TreeStoreElem *UNUSED(tselem), const eOLSetState set) { wmKeyMapItem *kmi = te->directdata; - + if (set == OL_SETSEL_NONE) { if (kmi->flag & KMI_INACTIVE) { return OL_DRAWSEL_NONE; @@ -888,7 +888,7 @@ eOLDrawState tree_element_type_active( case TSE_GP_LAYER: //return tree_element_active_gplayer(C, scene, te, tselem, set); break; - + } return OL_DRAWSEL_NONE; } @@ -977,13 +977,13 @@ static bool do_outliner_item_activate_from_cursor( if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { TreeStoreElem *tselem = TREESTORE(te); bool openclose = false; - + /* open close icon */ if ((te->flag & TE_ICONROW) == 0) { // hidden icon, no open/close if (mval[0] > te->xs && mval[0] < te->xs + UI_UNIT_X) openclose = true; } - + if (openclose) { /* all below close/open? */ if (extend) { @@ -993,9 +993,9 @@ static bool do_outliner_item_activate_from_cursor( else { if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; - + } - + return true; } /* name and first icon */ @@ -1007,7 +1007,7 @@ static bool do_outliner_item_activate_from_cursor( return true; } } - + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_activate_from_cursor(C, scene, ar, soops, te, extend, recursive, mval)) { return true; @@ -1064,29 +1064,29 @@ int outliner_item_do_activate_from_cursor( break; } } - + if (te) { ED_undo_push(C, "Outliner click event"); } else { short selecting = -1; int row; - + /* get row number - 100 here is just a dummy value since we don't need the column */ - UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, + UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, fmval[0], fmval[1], NULL, &row); - + /* select relevant row */ if (outliner_select(soops, &soops->tree, &row, &selecting)) { - + soops->storeflag |= SO_TREESTORE_REDRAW; - + /* no need for undo push here, only changing outliner data which is * scene level - campbell */ /* ED_undo_push(C, "Outliner selection event"); */ } } - + ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -1105,11 +1105,11 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) ot->name = "Activate Item"; ot->idname = "OUTLINER_OT_item_activate"; ot->description = "Handle mouse clicks to activate/select items"; - + ot->invoke = outliner_item_activate; - + ot->poll = ED_operator_outliner_active; - + RNA_def_boolean(ot->srna, "extend", true, "Extend", "Extend selection for activation"); RNA_def_boolean(ot->srna, "recursive", false, "Recursive", "Select Objects and their children"); } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 0fcebc53f58..75151325bdf 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -96,7 +96,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -115,7 +115,7 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, case ID_OB: *objectlevel = 1; break; - + case ID_ME: case ID_CU: case ID_MB: case ID_LT: case ID_LA: case ID_AR: case ID_CA: case ID_SPK: case ID_MA: case ID_TE: case ID_IP: case ID_IM: @@ -149,7 +149,7 @@ static void unlink_material_cb( { Material **matar = NULL; int a, totcol = 0; - + if (GS(tsep->id->name) == ID_OB) { Object *ob = (Object *)tsep->id; totcol = ob->totcol; @@ -190,7 +190,7 @@ static void unlink_texture_cb( { MTex **mtex = NULL; int a; - + if (GS(tsep->id->name) == ID_MA) { Material *ma = (Material *)tsep->id; mtex = ma->mtex; @@ -226,7 +226,7 @@ static void unlink_group_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data)) { Group *group = (Group *)tselem->id; - + if (tsep) { if (GS(tsep->id->name) == ID_OB) { Object *ob = (Object *)tsep->id; @@ -245,7 +245,7 @@ static void unlink_world_cb( { Scene *parscene = (Scene *)tsep->id; World *wo = (World *)tselem->id; - + /* need to use parent scene not just scene, otherwise may end up getting wrong one */ id_us_min(&wo->id); parscene->world = NULL; @@ -258,7 +258,7 @@ static void outliner_do_libdata_operation( { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -363,7 +363,7 @@ static void object_select_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { Base *base = (Base *)te->directdata; - + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0)) { base->flag |= SELECT; @@ -385,7 +385,7 @@ static void object_deselect_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { Base *base = (Base *)te->directdata; - + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->flag &= ~SELECT; @@ -398,7 +398,7 @@ static void object_delete_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *user_data) { Base *base = (Base *)te->directdata; - + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { @@ -420,7 +420,7 @@ static void object_delete_cb( if (scene->obedit == base->object) { ED_object_editmode_exit(C, EM_FREEDATA | EM_WAITCURSOR); } - + ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); /* leave for ED_outliner_id_unref to handle */ #if 0 @@ -459,7 +459,7 @@ static void id_fake_user_set_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + id_fake_user_set(id); } @@ -468,7 +468,7 @@ static void id_fake_user_clear_cb( TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + id_fake_user_clear(id); } @@ -486,15 +486,15 @@ static void singleuser_action_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + if (id) { IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id; PointerRNA ptr = {{NULL}}; PropertyRNA *prop; - + RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr); prop = RNA_struct_find_property(&ptr, "action"); - + id_single_user(C, id, &ptr, prop); } } @@ -504,16 +504,16 @@ static void singleuser_world_cb( TreeStoreElem *tsep, TreeStoreElem *tselem, void *UNUSED(user_data)) { ID *id = tselem->id; - + /* need to use parent scene not just scene, otherwise may end up getting wrong one */ if (id) { Scene *parscene = (Scene *)tsep->id; PointerRNA ptr = {{NULL}}; PropertyRNA *prop; - + RNA_id_pointer_create(&parscene->id, &ptr); prop = RNA_struct_find_property(&ptr, "world"); - + id_single_user(C, id, &ptr, prop); } } @@ -558,7 +558,7 @@ void outliner_do_object_operation_ex( outliner_operation_cb operation_cb, bool select_recurse) { TreeElement *te; - + for (te = lb->first; te; te = te->next) { TreeStoreElem *tselem = TREESTORE(te); bool select_handled = false; @@ -612,7 +612,7 @@ static void cleardrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te), TreeStoreElem *tselem, void *UNUSED(arg)) { IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id; - + /* just free drivers - stored as a list of F-Curves */ free_fcurves(&iat->adt->drivers); } @@ -622,11 +622,11 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te { IdAdtTemplate *iat = (IdAdtTemplate *)tselem->id; FCurve *fcu; - + /* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */ for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_DISABLED; - + if (fcu->driver) fcu->driver->flag &= ~DRIVER_FLAG_INVALID; } @@ -657,7 +657,7 @@ typedef enum eOutliner_PropModifierOps { static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { bPoseChannel *pchan = (bPoseChannel *)te->directdata; - + if (event == OL_DOP_SELECT) pchan->bone->flag |= BONE_SELECTED; else if (event == OL_DOP_DESELECT) @@ -673,7 +673,7 @@ static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { Bone *bone = (Bone *)te->directdata; - + if (event == OL_DOP_SELECT) bone->flag |= BONE_SELECTED; else if (event == OL_DOP_DESELECT) @@ -689,7 +689,7 @@ static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), v static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { EditBone *ebone = (EditBone *)te->directdata; - + if (event == OL_DOP_SELECT) ebone->flag |= BONE_SELECTED; else if (event == OL_DOP_DESELECT) @@ -719,7 +719,7 @@ static void sequence_cb(int event, TreeElement *te, TreeStoreElem *tselem, void static void gp_layer_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *UNUSED(arg)) { bGPDlayer *gpl = (bGPDlayer *)te->directdata; - + if (event == OL_DOP_SELECT) gpl->flag |= GP_LAYER_SELECT; else if (event == OL_DOP_DESELECT) @@ -811,7 +811,7 @@ static void outliner_do_data_operation(SpaceOops *soops, int type, int event, Li { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -927,11 +927,11 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); int event; const char *str = NULL; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); if (event == OL_OP_SELECT) { @@ -940,7 +940,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } - + str = "Select Objects"; WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -949,7 +949,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) outliner_do_object_operation_ex(C, op->reports, scene, soops, &soops->tree, object_select_hierarchy_cb, false); if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); - } + } str = "Select Object Hierarchy"; WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -1015,7 +1015,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) } ED_undo_push(C, str); - + return OPERATOR_FINISHED; } @@ -1026,12 +1026,12 @@ void OUTLINER_OT_object_operation(wmOperatorType *ot) ot->name = "Outliner Object Operation"; ot->idname = "OUTLINER_OT_object_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_object_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; ot->prop = RNA_def_enum(ot->srna, "type", prop_object_op_types, 0, "Object Operation", ""); @@ -1072,11 +1072,11 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); SpaceOops *soops = CTX_wm_space_outliner(C); int event; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); switch (event) { @@ -1129,14 +1129,14 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot) ot->name = "Outliner Group Operation"; ot->idname = "OUTLINER_OT_group_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_group_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_group_op_types, 0, "Group Operation", ""); } @@ -1144,13 +1144,13 @@ void OUTLINER_OT_group_operation(wmOperatorType *ot) typedef enum eOutlinerIdOpTypes { OUTLINER_IDOP_INVALID = 0, - + OUTLINER_IDOP_UNLINK, OUTLINER_IDOP_LOCAL, OUTLINER_IDOP_SINGLE, OUTLINER_IDOP_DELETE, OUTLINER_IDOP_REMAP, - + OUTLINER_IDOP_FAKE_ADD, OUTLINER_IDOP_FAKE_CLEAR, OUTLINER_IDOP_RENAME, @@ -1180,15 +1180,15 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutlinerIdOpTypes event; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + event = RNA_enum_get(op->ptr, "type"); - + switch (event) { case OUTLINER_IDOP_UNLINK: { @@ -1196,25 +1196,25 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) switch (idlevel) { case ID_AC: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_action_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case ID_MA: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_material_cb, NULL); - + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink material"); break; case ID_TE: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_texture_cb, NULL); - + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink texture"); break; case ID_WO: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, unlink_world_cb, NULL); - + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Unlink world"); break; @@ -1237,18 +1237,18 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) switch (idlevel) { case ID_AC: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_action_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Single-User Action"); break; - + case ID_WO: outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, singleuser_world_cb, NULL); - + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Single-User World"); break; - + default: BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; @@ -1275,7 +1275,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) { /* set fake user */ outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_set_cb, NULL); - + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Add Fake User"); break; @@ -1284,7 +1284,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) { /* clear fake user */ outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_fake_user_clear_cb, NULL); - + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Clear Fake User"); break; @@ -1293,7 +1293,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) { /* rename */ outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, item_rename_cb, NULL); - + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Rename"); break; @@ -1302,18 +1302,18 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) outliner_do_libdata_operation(C, op->reports, scene, soops, &soops->tree, id_select_linked_cb, NULL); ED_undo_push(C, "Select"); break; - + default: // invalid - unhandled break; } - + /* wrong notifier still... */ WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); - - // XXX: this is just so that outliner is always up to date + + // XXX: this is just so that outliner is always up to date WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); - + return OPERATOR_FINISHED; } @@ -1324,14 +1324,14 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot) ot->name = "Outliner ID data Operation"; ot->idname = "OUTLINER_OT_id_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_id_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_id_op_types, 0, "ID data Operation", ""); } @@ -1435,7 +1435,7 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l { TreeElement *te; TreeStoreElem *tselem; - + for (te = lb->first; te; te = te->next) { tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { @@ -1455,12 +1455,12 @@ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *l static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, TreeStoreElem *tsep, ID *actId) { bAction *act = (bAction *)actId; - + if (tselem->type == TSE_ANIM_DATA) { /* "animation" entries - action is child of this */ BKE_animdata_set_action(NULL, tselem->id, act); } - /* TODO: if any other "expander" channels which own actions need to support this menu, + /* TODO: if any other "expander" channels which own actions need to support this menu, * add: tselem->type = ... */ else if (tsep && (tsep->type == TSE_ANIM_DATA)) { @@ -1474,17 +1474,17 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) { SpaceOops *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; - + bAction *act; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + /* get action to use */ act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); - + if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid action to add"); return OPERATOR_CANCELLED; @@ -1497,7 +1497,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) "for this action to avoid future problems)", act->id.name + 2); } - + /* perform action if valid channel */ if (datalevel == TSE_ANIM_DATA) outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb); @@ -1505,11 +1505,11 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb); else return OPERATOR_CANCELLED; - + /* set notifier that things have changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Set action"); - + /* done */ return OPERATOR_FINISHED; } @@ -1522,15 +1522,15 @@ void OUTLINER_OT_action_set(wmOperatorType *ot) ot->name = "Outliner Set Action"; ot->idname = "OUTLINER_OT_action_set"; ot->description = "Change the active action used"; - + /* api callbacks */ ot->invoke = WM_enum_search_invoke; ot->exec = outliner_action_set_exec; ot->poll = ED_operator_outliner_active; - + /* flags */ ot->flag = 0; - + /* props */ // TODO: this would be nicer as an ID-pointer... prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); @@ -1543,15 +1543,15 @@ void OUTLINER_OT_action_set(wmOperatorType *ot) typedef enum eOutliner_AnimDataOps { OUTLINER_ANIMOP_INVALID = 0, - + OUTLINER_ANIMOP_CLEAR_ADT, - + OUTLINER_ANIMOP_SET_ACT, OUTLINER_ANIMOP_CLEAR_ACT, - + OUTLINER_ANIMOP_REFRESH_DRV, OUTLINER_ANIMOP_CLEAR_DRV - + //OUTLINER_ANIMOP_COPY_DRIVERS, //OUTLINER_ANIMOP_PASTE_DRIVERS } eOutliner_AnimDataOps; @@ -1573,66 +1573,66 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_AnimDataOps event; short updateDeps = 0; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + if (datalevel != TSE_ANIM_DATA) return OPERATOR_CANCELLED; - + /* perform the core operation */ switch (event) { case OUTLINER_ANIMOP_CLEAR_ADT: /* Remove Animation Data - this may remove the active action, in some cases... */ outliner_do_data_operation(soops, datalevel, event, &soops->tree, clear_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Clear Animation Data"); break; - + case OUTLINER_ANIMOP_SET_ACT: /* delegate once again... */ WM_operator_name_call(C, "OUTLINER_OT_action_set", WM_OP_INVOKE_REGION_WIN, NULL); break; - + case OUTLINER_ANIMOP_CLEAR_ACT: /* clear active action - using standard rules */ outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; - + case OUTLINER_ANIMOP_REFRESH_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ updateDeps = 1; break; - + case OUTLINER_ANIMOP_CLEAR_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb, NULL); - + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); ED_undo_push(C, "Clear Drivers"); updateDeps = 1; break; - + default: // invalid break; } - + /* update dependencies */ if (updateDeps) { /* rebuild depsgraph for the new deps */ DAG_relations_tag_update(CTX_data_main(C)); } - + return OPERATOR_FINISHED; } @@ -1643,14 +1643,14 @@ void OUTLINER_OT_animdata_operation(wmOperatorType *ot) ot->name = "Outliner Animation Data Operation"; ot->idname = "OUTLINER_OT_animdata_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_animdata_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_animdata_op_types, 0, "Animation Operation", ""); } @@ -1763,14 +1763,14 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) SpaceOops *soops = CTX_wm_space_outliner(C); int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_PropDataOps event; - + /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + switch (datalevel) { case TSE_POSE_CHANNEL: { @@ -1822,7 +1822,7 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; } - + return OPERATOR_FINISHED; } @@ -1833,14 +1833,14 @@ void OUTLINER_OT_data_operation(wmOperatorType *ot) ot->name = "Outliner Data Operation"; ot->idname = "OUTLINER_OT_data_operation"; ot->description = ""; - + /* callbacks */ ot->invoke = WM_menu_invoke; ot->exec = outliner_data_operation_exec; ot->poll = ED_operator_outliner_active; - + ot->flag = 0; - + ot->prop = RNA_def_enum(ot->srna, "type", prop_data_op_types, 0, "Data Operation", ""); } @@ -1852,25 +1852,25 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop TreeElement *te, const float mval[2]) { ReportList *reports = CTX_wm_reports(C); // XXX... - + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; TreeStoreElem *tselem = TREESTORE(te); - + /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - + if (outliner_has_one_flag(&soops->tree, TSE_SELECTED, 1)) outliner_set_flag(&soops->tree, TSE_SELECTED, 0); - + tselem->flag |= TSE_SELECTED; /* redraw, same as outliner_select function */ soops->storeflag |= SO_TREESTORE_REDRAW; ED_region_tag_redraw(ar); } - + set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - + if (scenelevel) { if (objectlevel || datalevel || idlevel) { BKE_report(reports, RPT_WARNING, "Mixed selection"); @@ -1927,10 +1927,10 @@ static int do_outliner_operation_event(bContext *C, ARegion *ar, SpaceOops *soop } } } - + return 1; } - + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_operation_event(C, ar, soops, te, mval)) return 1; @@ -1952,13 +1952,13 @@ static int outliner_operation(bContext *C, wmOperator *UNUSED(op), const wmEvent } UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); - + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_operation_event(C, ar, soops, te, fmval)) { break; } } - + return OPERATOR_FINISHED; } @@ -1968,9 +1968,9 @@ void OUTLINER_OT_operation(wmOperatorType *ot) ot->name = "Execute Operation"; ot->idname = "OUTLINER_OT_operation"; ot->description = "Context menu for item operations"; - + ot->invoke = outliner_operation; - + ot->poll = ED_operator_outliner_active; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 6a4e9bc9578..b54a7705686 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -28,7 +28,7 @@ /** \file blender/editors/space_outliner/outliner_tree.c * \ingroup spoutliner */ - + #include #include @@ -89,11 +89,11 @@ static void outliner_storage_cleanup(SpaceOops *soops) { BLI_mempool *ts = soops->treestore; - + if (ts) { TreeStoreElem *tselem; int unused = 0; - + /* each element used once, for ID blocks with more users to have each a treestore */ BLI_mempool_iter iter; @@ -101,7 +101,7 @@ static void outliner_storage_cleanup(SpaceOops *soops) while ((tselem = BLI_mempool_iterstep(&iter))) { tselem->used = 0; } - + /* cleanup only after reading file or undo step, and always for * RNA datablocks view in order to save memory */ if (soops->storeflag & SO_TREESTORE_CLEANUP) { @@ -111,7 +111,7 @@ static void outliner_storage_cleanup(SpaceOops *soops) while ((tselem = BLI_mempool_iterstep(&iter))) { if (tselem->id == NULL) unused++; } - + if (unused) { if (BLI_mempool_len(ts) == unused) { BLI_mempool_destroy(ts); @@ -147,11 +147,11 @@ static void outliner_storage_cleanup(SpaceOops *soops) static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short type, short nr) { TreeStoreElem *tselem; - + if (soops->treestore == NULL) { /* if treestore was not created in readfile.c, create it here */ soops->treestore = BLI_mempool_create(sizeof(TreeStoreElem), 1, 512, BLI_MEMPOOL_ALLOW_ITER); - + } if (soops->treehash == NULL) { soops->treehash = BKE_outliner_treehash_create_from_treestore(soops->treestore); @@ -184,10 +184,10 @@ void outliner_free_tree(ListBase *lb) { while (lb->first) { TreeElement *te = lb->first; - + outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - + if (te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } @@ -217,12 +217,12 @@ TreeElement *outliner_find_tse(SpaceOops *soops, const TreeStoreElem *tse) TreeStoreElem *tselem; if (tse->id == NULL) return NULL; - + /* check if 'tse' is in treestore */ tselem = BKE_outliner_treehash_lookup_any(soops->treehash, tse->type, tse->nr, tse->id); - if (tselem) + if (tselem) return outliner_find_tree_element(&soops->tree, tselem); - + return NULL; } @@ -289,7 +289,7 @@ ID *outliner_search_back(SpaceOops *UNUSED(soops), TreeElement *te, short idcode { TreeStoreElem *tselem; te = te->parent; - + while (te) { tselem = TREESTORE(te); if (tselem->type == 0 && te->idcode == idcode) return tselem->id; @@ -302,7 +302,7 @@ ID *outliner_search_back(SpaceOops *UNUSED(soops), TreeElement *te, short idcode /* ********************************************************* */ /* Prototype, see functions below */ -static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, +static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, TreeElement *parent, short type, short index); /* -------------------------------------------------------- */ @@ -312,11 +312,11 @@ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curB TreeElement *parent, int *a) { TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); - + (*a)++; te->name = curBone->name; te->directdata = curBone; - + for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } @@ -333,16 +333,16 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc /* log stuff is to convert bitflags (powers of 2) to small integers, * in order to not overflow short tselem->nr */ - + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); te->name = IFACE_("Combined"); te->directdata = &srl->passflag; - + /* save cpu cycles, but we add the first to invoke an open/close triangle */ tselem = TREESTORE(tenla); if (tselem->flag & TSE_CLOSED) return; - + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); te->name = IFACE_("Z"); te->directdata = &srl->passflag; @@ -454,27 +454,27 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s SceneRenderLayer *srl; TreeElement *tenla = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); int a; - + tenla->name = IFACE_("RenderLayers"); for (a = 0, srl = sce->r.layers.first; srl; srl = srl->next, a++) { TreeElement *tenlay = outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); tenlay->name = srl->name; tenlay->directdata = &srl->layflag; - + if (srl->light_override) outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); if (srl->mat_override) outliner_add_element(soops, &tenlay->subtree, srl->mat_override, tenlay, TSE_LINKED_MAT, 0); - + outliner_add_passes(soops, tenlay, &sce->id, srl); } - + // TODO: move this to the front? if (outliner_animdata_test(sce->adt)) outliner_add_element(soops, lb, sce, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, lb, sce->gpd, te, 0, 0); - + outliner_add_element(soops, lb, sce->world, te, 0, 0); #ifdef WITH_FREESTYLE @@ -488,41 +488,41 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree { if (outliner_animdata_test(ob->adt)) outliner_add_element(soops, &te->subtree, ob, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this - + if (ob->proxy && !ID_IS_LINKED(ob)) outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); - + outliner_add_element(soops, &te->subtree, ob->gpd, te, 0, 0); - + outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0); - + if (ob->pose) { bArmature *arm = ob->data; bPoseChannel *pchan; TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); - + tenla->name = IFACE_("Pose"); - + /* channels undefined in editmode, but we want the 'tenla' pose icon itself */ if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) { TreeElement *ten; int a = 0, const_index = 1000; /* ensure unique id for bone constraints */ - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) { ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); ten->name = pchan->name; ten->directdata = pchan; pchan->temp = (void *)ten; - + if (pchan->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten1; TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); //char *str; - + tenla1->name = IFACE_("Constraints"); for (con = pchan->constraints.first; con; con = con->next, const_index++) { ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); @@ -555,7 +555,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree ten = nten; } } - + /* Pose Groups */ if (ob->pose->agroups.first) { bActionGroup *agrp; @@ -571,11 +571,11 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree } } } - + for (int a = 0; a < ob->totcol; a++) { outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); } - + if (ob->constraints.first) { //Object *target; bConstraint *con; @@ -583,7 +583,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); //char *str; int a; - + tenla->name = IFACE_("Constraints"); for (con = ob->constraints.first, a = 0; con; con = con->next, a++) { ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); @@ -598,18 +598,18 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree /* possible add all other types links? */ } } - + if (ob->modifiers.first) { ModifierData *md; TreeElement *ten_mod = outliner_add_element(soops, &te->subtree, ob, te, TSE_MODIFIER_BASE, 0); int index; - + ten_mod->name = IFACE_("Modifiers"); for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) { TreeElement *ten = outliner_add_element(soops, &ten_mod->subtree, ob, ten_mod, TSE_MODIFIER, index); ten->name = md->name; ten->directdata = md; - + if (md->type == eModifierType_Lattice) { outliner_add_element(soops, &ten->subtree, ((LatticeModifierData *) md)->object, ten, TSE_LINKED_OB, 0); } @@ -625,21 +625,21 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree else if (md->type == eModifierType_ParticleSystem) { ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys; TreeElement *ten_psys; - + ten_psys = outliner_add_element(soops, &ten->subtree, ob, te, TSE_LINKED_PSYS, 0); ten_psys->directdata = psys; ten_psys->name = psys->part->id.name + 2; } } } - + /* vertex groups */ if (ob->defbase.first) { bDeformGroup *defgroup; TreeElement *ten; TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); int a; - + tenla->name = IFACE_("Vertex Groups"); for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) { ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); @@ -647,7 +647,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree ten->directdata = defgroup; } } - + /* duplicated group */ if (ob->dup_group) outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0); @@ -659,7 +659,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { /* tuck pointer back in object, to construct hierarchy */ if (GS(id->name) == ID_OB) id->newid = (ID *)te; - + /* expand specific data always */ switch (GS(id->name)) { case ID_LI: @@ -681,10 +681,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Mesh *me = (Mesh *)id; int a; - + if (outliner_animdata_test(me->adt)) outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); for (a = 0; a < me->totcol; a++) outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); @@ -696,10 +696,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Curve *cu = (Curve *)id; int a; - + if (outliner_animdata_test(cu->adt)) outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < cu->totcol; a++) outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); break; @@ -708,10 +708,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { MetaBall *mb = (MetaBall *)id; int a; - + if (outliner_animdata_test(mb->adt)) outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < mb->totcol; a++) outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); break; @@ -720,10 +720,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Material *ma = (Material *)id; int a; - + if (outliner_animdata_test(ma->adt)) outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < MAX_MTEX; a++) { if (ma->mtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); } @@ -732,17 +732,17 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor case ID_TE: { Tex *tex = (Tex *)id; - + if (outliner_animdata_test(tex->adt)) outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0); - + outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); break; } case ID_CA: { Camera *ca = (Camera *)id; - + if (outliner_animdata_test(ca->adt)) outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); break; @@ -761,10 +761,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { Lamp *la = (Lamp *)id; int a; - + if (outliner_animdata_test(la->adt)) outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < MAX_MTEX; a++) { if (la->mtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); } @@ -782,10 +782,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { World *wrld = (World *)id; int a; - + if (outliner_animdata_test(wrld->adt)) outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); - + for (a = 0; a < MAX_MTEX; a++) { if (wrld->mtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); } @@ -794,7 +794,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor case ID_KE: { Key *key = (Key *)id; - + if (outliner_animdata_test(key->adt)) outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); break; @@ -809,14 +809,14 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { bArmature *arm = (bArmature *)id; int a = 0; - + if (outliner_animdata_test(arm->adt)) outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); - + if (arm->edbo) { EditBone *ebone; TreeElement *ten; - + for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) { ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); ten->directdata = ebone; @@ -856,7 +856,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor { FreestyleLineStyle *linestyle = (FreestyleLineStyle *)id; int a; - + if (outliner_animdata_test(linestyle->adt)) outliner_add_element(soops, &te->subtree, linestyle, te, TSE_ANIM_DATA, 0); @@ -871,10 +871,10 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor bGPdata *gpd = (bGPdata *)id; bGPDlayer *gpl; int a = 0; - + if (outliner_animdata_test(gpd->adt)) outliner_add_element(soops, &te->subtree, gpd, te, TSE_ANIM_DATA, 0); - + // TODO: base element for layers? for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { outliner_add_element(soops, &te->subtree, gpl, te, TSE_GP_LAYER, a); @@ -895,7 +895,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i TreeElement *te; TreeStoreElem *tselem; ID *id = idv; - + if (ELEM(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { id = ((PointerRNA *)idv)->id.data; if (!id) id = ((PointerRNA *)idv)->data; @@ -924,11 +924,11 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* add to the storage */ check_persistent(soops, te, id, type, index); tselem = TREESTORE(te); - + /* if we are searching for something expand to see child elements */ if (SEARCHING_OUTLINER(soops)) tselem->flag |= TSE_CHILDSEARCH; - + te->parent = parent; te->index = index; // for data arays if (ELEM(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { @@ -954,10 +954,10 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i te->name = id->name + 2; // default, can be overridden by Library or non-ID data te->idcode = GS(id->name); } - + if (type == 0) { TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL; - + /* ID datablock */ if (tsepar == NULL || tsepar->type != TSE_ID_BASE) outliner_add_id_contents(soops, te, tselem, id); @@ -965,30 +965,30 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else if (type == TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; AnimData *adt = (AnimData *)iat->adt; - + /* this element's info */ te->name = IFACE_("Animation"); te->directdata = adt; - + /* Action */ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); - + /* Drivers */ if (adt->drivers.first) { TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); ID *lastadded = NULL; FCurve *fcu; - + ted->name = IFACE_("Drivers"); - + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { if (fcu->driver && fcu->driver->variables.first) { ChannelDriver *driver = fcu->driver; DriverVar *dvar; - + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* loop over all targets used here */ - DRIVER_TARGETS_USED_LOOPER(dvar) + DRIVER_TARGETS_USED_LOOPER(dvar) { if (lastadded != dtar->id) { // XXX this lastadded check is rather lame, and also fails quite badly... @@ -1001,23 +1001,23 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } } - + /* NLA Data */ if (adt->nla_tracks.first) { TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); NlaTrack *nlt; int a = 0; - + tenla->name = IFACE_("NLA Tracks"); - + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { TreeElement *tenlt = outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); NlaStrip *strip; TreeElement *ten; int b = 0; - + tenlt->name = nlt->name; - + for (strip = nlt->strips.first; strip; strip = strip->next, b++) { ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); if (ten) ten->directdata = strip; @@ -1027,7 +1027,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } else if (type == TSE_GP_LAYER) { bGPDlayer *gpl = (bGPDlayer *)idv; - + te->name = gpl->info; te->directdata = gpl; } @@ -1200,31 +1200,31 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i wmKeyMap *km = (wmKeyMap *)idv; wmKeyMapItem *kmi; char opname[OP_MAX_TYPENAME]; - + te->directdata = idv; te->name = km->idname; - + if (TSELEM_OPEN(tselem, soops)) { int a = 0; - + for (kmi = km->items.first; kmi; kmi = kmi->next, a++) { const char *key = WM_key_event_string(kmi->type, false); - + if (key[0]) { wmOperatorType *ot = NULL; - + if (kmi->propvalue) { /* pass */ } else { ot = WM_operatortype_find(kmi->idname, 0); } - + if (ot || kmi->propvalue) { TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); - + ten->directdata = kmi; - + if (kmi->propvalue) { ten->name = IFACE_("Modal map, not yet"); } @@ -1237,7 +1237,7 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i } } } - else + else te->flag |= TE_LAZY_CLOSED; } @@ -1312,25 +1312,25 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE TreeElement *ten; ListBase *lbarray[MAX_LIBARRAY]; int a, tot; - + tot = set_listbasepointers(mainvar, lbarray); for (a = 0; a < tot; a++) { if (lbarray[a]->first) { ID *id = lbarray[a]->first; - + /* check if there's data in current lib */ for (; id; id = id->next) if (id->lib == lib) break; - + if (id) { ten = outliner_add_element(soops, &te->subtree, lbarray[a], NULL, TSE_ID_BASE, 0); ten->directdata = lbarray[a]; - + ten->name = BKE_idcode_to_name_plural(GS(id->name)); if (ten->name == NULL) ten->name = "UNKNOWN"; - + for (id = lbarray[a]->first; id; id = id->next) { if (id->lib == lib) outliner_add_element(soops, &ten->subtree, id, ten, 0, 0); @@ -1338,7 +1338,7 @@ static void outliner_add_library_contents(Main *mainvar, SpaceOops *soops, TreeE } } } - + } static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) @@ -1346,18 +1346,18 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) TreeElement *ten; ListBase *lbarray[MAX_LIBARRAY]; int a, tot; - + tot = set_listbasepointers(mainvar, lbarray); for (a = 0; a < tot; a++) { if (lbarray[a]->first) { ID *id = lbarray[a]->first; - + /* check if there are any datablocks of this type which are orphans */ for (; id; id = id->next) { if (ID_REAL_USERS(id) <= 0) break; } - + if (id) { /* header for this type of datablock */ /* TODO's: @@ -1366,11 +1366,11 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) */ ten = outliner_add_element(soops, &soops->tree, lbarray[a], NULL, TSE_ID_BASE, 0); ten->directdata = lbarray[a]; - + ten->name = BKE_idcode_to_name_plural(GS(id->name)); if (ten->name == NULL) ten->name = "UNKNOWN"; - + /* add the orphaned datablocks - these will not be added with any subtrees attached */ for (id = lbarray[a]->first; id; id = id->next) { if (ID_REAL_USERS(id) <= 0) @@ -1398,7 +1398,7 @@ static void outliner_make_hierarchy(ListBase *lb) while (te) { ten = te->next; tselem = TREESTORE(te); - + if (tselem->type == 0 && te->idcode == ID_OB) { Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { @@ -1427,16 +1427,16 @@ static int treesort_alpha_ob(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; int comp; - + /* first put objects last (hierarchy) */ comp = (x1->idcode == ID_OB); if (x2->idcode == ID_OB) comp += 2; - + if (comp == 1) return 1; else if (comp == 2) return -1; else if (comp == 3) { comp = strcmp(x1->name, x2->name); - + if (comp > 0) return 1; else if (comp < 0) return -1; return 0; @@ -1449,9 +1449,9 @@ static int treesort_alpha(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; int comp; - + comp = strcmp(x1->name, x2->name); - + if (comp > 0) return 1; else if (comp < 0) return -1; return 0; @@ -1463,7 +1463,7 @@ static int treesort_alpha(const void *v1, const void *v2) static int treesort_obtype_alpha(const void *v1, const void *v2) { const tTreeSort *x1 = v1, *x2 = v2; - + /* first put objects last (hierarchy) */ if (x1->idcode == ID_OB && x2->idcode != ID_OB) { return 1; @@ -1480,7 +1480,7 @@ static int treesort_obtype_alpha(const void *v1, const void *v2) } else { int comp = strcmp(x1->name, x2->name); - + if (comp > 0) return 1; else if (comp < 0) return -1; return 0; @@ -1499,13 +1499,13 @@ static void outliner_sort(ListBase *lb) te = lb->last; if (te == NULL) return; tselem = TREESTORE(te); - + /* sorting rules; only object lists, ID lists, or deformgroups */ if ( ELEM(tselem->type, TSE_DEFGROUP, TSE_ID_BASE) || (tselem->type == 0 && te->idcode == ID_OB)) { - + /* count first */ for (te = lb->first; te; te = te->next) totelem++; - + if (totelem > 1) { tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); tTreeSort *tp = tear; @@ -1516,15 +1516,15 @@ static void outliner_sort(ListBase *lb) tp->te = te; tp->name = te->name; tp->idcode = te->idcode; - + if (tselem->type && tselem->type != TSE_DEFGROUP) tp->idcode = 0; // don't sort this if (tselem->type == TSE_ID_BASE) tp->idcode = 1; // do sort this - + tp->id = tselem->id; } - + /* just sort alphabetically */ if (tear->idcode == 1) { qsort(tear, totelem, sizeof(tTreeSort), treesort_alpha); @@ -1533,11 +1533,11 @@ static void outliner_sort(ListBase *lb) /* keep beginning of list */ for (tp = tear, skip = 0; skip < totelem; skip++, tp++) if (tp->idcode) break; - + if (skip < totelem) qsort(tear + skip, totelem - skip, sizeof(tTreeSort), treesort_alpha_ob); } - + BLI_listbase_clear(lb); tp = tear; while (totelem--) { @@ -1547,7 +1547,7 @@ static void outliner_sort(ListBase *lb) MEM_freeN(tear); } } - + for (te = lb->first; te; te = te->next) { outliner_sort(&te->subtree); } @@ -1572,7 +1572,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) char search_buff[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; char *search_string; - /* although we don't have any search string, we return true + /* although we don't have any search string, we return true * since the entire tree is ok then... */ if (soops->search_string[0] == 0) @@ -1589,7 +1589,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) for (te = lb->first; te; te = ten) { ten = te->next; - + if (!outliner_filter_has_name(te, search_string, soops->search_flags)) { /* item isn't something we're looking for, but... * - if the subtree is expanded, check if there are any matches that can be easily found @@ -1598,29 +1598,29 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) * so these can be safely ignored (i.e. the subtree can get freed) */ tselem = TREESTORE(te); - + /* flag as not a found item */ tselem->flag &= ~TSE_SEARCHMATCH; - + if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree) == 0) { outliner_free_tree(&te->subtree); BLI_remlink(lb, te); - + if (te->flag & TE_FREE_NAME) MEM_freeN((void *)te->name); MEM_freeN(te); } } else { tselem = TREESTORE(te); - + /* flag as a found item - we can then highlight it */ tselem->flag |= TSE_SEARCHMATCH; - + /* filter subtree too */ outliner_filter_tree(soops, &te->subtree); } } - + /* if there are still items in the list, that means that there were still some matches */ return (BLI_listbase_is_empty(lb) == false); } @@ -1655,11 +1655,11 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) outliner_free_tree(&soops->tree); outliner_storage_cleanup(soops); - + /* options */ if (soops->outlinevis == SO_LIBRARIES) { Library *lib; - + /* current file first - mainvar provides tselem with unique pointer - not used */ ten = outliner_add_element(soops, &soops->tree, mainvar, NULL, TSE_ID_BASE, 0); ten->name = IFACE_("Current File"); @@ -1667,13 +1667,13 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) tselem = TREESTORE(ten); if (!tselem->used) tselem->flag &= ~TSE_CLOSED; - + outliner_add_library_contents(mainvar, soops, ten, NULL); - + for (lib = mainvar->library.first; lib; lib = lib->id.next) { ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); lib->id.newid = (ID *)ten; - + outliner_add_library_contents(mainvar, soops, ten, lib); } @@ -1704,7 +1704,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) /* restore newid pointers */ for (lib = mainvar->library.first; lib; lib = lib->id.next) lib->id.newid = NULL; - + } else if (soops->outlinevis == SO_ALL_SCENES) { Scene *sce; @@ -1713,7 +1713,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) tselem = TREESTORE(te); if (sce == scene && show_opened) tselem->flag &= ~TSE_CLOSED; - + for (base = sce->base.first; base; base = base->next) { ten = outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); ten->directdata = base; @@ -1724,9 +1724,9 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) } } else if (soops->outlinevis == SO_CUR_SCENE) { - + outliner_add_scene_contents(soops, &soops->tree, scene, NULL); - + for (base = scene->base.first; base; base = base->next) { ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); ten->directdata = base; @@ -1743,11 +1743,11 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) else if (soops->outlinevis == SO_GROUPS) { Group *group; GroupObject *go; - + for (group = mainvar->group.first; group; group = group->id.next) { if (group->gobject.first) { te = outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - + for (go = group->gobject.first; go; go = go->next) { ten = outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); ten->directdata = NULL; /* eh, why? */ diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index cb6d67390a0..0cf4fd09555 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -66,7 +66,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) { ListBase *lb; wmKeyMap *keymap; - + /* make sure we keep the hide flags */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.scroll &= ~(V2D_SCROLL_LEFT | V2D_SCROLL_TOP); /* prevent any noise of past */ @@ -79,7 +79,7 @@ static void outliner_main_region_init(wmWindowManager *wm, ARegion *ar) ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */ @@ -270,16 +270,16 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) { View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - + /* clear */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + draw_outliner(C); - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -289,7 +289,7 @@ static void outliner_main_region_draw(const bContext *C, ARegion *ar) static void outliner_main_region_free(ARegion *UNUSED(ar)) { - + } static void outliner_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn) @@ -393,7 +393,7 @@ static void outliner_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(s ED_region_tag_redraw(ar); break; } - + } @@ -438,20 +438,20 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C)) soutliner = MEM_callocN(sizeof(SpaceOops), "initoutliner"); soutliner->spacetype = SPACE_OUTLINER; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for outliner"); - + BLI_addtail(&soutliner->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for outliner"); - + BLI_addtail(&soutliner->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + return (SpaceLink *)soutliner; } @@ -459,7 +459,7 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C)) static void outliner_free(SpaceLink *sl) { SpaceOops *soutliner = (SpaceOops *)sl; - + outliner_free_tree(&soutliner->tree); if (soutliner->treestore) { BLI_mempool_destroy(soutliner->treestore); @@ -472,7 +472,7 @@ static void outliner_free(SpaceLink *sl) /* spacetype; init callback */ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) { - + } static SpaceLink *outliner_duplicate(SpaceLink *sl) @@ -483,7 +483,7 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) BLI_listbase_clear(&soutlinern->tree); soutlinern->treestore = NULL; soutlinern->treehash = NULL; - + return (SpaceLink *)soutlinern; } @@ -525,10 +525,10 @@ void ED_spacetype_outliner(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - + st->spaceid = SPACE_OUTLINER; strncpy(st->name, "Outliner", BKE_ST_MAXNAME); - + st->new = outliner_new; st->free = outliner_free; st->init = outliner_init; @@ -542,25 +542,25 @@ void ED_spacetype_outliner(void) art = MEM_callocN(sizeof(ARegionType), "spacetype outliner region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; - + art->init = outliner_main_region_init; art->draw = outliner_main_region_draw; art->free = outliner_main_region_free; art->listener = outliner_main_region_listener; BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype outliner header region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - + art->init = outliner_header_region_init; art->draw = outliner_header_region_draw; art->free = outliner_header_region_free; art->listener = outliner_header_region_listener; BLI_addhead(&st->regiontypes, art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index 9134b8fd5d7..cd77e3032f1 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -66,33 +66,33 @@ static SpaceLink *script_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceScript *sscript; - + sscript = MEM_callocN(sizeof(SpaceScript), "initscript"); sscript->spacetype = SPACE_SCRIPT; - - + + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for script"); - + BLI_addtail(&sscript->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for script"); - + BLI_addtail(&sscript->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + /* channel list region XXX */ - + return (SpaceLink *)sscript; } /* not spacelink itself */ static void script_free(SpaceLink *sl) -{ +{ SpaceScript *sscript = (SpaceScript *) sl; #ifdef WITH_PYTHON @@ -116,9 +116,9 @@ static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *script_duplicate(SpaceLink *sl) { SpaceScript *sscriptn = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ - + return (SpaceLink *)sscriptn; } @@ -128,9 +128,9 @@ static SpaceLink *script_duplicate(SpaceLink *sl) static void script_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Script", SPACE_SCRIPT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -145,12 +145,12 @@ static void script_main_region_draw(const bContext *C, ARegion *ar) /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* data... */ // BPY_script_exec(C, "/root/blender-svn/blender25/test.py", NULL); - + #ifdef WITH_PYTHON if (sscript->script) { // BPY_run_script_space_draw(C, sscript); @@ -158,10 +158,10 @@ static void script_main_region_draw(const bContext *C, ARegion *ar) #else (void)sscript; #endif - + /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers? */ } @@ -188,17 +188,17 @@ void ED_spacetype_script(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype script"); ARegionType *art; - + st->spaceid = SPACE_SCRIPT; strncpy(st->name, "Script", BKE_ST_MAXNAME); - + st->new = script_new; st->free = script_free; st->init = script_init; st->duplicate = script_duplicate; st->operatortypes = script_operatortypes; st->keymap = script_keymap; - + /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype script region"); art->regionid = RGN_TYPE_WINDOW; @@ -208,19 +208,19 @@ void ED_spacetype_script(void) art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_UI | ED_KEYMAP_FRAMES; // XXX need to further test this ED_KEYMAP_UI is needed for button interaction BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype script region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; - + art->init = script_header_region_init; art->draw = script_header_region_draw; - + BLI_addhead(&st->regiontypes, art); - - + + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 8315a0eab3d..98370ea9dee 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -95,12 +95,12 @@ static void sequencer_generic_props__internal(wmOperatorType *ot, int flag) if (flag & SEQPROP_STARTFRAME) RNA_def_int(ot->srna, "frame_start", 0, INT_MIN, INT_MAX, "Start Frame", "Start frame of the sequence strip", INT_MIN, INT_MAX); - + if (flag & SEQPROP_ENDFRAME) RNA_def_int(ot->srna, "frame_end", 0, INT_MIN, INT_MAX, "End Frame", "End frame for the color strip", INT_MIN, INT_MAX); /* not usual since most strips have a fixed length */ - + RNA_def_int(ot->srna, "channel", 1, 1, MAXSEQ, "Channel", "Channel to place this strip into", 1, MAXSEQ); - + RNA_def_boolean(ot->srna, "replace_sel", 1, "Replace Selection", "Replace the current selection"); /* only for python scripts which import strips and place them after */ @@ -145,7 +145,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type) proximity = cfra - seq->enddisp; } } - + if (tgt) { return tgt->machine; } @@ -155,16 +155,16 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type) static void sequencer_generic_invoke_xy__internal(bContext *C, wmOperator *op, int flag, int type) { Scene *scene = CTX_data_scene(C); - + int cfra = (int) CFRA; - + /* effect strips don't need a channel initialized from the mouse */ if (!(flag & SEQPROP_NOCHAN)) { RNA_int_set(op->ptr, "channel", sequencer_generic_invoke_xy_guess_channel(C, type)); } RNA_int_set(op->ptr, "frame_start", cfra); - + if ((flag & SEQPROP_ENDFRAME) && RNA_struct_property_is_set(op->ptr, "frame_end") == 0) RNA_int_set(op->ptr, "frame_end", cfra + 25); // XXX arbitary but ok for now. @@ -201,7 +201,7 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato if ((is_file != -1) && relative) BLI_path_rel(seq_load->path, bmain->name); - + if ((prop = RNA_struct_find_property(op->ptr, "frame_end"))) { seq_load->end_frame = RNA_property_int_get(op->ptr, prop); } @@ -217,7 +217,7 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, bContext *C, wmOperato if ((prop = RNA_struct_find_property(op->ptr, "sound")) && RNA_property_boolean_get(op->ptr, prop)) seq_load->flag |= SEQ_LOAD_MOVIE_SOUND; - + if ((prop = RNA_struct_find_property(op->ptr, "use_framerate")) && RNA_property_boolean_get(op->ptr, prop)) seq_load->flag |= SEQ_LOAD_SYNC_FPS; @@ -286,35 +286,35 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - + Scene *sce_seq; Sequence *seq; /* generic strip vars */ Strip *strip; - + int start_frame, channel; /* operator props */ - + start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - + sce_seq = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); - + if (sce_seq == NULL) { BKE_report(op->reports, RPT_ERROR, "Scene not found"); return OPERATOR_CANCELLED; } - + seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel); seq->type = SEQ_TYPE_SCENE; seq->blend_mode = SEQ_TYPE_CROSS; /* so alpha adjustment fade to the strip below */ seq->scene = sce_seq; - + /* basic defaults */ seq->strip = strip = MEM_callocN(sizeof(Strip), "strip"); seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1; strip->us = 1; - + BLI_strncpy(seq->name + 2, sce_seq->id.name + 2, sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); @@ -322,12 +322,12 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) BKE_sequence_calc_disp(scene, seq); BKE_sequencer_sort(scene); - + sequencer_add_apply_replace_sel(C, op, seq); sequencer_add_apply_overlap(C, op, seq); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } @@ -347,7 +347,7 @@ static int sequencer_add_scene_strip_invoke(bContext *C, wmOperator *op, const w void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) { PropertyRNA *prop; - + /* identifiers */ ot->name = "Add Scene Strip"; ot->idname = "SEQUENCER_OT_scene_strip_add"; @@ -358,10 +358,10 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) ot->exec = sequencer_add_scene_strip_exec; ot->poll = ED_operator_sequencer_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); RNA_def_enum_funcs(prop, RNA_scene_without_active_itemf); @@ -374,24 +374,24 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, true); - + MovieClip *clip; Sequence *seq; /* generic strip vars */ Strip *strip; - + int start_frame, channel; /* operator props */ - + start_frame = RNA_int_get(op->ptr, "frame_start"); channel = RNA_int_get(op->ptr, "channel"); - + clip = BLI_findlink(&CTX_data_main(C)->movieclip, RNA_enum_get(op->ptr, "clip")); - + if (clip == NULL) { BKE_report(op->reports, RPT_ERROR, "Movie clip not found"); return OPERATOR_CANCELLED; } - + seq = BKE_sequence_alloc(ed->seqbasep, start_frame, channel); seq->type = SEQ_TYPE_MOVIECLIP; seq->blend_mode = SEQ_TYPE_CROSS; @@ -403,18 +403,18 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) seq->strip = strip = MEM_callocN(sizeof(Strip), "strip"); seq->len = BKE_movieclip_get_duration(clip); strip->us = 1; - + BLI_strncpy(seq->name + 2, clip->id.name + 2, sizeof(seq->name) - 2); BKE_sequence_base_unique_name_recursive(&ed->seqbase, seq); BKE_sequence_calc_disp(scene, seq); BKE_sequencer_sort(scene); - + sequencer_add_apply_replace_sel(C, op, seq); sequencer_add_apply_overlap(C, op, seq); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } @@ -669,7 +669,7 @@ static int sequencer_add_movie_strip_invoke(bContext *C, wmOperator *op, const w sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_MOVIE); return sequencer_add_movie_strip_exec(C, op); } - + sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_MOVIE); sequencer_add_init(C, op); @@ -705,7 +705,7 @@ static void sequencer_add_draw(bContext *UNUSED(C), wmOperator *op) void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) { - + /* identifiers */ ot->name = "Add Movie Strip"; ot->idname = "SEQUENCER_OT_movie_strip_add"; @@ -721,7 +721,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_MOVIE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); @@ -746,7 +746,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const w sequencer_generic_invoke_xy__internal(C, op, SEQPROP_NOPATHS, SEQ_TYPE_SOUND_RAM); return sequencer_add_sound_strip_exec(C, op); } - + sequencer_generic_invoke_xy__internal(C, op, 0, SEQ_TYPE_SOUND_RAM); WM_event_add_fileselect(C, op); @@ -758,7 +758,7 @@ static int sequencer_add_sound_strip_invoke(bContext *C, wmOperator *op, const w void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) { - + /* identifiers */ ot->name = "Add Sound Strip"; ot->idname = "SEQUENCER_OT_sound_strip_add"; @@ -769,10 +769,10 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) ot->exec = sequencer_add_sound_strip_exec; ot->poll = ED_operator_sequencer_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_SOUND, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); @@ -928,7 +928,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, const w sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME | SEQPROP_NOPATHS, SEQ_TYPE_IMAGE); return sequencer_add_image_strip_exec(C, op); } - + sequencer_generic_invoke_xy__internal(C, op, SEQPROP_ENDFRAME, SEQ_TYPE_IMAGE); sequencer_add_init(C, op); @@ -944,7 +944,7 @@ static int sequencer_add_image_strip_invoke(bContext *C, wmOperator *op, const w void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) { - + /* identifiers */ ot->name = "Add Image Strip"; ot->idname = "SEQUENCER_OT_image_strip_add"; @@ -957,10 +957,10 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) ot->ui = sequencer_add_draw; ot->poll = ED_operator_sequencer_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_IMAGE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, FILE_SORT_ALPHA); @@ -981,7 +981,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) struct SeqEffectHandle sh; int start_frame, end_frame, channel, type; /* operator props */ - + Sequence *seq1, *seq2, *seq3; const char *error_msg; @@ -990,7 +990,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) channel = RNA_int_get(op->ptr, "channel"); type = RNA_enum_get(op->ptr, "type"); - + // XXX move to invoke if (!seq_effect_find_selected(scene, NULL, type, &seq1, &seq2, &seq3, &error_msg)) { BKE_report(op->reports, RPT_ERROR, error_msg); @@ -1026,7 +1026,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; BKE_sequence_calc(scene, seq); - + /* basic defaults */ seq->strip = strip = MEM_callocN(sizeof(Strip), "strip"); strip->us = 1; @@ -1064,7 +1064,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) /* not sure if this is needed with update_changed_seq_and_deps. * it was NOT called in blender 2.4x, but wont hurt */ - BKE_sequencer_sort(scene); + BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1108,10 +1108,10 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot) ot->exec = sequencer_add_effect_strip_exec; ot->poll = ED_operator_sequencer_active_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME); RNA_def_enum(ot->srna, "type", sequencer_prop_effect_types, SEQ_TYPE_CROSS, "Type", "Sequencer effect type"); RNA_def_float_vector(ot->srna, "color", 3, NULL, 0.0f, 1.0f, "Color", diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index b33a26db728..72f78d4f466 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -65,7 +65,7 @@ void sequencer_buttons_register(ARegionType *UNUSED(art)) { #if 0 PanelType *pt; - + pt = MEM_callocN(sizeof(PanelType), "spacetype sequencer panel gpencil"); strcpy(pt->idname, "SEQUENCER_PT_gpencil"); strcpy(pt->label, N_("Grease Pencil")); @@ -83,7 +83,7 @@ static int sequencer_properties_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = sequencer_has_buttons_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -95,10 +95,10 @@ void SEQUENCER_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->idname = "SEQUENCER_OT_properties"; ot->description = "Toggle the properties region visibility"; - + ot->exec = sequencer_properties_toggle_exec; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index c3a27dad538..7c32895afb4 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -125,12 +125,12 @@ void color3ubv_from_seq(Scene *curscene, Sequence *seq, unsigned char col[3]) case SEQ_TYPE_SCENE: UI_GetThemeColor3ubv(TH_SEQ_SCENE, col); - + if (seq->scene == curscene) { UI_GetColorPtrShade3ubv(col, col, 20); } break; - + /* transitions */ case SEQ_TYPE_CROSS: case SEQ_TYPE_GAMCROSS: @@ -210,14 +210,14 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc float startsample, endsample; float value1, value2; bSound *sound = seq->sound; - + SoundWaveform *waveform; - + if (!sound->spinlock) { sound->spinlock = MEM_mallocN(sizeof(SpinLock), "sound_spinlock"); BLI_spin_init(sound->spinlock); } - + BLI_spin_lock(sound->spinlock); if (!sound->waveform) { if (!(sound->flags & SOUND_FLAGS_WAVEFORM_LOADING)) { @@ -232,7 +232,7 @@ static void drawseqwave(const bContext *C, SpaceSeq *sseq, Scene *scene, Sequenc return; /* nothing to draw */ } BLI_spin_unlock(sound->spinlock); - + waveform = sound->waveform; if (waveform->length == 0) { @@ -287,7 +287,7 @@ static void drawmeta_stipple(int value) if (value) { GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_HALFTONE); - + glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x8888); } @@ -358,7 +358,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, color3ubv_from_seq(scene, seq, col); glColor4ubv(col); - + /* clamp within parent sequence strip bounds */ if (x1_chan < x1) x1_chan = x1; if (x2_chan > x2) x2_chan = x2; @@ -379,7 +379,7 @@ static void drawmeta_contents(Scene *scene, Sequence *seqm, float x1, float y1, if (seqm->flag & SEQ_MUTE) drawmeta_stipple(0); - + glDisable(GL_BLEND); } @@ -400,10 +400,10 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla float v1[2], v2[2], v3[2], rx1 = 0, rx2 = 0; //for triangles and rect float x1, x2, y1, y2; unsigned int whichsel = 0; - + x1 = seq->startdisp; x2 = seq->enddisp; - + y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; @@ -411,50 +411,50 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla if (direction == SEQ_LEFTHANDLE) { rx1 = x1; rx2 = x1 + handsize_clamped * 0.75f; - + v1[0] = x1 + handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); v2[0] = x1 + handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); v3[0] = v2[0] + handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; - + whichsel = SEQ_LEFTSEL; } else if (direction == SEQ_RIGHTHANDLE) { rx1 = x2 - handsize_clamped * 0.75f; rx2 = x2; - + v1[0] = x2 - handsize_clamped / 4; v1[1] = y1 + ( ((y1 + y2) / 2.0f - y1) / 2); v2[0] = x2 - handsize_clamped / 4; v2[1] = y2 - ( ((y1 + y2) / 2.0f - y1) / 2); v3[0] = v2[0] - handsize_clamped / 4; v3[1] = (y1 + y2) / 2.0f; - + whichsel = SEQ_RIGHTSEL; } - + /* draw! */ if (!(seq->type & SEQ_TYPE_EFFECT) || BKE_sequence_effect_get_num_inputs(seq->type) == 0) { glEnable(GL_BLEND); - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + if (seq->flag & whichsel) glColor4ub(0, 0, 0, 80); else if (seq->flag & SELECT) glColor4ub(255, 255, 255, 30); else glColor4ub(0, 0, 0, 22); - + glRectf(rx1, y1, rx2, y2); - + if (seq->flag & whichsel) glColor4ub(255, 255, 255, 200); else glColor4ub(0, 0, 0, 50); - + glEnable(GL_POLYGON_SMOOTH); glBegin(GL_TRIANGLES); glVertex2fv(v1); glVertex2fv(v2); glVertex2fv(v3); glEnd(); - + glDisable(GL_POLYGON_SMOOTH); glDisable(GL_BLEND); } - + if ((G.moving & G_TRANSFORM_SEQ) || (seq->flag & whichsel)) { const char col[4] = {255, 255, 255, 255}; char numstr[32]; @@ -570,7 +570,7 @@ static void draw_seq_text(View2D *v2d, SpaceSeq *sseq, Sequence *seq, float x1, str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } - + if (seq->flag & SELECT) { col[0] = col[1] = col[2] = 255; } @@ -594,23 +594,23 @@ static void draw_seq_text(View2D *v2d, SpaceSeq *sseq, Sequence *seq, float x1, void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, float x2, float y2) { float ymid1, ymid2; - + if (seq->flag & SEQ_MUTE) { GPU_basic_shader_bind(GPU_SHADER_STIPPLE | GPU_SHADER_USE_COLOR); GPU_basic_shader_stipple(GPU_SHADER_STIPPLE_HALFTONE); } - + ymid1 = (y2 - y1) * 0.25f + y1; ymid2 = (y2 - y1) * 0.65f + y1; - + glBegin(GL_QUADS); - + if (seq->flag & SEQ_INVALID_EFFECT) { col[0] = 255; col[1] = 0; col[2] = 255; } else if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -50); /* else UI_GetColorPtrShade3ubv(col, col, 0); */ /* DO NOTHING */ - + glColor3ubv(col); - + glVertex2f(x1, y1); glVertex2f(x2, y1); @@ -619,29 +619,29 @@ void draw_shadedstrip(Sequence *seq, unsigned char col[3], float x1, float y1, f else UI_GetColorPtrShade3ubv(col, col, -5); glColor3ubv((GLubyte *)col); - + glVertex2f(x2, ymid1); glVertex2f(x1, ymid1); - + glEnd(); - + glRectf(x1, ymid1, x2, ymid2); - + glBegin(GL_QUADS); - + glVertex2f(x1, ymid2); glVertex2f(x2, ymid2); - + if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, -15); else UI_GetColorPtrShade3ubv(col, col, 25); - + glColor3ubv((GLubyte *)col); - + glVertex2f(x2, y2); glVertex2f(x1, y2); - + glEnd(); - + if (seq->flag & SEQ_MUTE) { GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } @@ -652,25 +652,25 @@ void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq) float x1, x2, y1, y2, pixely, a; unsigned char col[3], blendcol[3]; View2D *v2d = &ar->v2d; - + x1 = seq->startdisp; x2 = seq->enddisp; - + y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; y2 = seq->machine + SEQ_STRIP_OFSTOP; - + pixely = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); - + if (pixely <= 0) return; /* can happen when the view is split/resized */ - + blendcol[0] = blendcol[1] = blendcol[2] = 120; - + if (seq->startofs) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + color3ubv_from_seq(scene, seq, col); - + if (seq->flag & SELECT) { UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40); glColor4ub(col[0], col[1], col[2], 170); @@ -679,22 +679,22 @@ void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0); glColor4ub(col[0], col[1], col[2], 110); } - + glRectf((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); - + if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255); else glColor4ub(col[0], col[1], col[2], 160); - + fdrawbox((float)(seq->start), y1 - SEQ_STRIP_OFSBOTTOM, x1, y1); //outline - + glDisable(GL_BLEND); } if (seq->endofs) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + color3ubv_from_seq(scene, seq, col); - + if (seq->flag & SELECT) { UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.3, -40); glColor4ub(col[0], col[1], col[2], 170); @@ -703,30 +703,30 @@ void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq) UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.6, 0); glColor4ub(col[0], col[1], col[2], 110); } - + glRectf(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); - + if (seq->flag & SELECT) glColor4ub(col[0], col[1], col[2], 255); else glColor4ub(col[0], col[1], col[2], 160); - + fdrawbox(x2, y2, (float)(seq->start + seq->len), y2 + SEQ_STRIP_OFSBOTTOM); //outline - + glDisable(GL_BLEND); } if (seq->startstill) { color3ubv_from_seq(scene, seq, col); UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40); glColor3ubv((GLubyte *)col); - + draw_shadedstrip(seq, col, x1, y1, (float)(seq->start), y2); - + /* feint pinstripes, helps see exactly which is extended and which isn't, * especially when the extension is very small */ if (seq->flag & SELECT) UI_GetColorPtrBlendShade3ubv(col, col, col, 0.0, 24); else UI_GetColorPtrShade3ubv(col, col, -16); - + glColor3ubv((GLubyte *)col); - + for (a = y1; a < y2; a += pixely * 2.0f) { fdrawline(x1, a, (float)(seq->start), a); } @@ -735,16 +735,16 @@ void draw_sequence_extensions(Scene *scene, ARegion *ar, Sequence *seq) color3ubv_from_seq(scene, seq, col); UI_GetColorPtrBlendShade3ubv(col, blendcol, col, 0.75, 40); glColor3ubv((GLubyte *)col); - + draw_shadedstrip(seq, col, (float)(seq->start + seq->len), y1, x2, y2); - + /* feint pinstripes, helps see exactly which is extended and which isn't, * especially when the extension is very small */ if (seq->flag & SELECT) UI_GetColorPtrShade3ubv(col, col, 24); else UI_GetColorPtrShade3ubv(col, col, -16); - + glColor3ubv((GLubyte *)col); - + for (a = y1; a < y2; a += pixely * 2.0f) { fdrawline((float)(seq->start + seq->len), a, x2, a); } @@ -766,7 +766,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg /* we need to know if this is a single image/color or not for drawing */ is_single_image = (char)BKE_sequence_single_check(seq); - + /* body */ x1 = (seq->startstill) ? seq->start : seq->startdisp; y1 = seq->machine + SEQ_STRIP_OFSBOTTOM; @@ -777,7 +777,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg /* get the correct color per strip type*/ //color3ubv_from_seq(scene, seq, col); color3ubv_from_seq(scene, seq, background_col); - + /* draw the main strip body */ if (is_single_image) { /* single image */ draw_shadedstrip(seq, background_col, @@ -796,11 +796,11 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg draw_seq_handle(v2d, seq, handsize_clamped, SEQ_LEFTHANDLE); draw_seq_handle(v2d, seq, handsize_clamped, SEQ_RIGHTHANDLE); - + /* draw the strip outline */ x1 = seq->startdisp; x2 = seq->enddisp; - + /* draw sound wave */ if (seq->type == SEQ_TYPE_SOUND_RAM) { if (!(sseq->flag & SEQ_NO_WAVEFORMS)) { @@ -848,7 +848,7 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg } else UI_GetColorPtrShade3ubv(col, col, outline_tint); - + if ((seq->type == SEQ_TYPE_META) || ((seq->type == SEQ_TYPE_SCENE) && (seq->flag & SEQ_SCENE_STRIPS))) { @@ -859,15 +859,15 @@ static void draw_seq_strip(const bContext *C, SpaceSeq *sseq, Scene *scene, AReg glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0x8888); } - + glColor3ubv((GLubyte *)col); - + UI_draw_roundbox_shade_x(GL_LINE_LOOP, x1, y1, x2, y2, 0.0, 0.1, 0.0); - + if (seq->flag & SEQ_MUTE) { glDisable(GL_LINE_STIPPLE); } - + /* calculate if seq is long enough to print a name */ x1 = seq->startdisp + handsize_clamped; x2 = seq->enddisp - handsize_clamped; @@ -997,7 +997,7 @@ static ImBuf *sequencer_make_scope(Scene *scene, ImBuf *ibuf, ImBuf *(*make_scop { ImBuf *display_ibuf = IMB_dupImBuf(ibuf); ImBuf *scope; - + IMB_colormanagement_imbuf_make_display_space(display_ibuf, &scene->view_settings, &scene->display_settings); @@ -1457,7 +1457,7 @@ void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq) { int rectx, recty; int render_size = sseq->render_size; - int proxy_size = 100.0; + int proxy_size = 100.0; if (render_size == 0) { render_size = scene->r.size; } @@ -1483,7 +1483,7 @@ void drawprefetchseqspace(Scene *scene, ARegion *UNUSED(ar), SpaceSeq *sseq) static void draw_seq_backdrop(View2D *v2d) { int i; - + /* darker gray overlay over the view backdrop */ UI_ThemeColorShade(TH_BACK, -20); glRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0); @@ -1497,7 +1497,7 @@ static void draw_seq_backdrop(View2D *v2d) UI_ThemeColorShade(TH_BACK, -15); else UI_ThemeColorShade(TH_BACK, -25); - + glVertex2f(v2d->cur.xmax, i); glVertex2f(v2d->cur.xmin, i); glVertex2f(v2d->cur.xmin, i + 1); @@ -1506,16 +1506,16 @@ static void draw_seq_backdrop(View2D *v2d) i += 1.0; } glEnd(); - + /* Darker lines separating the horizontal bands */ i = max_ii(1, ((int)v2d->cur.ymin) - 1); UI_ThemeColor(TH_GRID); - + glBegin(GL_LINES); while (i < v2d->cur.ymax) { glVertex2f(v2d->cur.xmax, i); glVertex2f(v2d->cur.xmin, i); - + i += 1.0; } glEnd(); @@ -1530,12 +1530,12 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) Sequence *last_seq = BKE_sequencer_active_get(scene); int sel = 0, j; float pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); - + /* loop through twice, first unselected, then selected */ for (j = 0; j < 2; j++) { Sequence *seq; int outline_tint = (j) ? -60 : -150; /* highlighting around strip edges indicating selection */ - + /* loop through strips, checking for those that are visible */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { /* boundbox and selection tests for NOT drawing the strip... */ @@ -1545,15 +1545,15 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue; else if (seq->machine + 1.0f < v2d->cur.ymin) continue; else if (seq->machine > v2d->cur.ymax) continue; - + /* strip passed all tests unscathed... so draw it now */ draw_seq_strip(C, sseq, scene, ar, seq, outline_tint, pixelx); } - + /* draw selected next time round */ sel = SELECT; } - + /* draw the last selected last (i.e. 'active' in other parts of Blender), removes some overlapping error */ if (last_seq) draw_seq_strip(C, sseq, scene, ar, last_seq, 120, pixelx); @@ -1575,8 +1575,8 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) const int frame_end = PEFRA + 1; glEnable(GL_BLEND); - - /* draw darkened area outside of active timeline + + /* draw darkened area outside of active timeline * frame range used is preview range or scene range */ UI_ThemeColorShadeAlpha(TH_BACK, -25, -100); @@ -1618,27 +1618,27 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) View2DScrollers *scrollers; short unit = 0, flag = 0; float col[3]; - + /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); - if (ed && ed->metastack.first) + if (ed && ed->metastack.first) glClearColor(col[0], col[1], col[2] - 0.1f, 0.0f); - else + else glClearColor(col[0], col[1], col[2], 0.0f); glClear(GL_COLOR_BUFFER_BIT); UI_view2d_view_ortho(v2d); - - - /* calculate extents of sequencer strips/data + + + /* calculate extents of sequencer strips/data * NOTE: needed for the scrollers later */ boundbox_seq(scene, &v2d->tot); - - + + /* draw backdrop */ draw_seq_backdrop(v2d); - + /* regular grid-pattern over the rest of the view (i.e. 1-second grid lines) */ UI_view2d_constant_grid_draw(v2d, FPS); @@ -1647,30 +1647,30 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) draw_image_seq(C, scene, ar, sseq, scene->r.cfra, 0, false, true); UI_view2d_view_ortho(v2d); } - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); - + seq_draw_sfra_efra(scene, v2d); /* sequence strips (if there is data available to be drawn) */ if (ed) { /* draw the data */ draw_seq_strips(C, ed, ar); - + /* text draw cached (for sequence names), in pixelspace now */ UI_view2d_text_cache_draw(ar); } - + /* current frame */ UI_view2d_view_ortho(v2d); if ((sseq->flag & SEQ_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS; if ((sseq->flag & SEQ_NO_DRAW_CFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); - + /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); ED_markers_draw(C, DRAW_MARKERS_LINES | DRAW_MARKERS_MARGIN); - + /* preview range */ UI_view2d_view_ortho(v2d); ANIM_draw_previewrange(C, v2d, 1); @@ -1687,7 +1687,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) glEnd(); } - + /* callback */ ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 1b0e20ec095..97ff55bf883 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -129,7 +129,7 @@ typedef struct TransSeq { /* ***************** proxy job manager ********************** */ typedef struct ProxyBuildJob { - Scene *scene; + Scene *scene; struct Main *main; ListBase queue; int stop; @@ -154,7 +154,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog struct SeqIndexBuildContext *context = link->data; BKE_sequencer_proxy_rebuild(context, stop, do_update, progress); - + if (*stop) { pj->stop = 1; fprintf(stderr, "Canceling proxy rebuild on users request...\n"); @@ -187,7 +187,7 @@ static void seq_proxy_build_job(const bContext *C) ScrArea *sa = CTX_wm_area(C); Sequence *seq; GSet *file_list; - + if (ed == NULL) { return; } @@ -199,7 +199,7 @@ static void seq_proxy_build_job(const bContext *C) if (!pj) { pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); - + pj->scene = scene; pj->main = CTX_data_main(C); @@ -218,7 +218,7 @@ static void seq_proxy_build_job(const bContext *C) SEQ_END BLI_gset_free(file_list, MEM_freeN); - + if (!WM_jobs_is_running(wm_job)) { G.is_break = false; WM_jobs_start(CTX_wm_manager(C), wm_job); @@ -245,7 +245,7 @@ void boundbox_seq(Scene *scene, rctf *rect) Editing *ed = BKE_sequencer_editing_get(scene, false); float min[2], max[2]; - + if (ed == NULL) return; min[0] = 0.0; @@ -274,18 +274,18 @@ static int mouse_frame_side(View2D *v2d, short mouse_x, int frame) { int mval[2]; float mouseloc[2]; - + mval[0] = mouse_x; mval[1] = 0; - + /* choose the side based on which side of the playhead the mouse is on */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &mouseloc[0], &mouseloc[1]); - + return mouseloc[0] > frame ? SEQ_SIDE_RIGHT : SEQ_SIDE_LEFT; } -Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel) +Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int sel) { /* sel - 0==unselected, 1==selected, -1==done care*/ Sequence *seq; @@ -294,7 +294,7 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se if (ed == NULL) return NULL; if (sel > 0) sel = SELECT; - + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq != test) && (test->machine == seq->machine) && @@ -317,16 +317,16 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se return NULL; } -static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel) +static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, int sel) { /* sel - 0==unselected, 1==selected, -1==done care*/ Sequence *seq, *best_seq = NULL; Editing *ed = BKE_sequencer_editing_get(scene, false); - + int dist, best_dist; best_dist = MAXFRAME * 2; - + if (ed == NULL) return NULL; seq = ed->seqbasep->first; @@ -337,7 +337,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i ((sel == -1) || (sel == (seq->flag & SELECT)))) { dist = MAXFRAME * 2; - + switch (lr) { case SEQ_SIDE_LEFT: if (seq->enddisp <= test->startdisp) { @@ -350,7 +350,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i } break; } - + if (dist == 0) { best_seq = seq; break; @@ -376,15 +376,15 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ float displen; *hand = SEQ_SIDE_NONE; - + if (ed == NULL) return NULL; - + pixelx = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); - + seq = ed->seqbasep->first; - + while (seq) { if (seq->machine == (int)y) { /* check for both normal strips, and strips that have been flipped horizontally */ @@ -392,23 +392,23 @@ Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[ ((seq->startdisp > seq->enddisp) && (seq->startdisp >= x && seq->enddisp <= x)) ) { if (BKE_sequence_tx_test(seq)) { - + /* clamp handles to defined size in pixel space */ - + handsize = seq->handsize; displen = (float)abs(seq->startdisp - seq->enddisp); - + if (displen / pixelx > 16) { /* don't even try to grab the handles of small strips */ /* Set the max value to handle to 1/3 of the total len when its less than 28. * This is important because otherwise selecting handles happens even when you click in the middle */ - + if ((displen / 3) < 30 * pixelx) { handsize = displen / 3; } else { CLAMP(handsize, 7 * pixelx, 30 * pixelx); } - + if (handsize + seq->startdisp >= x) *hand = SEQ_SIDE_LEFT; else if (-handsize + seq->enddisp <= x) @@ -446,7 +446,7 @@ void ED_sequencer_deselect_all(Scene *scene) Sequence *seq; Editing *ed = BKE_sequencer_editing_get(scene, false); - + if (ed == NULL) return; SEQP_BEGIN (ed, seq) @@ -454,7 +454,7 @@ void ED_sequencer_deselect_all(Scene *scene) seq->flag &= ~SEQ_ALLSEL; } SEQ_END - + } void recurs_sel_seq(Sequence *seqm) @@ -519,7 +519,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen { Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq; - + *error_str = NULL; if (!activeseq) @@ -550,7 +550,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen seq2 = seq3; seq3 = tmp; } - + switch (BKE_sequence_effect_get_num_inputs(type)) { case 0: @@ -572,12 +572,12 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen if (seq3 == NULL) seq3 = seq2; break; } - + if (seq1 == NULL && seq2 == NULL && seq3 == NULL) { *error_str = N_("TODO: in what cases does this happen?"); return 0; } - + *selseq1 = seq1; *selseq2 = seq2; *selseq3 = seq3; @@ -689,7 +689,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe) /* First Strip! */ /* strips with extended stillfames before */ - + /* Precaution, needed because the length saved on-disk may not match the length saved in the blend file, * or our code may have minor differences reading file length between versions. * This causes hard-cut to fail, see: T47862 */ @@ -731,7 +731,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe) skip_dup = true; } } - + BKE_sequence_reload_new_file(scene, seq, false); BKE_sequence_calc(scene, seq); @@ -739,7 +739,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe) /* Duplicate AFTER the first change */ seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } - + if (seqn) { seqn->flag |= SELECT; @@ -841,14 +841,14 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe) skip_dup = true; } } - + BKE_sequence_calc(scene, seq); if (!skip_dup) { /* Duplicate AFTER the first change */ seqn = BKE_sequence_dupli_recursive(scene, scene, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } - + if (seqn) { seqn->flag |= SELECT; @@ -902,14 +902,14 @@ static bool cut_seq_list(Scene *scene, ListBase *slist, int cutframe, { Sequence *seq, *seq_next_iter; Sequence *seq_first_new = NULL; - + seq = slist->first; while (seq && seq != seq_first_new) { seq_next_iter = seq->next; /* we need this because we may remove seq */ seq->tmp = NULL; if (seq->flag & SELECT) { - if (cutframe > seq->startdisp && + if (cutframe > seq->startdisp && cutframe < seq->enddisp) { Sequence *seqn = cut_seq(scene, seq, cutframe); @@ -947,7 +947,7 @@ static bool sequence_offset_after_frame(Scene *scene, const int delta, const int TimeMarker *marker; /* all strips >= cfra are shifted */ - + if (ed == NULL) return 0; for (seq = ed->seqbasep->first; seq; seq = seq->next) { @@ -975,7 +975,7 @@ static void set_filter_seq(Scene *scene) Sequence *seq; Editing *ed = BKE_sequencer_editing_get(scene, false); - + if (ed == NULL) return; if (okee("Set Deinterlace") == 0) return; @@ -1000,32 +1000,32 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene) Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); Editing *ed = BKE_sequencer_editing_get(scene, false); char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX]; - - + + if (last_seq == NULL) return; - + BLI_strncpy(from, last_seq->strip->dir, sizeof(from)); // XXX if (0 == sbutton(from, 0, sizeof(from) - 1, "From: ")) // return; - + BLI_strncpy(to, from, sizeof(to)); // XXX if (0 == sbutton(to, 0, sizeof(to) - 1, "To: ")) // return; - + if (STREQ(to, from)) return; - + SEQP_BEGIN (ed, seq) { if (seq->flag & SELECT) { if (STREQLEN(seq->strip->dir, from, strlen(from))) { printf("found %s\n", seq->strip->dir); - + /* strip off the beginning */ stripped[0] = 0; BLI_strncpy(stripped, seq->strip->dir + strlen(from), FILE_MAX); - + /* new path */ BLI_snprintf(seq->strip->dir, sizeof(seq->strip->dir), "%s%s", to, stripped); printf("new %s\n", seq->strip->dir); @@ -1033,7 +1033,7 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene *scene) } } SEQ_END - + } @@ -1049,7 +1049,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) boundbox_seq(scene, &rectf); sfra = (int)rectf.xmin; efra = (int)rectf.xmax; - + /* first check if the current frame has a gap already */ for (cfra = CFRA; cfra >= sfra; cfra--) { if (BKE_sequencer_evaluate_frame(scene, cfra)) { @@ -1074,7 +1074,7 @@ static int sequencer_gap_remove_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } @@ -1086,15 +1086,15 @@ void SEQUENCER_OT_gap_remove(struct wmOperatorType *ot) ot->name = "Remove Gaps"; ot->idname = "SEQUENCER_OT_gap_remove"; ot->description = "Remove gap at current frame to first strip at the right, independent of selection or locked state of strips"; - + /* api callbacks */ // ot->invoke = sequencer_snap_invoke; ot->exec = sequencer_gap_remove_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "all", 0, "All Gaps", "Do all gaps to right of current frame"); } @@ -1102,13 +1102,13 @@ static int sequencer_gap_insert_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); int frames = RNA_int_get(op->ptr, "frames"); - + sequence_offset_after_frame(scene, frames, CFRA); - + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; - + } void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot) @@ -1117,15 +1117,15 @@ void SEQUENCER_OT_gap_insert(struct wmOperatorType *ot) ot->name = "Insert Gaps"; ot->idname = "SEQUENCER_OT_gap_insert"; ot->description = "Insert gap at current frame to first strips at the right, independent of selection or locked state of strips"; - + /* api callbacks */ // ot->invoke = sequencer_snap_invoke; ot->exec = sequencer_gap_insert_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_int(ot->srna, "frames", 10, 0, INT_MAX, "Frames", "Frames to insert after current strip", 0, 1000); } @@ -1137,7 +1137,7 @@ static int seq_get_snaplimit(View2D *v2d) * a bit lazy but its only done once pre transform */ float xmouse, ymouse, x; int mval[2] = {24, 0}; /* 24 screen px snap */ - + UI_view2d_region_to_view(v2d, mval[0], mval[1], &xmouse, &ymouse); x = xmouse; mval[0] = 0; @@ -1190,7 +1190,7 @@ int sequencer_view_strips_poll(bContext *C) static int sequencer_snap_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - + Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq; int snap_frame; @@ -1232,31 +1232,31 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } } else if (seq->type & SEQ_TYPE_EFFECT) { - if (seq->seq1 && (seq->seq1->flag & SELECT)) + if (seq->seq1 && (seq->seq1->flag & SELECT)) BKE_sequence_calc(scene, seq); - else if (seq->seq2 && (seq->seq2->flag & SELECT)) + else if (seq->seq2 && (seq->seq2->flag & SELECT)) BKE_sequence_calc(scene, seq); - else if (seq->seq3 && (seq->seq3->flag & SELECT)) + else if (seq->seq3 && (seq->seq3->flag & SELECT)) BKE_sequence_calc(scene, seq); } } /* as last: */ BKE_sequencer_sort(scene); - + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } static int sequencer_snap_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); - + int snap_frame; - + snap_frame = CFRA; - + RNA_int_set(op->ptr, "frame", snap_frame); return sequencer_snap_exec(C, op); } @@ -1267,15 +1267,15 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot) ot->name = "Snap Strips to Frame"; ot->idname = "SEQUENCER_OT_snap"; ot->description = "Frame where selected strips will be snapped"; - + /* api callbacks */ ot->invoke = sequencer_snap_invoke; ot->exec = sequencer_snap_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will be snapped", INT_MIN, INT_MAX); } @@ -1729,7 +1729,7 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) bool selected; selected = !RNA_boolean_get(op->ptr, "unselected"); - + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->flag & SEQ_LOCK) == 0) { if (selected) { /* mute unselected */ @@ -1746,10 +1746,10 @@ static int sequencer_mute_exec(bContext *C, wmOperator *op) } } } - + BKE_sequencer_update_muting(ed); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } @@ -1759,14 +1759,14 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot) ot->name = "Mute Strips"; ot->idname = "SEQUENCER_OT_mute"; ot->description = "Mute (un)selected strips"; - + /* api callbacks */ ot->exec = sequencer_mute_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Mute unselected rather than selected strips"); } @@ -1780,7 +1780,7 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) bool selected; selected = !RNA_boolean_get(op->ptr, "unselected"); - + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->flag & SEQ_LOCK) == 0) { if (selected) { /* unmute unselected */ @@ -1797,10 +1797,10 @@ static int sequencer_unmute_exec(bContext *C, wmOperator *op) } } } - + BKE_sequencer_update_muting(ed); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } @@ -1810,14 +1810,14 @@ void SEQUENCER_OT_unmute(struct wmOperatorType *ot) ot->name = "Un-Mute Strips"; ot->idname = "SEQUENCER_OT_unmute"; ot->description = "Unmute (un)selected strips"; - + /* api callbacks */ ot->exec = sequencer_unmute_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Unmute unselected rather than selected strips"); } @@ -1846,11 +1846,11 @@ void SEQUENCER_OT_lock(struct wmOperatorType *ot) ot->name = "Lock Strips"; ot->idname = "SEQUENCER_OT_lock"; ot->description = "Lock the active strip so that it can't be transformed"; - + /* api callbacks */ ot->exec = sequencer_lock_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1879,11 +1879,11 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot) ot->name = "UnLock Strips"; ot->idname = "SEQUENCER_OT_unlock"; ot->description = "Unlock the active strip so that it can't be transformed"; - + /* api callbacks */ ot->exec = sequencer_unlock_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1921,11 +1921,11 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) ot->name = "Reload Strips"; ot->idname = "SEQUENCER_OT_reload"; ot->description = "Reload strips in the sequencer"; - + /* api callbacks */ ot->exec = sequencer_reload_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER; /* no undo, the data changed is stored outside 'main' */ @@ -1961,7 +1961,7 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot) ot->name = "Refresh Sequencer"; ot->idname = "SEQUENCER_OT_refresh_all"; ot->description = "Refresh the sequencer editor"; - + /* api callbacks */ ot->exec = sequencer_refresh_all_exec; ot->poll = sequencer_refresh_all_poll; @@ -2082,14 +2082,14 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) cut_frame = RNA_int_get(op->ptr, "frame"); cut_hard = RNA_enum_get(op->ptr, "type"); cut_side = RNA_enum_get(op->ptr, "side"); - + if (cut_hard == SEQ_CUT_HARD) { changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_hard); } else { changed = cut_seq_list(scene, ed->seqbasep, cut_frame, cut_seq_soft); } - + if (changed) { /* got new strips ? */ Sequence *seq; @@ -2142,7 +2142,7 @@ static int sequencer_cut_invoke(bContext *C, wmOperator *op, const wmEvent *even if (ED_operator_sequencer_active(C) && v2d) cut_side = mouse_frame_side(v2d, event->mval[0], cut_frame); - + RNA_int_set(op->ptr, "frame", cut_frame); RNA_enum_set(op->ptr, "side", cut_side); /*RNA_enum_set(op->ptr, "type", cut_hard); */ /*This type is set from the key shortcut */ @@ -2157,15 +2157,15 @@ void SEQUENCER_OT_cut(struct wmOperatorType *ot) ot->name = "Cut Strips"; ot->idname = "SEQUENCER_OT_cut"; ot->description = "Cut the selected strips"; - + /* api callbacks */ ot->invoke = sequencer_cut_invoke; ot->exec = sequencer_cut_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_int(ot->srna, "frame", 0, INT_MIN, INT_MAX, "Frame", "Frame where selected strips will be cut", INT_MIN, INT_MAX); RNA_def_enum(ot->srna, "type", prop_cut_types, SEQ_CUT_SOFT, "Type", "The type of cut operation to perform on strips"); RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_BOTH, "Side", "The side that remains selected after cutting"); @@ -2217,14 +2217,14 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) ot->name = "Duplicate Strips"; ot->idname = "SEQUENCER_OT_duplicate"; ot->description = "Duplicate the selected strips"; - + /* api callbacks */ ot->exec = sequencer_add_duplicate_exec; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* to give to transform */ RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", ""); } @@ -2285,7 +2285,7 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } @@ -2311,12 +2311,12 @@ void SEQUENCER_OT_delete(wmOperatorType *ot) ot->name = "Erase Strips"; ot->idname = "SEQUENCER_OT_delete"; ot->description = "Erase selected strips from the sequencer"; - + /* api callbacks */ ot->invoke = sequencer_delete_invoke; ot->exec = sequencer_delete_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2379,7 +2379,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); - + Sequence *seq, *seq_new; Strip *strip_new; StripElem *se, *se_new; @@ -2449,7 +2449,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) /* as last: */ BKE_sequencer_sort(scene); - + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); return OPERATOR_FINISHED; @@ -2462,12 +2462,12 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot) ot->name = "Separate Images"; ot->idname = "SEQUENCER_OT_images_separate"; ot->description = "On image sequence strips, it returns a strip for each image"; - + /* api callbacks */ ot->exec = sequencer_separate_images_exec; ot->invoke = WM_operator_props_popup_confirm; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2553,11 +2553,11 @@ void SEQUENCER_OT_meta_toggle(wmOperatorType *ot) ot->name = "Toggle Meta Strip"; ot->idname = "SEQUENCER_OT_meta_toggle"; ot->description = "Toggle a metastrip (to edit enclosed strips)"; - + /* api callbacks */ ot->exec = sequencer_meta_toggle_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2568,7 +2568,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); - + Sequence *seq, *seqm, *next, *last_seq = BKE_sequencer_active_get(scene); int channel_max = 1; @@ -2600,7 +2600,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seqm->strip = MEM_callocN(sizeof(Strip), "metastrip"); seqm->strip->us = 1; - + BKE_sequencer_active_set(scene, seqm); if (BKE_sequence_test_overlap(ed->seqbasep, seqm) ) BKE_sequence_base_shuffle(ed->seqbasep, seqm, scene); @@ -2620,11 +2620,11 @@ void SEQUENCER_OT_meta_make(wmOperatorType *ot) ot->name = "Make Meta Strip"; ot->idname = "SEQUENCER_OT_meta_make"; ot->description = "Group selected strips into a metastrip"; - + /* api callbacks */ ot->exec = sequencer_meta_make_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2693,11 +2693,11 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot) ot->name = "UnMeta Strip"; ot->idname = "SEQUENCER_OT_meta_separate"; ot->description = "Put the contents of a metastrip back in the sequencer"; - + /* api callbacks */ ot->exec = sequencer_meta_separate_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2719,11 +2719,11 @@ void SEQUENCER_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "SEQUENCER_OT_view_all"; ot->description = "View all the strips in the sequencer"; - + /* api callbacks */ ot->exec = sequencer_view_all_exec; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER; } @@ -2732,7 +2732,7 @@ static int sequencer_view_frame_exec(bContext *C, wmOperator *op) { const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); ANIM_center_frame(C, smooth_viewtx); - + return OPERATOR_FINISHED; } @@ -2742,11 +2742,11 @@ void SEQUENCER_OT_view_frame(wmOperatorType *ot) ot->name = "View Frame"; ot->idname = "SEQUENCER_OT_view_frame"; ot->description = "Reset viewable area to show range around current frame"; - + /* api callbacks */ ot->exec = sequencer_view_frame_exec; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2766,7 +2766,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) v2d->cur = v2d->tot; UI_view2d_curRect_validate(v2d); UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY); - + #if 0 /* Like zooming on an image view */ float zoomX, zoomY; @@ -2808,11 +2808,11 @@ void SEQUENCER_OT_view_all_preview(wmOperatorType *ot) ot->name = "View All"; ot->idname = "SEQUENCER_OT_view_all_preview"; ot->description = "Zoom preview to fit in the area"; - + /* api callbacks */ ot->exec = sequencer_view_all_preview_exec; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER; } @@ -2883,11 +2883,11 @@ void SEQUENCER_OT_view_toggle(wmOperatorType *ot) ot->name = "View Toggle"; ot->idname = "SEQUENCER_OT_view_toggle"; ot->description = "Toggle between sequencer views (sequence, preview, both)"; - + /* api callbacks */ ot->exec = sequencer_view_toggle_exec; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER; } @@ -2928,7 +2928,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op) if (ymax != 0) { const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); - + xmax += xmargin; xmin -= xmargin; ymax += ymargin; @@ -2957,7 +2957,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *op) else { return OPERATOR_CANCELLED; } - + } void SEQUENCER_OT_view_selected(wmOperatorType *ot) @@ -2966,11 +2966,11 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) ot->name = "View Selected"; ot->idname = "SEQUENCER_OT_view_selected"; ot->description = "Zoom the sequencer on the selected strips"; - + /* api callbacks */ ot->exec = sequencer_view_selected_exec; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER; } @@ -2982,7 +2982,7 @@ static bool strip_jump_internal(Scene *scene, bool changed = false; int cfra = CFRA; int nfra = BKE_sequencer_find_next_prev_edit(scene, cfra, side, do_skip_mute, do_center, false); - + if (nfra != cfra) { CFRA = nfra; changed = true; @@ -3013,7 +3013,7 @@ static int sequencer_strip_jump_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); - + return OPERATOR_FINISHED; } @@ -3030,7 +3030,7 @@ void SEQUENCER_OT_strip_jump(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "next", true, "Next Strip", ""); RNA_def_boolean(ot->srna, "center", true, "Use strip center", ""); @@ -3082,9 +3082,9 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) if (active_seq == NULL) return OPERATOR_CANCELLED; seq = find_next_prev_sequence(scene, active_seq, side, -1); - + if (seq) { - + /* disallow effect strips */ if (BKE_sequence_effect_get_num_inputs(seq->type) >= 1 && (seq->effectdata || seq->seq1 || seq->seq2 || seq->seq3)) return OPERATOR_CANCELLED; @@ -3092,10 +3092,10 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; switch (side) { - case SEQ_SIDE_LEFT: + case SEQ_SIDE_LEFT: swap_sequence(scene, seq, active_seq); break; - case SEQ_SIDE_RIGHT: + case SEQ_SIDE_RIGHT: swap_sequence(scene, active_seq, seq); break; } @@ -3135,14 +3135,14 @@ void SEQUENCER_OT_swap(wmOperatorType *ot) ot->name = "Swap Strip"; ot->idname = "SEQUENCER_OT_swap"; ot->description = "Swap active strip with strip to the right or left"; - + /* api callbacks */ ot->exec = sequencer_swap_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_enum(ot->srna, "side", prop_side_lr_types, SEQ_SIDE_RIGHT, "Side", "Side of the strip to swap"); } @@ -3194,14 +3194,14 @@ void SEQUENCER_OT_rendersize(wmOperatorType *ot) ot->name = "Set Render Size"; ot->idname = "SEQUENCER_OT_rendersize"; ot->description = "Set render size and aspect from active sequence"; - + /* api callbacks */ ot->exec = sequencer_rendersize_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ } @@ -3484,13 +3484,13 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq; GSet *file_list; - + if (ed == NULL) { return OPERATOR_CANCELLED; } file_list = BLI_gset_new(BLI_ghashutil_strhash_p, BLI_ghashutil_strcmp, "file list"); - + SEQP_BEGIN(ed, seq) { if ((seq->flag & SELECT)) { @@ -3512,7 +3512,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) SEQ_END BLI_gset_free(file_list, MEM_freeN); - + return OPERATOR_FINISHED; } @@ -3522,11 +3522,11 @@ void SEQUENCER_OT_rebuild_proxy(wmOperatorType *ot) ot->name = "Rebuild Proxy and Timecode Indices"; ot->idname = "SEQUENCER_OT_rebuild_proxy"; ot->description = "Rebuild all selected proxies and timecode indices using the job system"; - + /* api callbacks */ ot->invoke = sequencer_rebuild_proxy_invoke; ot->exec = sequencer_rebuild_proxy_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER; } @@ -3563,27 +3563,27 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) if (proxy_25) seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_25; - else + else seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_25; - + if (proxy_50) seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_50; - else + else seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_50; - + if (proxy_75) seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_75; - else + else seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_75; - + if (proxy_100) seq->strip->proxy->build_size_flags |= SEQ_PROXY_IMAGE_SIZE_100; - else + else seq->strip->proxy->build_size_flags &= ~SEQ_PROXY_IMAGE_SIZE_100; - + if (!overwrite) seq->strip->proxy->build_flags |= SEQ_PROXY_SKIP_EXISTING; - else + else seq->strip->proxy->build_flags &= ~SEQ_PROXY_SKIP_EXISTING; } } @@ -3591,7 +3591,7 @@ static int sequencer_enable_proxies_exec(bContext *C, wmOperator *op) SEQ_END WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); - + return OPERATOR_FINISHED; } @@ -3601,14 +3601,14 @@ void SEQUENCER_OT_enable_proxies(wmOperatorType *ot) ot->name = "Set Selected Strip Proxies"; ot->idname = "SEQUENCER_OT_enable_proxies"; ot->description = "Enable selected proxies on all selected Movie strips"; - + /* api callbacks */ ot->invoke = sequencer_enable_proxies_invoke; ot->exec = sequencer_enable_proxies_exec; - + /* flags */ ot->flag = OPTYPE_REGISTER; - + RNA_def_boolean(ot->srna, "proxy_25", false, "25%", ""); RNA_def_boolean(ot->srna, "proxy_50", false, "50%", ""); RNA_def_boolean(ot->srna, "proxy_75", false, "75%", ""); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 04c9cd6fa54..713aa8994b3 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -175,7 +175,7 @@ enum { SEQ_SELECT_LR_NONE = 0, SEQ_SELECT_LR_MOUSE, SEQ_SELECT_LR_LEFT, - SEQ_SELECT_LR_RIGHT + SEQ_SELECT_LR_RIGHT }; /* defines used internally */ diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index a3cfcae77b8..234989ef244 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -68,7 +68,7 @@ void sequencer_operatortypes(void) WM_operatortype_append(SEQUENCER_OT_meta_toggle); WM_operatortype_append(SEQUENCER_OT_meta_make); WM_operatortype_append(SEQUENCER_OT_meta_separate); - + WM_operatortype_append(SEQUENCER_OT_gap_remove); WM_operatortype_append(SEQUENCER_OT_gap_insert); WM_operatortype_append(SEQUENCER_OT_snap); @@ -135,7 +135,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + /* Common items ------------------------------------------------------------------ */ keymap = WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0); @@ -228,7 +228,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_remove", BACKSPACEKEY, KM_PRESS, 0, 0)->ptr, "all", false); RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_remove", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "all", true); WM_keymap_add_item(keymap, "SEQUENCER_OT_gap_insert", EQUALKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SEQUENCER_OT_swap_inputs", SKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index 3f908dc7096..c58c05b67c0 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -80,11 +80,11 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p BLI_mutex_lock(pj->mutex); previewjb = pj->previews.first; BLI_mutex_unlock(pj->mutex); - + while (previewjb) { PreviewJobAudio *preview_next; bSound *sound = previewjb->sound; - + BKE_sound_read_waveform(sound, stop); if (*stop || G.is_break) { @@ -98,12 +98,12 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p BLI_spin_lock(sound->spinlock); sound->flags &= ~SOUND_FLAGS_WAVEFORM_LOADING; BLI_spin_unlock(sound->spinlock); - + BLI_mutex_lock(pj->mutex); previewjb = previewjb->next; BLI_mutex_unlock(pj->mutex); } - + BLI_mutex_lock(pj->mutex); BLI_freelistN(&pj->previews); pj->total = 0; @@ -111,12 +111,12 @@ static void preview_startjob(void *data, short *stop, short *do_update, float *p BLI_mutex_unlock(pj->mutex); break; } - + BLI_mutex_lock(pj->mutex); preview_next = previewjb->next; BLI_freelinkN(&pj->previews, previewjb); previewjb = preview_next; - pj->processed++; + pj->processed++; *progress = (pj->total > 0) ? (float)pj->processed / (float)pj->total : 1.0f; *do_update = true; BLI_mutex_unlock(pj->mutex); @@ -145,19 +145,19 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq) if (!pj) { pj = MEM_callocN(sizeof(PreviewJob), "preview rebuild job"); - + pj->mutex = BLI_mutex_alloc(); pj->scene = CTX_data_scene(C); - + WM_jobs_customdata_set(wm_job, pj, free_preview_job); WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER); WM_jobs_callbacks(wm_job, preview_startjob, NULL, NULL, preview_endjob); } - + /* attempt to lock mutex of job here */ - + audiojob->sound = seq->sound; - + BLI_mutex_lock(pj->mutex); BLI_addtail(&pj->previews, audiojob); pj->total++; @@ -168,5 +168,5 @@ void sequencer_preview_add_sound(const bContext *C, Sequence *seq) WM_jobs_start(CTX_wm_manager(C), wm_job); } - ED_area_tag_redraw(sa); + ED_area_tag_redraw(sa); } diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 8c57089f7ab..00811d68251 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -160,7 +160,7 @@ static ImBuf *make_waveform_view_from_ibuf_byte(ImBuf *ibuf) wform_put_grid(tgt, w, h); wform_put_border(tgt, w, h); - + for (x = 0; x < 256; x++) { wtable[x] = (unsigned char) (pow(((float) x + 1) / 256, waveform_gamma) * 255); } @@ -229,7 +229,7 @@ static ImBuf *make_waveform_view_from_ibuf_float(ImBuf *ibuf) } wform_put_border(tgt, w, h); - + return rval; } @@ -285,7 +285,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) } wform_put_border(tgt, w, h); - + return rval; } @@ -334,7 +334,7 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf) } wform_put_border(tgt, w, h); - + return rval; } @@ -542,7 +542,7 @@ static ImBuf *make_histogram_view_from_ibuf_byte(ImBuf *ibuf) } wform_put_border((unsigned char *) rval->rect, rval->x, rval->y); - + return rval; } @@ -610,7 +610,7 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) if (bins[2][x] > nb) nb = bins[2][x]; } - + for (x = 0; x < HIS_STEPS; x++) { if (nr) { draw_histogram_bar(rval, x + 1, ((float) bins[0][x]) / nr, 0); @@ -622,11 +622,11 @@ static ImBuf *make_histogram_view_from_ibuf_float(ImBuf *ibuf) draw_histogram_bar(rval, x + 1, ((float) bins[2][x]) / nb, 2); } } - + draw_histogram_marker(rval, get_bin_float(0.0)); draw_histogram_marker(rval, get_bin_float(1.0)); wform_put_border((unsigned char *) rval->rect, rval->x, rval->y); - + return rval; } @@ -653,7 +653,7 @@ static void vectorscope_put_cross(unsigned char r, unsigned char g, unsigned ch rgb[1] = (float)g / 255.0f; rgb[2] = (float)b / 255.0f; rgb_to_yuv_normalized(rgb, yuv); - + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + (int) ((yuv[1] * (w - 3) + 1))); @@ -698,12 +698,12 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf) for (x = 0; x < ibuf->x; x++) { const char *src1 = src + 4 * (ibuf->x * y + x); char *p; - + rgb[0] = (float)src1[0] / 255.0f; rgb[1] = (float)src1[1] / 255.0f; rgb[2] = (float)src1[2] / 255.0f; rgb_to_yuv_normalized(rgb, yuv); - + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + (int) ((yuv[1] * (w - 3) + 1))); scope_put_pixel(wtable, (unsigned char *)p); @@ -744,7 +744,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) for (x = 0; x < ibuf->x; x++) { const float *src1 = src + 4 * (ibuf->x * y + x); const char *p; - + memcpy(rgb, src1, 3 * sizeof(float)); CLAMP(rgb[0], 0.0f, 1.0f); @@ -752,7 +752,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) CLAMP(rgb[2], 0.0f, 1.0f); rgb_to_yuv_normalized(rgb, yuv); - + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + (int) ((yuv[1] * (w - 3) + 1))); scope_put_pixel(wtable, (unsigned char *)p); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 90a369760ac..d7206a6da4e 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -59,11 +59,11 @@ static void *find_nearest_marker(int UNUSED(d1), int UNUSED(d2)) { return NULL; } - + static void select_surrounding_handles(Scene *scene, Sequence *test) /* XXX BRING BACK */ { Sequence *neighbor; - + neighbor = find_neighboring_sequence(scene, test, SEQ_SIDE_LEFT, -1); if (neighbor) { /* Only select neighbor handle if matching handle from test seq is also selected, or if neighbor @@ -152,10 +152,10 @@ static void select_linked_time(ListBase *seqbase, Sequence *seq_link) void select_surround_from_last(Scene *scene) { Sequence *seq = get_last_seq(scene); - + if (seq == NULL) return; - + select_surrounding_handles(scene, seq); } #endif @@ -163,7 +163,7 @@ void select_surround_from_last(Scene *scene) void ED_sequencer_select_sequence_single(Scene *scene, Sequence *seq, bool deselect_all) { Editing *ed = BKE_sequencer_editing_get(scene, false); - + if (deselect_all) ED_sequencer_deselect_all(scene); @@ -264,11 +264,11 @@ void SEQUENCER_OT_select_all(struct wmOperatorType *ot) ot->name = "(De)select All"; ot->idname = "SEQUENCER_OT_select_all"; ot->description = "Select or deselect all strips"; - + /* api callbacks */ ot->exec = sequencer_de_select_all_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -294,7 +294,7 @@ static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); - + return OPERATOR_FINISHED; } @@ -304,11 +304,11 @@ void SEQUENCER_OT_select_inverse(struct wmOperatorType *ot) ot->name = "Select Inverse"; ot->idname = "SEQUENCER_OT_select_inverse"; ot->description = "Select unselected strips"; - + /* api callbacks */ ot->exec = sequencer_select_inverse_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -322,16 +322,16 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e const bool linked_handle = RNA_boolean_get(op->ptr, "linked_handle"); const bool linked_time = RNA_boolean_get(op->ptr, "linked_time"); int left_right = RNA_enum_get(op->ptr, "left_right"); - + Sequence *seq, *neighbor, *act_orig; int hand, sel_side; TimeMarker *marker; if (ed == NULL) return OPERATOR_CANCELLED; - + marker = find_nearest_marker(SCE_MARKERS, 1); //XXX - dummy function for now - + seq = find_nearest_seq(scene, v2d, &hand, event->mval); // XXX - not nice, Ctrl+RMB needs to do left_right only when not over a strip @@ -353,13 +353,13 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e /* deselect_markers(0, 0); */ /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */ marker->flag |= SELECT; } - + } else if (left_right != SEQ_SELECT_LR_NONE) { /* use different logic for this */ float x; ED_sequencer_deselect_all(scene); - + switch (left_right) { case SEQ_SELECT_LR_MOUSE: x = UI_view2d_region_to_view_x(v2d, event->mval[0]); @@ -372,7 +372,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e x = CFRA; break; } - + SEQP_BEGIN (ed, seq) { if (((x < CFRA) && (seq->enddisp <= CFRA)) || @@ -408,10 +408,10 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e if (extend == 0 && linked_handle == 0) ED_sequencer_deselect_all(scene); - + if (seq) { BKE_sequencer_active_set(scene, seq); - + if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) { if (seq->strip) { BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); @@ -422,7 +422,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR); } } - + /* On Alt selection, select the strip and bordering handles */ if (linked_handle) { if (!ELEM(hand, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT)) { @@ -521,7 +521,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e } } } - + /* marker transform */ #if 0 // XXX probably need to redo this differently for 2.5 if (marker) { @@ -529,7 +529,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e // getmouseco_areawin(mval); xo = mval[0]; yo = mval[1]; - + while (get_mbut()) { // getmouseco_areawin(mval); if (abs(mval[0] - xo) + abs(mval[1] - yo) > 4) { @@ -539,7 +539,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, const wmEvent *e } } #endif - + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); /* allowing tweaks */ @@ -555,19 +555,19 @@ void SEQUENCER_OT_select(wmOperatorType *ot) {SEQ_SELECT_LR_RIGHT, "RIGHT", 0, "Right", "Select right"}, {0, NULL, 0, NULL, NULL} }; - + /* identifiers */ ot->name = "Activate/Select"; ot->idname = "SEQUENCER_OT_select"; ot->description = "Select a strip (last selected becomes the \"active strip\")"; - + /* api callbacks */ ot->invoke = sequencer_select_invoke; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); RNA_def_boolean(ot->srna, "linked_handle", 0, "Linked Handle", "Select handles next to the active strip"); @@ -584,10 +584,10 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li Sequence *seq, *neighbor; bool changed = false; int isel; - + if (ed == NULL) return changed; - + if (sel) { sel = SELECT; isel = 0; @@ -596,14 +596,14 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li sel = 0; isel = SELECT; } - + if (!linked) { /* if not linked we only want to touch each seq once, newseq */ for (seq = ed->seqbasep->first; seq; seq = seq->next) { seq->tmp = NULL; } } - + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if ((seq->flag & SELECT) == sel) { if (linked || (seq->tmp == NULL)) { @@ -639,7 +639,7 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li } } } - + return changed; } @@ -649,12 +649,12 @@ static bool select_more_less_seq__internal(Scene *scene, bool sel, const bool li static int sequencer_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - + if (!select_more_less_seq__internal(scene, true, false)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); - + return OPERATOR_FINISHED; } @@ -664,14 +664,14 @@ void SEQUENCER_OT_select_more(wmOperatorType *ot) ot->name = "Select More"; ot->idname = "SEQUENCER_OT_select_more"; ot->description = "Select more strips adjacent to the current selection"; - + /* api callbacks */ ot->exec = sequencer_select_more_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ } @@ -680,12 +680,12 @@ void SEQUENCER_OT_select_more(wmOperatorType *ot) static int sequencer_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - + if (!select_more_less_seq__internal(scene, false, false)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); - + return OPERATOR_FINISHED; } @@ -695,14 +695,14 @@ void SEQUENCER_OT_select_less(wmOperatorType *ot) ot->name = "Select Less"; ot->idname = "SEQUENCER_OT_select_less"; ot->description = "Shrink the current selection of adjacent selected strips"; - + /* api callbacks */ ot->exec = sequencer_select_less_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ } @@ -712,9 +712,9 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons { Scene *scene = CTX_data_scene(C); View2D *v2d = UI_view2d_fromcontext(C); - + bool extend = RNA_boolean_get(op->ptr, "extend"); - + Sequence *mouse_seq; int selected, hand; @@ -722,20 +722,20 @@ static int sequencer_select_linked_pick_invoke(bContext *C, wmOperator *op, cons mouse_seq = find_nearest_seq(scene, v2d, &hand, event->mval); if (!mouse_seq) return OPERATOR_FINISHED; /* user error as with mesh?? */ - + if (extend == 0) ED_sequencer_deselect_all(scene); - + mouse_seq->flag |= SELECT; recurs_sel_seq(mouse_seq); - + selected = 1; while (selected) { selected = select_more_less_seq__internal(scene, 1, 1); } - + WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); - + return OPERATOR_FINISHED; } @@ -745,14 +745,14 @@ void SEQUENCER_OT_select_linked_pick(wmOperatorType *ot) ot->name = "Select Pick Linked"; ot->idname = "SEQUENCER_OT_select_linked_pick"; ot->description = "Select a chain of linked strips nearest to the mouse pointer"; - + /* api callbacks */ ot->invoke = sequencer_select_linked_pick_invoke; ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); } @@ -780,14 +780,14 @@ void SEQUENCER_OT_select_linked(wmOperatorType *ot) ot->name = "Select Linked"; ot->idname = "SEQUENCER_OT_select_linked"; ot->description = "Select all strips adjacent to the current selection"; - + /* api callbacks */ ot->exec = sequencer_select_linked_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ } @@ -830,14 +830,14 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot) ot->name = "Select Handles"; ot->idname = "SEQUENCER_OT_select_handles"; ot->description = "Select manipulator handles on the sides of the selected strip"; - + /* api callbacks */ ot->exec = sequencer_select_handles_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_enum(ot->srna, "side", prop_side_types, SEQ_SIDE_BOTH, "Side", "The side of the handle that is selected"); } @@ -867,7 +867,7 @@ void SEQUENCER_OT_select_active_side(wmOperatorType *ot) ot->name = "Select Active Side"; ot->idname = "SEQUENCER_OT_select_active_side"; ot->description = "Select strips on the nominated side of the active strip"; - + /* api callbacks */ ot->exec = sequencer_select_active_side_exec; ot->poll = sequencer_edit_poll; @@ -886,7 +886,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); View2D *v2d = UI_view2d_fromcontext(C); - + Sequence *seq; rctf rectf, rq; const bool select = !RNA_boolean_get(op->ptr, "deselect"); @@ -900,7 +900,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) for (seq = ed->seqbasep->first; seq; seq = seq->next) { seq_rectf(seq, &rq); - + if (BLI_rctf_isect(&rq, &rectf, NULL)) { if (select) seq->flag |= SELECT; else seq->flag &= ~SEQ_ALLSEL; @@ -915,7 +915,7 @@ static int sequencer_borderselect_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER | NA_SELECTED, scene); return OPERATOR_FINISHED; -} +} /* ****** Border Select ****** */ @@ -925,18 +925,18 @@ void SEQUENCER_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->idname = "SEQUENCER_OT_select_border"; ot->description = "Select strips using border selection"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = sequencer_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->cancel = WM_gesture_border_cancel; - + ot->poll = ED_operator_sequencer_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); } @@ -1267,15 +1267,15 @@ void SEQUENCER_OT_select_grouped(wmOperatorType *ot) ot->name = "Select Grouped"; ot->description = "Select all strips grouped by various properties"; ot->idname = "SEQUENCER_OT_select_grouped"; - + /* api callbacks */ ot->invoke = WM_menu_invoke; ot->exec = sequencer_select_grouped_exec; ot->poll = sequencer_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", sequencer_prop_select_grouped_types, 0, "Type", ""); RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend selection instead of deselecting everything first"); diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index 4d6ea865b40..4acda8799cb 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -97,7 +97,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) ImBuf *ibuf = sequencer_ibuf_get(bmain, scene, sseq, CFRA, 0, NULL); ImageSampleInfo *info = op->customdata; float fx, fy; - + if (ibuf == NULL) { IMB_freeImBuf(ibuf); info->draw = 0; @@ -121,7 +121,7 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) info->colp = NULL; info->colfp = NULL; - + if (ibuf->rect) { cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x); diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index ef1e9d866e7..47c134d02e1 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -81,28 +81,28 @@ ARegion *sequencer_has_buttons_region(ScrArea *sa) ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "buttons for sequencer"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } static ARegion *sequencer_find_region(ScrArea *sa, short type) { ARegion *ar = NULL; - + for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->regiontype == type) return ar; @@ -117,7 +117,7 @@ static SpaceLink *sequencer_new(const bContext *C) Scene *scene = CTX_data_scene(C); ARegion *ar; SpaceSeq *sseq; - + sseq = MEM_callocN(sizeof(SpaceSeq), "initsequencer"); sseq->spacetype = SPACE_SEQ; sseq->chanshown = 0; @@ -127,19 +127,19 @@ static SpaceLink *sequencer_new(const bContext *C) /* header */ ar = MEM_callocN(sizeof(ARegion), "header for sequencer"); - + BLI_addtail(&sseq->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* buttons/list view */ ar = MEM_callocN(sizeof(ARegion), "buttons for sequencer"); - + BLI_addtail(&sseq->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* preview region */ /* NOTE: if you change values here, also change them in sequencer_init_preview_region */ ar = MEM_callocN(sizeof(ARegion), "preview region for sequencer"); @@ -166,26 +166,26 @@ static SpaceLink *sequencer_new(const bContext *C) /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for sequencer"); - + BLI_addtail(&sseq->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - - + + /* seq space goes from (0,8) to (0, efra) */ - + ar->v2d.tot.xmin = 0.0f; ar->v2d.tot.ymin = 0.0f; ar->v2d.tot.xmax = scene->r.efra; ar->v2d.tot.ymax = 8.0f; - + ar->v2d.cur = ar->v2d.tot; - + ar->v2d.min[0] = 10.0f; ar->v2d.min[1] = 0.5f; - + ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = MAXSEQ; - + ar->v2d.minzoom = 0.01f; ar->v2d.maxzoom = 100.0f; @@ -200,7 +200,7 @@ static SpaceLink *sequencer_new(const bContext *C) /* not spacelink itself */ static void sequencer_free(SpaceLink *sl) -{ +{ SpaceSeq *sseq = (SpaceSeq *) sl; SequencerScopes *scopes = &sseq->scopes; @@ -231,7 +231,7 @@ static void sequencer_free(SpaceLink *sl) /* spacetype; init callback */ static void sequencer_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) { - + } static void sequencer_refresh(const bContext *C, ScrArea *sa) @@ -335,7 +335,7 @@ static void sequencer_refresh(const bContext *C, ScrArea *sa) static SpaceLink *sequencer_duplicate(SpaceLink *sl) { SpaceSeq *sseqn = MEM_dupallocN(sl); - + /* clear or remove stuff from old */ // XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd, false); @@ -421,7 +421,7 @@ static void sequencer_drop_copy(wmDrag *drag, wmDropBox *drop) char dir[FILE_MAX], file[FILE_MAX]; BLI_split_dirfile(drag->path, dir, file, sizeof(dir), sizeof(file)); - + RNA_string_set(drop->ptr, "directory", dir); RNA_collection_clear(drop->ptr, "files"); diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 72a274dcb5f..01e4bc4917e 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -66,17 +66,17 @@ static SpaceLink *text_new(const bContext *UNUSED(C)) { ARegion *ar; SpaceText *stext; - + stext = MEM_callocN(sizeof(SpaceText), "inittext"); stext->spacetype = SPACE_TEXT; stext->lheight = 12; stext->tabnumber = 4; stext->margin_column = 80; - + /* header */ ar = MEM_callocN(sizeof(ARegion), "header for text"); - + BLI_addtail(&stext->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; @@ -91,18 +91,18 @@ static SpaceLink *text_new(const bContext *UNUSED(C)) /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for text"); - + BLI_addtail(&stext->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + return (SpaceLink *)stext; } /* not spacelink itself */ static void text_free(SpaceLink *sl) -{ +{ SpaceText *stext = (SpaceText *) sl; - + stext->text = NULL; text_free_caches(stext); } @@ -204,7 +204,7 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_select_line); WM_operatortype_append(TEXT_OT_select_all); WM_operatortype_append(TEXT_OT_select_word); - + WM_operatortype_append(TEXT_OT_move_lines); WM_operatortype_append(TEXT_OT_jump); @@ -230,7 +230,7 @@ static void text_operatortypes(void) WM_operatortype_append(TEXT_OT_replace_set_selected); WM_operatortype_append(TEXT_OT_start_find); - + WM_operatortype_append(TEXT_OT_to_3d_object); WM_operatortype_append(TEXT_OT_resolve_conflict); @@ -242,7 +242,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + keymap = WM_keymap_find(keyconf, "Text Generic", SPACE_TEXT, 0); WM_keymap_add_item(keymap, "TEXT_OT_start_find", FKEY, KM_PRESS, KM_CTRL, 0); #ifdef __APPLE__ @@ -254,7 +254,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_properties", TKEY, KM_PRESS, KM_CTRL, 0); keymap = WM_keymap_find(keyconf, "Text", SPACE_TEXT, 0); - + #ifdef __APPLE__ RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", LINE_END); @@ -262,30 +262,30 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", UPARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", FILE_TOP); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", DOWNARROWKEY, KM_PRESS, KM_OSKEY, 0)->ptr, "type", FILE_BOTTOM); - + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", LINE_BEGIN); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", LINE_END); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", LEFTARROWKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", PREV_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", RIGHTARROWKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", FILE_TOP); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_select", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0)->ptr, "type", FILE_BOTTOM); - + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", DEL_PREV_WORD); - + WM_keymap_add_item(keymap, "TEXT_OT_save", SKEY, KM_PRESS, KM_ALT | KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_save_as", SKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_OSKEY, 0); - WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); + WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_find_set_selected", EKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "TEXT_OT_select_line", AKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); #endif - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELUPMOUSE, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", false); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", true); @@ -293,7 +293,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", false); - + kmi = WM_keymap_add_item(keymap, "WM_OT_context_cycle_int", PADMINUS, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.font_size"); RNA_boolean_set(kmi->ptr, "reverse", true); @@ -305,7 +305,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_save_as", SKEY, KM_PRESS, KM_ALT | KM_SHIFT | KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_run_script", PKEY, KM_PRESS, KM_ALT, 0); - + WM_keymap_add_item(keymap, "TEXT_OT_cut", XKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); @@ -313,7 +313,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "TEXT_OT_cut", DELKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "TEXT_OT_copy", INSERTKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "TEXT_OT_paste", INSERTKEY, KM_PRESS, KM_SHIFT, 0); - + WM_keymap_add_item(keymap, "TEXT_OT_duplicate_line", DKEY, KM_PRESS, KM_CTRL, 0); if (U.uiflag & USER_MMB_PASTE) { // XXX not dynamic @@ -327,14 +327,14 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_lines", UPARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "direction", TXT_MOVE_LINE_UP); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move_lines", DOWNARROWKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0)->ptr, "direction", TXT_MOVE_LINE_DOWN); - + WM_keymap_add_item(keymap, "TEXT_OT_indent", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_unindent", TABKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "TEXT_OT_uncomment", DKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", HOMEKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_BEGIN); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", ENDKEY, KM_PRESS, 0, 0)->ptr, "type", LINE_END); - + RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", EKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", LINE_END); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", EKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", LINE_END); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_move", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "type", PREV_CHAR); @@ -366,7 +366,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", DEL_PREV_CHAR); /* same as above [#26623] */ RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "TEXT_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); - + WM_keymap_add_item(keymap, "TEXT_OT_overwrite_toggle", INSERTKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", LEFTMOUSE, KM_PRESS, 0, 0); @@ -387,7 +387,7 @@ static void text_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "TEXT_MT_toolbox", RIGHTMOUSE, KM_PRESS, KM_ANY, 0); WM_keymap_add_item(keymap, "TEXT_OT_autocomplete", SPACEKEY, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_item(keymap, "TEXT_OT_line_number", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); WM_keymap_add_item(keymap, "TEXT_OT_insert", KM_TEXTINPUT, KM_ANY, KM_ANY, 0); // last! } @@ -417,18 +417,18 @@ static void text_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; ListBase *lb; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Text Generic", SPACE_TEXT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); keymap = WM_keymap_find(wm->defaultconf, "Text", SPACE_TEXT, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - + /* add drop boxes */ lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW); - + WM_event_add_dropbox_handler(&ar->handlers, lb); } @@ -437,19 +437,19 @@ static void text_main_region_draw(const bContext *C, ARegion *ar) /* draw entirely, view changes should be handled here */ SpaceText *st = CTX_wm_space_text(C); //View2D *v2d = &ar->v2d; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + // UI_view2d_view_ortho(v2d); - + /* data... */ draw_text_main(st, ar); - + /* reset view matrix */ // UI_view2d_view_restore(C); - + /* scrollers? */ } @@ -509,7 +509,7 @@ static void text_drop_paste(wmDrag *drag, wmDropBox *drop) static void text_dropboxes(void) { ListBase *lb = WM_dropboxmap_find("Text", SPACE_TEXT, RGN_TYPE_WINDOW); - + WM_dropbox_add(lb, "TEXT_OT_open", text_drop_poll, text_drop_copy); WM_dropbox_add(lb, "TEXT_OT_insert", text_drop_paste_poll, text_drop_paste); } @@ -549,9 +549,9 @@ static void text_properties_region_init(wmWindowManager *wm, ARegion *ar) static void text_properties_region_draw(const bContext *C, ARegion *ar) { SpaceText *st = CTX_wm_space_text(C); - + ED_region_panels(C, ar, NULL, -1, true); - + /* this flag trick is make sure buttons have been added already */ if (st->flags & ST_FIND_ACTIVATE) { if (UI_textbutton_activate_rna(C, ar, st, "find_text")) { @@ -584,10 +584,10 @@ void ED_spacetype_text(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype text"); ARegionType *art; - + st->spaceid = SPACE_TEXT; strncpy(st->name, "Text", BKE_ST_MAXNAME); - + st->new = text_new; st->free = text_free; st->init = text_init; @@ -608,13 +608,13 @@ void ED_spacetype_text(void) art->event_cursor = true; BLI_addhead(&st->regiontypes, art); - + /* regions: properties */ art = MEM_callocN(sizeof(ARegionType), "spacetype text region"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_COMPACT_PANEL_WIDTH; art->keymapflag = ED_KEYMAP_UI; - + art->init = text_properties_region_init; art->draw = text_properties_region_draw; BLI_addhead(&st->regiontypes, art); @@ -624,7 +624,7 @@ void ED_spacetype_text(void) art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; - + art->init = text_header_region_init; art->draw = text_header_region_draw; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 23f28a91be8..9a3dcddf804 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -111,7 +111,7 @@ static int text_font_draw_character_utf8(const TextDrawContext *tdc, int x, int #if 0 /* Formats every line of the current text */ -static void txt_format_text(SpaceText *st) +static void txt_format_text(SpaceText *st) { TextLine *linep; @@ -189,7 +189,7 @@ int wrap_width(const SpaceText *st, ARegion *ar) { int winx = ar->winx - TXT_SCROLL_WIDTH; int x, max; - + x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; max = st->cwidth ? (winx - x) / st->cwidth : 0; return max > 8 ? max : 8; @@ -356,7 +356,7 @@ void wrap_offset_in_line(const SpaceText *st, ARegion *ar, TextLine *linein, int int text_get_char_pos(const SpaceText *st, const char *line, int cur) { int a = 0, i; - + for (i = 0; i < cur && line[i]; i += BLI_str_utf8_size_safe(line + i)) { if (line[i] == '\t') a += st->tabnumber - a % st->tabnumber; @@ -405,11 +405,11 @@ static int text_draw_wrapped( if (max < 8) max = 8; basex = x; lines = 1; - + fpos = fstart = 0; mstart = 0; mend = txt_utf8_forward_columns(str, max, &padding) - str; end = wrap = max - padding; - + for (i = 0, mi = 0; str[mi]; i += columns, mi += BLI_str_utf8_size_safe(str + mi)) { columns = BLI_str_utf8_char_width_safe(str + mi); if (i + columns > end) { @@ -657,7 +657,7 @@ void text_drawcache_tag_update(SpaceText *st, int full) /* this happens if text editor ops are caled from python */ if (st == NULL) return; - + if (st->drawcache) { DrawCache *drawcache = (DrawCache *)st->drawcache; Text *txt = st->text; @@ -806,17 +806,17 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) back->xmax = ar->winx; back->ymin = 0; back->ymax = ar->winy; - + scroll->xmin = ar->winx - V2D_SCROLL_WIDTH; scroll->xmax = ar->winx - 5; scroll->ymin = 4; scroll->ymax = 4 + pix_available; - + /* when re-sizing a view-port with the bar at the bottom to a greater height more blank lines will be added */ if (ltexth + blank_lines < st->top + st->viewlines) { blank_lines = st->top + st->viewlines - ltexth; } - + ltexth += blank_lines; barheight = (ltexth > 0) ? (st->viewlines * pix_available) / ltexth : 0; @@ -893,7 +893,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) if (hlend - hlstart < 2) { hlend = hlstart + 2; } - + st->txtscroll = *scroll; st->txtscroll.ymax = ar->winy - pix_top_margin - hlstart; st->txtscroll.ymin = ar->winy - pix_top_margin - hlend; @@ -908,7 +908,7 @@ static void draw_textscroll(const SpaceText *st, rcti *scroll, rcti *back) uiWidgetColors wcol = btheme->tui.wcol_scroll; unsigned char col[4]; float rad; - + UI_ThemeColor(TH_BACK); glRecti(back->xmin, back->ymin, back->xmax, back->ymax); @@ -934,10 +934,10 @@ static void draw_documentation(const SpaceText *st, ARegion *ar) char *docs, buf[DOC_WIDTH + 1], *p; int i, br, lines; int boxw, boxh, l, x, y /* , top */ /* UNUSED */; - + if (!st || !st->text) return; if (!texttool_text_is_active(st->text)) return; - + docs = texttool_docs_get(); if (!docs) return; @@ -947,7 +947,7 @@ static void draw_documentation(const SpaceText *st, ARegion *ar) /* Count the visible lines to the cursor */ for (tmp = st->text->curl, l = -st->top; tmp; tmp = tmp->prev, l++) ; if (l < 0) return; - + if (st->showlinenrs) { x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET + TEXTXLOC - 4; } @@ -1027,7 +1027,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc int w, boxw = 0, boxh, i, x, y, *top; const int lheight = st->lheight_dpi + TXT_LINE_SPACING; const int margin_x = 2; - + if (!st->text) return; if (!texttool_text_is_active(st->text)) return; @@ -1054,7 +1054,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc boxw = SUGG_LIST_WIDTH * st->cwidth + 20; boxh = SUGG_LIST_SIZE * lheight + 8; - + if (x + boxw > ar->winx) x = MAX2(0, ar->winx - boxw); @@ -1077,7 +1077,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc BLI_strncpy(str, item->name, len + 1); w = st->cwidth * text_get_char_pos(st, str, len); - + if (item == sel) { UI_ThemeColor(TH_SHADE2); glRecti(x + margin_x, y - 3, x + margin_x + w, y + lheight - 3); @@ -1117,7 +1117,7 @@ static void draw_cursor(SpaceText *st, ARegion *ar) vselc = 0; hidden = 1; } - + UI_ThemeColor(TH_SHADE2); x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; y = ar->winy; @@ -1188,27 +1188,27 @@ static void draw_cursor(SpaceText *st, ARegion *ar) x2 = x1 + ar->winx; glColor4ub(255, 255, 255, 32); - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glRecti(x1 - 4, y1, x2, y2); glDisable(GL_BLEND); } } - + if (!hidden) { /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */ x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; x += vselc * st->cwidth; y = ar->winy - vsell * lheight; - + if (st->overwrite) { char ch = text->sell->line[text->selc]; - + y += TXT_LINE_SPACING; w = st->cwidth; if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber; - + UI_ThemeColor(TH_HILITE); glRecti(x, y - lheight - 1, x + w, y - lheight + 1); } @@ -1227,7 +1227,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi Text *text = st->text; int b, fc, find, stack, viewc, viewl, offl, offc, x, y; int startc, endc, c; - + char ch; // showsyntax must be on or else the format string will be null @@ -1246,7 +1246,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi endc = -1; find = -b; stack = 0; - + /* Don't highlight backets if syntax HL is off or bracket in string or comment. */ if (!linep->format || linep->format[fc] == FMT_TYPE_STRING || linep->format[fc] == FMT_TYPE_COMMENT) return; @@ -1371,7 +1371,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) const int clip_min_y = -(int)(st->lheight_dpi - 1); st->viewlines = (st->lheight_dpi) ? (int)(ar->winy - clip_min_y) / (st->lheight_dpi + TXT_LINE_SPACING) : 0; - + text_draw_context_init(st, &tdc); text_update_drawcache(st, ar); @@ -1379,7 +1379,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) /* make sure all the positional pointers exist */ if (!text->curl || !text->sell || !text->lines.first || !text->lines.last) txt_clean_text(text); - + /* update rects for scroll */ calc_text_rcts(st, ar, &scroll, &back); /* scroll will hold the entire bar size */ @@ -1431,7 +1431,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) } y = ar->winy - st->lheight_dpi; winx = ar->winx - TXT_SCROLL_WIDTH; - + /* draw cursor */ draw_cursor(st, ar); @@ -1466,13 +1466,13 @@ void draw_text_main(SpaceText *st, ARegion *ar) text_draw(st, &tdc, tmp->line, st->left, ar->winx / st->cwidth, x, y, tmp->format); y -= st->lheight_dpi + TXT_LINE_SPACING; } - + wrap_skip = 0; } - + if (st->flags & ST_SHOW_MARGIN) { margin_column_x = x + st->cwidth * (st->margin_column - st->left); - + if (margin_column_x >= x) { /* same color as line number background */ UI_ThemeColor(TH_GRID); @@ -1491,7 +1491,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) draw_textscroll(st, &scroll, &back); /* draw_documentation(st, ar); - No longer supported */ draw_suggestion_list(st, &tdc, ar); - + text_font_end(&tdc); } @@ -1542,7 +1542,7 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center) st->top = i; } } - + if (st->wordwrap) { st->left = 0; } diff --git a/source/blender/editors/space_text/text_format.c b/source/blender/editors/space_text/text_format.c index 0133122c5a3..b64eefe969b 100644 --- a/source/blender/editors/space_text/text_format.c +++ b/source/blender/editors/space_text/text_format.c @@ -216,7 +216,7 @@ TextFormatType *ED_text_format_get(Text *text) } } - /* If we make it here we never found an extension that worked - return + /* If we make it here we never found an extension that worked - return * the "default" text format */ return tft_lb.first; } diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index f7e1d433e51..8b6ec2d804b 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -34,7 +34,7 @@ /* *** Lua Keywords (for format_line) *** */ -/* Checks the specified source string for a Lua keyword (minus boolean & 'nil'). +/* Checks the specified source string for a Lua keyword (minus boolean & 'nil'). * This name must start at the beginning of the source string and must be * followed by a non-identifier (see text_check_identifier(char)) or null char. * @@ -75,7 +75,7 @@ static int txtfmt_lua_find_keyword(const char *string) return i; } -/* Checks the specified source string for a Lua special name/function. This +/* Checks the specified source string for a Lua special name/function. This * name must start at the beginning of the source string and must be followed * by a non-identifier (see text_check_identifier(char)) or null character. * diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index 97dc1be3b9a..2daaaa348e6 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -132,7 +132,7 @@ static int txtfmt_osl_find_reserved(const char *string) static int txtfmt_osl_find_specialvar(const char *string) { int i, len; - + /* OSL shader types */ if (STR_LITERAL_STARTSWITH(string, "shader", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "surface", len)) i = len; diff --git a/source/blender/editors/space_text/text_header.c b/source/blender/editors/space_text/text_header.c index 1a6d3181349..50a8739c5b4 100644 --- a/source/blender/editors/space_text/text_header.c +++ b/source/blender/editors/space_text/text_header.c @@ -54,21 +54,21 @@ static ARegion *text_has_properties_region(ScrArea *sa) ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "properties region"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_LEFT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } @@ -81,7 +81,7 @@ static int text_properties_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = text_has_properties_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -94,7 +94,7 @@ void TEXT_OT_properties(wmOperatorType *ot) ot->name = "Properties"; ot->description = "Toggle the properties region visibility"; ot->idname = "TEXT_OT_properties"; - + /* api callbacks */ ot->exec = text_properties_exec; ot->poll = text_properties_poll; @@ -105,15 +105,15 @@ static int text_text_search_exec(bContext *C, wmOperator *UNUSED(op)) ScrArea *sa = CTX_wm_area(C); ARegion *ar = text_has_properties_region(sa); SpaceText *st = CTX_wm_space_text(C); - + if (ar) { if (ar->flag & RGN_FLAG_HIDDEN) ED_region_toggle_hidden(C, ar); - + /* cannot send a button activate yet for case when region wasn't visible yet */ /* flag gets checked and cleared in main draw callback */ st->flags |= ST_FIND_ACTIVATE; - + ED_region_tag_redraw(ar); } return OPERATOR_FINISHED; @@ -126,7 +126,7 @@ void TEXT_OT_start_find(wmOperatorType *ot) ot->name = "Find"; ot->description = "Start searching text"; ot->idname = "TEXT_OT_start_find"; - + /* api callbacks */ ot->exec = text_text_search_exec; ot->poll = text_properties_poll; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 24215c6d403..fe15d9165b7 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -124,7 +124,7 @@ static int text_region_edit_poll(bContext *C) if (!st || !text) return 0; - + if (!ar || ar->regiontype != RGN_TYPE_WINDOW) return 0; @@ -198,11 +198,11 @@ void TEXT_OT_new(wmOperatorType *ot) ot->name = "Create Text Block"; ot->idname = "TEXT_OT_new"; ot->description = "Create a new text data-block"; - + /* api callbacks */ ot->exec = text_new_exec; ot->poll = text_new_poll; - + /* flags */ ot->flag = OPTYPE_UNDO; } @@ -278,10 +278,10 @@ static int text_open_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e if (RNA_struct_property_is_set(op->ptr, "filepath")) return text_open_exec(C, op); - + text_open_init(C, op); RNA_string_set(op->ptr, "filepath", path); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -301,7 +301,7 @@ void TEXT_OT_open(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_filesel( ot, FILE_TYPE_FOLDER | FILE_TYPE_TEXT | FILE_TYPE_PYSCRIPT, FILE_SPECIAL, FILE_OPENFILE, @@ -352,7 +352,7 @@ void TEXT_OT_reload(wmOperatorType *ot) ot->name = "Reload"; ot->idname = "TEXT_OT_reload"; ot->description = "Reload active text data-block from its file"; - + /* api callbacks */ ot->exec = text_reload_exec; ot->invoke = WM_operator_confirm; @@ -401,12 +401,12 @@ void TEXT_OT_unlink(wmOperatorType *ot) ot->name = "Unlink"; ot->idname = "TEXT_OT_unlink"; ot->description = "Unlink active text data-block"; - + /* api callbacks */ ot->exec = text_unlink_exec; ot->invoke = WM_operator_confirm; ot->poll = text_unlink_poll; - + /* flags */ ot->flag = OPTYPE_UNDO; } @@ -440,7 +440,7 @@ void TEXT_OT_make_internal(wmOperatorType *ot) /* api callbacks */ ot->exec = text_make_internal_exec; ot->poll = text_edit_poll; - + /* flags */ ot->flag = OPTYPE_UNDO; } @@ -453,7 +453,7 @@ static int text_save_poll(bContext *C) if (!text_edit_poll(C)) return 0; - + return (text->name != NULL && !(text->flags & TXT_ISMEM)); } @@ -463,10 +463,10 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports) TextLine *tmp; BLI_stat_t st; char filepath[FILE_MAX]; - + BLI_strncpy(filepath, text->name, FILE_MAX); BLI_path_abs(filepath, bmain->name); - + fp = BLI_fopen(filepath, "w"); if (fp == NULL) { BKE_reportf(reports, RPT_ERROR, "Unable to save '%s': %s", @@ -480,7 +480,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports) fputc('\n', fp); } } - + fclose(fp); if (BLI_stat(filepath, &st) == 0) { @@ -494,7 +494,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports) BKE_reportf(reports, RPT_WARNING, "Unable to stat '%s': %s", filepath, errno ? strerror(errno) : TIP_("unknown error stating file")); } - + text->flags &= ~TXT_ISDIRTY; } @@ -563,9 +563,9 @@ static int text_save_as_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE str = text->id.name + 2; else str = bmain->name; - + RNA_string_set(op->ptr, "filepath", str); - WM_event_add_fileselect(C, op); + WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; } @@ -576,7 +576,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) ot->name = "Save As"; ot->idname = "TEXT_OT_save_as"; ot->description = "Save active text file with options"; - + /* api callbacks */ ot->exec = text_save_as_exec; ot->invoke = text_save_as_invoke; @@ -653,7 +653,7 @@ void TEXT_OT_run_script(wmOperatorType *ot) ot->name = "Run Script"; ot->idname = "TEXT_OT_run_script"; ot->description = "Run active script"; - + /* api callbacks */ ot->poll = text_run_script_poll; ot->exec = text_run_script_exec; @@ -672,7 +672,7 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS Object *ob; bConstraint *con; short update; - + /* check all pyconstraints */ for (ob = CTX_data_main(C)->object.first; ob; ob = ob->id.next) { update = 0; @@ -684,7 +684,7 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS bPythonConstraint *data = con->data; if (data->text == text) BPY_pyconstraint_update(ob, con); update = 1; - + } } } @@ -696,7 +696,7 @@ static int text_refresh_pyconstraints_exec(bContext *UNUSED(C), wmOperator *UNUS update = 1; } } - + if (update) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } @@ -713,7 +713,7 @@ void TEXT_OT_refresh_pyconstraints(wmOperatorType *ot) ot->name = "Refresh PyConstraints"; ot->idname = "TEXT_OT_refresh_pyconstraints"; ot->description = "Refresh all pyconstraints"; - + /* api callbacks */ ot->exec = text_refresh_pyconstraints_exec; ot->poll = text_edit_poll; @@ -757,7 +757,7 @@ void TEXT_OT_paste(wmOperatorType *ot) ot->name = "Paste"; ot->idname = "TEXT_OT_paste"; ot->description = "Paste text from clipboard"; - + /* api callbacks */ ot->exec = text_paste_exec; ot->poll = text_edit_poll; @@ -871,7 +871,7 @@ void TEXT_OT_cut(wmOperatorType *ot) ot->name = "Cut"; ot->idname = "TEXT_OT_cut"; ot->description = "Cut selected text to clipboard"; - + /* api callbacks */ ot->exec = text_cut_exec; ot->poll = text_edit_poll; @@ -912,7 +912,7 @@ void TEXT_OT_indent(wmOperatorType *ot) ot->name = "Indent"; ot->idname = "TEXT_OT_indent"; ot->description = "Indent selected text"; - + /* api callbacks */ ot->exec = text_indent_exec; ot->poll = text_edit_poll; @@ -948,7 +948,7 @@ void TEXT_OT_unindent(wmOperatorType *ot) ot->name = "Unindent"; ot->idname = "TEXT_OT_unindent"; ot->description = "Unindent selected text"; - + /* api callbacks */ ot->exec = text_unindent_exec; ot->poll = text_edit_poll; @@ -1077,7 +1077,7 @@ void TEXT_OT_uncomment(wmOperatorType *ot) ot->name = "Uncomment"; ot->idname = "TEXT_OT_uncomment"; ot->description = "Convert selected comment to text"; - + /* api callbacks */ ot->exec = text_uncomment_exec; ot->poll = text_edit_poll; @@ -1117,7 +1117,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) MEM_freeN(tmp->line); if (tmp->format) MEM_freeN(tmp->format); - + /* Put new_line in the tmp->line spot still need to try and set the curc correctly. */ tmp->line = new_line; tmp->len = strlen(new_line); @@ -1126,7 +1126,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) max_len = tmp->len; } } - + if (type == TO_TABS) { char *tmp_line = MEM_mallocN(sizeof(*tmp_line) * (max_len + 1), __func__); @@ -1212,7 +1212,7 @@ void TEXT_OT_convert_whitespace(wmOperatorType *ot) ot->name = "Convert Whitespace"; ot->idname = "TEXT_OT_convert_whitespace"; ot->description = "Convert whitespaces by type"; - + /* api callbacks */ ot->exec = text_convert_whitespace_exec; ot->poll = text_edit_poll; @@ -1244,7 +1244,7 @@ void TEXT_OT_select_all(wmOperatorType *ot) ot->name = "Select All"; ot->idname = "TEXT_OT_select_all"; ot->description = "Select all text"; - + /* api callbacks */ ot->exec = text_select_all_exec; ot->poll = text_edit_poll; @@ -1270,7 +1270,7 @@ void TEXT_OT_select_line(wmOperatorType *ot) ot->name = "Select Line"; ot->idname = "TEXT_OT_select_line"; ot->description = "Select text by line"; - + /* api callbacks */ ot->exec = text_select_line_exec; ot->poll = text_edit_poll; @@ -1315,14 +1315,14 @@ static int move_lines_exec(bContext *C, wmOperator *op) TextUndoBuf *utxt = ED_text_undo_push_init(C); txt_move_lines(text, utxt, direction); - + text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); /* run the script while editing, evil but useful */ if (CTX_wm_space_text(C)->live_edit) text_run_script(C, NULL); - + return OPERATOR_FINISHED; } @@ -1338,7 +1338,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot) ot->name = "Move Lines"; ot->idname = "TEXT_OT_move_lines"; ot->description = "Move the currently selected line(s) up/down"; - + /* api callbacks */ ot->exec = move_lines_exec; ot->poll = text_edit_poll; @@ -1757,7 +1757,7 @@ static void cursor_skip(SpaceText *st, ARegion *ar, Text *text, int lines, const { TextLine **linep; int *charp; - + if (sel) { linep = &text->sell; charp = &text->selc; } else { linep = &text->curl; charp = &text->curc; } @@ -1802,7 +1802,7 @@ static int text_move_cursor(bContext *C, int type, bool select) if (st && st->wordwrap && ar) txt_wrap_move_bol(st, ar, select); else txt_move_bol(text, select); break; - + case LINE_END: if (!select) { txt_sel_clear(text); @@ -1814,7 +1814,7 @@ static int text_move_cursor(bContext *C, int type, bool select) case FILE_TOP: txt_move_bof(text, select); break; - + case FILE_BOTTOM: txt_move_eof(text, select); break; @@ -1857,7 +1857,7 @@ static int text_move_cursor(bContext *C, int type, bool select) if (st && st->wordwrap && ar) txt_wrap_move_up(st, ar, select); else txt_move_up(text, select); break; - + case NEXT_LINE: if (st && st->wordwrap && ar) txt_wrap_move_down(st, ar, select); else txt_move_down(text, select); @@ -1893,7 +1893,7 @@ void TEXT_OT_move(wmOperatorType *ot) ot->name = "Move Cursor"; ot->idname = "TEXT_OT_move"; ot->description = "Move cursor to position type"; - + /* api callbacks */ ot->exec = text_move_exec; ot->poll = text_edit_poll; @@ -1917,7 +1917,7 @@ void TEXT_OT_move_select(wmOperatorType *ot) ot->name = "Move Select"; ot->idname = "TEXT_OT_move_select"; ot->description = "Move the cursor while selecting"; - + /* api callbacks */ ot->exec = text_move_select_exec; ot->poll = text_space_edit_poll; @@ -1961,7 +1961,7 @@ void TEXT_OT_jump(wmOperatorType *ot) ot->name = "Jump"; ot->idname = "TEXT_OT_jump"; ot->description = "Jump cursor to line"; - + /* api callbacks */ ot->invoke = text_jump_invoke; ot->exec = text_jump_exec; @@ -2052,7 +2052,7 @@ static int text_delete_exec(bContext *C, wmOperator *op) /* run the script while editing, evil but useful */ if (st->live_edit) text_run_script(C, NULL); - + return OPERATOR_FINISHED; } @@ -2062,7 +2062,7 @@ void TEXT_OT_delete(wmOperatorType *ot) ot->name = "Delete"; ot->idname = "TEXT_OT_delete"; ot->description = "Delete text by cursor position"; - + /* api callbacks */ ot->exec = text_delete_exec; ot->poll = text_edit_poll; @@ -2093,7 +2093,7 @@ void TEXT_OT_overwrite_toggle(wmOperatorType *ot) ot->name = "Toggle Overwrite"; ot->idname = "TEXT_OT_overwrite_toggle"; ot->description = "Toggle overwrite while typing"; - + /* api callbacks */ ot->exec = text_toggle_overwrite_exec; ot->poll = text_space_edit_poll; @@ -2264,20 +2264,20 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) { SpaceText *st = CTX_wm_space_text(C); TextScroll *tsc; - + if (RNA_struct_property_is_set(op->ptr, "lines")) return text_scroll_exec(C, op); - + tsc = MEM_callocN(sizeof(TextScroll), "TextScroll"); tsc->first = 1; tsc->zone = SCROLLHANDLE_BAR; op->customdata = tsc; - + st->flags |= ST_SCROLL_SELECT; - + if (event->type == MOUSEPAN) { text_update_character_width(st); - + tsc->old[0] = event->x; tsc->old[1] = event->y; /* Sensitivity of scroll set to 4pix per line/char */ @@ -2291,7 +2291,7 @@ static int text_scroll_invoke(bContext *C, wmOperator *op, const wmEvent *event) } WM_event_add_modal_handler(C, op); - + return OPERATOR_RUNNING_MODAL; } @@ -2300,11 +2300,11 @@ void TEXT_OT_scroll(wmOperatorType *ot) /* identifiers */ ot->name = "Scroll"; /* don't really see the difference between this and - * scroll_bar. Both do basically the same thing (aside + * scroll_bar. Both do basically the same thing (aside * from keymaps).*/ ot->idname = "TEXT_OT_scroll"; ot->description = ""; - + /* api callbacks */ ot->exec = text_scroll_exec; ot->invoke = text_scroll_invoke; @@ -2330,10 +2330,10 @@ static int text_region_scroll_poll(bContext *C) if (!st || !text) return 0; - + if (!ar || ar->regiontype != RGN_TYPE_WINDOW) return 0; - + return 1; } @@ -2347,7 +2347,7 @@ static int text_scroll_bar_invoke(bContext *C, wmOperator *op, const wmEvent *ev if (RNA_struct_property_is_set(op->ptr, "lines")) return text_scroll_exec(C, op); - + /* verify we are in the right zone */ if (mval[0] > st->txtbar.xmin && mval[0] < st->txtbar.xmax) { if (mval[1] >= st->txtbar.ymin && mval[1] <= st->txtbar.ymax) { @@ -2392,11 +2392,11 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot) /* identifiers */ ot->name = "Scrollbar"; /* don't really see the difference between this and - * scroll. Both do basically the same thing (aside + * scroll. Both do basically the same thing (aside * from keymaps).*/ ot->idname = "TEXT_OT_scroll_bar"; ot->description = ""; - + /* api callbacks */ ot->invoke = text_scroll_bar_invoke; ot->modal = text_scroll_modal; @@ -2431,7 +2431,7 @@ static int flatten_width(SpaceText *st, const char *str) total += BLI_str_utf8_char_width_safe(str + i); } } - + return total; } @@ -2444,14 +2444,14 @@ static int flatten_column_to_offset(SpaceText *st, const char *str, int index) col = st->tabnumber - i % st->tabnumber; else col = BLI_str_utf8_char_width_safe(str + j); - + if (i + col > index) break; - + i += col; j += BLI_str_utf8_size_safe(str + j); } - + return j; } @@ -2482,7 +2482,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in int max = wrap_width(st, ar); /* column */ int charp = -1; /* mem */ bool found = false; /* flags */ - + /* Point to line matching given y position, if any. */ TextLine *linep = get_line_pos_wrapped(st, ar, &y); @@ -2495,7 +2495,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in for (j = 0 ; !found && ((ch = linep->line[j]) != '\0'); j += BLI_str_utf8_size_safe(linep->line + j)) { int chars; int columns = BLI_str_utf8_char_width_safe(linep->line + j); /* = 1 for tab */ - + /* Mimic replacement of tabs */ if (ch == '\t') { chars = st->tabnumber - i % st->tabnumber; @@ -2504,7 +2504,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in else { chars = 1; } - + while (chars--) { /* Gone too far, go back to last wrap point */ if (y < 0) { @@ -2526,22 +2526,22 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in } if (i + columns - start > max) { end = MIN2(end, i); - + if (found) { /* exact cursor position was found, check if it's still on needed line (hasn't been wrapped) */ if (charp > endj && !chop && ch != '\0') charp = endj; break; } - + if (chop) endj = j; start = end; end += max; - + if (j < linep->len) y--; - + chop = true; if (y == 0 && i + columns - start > x) { charp = curs; @@ -2553,7 +2553,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in if (found) { break; } - + if (y == 0 && i + columns - start > x) { charp = curs; found = true; @@ -2568,7 +2568,7 @@ static void text_cursor_set_to_pos_wrapped(SpaceText *st, ARegion *ar, int x, in } BLI_assert(y == 0); - + if (!found) { /* On correct line but didn't meet cursor, must be at end */ charp = linep->len; @@ -2606,7 +2606,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con if (x < 0) x = 0; x = text_pixel_x_to_column(st, x) + st->left; - + if (st->wordwrap) { text_cursor_set_to_pos_wrapped(st, ar, x, y, sel); } @@ -2614,12 +2614,12 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con TextLine **linep; int *charp; int w; - + if (sel) { linep = &text->sell; charp = &text->selc; } else { linep = &text->curl; charp = &text->curc; } - + y -= txt_get_span(text->lines.first, *linep) - st->top; - + if (y > 0) { while (y-- != 0) { if ((*linep)->next) *linep = (*linep)->next; @@ -2631,7 +2631,7 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con } } - + w = flatten_width(st, (*linep)->line); if (x < w) *charp = flatten_column_to_offset(st, (*linep)->line, x); else *charp = (*linep)->len; @@ -2679,7 +2679,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, const wmEvent *ev } else if (!st->wordwrap && (event->mval[0] < 0 || event->mval[0] > ar->winx)) { text_cursor_timer_ensure(C, ssel); - + if (event->type == TIMER) { text_cursor_set_to_pos(st, ar, CLAMPIS(event->mval[0], 0, ar->winx), event->mval[1], 1); text_scroll_to_cursor(st, ar, false); @@ -2876,7 +2876,7 @@ void TEXT_OT_line_number(wmOperatorType *ot) ot->name = "Line Number"; ot->idname = "TEXT_OT_line_number"; ot->description = "The current line number"; - + /* api callbacks */ ot->invoke = text_line_number_invoke; ot->poll = text_region_edit_poll; @@ -2913,7 +2913,7 @@ static int text_insert_exec(bContext *C, wmOperator *op) } MEM_freeN(str); - + if (!done) return OPERATOR_CANCELLED; @@ -2941,7 +2941,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event) else { char str[BLI_UTF8_MAX + 1]; size_t len; - + if (event->utf8_buf[0]) { len = BLI_str_utf8_size_safe(event->utf8_buf); memcpy(str, event->utf8_buf, len); @@ -2956,7 +2956,7 @@ static int text_insert_invoke(bContext *C, wmOperator *op, const wmEvent *event) } ret = text_insert_exec(C, op); - + /* run the script while editing, evil but useful */ if (ret == OPERATOR_FINISHED && CTX_wm_space_text(C)->live_edit) text_run_script(C, NULL); @@ -2972,7 +2972,7 @@ void TEXT_OT_insert(wmOperatorType *ot) ot->name = "Insert"; ot->idname = "TEXT_OT_insert"; ot->description = "Insert text at cursor position"; - + /* api callbacks */ ot->exec = text_insert_exec; ot->invoke = text_insert_invoke; @@ -3064,7 +3064,7 @@ void TEXT_OT_find(wmOperatorType *ot) ot->name = "Find Next"; ot->idname = "TEXT_OT_find"; ot->description = "Find specified text"; - + /* api callbacks */ ot->exec = text_find_exec; ot->poll = text_space_edit_poll; @@ -3116,7 +3116,7 @@ void TEXT_OT_find_set_selected(wmOperatorType *ot) ot->name = "Find Set Selected"; ot->idname = "TEXT_OT_find_set_selected"; ot->description = "Find specified text and set as selected"; - + /* api callbacks */ ot->exec = text_find_set_selected_exec; ot->poll = text_space_edit_poll; @@ -3143,7 +3143,7 @@ void TEXT_OT_replace_set_selected(wmOperatorType *ot) ot->name = "Replace Set Selected"; ot->idname = "TEXT_OT_replace_set_selected"; ot->description = "Replace text with specified text and set as selected"; - + /* api callbacks */ ot->exec = text_replace_set_selected_exec; ot->poll = text_space_edit_poll; @@ -3259,11 +3259,11 @@ void TEXT_OT_to_3d_object(wmOperatorType *ot) ot->name = "To 3D Object"; ot->idname = "TEXT_OT_to_3d_object"; ot->description = "Create 3D text object from active text data-block"; - + /* api callbacks */ ot->exec = text_to_3d_object_exec; ot->poll = text_edit_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 41cf6bb3622..03045364e5b 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -74,14 +74,14 @@ /* ************************ main time area region *********************** */ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) -{ - /* draw darkened area outside of active timeline - * frame range used is preview range or scene range +{ + /* draw darkened area outside of active timeline + * frame range used is preview range or scene range */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - + if (PSFRA < PEFRA) { glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); @@ -104,13 +104,13 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene) SpaceTimeCache *stc = stime->caches.first; const float cache_draw_height = (4.0f * UI_DPI_FAC * U.pixelsize); float yoffs = 0.f; - + if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) return; BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0); - /* iterate over pointcaches on the active object, + /* iterate over pointcaches on the active object, * add spacetimecache and vertex array for each */ for (pid = pidlist.first; pid; pid = pid->next) { float col[4], *fp; @@ -161,25 +161,25 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene) fp[0] = (float)i - 0.5f; fp[1] = 0.0; fp += 2; - + fp[0] = (float)i - 0.5f; fp[1] = 1.0; fp += 2; - + fp[0] = (float)i + 0.5f; fp[1] = 1.0; fp += 2; - + fp[0] = (float)i + 0.5f; fp[1] = 0.0; fp += 2; } } - + glPushMatrix(); glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0); glScalef(1.0, cache_draw_height, 0.0); - + switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; @@ -213,11 +213,11 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene) break; } glColor4fv(col); - + glEnable(GL_BLEND); - + glRectf((float)sta, 0.0, (float)end, 1.0); - + col[3] = 0.4f; if (pid->cache->flag & PTCACHE_BAKED) { col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; @@ -226,16 +226,16 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene) col[0] += 0.4f; col[1] += 0.4f; col[2] += 0.4f; } glColor4fv(col); - + glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, stc->array); glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2); glDisableClientState(GL_VERTEX_ARRAY); - + glDisable(GL_BLEND); - + glPopMatrix(); - + yoffs += cache_draw_height; stc = stc->next; @@ -256,14 +256,14 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene) static void time_cache_free(SpaceTime *stime) { SpaceTimeCache *stc; - + for (stc = stime->caches.first; stc; stc = stc->next) { if (stc->array) { MEM_freeN(stc->array); stc->array = NULL; } } - + BLI_freelistN(&stime->caches); } @@ -277,17 +277,17 @@ static void time_cache_refresh(SpaceTime *stime) static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe) { ActKeyColumn *akn = NULL; - + /* sanity checks */ if (ak == NULL) return NULL; - + /* check if this is a match, or whether it is in some subtree */ if (cframe < ak->cfra) akn = time_cfra_find_ak(ak->left, cframe); else if (cframe > ak->cfra) akn = time_cfra_find_ak(ak->right, cframe); - + /* if no match found (or found match), just use the current one */ if (akn == NULL) return ak; @@ -301,16 +301,16 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) bDopeSheet ads = {NULL}; DLRBT_Tree keys; ActKeyColumn *ak; - + float fac1 = (GS(id->name) == ID_GD) ? 0.8f : 0.6f; /* draw GPencil keys taller, to help distinguish them */ float fac2 = 1.0f - fac1; - + float ymin = v2d->tot.ymin; float ymax = v2d->tot.ymax * fac1 + ymin * fac2; - + /* init binarytree-list for getting keyframes */ BLI_dlrbTree_init(&keys); - + /* init dopesheet settings */ if (onlysel) ads.filterflag |= ADS_FILTER_ONLYSEL; @@ -332,12 +332,12 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) default: break; } - + /* build linked-list for searching */ BLI_dlrbTree_linkedlist_sync(&keys); - - /* start drawing keyframes - * - we use the binary-search capabilities of the tree to only start from + + /* start drawing keyframes + * - we use the binary-search capabilities of the tree to only start from * the first visible keyframe (last one can then be easily checked) * - draw within a single GL block to be faster */ @@ -350,7 +350,7 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) glVertex2f(ak->cfra, ymax); } glEnd(); // GL_LINES - + /* free temp stuff */ BLI_dlrbTree_free(&keys); } @@ -412,7 +412,7 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar) Object *ob = CTX_data_active_object(C); View2D *v2d = &ar->v2d; bool onlysel = ((scene->flag & SCE_KEYS_NO_SELONLY) == 0); - + /* set this for all keyframe lines once and for all */ glLineWidth(1.0); @@ -420,7 +420,7 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar) UI_ThemeColor(TH_TIME_KEYFRAME); time_draw_caches_keyframes(CTX_data_main(C), scene, v2d, onlysel); - /* draw grease pencil keyframes (if available) */ + /* draw grease pencil keyframes (if available) */ UI_ThemeColor(TH_TIME_GP_KEYFRAME); if (scene->gpd) { time_draw_idblock_keyframes(v2d, (ID *)scene->gpd, onlysel); @@ -428,8 +428,8 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar) if (ob && ob->gpd) { time_draw_idblock_keyframes(v2d, (ID *)ob->gpd, onlysel); } - - /* draw scene keyframes first + + /* draw scene keyframes first * - don't try to do this when only drawing active/selected data keyframes, * since this can become quite slow */ @@ -438,33 +438,33 @@ static void time_draw_keyframes(const bContext *C, ARegion *ar) UI_ThemeColorShade(TH_TIME_KEYFRAME, -50); time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel); } - - /* draw keyframes from selected objects + + /* draw keyframes from selected objects * - only do the active object if in posemode (i.e. showing only keyframes for the bones) * OR the onlysel flag was set, which means that only active object's keyframes should * be considered */ UI_ThemeColor(TH_TIME_KEYFRAME); - + if (ob && ((ob->mode == OB_MODE_POSE) || onlysel)) { /* draw keyframes for active object only */ time_draw_idblock_keyframes(v2d, (ID *)ob, onlysel); } else { bool active_done = false; - + /* draw keyframes from all selected objects */ CTX_DATA_BEGIN (C, Object *, obsel, selected_objects) { /* last arg is 0, since onlysel doesn't apply here... */ time_draw_idblock_keyframes(v2d, (ID *)obsel, 0); - + /* if this object is the active one, set flag so that we don't draw again */ if (obsel == ob) active_done = true; } CTX_DATA_END; - + /* if active object hasn't been done yet, draw it... */ if (ob && (active_done == 0)) time_draw_idblock_keyframes(v2d, (ID *)ob, 0); @@ -558,9 +558,9 @@ static void time_listener(bScreen *UNUSED(sc), ScrArea *sa, wmNotifier *wmn) static void time_main_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); - + /* own keymap */ keymap = WM_keymap_find(wm->defaultconf, "Timeline", SPACE_TIME, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -576,49 +576,49 @@ static void time_main_region_draw(const bContext *C, ARegion *ar) View2DGrid *grid; View2DScrollers *scrollers; int unit, flag = 0; - + /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); glClear(GL_COLOR_BUFFER_BIT); - + UI_view2d_view_ortho(v2d); - + /* grid */ unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS)); UI_view2d_grid_free(grid); - + ED_region_draw_cb_draw(C, ar, REGION_DRAW_PRE_VIEW); /* start and end frame */ time_draw_sfra_efra(scene, v2d); - + /* current frame */ flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */ if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS; if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); - + UI_view2d_view_ortho(v2d); - + /* keyframes */ time_draw_keyframes(C, ar); - + /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); ED_markers_draw(C, 0); - + /* caches */ time_draw_cache(stime, obact, scene); - + /* callback */ UI_view2d_view_ortho(v2d); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); /* reset view matrix */ UI_view2d_view_restore(C); - + /* scrollers */ scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); @@ -637,7 +637,7 @@ static void time_main_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), case NC_ANIMATION: ED_region_tag_redraw(ar); break; - + case NC_SCENE: switch (wmn->data) { case ND_OB_SELECT: @@ -718,22 +718,22 @@ static SpaceLink *time_new(const bContext *C) /* header */ ar = MEM_callocN(sizeof(ARegion), "header for time"); - + BLI_addtail(&stime->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for time"); - + BLI_addtail(&stime->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + ar->v2d.tot.xmin = (float)(SFRA - 4); ar->v2d.tot.ymin = 0.0f; ar->v2d.tot.xmax = (float)(EFRA + 4); ar->v2d.tot.ymax = 50.0f; - + ar->v2d.cur = ar->v2d.tot; ar->v2d.min[0] = 1.0f; @@ -758,7 +758,7 @@ static SpaceLink *time_new(const bContext *C) static void time_free(SpaceLink *sl) { SpaceTime *stime = (SpaceTime *)sl; - + time_cache_free(stime); } /* spacetype; init callback in ED_area_initialize() */ @@ -767,9 +767,9 @@ static void time_free(SpaceLink *sl) static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa) { SpaceTime *stime = (SpaceTime *)sa->spacedata.first; - + time_cache_free(stime); - + /* enable all cache display */ stime->cache_display |= TIME_CACHE_DISPLAY; stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES); @@ -781,9 +781,9 @@ static SpaceLink *time_duplicate(SpaceLink *sl) { SpaceTime *stime = (SpaceTime *)sl; SpaceTime *stimen = MEM_dupallocN(stime); - + BLI_listbase_clear(&stimen->caches); - + return (SpaceLink *)stimen; } @@ -793,10 +793,10 @@ void ED_spacetype_time(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - + st->spaceid = SPACE_TIME; strncpy(st->name, "Timeline", BKE_ST_MAXNAME); - + st->new = time_new; st->free = time_free; st->init = time_init; @@ -805,29 +805,29 @@ void ED_spacetype_time(void) st->keymap = NULL; st->listener = time_listener; st->refresh = time_refresh; - + /* regions: main window */ art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; - + art->init = time_main_region_init; art->draw = time_main_region_draw; art->listener = time_main_region_listener; art->keymap = time_keymap; art->lock = 1; /* Due to pointcache, see T4960. */ BLI_addhead(&st->regiontypes, art); - + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - + art->init = time_header_region_init; art->draw = time_header_region_draw; art->listener = time_header_region_listener; BLI_addhead(&st->regiontypes, art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 604db19d81a..85e8ca110ef 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -63,16 +63,16 @@ static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op)) scene->r.psfra = frame; else scene->r.sfra = frame; - + if (PEFRA < frame) { if (PRVRANGEON) scene->r.pefra = frame; else scene->r.efra = frame; } - + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); - + return OPERATOR_FINISHED; } @@ -82,14 +82,14 @@ static void TIME_OT_start_frame_set(wmOperatorType *ot) ot->name = "Set Start Frame"; ot->idname = "TIME_OT_start_frame_set"; ot->description = "Set the start frame"; - + /* api callbacks */ ot->exec = time_set_sfra_exec; ot->poll = ED_operator_timeline_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} +} static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op)) @@ -114,9 +114,9 @@ static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op)) else scene->r.sfra = frame; } - + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); - + return OPERATOR_FINISHED; } @@ -126,11 +126,11 @@ static void TIME_OT_end_frame_set(wmOperatorType *ot) ot->name = "Set End Frame"; ot->idname = "TIME_OT_end_frame_set"; ot->description = "Set the end frame"; - + /* api callbacks */ ot->exec = time_set_efra_exec; ot->poll = ED_operator_timeline_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -150,15 +150,15 @@ static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op)) /* set extents of view to start/end frames (Preview Range too) */ v2d->cur.xmin = (float)PSFRA; v2d->cur.xmax = (float)PEFRA; - + /* we need an extra "buffer" factor on either side so that the endpoints are visible */ const float extra = 0.01f * BLI_rctf_size_x(&v2d->cur); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - + /* this only affects this TimeLine instance, so just force redraw of this region */ ED_region_tag_redraw(ar); - + return OPERATOR_FINISHED; } @@ -168,11 +168,11 @@ static void TIME_OT_view_all(wmOperatorType *ot) ot->name = "View All"; ot->idname = "TIME_OT_view_all"; ot->description = "Show the entire playable frame range"; - + /* api callbacks */ ot->exec = time_view_all_exec; ot->poll = ED_operator_timeline_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -183,7 +183,7 @@ static int time_view_frame_exec(bContext *C, wmOperator *op) { const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); ANIM_center_frame(C, smooth_viewtx); - + return OPERATOR_FINISHED; } @@ -193,11 +193,11 @@ static void TIME_OT_view_frame(wmOperatorType *ot) ot->name = "View Frame"; ot->idname = "TIME_OT_view_frame"; ot->description = "Reset viewable area to show range around current frame"; - + /* api callbacks */ ot->exec = time_view_frame_exec; ot->poll = ED_operator_timeline_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -215,7 +215,7 @@ void time_operatortypes(void) void time_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap = WM_keymap_find(keyconf, "Timeline", SPACE_TIME, 0); - + WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "TIME_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c index 662c35be9ac..209b32f45f3 100644 --- a/source/blender/editors/space_userpref/space_userpref.c +++ b/source/blender/editors/space_userpref/space_userpref.c @@ -77,9 +77,9 @@ static SpaceLink *userpref_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void userpref_free(SpaceLink *UNUSED(sl)) -{ +{ // SpaceUserPref *spref = (SpaceUserPref *)sl; - + } @@ -105,7 +105,7 @@ static void userpref_main_region_init(wmWindowManager *wm, ARegion *ar) { /* do not use here, the properties changed in userprefs do a system-wide refresh, then scroller jumps back */ /* ar->v2d.flag &= ~V2D_IS_INITIALISED; */ - + ar->v2d.scroll = V2D_SCROLL_RIGHT | V2D_SCROLL_VERTICAL_HIDE; ED_region_panels_init(wm, ar); @@ -122,7 +122,7 @@ static void userpref_operatortypes(void) static void userpref_keymap(struct wmKeyConfig *UNUSED(keyconf)) { - + } /* add handlers, stuff you only do once or on area/region changes */ diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 7d279b95e3b..ba75ae6f766 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -65,12 +65,12 @@ * - include support for editing the path verts */ /* Set up drawing environment for drawing motion paths */ -void draw_motion_paths_init(View3D *v3d, ARegion *ar) +void draw_motion_paths_init(View3D *v3d, ARegion *ar) { RegionView3D *rv3d = ar->regiondata; - + if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + glPushMatrix(); glLoadMatrixf(rv3d->viewmat); } @@ -97,7 +97,7 @@ static void set_motion_path_color(Scene *scene, bMotionPath *mpath, int i, short if (frame < CFRA) { if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) { /* Custom color: previous frames color is darker than current frame */ - glColor3fv(prev_color); + glColor3fv(prev_color); } else { /* black - before cfra */ @@ -115,7 +115,7 @@ static void set_motion_path_color(Scene *scene, bMotionPath *mpath, int i, short else if (frame > CFRA) { if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) { /* Custom color: next frames color is equal to user selected color */ - glColor3fv(next_color); + glColor3fv(next_color); } else { /* blue - after cfra */ @@ -133,7 +133,7 @@ static void set_motion_path_color(Scene *scene, bMotionPath *mpath, int i, short else { if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) { /* Custom color: current frame color is slightly darker than user selected color */ - glColor3fv(frame_color); + glColor3fv(frame_color); } else { /* green - on cfra */ @@ -149,11 +149,11 @@ static void set_motion_path_color(Scene *scene, bMotionPath *mpath, int i, short #undef SET_INTENSITY } -/* Draw the given motion path for an Object or a Bone +/* Draw the given motion path for an Object or a Bone * - assumes that the viewport has already been initialized properly * i.e. draw_motion_paths_init() has been called */ -void draw_motion_path_instance(Scene *scene, +void draw_motion_path_instance(Scene *scene, Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath) { //RegionView3D *rv3d = ar->regiondata; @@ -182,10 +182,10 @@ void draw_motion_path_instance(Scene *scene, /* Save old line width */ GLfloat old_width; glGetFloatv(GL_LINE_WIDTH, &old_width); - + /* get frame ranges */ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) { - /* With "Around Current", we only choose frames from around + /* With "Around Current", we only choose frames from around * the current frame to draw. */ sfra = CFRA - avs->path_bc; @@ -196,8 +196,8 @@ void draw_motion_path_instance(Scene *scene, sfra = avs->path_sf; efra = avs->path_ef; } - - /* no matter what, we can only show what is in the cache and no more + + /* no matter what, we can only show what is in the cache and no more * - abort if whole range is past ends of path * - otherwise clamp endpoints to extents of path */ @@ -209,22 +209,22 @@ void draw_motion_path_instance(Scene *scene, /* end clamp */ efra = mpath->end_frame; } - + if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) { /* whole path is out of bounds */ return; } - + len = efra - sfra; - + if ((len <= 0) || (mpath->points == NULL)) { return; } - + /* get pointers to parts of path */ sind = sfra - mpath->start_frame; mpv_start = (mpath->points + sind); - + /* draw curve-line of path */ /* Draw lines only if line drawing option is enabled */ if (mpath->flag & MOTIONPATH_FLAG_LINES) { @@ -247,7 +247,7 @@ void draw_motion_path_instance(Scene *scene, /* Point must be bigger than line thickness */ glPointSize(mpath->line_thickness + 1.0); - + /* draw little black point at each frame * NOTE: this is not really visible/noticeable */ @@ -255,7 +255,7 @@ void draw_motion_path_instance(Scene *scene, for (i = 0, mpv = mpv_start; i < len; i++, mpv++) glVertex3fv(mpv->co); glEnd(); - + /* Draw little white dots at each framestep value or replace with custom color */ if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) { glColor4fv(mpath->color); @@ -267,39 +267,39 @@ void draw_motion_path_instance(Scene *scene, for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) glVertex3fv(mpv->co); glEnd(); - - /* Draw big green dot where the current frame is + + /* Draw big green dot where the current frame is * NOTE: this is only done when keyframes are shown, since this adds similar types of clutter */ if ((avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) && - (sfra < CFRA) && (CFRA <= efra)) + (sfra < CFRA) && (CFRA <= efra)) { UI_ThemeColor(TH_CFRAME); - + glPointSize(mpath->line_thickness + 5.0); glBegin(GL_POINTS); mpv = mpv_start + (CFRA - sfra); glVertex3fv(mpv->co); glEnd(); - + UI_ThemeColor(TH_TEXT_HI); } - + /* XXX, this isn't up to date but probably should be kept so. */ invert_m4_m4(ob->imat, ob->obmat); - + /* Draw frame numbers at each framestep value */ if (avs->path_viewflag & MOTIONPATH_VIEW_FNUMS) { unsigned char col[4]; UI_GetThemeColor3ubv(TH_TEXT_HI, col); col[3] = 255; - + for (i = 0, mpv = mpv_start; i < len; i += stepsize, mpv += stepsize) { int frame = sfra + i; char numstr[32]; size_t numstr_len; float co[3]; - + /* only draw framenum if several consecutive highlighted points don't occur on same point */ if (i == 0) { numstr_len = sprintf(numstr, " %d", frame); @@ -310,7 +310,7 @@ void draw_motion_path_instance(Scene *scene, else if ((i >= stepsize) && (i < len - stepsize)) { bMotionPathVert *mpvP = (mpv - stepsize); bMotionPathVert *mpvN = (mpv + stepsize); - + if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) { numstr_len = sprintf(numstr, " %d", frame); mul_v3_m4v3(co, ob->imat, mpv->co); @@ -320,24 +320,24 @@ void draw_motion_path_instance(Scene *scene, } } } - + /* Keyframes - dots and numbers */ if (avs->path_viewflag & MOTIONPATH_VIEW_KFRAS) { unsigned char col[4]; - + AnimData *adt = BKE_animdata_from_id(&ob->id); DLRBT_Tree keys; - + /* build list of all keyframes in active action for object or pchan */ BLI_dlrbTree_init(&keys); - + if (adt) { /* it is assumed that keyframes for bones are all grouped in a single group * unless an option is set to always use the whole action */ if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) { bActionGroup *agrp = BKE_action_group_find_name(adt->action, pchan->name); - + if (agrp) { agroup_to_keylist(adt, agrp, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); @@ -348,11 +348,11 @@ void draw_motion_path_instance(Scene *scene, BLI_dlrbTree_linkedlist_sync(&keys); } } - + /* Draw slightly-larger yellow dots at each keyframe */ UI_GetThemeColor3ubv(TH_VERTEX_SELECT, col); col[3] = 255; - + /* if custom, point must be bigger than line */ if (mpath->flag & MOTIONPATH_FLAG_CUSTOM) { glPointSize(mpath->line_thickness + 3.0); @@ -361,27 +361,27 @@ void draw_motion_path_instance(Scene *scene, glPointSize(4.0f); } glColor3ubv(col); - + glBegin(GL_POINTS); for (i = 0, mpv = mpv_start; i < len; i++, mpv++) { - int frame = sfra + i; + int frame = sfra + i; float mframe = (float)(frame); - + if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) glVertex3fv(mpv->co); } glEnd(); - + /* Draw frame numbers of keyframes */ if (avs->path_viewflag & MOTIONPATH_VIEW_KFNOS) { float co[3]; for (i = 0, mpv = mpv_start; i < len; i++, mpv++) { float mframe = (float)(sfra + i); - + if (BLI_dlrbTree_search_exact(&keys, compare_ak_cfraPtr, &mframe)) { char numstr[32]; size_t numstr_len; - + numstr_len = sprintf(numstr, " %d", (sfra + i)); mul_v3_m4v3(co, ob->imat, mpv->co); view3d_cached_text_draw_add(co, numstr, numstr_len, @@ -389,7 +389,7 @@ void draw_motion_path_instance(Scene *scene, } } } - + BLI_dlrbTree_free(&keys); } } diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 9a2dfd82609..bbda002eb8d 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -93,13 +93,13 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) bArmature *arm = (ob) ? ob->data : NULL; bActionGroup *grp = NULL; short color_index = 0; - + /* sanity check */ if (ELEM(NULL, ob, arm, pose, pchan)) { bcolor = NULL; return; } - + /* only try to set custom color if enabled for armature */ if (arm->flag & ARM_COL_CUSTOM) { /* currently, a bone can only use a custom color set if it's group (if it has one), @@ -111,9 +111,9 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) color_index = grp->customCol; } } - + /* bcolor is a pointer to the color set to use. If NULL, then the default - * color set (based on the theme colors for 3d-view) is used. + * color set (based on the theme colors for 3d-view) is used. */ if (color_index > 0) { bTheme *btheme = UI_GetTheme(); @@ -132,14 +132,14 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) static void cp_shade_color3ub(unsigned char cp[3], const int offset) { int r, g, b; - + r = offset + (int) cp[0]; CLAMP(r, 0, 255); g = offset + (int) cp[1]; CLAMP(g, 0, 255); b = offset + (int) cp[2]; CLAMP(b, 0, 255); - + cp[0] = r; cp[1] = g; cp[2] = b; @@ -153,7 +153,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) { if (bcolor) { unsigned char cp[3]; - + if (boneflag & BONE_DRAW_ACTIVE) { copy_v3_v3_char((char *)cp, bcolor->active); if (!(boneflag & BONE_SELECTED)) { @@ -168,7 +168,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) copy_v3_v3_char((char *)cp, bcolor->solid); cp_shade_color3ub(cp, -50); } - + glColor3ubv(cp); } else { @@ -185,7 +185,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) UI_ThemeColor(TH_WIRE); } } - + return true; } case PCHAN_COLOR_SOLID: @@ -195,7 +195,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) } else UI_ThemeColor(TH_BONE_SOLID); - + return true; } case PCHAN_COLOR_CONSTS: @@ -205,7 +205,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) else if (constflag & PCHAN_HAS_IK) glColor4ub(255, 255, 0, 80); else if (constflag & PCHAN_HAS_SPLINEIK) glColor4ub(200, 255, 0, 80); else if (constflag & PCHAN_HAS_CONST) glColor4ub(0, 255, 120, 80); - + return true; } return false; @@ -232,7 +232,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) else if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_BONE_POSE); else UI_ThemeColor(TH_BONE_SOLID); } - + return true; } case PCHAN_COLOR_SPHEREBONE_END: @@ -252,7 +252,7 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) copy_v3_v3_char((char *)cp, bcolor->solid); cp_shade_color3ub(cp, -30); } - + glColor3ubv(cp); } else { @@ -280,11 +280,11 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag) else UI_ThemeColorShade(TH_BACK, -30); } - + return true; } } - + return false; } @@ -322,7 +322,7 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) { static GLuint displist = 0; float n[3] = {0.0f}; - + glScalef(xsize, ysize, zsize); if (displist == 0) { @@ -331,26 +331,26 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) glBegin(GL_QUADS); n[0] = -1.0; - glNormal3fv(n); + glNormal3fv(n); glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); n[0] = 0; n[1] = -1.0; - glNormal3fv(n); + glNormal3fv(n); glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[1]); n[1] = 0; n[0] = 1.0; - glNormal3fv(n); + glNormal3fv(n); glVertex3fv(cube[4]); glVertex3fv(cube[7]); glVertex3fv(cube[6]); glVertex3fv(cube[5]); n[0] = 0; n[1] = 1.0; - glNormal3fv(n); + glNormal3fv(n); glVertex3fv(cube[7]); glVertex3fv(cube[3]); glVertex3fv(cube[2]); glVertex3fv(cube[6]); n[1] = 0; n[2] = 1.0; - glNormal3fv(n); + glNormal3fv(n); glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[2]); n[2] = -1.0; - glNormal3fv(n); + glNormal3fv(n); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glVertex3fv(cube[0]); glVertex3fv(cube[3]); glEnd(); @@ -363,56 +363,56 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize) static void drawcube_size(float xsize, float ysize, float zsize) { static GLuint displist = 0; - + if (displist == 0) { displist = glGenLists(1); glNewList(displist, GL_COMPILE); - + glBegin(GL_LINE_STRIP); glVertex3fv(cube[0]); glVertex3fv(cube[1]); glVertex3fv(cube[2]); glVertex3fv(cube[3]); glVertex3fv(cube[0]); glVertex3fv(cube[4]); glVertex3fv(cube[5]); glVertex3fv(cube[6]); glVertex3fv(cube[7]); glVertex3fv(cube[4]); glEnd(); - + glBegin(GL_LINES); glVertex3fv(cube[1]); glVertex3fv(cube[5]); glVertex3fv(cube[2]); glVertex3fv(cube[6]); glVertex3fv(cube[3]); glVertex3fv(cube[7]); glEnd(); - + glEndList(); } glScalef(xsize, ysize, zsize); glCallList(displist); - + } static void draw_bonevert(void) { static GLuint displist = 0; - + if (displist == 0) { GLUquadricObj *qobj; - + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - + glPushMatrix(); - + qobj = gluNewQuadric(); - gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0.0, 0.05, 16, 1); - + glRotatef(90, 0, 1, 0); gluDisk(qobj, 0.0, 0.05, 16, 1); - + glRotatef(90, 1, 0, 0); gluDisk(qobj, 0.0, 0.05, 16, 1); - - gluDeleteQuadric(qobj); - + + gluDeleteQuadric(qobj); + glPopMatrix(); glEndList(); } @@ -423,19 +423,19 @@ static void draw_bonevert(void) static void draw_bonevert_solid(void) { static GLuint displist = 0; - + if (displist == 0) { GLUquadricObj *qobj; - + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_FILL); /* Draw tips of a bone */ gluSphere(qobj, 0.05, 8, 5); - gluDeleteQuadric(qobj); - + gluDeleteQuadric(qobj); + glEndList(); } @@ -481,7 +481,7 @@ static const float bone_octahedral_solid_normals[8][3] = { static void draw_bone_octahedral(void) { static GLuint displist = 0; - + if (displist == 0) { displist = glGenLists(1); glNewList(displist, GL_COMPILE); @@ -500,12 +500,12 @@ static void draw_bone_octahedral(void) GL_UNSIGNED_INT, bone_octahedral_wire_square); glDisableClientState(GL_VERTEX_ARRAY); - + glEndList(); } glCallList(displist); -} +} static void draw_bone_solid_octahedral(void) { @@ -543,7 +543,7 @@ static void draw_bone_solid_octahedral(void) } glCallList(displist); -} +} /* *************** Armature drawing, bones ******************* */ @@ -554,7 +554,7 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, if ((boneflag & BONE_CONNECTED) == 0) { if (id != -1) GPU_select_load_id(id | BONESEL_ROOT); - + if (dt <= OB_WIRE) { if (armflag & ARM_EDITMODE) { if (boneflag & BONE_ROOTSEL) UI_ThemeColor(TH_VERTEX_SELECT); @@ -562,22 +562,22 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, } } else { - if (armflag & ARM_POSEMODE) + if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0); else UI_ThemeColor(TH_BONE_SOLID); } - - if (dt > OB_WIRE) + + if (dt > OB_WIRE) draw_bonevert_solid(); - else + else draw_bonevert(); } - + /* Draw tip point */ if (id != -1) GPU_select_load_id(id | BONESEL_TIP); - + if (dt <= OB_WIRE) { if (armflag & ARM_EDITMODE) { if (boneflag & BONE_TIPSEL) UI_ThemeColor(TH_VERTEX_SELECT); @@ -585,19 +585,19 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag, } } else { - if (armflag & ARM_POSEMODE) + if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0); else UI_ThemeColor(TH_BONE_SOLID); } - + glTranslatef(0.0f, 1.0f, 0.0f); - if (dt > OB_WIRE) + if (dt > OB_WIRE) draw_bonevert_solid(); - else + else draw_bonevert(); glTranslatef(0.0f, -1.0f, 0.0f); - + } /* 16 values of sin function (still same result!) */ @@ -632,7 +632,7 @@ static void draw_sphere_bone_dist(float smat[4][4], float imat[4][4], bPoseChann { float head, tail, dist /*, length*/; float *headvec, *tailvec, dirvec[3]; - + /* figure out the sizes of spheres */ if (ebone) { /* this routine doesn't call get_matrix_editbone() that calculates it */ @@ -659,9 +659,9 @@ static void draw_sphere_bone_dist(float smat[4][4], float imat[4][4], bPoseChann headvec = pchan->pose_head; tailvec = pchan->pose_tail; } - + /* ***** draw it ***** */ - + /* move vector to viewspace */ sub_v3_v3v3(dirvec, tailvec, headvec); mul_mat3_m4_v3(smat, dirvec); @@ -689,16 +689,16 @@ static void draw_sphere_bone_dist(float smat[4][4], float imat[4][4], bPoseChann /* move vector back */ mul_mat3_m4_v3(imat, dirvec); - + if (0.0f != normalize_v3(dirvec)) { float norvec[3], vec1[3], vec2[3], vec[3]; int a; - + //mul_v3_fl(dirvec, head); cross_v3_v3v3(norvec, dirvec, imat[2]); - + glBegin(GL_QUAD_STRIP); - + for (a = 0; a < 16; a++) { vec[0] = -si[a] * dirvec[0] + co[a] * norvec[0]; vec[1] = -si[a] * dirvec[1] + co[a] * norvec[1]; @@ -706,13 +706,13 @@ static void draw_sphere_bone_dist(float smat[4][4], float imat[4][4], bPoseChann madd_v3_v3v3fl(vec1, headvec, vec, head); madd_v3_v3v3fl(vec2, headvec, vec, head + dist); - + glColor4ub(255, 255, 255, 50); glVertex3fv(vec1); //glColor4ub(255, 255, 255, 0); glVertex3fv(vec2); } - + for (a = 15; a >= 0; a--) { vec[0] = si[a] * dirvec[0] + co[a] * norvec[0]; vec[1] = si[a] * dirvec[1] + co[a] * norvec[1]; @@ -720,14 +720,14 @@ static void draw_sphere_bone_dist(float smat[4][4], float imat[4][4], bPoseChann madd_v3_v3v3fl(vec1, tailvec, vec, tail); madd_v3_v3v3fl(vec2, tailvec, vec, tail + dist); - + //glColor4ub(255, 255, 255, 50); glVertex3fv(vec1); //glColor4ub(255, 255, 255, 0); glVertex3fv(vec2); } /* make it cyclic... */ - + vec[0] = -si[0] * dirvec[0] + co[0] * norvec[0]; vec[1] = -si[0] * dirvec[1] + co[0] * norvec[1]; vec[2] = -si[0] * dirvec[2] + co[0] * norvec[2]; @@ -739,7 +739,7 @@ static void draw_sphere_bone_dist(float smat[4][4], float imat[4][4], bPoseChann glVertex3fv(vec1); //glColor4ub(255, 255, 255, 0); glVertex3fv(vec2); - + glEnd(); } } @@ -752,12 +752,12 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4], { float head, tail /*, length*/; float *headvec, *tailvec, dirvec[3]; - + /* figure out the sizes of spheres */ if (ebone) { /* this routine doesn't call get_matrix_editbone() that calculates it */ ebone->length = len_v3v3(ebone->head, ebone->tail); - + /*length = ebone->length;*/ /*UNUSED*/ tail = ebone->rad_tail; if (ebone->parent && (boneflag & BONE_CONNECTED)) @@ -777,7 +777,7 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4], headvec = pchan->pose_head; tailvec = pchan->pose_tail; } - + /* sphere root color */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_ROOTSEL) UI_ThemeColor(TH_VERTEX_SELECT); @@ -785,55 +785,55 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4], } else if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); - + /* Draw root point if we are not connected */ if ((boneflag & BONE_CONNECTED) == 0) { if (id != -1) GPU_select_load_id(id | BONESEL_ROOT); - + drawcircball(GL_LINE_LOOP, headvec, head, imat); } - + /* Draw tip point */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_TIPSEL) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_VERTEX); } - + if (id != -1) GPU_select_load_id(id | BONESEL_TIP); - + drawcircball(GL_LINE_LOOP, tailvec, tail, imat); - + /* base */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_SELECT); else UI_ThemeColor(TH_WIRE_EDIT); } - + sub_v3_v3v3(dirvec, tailvec, headvec); - + /* move vector to viewspace */ mul_mat3_m4_v3(smat, dirvec); /* clear zcomp */ dirvec[2] = 0.0f; /* move vector back */ mul_mat3_m4_v3(imat, dirvec); - + if (0.0f != normalize_v3(dirvec)) { float norvech[3], norvect[3], vec[3]; - + copy_v3_v3(vec, dirvec); - + mul_v3_fl(dirvec, head); cross_v3_v3v3(norvech, dirvec, imat[2]); - + mul_v3_fl(vec, tail); cross_v3_v3v3(norvect, vec, imat[2]); - + if (id != -1) GPU_select_load_id(id | BONESEL_BONE); - + glBegin(GL_LINES); add_v3_v3v3(vec, headvec, norvech); @@ -847,7 +847,7 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4], sub_v3_v3v3(vec, tailvec, norvect); glVertex3fv(vec); - + glEnd(); } } @@ -859,7 +859,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co GLUquadricObj *qobj; float head, tail, length; float fac1, fac2; - + glPushMatrix(); qobj = gluNewQuadric(); @@ -880,20 +880,20 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co else head = pchan->bone->rad_head; } - + /* move to z-axis space */ glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); if (dt == OB_SOLID) { /* set up solid drawing */ GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR); - - gluQuadricDrawStyle(qobj, GLU_FILL); + + gluQuadricDrawStyle(qobj, GLU_FILL); } else { - gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); } - + /* sphere root color */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_ROOTSEL) UI_ThemeColor(TH_VERTEX_SELECT); @@ -903,14 +903,14 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co set_pchan_glColor(PCHAN_COLOR_SPHEREBONE_END, boneflag, constflag); else if (dt == OB_SOLID) UI_ThemeColorShade(TH_BONE_SOLID, -30); - + /* Draw root point if we are not connected */ if ((boneflag & BONE_CONNECTED) == 0) { if (id != -1) GPU_select_load_id(id | BONESEL_ROOT); gluSphere(qobj, head, 16, 10); } - + /* Draw tip point */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_TIPSEL) UI_ThemeColor(TH_VERTEX_SELECT); @@ -919,11 +919,11 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co if (id != -1) GPU_select_load_id(id | BONESEL_TIP); - + glTranslatef(0.0f, 0.0f, length); gluSphere(qobj, tail, 16, 10); glTranslatef(0.0f, 0.0f, -length); - + /* base */ if (armflag & ARM_EDITMODE) { if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_SELECT); @@ -933,28 +933,28 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co set_pchan_glColor(PCHAN_COLOR_SPHEREBONE_BASE, boneflag, constflag); else if (dt == OB_SOLID) UI_ThemeColor(TH_BONE_SOLID); - + fac1 = (length - head) / length; fac2 = (length - tail) / length; - + if (length > (head + tail)) { if (id != -1) GPU_select_load_id(id | BONESEL_BONE); - + glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -1.0f); - + glTranslatef(0.0f, 0.0f, head); gluCylinder(qobj, fac1 * head + (1.0f - fac1) * tail, fac2 * tail + (1.0f - fac2) * head, length - head - tail, 16, 1); glTranslatef(0.0f, 0.0f, -head); - + glDisable(GL_POLYGON_OFFSET_FILL); - + /* draw sphere on extrema */ glTranslatef(0.0f, 0.0f, length - tail); gluSphere(qobj, fac2 * tail + (1.0f - fac2) * head, 16, 10); glTranslatef(0.0f, 0.0f, -length + tail); - + glTranslatef(0.0f, 0.0f, head); gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10); } @@ -963,14 +963,14 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co glTranslatef(0.0f, 0.0f, (head + length - tail) / 2.0f); gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10); } - + /* restore */ if (dt == OB_SOLID) { GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } - + glPopMatrix(); - gluDeleteQuadric(qobj); + gluDeleteQuadric(qobj); } static GLubyte bm_dot6[] = {0x0, 0x18, 0x3C, 0x7E, 0x7E, 0x3C, 0x18, 0x0}; @@ -987,15 +987,15 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned BLI_assert(glaGetOneInt(GL_UNPACK_ALIGNMENT) == 1); float length; - - if (pchan) + + if (pchan) length = pchan->bone->length; - else + else length = ebone->length; - + glPushMatrix(); glScalef(length, length, length); - + /* this chunk not in object mode */ if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) { glLineWidth(4.0f); @@ -1010,7 +1010,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned else if (armflag & ARM_EDITMODE) { UI_ThemeColor(TH_WIRE_EDIT); } - + /* Draw root point if we are not connected */ if ((boneflag & BONE_CONNECTED) == 0) { if (G.f & G_PICKSEL) { @@ -1024,15 +1024,15 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glBitmap(8, 8, 4, 4, 0, 0, bm_dot8); } } - + if (id != -1) GPU_select_load_id((GLuint) id | BONESEL_BONE); - + glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f); glEnd(); - + /* tip */ if (G.f & G_PICKSEL) { /* no bitmap in selection mode, crashes 3d cards... */ @@ -1045,17 +1045,17 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glRasterPos3f(0.0f, 1.0f, 0.0f); glBitmap(8, 8, 4, 4, 0, 0, bm_dot7); } - + /* further we send no names */ if (id != -1) GPU_select_load_id(id & 0xFFFF); /* object tag, for bordersel optim */ - + if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_LINEBONE, boneflag, constflag); } - + glLineWidth(2.0); - + /*Draw root point if we are not connected */ if ((boneflag & BONE_CONNECTED) == 0) { if ((G.f & G_PICKSEL) == 0) { @@ -1068,7 +1068,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glBitmap(8, 8, 4, 4, 0, 0, bm_dot6); } } - + if (armflag & ARM_EDITMODE) { if (boneflag & BONE_SELECTED) UI_ThemeColor(TH_EDGE_SELECT); else UI_ThemeColorShade(TH_BACK, -30); @@ -1077,7 +1077,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, 1.0f, 0.0f); glEnd(); - + /* tip */ if ((G.f & G_PICKSEL) == 0) { /* no bitmap in selection mode, crashes 3d cards... */ @@ -1088,11 +1088,11 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glRasterPos3f(0.0f, 1.0f, 0.0f); glBitmap(8, 8, 4, 4, 0, 0, bm_dot5); } - + glPopMatrix(); } -/* A partial copy of b_bone_spline_setup(), with just the parts for previewing editmode curve settings +/* A partial copy of b_bone_spline_setup(), with just the parts for previewing editmode curve settings * * This assumes that prev/next bones don't have any impact (since they should all still be in the "straight" * position here anyway), and that we can simply apply the bbone settings to get the desired effect... @@ -1103,12 +1103,12 @@ static void ebone_spline_preview(EditBone *ebone, Mat4 result_array[MAX_BBONE_SU float mat3[3][3]; float data[MAX_BBONE_SUBDIV + 1][4], *fp; int a; - + length = ebone->length; - + hlength1 = ebone->ease1 * length * 0.390464f; /* 0.5f * sqrt(2) * kappa, the handle length for near-perfect circles */ hlength2 = ebone->ease2 * length * 0.390464f; - + /* find the handle points, since this is inside bone space, the * first point = (0, 0, 0) * last point = (0, length, 0) @@ -1119,12 +1119,12 @@ static void ebone_spline_preview(EditBone *ebone, Mat4 result_array[MAX_BBONE_SU h1[1] = hlength1; h1[2] = ebone->curveInY; roll1 = ebone->roll1; - + h2[0] = ebone->curveOutX; h2[1] = -hlength2; h2[2] = ebone->curveOutY; roll2 = ebone->roll2; - + /* make curve */ if (ebone->segments > MAX_BBONE_SUBDIV) ebone->segments = MAX_BBONE_SUBDIV; @@ -1140,26 +1140,26 @@ static void ebone_spline_preview(EditBone *ebone, Mat4 result_array[MAX_BBONE_SU for (a = 0, fp = data[0]; a < ebone->segments; a++, fp += 4) { sub_v3_v3v3(h1, fp + 4, fp); vec_roll_to_mat3(h1, fp[3], mat3); /* fp[3] is roll */ - + copy_m4_m3(result_array[a].mat, mat3); copy_v3_v3(result_array[a].mat[3], fp); - + /* "extra" scale facs... */ { const int num_segments = ebone->segments; - + const float scaleFactorIn = 1.0f + (ebone->scaleIn - 1.0f) * ((float)(num_segments - a) / (float)num_segments); const float scaleFactorOut = 1.0f + (ebone->scaleOut - 1.0f) * ((float)(a + 1) / (float)num_segments); - + const float scalefac = scaleFactorIn * scaleFactorOut; float bscalemat[4][4], bscale[3]; - + bscale[0] = scalefac; bscale[1] = 1.0f; bscale[2] = scalefac; - + size_to_mat4(bscalemat, bscale); - + /* Note: don't multiply by inverse scale mat here, as it causes problems with scaling shearing and breaking segment chains */ mul_m4_series(result_array[a].mat, result_array[a].mat, bscalemat); } @@ -1169,24 +1169,24 @@ static void ebone_spline_preview(EditBone *ebone, Mat4 result_array[MAX_BBONE_SU static void draw_b_bone_boxes(const short dt, bPoseChannel *pchan, EditBone *ebone, float xwidth, float length, float zwidth) { int segments = 0; - - if (pchan) + + if (pchan) segments = pchan->bone->segments; else if (ebone) segments = ebone->segments; - + if (segments > 1) { float dlen = length / (float)segments; Mat4 bbone[MAX_BBONE_SUBDIV]; int a; - + if (pchan) { b_bone_spline_setup(pchan, 0, bbone); } else if (ebone) { ebone_spline_preview(ebone, bbone); } - + for (a = 0; a < segments; a++) { glPushMatrix(); glMultMatrixf(bbone[a].mat); @@ -1207,7 +1207,7 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl bPoseChannel *pchan, EditBone *ebone) { float xwidth, length, zwidth; - + if (pchan) { xwidth = pchan->bone->xwidth; length = pchan->bone->length; @@ -1218,7 +1218,7 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl length = ebone->length; zwidth = ebone->zwidth; } - + /* draw points only if... */ if (armflag & ARM_EDITMODE) { /* move to unitspace */ @@ -1233,32 +1233,32 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl if (armflag & ARM_POSEMODE) { if (dt <= OB_WIRE) set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); - else + else set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag); } else if (armflag & ARM_EDITMODE) { if (dt == OB_WIRE) { set_ebone_glColor(boneflag); } - else + else UI_ThemeColor(TH_BONE_SOLID); } - + if (id != -1) { GPU_select_load_id((GLuint) id | BONESEL_BONE); } - + /* set up solid drawing */ if (dt > OB_WIRE) { GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR); - + if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag); else UI_ThemeColor(TH_BONE_SOLID); - + draw_b_bone_boxes(OB_SOLID, pchan, ebone, xwidth, length, zwidth); - + /* disable solid drawing */ GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); } @@ -1269,17 +1269,17 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl /* set constraint colors */ if (set_pchan_glColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) { glEnable(GL_BLEND); - + draw_b_bone_boxes(OB_SOLID, pchan, ebone, xwidth, length, zwidth); - + glDisable(GL_BLEND); } - + /* restore colors */ set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); } } - + draw_b_bone_boxes(OB_WIRE, pchan, ebone, xwidth, length, zwidth); } } @@ -1290,27 +1290,27 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len float dlen = length / (float)segments; Mat4 *bbone = bbones; int a; - + for (a = 0; a < segments; a++, bbone++) { glPushMatrix(); glMultMatrixf(bbone->mat); - + glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, dlen, 0.0f); glEnd(); /* GL_LINES */ - + glPopMatrix(); } } else { glPushMatrix(); - + glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, length, 0.0f); glEnd(); - + glPopMatrix(); } } @@ -1322,19 +1322,19 @@ static void draw_wire_bone(const short dt, int armflag, int boneflag, short cons Mat4 *bbones = NULL; int segments = 0; float length; - + if (pchan) { segments = pchan->bone->segments; length = pchan->bone->length; - + if (segments > 1) { b_bone_spline_setup(pchan, 0, bbones_array); bbones = bbones_array; } } - else + else length = ebone->length; - + /* draw points only if... */ if (armflag & ARM_EDITMODE) { /* move to unitspace */ @@ -1344,19 +1344,19 @@ static void draw_wire_bone(const short dt, int armflag, int boneflag, short cons glPopMatrix(); length *= 0.95f; /* make vertices visible */ } - + /* this chunk not in object mode */ if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) { if (id != -1) GPU_select_load_id((GLuint) id | BONESEL_BONE); - + draw_wire_bone_segments(pchan, bbones, length, segments); - + /* further we send no names */ if (id != -1) GPU_select_load_id(id & 0xFFFF); /* object tag, for bordersel optim */ } - + /* colors for modes */ if (armflag & ARM_POSEMODE) { set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); @@ -1364,17 +1364,17 @@ static void draw_wire_bone(const short dt, int armflag, int boneflag, short cons else if (armflag & ARM_EDITMODE) { set_ebone_glColor(boneflag); } - + /* draw normal */ draw_wire_bone_segments(pchan, bbones, length, segments); } static void draw_bone(const short dt, int armflag, int boneflag, short constflag, unsigned int id, float length) { - + /* Draw a 3d octahedral bone, we use normalized space based on length, * for display-lists */ - + glScalef(length, length, length); /* set up solid drawing */ @@ -1382,23 +1382,23 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag GPU_basic_shader_bind(GPU_SHADER_LIGHTING | GPU_SHADER_USE_COLOR); UI_ThemeColor(TH_BONE_SOLID); } - + /* colors for posemode */ if (armflag & ARM_POSEMODE) { if (dt <= OB_WIRE) set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); - else + else set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag); } - - + + draw_bone_points(dt, armflag, boneflag, id); - + /* now draw the bone itself */ if (id != -1) { GPU_select_load_id((GLuint) id | BONESEL_BONE); } - + /* wire? */ if (dt <= OB_WIRE) { /* colors */ @@ -1410,12 +1410,12 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag /* draw constraint colors */ if (set_pchan_glColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) { glEnable(GL_BLEND); - + draw_bone_solid_octahedral(); - + glDisable(GL_BLEND); } - + /* restore colors */ set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); } @@ -1441,18 +1441,18 @@ static void draw_custom_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d, Obje const short dt, int armflag, int boneflag, unsigned int id, float length) { if (ob == NULL) return; - + glScalef(length, length, length); - + /* colors for posemode */ if (armflag & ARM_POSEMODE) { set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, 0); } - + if (id != -1) { GPU_select_load_id((GLuint) id | BONESEL_BONE); } - + draw_object_instance(scene, v3d, rv3d, ob, dt, armflag & ARM_POSEMODE); } @@ -1461,32 +1461,32 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) { bConstraint *con; bPoseChannel *parchan; - + for (con = pchan->constraints.first; con; con = con->next) { if (con->enforce == 0.0f) continue; - + switch (con->type) { case CONSTRAINT_TYPE_KINEMATIC: { bKinematicConstraint *data = (bKinematicConstraint *)con->data; int segcount = 0; - + /* if only_temp, only draw if it is a temporary ik-chain */ if ((only_temp) && !(data->flag & CONSTRAINT_IK_TEMP)) continue; - + setlinestyle(3); glBegin(GL_LINES); - + /* exclude tip from chain? */ if ((data->flag & CONSTRAINT_IK_TIP) == 0) parchan = pchan->parent; else parchan = pchan; - + glVertex3fv(parchan->pose_tail); - + /* Find the chain's root */ while (parchan->parent) { segcount++; @@ -1497,22 +1497,22 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) } if (parchan) glVertex3fv(parchan->pose_head); - + glEnd(); setlinestyle(0); break; } - case CONSTRAINT_TYPE_SPLINEIK: + case CONSTRAINT_TYPE_SPLINEIK: { bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; int segcount = 0; - + setlinestyle(3); glBegin(GL_LINES); - + parchan = pchan; glVertex3fv(parchan->pose_tail); - + /* Find the chain's root */ while (parchan->parent) { segcount++; @@ -1568,11 +1568,11 @@ static void draw_dof_ellipse(float ax, float az) pz = 0.0f; for (i = 1; i < n; i++) { z = staticSine[i]; - + px = 0.0f; for (j = 1; j <= (n - i); j++) { x = staticSine[j]; - + if (j == n - i) { glEnd(); glBegin(GL_TRIANGLES); @@ -1588,7 +1588,7 @@ static void draw_dof_ellipse(float ax, float az) bgl_sphere_project(ax * px, az * pz); bgl_sphere_project(ax * px, az * z); } - + px = x; } pz = z; @@ -1611,10 +1611,10 @@ static void draw_pose_dofs(Object *ob) bArmature *arm = ob->data; bPoseChannel *pchan; Bone *bone; - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; - + if ((bone != NULL) && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) { if (bone->flag & BONE_SELECTED) { if (bone->layer & arm->layer) { @@ -1623,35 +1623,35 @@ static void draw_pose_dofs(Object *ob) float corner[4][3], posetrans[3], mat[4][4]; float phi = 0.0f, theta = 0.0f, scale; int a, i; - + /* in parent-bone pose, but own restspace */ glPushMatrix(); - + copy_v3_v3(posetrans, pchan->pose_mat[3]); glTranslate3fv(posetrans); - + if (pchan->parent) { copy_m4_m4(mat, pchan->parent->pose_mat); mat[3][0] = mat[3][1] = mat[3][2] = 0.0f; glMultMatrixf(mat); } - + copy_m4_m3(mat, pchan->bone->bone_mat); glMultMatrixf(mat); - + scale = bone->length * pchan->size[1]; glScalef(scale, scale, scale); - + if (pchan->ikflag & BONE_IK_XLIMIT) { if (pchan->ikflag & BONE_IK_ZLIMIT) { float amin[3], amax[3]; - + for (i = 0; i < 3; i++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ amin[i] = sinf(pchan->limitmin[i] * 0.5f); amax[i] = sinf(pchan->limitmax[i] * 0.5f); } - + glScalef(1.0f, -1.0f, 1.0f); if ((amin[0] != 0.0f) && (amin[2] != 0.0f)) draw_dof_ellipse(amin[0], amin[2]); @@ -1664,21 +1664,21 @@ static void draw_pose_dofs(Object *ob) glScalef(1.0f, -1.0f, 1.0f); } } - + /* arcs */ if (pchan->ikflag & BONE_IK_ZLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ theta = RAD2DEGF(0.5f * (pchan->limitmin[2] + pchan->limitmax[2])); glRotatef(theta, 0.0f, 0.0f, 1.0f); - + glColor3ub(50, 50, 255); /* blue, Z axis limit */ glBegin(GL_LINE_STRIP); for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ float fac = ((float)a) / 16.0f * 0.5f; - + phi = fac * (pchan->limitmax[2] - pchan->limitmin[2]); - + i = (a == -16) ? 0 : 1; corner[i][0] = sinf(phi); corner[i][1] = cosf(phi); @@ -1686,22 +1686,22 @@ static void draw_pose_dofs(Object *ob) glVertex3fv(corner[i]); } glEnd(); - + glRotatef(-theta, 0.0f, 0.0f, 1.0f); } - + if (pchan->ikflag & BONE_IK_XLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ theta = RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0])); glRotatef(theta, 1.0f, 0.0f, 0.0f); - + glColor3ub(255, 50, 50); /* Red, X axis limit */ glBegin(GL_LINE_STRIP); for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ float fac = ((float)a) / 16.0f * 0.5f; phi = (float)M_PI_2 + fac * (pchan->limitmax[0] - pchan->limitmin[0]); - + i = (a == -16) ? 2 : 3; corner[i][0] = 0.0f; corner[i][1] = sinf(phi); @@ -1709,12 +1709,12 @@ static void draw_pose_dofs(Object *ob) glVertex3fv(corner[i]); } glEnd(); - + glRotatef(-theta, 1.0f, 0.0f, 0.0f); } - + /* out of cone, out of bone */ - glPopMatrix(); + glPopMatrix(); } } } @@ -1753,27 +1753,27 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, bool draw_wire = false; int flag; bool is_cull_enabled; - + /* being set below */ arm->layer_used = 0; - + /* precalc inverse matrix for drawing screen aligned */ if (arm->drawtype == ARM_ENVELOPE) { /* precalc inverse matrix for drawing screen aligned */ copy_m4_m4(smat, rv3d->viewmatob); mul_mat3_m4_fl(smat, 1.0f / len_v3(ob->obmat[0])); invert_m4_m4(imat, smat); - + /* and draw blended distances */ if (arm->flag & ARM_POSEMODE) { glEnable(GL_BLEND); - + if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; if (bone) { - /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] * NOTE: this is the only case with (NO_DEFORM == 0) flag, as this is for envelope influence drawing */ if (((bone->flag & (BONE_HIDDEN_P | BONE_NO_DEFORM | BONE_HIDDEN_PG)) == 0) && @@ -1786,12 +1786,12 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } } } - + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); } } - + /* little speedup, also make sure transparent only draws once */ glCullFace(GL_BACK); if (v3d->flag2 & V3D_BACKFACE_CULLING) { @@ -1804,13 +1804,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* if solid we draw that first, with selection codes, but without names, axes etc */ if (dt > OB_WIRE) { - if (arm->flag & ARM_POSEMODE) + if (arm->flag & ARM_POSEMODE) index = base->selcol; - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; arm->layer_used |= bone->layer; - + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) && ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0)) @@ -1818,24 +1818,24 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (bone->layer & arm->layer) { const bool use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM); glPushMatrix(); - + if (use_custom && pchan->custom_tx) { glMultMatrixf(pchan->custom_tx->pose_mat); } else { glMultMatrixf(pchan->pose_mat); } - + /* catch exception for bone with hidden parent */ flag = bone->flag; if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) { flag &= ~BONE_CONNECTED; } - + /* set temporary flag for drawing bone as active, but only if selected */ if (bone == arm->act_bone) flag |= BONE_DRAW_ACTIVE; - + if (do_const_color) { /* keep color */ } @@ -1888,13 +1888,13 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glPopMatrix(); } } - + if (index != -1) index += 0x10000; /* pose bones count in higher 2 bytes only */ } - + /* very very confusing... but in object mode, solid draw, we cannot do GPU_select_load_id yet, - * stick bones and/or wire custom-shapes are drawn in next loop + * stick bones and/or wire custom-shapes are drawn in next loop */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && (draw_wire == false) && index != -1) { /* object tag, for bordersel optim */ @@ -1902,7 +1902,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, index = -1; } } - + /* custom bone may draw outline double-width */ if (arm->flag & ARM_POSEMODE) { glLineWidth(1.0f); @@ -1914,11 +1914,11 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, { if (arm->flag & ARM_POSEMODE) index = base->selcol; - + /* only draw custom bone shapes that need to be drawn as wires */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; - + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) && ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0) ) @@ -1927,14 +1927,14 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (pchan->custom) { if ((dt < OB_SOLID) || (bone->flag & BONE_DRAWWIRE)) { glPushMatrix(); - + if (pchan->custom_tx) { glMultMatrixf(pchan->custom_tx->pose_mat); } else { glMultMatrixf(pchan->pose_mat); } - + /* prepare colors */ if (do_const_color) { /* 13 October 2009, Disabled this to make ghosting show the right colors (Aligorith) */ @@ -1944,26 +1944,26 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else { glColor3ubv(ob_wire_col); } - + /* catch exception for bone with hidden parent */ flag = bone->flag; if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) flag &= ~BONE_CONNECTED; - + /* set temporary flag for drawing bone as active, but only if selected */ if (bone == arm->act_bone) flag |= BONE_DRAW_ACTIVE; - + draw_custom_bone(scene, v3d, rv3d, pchan->custom, OB_WIRE, arm->flag, flag, index, PCHAN_CUSTOM_DRAW_SIZE(pchan)); - + glPopMatrix(); } } } } - - if (index != -1) + + if (index != -1) index += 0x10000; /* pose bones count in higher 2 bytes only */ } /* stick or wire bones have not been drawn yet so don't clear object selection in this case */ @@ -1978,7 +1978,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if ((dt <= OB_WIRE) || (arm->flag & ARM_POSEMODE) || ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { /* draw line check first. we do selection indices */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE)) { - if (arm->flag & ARM_POSEMODE) + if (arm->flag & ARM_POSEMODE) index = base->selcol; } /* if solid && posemode, we draw again with polygonoffset */ @@ -1987,7 +1987,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } else { /* and we use selection indices if not done yet */ - if (arm->flag & ARM_POSEMODE) + if (arm->flag & ARM_POSEMODE) index = base->selcol; } @@ -1999,7 +1999,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { bone = pchan->bone; arm->layer_used |= bone->layer; - + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ if (((bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) && ((G.f & G_PICKSEL) == 0 || (bone->flag & BONE_UNSELECTABLE) == 0)) @@ -2007,7 +2007,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (bone->layer & arm->layer) { const short constflag = pchan->constflag; if ((do_dashed & DASH_RELATIONSHIP_LINES) && (pchan->parent)) { - /* Draw a line from our root to the parent's tip + /* Draw a line from our root to the parent's tip * - only if V3D_HIDE_HELPLINES is enabled... */ if ((do_dashed & DASH_HELP_LINES) && ((bone->flag & BONE_CONNECTED) == 0)) { @@ -2022,8 +2022,8 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glEnd(); setlinestyle(0); } - - /* Draw a line to IK root bone + + /* Draw a line to IK root bone * - only if temporary chain (i.e. "autoik") */ if (arm->flag & ARM_POSEMODE) { @@ -2039,27 +2039,27 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else if (constflag & PCHAN_HAS_SPLINEIK) { if (bone->flag & BONE_SELECTED) { glColor3ub(150, 200, 50); /* add theme! */ - + GPU_select_load_id(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & DASH_HELP_LINES)); } } } } - + glPushMatrix(); if (arm->drawtype != ARM_ENVELOPE) glMultMatrixf(pchan->pose_mat); - + /* catch exception for bone with hidden parent */ flag = bone->flag; if ((bone->parent) && (bone->parent->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) flag &= ~BONE_CONNECTED; - + /* set temporary flag for drawing bone as active, but only if selected */ if (bone == arm->act_bone) flag |= BONE_DRAW_ACTIVE; - + /* extra draw service for pose mode */ /* set color-set to use */ @@ -2069,7 +2069,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else { set_pchan_colorset(ob, pchan); } - + if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { /* custom bone shapes should not be drawn here! */ } @@ -2085,25 +2085,25 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, draw_b_bone(OB_WIRE, arm->flag, flag, constflag, index, pchan, NULL); else draw_bone(OB_WIRE, arm->flag, flag, constflag, index, bone->length); - + glPopMatrix(); } } - + /* pose bones count in higher 2 bytes only */ - if (index != -1) + if (index != -1) index += 0x10000; } /* restore things */ if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt > OB_WIRE) && (arm->flag & ARM_POSEMODE)) ED_view3d_polygon_offset(rv3d, 0.0); } - + /* restore */ if (is_cull_enabled) { glDisable(GL_CULL_FACE); } - + /* draw DoFs */ if (arm->flag & ARM_POSEMODE) { if (((base->flag & OB_FROMDUPLI) == 0) && ((v3d->flag & V3D_HIDE_HELPLINES) == 0)) { @@ -2134,9 +2134,9 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, col[2] = ob_wire_col[2]; col[3] = 255; } - + if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0) { if (pchan->bone->layer & arm->layer) { @@ -2147,32 +2147,32 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else if (dt > OB_WIRE) { UI_GetThemeColor3ubv(TH_TEXT, col); } - + /* Draw names of bone */ if (arm->flag & ARM_DRAWNAMES) { mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail); view3d_cached_text_draw_add(vec, pchan->name, strlen(pchan->name), 10, 0, col); } - + /* Draw additional axes on the bone tail */ if ((arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE)) { glPushMatrix(); copy_m4_m4(bmat, pchan->pose_mat); bone_matrix_translate_y(bmat, pchan->bone->length); glMultMatrixf(bmat); - + glColor3ubv(col); float viewmat_pchan[4][4]; mul_m4_m4m4(viewmat_pchan, rv3d->viewmatob, bmat); drawaxes(viewmat_pchan, pchan->bone->length * 0.25f, OB_ARROWS); - + glPopMatrix(); } } } } - + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } } @@ -2197,7 +2197,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) float smat[4][4], imat[4][4], bmat[4][4]; unsigned int index; int flag; - + /* being set in code below */ arm->layer_used = 0; @@ -2209,10 +2209,10 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) copy_m4_m4(smat, rv3d->viewmatob); mul_mat3_m4_fl(smat, 1.0f / len_v3(ob->obmat[0])); invert_m4_m4(imat, smat); - + /* and draw blended distances */ glEnable(GL_BLEND); - + if (v3d->zbuf) glDisable(GL_DEPTH_TEST); for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { @@ -2223,11 +2223,11 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) } } } - + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); } - + /* if solid we draw it first */ if ((dt > OB_WIRE) && (arm->drawtype != ARM_LINE)) { for (eBone = arm->edbo->first, index = 0; eBone; eBone = eBone->next, index++) { @@ -2236,17 +2236,17 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) glPushMatrix(); get_matrix_editbone(eBone, bmat); glMultMatrixf(bmat); - + /* catch exception for bone with hidden parent */ flag = eBone->flag; if ((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) { flag &= ~BONE_CONNECTED; } - + /* set temporary flag for drawing bone as active, but only if selected */ if (eBone == arm->act_edbone) flag |= BONE_DRAW_ACTIVE; - + if (arm->drawtype == ARM_ENVELOPE) draw_sphere_bone(OB_SOLID, arm->flag, flag, 0, index, NULL, eBone); else if (arm->drawtype == ARM_B_BONE) @@ -2256,13 +2256,13 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) else { draw_bone(OB_SOLID, arm->flag, flag, 0, index, eBone->length); } - + glPopMatrix(); } } } } - + /* if wire over solid, set offset */ index = -1; GPU_select_load_id(-1); @@ -2270,26 +2270,26 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) if (G.f & G_PICKSEL) index = 0; } - else if (dt > OB_WIRE) + else if (dt > OB_WIRE) ED_view3d_polygon_offset(rv3d, 1.0); - else if (arm->flag & ARM_EDITMODE) + else if (arm->flag & ARM_EDITMODE) index = 0; /* do selection codes */ - + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { arm->layer_used |= eBone->layer; if (eBone->layer & arm->layer) { if ((eBone->flag & BONE_HIDDEN_A) == 0) { - + /* catch exception for bone with hidden parent */ flag = eBone->flag; if ((eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent)) { flag &= ~BONE_CONNECTED; } - + /* set temporary flag for drawing bone as active, but only if selected */ if (eBone == arm->act_edbone) flag |= BONE_DRAW_ACTIVE; - + if (arm->drawtype == ARM_ENVELOPE) { if (dt < OB_SOLID) draw_sphere_bone_wire(smat, imat, arm->flag, flag, 0, index, NULL, eBone); @@ -2298,8 +2298,8 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) glPushMatrix(); get_matrix_editbone(eBone, bmat); glMultMatrixf(bmat); - - if (arm->drawtype == ARM_LINE) + + if (arm->drawtype == ARM_LINE) draw_line_bone(arm->flag, flag, 0, index, NULL, eBone); else if (arm->drawtype == ARM_WIRE) draw_wire_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone); @@ -2307,28 +2307,28 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) draw_b_bone(OB_WIRE, arm->flag, flag, 0, index, NULL, eBone); else draw_bone(OB_WIRE, arm->flag, flag, 0, index, eBone->length); - + glPopMatrix(); } - + /* offset to parent */ if (eBone->parent) { UI_ThemeColor(TH_WIRE_EDIT); GPU_select_load_id(-1); /* -1 here is OK! */ setlinestyle(3); - + glBegin(GL_LINES); glVertex3fv(eBone->parent->tail); glVertex3fv(eBone->head); glEnd(); - + setlinestyle(0); } } } if (index != -1) index++; } - + /* restore */ if (index != -1) { GPU_select_load_id(-1); @@ -2340,7 +2340,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) else if (dt > OB_WIRE) { ED_view3d_polygon_offset(rv3d, 0.0); } - + /* finally names and axes */ if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) { /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ @@ -2348,9 +2348,9 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) float vec[3]; unsigned char col[4]; col[3] = 255; - + if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { if (eBone->layer & arm->layer) { if ((eBone->flag & BONE_HIDDEN_A) == 0) { @@ -2374,14 +2374,14 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) float viewmat_ebone[4][4]; mul_m4_m4m4(viewmat_ebone, rv3d->viewmatob, bmat); drawaxes(viewmat_ebone, eBone->length * 0.25f, OB_ARROWS); - + glPopMatrix(); } - + } } } - + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } } @@ -2399,16 +2399,16 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, ARegion *ar, Object *ob) bAnimVizSettings *avs = &ob->pose->avs; bArmature *arm = ob->data; bPoseChannel *pchan; - + /* setup drawing environment for paths */ draw_motion_paths_init(v3d, ar); - + /* draw paths where they exist and they releated bone is visible */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone->layer & arm->layer) && (pchan->mpath)) draw_motion_path_instance(scene, ob, pchan, avs, pchan->mpath); } - + /* cleanup after drawing */ draw_motion_paths_cleanup(v3d); } @@ -2416,7 +2416,7 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, ARegion *ar, Object *ob) /* ---------- Ghosts --------- */ -/* helper function for ghost drawing - sets/removes flags for temporarily +/* helper function for ghost drawing - sets/removes flags for temporarily * hiding unselected bones while drawing ghosts */ static void ghost_poses_tag_unselected(Object *ob, short unset) @@ -2424,11 +2424,11 @@ static void ghost_poses_tag_unselected(Object *ob, short unset) bArmature *arm = ob->data; bPose *pose = ob->pose; bPoseChannel *pchan; - + /* don't do anything if no hiding any bones */ if ((arm->flag & ARM_GHOST_ONLYSEL) == 0) return; - + /* loop over all pchans, adding/removing tags as appropriate */ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone) && (arm->layer & pchan->bone->layer)) { @@ -2445,7 +2445,7 @@ static void ghost_poses_tag_unselected(Object *ob, short unset) } } -/* draw ghosts that occur within a frame range +/* draw ghosts that occur within a frame range * note: object should be in posemode */ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base *base) @@ -2456,54 +2456,54 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base bPose *posen, *poseo; float start, end, stepsize, range, colfac; int cfrao, flago; - + start = (float)arm->ghostsf; end = (float)arm->ghostef; if (end <= start) return; - + /* prevent infinite loops if this is set to 0 - T49527 */ if (arm->ghostsize < 1) arm->ghostsize = 1; - + stepsize = (float)(arm->ghostsize); range = (float)(end - start); - + /* store values */ ob->mode &= ~OB_MODE_POSE; cfrao = CFRA; flago = arm->flag; arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES); - + /* copy the pose */ poseo = ob->pose; BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ - + glEnable(GL_BLEND); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + /* draw from first frame of range to last */ for (CFRA = (int)start; CFRA <= end; CFRA += (int)stepsize) { colfac = (end - (float)CFRA) / range; UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac))); - + BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, true, false); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - + /* before disposing of temp pose, use it to restore object to a sane state */ BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)cfrao, ADT_RECALC_ALL); - + /* clean up temporary pose */ ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BKE_pose_free(posen); - + /* restore */ CFRA = cfrao; ob->pose = poseo; @@ -2511,7 +2511,7 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base ob->mode |= OB_MODE_POSE; } -/* draw ghosts on keyframes in action within range +/* draw ghosts on keyframes in action within range * - object should be in posemode */ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base *base) @@ -2525,28 +2525,28 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * ActKeyColumn *ak, *akn; float start, end, range, colfac, i; int cfrao, flago; - + start = (float)arm->ghostsf; end = (float)arm->ghostef; if (end <= start) return; - + /* get keyframes - then clip to only within range */ BLI_dlrbTree_init(&keys); action_to_keylist(adt, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); - + range = 0; for (ak = keys.first; ak; ak = akn) { akn = ak->next; - + if ((ak->cfra < start) || (ak->cfra > end)) BLI_freelinkN((ListBase *)&keys, ak); else range++; } if (range == 0) return; - + /* store values */ ob->mode &= ~OB_MODE_POSE; cfrao = CFRA; @@ -2559,32 +2559,32 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * ob->pose = posen; BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ - + glEnable(GL_BLEND); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + /* draw from first frame of range to last */ for (ak = keys.first, i = 0; ak; ak = ak->next, i++) { colfac = i / range; UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac))); - + CFRA = (int)ak->cfra; - + BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, true, false); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - + /* before disposing of temp pose, use it to restore object to a sane state */ BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)cfrao, ADT_RECALC_ALL); - + /* clean up temporary pose */ ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BLI_dlrbTree_free(&keys); BKE_pose_free(posen); - + /* restore */ CFRA = cfrao; ob->pose = poseo; @@ -2603,7 +2603,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) bPose *posen, *poseo; float cur, start, end, stepsize, range, colfac, actframe, ctime; int cfrao, flago; - + /* pre conditions, get an action with sufficient frames */ if (ELEM(NULL, adt, adt->action)) return; @@ -2611,56 +2611,56 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) calc_action_range(adt->action, &start, &end, 0); if (start == end) return; - + /* prevent infinite loops if this is set to 0 - T49527 */ if (arm->ghostsize < 1) arm->ghostsize = 1; - + stepsize = (float)(arm->ghostsize); range = (float)(arm->ghostep) * stepsize + 0.5f; /* plus half to make the for loop end correct */ - + /* store values */ ob->mode &= ~OB_MODE_POSE; cfrao = CFRA; actframe = BKE_nla_tweakedit_remap(adt, (float)CFRA, 0); flago = arm->flag; arm->flag &= ~(ARM_DRAWNAMES | ARM_DRAWAXES); - + /* copy the pose */ poseo = ob->pose; BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ - + glEnable(GL_BLEND); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + /* draw from darkest blend to lowest */ for (cur = stepsize; cur < range; cur += stepsize) { ctime = cur - (float)fmod(cfrao, stepsize); /* ensures consistent stepping */ colfac = ctime / range; UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac))); - + /* only within action range */ if (actframe + ctime >= start && actframe + ctime <= end) { CFRA = (int)BKE_nla_tweakedit_remap(adt, actframe + ctime, NLATIME_CONVERT_MAP); - + if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, NULL, true, false); } } - + ctime = cur + (float)fmod((float)cfrao, stepsize) - stepsize + 1.0f; /* ensures consistent stepping */ colfac = ctime / range; UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0f * sqrtf(colfac))); - + /* only within action range */ if ((actframe - ctime >= start) && (actframe - ctime <= end)) { CFRA = (int)BKE_nla_tweakedit_remap(adt, actframe - ctime, NLATIME_CONVERT_MAP); - + if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); BKE_pose_where_is(scene, ob); @@ -2670,14 +2670,14 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); - + /* before disposing of temp pose, use it to restore object to a sane state */ BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)cfrao, ADT_RECALC_ALL); - + /* clean up temporary pose */ ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BKE_pose_free(posen); - + /* restore */ CFRA = cfrao; ob->pose = poseo; @@ -2719,7 +2719,7 @@ bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); /* only for lighting... */ } } - + /* arm->flag is being used to detect mode... */ /* editmode? */ if (arm->edbo) { @@ -2773,8 +2773,8 @@ bool draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } } draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline); - arm->flag &= ~ARM_POSEMODE; - + arm->flag &= ~ARM_POSEMODE; + if (ob->mode & OB_MODE_POSE) UI_ThemeColor(TH_WIRE); /* restore, for extra draw stuff */ } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index b6bcc592cc8..27180097107 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -104,7 +104,7 @@ static BLI_bitmap *get_tface_mesh_marked_edge_info(Mesh *me, bool draw_select_ed MLoop *ml; int i, j; bool select_set; - + for (i = 0; i < me->totpoly; i++) { mp = &me->mpoly[i]; @@ -197,7 +197,7 @@ void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm, bool d dm->drawMappedFaces(dm, draw_mesh_face_select__drawFaceOptsInv, NULL, NULL, (void *)me, DM_DRAW_SKIP_HIDDEN); glDisable(GL_BLEND); } - + ED_view3d_polygon_offset(rv3d, 1.0); /* Draw Stippled Outline for selected faces */ @@ -330,7 +330,7 @@ static bool set_draw_settings_cached( glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE); - + glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); @@ -342,14 +342,14 @@ static bool set_draw_settings_cached( glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS); glBindTexture(GL_TEXTURE_2D, ima->bindcode[TEXTARGET_TEXTURE_2D]); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); } else { glActiveTexture(GL_TEXTURE1); glDisable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, 0); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); c_badtex = true; GPU_clear_tpage(true); @@ -457,9 +457,9 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O Gtexdraw.canvas = (Gtexdraw.texpaint_material) ? NULL : imapaint->canvas; Gtexdraw.is_tex = is_tex; - /* naughty multitexturing hacks to quickly support stencil + shading + alpha blending + /* naughty multitexturing hacks to quickly support stencil + shading + alpha blending * in new texpaint code. The better solution here would be to support GLSL */ - if (Gtexdraw.is_texpaint) { + if (Gtexdraw.is_texpaint) { glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); @@ -470,7 +470,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA); glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE); glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_PREVIOUS); - + /* load the stencil texture here */ if (Gtexdraw.stencil != NULL) { glActiveTexture(GL_TEXTURE2); @@ -496,7 +496,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O } glActiveTexture(GL_TEXTURE0); } - + Gtexdraw.color_profile = BKE_scene_check_color_management_enabled(scene); Gtexdraw.use_game_mat = (RE_engines_find(scene->r.engine)->flag & RE_GAME) != 0; Gtexdraw.use_backface_culling = (v3d->flag2 & V3D_BACKFACE_CULLING) != 0; @@ -522,7 +522,7 @@ static void draw_textured_end(void) glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_COLOR); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, 0); - } + } glActiveTexture(GL_TEXTURE0); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); /* manual reset, since we don't use tpage */ @@ -542,7 +542,7 @@ static void draw_textured_end(void) * glLightfv(GL_POSITION, ...) which * is transformed by the current matrix... we * need to make sure that matrix is identity. - * + * * It would be better if drawmesh.c kept track * of and restored the light settings it changed. * - zr @@ -710,7 +710,7 @@ static void update_tface_color_layer(DerivedMesh *dm, bool use_mcol) else copy_v3_v3(col, &ma->r); rgb_float_to_uchar((unsigned char *)&lcol.r, col); lcol.a = 255; - + for (j = 0; j < mp->totloop; j++, loop_index++) { finalCol[loop_index] = lcol; } @@ -741,7 +741,7 @@ static DMDrawOption draw_tface_mapped__set_draw(void *userData, int origindex, i else { MTexPoly *tpoly = (me->mtpoly) ? &me->mtpoly[origindex] : NULL; int matnr = mpoly->mat_nr; - + return draw_tface__set_draw(tpoly, (me->mloopcol != NULL), matnr); } } @@ -899,7 +899,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) BKE_bproperty_set_valstr(prop, string); characters = strlen(string); - + if (!BKE_image_has_ibuf(mtpoly->tpage, NULL)) characters = 0; @@ -957,7 +957,7 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d /* correct for negative scale */ if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW); else glFrontFace(GL_CCW); - + /* draw the textured mesh */ draw_textured_begin(scene, v3d, rv3d, ob); @@ -1047,7 +1047,7 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d } draw_textured_end(); - + /* draw edges and selected faces over textured mesh */ if (!(ob == scene->obedit) && (draw_flags & DRAW_FACE_SELECT)) { bool draw_select_edges = (ob->mode & OB_MODE_TEXTURE_PAINT) == 0; @@ -1056,7 +1056,7 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d /* reset from negative scale correction */ glFrontFace(GL_CCW); - + /* in editmode, the blend mode needs to be set in case it was ADD */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } @@ -1207,7 +1207,7 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, TexMatCallback data = {scene, ob, me, dm, shadeless, two_sided_lighting}; bool (*set_face_cb)(void *, int); bool picking = (G.f & G_PICKSEL) != 0; - + /* face hiding callback depending on mode */ if (ob == scene->obedit) set_face_cb = tex_mat_set_face_editmesh_cb; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index c3823627009..cb45a049e11 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -251,11 +251,11 @@ bool check_object_draw_texture(Scene *scene, View3D *v3d, const char drawtype) { return true; } - + if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) { return true; } - + return false; } @@ -304,7 +304,7 @@ bool draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, const char dt) return false; if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return false; - + if (v3d->flag2 & V3D_SHOW_SOLID_MATCAP) return true; @@ -439,62 +439,62 @@ static void draw_xyz_wire(const float viewmat_local_unit[3][3], const float c[3] copy_v3_v3(buffer[n++], v1); copy_v3_v3(buffer[n++], v2); - + /* top left to bottom right */ mul_v3_fl(dy, 2.0f); add_v3_v3(v1, dy); sub_v3_v3(v2, dy); - + copy_v3_v3(buffer[n++], v1); copy_v3_v3(buffer[n++], v2); break; case 1: /* y axis */ line_type = GL_LINES; - + /* bottom left to top right */ mul_v3_fl(dx, 0.75f); negate_v3_v3(v1, dx); sub_v3_v3(v1, dy); copy_v3_v3(v2, dx); add_v3_v3(v2, dy); - + copy_v3_v3(buffer[n++], v1); copy_v3_v3(buffer[n++], v2); - + /* top left to center */ mul_v3_fl(dy, 2.0f); add_v3_v3(v1, dy); zero_v3(v2); - + copy_v3_v3(buffer[n++], v1); copy_v3_v3(buffer[n++], v2); - + break; case 2: /* z axis */ line_type = GL_LINE_STRIP; - + /* start at top left */ negate_v3_v3(v1, dx); add_v3_v3(v1, dy); - + copy_v3_v3(buffer[n++], v1); - + mul_v3_fl(dx, 2.0f); add_v3_v3(v1, dx); copy_v3_v3(buffer[n++], v1); - + mul_v3_fl(dy, 2.0f); sub_v3_v3(v1, dx); sub_v3_v3(v1, dy); - + copy_v3_v3(buffer[n++], v1); - + add_v3_v3(v1, dx); - + copy_v3_v3(buffer[n++], v1); - + break; default: BLI_assert(0); @@ -604,18 +604,18 @@ void drawaxes(const float viewmat_local[4][4], float size, char drawtype) v2[axis] = size; glVertex3fv(v1); glVertex3fv(v2); - + v1[axis] = size * 0.85f; v1[arrow_axis] = -size * 0.08f; glVertex3fv(v1); glVertex3fv(v2); - + v1[arrow_axis] = size * 0.08f; glVertex3fv(v1); glVertex3fv(v2); glEnd(); - + v2[axis] += size * 0.125f; draw_xyz_wire(viewmat_local_unit, v2, size, axis); @@ -771,7 +771,7 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], /* write to near buffer always */ glDepthRange(0.0, 0.0); glEnable(GL_BLEND); - + if (special_color) { if (selstate == ACTIVE || selstate == SELECT) glColor4ub(0x88, 0xFF, 0xFF, 155); else glColor4ub(0x55, 0xCC, 0xCC, 155); @@ -872,7 +872,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write) RegionView3D *rv3d = ar->regiondata; ViewCachedString *vos; int tot = 0; - + BLI_assert(g_v3d_string_level >= 0 && g_v3d_string_level <= 2); /* project first and test */ @@ -911,14 +911,14 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write) glPushMatrix(); wmOrtho2_region_pixelspace(ar); glLoadIdentity(); - + if (depth_write) { if (v3d->zbuf) glDisable(GL_DEPTH_TEST); } else { glDepthMask(0); } - + for (vos = g_v3d_strings[g_v3d_string_level]; vos; vos = vos->next) { if (vos->sco[0] != IS_CLIPPED) { if (col_pack_prev != vos->col.pack) { @@ -941,7 +941,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, bool depth_write) else { glDepthMask(1); } - + glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); @@ -1034,7 +1034,7 @@ static void spotvolume(float lvec[3], float vvec[3], const float inp) /* according definition, we derive cross product is (plane[1],-plane[0],0), en cos = plane[2]);*/ /* translating this comment to english didnt really help me understanding the math! :-) (ton) */ - + q[1] = plane[1]; q[2] = -plane[0]; q[3] = 0; @@ -1203,7 +1203,7 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, (dt > OB_WIRE) && !(G.f & G_PICKSEL) && (la->type == LA_SUN) && - ((la->mode & LA_SHAD_BUF) || + ((la->mode & LA_SHAD_BUF) || (la->mode & LA_SHAD_RAY)) && (la->mode & LA_SHOW_SHADOW_BOX) && !(base->flag & OB_FROMDUPLI) && @@ -1217,7 +1217,7 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, ED_view3d_after_add(v3d->xray ? &v3d->afterdraw_xraytransp : &v3d->afterdraw_transp, base, dflag); return; } - + /* we first draw only the screen aligned & fixed scale stuff */ glPushMatrix(); glLoadMatrixf(rv3d->viewmat); @@ -1256,13 +1256,13 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, } } } - + /* Inner Circle */ glEnable(GL_BLEND); drawcircball(GL_LINE_LOOP, vec, lampsize, imat); glDisable(GL_BLEND); drawcircball(GL_POLYGON, vec, lampsize, imat); - + /* restore */ if ((dflag & DRAW_CONSTCOLOR) == 0) { if (ob->id.us > 1) @@ -1286,24 +1286,24 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, setlinestyle(3); circrad = 0.0f; } - + /* draw the pretty sun rays */ if (la->type == LA_SUN) { float v1[3], v2[3], mat[3][3]; short axis; - + /* setup a 45 degree rotation matrix */ axis_angle_normalized_to_mat3_ex(mat, imat[2], M_SQRT1_2, M_SQRT1_2); /* vectors */ mul_v3_v3fl(v1, imat[0], circrad * 1.2f); mul_v3_v3fl(v2, imat[0], circrad * 2.5f); - + /* center */ glTranslate3fv(vec); - + setlinestyle(3); - + glBegin(GL_LINES); for (axis = 0; axis < 8; axis++) { glVertex3fv(v1); @@ -1312,20 +1312,20 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, mul_m3_v3(mat, v2); } glEnd(); - + glTranslatef(-vec[0], -vec[1], -vec[2]); } - + if (la->type == LA_LOCAL) { if (la->mode & LA_SPHERE) { drawcircball(GL_LINE_LOOP, vec, la->dist, imat); } } - + glPopMatrix(); /* back in object space */ zero_v3(vec); - + if (is_view) { /* skip drawing extra info */ } @@ -1439,7 +1439,7 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, glEnd(); } else if (ELEM(la->type, LA_HEMI, LA_SUN)) { - + /* draw the line from the circle along the dist */ glBegin(GL_LINES); vec[2] = -circrad; @@ -1447,22 +1447,22 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, vec[2] = -la->dist; glVertex3fv(vec); glEnd(); - + if (la->type == LA_HEMI) { /* draw the hemisphere curves */ short axis, steps, dir; float outdist, zdist, mul; zero_v3(vec); outdist = 0.14; mul = 1.4; dir = 1; - + setlinestyle(4); /* loop over the 4 compass points, and draw each arc as a LINE_STRIP */ for (axis = 0; axis < 4; axis++) { float v[3] = {0.0, 0.0, 0.0}; zdist = 0.02; - + glBegin(GL_LINE_STRIP); - + for (steps = 0; steps < 6; steps++) { if (axis == 0 || axis == 1) { /* x axis up, x axis down */ /* make the arcs start at the edge of the energy circle */ @@ -1475,12 +1475,12 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, } v[2] = v[2] - steps * zdist; - + glVertex3fv(v); - + zdist = zdist * mul; } - + glEnd(); /* flip the direction */ dir = -dir; @@ -1506,41 +1506,41 @@ static void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base, glVertex3f(0.0, 0.0, -la->dist); glEnd(); } - + /* and back to viewspace */ glPushMatrix(); glLoadMatrixf(rv3d->viewmat); copy_v3_v3(vec, ob->obmat[3]); setlinestyle(0); - + if ((la->type == LA_SPOT) && (la->mode & LA_SHAD_BUF) && (is_view == false)) { drawshadbuflimits(la, ob->obmat); } - + if ((dflag & DRAW_CONSTCOLOR) == 0) { UI_GetThemeColor4ubv(TH_LAMP, col); glColor4ubv(col); } glEnable(GL_BLEND); - + if (vec[2] > 0) vec[2] -= circrad; else vec[2] += circrad; - + glBegin(GL_LINES); glVertex3fv(vec); vec[2] = 0; glVertex3fv(vec); glEnd(); - + glPointSize(2.0); glBegin(GL_POINTS); glVertex3fv(vec); glEnd(); - + glDisable(GL_BLEND); - + if ((dflag & DRAW_CONSTCOLOR) == 0) { /* restore for drawing extra stuff */ glColor3ubv(ob_wire_col); @@ -2140,10 +2140,10 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base tvec[0] = shift[0] + ((-0.7f * drawsize) * scale[0]); tvec[1] = shift[1] + ((drawsize * (asp[1] + 0.1f)) * scale[1]); glVertex3fv(tvec); /* left */ - + tvec[0] = shift[0] + ((0.7f * drawsize) * scale[0]); glVertex3fv(tvec); /* right */ - + tvec[0] = shift[0]; tvec[1] = shift[1] + ((1.1f * drawsize * (asp[1] + 0.7f)) * scale[1]); glVertex3fv(tvec); /* top */ @@ -2263,7 +2263,7 @@ static void lattice_draw_verts(Lattice *lt, DispList *dl, BPoint *actbp, short s } } } - + glEnd(); } @@ -2274,12 +2274,12 @@ static void drawlattice__point(Lattice *lt, DispList *dl, int u, int v, int w, i if (actdef_wcol) { float col[3]; MDeformWeight *mdw = defvert_find_index(lt->dvert + index, actdef_wcol - 1); - + weight_to_rgb(col, mdw ? mdw->weight : 0.0f); glColor3fv(col); } - + if (dl) { glVertex3fv(&dl->verts[index * 3]); } @@ -2341,12 +2341,12 @@ static void drawlattice(View3D *v3d, Object *ob) const bool is_edit = (lt->editlatt != NULL); dl = BKE_displist_find(&ob->curve_cache->disp, DL_VERTS); - + if (is_edit) { lt = lt->editlatt->latt; UI_ThemeColor(TH_WIRE_EDIT); - + if (ob->defbase.first && lt->dvert) { actdef_wcol = ob->actdef; } @@ -2382,10 +2382,10 @@ static void drawlattice(View3D *v3d, Object *ob) BPoint *actbp = BKE_lattice_active_point_get(lt); if (v3d->zbuf) glDisable(GL_DEPTH_TEST); - + lattice_draw_verts(lt, dl, actbp, 0); lattice_draw_verts(lt, dl, actbp, 1); - + if (v3d->zbuf) glEnable(GL_DEPTH_TEST); } } @@ -2509,7 +2509,7 @@ static void draw_dm_face_centers__mapFunc(void *userData, int index, const float { drawBMSelect_userData *data = userData; BMFace *efa = BM_face_at_index(data->bm, index); - + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN) && (BM_elem_flag_test(efa, BM_ELEM_SELECT) == data->select)) { @@ -2584,7 +2584,7 @@ static void draw_dm_verts__mapFunc(void *userData, int index, const float co[3], if (vs->flag & MVERT_SKIN_ROOT) { float radius = (vs->radius[0] + vs->radius[1]) * 0.5f; glEnd(); - + glColor4ubv(data->th_skin_root); drawcircball(GL_LINES, co, radius, data->imat); @@ -2656,7 +2656,7 @@ static DMDrawOption draw_dm_edges_sel__setDrawOptions(void *userData, int index) /* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */ if (col[3] == 0) return DM_DRAW_OPTION_SKIP; - + glColor4ubv(col); } return DM_DRAW_OPTION_NORMAL; @@ -2670,7 +2670,7 @@ static void draw_dm_edges_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba unsigned char *selCol, unsigned char *actCol, BMEdge *eed_act) { drawDMEdgesSel_userData data; - + data.baseCol = baseCol; data.selCol = selCol; data.actCol = actCol; @@ -2963,7 +2963,7 @@ static DMDrawOption draw_dm_faces_sel__setDrawOptions(void *userData, int index) drawDMFacesSel_userData *data = userData; BMFace *efa = BM_face_at_index(data->bm, index); unsigned char *col; - + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { if (efa == data->efa_act) { glColor4ubv(data->cols[2]); @@ -3052,7 +3052,7 @@ static DMDrawOption draw_dm_creases__setDrawOptions(void *userData, int index) drawDMLayer_userData *data = userData; BMesh *bm = data->bm; BMEdge *eed = BM_edge_at_index(bm, index); - + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { const float crease = BM_ELEM_CD_GET_FLOAT(eed, data->cd_layer_offset); if (crease != 0.0f) { @@ -3184,13 +3184,13 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, glColor4ubv(col); draw_dm_verts(em, cageDM, sel, eve_act, rv3d); } - + if (check_ob_drawface_dot(scene, v3d, obedit->dt)) { glPointSize(fsize); glColor4ubv(fcol); draw_dm_face_centers(em, cageDM, sel); } - + if (pass == 0) { glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); @@ -3212,7 +3212,7 @@ static void draw_em_fancy_edges(BMEditMesh *em, Scene *scene, View3D *v3d, UI_GetThemeColor4ubv(TH_EDGE_SELECT, selCol); UI_GetThemeColor4ubv(TH_WIRE_EDIT, wireCol); UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, actCol); - + /* when sel only is used, don't render wire, only selected, this is used for * textured draw mode when the 'edges' option is disabled */ if (sel_only) @@ -3461,7 +3461,7 @@ static void draw_em_measure_stats(ARegion *ar, View3D *v3d, Object *ob, BMEditMe } (void)0 UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEAREA, col); - + if (dm) { BM_mesh_elem_index_ensure(em->bm, BM_VERT); } @@ -3681,9 +3681,9 @@ static void draw_em_fancy(Scene *scene, ARegion *ar, View3D *v3d, Mesh *me = ob->data; const bool use_occlude_wire = (dt > OB_WIRE) && (v3d->flag2 & V3D_OCCLUDE_WIRE); bool use_depth_offset = false; - + glLineWidth(1); - + BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE); if (check_object_draw_editweight(me, finalDM)) { @@ -3989,7 +3989,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D else if (ob->dtx & OB_DRAWWIRE) { draw_wire = OBDRAW_WIRE_ON_DEPTH; /* draw wire after solid using zoffset and depth buffer adjusment */ } - + /* check polys instead of tessfaces because of dyntopo where tessfaces don't exist */ if (dm->type == DM_TYPE_CCGDM) { no_edges = !subsurf_has_edges(dm); @@ -4195,7 +4195,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D ED_view3d_polygon_offset(rv3d, 1.0); glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ } - + glLineWidth(1.0f); dm->drawEdges(dm, ((dt == OB_WIRE) || no_faces), (ob->dtx & OB_DRAW_ALL_EDGES) != 0); @@ -4204,7 +4204,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D ED_view3d_polygon_offset(rv3d, 0.0); } } - + if (is_obact && BKE_paint_select_vert_test(ob)) { const bool use_depth = (v3d->flag & V3D_ZBUF_SELECT) != 0; glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); @@ -4238,7 +4238,7 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3 } } } - + if (obedit && ob != obedit && ob->data == obedit->data) { if (BKE_key_from_object(ob) || BKE_key_from_object(obedit)) {} else if (ob->modifiers.first || obedit->modifiers.first) {} @@ -4253,7 +4253,7 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3 if (ob == obedit || drawlinked) { DerivedMesh *finalDM, *cageDM; - + if (obedit != ob) { finalDM = cageDM = editbmesh_get_derived_base( ob, em, scene->customdata_mask); @@ -4304,11 +4304,11 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3 draw_mesh_fancy(scene, ar, v3d, rv3d, base, dt, ob_wire_col, dflag); GPU_end_object_materials(); - + if (me->totvert == 0) retval = true; } } - + if ((dflag & DRAW_PICKING) == 0 && (base->flag & OB_FROMDUPLI) == 0 && (v3d->flag2 & V3D_RENDER_SHADOW) == 0) { /* GPU_begin_object_materials checked if this is needed */ if (do_alpha_after) { @@ -4329,7 +4329,7 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3 if (v3d->flag2 & V3D_BACKFACE_CULLING) glDisable(GL_CULL_FACE); - + return retval; } @@ -4343,7 +4343,7 @@ static bool draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3 static bool drawDispListwire_ex(ListBase *dlbase, unsigned int dl_type_mask) { if (dlbase == NULL) return true; - + glEnableClientState(GL_VERTEX_ARRAY); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); @@ -4355,7 +4355,7 @@ static bool drawDispListwire_ex(ListBase *dlbase, unsigned int dl_type_mask) if ((dl_type_mask & (1 << dl->type)) == 0) { continue; } - + const float *data = dl->verts; int parts; @@ -4366,7 +4366,7 @@ static bool drawDispListwire_ex(ListBase *dlbase, unsigned int dl_type_mask) for (parts = 0; parts < dl->parts; parts++) glDrawArrays(GL_LINE_STRIP, parts * dl->nr, dl->nr); - + break; case DL_POLY: @@ -4424,10 +4424,10 @@ static bool drawDispListwire_ex(ListBase *dlbase, unsigned int dl_type_mask) break; } } - + glDisableClientState(GL_VERTEX_ARRAY); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - + return false; } @@ -4449,14 +4449,14 @@ static void drawDispListsolid(ListBase *lb, Object *ob, const short dflag, const unsigned char ob_wire_col[4], const bool use_glsl) { GPUVertexAttribs gattribs; - + if (lb == NULL) return; glEnableClientState(GL_VERTEX_ARRAY); /* track current material, -1 for none (needed for lines) */ short col = -1; - + DispList *dl = lb->first; while (dl) { const float *data = dl->verts; @@ -4928,7 +4928,7 @@ static void draw_particle(ParticleKey *state, int draw_as, short draw, float pix copy_v3_v3(bb->vel, state->vel); psys_make_billboard(bb, xvec, yvec, zvec, bb_center); - + add_v3_v3v3(pdd->vd, bb_center, xvec); add_v3_v3(pdd->vd, yvec); pdd->vd += 3; @@ -5124,7 +5124,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv case PART_DRAW_CROSS: case PART_DRAW_AXIS: /* lets calculate the scale: */ - + if (part->draw_size == 0.0) pixsize_scale = 2.0f; else @@ -5461,14 +5461,14 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if (part->type == PART_HAIR) { if (part->draw & PART_DRAW_GUIDE_HAIRS) { DerivedMesh *hair_dm = psys->hair_out_dm; - + glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - + for (a = 0, pa = psys->particles; a < totpart; a++, pa++) { if (pa->totkey > 1) { HairKey *hkey = pa->hair; - + glVertexPointer(3, GL_FLOAT, sizeof(HairKey), hkey->world_co); #if 0 /* XXX use proper theme color here */ @@ -5480,37 +5480,37 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glDrawArrays(GL_LINE_STRIP, 0, pa->totkey); } } - + if (hair_dm) { MVert *mvert = hair_dm->getVertArray(hair_dm); int i; - + glColor3f(0.9f, 0.4f, 0.4f); - + glBegin(GL_LINES); for (a = 0, pa = psys->particles; a < totpart; a++, pa++) { for (i = 1; i < pa->totkey; ++i) { float v1[3], v2[3]; - + copy_v3_v3(v1, mvert[pa->hair_index + i - 1].co); copy_v3_v3(v2, mvert[pa->hair_index + i].co); - + mul_m4_v3(ob->obmat, v1); mul_m4_v3(ob->obmat, v2); - + glVertex3fv(v1); glVertex3fv(v2); } } glEnd(); } - + glEnableClientState(GL_NORMAL_ARRAY); if ((dflag & DRAW_CONSTCOLOR) == 0) if (part->draw_col == PART_DRAW_COL_MAT) glEnableClientState(GL_COLOR_ARRAY); } - + if (part->draw & PART_DRAW_HAIR_GRID) { ClothModifierData *clmd = psys->clmd; if (clmd) { @@ -5518,10 +5518,10 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv float *gmax = clmd->hair_grid_max; int *res = clmd->hair_grid_res; int i; - + glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - + if (select) UI_ThemeColor(TH_ACTIVE); else @@ -5531,18 +5531,18 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glVertex3f(gmax[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmax[1], gmin[2]); glVertex3f(gmax[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmin[1], gmin[2]); - + glVertex3f(gmin[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmax[1], gmax[2]); glVertex3f(gmax[0], gmax[1], gmax[2]); glVertex3f(gmin[0], gmax[1], gmax[2]); glVertex3f(gmin[0], gmax[1], gmax[2]); glVertex3f(gmin[0], gmin[1], gmax[2]); - + glVertex3f(gmin[0], gmin[1], gmin[2]); glVertex3f(gmin[0], gmin[1], gmax[2]); glVertex3f(gmax[0], gmin[1], gmin[2]); glVertex3f(gmax[0], gmin[1], gmax[2]); glVertex3f(gmin[0], gmax[1], gmin[2]); glVertex3f(gmin[0], gmax[1], gmax[2]); glVertex3f(gmax[0], gmax[1], gmin[2]); glVertex3f(gmax[0], gmax[1], gmax[2]); glEnd(); - + if (select) UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -100); else @@ -5572,7 +5572,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } glEnd(); glDisable(GL_BLEND); - + glEnableClientState(GL_NORMAL_ARRAY); if ((dflag & DRAW_CONSTCOLOR) == 0) if (part->draw_col == PART_DRAW_COL_MAT) @@ -5580,7 +5580,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } } } - + /* draw child particles */ cache = psys->childcache; for (a = 0; a < totchild; a++) { @@ -5684,9 +5684,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glDisableClientState(GL_COLOR_ARRAY); cpack(0xC0C0C0); } - + glVertexPointer(3, GL_FLOAT, 0, pdd->vedata); - + glDrawArrays(GL_LINES, 0, 2 * totve); } @@ -5694,7 +5694,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv glPolygonMode(GL_BACK, polygonmode[1]); /* 7. */ - + GPU_basic_shader_bind(GPU_SHADER_USE_COLOR); glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); @@ -6124,9 +6124,9 @@ static void drawvertsN(Nurb *nu, const char sel, const bool hide_handles, const UI_ThemeColor(color); glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); - + glBegin(GL_POINTS); - + if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; @@ -6173,7 +6173,7 @@ static void drawvertsN(Nurb *nu, const char sel, const bool hide_handles, const bp++; } } - + glEnd(); } @@ -6375,7 +6375,7 @@ static void draw_editnurb( return; if (v3d->zbuf) glDepthFunc(GL_ALWAYS); - + /* first non-selected and active handles */ int index = 0; for (nu = nurb; nu; nu = nu->next) { @@ -6394,7 +6394,7 @@ static void draw_editnurb( drawhandlesN(nu, 1, hide_handles); drawvertsN(nu, 0, hide_handles, NULL); } - + if (v3d->zbuf) glDepthFunc(GL_LEQUAL); glColor3ubv(wire_col); @@ -6408,7 +6408,7 @@ static void draw_editnurb( BevPoint *bevp = bl->bevpoints; int nr = bl->nr; int skip = nu->resolu / 16; - + while (nr-- > 0) { /* accounts for empty bevel lists */ const float fac = bevp->radius * ts->normalsize; float vec_a[3]; /* Offset perpendicular to the curve */ @@ -6417,7 +6417,7 @@ static void draw_editnurb( vec_a[0] = fac; vec_a[1] = 0.0f; vec_a[2] = 0.0f; - + mul_qt_v3(bevp->quat, vec_a); madd_v3_v3fl(vec_a, bevp->dir, -fac); @@ -6432,7 +6432,7 @@ static void draw_editnurb( glVertex3fv(bevp->vec); glVertex3fv(vec_b); glEnd(); - + bevp += skip + 1; nr -= skip; } @@ -6440,11 +6440,11 @@ static void draw_editnurb( } if (v3d->zbuf) glDepthFunc(GL_ALWAYS); - + for (nu = nurb; nu; nu = nu->next) { drawvertsN(nu, 1, hide_handles, vert); } - + if (v3d->zbuf) glDepthFunc(GL_LEQUAL); } @@ -6593,31 +6593,31 @@ static void draw_editfont(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *b static void draw_empty_sphere(float size) { static GLuint displist = 0; - + if (displist == 0) { GLUquadricObj *qobj; - + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - + glPushMatrix(); - + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0.0, 1, 16, 1); - + glRotatef(90, 0, 1, 0); gluDisk(qobj, 0.0, 1, 16, 1); - + glRotatef(90, 1, 0, 0); gluDisk(qobj, 0.0, 1, 16, 1); - + gluDeleteQuadric(qobj); - + glPopMatrix(); glEndList(); } - + glScalef(size, size, size); glCallList(displist); glScalef(1.0f / size, 1.0f / size, 1.0f / size); @@ -6630,15 +6630,15 @@ static void draw_empty_cone(float size) GLUquadricObj *qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); - + glPushMatrix(); - + glScalef(radius, size * 2.0f, radius); glRotatef(-90.0, 1.0, 0.0, 0.0); gluCylinder(qobj, 1.0, 0.0, 1.0, 8, 1); glPopMatrix(); - + gluDeleteQuadric(qobj); } @@ -6718,10 +6718,10 @@ static void drawcircle_size(float size) for (short degrees = 0; degrees < CIRCLE_RESOL; degrees++) { float x = cosval[degrees]; float y = sinval[degrees]; - + glVertex3f(x * size, 0.0f, y * size); } - + glEnd(); } @@ -6779,7 +6779,7 @@ static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, MetaElem *ml; float imat[4][4]; int code = 1; - + MetaBall *mb = ob->data; if (mb->editelems) { @@ -6816,7 +6816,7 @@ static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, glColor3ubv(ob_wire_col); } } - + glLineWidth(1.0f); while (ml) { @@ -6826,7 +6826,7 @@ static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, if ((ml->flag & SELECT) && (ml->flag & MB_SCALE_RAD)) cpack(0xA0A0F0); else cpack(0x3030A0); } - + if (G.f & G_PICKSEL) { ml->selcol1 = code; GPU_select_load_id(code++); @@ -6840,14 +6840,14 @@ static bool drawmball(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, if ((ml->flag & SELECT) && !(ml->flag & MB_SCALE_RAD)) cpack(0xA0F0A0); else cpack(0x30A030); } - + if (G.f & G_PICKSEL) { ml->selcol2 = code; GPU_select_load_id(code++); } drawcircball(GL_LINE_LOOP, &(ml->x), ml->rad * atanf(ml->s) / (float)M_PI_2, imat); } - + ml = ml->next; } return false; @@ -6861,14 +6861,14 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d, float vec[3] = {0.0, 0.0, 0.0}; /* scale size of circle etc with the empty drawsize */ const float size = (ob->type == OB_EMPTY) ? ob->empty_drawsize : 1.0f; - + /* calculus here, is reused in PFIELD_FORCE */ invert_m4_m4(imat, rv3d->viewmatob); #if 0 normalize_v3(imat[0]); /* we don't do this because field doesnt scale either... apart from wind! */ normalize_v3(imat[1]); #endif - + if (pd->forcefield == PFIELD_WIND) { float force_val = pd->f_strength; @@ -6886,7 +6886,7 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d, vec[2] = 1.5f * force_val; drawcircball(GL_LINE_LOOP, vec, size, tmat); vec[2] = 0.0f; /* reset vec for max dist circle */ - + } else if (pd->forcefield == PFIELD_FORCE) { float ffall_val = pd->f_power; @@ -6935,7 +6935,7 @@ static void draw_forcefield(Object *ob, RegionView3D *rv3d, setlinestyle(0); where_on_path(ob, 0.0f, guidevec1, guidevec2, NULL, NULL, NULL); drawcircball(GL_LINE_LOOP, guidevec1, mindist, imat); - + copy_v3_v3(vec, guidevec1); /* max center */ } } @@ -7006,7 +7006,7 @@ static void draw_box(const float vec[8][3], bool solid) { glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT, 0, vec); - + if (solid) { const GLubyte indices[24] = {0, 1, 2, 3, 7, 6, 5, 4, 4, 5, 1, 0, 3, 2, 6, 7, 3, 7, 4, 0, 1, 5, 6, 2}; glDrawRangeElements(GL_QUADS, 0, 7, 24, GL_UNSIGNED_BYTE, indices); @@ -7023,9 +7023,9 @@ static void draw_bb_quadric(BoundBox *bb, char type, bool around_origin) { float size[3], cent[3]; GLUquadricObj *qobj = gluNewQuadric(); - + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); - + BKE_boundbox_calc_size_aabb(bb, size); if (around_origin) { @@ -7034,7 +7034,7 @@ static void draw_bb_quadric(BoundBox *bb, char type, bool around_origin) else { BKE_boundbox_calc_center_aabb(bb, cent); } - + glPushMatrix(); if (type == OB_BOUND_SPHERE) { float scale = MAX3(size[0], size[1], size[2]); @@ -7064,7 +7064,7 @@ static void draw_bb_quadric(BoundBox *bb, char type, bool around_origin) gluSphere(qobj, radius, 8, 4); } glPopMatrix(); - + gluDeleteQuadric(qobj); } @@ -7072,7 +7072,7 @@ static void draw_bounding_volume(Object *ob, char type) { BoundBox bb_local; BoundBox *bb = NULL; - + if (ob->type == OB_MESH) { bb = BKE_mesh_boundbox_get(ob); } @@ -7095,24 +7095,24 @@ static void draw_bounding_volume(Object *ob, char type) bb = &bb_local; BKE_boundbox_init_from_minmax(bb, min, max); } - + if (bb == NULL) return; - + if (ob->gameflag & OB_BOUNDS) { /* bounds need to be drawn around origin for game engine */ if (type == OB_BOUND_BOX) { float vec[8][3], size[3]; - + BKE_boundbox_calc_size_aabb(bb, size); - + vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0]; vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0]; vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1]; vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1]; vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2]; vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2]; - + draw_box(vec, false); } else { @@ -7130,7 +7130,7 @@ static void draw_bounding_volume(Object *ob, char type) static void drawtexspace(Object *ob) { float vec[8][3], loc[3], size[3]; - + if (ob->type == OB_MESH) { BKE_mesh_texspace_get(ob->data, loc, NULL, size); } @@ -7148,13 +7148,13 @@ static void drawtexspace(Object *ob) vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = loc[0] - size[0]; vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = loc[0] + size[0]; - + vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = loc[1] - size[1]; vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = loc[1] + size[1]; vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = loc[2] - size[2]; vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = loc[2] + size[2]; - + setlinestyle(2); draw_box(vec, false); @@ -7169,9 +7169,9 @@ static void draw_object_selected_outline( { RegionView3D *rv3d = ar->regiondata; Object *ob = base->object; - + glDepthMask(0); - + if (ELEM(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { bool has_faces = false; @@ -7426,14 +7426,14 @@ static void draw_rigidbody_shape(Object *ob) switch (ob->rigidbody_object->shape) { case RB_SHAPE_BOX: BKE_boundbox_calc_size_aabb(bb, size); - + vec[0][0] = vec[1][0] = vec[2][0] = vec[3][0] = -size[0]; vec[4][0] = vec[5][0] = vec[6][0] = vec[7][0] = +size[0]; vec[0][1] = vec[1][1] = vec[4][1] = vec[5][1] = -size[1]; vec[2][1] = vec[3][1] = vec[6][1] = vec[7][1] = +size[1]; vec[0][2] = vec[3][2] = vec[4][2] = vec[7][2] = -size[2]; vec[1][2] = vec[2][2] = vec[5][2] = vec[6][2] = +size[2]; - + draw_box(vec, false); break; case RB_SHAPE_SPHERE: @@ -7475,11 +7475,11 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (ob != scene->obedit) { if (ob->restrictflag & OB_RESTRICT_VIEW) return; - + if (render_override) { if (ob->restrictflag & OB_RESTRICT_RENDER) return; - + if (!has_particles && (ob->transflag & (OB_DUPLI & ~OB_DUPLIFRAMES))) return; } @@ -7558,17 +7558,17 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short glLineWidth(1.0f); view3d_cached_text_draw_begin(); - + /* draw motion paths (in view space) */ if (ob->mpath && !render_override) { bAnimVizSettings *avs = &ob->avs; - + /* setup drawing environment for paths */ draw_motion_paths_init(v3d, ar); - + /* draw motion path for object */ draw_motion_path_instance(scene, ob, NULL, avs, ob->mpath); - + /* cleanup after drawing */ draw_motion_paths_cleanup(v3d); } @@ -7693,7 +7693,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short case OB_MBALL: { MetaBall *mb = ob->data; - + if (mb->editelems) drawmball(scene, v3d, rv3d, base, dt, dflag, ob_wire_col); else if (dt == OB_BOUNDBOX) { @@ -7810,7 +7810,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short //glDepthMask(GL_FALSE); glLoadMatrixf(rv3d->viewmat); - + view3d_cached_text_draw_begin(); for (psys = ob->particlesystem.first; psys; psys = psys->next) { @@ -7827,7 +7827,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short view3d_cached_text_draw_end(v3d, ar, 0); glMultMatrixf(ob->obmat); - + //glDepthMask(GL_TRUE); if (col) cpack(col); } @@ -7996,13 +7996,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short setlinestyle(0); } } - + /* return warning, this is cached text draw */ invert_m4_m4(ob->imat, ob->obmat); view3d_cached_text_draw_end(v3d, ar, 1); /* return warning, clear temp flag */ v3d->flag2 &= ~V3D_SHOW_SOLID_MATCAP; - + glLoadMatrixf(rv3d->viewmat); if (zbufoff) { @@ -8057,7 +8057,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short if (dflag == 0 && (v3d->flag & V3D_HIDE_HELPLINES) == 0 && !render_override) { ListBase *list; RigidBodyCon *rbc = ob->rigidbody_constraint; - + /* draw hook center and offset line */ if (ob != scene->obedit) draw_hooks(ob); @@ -8077,15 +8077,15 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short bConstraint *curcon; bConstraintOb *cob; unsigned char col1[4], col2[4]; - + list = &ob->constraints; - + UI_GetThemeColor3ubv(TH_GRID, col1); UI_make_axis_color(col1, col2, 'Z'); glColor3ubv(col2); - + cob = BKE_constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); - + for (curcon = list->first; curcon; curcon = curcon->next) { if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) { /* special case for object solver and follow track constraints because they don't fill @@ -8143,7 +8143,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short } } } - + BKE_constraints_clear_evalob(cob); } /* draw rigid body constraint lines */ @@ -8284,7 +8284,7 @@ static void bbs_mesh_wire(BMEditMesh *em, DerivedMesh *dm, int offset) static DMDrawOption bbs_mesh_mask__setSolidDrawOptions(void *userData, int index) { BMFace *efa = BM_face_at_index(userData, index); - + if (!BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) { return DM_DRAW_OPTION_NORMAL; } @@ -8397,7 +8397,7 @@ static void bbs_mesh_solid_faces(Scene *scene, Object *ob) { DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); Mesh *me = ob->data; - + glColor3ub(0, 0, 0); DM_update_materials(dm, ob); @@ -8494,7 +8494,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r { Mesh *me = ob->data; DerivedMesh *dm = NULL, *edm = NULL; - + if (ob->mode & OB_MODE_EDIT) { edm = editbmesh_get_derived_base(ob, me->edit_btmesh, CD_MASK_BAREMESH); DM_update_materials(edm, ob); @@ -8518,9 +8518,9 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r bool glsl = draw_glsl_material(scene, ob, v3d, dt); GPU_begin_object_materials(v3d, rv3d, scene, ob, glsl, NULL); } - + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); - + if (dm) { dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind); GPU_end_object_materials(); diff --git a/source/blender/editors/space_view3d/drawsimdebug.c b/source/blender/editors/space_view3d/drawsimdebug.c index f8cb031107d..9165147736a 100644 --- a/source/blender/editors/space_view3d/drawsimdebug.c +++ b/source/blender/editors/space_view3d/drawsimdebug.c @@ -48,23 +48,23 @@ static void draw_sim_debug_elements(SimDebugData *debug_data, float imat[4][4]) { GHashIterator iter; - + /**** dots ****/ - + glPointSize(3.0f); glBegin(GL_POINTS); for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { SimDebugElement *elem = BLI_ghashIterator_getValue(&iter); if (elem->type != SIM_DEBUG_ELEM_DOT) continue; - + glColor3f(elem->color[0], elem->color[1], elem->color[2]); glVertex3f(elem->v1[0], elem->v1[1], elem->v1[2]); } glEnd(); - + /**** circles ****/ - + { float circle[16][2] = { {0.000000, 1.000000}, {0.382683, 0.923880}, {0.707107, 0.707107}, {0.923880, 0.382683}, @@ -76,10 +76,10 @@ static void draw_sim_debug_elements(SimDebugData *debug_data, float imat[4][4]) float radius = elem->v2[0]; float co[3]; int i; - + if (elem->type != SIM_DEBUG_ELEM_CIRCLE) continue; - + glColor3f(elem->color[0], elem->color[1], elem->color[2]); glBegin(GL_LINE_LOOP); for (i = 0; i < 16; ++i) { @@ -88,62 +88,62 @@ static void draw_sim_debug_elements(SimDebugData *debug_data, float imat[4][4]) co[2] = 0.0f; mul_mat3_m4_v3(imat, co); add_v3_v3(co, elem->v1); - + glVertex3f(co[0], co[1], co[2]); } glEnd(); } } - + /**** lines ****/ - + glBegin(GL_LINES); for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { SimDebugElement *elem = BLI_ghashIterator_getValue(&iter); if (elem->type != SIM_DEBUG_ELEM_LINE) continue; - + glColor3f(elem->color[0], elem->color[1], elem->color[2]); glVertex3f(elem->v1[0], elem->v1[1], elem->v1[2]); glVertex3f(elem->v2[0], elem->v2[1], elem->v2[2]); } glEnd(); - + /**** vectors ****/ - + glPointSize(2.0f); glBegin(GL_POINTS); for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { SimDebugElement *elem = BLI_ghashIterator_getValue(&iter); if (elem->type != SIM_DEBUG_ELEM_VECTOR) continue; - + glColor3f(elem->color[0], elem->color[1], elem->color[2]); glVertex3f(elem->v1[0], elem->v1[1], elem->v1[2]); } glEnd(); - + glBegin(GL_LINES); for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { SimDebugElement *elem = BLI_ghashIterator_getValue(&iter); float t[3]; if (elem->type != SIM_DEBUG_ELEM_VECTOR) continue; - + glColor3f(elem->color[0], elem->color[1], elem->color[2]); glVertex3f(elem->v1[0], elem->v1[1], elem->v1[2]); add_v3_v3v3(t, elem->v1, elem->v2); glVertex3f(t[0], t[1], t[2]); } glEnd(); - + /**** strings ****/ - + for (BLI_ghashIterator_init(&iter, debug_data->gh); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { SimDebugElement *elem = BLI_ghashIterator_getValue(&iter); if (elem->type != SIM_DEBUG_ELEM_STRING) continue; - + unsigned char col[4]; rgb_float_to_uchar(col, elem->color); col[3] = 255; @@ -157,24 +157,24 @@ void draw_sim_debug_data(Scene *UNUSED(scene), View3D *v3d, ARegion *ar) RegionView3D *rv3d = ar->regiondata; /*Object *ob = base->object;*/ float imat[4][4]; - + if (!_sim_debug_data) return; - + invert_m4_m4(imat, rv3d->viewmatob); - + // glDepthMask(GL_FALSE); // glEnable(GL_BLEND); - + glPushMatrix(); glLoadMatrixf(rv3d->viewmat); - + view3d_cached_text_draw_begin(); draw_sim_debug_elements(_sim_debug_data, imat); view3d_cached_text_draw_end(v3d, ar, false); - + glPopMatrix(); - + // glDepthMask(GL_TRUE); // glDisable(GL_BLEND); } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index d999b9fef0a..833d54efd75 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -86,49 +86,49 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; - + /* add subdiv level; after header */ ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ if (ar == NULL) return NULL; - + arnew = MEM_callocN(sizeof(ARegion), "buttons for view3d"); - + BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype = RGN_TYPE_UI; arnew->alignment = RGN_ALIGN_RIGHT; - + arnew->flag = RGN_FLAG_HIDDEN; - + return arnew; } ARegion *view3d_has_tools_region(ScrArea *sa) { ARegion *ar, *artool = NULL, *arprops = NULL, *arhead; - + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_TOOLS) artool = ar; if (ar->regiontype == RGN_TYPE_TOOL_PROPS) arprops = ar; } - + /* tool region hide/unhide also hides props */ if (arprops && artool) return artool; - + if (artool == NULL) { /* add subdiv level; after header */ for (arhead = sa->regionbase.first; arhead; arhead = arhead->next) if (arhead->regiontype == RGN_TYPE_HEADER) break; - + /* is error! */ if (arhead == NULL) return NULL; - + artool = MEM_callocN(sizeof(ARegion), "tools for view3d"); - + BLI_insertlinkafter(&sa->regionbase, arhead, artool); artool->regiontype = RGN_TYPE_TOOLS; artool->alignment = RGN_ALIGN_LEFT; @@ -138,12 +138,12 @@ ARegion *view3d_has_tools_region(ScrArea *sa) if (arprops == NULL) { /* add extra subdivided region for tool properties */ arprops = MEM_callocN(sizeof(ARegion), "tool props for view3d"); - + BLI_insertlinkafter(&sa->regionbase, artool, arprops); arprops->regiontype = RGN_TYPE_TOOL_PROPS; arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; } - + return artool; } @@ -153,7 +153,7 @@ ARegion *view3d_has_tools_region(ScrArea *sa) RegionView3D *ED_view3d_context_rv3d(bContext *C) { RegionView3D *rv3d = CTX_wm_region_view3d(C); - + if (rv3d == NULL) { ScrArea *sa = CTX_wm_area(C); if (sa && sa->spacetype == SPACE_VIEW3D) { @@ -312,7 +312,7 @@ static SpaceLink *view3d_new(const bContext *C) ARegion *ar; View3D *v3d; RegionView3D *rv3d; - + v3d = MEM_callocN(sizeof(View3D), "initview3d"); v3d->spacetype = SPACE_VIEW3D; v3d->lay = v3d->layact = 1; @@ -327,10 +327,10 @@ static SpaceLink *view3d_new(const bContext *C) v3d->drawtype = OB_SOLID; v3d->gridflag = V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_FLOOR; - + v3d->flag = V3D_SELECT_OUTLINE; v3d->flag2 = V3D_SHOW_RECONSTRUCTION | V3D_SHOW_GPENCIL; - + v3d->lens = 35.0f; v3d->near = 0.01f; v3d->far = 1000.0f; @@ -338,7 +338,7 @@ static SpaceLink *view3d_new(const bContext *C) v3d->twflag |= U.tw_flag & V3D_USE_MANIPULATOR; v3d->twtype = V3D_MANIP_TRANSLATE; v3d->around = V3D_AROUND_CENTER_MEAN; - + v3d->bundle_size = 0.2f; v3d->bundle_drawtype = OB_PLAINAXES; @@ -350,48 +350,48 @@ static SpaceLink *view3d_new(const bContext *C) /* header */ ar = MEM_callocN(sizeof(ARegion), "header for view3d"); - + BLI_addtail(&v3d->regionbase, ar); ar->regiontype = RGN_TYPE_HEADER; ar->alignment = RGN_ALIGN_BOTTOM; - + /* tool shelf */ ar = MEM_callocN(sizeof(ARegion), "toolshelf for view3d"); - + BLI_addtail(&v3d->regionbase, ar); ar->regiontype = RGN_TYPE_TOOLS; ar->alignment = RGN_ALIGN_LEFT; ar->flag = RGN_FLAG_HIDDEN; - + /* tool properties */ ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d"); - + BLI_addtail(&v3d->regionbase, ar); ar->regiontype = RGN_TYPE_TOOL_PROPS; ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; ar->flag = RGN_FLAG_HIDDEN; - + /* buttons/list view */ ar = MEM_callocN(sizeof(ARegion), "buttons for view3d"); - + BLI_addtail(&v3d->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; - + /* main region */ ar = MEM_callocN(sizeof(ARegion), "main region for view3d"); - + BLI_addtail(&v3d->regionbase, ar); ar->regiontype = RGN_TYPE_WINDOW; - + ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region view3d"); rv3d = ar->regiondata; rv3d->viewquat[0] = 1.0f; rv3d->persp = RV3D_PERSP; rv3d->view = RV3D_VIEW_USER; rv3d->dist = 10.0; - + return (SpaceLink *)v3d; } @@ -412,9 +412,9 @@ static void view3d_free(SpaceLink *sl) BLI_freelistN(&vd->bgpicbase); if (vd->localvd) MEM_freeN(vd->localvd); - + if (vd->properties_storage) MEM_freeN(vd->properties_storage); - + /* matcap material, its preview rect gets freed via icons */ if (vd->defmaterial) { if (vd->defmaterial->gpumaterial.first) @@ -441,7 +441,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) View3D *v3do = (View3D *)sl; View3D *v3dn = MEM_dupallocN(sl); BGpic *bgpic; - + /* clear or remove stuff from old */ if (v3dn->localvd) { @@ -452,7 +452,7 @@ static SpaceLink *view3d_duplicate(SpaceLink *sl) if (v3dn->drawtype == OB_RENDER) v3dn->drawtype = OB_SOLID; - + /* copy or clear inside new stuff */ v3dn->defmaterial = NULL; @@ -483,19 +483,19 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; /* object ops. */ - + /* important to be before Pose keymap since they can both be enabled at once */ keymap = WM_keymap_find(wm->defaultconf, "Face Mask", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - - + + keymap = WM_keymap_find(wm->defaultconf, "Weight Paint Vertex Selection", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); /* pose is not modal, operator poll checks for this */ keymap = WM_keymap_find(wm->defaultconf, "Pose", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Object Mode", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -516,13 +516,13 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) keymap = WM_keymap_find(wm->defaultconf, "Sculpt", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Mesh", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Curve", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Armature", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -531,7 +531,7 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) keymap = WM_keymap_find(wm->defaultconf, "Metaball", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + keymap = WM_keymap_find(wm->defaultconf, "Lattice", 0, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); @@ -554,12 +554,12 @@ static void view3d_main_region_init(wmWindowManager *wm, ARegion *ar) keymap = WM_keymap_find(wm->defaultconf, "3D View", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); - + /* add drop boxes */ lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); - + WM_event_add_dropbox_handler(&ar->handlers, lb); - + } static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar) @@ -572,7 +572,7 @@ static void view3d_main_region_exit(wmWindowManager *wm, ARegion *ar) GPU_offscreen_free(rv3d->gpuoffscreen); rv3d->gpuoffscreen = NULL; } - + if (rv3d->compositor) { GPU_fx_compositor_destroy(rv3d->compositor); rv3d->compositor = NULL; @@ -667,7 +667,7 @@ static void view3d_ob_drop_copy(wmDrag *drag, wmDropBox *drop) static void view3d_group_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = drag->poin; - + drop->opcontext = WM_OP_EXEC_DEFAULT; RNA_string_set(drop->ptr, "name", id->name + 2); } @@ -675,14 +675,14 @@ static void view3d_group_drop_copy(wmDrag *drag, wmDropBox *drop) static void view3d_id_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = drag->poin; - + RNA_string_set(drop->ptr, "name", id->name + 2); } static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = drag->poin; - + if (id) { RNA_string_set(drop->ptr, "name", id->name + 2); RNA_struct_property_unset(drop->ptr, "filepath"); @@ -698,13 +698,13 @@ static void view3d_id_path_drop_copy(wmDrag *drag, wmDropBox *drop) static void view3d_dropboxes(void) { ListBase *lb = WM_dropboxmap_find("View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW); - + WM_dropbox_add(lb, "OBJECT_OT_add_named", view3d_ob_drop_poll, view3d_ob_drop_copy); WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy); WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_mesh_drop_poll, view3d_id_path_drop_copy); WM_dropbox_add(lb, "OBJECT_OT_drop_named_image", view3d_ima_empty_drop_poll, view3d_id_path_drop_copy); WM_dropbox_add(lb, "VIEW3D_OT_background_image_add", view3d_ima_bg_drop_poll, view3d_id_path_drop_copy); - WM_dropbox_add(lb, "OBJECT_OT_group_instance_add", view3d_group_drop_poll, view3d_group_drop_copy); + WM_dropbox_add(lb, "OBJECT_OT_group_instance_add", view3d_group_drop_poll, view3d_group_drop_copy); } @@ -713,14 +713,14 @@ static void view3d_dropboxes(void) static void view3d_main_region_free(ARegion *ar) { RegionView3D *rv3d = ar->regiondata; - + if (rv3d) { if (rv3d->localvd) MEM_freeN(rv3d->localvd); if (rv3d->clipbb) MEM_freeN(rv3d->clipbb); if (rv3d->render_engine) RE_engine_free(rv3d->render_engine); - + if (rv3d->depths) { if (rv3d->depths->depths) MEM_freeN(rv3d->depths->depths); MEM_freeN(rv3d->depths); @@ -745,20 +745,20 @@ static void *view3d_main_region_duplicate(void *poin) { if (poin) { RegionView3D *rv3d = poin, *new; - + new = MEM_dupallocN(rv3d); if (rv3d->localvd) new->localvd = MEM_dupallocN(rv3d->localvd); if (rv3d->clipbb) new->clipbb = MEM_dupallocN(rv3d->clipbb); - + new->depths = NULL; new->gpuoffscreen = NULL; new->render_engine = NULL; new->sms = NULL; new->smooth_timer = NULL; new->compositor = NULL; - + return new; } return NULL; @@ -798,7 +798,7 @@ static void view3d_main_region_listener(bScreen *sc, ScrArea *sa, ARegion *ar, w { Scene *scene = sc->scene; View3D *v3d = sa->spacedata.first; - + /* context changes */ switch (wmn->category) { case NC_ANIMATION: @@ -1037,7 +1037,7 @@ static void view3d_main_region_cursor(wmWindow *win, ScrArea *UNUSED(sa), ARegio static void view3d_header_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); - + WM_event_add_keymap_handler(&ar->handlers, keymap); ED_region_header_init(ar); @@ -1084,7 +1084,7 @@ static void view3d_buttons_region_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; ED_region_panels_init(wm, ar); - + keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); WM_event_add_keymap_handler(&ar->handlers, keymap); } @@ -1188,7 +1188,7 @@ static void view3d_buttons_region_listener(bScreen *UNUSED(sc), ScrArea *UNUSED( static void view3d_tools_region_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - + ED_region_panels_init(wm, ar); keymap = WM_keymap_find(wm->defaultconf, "3D View Generic", SPACE_VIEW3D, 0); @@ -1359,7 +1359,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT)) CTX_data_pointer_set(result, &scene->id, &RNA_ObjectBase, scene->basact); } - + return 1; } else if (CTX_data_equals(member, "active_object")) { @@ -1371,7 +1371,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes if ((ob->restrictflag & OB_RESTRICT_VIEW) == 0 || (ob->mode & OB_MODE_EDIT)) CTX_data_id_pointer_set(result, &scene->basact->object->id); } - + return 1; } else { @@ -1447,10 +1447,10 @@ void ED_spacetype_view3d(void) { SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype view3d"); ARegionType *art; - + st->spaceid = SPACE_VIEW3D; strncpy(st->name, "View3D", BKE_ST_MAXNAME); - + st->new = view3d_new; st->free = view3d_free; st->init = view3d_init; @@ -1475,7 +1475,7 @@ void ED_spacetype_view3d(void) art->cursor = view3d_main_region_cursor; art->lock = 1; /* can become flag, see BKE_spacedata_draw_locks */ BLI_addhead(&st->regiontypes, art); - + /* regions: listview/buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d buttons region"); art->regionid = RGN_TYPE_UI; @@ -1498,7 +1498,7 @@ void ED_spacetype_view3d(void) art->init = view3d_tools_region_init; art->draw = view3d_tools_region_draw; BLI_addhead(&st->regiontypes, art); - + #if 0 /* unfinished still */ view3d_toolshelf_register(art); @@ -1514,10 +1514,10 @@ void ED_spacetype_view3d(void) art->init = view3d_tools_region_init; art->draw = view3d_tools_region_draw; BLI_addhead(&st->regiontypes, art); - + view3d_tool_props_register(art); - - + + /* regions: header */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d header region"); art->regionid = RGN_TYPE_HEADER; @@ -1527,7 +1527,7 @@ void ED_spacetype_view3d(void) art->init = view3d_header_region_init; art->draw = view3d_header_region_draw; BLI_addhead(&st->regiontypes, art); - + BKE_spacetype_register(st); } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 0c67776693d..fbbc5bd7bb9 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -833,7 +833,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) bcol = uiLayoutColumn(pa->layout, true); row = uiLayoutRow(bcol, true); /* The filter button row */ - + RNA_pointer_create(NULL, &RNA_ToolSettings, ts, &tools_ptr); uiItemR(row, &tools_ptr, "vertex_group_subset", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -862,7 +862,7 @@ static void view3d_panel_vgroup(const bContext *C, Panel *pa) UI_but_flag_enable(but, UI_BUT_INACTIVE); } xco += x; - + row = uiLayoutRow(split, true); uiLayoutSetEnabled(row, !locked); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index b167f731852..d8247caa5c2 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -124,35 +124,35 @@ extern void bl_debug_color_set(const unsigned int col); void circf(float x, float y, float rad) { - GLUquadricObj *qobj = gluNewQuadric(); - - gluQuadricDrawStyle(qobj, GLU_FILL); - - glPushMatrix(); - + GLUquadricObj *qobj = gluNewQuadric(); + + gluQuadricDrawStyle(qobj, GLU_FILL); + + glPushMatrix(); + glTranslatef(x, y, 0.0); - + gluDisk(qobj, 0.0, rad, 32, 1); - - glPopMatrix(); - + + glPopMatrix(); + gluDeleteQuadric(qobj); } void circ(float x, float y, float rad) { - GLUquadricObj *qobj = gluNewQuadric(); - - gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); - - glPushMatrix(); - + GLUquadricObj *qobj = gluNewQuadric(); + + gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); + + glPushMatrix(); + glTranslatef(x, y, 0.0); - + gluDisk(qobj, 0.0, rad, 32, 1); - - glPopMatrix(); - + + glPopMatrix(); + gluDeleteQuadric(qobj); } @@ -240,7 +240,7 @@ bool ED_view3d_clipping_test(const RegionView3D *rv3d, const float co[3], const static void drawgrid_draw(ARegion *ar, double wx, double wy, double x, double y, double dx) -{ +{ double verts[2][2]; x += (wx); @@ -306,14 +306,14 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** dx = fabs(x - (wx) * fx / fw); if (dx == 0) dx = fabs(y - (wy) * fy / fw); - + glLineWidth(1.0f); glDepthMask(GL_FALSE); /* disable write in zbuffer */ /* check zoom out */ UI_ThemeColor(TH_GRID); - + if (unit->system) { /* Use GRID_MIN_PX * 2 for units because very very small grid * items are less useful when dealing with units */ @@ -430,23 +430,23 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** UI_GetThemeColor3ubv(TH_GRID, col); setlinestyle(0); - + /* center cross */ /* horizontal line */ if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) UI_make_axis_color(col, col2, 'Y'); else UI_make_axis_color(col, col2, 'X'); glColor3ubv(col2); - - fdrawline(0.0, y, (float)ar->winx, y); - + + fdrawline(0.0, y, (float)ar->winx, y); + /* vertical line */ if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) UI_make_axis_color(col, col2, 'Y'); else UI_make_axis_color(col, col2, 'Z'); glColor3ubv(col2); - fdrawline(x, 0.0, x, (float)ar->winy); + fdrawline(x, 0.0, x, (float)ar->winy); glDepthMask(GL_TRUE); /* enable write in zbuffer */ } @@ -485,7 +485,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool wr const int gridlines = v3d->gridlines / 2; if (v3d->gridlines < 3) return; - + /* use 'grid_scale' instead of 'v3d->grid' from now on */ grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit); grid = gridlines * grid_scale; @@ -538,7 +538,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool wr glDisableClientState(GL_VERTEX_ARRAY); } - + /* draw the Z axis line */ /* check for the 'show Z axis' preference */ if (v3d->gridflag & (V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) { @@ -561,7 +561,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit, bool wr } glEnd(); } - + glDepthMask(GL_TRUE); } @@ -575,9 +575,9 @@ static void drawcursor(Scene *scene, ARegion *ar, View3D *v3d) const float f5 = 0.25f * U.widget_unit; const float f10 = 0.5f * U.widget_unit; const float f20 = U.widget_unit; - + glLineWidth(1); - setlinestyle(0); + setlinestyle(0); cpack(0xFF); circ((float)co[0], (float)co[1], f10); setlinestyle(4); @@ -691,7 +691,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) sub_v3_v3v3(end, o, scaled_axis); glVertex3fv(end); glEnd(); - + /* -- draw ring around rotation center -- */ { #define ROT_AXIS_DETAIL 13 @@ -757,7 +757,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) static void draw_view_icon(RegionView3D *rv3d, rcti *rect) { BIFIconID icon; - + if (ELEM(rv3d->view, RV3D_VIEW_TOP, RV3D_VIEW_BOTTOM)) icon = ICON_AXIS_TOP; else if (ELEM(rv3d->view, RV3D_VIEW_FRONT, RV3D_VIEW_BACK)) @@ -765,19 +765,19 @@ static void draw_view_icon(RegionView3D *rv3d, rcti *rect) else if (ELEM(rv3d->view, RV3D_VIEW_RIGHT, RV3D_VIEW_LEFT)) icon = ICON_AXIS_SIDE; else return; - + glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + UI_icon_draw(5.0 + rect->xmin, 5.0 + rect->ymin, icon); - + glDisable(GL_BLEND); } static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) { const char *name = NULL; - + switch (rv3d->view) { case RV3D_VIEW_FRONT: if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Front Ortho"); @@ -803,7 +803,7 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) if (rv3d->persp == RV3D_ORTHO) name = IFACE_("Left Ortho"); else name = IFACE_("Left Persp"); break; - + default: if (rv3d->persp == RV3D_CAMOB) { if ((v3d->camera) && (v3d->camera->type == OB_CAMERA)) { @@ -829,7 +829,7 @@ static const char *view3d_get_name(View3D *v3d, RegionView3D *rv3d) } break; } - + return name; } @@ -857,7 +857,7 @@ static void draw_viewport_name(ARegion *ar, View3D *v3d, rcti *rect) #endif } -/* draw info beside axes in bottom left-corner: +/* draw info beside axes in bottom left-corner: * framenum, object name, bone name (if available), marker name (if available) */ @@ -874,7 +874,7 @@ static void draw_selected_name(Scene *scene, Object *ob, const rcti *rect) s += sprintf(s, "(%d)", cfra); - /* + /* * info can contain: * - a frame (7 + 2) * - 3 object names (MAX_NAME) @@ -885,7 +885,7 @@ static void draw_selected_name(Scene *scene, Object *ob, const rcti *rect) /* get name of marker on current frame (if available) */ markern = BKE_scene_find_marker_name(scene, cfra); - + /* check if there is an object */ if (ob) { *s++ = ' '; @@ -894,7 +894,7 @@ static void draw_selected_name(Scene *scene, Object *ob, const rcti *rect) /* name(s) to display depends on type of object */ if (ob->type == OB_ARMATURE) { bArmature *arm = ob->data; - + /* show name of active bone too (if possible) */ if (arm->edbo) { if (arm->act_edbone) { @@ -943,7 +943,7 @@ static void draw_selected_name(Scene *scene, Object *ob, const rcti *rect) } } } - + /* color depends on whether there is a keyframe */ if (id_frame_has_keyframe((ID *)ob, /* BKE_scene_frame_get(scene) */ (float)cfra, ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_TIME_KEYFRAME); @@ -963,7 +963,7 @@ static void draw_selected_name(Scene *scene, Object *ob, const rcti *rect) if (markern) { s += sprintf(s, " <%s>", markern); } - + if (U.uiflag & USER_SHOW_ROTVIEWICON) offset = U.widget_unit + (U.rvisize * 2) + rect->xmin; @@ -1107,14 +1107,14 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) return; if (v3d->camera->type == OB_CAMERA) ca = v3d->camera->data; - + ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &viewborder, false); /* the offsets */ x1 = viewborder.xmin; y1 = viewborder.ymin; x2 = viewborder.xmax; y2 = viewborder.ymax; - + glLineWidth(1.0f); /* apply offsets so the real 3D camera shows through */ @@ -1128,7 +1128,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) y1i = (int)(y1 - 1.0001f); x2i = (int)(x2 + (1.0f - 0.0001f)); y2i = (int)(y2 + (1.0f - 0.0001f)); - + /* passepartout, specified in camera edit buttons */ if (ca && (ca->flag & CAM_SHOWPASSEPARTOUT) && ca->passepartalpha > 0.000001f) { const float winx = (ar->winx + 1); @@ -1151,14 +1151,14 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) glRectf(x1i, winy, x2i, y2i); if (y2i > 0.0f) glRectf(x1i, y1i, x2i, 0.0); - + glDisable(GL_BLEND); } setlinestyle(0); UI_ThemeColor(TH_BACK); - + fdrawbox(x1i, y1i, x2i, y2i); #ifdef VIEW3D_CAMERA_BORDER_HACK @@ -1364,7 +1364,7 @@ static void backdrawview3d(Scene *scene, wmWindow *win, ARegion *ar, View3D *v3d #endif if (v3d->drawtype > OB_WIRE) v3d->zbuf = true; - + /* dithering and AA break color coding, so disable */ glDisable(GL_DITHER); @@ -1411,10 +1411,10 @@ static void backdrawview3d(Scene *scene, wmWindow *win, ARegion *ar, View3D *v3d glClear(GL_COLOR_BUFFER_BIT); glDisable(GL_DEPTH_TEST); } - + if (rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_set(rv3d); - + G.f |= G_BACKBUFSEL; if (obact && (obact->lay & v3d->lay)) { @@ -1481,7 +1481,7 @@ int ED_view3d_backbuf_sample_size_clamp(ARegion *ar, const float dist) unsigned int ED_view3d_backbuf_sample(ViewContext *vc, int x, int y) { unsigned int col; - + if (x >= vc->ar->winx || y >= vc->ar->winy) { return 0; } @@ -1490,11 +1490,11 @@ unsigned int ED_view3d_backbuf_sample(ViewContext *vc, int x, int y) view3d_opengl_read_pixels(vc->ar, x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &col); glReadBuffer(GL_BACK); - + if (ENDIAN_ORDER == B_ENDIAN) { BLI_endian_switch_uint32(&col); } - + return GPU_select_to_index(col); } @@ -1529,7 +1529,7 @@ ImBuf *ED_view3d_backbuf_read(ViewContext *vc, int xmin, int ymin, int xmax, int } GPU_select_to_index_array(ibuf_clip->rect, size_clip[0] * size_clip[1]); - + if ((clip.xmin == xmin) && (clip.xmax == xmax) && (clip.ymin == ymin) && @@ -1577,19 +1577,19 @@ uint ED_view3d_backbuf_sample_rect( if (!buf) return 0; rc = 0; - + dirvec[0][0] = 1; dirvec[0][1] = 0; dirvec[1][0] = 0; dirvec[1][1] = -size; dirvec[2][0] = -1; dirvec[2][1] = 0; dirvec[3][0] = 0; dirvec[3][1] = size; - + bufmin = buf->rect; tbuf = buf->rect; bufmax = buf->rect + size * size; tbuf += amount * size + amount; - + for (nr = 1; nr <= size; nr++) { - + for (a = 0; a < 2; a++) { for (b = 0; b < nr; b++) { if (*tbuf && *tbuf >= min && *tbuf < max) { @@ -1605,9 +1605,9 @@ uint ED_view3d_backbuf_sample_rect( index = (*tbuf - min) + 1; goto exit; } - + tbuf += (dirvec[rc][0] + dirvec[rc][1]); - + if (tbuf < bufmin || tbuf >= bufmax) { goto exit; } @@ -1971,18 +1971,18 @@ void ED_view3d_after_add(ListBase *lb, Base *base, const short dflag) static void view3d_draw_transp(Scene *scene, ARegion *ar, View3D *v3d) { View3DAfter *v3da; - + glDepthMask(GL_FALSE); v3d->transp = true; - + while ((v3da = BLI_pophead(&v3d->afterdraw_transp))) { draw_object(scene, ar, v3d, v3da->base, v3da->dflag); MEM_freeN(v3da); } v3d->transp = false; - + glDepthMask(GL_TRUE); - + } /* clears zbuffer and draws it over */ @@ -2014,7 +2014,7 @@ static void view3d_draw_xraytransp(Scene *scene, ARegion *ar, View3D *v3d, const v3d->xray = true; v3d->transp = true; - + glDepthMask(GL_FALSE); while ((v3da = BLI_pophead(&v3d->afterdraw_xraytransp))) { @@ -2156,20 +2156,20 @@ static void draw_dupli_objects_color( tbase.object->transflag |= OB_NEG_SCALE; else tbase.object->transflag &= ~OB_NEG_SCALE; - + /* should move outside the loop but possible color is set in draw_object still */ if ((dflag & DRAW_CONSTCOLOR) == 0) { glColor3ubv(color_rgb); } - + /* generate displist, test for new object */ if (dob_prev && dob_prev->ob != dob->ob) { if (use_displist == true) glDeleteLists(displist, 1); - + use_displist = false; } - + if ((bb_tmp = BKE_object_boundbox_get(dob->ob))) { bb = *bb_tmp; /* must make a copy */ testbb = true; @@ -2178,12 +2178,12 @@ static void draw_dupli_objects_color( if (!testbb || ED_view3d_boundbox_clip_ex(rv3d, &bb, dob->mat)) { /* generate displist */ if (use_displist == false) { - + /* note, since this was added, its checked (dob->type == OB_DUPLIGROUP) * however this is very slow, it was probably needed for the NLA * offset feature (used in group-duplicate.blend but no longer works in 2.5) * so for now it should be ok to - campbell */ - + if ( /* if this is the last no need to make a displist */ (dob_next == NULL || dob_next->ob != dob->ob) || /* lamp drawing messes with matrices, could be handled smarter... but this works */ @@ -2199,28 +2199,28 @@ static void draw_dupli_objects_color( } else { // printf("draw_dupli_objects_color: using displist for %s\n", dob->ob->id.name + 2); - + /* disable boundbox check for list creation */ BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 1); /* need this for next part of code */ unit_m4(dob->ob->obmat); /* obmat gets restored */ - + displist = glGenLists(1); glNewList(displist, GL_COMPILE); draw_object(scene, ar, v3d, &tbase, dflag_dupli); glEndList(); - + use_displist = true; BKE_object_boundbox_flag(dob->ob, BOUNDBOX_DISABLED, 0); - } + } } - + if (use_displist) { glPushMatrix(); glMultMatrixf(dob->mat); glCallList(displist); glPopMatrix(); - } + } else { copy_m4_m4(dob->ob->obmat, dob->mat); GPU_begin_dupli_object(dob); @@ -2228,7 +2228,7 @@ static void draw_dupli_objects_color( GPU_end_dupli_object(); } } - + tbase.object->dt = dt; tbase.object->dtx = dtx; tbase.object->transflag = transflag; @@ -2241,7 +2241,7 @@ static void draw_dupli_objects_color( } free_object_duplilist(lb); - + if (use_displist) glDeleteLists(displist, 1); } @@ -2250,12 +2250,12 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas { /* define the color here so draw_dupli_objects_color can be called * from the set loop */ - + int color = (base->flag & SELECT) ? TH_SELECT : TH_WIRE; /* debug */ if (base->object->dup_group && base->object->dup_group->id.us < 1) color = TH_REDALERT; - + draw_dupli_objects_color(scene, ar, v3d, base, 0, color); } @@ -2304,7 +2304,7 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) MEM_freeN(d->depths); d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths Subset"); - + d->damaged = true; } @@ -2320,7 +2320,7 @@ void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) void ED_view3d_depth_update(ARegion *ar) { RegionView3D *rv3d = ar->regiondata; - + /* Create storage for, and, if necessary, copy depth buffer */ if (!rv3d->depths) rv3d->depths = MEM_callocN(sizeof(ViewDepths), "ViewDepths"); if (rv3d->depths) { @@ -2336,11 +2336,11 @@ void ED_view3d_depth_update(ARegion *ar) d->depths = MEM_mallocN(sizeof(float) * d->w * d->h, "View depths"); d->damaged = true; } - + if (d->damaged) { view3d_opengl_read_pixels(ar, 0, 0, d->w, d->h, GL_DEPTH_COMPONENT, GL_FLOAT, d->depths); glGetDoublev(GL_DEPTH_RANGE, d->depth_range); - + d->damaged = false; } } @@ -2386,7 +2386,7 @@ void ED_view3d_draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) if (v3d->flag2 & V3D_SHOW_GPENCIL) { ED_gpencil_draw_view3d(NULL, scene, v3d, ar, true); } - + v3d->zbuf = zbuf; } @@ -2409,7 +2409,7 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d) } } } - + for (base = scene->base.first; base; base = base->next) { if (v3d->lay & base->lay) { /* dupli drawing */ @@ -2419,7 +2419,7 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d) draw_object(scene, ar, v3d, base, dflag_depth); } } - + /* this isn't that nice, draw xray objects as if they are normal */ if (v3d->afterdraw_transp.first || v3d->afterdraw_xray.first || @@ -2429,7 +2429,7 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d) int mask_orig; v3d->xray = true; - + /* transp materials can change the depth mask, see #21388 */ glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); @@ -2464,7 +2464,7 @@ static void view3d_draw_depth_loop(Scene *scene, ARegion *ar, View3D *v3d) MEM_freeN(v3da); } - + v3d->xray = false; v3d->transp = false; @@ -2481,21 +2481,21 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover float glalphaclip = U.glalphaclip; int obcenter_dia = U.obcenter_dia; /* temp set drawtype to solid */ - + /* Setting these temporarily is not nice */ v3d->flag &= ~V3D_SELECT_OUTLINE; U.glalphaclip = alphaoverride ? 0.5f : glalphaclip; /* not that nice but means we wont zoom into billboards */ U.obcenter_dia = 0; - + /* Tools may request depth outside of regular drawing code. */ UI_Theme_Store(&theme_state); UI_SetTheme(SPACE_VIEW3D, RGN_TYPE_WINDOW); /* Setup view matrix. */ ED_view3d_draw_setup_view(NULL, scene, ar, v3d, rv3d->viewmat, rv3d->winmat, NULL); - + glClear(GL_DEPTH_BUFFER_BIT); - + if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(rv3d); } @@ -2511,7 +2511,7 @@ void ED_view3d_draw_depth(Scene *scene, ARegion *ar, View3D *v3d, bool alphaover ED_view3d_clipping_disable(); } rv3d->rflag &= ~RV3D_ZOFFSET_DISABLED; - + v3d->zbuf = zbuf; if (!v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -2588,13 +2588,13 @@ static void gpu_render_lamp_update(Scene *scene, View3D *v3d, Lamp *la = (Lamp *)ob->data; View3DShadow *shadow; unsigned int layers; - + lamp = GPU_lamp_from_blender(scene, ob, par); - + if (lamp) { GPU_lamp_update(lamp, lay, (ob->restrictflag & OB_RESTRICT_RENDER), obmat); GPU_lamp_update_colors(lamp, la->r, la->g, la->b, la->energy); - + layers = lay & v3d->lay; if (srl) layers &= srl->lay; @@ -2620,28 +2620,28 @@ static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d) Object *ob; World *world = scene->world; SceneRenderLayer *srl = v3d->scenelock ? BLI_findlink(&scene->r.layers, scene->r.actlay) : NULL; - + BLI_listbase_clear(&shadows); - + /* update lamp transform and gather shadow lamps */ for (SETLOOPER(scene, sce_iter, base)) { ob = base->object; - + if (ob->type == OB_LAMP) gpu_render_lamp_update(scene, v3d, ob, NULL, ob->obmat, ob->lay, &shadows, srl); - + if (ob->transflag & OB_DUPLI) { DupliObject *dob; ListBase *lb = object_duplilist(G.main->eval_ctx, scene, ob); - + for (dob = lb->first; dob; dob = dob->next) if (dob->ob->type == OB_LAMP) gpu_render_lamp_update(scene, v3d, dob->ob, ob, dob->mat, ob->lay, &shadows, srl); - + free_object_duplilist(lb); } } - + /* render shadows after updating all lamps, nested object_duplilist * don't work correct since it's replacing object matrices */ for (shadow = shadows.first; shadow; shadow = shadow->next) { @@ -2650,15 +2650,15 @@ static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d) int drawtype, lay, winsize, flag2 = v3d->flag2; ARegion ar = {NULL}; RegionView3D rv3d = {{{0}}}; - + drawtype = v3d->drawtype; lay = v3d->lay; - + v3d->drawtype = OB_SOLID; v3d->lay &= GPU_lamp_shadow_layer(shadow->lamp); v3d->flag2 &= ~(V3D_SOLID_TEX | V3D_SHOW_SOLID_MATCAP); v3d->flag2 |= V3D_RENDER_OVERRIDE | V3D_RENDER_SHADOW; - + GPU_lamp_shadow_buffer_bind(shadow->lamp, viewmat, &winsize, winmat); ar.regiondata = &rv3d; @@ -2676,12 +2676,12 @@ static void gpu_update_lamps_shadows_world(Scene *scene, View3D *v3d) false, false, true, NULL, NULL, NULL, NULL); GPU_lamp_shadow_buffer_unbind(shadow->lamp); - + v3d->drawtype = drawtype; v3d->lay = lay; v3d->flag2 = flag2; } - + BLI_freelistN(&shadows); /* update world values */ @@ -2711,7 +2711,7 @@ CustomDataMask ED_view3d_datamask(const Scene *scene, const View3D *v3d) mask |= CD_MASK_ORCO; } else { - if ((scene->gm.matmode == GAME_MAT_GLSL && drawtype == OB_TEXTURE) || + if ((scene->gm.matmode == GAME_MAT_GLSL && drawtype == OB_TEXTURE) || (drawtype == OB_MATERIAL)) { mask |= CD_MASK_ORCO; @@ -2728,7 +2728,7 @@ CustomDataMask ED_view3d_screen_datamask(const bScreen *screen) const Scene *scene = screen->scene; CustomDataMask mask = CD_MASK_BAREMESH; const ScrArea *sa; - + /* check if we need tfaces & mcols due to view mode */ for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->spacetype == SPACE_VIEW3D) { @@ -2770,7 +2770,7 @@ void ED_view3d_update_viewmat( mul_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); invert_m4_m4(rv3d->viewinv, rv3d->viewmat); - + /* calculate GLSL view dependent values */ /* store window coordinates scaling/offset */ @@ -2779,7 +2779,7 @@ void ED_view3d_update_viewmat( ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, &cameraborder, false); rv3d->viewcamtexcofac[0] = (float)ar->winx / BLI_rctf_size_x(&cameraborder); rv3d->viewcamtexcofac[1] = (float)ar->winy / BLI_rctf_size_y(&cameraborder); - + rv3d->viewcamtexcofac[2] = -rv3d->viewcamtexcofac[0] * cameraborder.xmin / (float)ar->winx; rv3d->viewcamtexcofac[3] = -rv3d->viewcamtexcofac[1] * cameraborder.ymin / (float)ar->winy; } @@ -2971,7 +2971,7 @@ static void view3d_draw_objects( /* must be before xray draw which clears the depth buffer */ if (v3d->flag2 & V3D_SHOW_GPENCIL) { wmWindowManager *wm = (C != NULL) ? CTX_wm_manager(C) : NULL; - + /* must be before xray draw which clears the depth buffer */ if (v3d->zbuf) glDisable(GL_DEPTH_TEST); ED_gpencil_draw_view3d(wm, scene, v3d, ar, true); @@ -3093,7 +3093,7 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar) /* calculate full shader for background */ GPU_material_bind(gpumat, 1, 1, 1.0, false, rv3d->viewmat, rv3d->viewinv, rv3d->viewcamtexcofac, (v3d->scenelock != 0)); - + bool material_not_bound = !GPU_material_bound(gpumat); if (material_not_bound) { @@ -3124,7 +3124,7 @@ static void view3d_main_region_clear(Scene *scene, View3D *v3d, ARegion *ar) } GPU_material_unbind(gpumat); - + glDepthFunc(GL_LEQUAL); glDisable(GL_DEPTH_TEST); } @@ -3541,18 +3541,18 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect) float fps; char printable[16]; int i, tot; - + if (!fpsi || !fpsi->lredrawtime || !fpsi->redrawtime) return; - + printable[0] = '\0'; - + #if 0 /* this is too simple, better do an average */ fps = (float)(1.0 / (fpsi->lredrawtime - fpsi->redrawtime)) #else fpsi->redrawtimes_fps[fpsi->redrawtime_index] = (float)(1.0 / (fpsi->lredrawtime - fpsi->redrawtime)); - + for (i = 0, tot = 0, fps = 0.0f; i < REDRAW_FRAME_AVERAGE; i++) { if (fpsi->redrawtimes_fps[i]) { fps += fpsi->redrawtimes_fps[i]; @@ -3561,11 +3561,11 @@ void ED_scene_draw_fps(Scene *scene, const rcti *rect) } if (tot) { fpsi->redrawtime_index = (fpsi->redrawtime_index + 1) % REDRAW_FRAME_AVERAGE; - + //fpsi->redrawtime_index++; //if (fpsi->redrawtime >= REDRAW_FRAME_AVERAGE) // fpsi->redrawtime = 0; - + fps = fps / tot; } #endif @@ -3611,7 +3611,7 @@ bool ED_view3d_calc_render_border( use_border = (scene->r.mode & R_BORDER) != 0; else use_border = (v3d->flag2 & V3D_RENDER_BORDER) != 0; - + if (!use_border) return false; @@ -3711,7 +3711,7 @@ static void view3d_main_region_draw_engine_info(View3D *v3d, RegionView3D *rv3d, if (!rv3d->render_engine || !rv3d->render_engine->text[0]) return; - + if (render_border) { /* draw darkened background color. no alpha because border render does * partial redraw and will not redraw the region behind this info bar */ @@ -3861,10 +3861,10 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie wmWindow *win = CTX_wm_window(C); RegionView3D *rv3d = ar->regiondata; unsigned int lay_used = v3d->lay_used; - + /* post processing */ bool do_compositing = false; - + /* shadow buffers, before we setup matrices */ if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) gpu_update_lamps_shadows_world(scene, v3d); @@ -3895,7 +3895,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie fx_settings = v3d->fx_settings; if (!rv3d->compositor) rv3d->compositor = GPU_fx_compositor_create(); - + if (rv3d->persp == RV3D_CAMOB && v3d->camera) BKE_camera_to_gpu_dof(v3d->camera, &fx_settings); else { @@ -3904,7 +3904,7 @@ static void view3d_main_region_draw_objects(const bContext *C, Scene *scene, Vie do_compositing = GPU_fx_compositor_initialize_passes(rv3d->compositor, &ar->winrct, &ar->drawrct, &fx_settings); } - + /* clear the background */ view3d_main_region_clear(scene, v3d, ar); @@ -3985,7 +3985,7 @@ static void view3d_main_region_draw_info(const bContext *C, Scene *scene, wmWindowManager *wm = CTX_wm_manager(C); RegionView3D *rv3d = ar->regiondata; rcti rect; - + /* local coordinate visible rect inside region, to accomodate overlapping ui */ ED_region_visible_rect(ar, &rect); @@ -4070,20 +4070,20 @@ void view3d_main_region_draw(const bContext *C, ARegion *ar) /* draw viewport using opengl */ if (v3d->drawtype != OB_RENDER || !view3d_main_region_do_render_draw(scene) || clip_border) { view3d_main_region_draw_objects(C, scene, v3d, ar, &grid_unit); - + #ifdef DEBUG_DRAW bl_debug_draw(); #endif if (G.debug & G_DEBUG_SIMDATA) draw_sim_debug_data(scene, v3d, ar); - + ED_region_pixelspace(ar); } /* draw viewport using external renderer */ if (v3d->drawtype == OB_RENDER) view3d_main_region_draw_engine(C, scene, ar, v3d, clip_border, &border_rect); - + view3d_main_region_draw_info(C, scene, ar, v3d, grid_unit, render_border); v3d->flag |= V3D_INVALID_BACKBUF; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index aea6aa093af..65d66df4824 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -147,7 +147,7 @@ void fly_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_add_item(keymap, WHEELDOWNMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_DECELERATE); WM_modalkeymap_add_item(keymap, MOUSEPAN, 0, 0, 0, FLY_MODAL_SPEED); - + WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, KM_ANY, 0, FLY_MODAL_PAN_ENABLE); /* XXX - Bug in the event system, middle mouse release doesnt work */ WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_RELEASE, KM_ANY, 0, FLY_MODAL_PAN_DISABLE); @@ -534,12 +534,12 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e case FLY_MODAL_CONFIRM: fly->state = FLY_CONFIRM; break; - + /* speed adjusting with mousepan (trackpad) */ case FLY_MODAL_SPEED: { float fac = 0.02f * (event->prevy - event->y); - + /* allowing to brake immediate */ if (fac > 0.0f && fly->speed < 0.0f) fly->speed = 0.0f; @@ -547,7 +547,7 @@ static void flyEvent(bContext *C, wmOperator *op, FlyInfo *fly, const wmEvent *e fly->speed = 0.0f; else fly->speed += fly->grid * fac; - + break; } case FLY_MODAL_ACCELERATE: diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index de7ffd223f5..124bd33f227 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -75,7 +75,7 @@ static void handle_view3d_lock(bContext *C) Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); View3D *v3d = CTX_wm_view3d(C); - + if (v3d != NULL && sa != NULL) { if (v3d->localvd == NULL && v3d->scenelock && sa->spacetype == SPACE_VIEW3D) { /* copy to scene */ @@ -86,7 +86,7 @@ static void handle_view3d_lock(bContext *C) /* not through notifier, listener don't have context * and non-open screens or spaces need to be updated too */ BKE_screen_view3d_main_sync(&bmain->screen, scene); - + /* notifiers for scene update */ WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); } @@ -121,7 +121,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) View3D *v3d = sa->spacedata.first; int nr = RNA_int_get(op->ptr, "nr"); const bool toggle = RNA_boolean_get(op->ptr, "toggle"); - + if (nr < 0) return OPERATOR_CANCELLED; @@ -169,13 +169,13 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) } } } - + if (v3d->scenelock) handle_view3d_lock(C); - + DAG_on_visible_update(CTX_data_main(C), false); ED_area_tag_redraw(sa); - + return OPERATOR_FINISHED; } @@ -185,18 +185,18 @@ static int view3d_layers_invoke(bContext *C, wmOperator *op, const wmEvent *even { if (event->ctrl || event->oskey) return OPERATOR_PASS_THROUGH; - + if (event->shift) RNA_boolean_set(op->ptr, "extend", true); else RNA_boolean_set(op->ptr, "extend", false); - + if (event->alt) { const int nr = RNA_int_get(op->ptr, "nr") + 10; RNA_int_set(op->ptr, "nr", nr); } view3d_layers_exec(C, op); - + return OPERATOR_FINISHED; } @@ -211,15 +211,15 @@ void VIEW3D_OT_layers(wmOperatorType *ot) ot->name = "Layers"; ot->description = "Toggle layer(s) visibility"; ot->idname = "VIEW3D_OT_layers"; - + /* api callbacks */ ot->invoke = view3d_layers_invoke; ot->exec = view3d_layers_exec; ot->poll = view3d_layers_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + RNA_def_int(ot->srna, "nr", 1, 0, 20, "Number", "The layer number to set, zero for all layers", 0, 20); RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Add this layer to the current view layers"); RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer"); @@ -293,7 +293,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiLayout *row; bool is_paint = false; int modeselect; - + RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr); RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr); RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr); @@ -303,7 +303,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* other buttons: */ UI_block_emboss_set(block, UI_EMBOSS); - + /* mode */ if ((gpd) && (gpd->flag & GP_DATA_STROKE_EDITMODE)) { modeselect = OB_MODE_GPENCIL; @@ -379,6 +379,6 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* Scene lock */ uiItemR(layout, &v3dptr, "lock_camera_and_layers", UI_ITEM_R_ICON_ONLY, "", ICON_NONE); } - + uiTemplateEditModeSelection(layout, C); } diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 7240b15e51d..5734fba84b5 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -70,9 +70,9 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); char str[FILE_MAX]; - + BKE_copybuffer_begin(bmain); - + /* context, selection, could be generalized */ CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { @@ -90,10 +90,10 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op) } } } - + BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend"); BKE_copybuffer_save(bmain, str, op->reports); - + BKE_report(op->reports, RPT_INFO, "Copied selected objects to buffer"); return OPERATOR_FINISHED; @@ -101,12 +101,12 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op) static void VIEW3D_OT_copybuffer(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Copy Selection to Buffer"; ot->idname = "VIEW3D_OT_copybuffer"; ot->description = "Selected objects are saved in a temp file"; - + /* api callbacks */ ot->exec = view3d_copybuffer_exec; ot->poll = ED_operator_scene; @@ -138,16 +138,16 @@ static int view3d_pastebuffer_exec(bContext *C, wmOperator *op) static void VIEW3D_OT_pastebuffer(wmOperatorType *ot) { - + /* identifiers */ ot->name = "Paste Selection from Buffer"; ot->idname = "VIEW3D_OT_pastebuffer"; ot->description = "Contents of copy buffer gets pasted"; - + /* api callbacks */ ot->exec = view3d_pastebuffer_exec; ot->poll = ED_operator_scene_editable; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -210,10 +210,10 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_layers); WM_operatortype_append(VIEW3D_OT_copybuffer); WM_operatortype_append(VIEW3D_OT_pastebuffer); - + WM_operatortype_append(VIEW3D_OT_properties); WM_operatortype_append(VIEW3D_OT_toolshelf); - + WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid); WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor); WM_operatortype_append(VIEW3D_OT_snap_selected_to_active); @@ -231,12 +231,12 @@ void view3d_keymap(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + keymap = WM_keymap_find(keyconf, "3D View Generic", SPACE_VIEW3D, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_toolshelf", TKEY, KM_PRESS, 0, 0); - + /* only for region 3D window */ keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0); @@ -258,7 +258,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "use_accurate", false); WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0); - + WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); @@ -274,20 +274,20 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_navigate", FKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); - + WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEPAN, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_rotate", MOUSEROTATE, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_move", MOUSEPAN, 0, KM_SHIFT, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEZOOM, 0, 0, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MOUSEPAN, 0, KM_CTRL, 0); - + /*numpad +/-*/ RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADPLUSKEY, KM_PRESS, 0, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", PADMINUS, KM_PRESS, 0, 0)->ptr, "delta", -1); /*ctrl +/-*/ RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", EQUALKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", MINUSKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1); - + /*wheel mouse forward/back*/ RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELINMOUSE, KM_PRESS, 0, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_zoom", WHEELOUTMOUSE, KM_PRESS, 0, 0)->ptr, "delta", -1); @@ -323,7 +323,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD3, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD4, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPLEFT); WM_keymap_add_item(keymap, "VIEW3D_OT_view_persportho", PAD5, KM_PRESS, 0, 0); - + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD6, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", PAD7, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", PAD8, KM_PRESS, 0, 0)->ptr, "type", V3D_VIEW_STEPUP); @@ -349,7 +349,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELUPMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPUP); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_orbit", WHEELDOWNMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0)->ptr, "type", V3D_VIEW_STEPDOWN); - + RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELUPMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPLEFT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_view_roll", WHEELDOWNMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "type", V3D_VIEW_STEPRIGHT); @@ -374,7 +374,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "align_active", true); WM_keymap_add_item(keymap, "VIEW3D_OT_localview", PADSLASHKEY, KM_PRESS, 0, 0); - + #ifdef WITH_INPUT_NDOF /* note: positioned here so keymaps show keyboard keys if assigned */ /* 3D mouse */ @@ -393,7 +393,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_RIGHT, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_RIGHT); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_TOP, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_TOP); RNA_enum_set(WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_BOTTOM, KM_PRESS, 0, 0)->ptr, "type", RV3D_VIEW_BOTTOM); - + /* 3D mouse align */ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_viewnumpad", NDOF_BUTTON_FRONT, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "type", RV3D_VIEW_FRONT); @@ -418,7 +418,7 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", EIGHTKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 8); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", NINEKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 9); RNA_int_set(WM_keymap_add_item(keymap, "VIEW3D_OT_layers", ZEROKEY, KM_PRESS, KM_ANY, 0)->ptr, "nr", 10); - + /* drawtype */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle_enum", ZKEY, KM_PRESS, 0, 0); @@ -499,7 +499,7 @@ void view3d_keymap(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_select_lasso", EVT_TWEAK_A, KM_ANY, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "deselect", true); WM_keymap_add_item(keymap, "VIEW3D_OT_select_circle", CKEY, KM_PRESS, 0, 0); - + WM_keymap_add_item(keymap, "VIEW3D_OT_clip_border", BKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_zoom_border", BKEY, KM_PRESS, KM_SHIFT, 0); @@ -509,19 +509,19 @@ void view3d_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "camera_only", false); WM_keymap_add_item(keymap, "VIEW3D_OT_clear_render_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - + WM_keymap_add_item(keymap, "VIEW3D_OT_camera_to_view", PAD0, KM_PRESS, KM_ALT | KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_object_as_camera", PAD0, KM_PRESS, KM_CTRL, 0); - + WM_keymap_add_menu(keymap, "VIEW3D_MT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - + #ifdef __APPLE__ WM_keymap_add_item(keymap, "VIEW3D_OT_copybuffer", CKEY, KM_PRESS, KM_OSKEY, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_pastebuffer", VKEY, KM_PRESS, KM_OSKEY, 0); #endif WM_keymap_add_item(keymap, "VIEW3D_OT_copybuffer", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_pastebuffer", VKEY, KM_PRESS, KM_CTRL, 0); - + /* context ops */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_enum", COMMAKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.pivot_point"); diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index e6688b56b2c..767df04c0b0 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -58,13 +58,13 @@ void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r_co[2], float mat[4][4]) { float vec4[4]; - + copy_v3_v3(vec4, co); vec4[3] = 1.0; /* r_co[0] = IS_CLIPPED; */ /* always overwritten */ - + mul_m4_v4(mat, vec4); - + if (vec4[3] > FLT_EPSILON) { r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; @@ -80,13 +80,13 @@ void ED_view3d_project_float_v2_m4(const ARegion *ar, const float co[3], float r void ED_view3d_project_float_v3_m4(const ARegion *ar, const float vec[3], float r_co[3], float mat[4][4]) { float vec4[4]; - + copy_v3_v3(vec4, vec); vec4[3] = 1.0; /* r_co[0] = IS_CLIPPED; */ /* always overwritten */ - + mul_m4_v4(mat, vec4); - + if (vec4[3] > FLT_EPSILON) { r_co[0] = (float)(ar->winx / 2.0f) + (ar->winx / 2.0f) * vec4[0] / vec4[3]; r_co[1] = (float)(ar->winy / 2.0f) + (ar->winy / 2.0f) * vec4[1] / vec4[3]; @@ -549,10 +549,10 @@ void ED_view3d_win_to_delta(const ARegion *ar, const float mval[2], float out[3] { RegionView3D *rv3d = ar->regiondata; float dx, dy; - + dx = 2.0f * mval[0] * zfac / ar->winx; dy = 2.0f * mval[1] * zfac / ar->winy; - + out[0] = (rv3d->persinv[0][0] * dx + rv3d->persinv[1][0] * dy); out[1] = (rv3d->persinv[0][1] * dx + rv3d->persinv[1][1] * dy); out[2] = (rv3d->persinv[0][2] * dx + rv3d->persinv[1][2] * dy); diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c index f2c87953302..bcd4da94257 100644 --- a/source/blender/editors/space_view3d/view3d_ruler.c +++ b/source/blender/editors/space_view3d/view3d_ruler.c @@ -323,7 +323,7 @@ static bool view3d_ruler_to_gpencil(bContext *C, RulerInfo *ruler_info) if (palcolor == NULL) { palcolor = BKE_gpencil_palettecolor_addnew(palette, (char *)ruler_name, true); } - + gpf = BKE_gpencil_layer_getframe(gpl, CFRA, true); BKE_gpencil_free_strokes(gpf); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 02a26dca6d2..06481231259 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -303,25 +303,25 @@ static bool edge_fully_inside_rect(const rctf *rect, const float v1[2], const fl static bool edge_inside_rect(const rctf *rect, const float v1[2], const float v2[2]) { int d1, d2, d3, d4; - + /* check points in rect */ if (edge_fully_inside_rect(rect, v1, v2)) return 1; - + /* check points completely out rect */ if (v1[0] < rect->xmin && v2[0] < rect->xmin) return 0; if (v1[0] > rect->xmax && v2[0] > rect->xmax) return 0; if (v1[1] < rect->ymin && v2[1] < rect->ymin) return 0; if (v1[1] > rect->ymax && v2[1] > rect->ymax) return 0; - + /* simple check lines intersecting. */ d1 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymin); d2 = (v1[1] - v2[1]) * (v1[0] - rect->xmin) + (v2[0] - v1[0]) * (v1[1] - rect->ymax); d3 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymax); d4 = (v1[1] - v2[1]) * (v1[0] - rect->xmax) + (v2[0] - v1[0]) * (v1[1] - rect->ymin); - + if (d1 < 0 && d2 < 0 && d3 < 0 && d4 < 0) return 0; if (d1 > 0 && d2 > 0 && d3 > 0 && d4 > 0) return 0; - + return 1; } @@ -377,7 +377,7 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, const int mcords[] ViewContext vc_tmp; LassoSelectUserData data; rcti rect; - + if ((ob->type != OB_ARMATURE) || (ob->pose == NULL)) { return; } @@ -418,7 +418,7 @@ static void do_lasso_select_objects( const bool extend, const bool select) { Base *base; - + if (extend == false && select) object_deselect_all_visible(vc->scene, vc->v3d); @@ -492,7 +492,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m ToolSettings *ts = vc->scene->toolsettings; rcti rect; int bbsel; - + /* set editmesh */ vc->em = BKE_editmesh_from_object(vc->obedit); @@ -508,7 +508,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m glLoadMatrixf(vc->rv3d->viewmat); bbsel = EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - + if (ts->selectmode & SCE_SELECT_VERTEX) { if (bbsel) { edbm_backbuf_check_and_select_verts(vc->em, select); @@ -527,7 +527,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m mesh_foreachScreenEdge(vc, do_lasso_select_mesh__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } - + if (ts->selectmode & SCE_SELECT_FACE) { if (bbsel) { edbm_backbuf_check_and_select_faces(vc->em, select); @@ -536,7 +536,7 @@ static void do_lasso_select_mesh(ViewContext *vc, const int mcords[][2], short m mesh_foreachScreenFace(vc, do_lasso_select_mesh__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT); } } - + EDBM_backbuf_free(); EDBM_selectmode_flush(vc->em); } @@ -791,7 +791,7 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh BLI_lasso_boundbox(&rect, mcords, moves); EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); - + edbm_backbuf_check_and_select_tfaces(me, select); EDBM_backbuf_free(); @@ -803,19 +803,19 @@ static void do_lasso_select_paintface(ViewContext *vc, const int mcords[][2], sh static void do_lasso_select_node(int mcords[][2], short moves, const bool select) { SpaceNode *snode = sa->spacedata.first; - + bNode *node; rcti rect; int node_cent[2]; float node_centf[2]; - + BLI_lasso_boundbox(&rect, mcords, moves); - + /* store selection in temp test flag */ for (node = snode->edittree->nodes.first; node; node = node->next) { node_centf[0] = BLI_RCT_CENTER_X(&node->totr); node_centf[1] = BLI_RCT_CENTER_Y(&node->totr); - + ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); if (BLI_rcti_isect_pt_v(&rect, node_cent) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { @@ -887,18 +887,18 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op) ViewContext vc; int mcords_tot; const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); - + if (mcords) { bool extend, select; view3d_operator_needs_opengl(C); - + /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc); - + extend = RNA_boolean_get(op->ptr, "extend"); select = !RNA_boolean_get(op->ptr, "deselect"); view3d_lasso_select(C, &vc, mcords, mcords_tot, extend, select); - + MEM_freeN((void *)mcords); return OPERATOR_FINISHED; @@ -911,16 +911,16 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot) ot->name = "Lasso Select"; ot->description = "Select items using lasso selection"; ot->idname = "VIEW3D_OT_select_lasso"; - + ot->invoke = WM_gesture_lasso_invoke; ot->modal = WM_gesture_lasso_modal; ot->exec = view3d_lasso_select_exec; ot->poll = view3d_selectable_data; ot->cancel = WM_gesture_lasso_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_gesture_lasso_select(ot); } @@ -1033,7 +1033,7 @@ void VIEW3D_OT_select_menu(wmOperatorType *ot) static void deselectall_except(Scene *scene, Base *b) /* deselect all except b */ { Base *base; - + for (base = FIRSTBASE; base; base = base->next) { if (base->flag & SELECT) { if (b != base) { @@ -1050,7 +1050,7 @@ static Base *object_mouse_select_menu( short baseCount = 0; bool ok; LinkNode *linklist = NULL; - + CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { ok = false; @@ -1253,12 +1253,12 @@ static Base *mouse_select_eval_buffer( View3D *v3d = vc->v3d; Base *base, *basact = NULL; int a; - + if (do_nearest) { unsigned int min = 0xFFFFFFFF; int selcol = 0, notcol = 0; - - + + if (has_bones) { /* we skip non-bone hits */ for (a = 0; a < hits; a++) { @@ -1271,7 +1271,7 @@ static Base *mouse_select_eval_buffer( else { /* only exclude active object when it is selected... */ if (BASACT && (BASACT->flag & SELECT) && hits > 1) notcol = BASACT->selcol; - + for (a = 0; a < hits; a++) { if (min > buffer[4 * a + 1] && notcol != (buffer[4 * a + 3] & 0xFFFF)) { min = buffer[4 * a + 1]; @@ -1279,7 +1279,7 @@ static Base *mouse_select_eval_buffer( } } } - + base = FIRSTBASE; while (base) { if (BASE_SELECTABLE(v3d, base)) { @@ -1290,7 +1290,7 @@ static Base *mouse_select_eval_buffer( if (base) basact = base; } else { - + base = startbase; while (base) { /* skip objects with select restriction, to prevent prematurely ending this loop @@ -1300,7 +1300,7 @@ static Base *mouse_select_eval_buffer( if (base == NULL) base = FIRSTBASE; if (base == startbase) break; } - + if (BASE_SELECTABLE(v3d, base)) { for (a = 0; a < hits; a++) { if (has_bones) { @@ -1316,15 +1316,15 @@ static Base *mouse_select_eval_buffer( } } } - + if (basact) break; - + base = base->next; if (base == NULL) base = FIRSTBASE; if (base == startbase) break; } } - + return basact; } @@ -1336,18 +1336,18 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, const int mval[2]) unsigned int buffer[MAXPICKBUF]; int hits; bool do_nearest; - + /* setup view context for argument to callbacks */ view3d_operator_needs_opengl(C); ED_view3d_viewcontext_init(C, &vc); - + hits = mixed_bones_object_selectbuffer(&vc, buffer, mval, false, false, &do_nearest); - + if (hits > 0) { const bool has_bones = selectbuffer_has_bones(buffer, hits); basact = mouse_select_eval_buffer(&vc, buffer, hits, vc.scene->base.first, has_bones, do_nearest); } - + return basact; } @@ -1386,7 +1386,7 @@ static bool ed_object_select_pick( int hits; const float mval_fl[2] = {(float)mval[0], (float)mval[1]}; - + /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc); @@ -1395,15 +1395,15 @@ static bool ed_object_select_pick( /* signal for view3d_opengl_select to skip editmode objects */ vc.obedit = NULL; } - + /* always start list from basact in wire mode */ startbase = FIRSTBASE; if (BASACT && BASACT->next) startbase = BASACT->next; - + /* This block uses the control key to make the object selected by its center point rather than its contents */ /* in editmode do not activate */ if (obcenter) { - + /* note; shift+alt goes to group-flush-selecting */ if (enumerate) { basact = object_mouse_select_menu(C, &vc, NULL, 0, mval, toggle); @@ -1426,7 +1426,7 @@ static bool ed_object_select_pick( } } base = base->next; - + if (base == NULL) base = FIRSTBASE; if (base == startbase) break; } @@ -1454,7 +1454,7 @@ static bool ed_object_select_pick( else { basact = mouse_select_eval_buffer(&vc, buffer, hits, startbase, has_bones, do_nearest); } - + if (has_bones && basact) { if (basact->object->type == OB_CAMERA) { if (BASACT == basact) { @@ -1518,16 +1518,16 @@ static bool ed_object_select_pick( scene, basact, buffer, hits, extend, deselect, toggle, do_nearest)) { /* then bone is found */ - - /* we make the armature selected: + + /* we make the armature selected: * not-selected active object in posemode won't work well for tools */ basact->flag |= SELECT; basact->object->flag = basact->flag; - + retval = true; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object); WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object); - + /* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */ if (BASACT && (BASACT->object->mode & OB_MODE_WEIGHT_PAINT)) { /* prevent activating */ @@ -1541,11 +1541,11 @@ static bool ed_object_select_pick( } } } - + /* so, do we have something selected? */ if (basact) { retval = true; - + if (vc.obedit) { /* only do select */ deselectall_except(scene, basact); @@ -1555,7 +1555,7 @@ static bool ed_object_select_pick( else if (BASE_SELECTABLE(v3d, basact)) { oldbasact = BASACT; - + if (extend) { ED_base_object_select(basact, BA_SELECT); } @@ -1751,7 +1751,7 @@ static void do_nurbs_box_select__doSelect( static int do_nurbs_box_select(ViewContext *vc, rcti *rect, bool select, bool extend) { BoxSelectUserData data; - + view3d_userdata_boxselect_init(&data, vc, rect, select); if (extend == false && select) { @@ -1785,7 +1785,7 @@ static int do_lattice_box_select(ViewContext *vc, rcti *rect, bool select, bool ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ lattice_foreachScreenVert(vc, do_lattice_box_select__doSelect, &data, V3D_PROJ_TEST_CLIP_DEFAULT); - + return OPERATOR_FINISHED; } @@ -1829,7 +1829,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext BoxSelectUserData data; ToolSettings *ts = vc->scene->toolsettings; int bbsel; - + view3d_userdata_boxselect_init(&data, vc, rect, select); if (extend == false && select) @@ -1860,7 +1860,7 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext mesh_foreachScreenEdge(vc, do_mesh_box_select__doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } - + if (ts->selectmode & SCE_SELECT_FACE) { if (bbsel) { edbm_backbuf_check_and_select_faces(vc->em, select); @@ -1869,11 +1869,11 @@ static int do_mesh_box_select(ViewContext *vc, rcti *rect, bool select, bool ext mesh_foreachScreenFace(vc, do_mesh_box_select__doSelectFace, &data, V3D_PROJ_TEST_CLIP_DEFAULT); } } - + EDBM_backbuf_free(); - + EDBM_selectmode_flush(vc->em); - + return OPERATOR_FINISHED; } @@ -1890,7 +1890,7 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool ext if (extend == false && select) BKE_mball_deselect_all(mb); - + for (ml = mb->editelems->first; ml; ml = ml->next) { for (a = 0; a < hits; a++) { if (ml->selcol1 == buffer[(4 * a) + 3]) { @@ -1920,11 +1920,11 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool int hits; hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL); - + /* clear flag we use to detect point was affected */ for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) ebone->flag &= ~BONE_DONE; - + if (extend == false && select) ED_armature_edit_deselect_all_visible(vc->obedit); @@ -1980,9 +1980,9 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool } } } - + ED_armature_edit_sync_selection(arm->edbo); - + return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } @@ -1996,12 +1996,12 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b int bone_selected = 0; int totobj = MAXPICKBUF; /* XXX solve later */ int hits; - + if ((ob) && (ob->mode & OB_MODE_POSE)) bone_only = 1; else bone_only = 0; - + if (extend == false && select) { if (bone_only) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) @@ -2027,7 +2027,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b * is the same as the object, we have a hit and can move to the next color * and object pair, if not, just move to the next object, * keeping the same color until we have a hit. - * + * * The buffer order is defined by OGL standard, hopefully no stupid GFX card * does it incorrectly. */ @@ -2035,7 +2035,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b if (hits > 0) { /* no need to loop if there's no hit */ Base *base; col = vbuffer + 3; - + for (base = vc->scene->base.first; base && hits; base = base->next) { if (BASE_SELECTABLE(vc->v3d, base)) { while (base->selcol == (*col & 0xFFFF)) { /* we got an object */ @@ -2059,19 +2059,19 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b else if (!bone_only) { ED_base_object_select(base, select ? BA_SELECT : BA_DESELECT); } - + col += 4; /* next color */ hits--; if (hits == 0) break; } } - + if (bone_selected) { if (base->object && (base->object->type == OB_ARMATURE)) { bArmature *arm = base->object->data; - + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, base->object); - + if (arm && (arm->flag & ARM_HAS_VIZ_DEPS)) { /* mask modifier ('armature' mode), etc. */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -2079,7 +2079,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b } } } - + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, vc->scene); } MEM_freeN(vbuffer); @@ -2100,7 +2100,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) /* setup view context for argument to callbacks */ ED_view3d_viewcontext_init(C, &vc); - + select = !RNA_boolean_get(op->ptr, "deselect"); extend = RNA_boolean_get(op->ptr, "extend"); WM_operator_properties_border_to_rcti(op, &rect); @@ -2164,7 +2164,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op) } return ret; -} +} /* *****************Selection Operators******************* */ @@ -2176,17 +2176,17 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->description = "Select items using border selection"; ot->idname = "VIEW3D_OT_select_border"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = view3d_borderselect_exec; ot->modal = WM_gesture_border_modal; ot->poll = view3d_selectable_data; ot->cancel = WM_gesture_border_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* rna */ WM_operator_properties_gesture_border_select(ot); } @@ -2286,7 +2286,7 @@ static int view3d_select_exec(bContext *C, wmOperator *op) retval = ED_mball_select_pick(C, location, extend, deselect, toggle); else if (obedit->type == OB_FONT) retval = ED_curve_editfont_select_pick(C, location, extend, deselect, toggle); - + } else if (obact && obact->mode & OB_MODE_PARTICLE_EDIT) return PE_mouse_particles(C, location, extend, deselect, toggle); @@ -2321,15 +2321,15 @@ void VIEW3D_OT_select(wmOperatorType *ot) ot->name = "Activate/Select"; ot->description = "Activate/select item(s)"; ot->idname = "VIEW3D_OT_select"; - + /* api callbacks */ ot->invoke = view3d_select_invoke; ot->exec = view3d_select_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_UNDO; - + /* properties */ WM_operator_properties_mouse_select(ot); @@ -2404,7 +2404,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva ToolSettings *ts = vc->scene->toolsettings; int bbsel; CircleSelectUserData data; - + bbsel = EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ @@ -2429,7 +2429,7 @@ static void mesh_circle_select(ViewContext *vc, const bool select, const int mva mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, V3D_PROJ_TEST_CLIP_NEAR); } } - + if (ts->selectmode & SCE_SELECT_FACE) { if (bbsel) { edbm_backbuf_check_and_select_faces(vc->em, select); @@ -2623,11 +2623,11 @@ static void do_circle_select_pose__doSelectBone( static void pose_circle_select(ViewContext *vc, const bool select, const int mval[2], float rad) { CircleSelectUserData data; - + view3d_userdata_circleselect_init(&data, vc, select, mval, rad); ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */ - + pose_foreachScreenBone(vc, do_circle_select_pose__doSelectBone, &data, V3D_PROJ_TEST_CLIP_DEFAULT); if (data.is_changed) { @@ -2650,13 +2650,13 @@ static bool armature_circle_doSelectJoint(void *userData, EditBone *ebone, const if (head) { if (data->select) ebone->flag |= BONE_ROOTSEL; - else + else ebone->flag &= ~BONE_ROOTSEL; } else { if (data->select) ebone->flag |= BONE_TIPSEL; - else + else ebone->flag &= ~BONE_TIPSEL; } return 1; @@ -2853,13 +2853,13 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot) ot->name = "Circle Select"; ot->description = "Select items using circle selection"; ot->idname = "VIEW3D_OT_select_circle"; - + ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = view3d_circle_select_exec; ot->poll = view3d_selectable_data; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_UNDO; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 5dd69cc66eb..80586217691 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -86,7 +86,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - + tv = tvs.transverts; for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, tv->loc); @@ -96,11 +96,11 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) vec[1] = gridf * floorf(0.5f + vec[1] / gridf); vec[2] = gridf * floorf(0.5f + vec[2] / gridf); sub_v3_v3(vec, obedit->obmat[3]); - + mul_m3_v3(imat, vec); copy_v3_v3(tv->loc, vec); } - + ED_transverts_update_obedit(&tvs, obedit); ED_transverts_free(&tvs); } @@ -112,15 +112,15 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; bArmature *arm = ob->data; - + invert_m4_m4(ob->imat, ob->obmat); - + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->flag & BONE_SELECTED) { if (pchan->bone->layer & arm->layer) { if ((pchan->bone->flag & BONE_CONNECTED) == 0) { float nLoc[3]; - + /* get nearest grid point to snap to */ copy_v3_v3(nLoc, pchan->pose_mat[3]); /* We must operate in world space! */ @@ -130,10 +130,10 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) vec[2] = gridf * floorf(0.5f + nLoc[2] / gridf); /* Back in object space... */ mul_m4_v3(ob->imat, vec); - + /* Get location of grid point in pose space. */ BKE_armature_loc_pose_to_bone(pchan, vec, vec); - + /* adjust location */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) pchan->loc[0] = vec[0]; @@ -152,18 +152,18 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) } } ob->pose->flag |= (POSE_LOCKED | POSE_DO_UNLOCK); - + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { vec[0] = -ob->obmat[3][0] + gridf * floorf(0.5f + ob->obmat[3][0] / gridf); vec[1] = -ob->obmat[3][1] + gridf * floorf(0.5f + ob->obmat[3][1] / gridf); vec[2] = -ob->obmat[3][2] + gridf * floorf(0.5f + ob->obmat[3][2] / gridf); - + if (ob->parent) { float originmat[3][3]; BKE_object_where_is_calc_ex(scene, NULL, ob, originmat); - + invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); } @@ -173,7 +173,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) ob->loc[1] += vec[1]; if ((ob->protectflag & OB_LOCK_LOCZ) == 0) ob->loc[2] += vec[2]; - + /* auto-keyframing */ ED_autokeyframe_object(C, scene, ob, ks); @@ -184,7 +184,7 @@ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) } WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - + return OPERATOR_FINISHED; } @@ -194,11 +194,11 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) ot->name = "Snap Selection to Grid"; ot->description = "Snap selected item(s) to nearest grid division"; ot->idname = "VIEW3D_OT_snap_selected_to_grid"; - + /* api callbacks */ ot->exec = snap_sel_to_grid_exec; ot->poll = ED_operator_region_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -232,7 +232,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global if (obedit) { float snap_target_local[3]; - + if (ED_transverts_check_obedit(obedit)) ED_transverts_create_from_obedit(&tvs, obedit, 0); if (tvs.transverts_tot == 0) @@ -240,7 +240,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - + /* get the cursor in object space */ sub_v3_v3v3(snap_target_local, snap_target_global, obedit->obmat[3]); mul_m3_v3(imat, snap_target_local); @@ -261,7 +261,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global copy_v3_v3(tv->loc, snap_target_local); } } - + ED_transverts_update_obedit(&tvs, obedit); ED_transverts_free(&tvs); } @@ -393,7 +393,7 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global } WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); - + return OPERATOR_FINISHED; } @@ -415,11 +415,11 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot) ot->name = "Snap Selection to Cursor"; ot->description = "Snap selected item(s) to cursor"; ot->idname = "VIEW3D_OT_snap_selected_to_cursor"; - + /* api callbacks */ ot->exec = snap_selected_to_cursor_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -470,7 +470,7 @@ static int snap_curs_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) curs[0] = gridf * floorf(0.5f + curs[0] / gridf); curs[1] = gridf * floorf(0.5f + curs[1] / gridf); curs[2] = gridf * floorf(0.5f + curs[2] / gridf); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); /* hrm */ return OPERATOR_FINISHED; @@ -482,11 +482,11 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) ot->name = "Snap Cursor to Grid"; ot->description = "Snap cursor to nearest grid division"; ot->idname = "VIEW3D_OT_snap_cursor_to_grid"; - + /* api callbacks */ ot->exec = snap_curs_to_grid_exec; ot->poll = ED_operator_region_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -569,7 +569,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) } copy_m3_m4(bmat, obedit->obmat); - + tv = tvs.transverts; for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, tv->loc); @@ -578,7 +578,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) add_v3_v3(centroid, vec); minmax_v3v3_v3(min, max, vec); } - + if (v3d->around == V3D_AROUND_CENTER_MEAN) { mul_v3_fl(centroid, 1.0f / (float)tvs.transverts_tot); copy_v3_v3(cursor, centroid); @@ -591,7 +591,7 @@ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) } else { Object *obact = CTX_data_active_object(C); - + if (obact && (obact->mode & OB_MODE_POSE)) { bArmature *arm = obact->data; bPoseChannel *pchan; @@ -666,11 +666,11 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot) ot->name = "Snap Cursor to Selected"; ot->description = "Snap cursor to center of selected item(s)"; ot->idname = "VIEW3D_OT_snap_cursor_to_selected"; - + /* api callbacks */ ot->exec = snap_curs_to_sel_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -721,7 +721,7 @@ static int snap_curs_to_active_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); float *curs; - + curs = ED_view3d_cursor3d_get(scene, v3d); if (snap_calc_active_center(C, false, curs)) { @@ -739,11 +739,11 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot) ot->name = "Snap Cursor to Active"; ot->description = "Snap cursor to active item"; ot->idname = "VIEW3D_OT_snap_cursor_to_active"; - + /* api callbacks */ ot->exec = snap_curs_to_active_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -758,9 +758,9 @@ static int snap_curs_to_center_exec(bContext *C, wmOperator *UNUSED(op)) curs = ED_view3d_cursor3d_get(scene, v3d); zero_v3(curs); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); - + return OPERATOR_FINISHED; } @@ -770,11 +770,11 @@ void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot) ot->name = "Snap Cursor to Center"; ot->description = "Snap cursor to the Center"; ot->idname = "VIEW3D_OT_snap_cursor_to_center"; - + /* api callbacks */ ot->exec = snap_curs_to_center_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -804,12 +804,12 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) if (ED_transverts_check_obedit(obedit)) ED_transverts_create_from_obedit(&tvs, obedit, TM_ALL_JOINTS); - + if (tvs.transverts_tot == 0) return false; copy_m3_m4(bmat, obedit->obmat); - + tv = tvs.transverts; for (a = 0; a < tvs.transverts_tot; a++, tv++) { copy_v3_v3(vec, (tv->flag & TX_VERT_USE_MAPLOC) ? tv->maploc : tv->loc); @@ -818,8 +818,8 @@ bool ED_view3d_minmax_verts(Object *obedit, float min[3], float max[3]) add_v3_v3(centroid, vec); minmax_v3v3_v3(min, max, vec); } - + ED_transverts_free(&tvs); - + return true; } diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 3e61809671a..e7ae0d39a2b 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -137,15 +137,15 @@ typedef struct CustomTool { static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) { wmOperatorType *ot = arg2; - + if (ot) { CustomTool *ct = MEM_callocN(sizeof(CustomTool), "CustomTool"); - + BLI_addtail(arg_listbase, ct); BLI_strncpy(ct->opname, ot->idname, OP_MAX_TYPENAME); BLI_strncpy(ct->context, CTX_data_mode_string(C), OP_MAX_TYPENAME); } - + } static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) @@ -157,7 +157,7 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons if (BLI_strcasestr(ot->name, str)) { if (WM_operator_poll((bContext *)C, ot)) { - + if (false == UI_search_item_add(items, ot->name, ot, 0)) break; } @@ -174,30 +174,30 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) wmWindow *win = CTX_wm_window(C); uiBlock *block; uiBut *but; - + /* clear initial search string, then all items show */ search[0] = 0; - + block = UI_block_begin(C, ar, "_popup", UI_EMBOSS); UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_SEARCH_MENU); - + /* fake button, it holds space for search items */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 15, UI_searchbox_size_x(), UI_searchbox_size_y(), NULL, 0, 0, 0, 0, NULL); - + but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 0, 150, 19, 0, 0, ""); UI_but_func_search_set(but, NULL, operator_search_cb, arg_listbase, operator_call_cb, NULL); - + UI_block_bounds_set_normal(block, 6); UI_block_direction_set(block, UI_DIR_DOWN); UI_block_end(C, block); - + wm_event_init_from_window(win, &event); event.type = EVT_BUT_OPEN; event.val = KM_PRESS; event.customdata = but; event.customdatafree = false; wm_event_add(win, &event); - + return block; } @@ -208,13 +208,13 @@ static void view3d_panel_tool_shelf(const bContext *C, Panel *pa) SpaceType *st = NULL; uiLayout *col; const char *context = CTX_data_mode_string(C); - + if (sl) st = BKE_spacetype_from_id(sl->spacetype); - + if (st && st->toolshelf.first) { CustomTool *ct; - + for (ct = st->toolshelf.first; ct; ct = ct->next) { if (STREQLEN(context, ct->context, OP_MAX_TYPENAME)) { col = uiLayoutColumn(pa->layout, true); @@ -242,7 +242,7 @@ void view3d_toolshelf_register(ARegionType *art) void view3d_tool_props_register(ARegionType *art) { PanelType *pt; - + pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel last operator"); strcpy(pt->idname, "VIEW3D_PT_last_operator"); strcpy(pt->label, N_("Operator")); @@ -258,7 +258,7 @@ static int view3d_toolshelf_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = view3d_has_tools_region(sa); - + if (ar) ED_region_toggle_hidden(C, ar); @@ -270,10 +270,10 @@ void VIEW3D_OT_toolshelf(wmOperatorType *ot) ot->name = "Tool Shelf"; ot->description = "Toggles tool shelf display"; ot->idname = "VIEW3D_OT_toolshelf"; - + ot->exec = view3d_toolshelf_toggle_exec; ot->poll = ED_operator_view3d_active; - + /* flags */ ot->flag = 0; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index e48ecd7797a..608580c0a08 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -132,7 +132,7 @@ void ED_view3d_smooth_view_ex( RegionView3D *rv3d = ar->regiondata; struct SmoothView3DStore sms = {{0}}; bool ok = false; - + /* initialize sms */ view3d_smooth_view_state_backup(&sms.dst, v3d, rv3d); view3d_smooth_view_state_backup(&sms.src, v3d, rv3d); @@ -185,11 +185,11 @@ void ED_view3d_smooth_view_ex( ED_view3d_from_object(sview->camera, sms.dst.ofs, sms.dst.quat, &sms.dst.dist, &sms.dst.lens); sms.to_camera = true; /* restore view3d values in end */ } - + /* skip smooth viewing for render engine draw */ if (smooth_viewtx && v3d->drawtype != OB_RENDER) { bool changed = false; /* zero means no difference */ - + if (sview->camera_old != sview->camera) changed = true; else if (sms.dst.dist != rv3d->dist) @@ -200,7 +200,7 @@ void ED_view3d_smooth_view_ex( changed = true; else if (!equals_v4v4(sms.dst.quat, rv3d->viewquat)) changed = true; - + /* The new view is different from the old one * so animate the view */ if (changed) { @@ -217,10 +217,10 @@ void ED_view3d_smooth_view_ex( } sms.time_allowed = (double)smooth_viewtx / 1000.0; - + /* if this is view rotation only * we can decrease the time allowed by - * the angle between quats + * the angle between quats * this means small rotations wont lag */ if (sview->quat && !sview->ofs && !sview->dist) { /* scale the time allowed by the rotation */ @@ -237,7 +237,7 @@ void ED_view3d_smooth_view_ex( } rv3d->rflag |= RV3D_NAVIGATING; - + /* not essential but in some cases the caller will tag the area for redraw, * and in that case we can get a flicker of the 'org' user view but we want to see 'src' */ view3d_smooth_view_state_restore(&sms.src, v3d, rv3d); @@ -256,7 +256,7 @@ void ED_view3d_smooth_view_ex( ok = true; } } - + /* if we get here nothing happens */ if (ok == false) { if (sms.to_camera == false) { @@ -297,15 +297,15 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool RegionView3D *rv3d = ar->regiondata; struct SmoothView3DStore *sms = rv3d->sms; float step, step_inv; - + if (sms->time_allowed != 0.0) step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed); else step = 1.0f; - + /* end timer */ if (step >= 1.0f) { - + /* if we went to camera, store the original */ if (sms->to_camera) { rv3d->persp = RV3D_CAMOB; @@ -317,14 +317,14 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool ED_view3d_camera_lock_sync(v3d, rv3d); ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); } - + if ((rv3d->viewlock & RV3D_LOCKED) == 0) { rv3d->view = sms->org_view; } MEM_freeN(rv3d->sms); rv3d->sms = NULL; - + WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rv3d->smooth_timer); rv3d->smooth_timer = NULL; rv3d->rflag &= ~RV3D_NAVIGATING; @@ -343,7 +343,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool else { interp_v3_v3v3(rv3d->ofs, sms->src.ofs, sms->dst.ofs, step); } - + rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv; v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv; @@ -355,7 +355,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool /* Event handling won't know if a UI item has been moved under the pointer. */ WM_event_add_mousemove(C); } - + if (sync_boxview && (rv3d->viewlock & RV3D_BOXVIEW)) { view3d_boxview_copy(CTX_wm_area(C), ar); } @@ -453,9 +453,9 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; - + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, v3d->camera); - + return OPERATOR_FINISHED; } @@ -485,11 +485,11 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot) ot->name = "Align Camera To View"; ot->description = "Set camera view to active view"; ot->idname = "VIEW3D_OT_camera_to_view"; - + /* api callbacks */ ot->exec = view3d_camera_to_view_exec; ot->poll = view3d_camera_to_view_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -654,7 +654,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op) } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); } - + return OPERATOR_FINISHED; } @@ -672,11 +672,11 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) ot->name = "Set Active Object as Camera"; ot->description = "Set the active object as the active camera for this view or scene"; ot->idname = "VIEW3D_OT_object_as_camera"; - + /* api callbacks */ ot->exec = view3d_setobjectascamera_exec; ot->poll = ED_operator_rv3d_user_region_poll; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -696,7 +696,7 @@ void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rcti *rect) rctf viewplane; float clipsta, clipend; bool is_ortho; - + is_ortho = ED_view3d_viewplane_get(v3d, rv3d, ar->winx, ar->winy, &viewplane, &clipsta, &clipend, NULL); rv3d->is_persp = !is_ortho; @@ -771,13 +771,13 @@ void view3d_viewmatrix_set( /* should be moved to better initialize later on XXX */ if (rv3d->viewlock & RV3D_LOCKED) ED_view3d_lock(rv3d); - + quat_to_mat4(rv3d->viewmat, rv3d->viewquat); if (rv3d->persp == RV3D_PERSP) rv3d->viewmat[3][2] -= rv3d->dist; if (v3d->ob_centre) { Object *ob = v3d->ob_centre; float vec[3]; - + copy_v3_v3(vec, ob->obmat[3]); if (ob->type == OB_ARMATURE && v3d->ob_centre_bone[0]) { bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, v3d->ob_centre_bone); @@ -929,16 +929,16 @@ int view3d_opengl_select( v3d->zbuf = true; glEnable(GL_DEPTH_TEST); } - + if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_set(vc->rv3d); - + GPU_select_begin(buffer, bufsize, &rect, gpu_select_mode, 0); ED_view3d_draw_select_loop(vc, scene, v3d, ar, use_obedit_skip, use_nearest); hits = GPU_select_end(); - + /* second pass, to get the closest object to camera */ if (do_passes && (hits > 0)) { GPU_select_begin(buffer, bufsize, &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits); @@ -950,12 +950,12 @@ int view3d_opengl_select( G.f &= ~G_PICKSEL; ED_view3d_draw_setup_view(vc->win, scene, ar, v3d, vc->rv3d->viewmat, NULL, NULL); - + if (v3d->drawtype > OB_WIRE) { v3d->zbuf = 0; glDisable(GL_DEPTH_TEST); } - + if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); @@ -978,9 +978,9 @@ static unsigned int free_localbit(Main *bmain) unsigned int lay; ScrArea *sa; bScreen *sc; - + lay = 0; - + /* sometimes we loose a localview: when an area is closed */ /* check all areas: which localviews are in use? */ for (sc = bmain->screen.first; sc; sc = sc->id.next) { @@ -994,7 +994,7 @@ static unsigned int free_localbit(Main *bmain) } } } - + if ((lay & 0x01000000) == 0) return 0x01000000; if ((lay & 0x02000000) == 0) return 0x02000000; if ((lay & 0x04000000) == 0) return 0x04000000; @@ -1003,35 +1003,35 @@ static unsigned int free_localbit(Main *bmain) if ((lay & 0x20000000) == 0) return 0x20000000; if ((lay & 0x40000000) == 0) return 0x40000000; if ((lay & 0x80000000) == 0) return 0x80000000; - + return 0; } int ED_view3d_scene_layer_set(int lay, const int *values, int *active) { int i, tot = 0; - + /* ensure we always have some layer selected */ for (i = 0; i < 20; i++) if (values[i]) tot++; - + if (tot == 0) return lay; - + for (i = 0; i < 20; i++) { - + if (active) { /* if this value has just been switched on, make that layer active */ if (values[i] && (lay & (1 << i)) == 0) { *active = (1 << i); } } - + if (values[i]) lay |= (1 << i); else lay &= ~(1 << i); } - + /* ensure always an active layer */ if (active && (lay & *active) == 0) { for (i = 0; i < 20; i++) { @@ -1041,7 +1041,7 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active) } } } - + return lay; } @@ -1072,9 +1072,9 @@ static bool view3d_localview_init( else { if (scene->obedit) { BKE_object_minmax(scene->obedit, min, max, false); - + ok = true; - + BASACT->lay |= locallay; scene->obedit->lay = BASACT->lay; } @@ -1092,12 +1092,12 @@ static bool view3d_localview_init( sub_v3_v3v3(box, max, min); size = max_fff(box[0], box[1], box[2]); } - + if (ok == true) { ARegion *ar; - + v3d->localvd = MEM_mallocN(sizeof(View3D), "localview"); - + memcpy(v3d->localvd, v3d, sizeof(View3D)); mid_v3_v3v3(mid, min, max); @@ -1145,11 +1145,11 @@ static bool view3d_localview_init( .dist = ok_dist ? &dist_new : NULL, .lens = &v3d->lens}); } } - + v3d->lay = locallay; } else { - /* clear flags */ + /* clear flags */ for (base = FIRSTBASE; base; base = base->next) { if (base->lay & locallay) { base->lay -= locallay; @@ -1171,9 +1171,9 @@ static void restore_localviewdata(wmWindowManager *wm, wmWindow *win, Main *bmai ARegion *ar; View3D *v3d = sa->spacedata.first; Object *camera_old, *camera_new; - + if (v3d->localvd == NULL) return; - + camera_old = v3d->camera; camera_new = v3d->localvd->camera; @@ -1181,16 +1181,16 @@ static void restore_localviewdata(wmWindowManager *wm, wmWindow *win, Main *bmai v3d->layact = v3d->localvd->layact; v3d->drawtype = v3d->localvd->drawtype; v3d->camera = v3d->localvd->camera; - + if (free) { MEM_freeN(v3d->localvd); v3d->localvd = NULL; } - + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { RegionView3D *rv3d = ar->regiondata; - + if (rv3d->localvd) { Object *camera_old_rv3d, *camera_new_rv3d; @@ -1227,16 +1227,16 @@ static bool view3d_localview_exit( View3D *v3d = sa->spacedata.first; struct Base *base; unsigned int locallay; - + if (v3d->localvd) { - + locallay = v3d->lay & 0xFF000000; restore_localviewdata(wm, win, bmain, sa, smooth_viewtx); /* for when in other window the layers have changed */ if (v3d->scenelock) v3d->lay = scene->lay; - + for (base = FIRSTBASE; base; base = base->next) { if (base->lay & locallay) { base->lay -= locallay; @@ -1248,7 +1248,7 @@ static bool view3d_localview_exit( base->object->lay = base->lay; } } - + DAG_on_visible_update(bmain, false); return true; @@ -1268,7 +1268,7 @@ static int localview_exec(bContext *C, wmOperator *op) ScrArea *sa = CTX_wm_area(C); View3D *v3d = CTX_wm_view3d(C); bool changed; - + if (v3d->localvd) { changed = view3d_localview_exit(wm, win, bmain, scene, sa, smooth_viewtx); } @@ -1298,11 +1298,11 @@ void VIEW3D_OT_localview(wmOperatorType *ot) ot->name = "Local View"; ot->description = "Toggle display of selected object(s) separately and centered in view"; ot->idname = "VIEW3D_OT_localview"; - + /* api callbacks */ ot->exec = localview_exec; ot->flag = OPTYPE_UNDO; /* localview changes object layer bitflags */ - + ot->poll = ED_operator_view3d_active; } diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index 76db203286d..7c3e24c3cc9 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -131,7 +131,7 @@ void ED_editors_exit(bContext *C) if (!bmain) return; - + /* frees all editmode undos */ if (G.main->wm.first) { wmWindowManager *wm = G.main->wm.first; @@ -145,7 +145,7 @@ void ED_editors_exit(bContext *C) for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->obedit) { Object *ob = sce->obedit; - + if (ob) { if (ob->type == OB_MESH) { Mesh *me = ob->data; @@ -218,7 +218,7 @@ void apply_keyb_grid(int shift, int ctrl, float *val, float fac1, float fac2, fl /* fac1 is for 'nothing', fac2 for CTRL, fac3 for SHIFT */ if (invert) ctrl = !ctrl; - + if (ctrl && shift) { if (fac3 != 0.0f) *val = fac3 * floorf(*val / fac3 + 0.5f); } diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index ab415c0cb83..92e0920da6b 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -72,7 +72,7 @@ static int uvedit_center(Scene *scene, BMEditMesh *em, Image *ima, float center[ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); - + zero_v2(center); BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(f, cd_poly_tex_offset); @@ -106,7 +106,7 @@ static void uvedit_translate(Scene *scene, BMEditMesh *em, Image *ima, float del const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); - + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(f, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, f, tf)) @@ -137,7 +137,7 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) float width = 8 * UI_UNIT_X; ED_space_image_get_size(sima, &imx, &imy); - + em = BKE_editmesh_from_object(obedit); if (uvedit_center(scene, em, ima, center)) { @@ -170,7 +170,7 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) step = 100; digits = 2; } - + UI_block_align_begin(block); uiDefButF(block, UI_BTYPE_NUM, B_UVEDIT_VERTEX, IFACE_("X:"), 0, 0, width, UI_UNIT_Y, &uvedit_old_center[0], UNPACK2(range_xy[0]), step, digits, ""); @@ -223,12 +223,12 @@ static int image_panel_uv_poll(const bContext *C, PanelType *UNUSED(pt)) static void image_panel_uv(const bContext *C, Panel *pa) { uiBlock *block; - + block = uiLayoutAbsoluteBlock(pa->layout); UI_block_func_handle_set(block, do_uvedit_vertex, NULL); uvedit_vertex_buttons(C, block); -} +} void ED_uvedit_buttons_register(ARegionType *art) { diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 7b793697077..79dcfb3299f 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -81,7 +81,7 @@ void ED_image_draw_cursor(ARegion *ar, const float cursor[2]) mul_v2_fl(zoom, 256.0f * UI_DPI_FAC); x_fac = zoom[0]; y_fac = zoom[1]; - + cpack(0xFFFFFF); glTranslate2fv(cursor); fdrawline(-0.05f * x_fac, 0, 0, 0.05f * y_fac); @@ -181,12 +181,12 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe BLI_buffer_declare_static(vec2f, tf_uvorig_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); ED_space_image_get_uv_aspect(sima, &aspx, &aspy); - + switch (sima->dt_uvstretch) { case SI_UVDT_STRETCH_AREA: { float totarea = 0.0f, totuvarea = 0.0f, areadiff, uvarea, area; - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { const int efa_len = efa->len; float (*tf_uv)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa_len); @@ -202,7 +202,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe totarea += BM_face_calc_area(efa); totuvarea += area_poly_v2(tf_uv, efa->len); - + if (uvedit_face_visible_test(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } @@ -212,7 +212,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe BM_elem_flag_disable(efa, BM_ELEM_TAG); } } - + if (totarea < FLT_EPSILON || totuvarea < FLT_EPSILON) { col[0] = 1.0; col[1] = col[2] = 0.0; @@ -245,17 +245,17 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); uvarea = area_poly_v2(tf_uv, efa->len) / totuvarea; - + if (area < FLT_EPSILON || uvarea < FLT_EPSILON) areadiff = 1.0f; else if (area > uvarea) areadiff = 1.0f - (uvarea / area); else areadiff = 1.0f - (area / uvarea); - + weight_to_rgb(col, areadiff); glColor3fv(col); - + /* TODO: USE_EDBM_LOOPTRIS */ glBegin(GL_POLYGON); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { @@ -278,10 +278,10 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe BLI_buffer_declare_static(vec2f, auv_buf, BLI_BUFFER_NOP, BM_DEFAULT_NGON_STACK_SIZE); col[3] = 0.5f; /* hard coded alpha, not that nice */ - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - + if (uvedit_face_visible_test(scene, ima, efa, tf)) { const int efa_len = efa->len; float (*tf_uv)[2] = (float (*)[2])BLI_buffer_reinit_data(&tf_uv_buf, vec2f, efa_len); @@ -423,7 +423,7 @@ static void draw_uvs_other_mesh_new_shading(Object *ob, const Image *curimage, c for (a = 0; a < totcol; a++) { Image *image; - + /* if no materials, assume a default material with no image */ if (ob->totcol) ED_object_get_active_image(ob, a + 1, &image, NULL, NULL, NULL); @@ -581,7 +581,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) interpedges = (ts->selectmode & SCE_SELECT_VERTEX); else interpedges = (ts->uv_selectmode == UV_SELECT_VERTEX); - + /* draw other uvs */ if (sima->flag & SI_DRAW_OTHER) { Image *curimage; @@ -602,7 +602,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } /* 1. draw shadow mesh */ - + if (sima->flag & SI_DRAWSHADOW) { DM_update_materials(em->derivedFinal, obedit); /* first try existing derivedmesh */ @@ -616,15 +616,15 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) * so if cage is the same as the final, theres no point in drawing this */ if (!((ts->uv_flag & UV_SYNC_SELECTION) && (cagedm == finaldm))) draw_uvs_dm_shadow(finaldm); - + /* release derivedmesh again */ if (cagedm != finaldm) cagedm->release(cagedm); finaldm->release(finaldm); } } - + /* 2. draw colored faces */ - + if (sima->flag & SI_DRAW_STRETCH) { draw_uvs_stretch(sima, scene, em, activetf); } @@ -634,7 +634,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - + #ifdef USE_EDBM_LOOPTRIS { unsigned int i; @@ -679,7 +679,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) glColor4ubv((GLubyte *)col2); else glColor4ubv((GLubyte *)col1); - + glBegin(GL_POLYGON); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -698,7 +698,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } else { /* would be nice to do this within a draw loop but most below are optional, so it would involve too many checks */ - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); @@ -711,7 +711,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_elem_flag_disable(efa, BM_ELEM_TAG); } } - + } /* 3. draw active face stippled */ @@ -738,7 +738,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } } #endif - + /* 4. draw edges */ if (sima->flag & SI_SMOOTH_UV) { @@ -771,7 +771,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } break; case SI_UVDT_BLACK: /* black/white */ - case SI_UVDT_WHITE: + case SI_UVDT_WHITE: if (sima->dt_uv == SI_UVDT_WHITE) glColor3f(1.0f, 1.0f, 1.0f); else glColor3f(0.0f, 0.0f, 0.0f); @@ -785,14 +785,14 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) case SI_UVDT_OUTLINE: glLineWidth(3); cpack(0x0); - + BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset); } - + glLineWidth(1); UI_GetThemeColor4ubv(TH_WIRE_EDIT, col2); glColor4ubv((unsigned char *)col2); @@ -844,11 +844,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) continue; - + draw_uvs_lineloop_bmface(efa, cd_loop_uv_offset); } } - + break; } @@ -861,10 +861,10 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) if (drawfaces) { float cent[2]; - + pointsize = UI_GetThemeValuef(TH_FACEDOT_SIZE); glPointSize(pointsize); - + glBegin(GL_POINTS); /* unselected faces */ @@ -897,13 +897,13 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } /* 6. draw uv vertices */ - + if (drawfaces != 2) { /* 2 means Mesh Face Mode */ /* unselected uvs */ UI_ThemeColor(TH_VERTEX); pointsize = UI_GetThemeValuef(TH_VERTEX_SIZE); glPointSize(pointsize); - + glBegin(GL_POINTS); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -916,12 +916,12 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } } glEnd(); - + /* pinned uvs */ /* give odd pointsizes odd pin pointsizes */ glPointSize(pointsize * 2 + (((int)pointsize % 2) ? (-1) : 0)); cpack(0xFF); - + glBegin(GL_POINTS); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -935,11 +935,11 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) } } glEnd(); - + /* selected uvs */ UI_ThemeColor(TH_VERTEX_SELECT); glPointSize(pointsize); - + glBegin(GL_POINTS); BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_TAG)) @@ -966,10 +966,10 @@ static void draw_uv_shadows_get(SpaceImage *sima, Object *ob, Object *obedit, bo if ((sima->mode == SI_MODE_PAINT) && obedit && obedit->type == OB_MESH) { struct BMEditMesh *em = BKE_editmesh_from_object(obedit); - + *show_shadow = EDBM_uv_check(em); } - + *show_texpaint = (ob && ob->type == OB_MESH && ob->mode == OB_MODE_TEXTURE_PAINT); } diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 9c6f468532f..0fa5fb9a48d 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -102,13 +102,13 @@ bool ED_uvedit_test(Object *obedit) if (!obedit) return 0; - + if (obedit->type != OB_MESH) return 0; em = BKE_editmesh_from_object(obedit); ret = EDBM_uv_check(em); - + return ret; } @@ -161,7 +161,7 @@ bool ED_object_get_active_image( if (r_ntree) *r_ntree = ntree; return true; } - + if (r_ima) *r_ima = NULL; if (r_iuser) *r_iuser = NULL; if (r_node) *r_node = node; @@ -196,7 +196,7 @@ void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, I MTexPoly *tf; bool update = false; const bool selected = !(scene->toolsettings->uv_flag & UV_SYNC_SELECTION); - + /* skip assigning these procedural images... */ if (ima && (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE)) return; @@ -252,7 +252,7 @@ void ED_uvedit_assign_image(Main *UNUSED(bmain), Scene *scene, Object *obedit, I { if (ima) { tf->tpage = ima; - + if (ima->id.us == 0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); @@ -299,7 +299,7 @@ static bool uvedit_set_tile(Object *obedit, Image *ima, int curtile) BMIter iter; MTexPoly *tf; int cd_poly_tex_offset; - + /* verify if we have something to do */ if (!ima || !ED_uvedit_test(obedit)) return false; @@ -310,7 +310,7 @@ static bool uvedit_set_tile(Object *obedit, Image *ima, int curtile) /* skip assigning these procedural images... */ if (ima->type == IMA_TYPE_R_RESULT || ima->type == IMA_TYPE_COMPOSITE) return false; - + em = BKE_editmesh_from_object(obedit); cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); @@ -492,7 +492,7 @@ bool uvedit_edge_select_test( return BM_elem_flag_test(l->e, BM_ELEM_SELECT); } else { - return BM_elem_flag_test(l->v, BM_ELEM_SELECT) && + return BM_elem_flag_test(l->v, BM_ELEM_SELECT) && BM_elem_flag_test(l->next->v, BM_ELEM_SELECT); } } @@ -545,7 +545,7 @@ void uvedit_edge_select_enable( luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); - + luv1->flag |= MLOOPUV_VERTSEL; luv2->flag |= MLOOPUV_VERTSEL; } @@ -573,7 +573,7 @@ void uvedit_edge_select_disable( luv1 = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv2 = BM_ELEM_CD_GET_VOID_P(l->next, cd_loop_uv_offset); - + luv1->flag &= ~MLOOPUV_VERTSEL; luv2->flag &= ~MLOOPUV_VERTSEL; } @@ -714,7 +714,7 @@ bool ED_uvedit_minmax(Scene *scene, Image *ima, Object *obedit, float r_min[2], tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -763,7 +763,7 @@ static bool ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[ tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { @@ -781,7 +781,7 @@ static bool ED_uvedit_median(Scene *scene, Image *ima, Object *obedit, float co[ static bool uvedit_center(Scene *scene, Image *ima, Object *obedit, float cent[2], char mode) { bool changed = false; - + if (mode == V3D_AROUND_CENTER_BOUNDS) { /* bounding box */ float min[2], max[2]; if (ED_uvedit_minmax(scene, ima, obedit, min, max)) { @@ -991,12 +991,12 @@ bool ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float mindist = 1e10f; copy_v2_v2(r_uv, co); - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); dist = len_manhattan_v2v2(co, luv->uv); @@ -1030,7 +1030,7 @@ static void uv_select_edgeloop_vertex_loop_flag(UvMapVert *first) count++; } - + if (count < 5) first->flag = 1; } @@ -1046,7 +1046,7 @@ static UvMapVert *uv_select_edgeloop_vertex_map_get(UvVertMap *vmap, BMFace *efa if (iterv->f == BM_elem_index_get(efa)) return first; } - + return NULL; } @@ -1188,7 +1188,7 @@ static int uv_select_edgeloop( else { select = true; } - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { iterv_curr = uv_select_edgeloop_vertex_map_get(vmap, efa, l); @@ -1295,7 +1295,7 @@ static void uv_select_linked( /* make_uv_vert_map_EM sets verts tmp.l to the indices */ vlist = BM_uv_vert_map_at_index(vmap, BM_elem_index_get(l->v)); - + startv = vlist; for (iterv = vlist; iterv; iterv = iterv->next) { @@ -1809,7 +1809,7 @@ static void UV_OT_align(wmOperatorType *ot) ot->description = "Align selected UV vertices to an axis"; ot->idname = "UV_OT_align"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_align_exec; ot->poll = ED_operator_uvedit; @@ -2008,7 +2008,7 @@ static void UV_OT_weld(wmOperatorType *ot) ot->description = "Weld selected UV vertices together"; ot->idname = "UV_OT_weld"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_weld_exec; ot->poll = ED_operator_uvedit; @@ -2055,7 +2055,7 @@ static void uv_select_all_perform(Scene *scene, Image *ima, BMEditMesh *em, int action = SEL_SELECT; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); - + if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; @@ -2069,8 +2069,8 @@ static void uv_select_all_perform(Scene *scene, Image *ima, BMEditMesh *em, int } } } - - + + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); @@ -2119,7 +2119,7 @@ static void UV_OT_select_all(wmOperatorType *ot) ot->description = "Change selection of all UV vertices"; ot->idname = "UV_OT_select_all"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_all_exec; ot->poll = ED_operator_uvedit; @@ -2272,7 +2272,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo hituv[i] = luv->uv; hitv[i] = BM_elem_index_get(l->v); } - + hitlen = hit.efa->len; } else if (selectmode == UV_SELECT_ISLAND) { @@ -2367,7 +2367,7 @@ static int uv_mouse_select(bContext *C, const float co[2], bool extend, bool loo tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tf)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (sticky == SI_STICKY_DISABLE) continue; luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -2444,7 +2444,7 @@ static void UV_OT_select(wmOperatorType *ot) ot->description = "Select UV vertices"; ot->idname = "UV_OT_select"; ot->flag = OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_exec; ot->invoke = uv_select_invoke; @@ -2493,7 +2493,7 @@ static void UV_OT_select_loop(wmOperatorType *ot) ot->description = "Select a loop of connected UV vertices"; ot->idname = "UV_OT_select_loop"; ot->flag = OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_loop_exec; ot->invoke = uv_select_loop_invoke; @@ -2575,7 +2575,7 @@ static void UV_OT_select_linked(wmOperatorType *ot) ot->description = "Select all UV vertices linked to the active UV map"; ot->idname = "UV_OT_select_linked"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_linked_exec; ot->poll = ED_operator_uvedit; /* requires space image */ @@ -2785,12 +2785,12 @@ static void uv_select_flush_from_tag_sticky_loc_internal( */ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object *obedit, const bool select) { - /* Selecting UV Faces with some modes requires us to change + /* Selecting UV Faces with some modes requires us to change * the selection in other faces (depending on the sticky mode). - * + * * This only needs to be done when the Mesh is not used for * selection (so for sticky modes, vertex or location based). */ - + ToolSettings *ts = scene->toolsettings; BMEditMesh *em = BKE_editmesh_from_object(obedit); BMFace *efa; @@ -2798,7 +2798,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object BMIter iter, liter; /* MTexPoly *tf; */ const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - + if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_VERTEX) { /* Tag all verts as untouched, then touch the ones that have a face center * in the loop and select all MLoopUV's that use a touched vert. */ @@ -2827,19 +2827,19 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object struct UvVertMap *vmap; float limit[2]; unsigned int efa_index; - + uvedit_pixel_to_float(sima, limit, 0.05); - + BM_mesh_elem_table_ensure(em->bm, BM_FACE); vmap = BM_uv_vert_map_create(em->bm, limit, false, false); if (vmap == NULL) { return; } - + BM_ITER_MESH_INDEX (efa, &iter, em->bm, BM_FACES_OF_MESH, efa_index) { if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { /* tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); */ /* UNUSED */ - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { uv_select_flush_from_tag_sticky_loc_internal( scene, em, vmap, efa_index, l, @@ -2848,7 +2848,7 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object } } BM_uv_vert_map_free(vmap); - + } else { /* SI_STICKY_DISABLE or ts->uv_flag & UV_SYNC_SELECTION */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { @@ -3057,12 +3057,12 @@ static int uv_border_select_exec(bContext *C, wmOperator *op) if (ts->uv_flag & UV_SYNC_SELECTION) { WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); } - + return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; -} +} static void UV_OT_select_border(wmOperatorType *ot) { @@ -3070,17 +3070,17 @@ static void UV_OT_select_border(wmOperatorType *ot) ot->name = "Border Select"; ot->description = "Select UV vertices using border selection"; ot->idname = "UV_OT_select_border"; - + /* api callbacks */ ot->invoke = WM_gesture_border_invoke; ot->exec = uv_border_select_exec; ot->modal = WM_gesture_border_modal; ot->poll = ED_operator_uvedit_space_image; /* requires space image */; ot->cancel = WM_gesture_border_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* properties */ RNA_def_boolean(ot->srna, "pinned", 0, "Pinned", "Border select pinned UVs only"); @@ -3139,7 +3139,7 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op) ellipse[1] = height * zoomy / radius; UI_view2d_region_to_view(&ar->v2d, x, y, &offset[0], &offset[1]); - + /* do selection */ if (use_face_center) { changed = false; @@ -3195,14 +3195,14 @@ static void UV_OT_circle_select(wmOperatorType *ot) ot->name = "Circle Select"; ot->description = "Select UV vertices using circle selection"; ot->idname = "UV_OT_circle_select"; - + /* api callbacks */ ot->invoke = WM_gesture_circle_invoke; ot->modal = WM_gesture_circle_modal; ot->exec = uv_circle_select_exec; ot->poll = ED_operator_uvedit_space_image; /* requires space image */; ot->cancel = WM_gesture_circle_cancel; - + /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -3399,7 +3399,7 @@ static int uv_snap_cursor_exec(bContext *C, wmOperator *op) if (!changed) return OPERATOR_CANCELLED; - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, sima); return OPERATOR_FINISHED; @@ -3417,7 +3417,7 @@ static void UV_OT_snap_cursor(wmOperatorType *ot) ot->description = "Snap cursor to target type"; ot->idname = "UV_OT_snap_cursor"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_snap_cursor_exec; ot->poll = ED_operator_uvedit_space_image; /* requires space image */; @@ -3504,7 +3504,7 @@ static bool uv_snap_uvs_to_adjacent_unselected(Scene *scene, Image *ima, Object bool changed = false; const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&bm->pdata, CD_MTEXPOLY); - + /* index every vert that has a selected UV using it, but only once so as to * get unique indices and to count how much to malloc */ BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { @@ -3569,7 +3569,7 @@ static bool uv_snap_uvs_to_pixels(SpaceImage *sima, Scene *scene, Object *obedit ED_space_image_get_size(sima, &width, &height); w = (float)width; h = (float)height; - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tface = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset); if (!uvedit_face_visible_test(scene, ima, efa, tface)) @@ -3642,7 +3642,7 @@ static void UV_OT_snap_selected(wmOperatorType *ot) ot->description = "Snap selected UV vertices to target type"; ot->idname = "UV_OT_snap_selected"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_snap_selection_exec; ot->poll = ED_operator_uvedit_space_image; @@ -3669,7 +3669,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) MTexPoly *tface; MLoopUV *luv; const bool clear = RNA_boolean_get(op->ptr, "clear"); - + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); @@ -3680,7 +3680,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - + if (!clear) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) luv->flag |= MLOOPUV_PINNED; @@ -3691,7 +3691,7 @@ static int uv_pin_exec(bContext *C, wmOperator *op) } } } - + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; @@ -3704,7 +3704,7 @@ static void UV_OT_pin(wmOperatorType *ot) ot->description = "Set/clear selected UV vertices as anchored between multiple unwrap operations"; ot->idname = "UV_OT_pin"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_pin_exec; ot->poll = ED_operator_uvedit; @@ -3730,7 +3730,7 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) BMIter iter, liter; MTexPoly *tface; MLoopUV *luv; - + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); const int cd_poly_tex_offset = CustomData_get_offset(&em->bm->pdata, CD_MTEXPOLY); @@ -3741,12 +3741,12 @@ static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - + if (luv->flag & MLOOPUV_PINNED) uvedit_uv_select_enable(em, scene, l, false, cd_loop_uv_offset); } } - + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; @@ -3759,7 +3759,7 @@ static void UV_OT_select_pinned(wmOperatorType *ot) ot->description = "Select all pinned UV vertices"; ot->idname = "UV_OT_select_pinned"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_select_pinned_exec; ot->poll = ED_operator_uvedit; @@ -3883,7 +3883,7 @@ static int uv_hide_exec(bContext *C, wmOperator *op) /* flush vertex selection changes */ if (em->selectmode != SCE_SELECT_FACE) EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX | SCE_SELECT_EDGE); - + BM_select_history_validate(em->bm); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); @@ -3899,7 +3899,7 @@ static void UV_OT_hide(wmOperatorType *ot) ot->description = "Hide (un)selected UV vertices"; ot->idname = "UV_OT_hide"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_hide_exec; ot->poll = ED_operator_uvedit; @@ -3966,7 +3966,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { totsel += BM_elem_flag_test(l->v, BM_ELEM_SELECT); } - + if (!totsel) { BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); @@ -4023,7 +4023,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op) } } } - + /* re-select tagged faces */ BM_mesh_elem_hflag_enable_test(em->bm, BM_FACE, BM_ELEM_SELECT, true, false, BM_ELEM_TAG); @@ -4039,7 +4039,7 @@ static void UV_OT_reveal(wmOperatorType *ot) ot->description = "Reveal all hidden UV vertices"; ot->idname = "UV_OT_reveal"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = uv_reveal_exec; ot->poll = ED_operator_uvedit; @@ -4068,9 +4068,9 @@ static int uv_set_2d_cursor_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; RNA_float_get_array(op->ptr, "location", sima->cursor); - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_IMAGE, NULL); - + return OPERATOR_FINISHED; } @@ -4100,7 +4100,7 @@ static void UV_OT_cursor_set(wmOperatorType *ot) ot->name = "Set 2D Cursor"; ot->description = "Set 2D cursor location"; ot->idname = "UV_OT_cursor_set"; - + /* api callbacks */ ot->exec = uv_set_2d_cursor_exec; ot->invoke = uv_set_2d_cursor_invoke; @@ -4134,7 +4134,7 @@ static int set_tile_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } - + return OPERATOR_CANCELLED; } @@ -4154,10 +4154,10 @@ static int set_tile_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) { fx = fx * ima->xrep; fy = fy * ima->yrep; - + tile[0] = fx; tile[1] = fy; - + sima->curtile = tile[1] * ima->xrep + tile[0]; RNA_int_set_array(op->ptr, "tile", tile); } @@ -4171,7 +4171,7 @@ static void UV_OT_tile_set(wmOperatorType *ot) ot->name = "Set Tile"; ot->description = "Set UV image tile coordinates"; ot->idname = "UV_OT_tile_set"; - + /* api callbacks */ ot->exec = set_tile_exec; ot->invoke = set_tile_invoke; @@ -4457,7 +4457,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; - + keymap = WM_keymap_find(keyconf, "UV Editor", 0, 0); keymap->poll = ED_operator_uvedit_can_uv_sculpt; @@ -4467,7 +4467,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* Mark edge seam */ WM_keymap_add_item(keymap, "UV_OT_mark_seam", EKEY, KM_PRESS, KM_CTRL, 0); - + /* pick selection */ RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select", SELECTMOUSE, KM_PRESS, 0, 0)->ptr, "extend", false); RNA_boolean_set(WM_keymap_add_item(keymap, "UV_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", true); @@ -4539,7 +4539,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) /* cursor */ WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "UV_OT_tile_set", ACTIONMOUSE, KM_PRESS, KM_SHIFT, 0); - + /* menus */ WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_select_mode", TABKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index c510c12ae53..1d2583cf9d4 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -113,7 +113,7 @@ typedef struct PVert { float uv[2]; unsigned char flag; -} PVert; +} PVert; typedef struct PEdge { struct PEdge *nextlink; @@ -242,8 +242,8 @@ typedef struct PHandle { */ static int PHashSizes[] = { - 1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, - 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, + 1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, + 16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 268435459 }; @@ -294,7 +294,7 @@ static void phash_insert(PHash *ph, PHashLink *link) link->next = lookup->next; lookup->next = link; } - + ph->size++; if (ph->size > (size * 3)) { @@ -323,7 +323,7 @@ static PHashLink *phash_lookup(PHash *ph, PHashKey key) return link; else if (PHASH_hash(ph, link->key) != hash) return NULL; - + return link; } @@ -336,7 +336,7 @@ static PHashLink *phash_next(PHash *ph, PHashKey key, PHashLink *link) return link; else if (PHASH_hash(ph, link->key) != hash) return NULL; - + return link; } @@ -562,7 +562,7 @@ static PEdge *p_wheel_edge_next(PEdge *e) } static PEdge *p_wheel_edge_prev(PEdge *e) -{ +{ return (e->pair) ? e->pair->next : NULL; } @@ -619,7 +619,7 @@ static void p_chart_topological_sanity_check(PChart *chart) for (v = chart->verts; v; v = v->nextlink) param_test_equals_ptr("v->edge->vert", v, v->edge->vert); - + for (e = chart->edges; e; e = e->nextlink) { if (e->pair) { param_test_equals_ptr("e->pair->pair", e, e->pair->pair); @@ -867,7 +867,7 @@ static PBool p_edge_implicit_seam(PEdge *e, PEdge *ep) ep->flag |= PEDGE_SEAM; return P_TRUE; } - + return P_FALSE; } @@ -881,7 +881,7 @@ static PBool p_edge_has_pair(PHandle *handle, PEdge *e, PEdge **pair, PBool impl if (e->flag & PEDGE_SEAM) return P_FALSE; - + key = PHASH_edge(key1, key2); pe = (PEdge *)phash_lookup(handle->hash_edges, key); *pair = NULL; @@ -999,7 +999,7 @@ static void p_split_vert(PChart *chart, PEdge *e) lastwe = e; for (we = p_wheel_edge_prev(e); we && (we != e); we = p_wheel_edge_prev(we)) lastwe = we; - + /* go over all edges in wheel */ for (we = lastwe; we; we = p_wheel_edge_next(we)) { if (we->flag & PEDGE_VERTEX_SPLIT) @@ -1202,7 +1202,7 @@ static PBool p_quad_split_direction(PHandle *handle, float **co, PHashKey *vkeys /* Construction: boundary filling */ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer) -{ +{ PEdge *e, *be; float len, maxlen = -1.0; @@ -1327,7 +1327,7 @@ static void p_chart_fill_boundary(PChart *chart, PEdge *be, int nedges) } else { ne2->vert->edge = ne2; - + ne2->u.heaplink = BLI_heap_insert(heap, p_edge_boundary_angle(ne2), ne2); e2->u.heaplink = BLI_heap_insert(heap, p_edge_boundary_angle(e2), e2); } @@ -1412,7 +1412,7 @@ static void p_polygon_kernel_clip(float (*oldpoints)[2], int noldpoints, float ( newpoints[*nnewpoints][1] = p2[1]; (*nnewpoints)++; } - + p1in = p2in; p1 = p2; } @@ -1422,7 +1422,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent { int i, size, nnewpoints = npoints; float (*oldpoints)[2], (*newpoints)[2], *p1, *p2; - + size = npoints * 3; oldpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonOldPoints"); newpoints = MEM_mallocN(sizeof(float) * 2 * size, "PPolygonNewPoints"); @@ -1486,7 +1486,7 @@ static void p_polygon_kernel_center(float (*points)[2], int npoints, float *cent int NCOLLAPSE = 1; int NCOLLAPSEX = 0; - + static float p_vert_cotan(float *v1, float *v2, float *v3) { float a[3], b[3], c[3], clen; @@ -1499,10 +1499,10 @@ static float p_vert_cotan(float *v1, float *v2, float *v3) if (clen == 0.0f) return 0.0f; - + return dot_v3v3(a, b) / clen; } - + static PBool p_vert_flipped_wheel_triangle(PVert *v) { PEdge *e = v->edge; @@ -1530,7 +1530,7 @@ static PBool p_vert_map_harmonic_weights(PVert *v) do { float t1, t2, weight; PVert *v1, *v2; - + v1 = e->next->vert; v2 = e->next->next->vert; t1 = p_vert_cotan(v2->co, e->vert->co, v1->co); @@ -1563,7 +1563,7 @@ static PBool p_vert_map_harmonic_weights(PVert *v) weightsum += t1 + t2; positionsum[0] += (v2->uv[1] - v1->uv[1]) + (t1 * v2->uv[0] + t2 * v1->uv[0]); positionsum[1] += (v1->uv[0] - v2->uv[0]) + (t1 * v2->uv[1] + t2 * v1->uv[1]); - + e = p_wheel_edge_next(e); } while (e && (e != v->edge)); } @@ -1617,20 +1617,20 @@ static void p_vert_harmonic_insert(PVert *v) do { PEdge *nexte = p_wheel_edge_next(e); - points[i][0] = e->next->vert->uv[0]; - points[i][1] = e->next->vert->uv[1]; + points[i][0] = e->next->vert->uv[0]; + points[i][1] = e->next->vert->uv[1]; if (nexte == NULL) { i++; - points[i][0] = e->next->next->vert->uv[0]; - points[i][1] = e->next->next->vert->uv[1]; + points[i][0] = e->next->next->vert->uv[0]; + points[i][1] = e->next->next->vert->uv[1]; break; } e = nexte; i++; } while (e != v->edge); - + p_polygon_kernel_center(points, npoints, v->uv); MEM_freeN(points); @@ -1653,7 +1653,7 @@ static void p_vert_fix_edge_pointer(PVert *v) /* set v->edge pointer to the edge with no pair, if there is one */ while (v->edge->pair) { v->edge = p_wheel_edge_prev(v->edge); - + if (v->edge == start) break; } @@ -1699,7 +1699,7 @@ static void p_collapse_edge(PEdge *edge, PEdge *pair) else keepv->edge = pair->next->pair->next; } - + /* update pairs and v->edge pointers */ if (edge) { PEdge *e1 = edge->next, *e2 = e1->next; @@ -1821,7 +1821,7 @@ static PBool p_collapse_allowed_topologic(PEdge *edge, PEdge *pair) * the chart) */ else if (!p_vert_interior(oldv) && !p_vert_interior(keepv)) return P_FALSE; - + return P_TRUE; } @@ -1868,7 +1868,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair) if (p_collapse_normal_flipped(v1->co, v2->co, oldv->co, keepv->co)) return P_FALSE; - + a[0] = angle; a[1] = p_vec_angle(v2->co, v1->co, oldv->co); a[2] = M_PI - a[0] - a[1]; @@ -1903,7 +1903,7 @@ static PBool p_collapse_allowed_geometric(PEdge *edge, PEdge *pair) /* abf++ criterion 2: avoid collapsing verts inwards */ if (p_vert_interior(keepv)) return P_FALSE; - + /* don't collapse significant boundary changes */ angle = p_vec_angle(v1->co, oldv->co, v2->co); if (angle < (M_PI * 160.0 / 180.0)) @@ -1921,7 +1921,7 @@ static PBool p_collapse_allowed(PEdge *edge, PEdge *pair) if (oldv->flag & PVERT_PIN) return P_FALSE; - + return (p_collapse_allowed_topologic(edge, pair) && p_collapse_allowed_geometric(edge, pair)); } @@ -2010,7 +2010,7 @@ static float p_collapse_cost(PEdge *edge, PEdge *pair) return cost; } - + static void p_collapse_cost_vertex(PVert *vert, float *mincost, PEdge **mine) { PEdge *e, *enext, *pair; @@ -2172,7 +2172,7 @@ static void p_chart_simplify_compute(PChart *chart) for (v = chart->verts; v; v = v->nextlink) { float cost; PEdge *e = NULL; - + p_collapse_cost_vertex(v, &cost, &e); if (e) @@ -2237,7 +2237,7 @@ static void p_chart_simplify_compute(PChart *chart) BLI_heap_remove(heap, v->u.heaplink); v->u.heaplink = NULL; } - + p_collapse_cost_vertex(v, &cost, &collapse); if (collapse) @@ -2331,7 +2331,7 @@ static void p_abf_setup_system(PAbfSystem *sys) for (i = 0; i < sys->ninterior; i++) sys->lambdaLength[i] = 1.0; - + sys->minangle = 1.0 * M_PI / 180.0; sys->maxangle = (float)M_PI - sys->minangle; } @@ -2649,7 +2649,7 @@ static PBool p_abf_matrix_invert(PAbfSystem *sys, PChart *chart) dlambda1 = pre[0] + pre[1] + pre[2]; dlambda1 = sys->dstar[f->u.id] * (sys->bstar[f->u.id] - dlambda1); - + sys->lambdaTriangle[f->u.id] += dlambda1; dalpha = (sys->bAlpha[e1->u.id] - dlambda1); @@ -2914,7 +2914,7 @@ static PBool p_chart_symmetry_pins(PChart *chart, PEdge *outer, PVert **pin1, PV if (!maxe1 || !maxe2 || (maxlen < 0.5f * totlen)) return P_FALSE; - + /* find pin1 in the split vertices */ be1 = maxe1; be2 = maxe2; @@ -3212,7 +3212,7 @@ static void p_chart_lscm_end(PChart *chart) { if (chart->u.lscm.context) EIG_linear_solver_delete(chart->u.lscm.context); - + if (chart->u.lscm.abf_alpha) { MEM_freeN(chart->u.lscm.abf_alpha); chart->u.lscm.abf_alpha = NULL; @@ -3250,7 +3250,7 @@ static float p_face_stretch(PFace *f) if (area <= 0.0f) /* flipped face -> infinite stretch */ return 1e10f; - + w = 1.0f / (2.0f * area); /* compute derivatives */ @@ -3682,7 +3682,7 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f if (ntri <= 10 || depth >= 15) return node; - + t1 = MEM_mallocN(sizeof(*t1) * ntri, "PNodeTri1"); t2 = MEM_mallocN(sizeof(*t2) * ntri, "PNodeTri1"); @@ -3707,7 +3707,7 @@ static SmoothNode *p_node_new(MemArena *arena, SmoothTriangle **tri, int ntri, f MEM_freeN(t2); return node; } - + node->tri = NULL; node->ntri = 0; MEM_freeN(tri); @@ -3782,7 +3782,7 @@ static float p_smooth_median_edge_length(PChart *chart) /* ok, so i'm lazy */ for (i = 0, e = chart->edges; e; e = e->nextlink, i++) lengths[i] = p_edge_length(e); - + qsort(lengths, i, sizeof(float), p_compare_float); median = lengths[i / 2]; @@ -3876,7 +3876,7 @@ static void p_smooth(PChart *chart) if ((gridx <= 2) || (gridy <= 2)) return; - + edgesx = gridx - 1; edgesy = gridy - 1; nsize = gridx * gridy; @@ -3936,7 +3936,7 @@ static void p_smooth(PChart *chart) float p[2], b[3]; i = x + y * gridx; - + p[0] = nodesx[i]; p[1] = nodesy[i]; @@ -3979,7 +3979,7 @@ static void p_smooth(PChart *chart) for (it2 = 0; it2 < maxiter2; it2++) { d = 0.0f; totiter += 1; - + memcpy(oldnodesx, nodesx, sizeof(float) * nsize); memcpy(oldnodesy, nodesy, sizeof(float) * nsize); @@ -4011,7 +4011,7 @@ static void p_smooth(PChart *chart) sum1 += vedges[j] * oldnodesy[i + gridx]; nodesy[i] = sum1 / sum2; - + p[0] = nodesx[i]; p[1] = nodesy[i]; @@ -4089,8 +4089,8 @@ static void p_smooth(PChart *chart) t2->co3[0] = t->co3[0]; t2->co3[1] = t->co3[1]; t2->oco3[0] = t->oco3[0]; t2->oco3[1] = t->oco3[1]; - *trip = t; trip++; t++; - *trip = t; trip++; t++; + *trip = t; trip++; t++; + *trip = t; trip++; t++; } } @@ -4107,7 +4107,7 @@ static void p_smooth(PChart *chart) p_node_delete(root); BLI_memarena_free(arena); - + MEM_freeN(triangles); } @@ -4149,7 +4149,7 @@ void param_delete(ParamHandle *handle) for (i = 0; i < phandle->ncharts; i++) p_chart_delete(phandle->charts[i]); - + if (phandle->charts) MEM_freeN(phandle->charts); @@ -4496,24 +4496,24 @@ static void param_pack_rotate(ParamHandle *handle) } void param_pack(ParamHandle *handle, float margin, bool do_rotate) -{ +{ /* box packing variables */ BoxPack *boxarray, *box; float tot_width, tot_height, scale; - + PChart *chart; int i, unpacked = 0; float trans[2]; double area = 0.0; - + PHandle *phandle = (PHandle *)handle; - + if (phandle->ncharts == 0) return; - + if (phandle->aspx != phandle->aspy) param_scale(handle, 1.0f / phandle->aspx, 1.0f / phandle->aspy); - + /* this could be its own function */ if (do_rotate) { param_pack_rotate(handle); @@ -4521,33 +4521,33 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate) /* we may not use all these boxes */ boxarray = MEM_mallocN(phandle->ncharts * sizeof(BoxPack), "BoxPack box"); - - + + for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; - + if (chart->flag & PCHART_NOPACK) { unpacked++; continue; } - + box = boxarray + (i - unpacked); - + p_chart_uv_bbox(chart, trans, chart->u.pack.size); - + trans[0] = -trans[0]; trans[1] = -trans[1]; - + p_chart_uv_translate(chart, trans); - + box->w = chart->u.pack.size[0] + trans[0]; box->h = chart->u.pack.size[1] + trans[1]; box->index = i; /* warning this index skips PCHART_NOPACK boxes */ - + if (margin > 0.0f) area += (double)sqrtf(box->w * box->h); } - + if (margin > 0.0f) { /* multiply the margin by the area to give predictable results not dependent on UV scale, * ...Without using the area running pack multiple times also gives a bad feedback loop. @@ -4556,12 +4556,12 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate) unpacked = 0; for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; - + if (chart->flag & PCHART_NOPACK) { unpacked++; continue; } - + box = boxarray + (i - unpacked); trans[0] = margin; trans[1] = margin; @@ -4570,19 +4570,19 @@ void param_pack(ParamHandle *handle, float margin, bool do_rotate) box->h += margin * 2; } } - + BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height); - + if (tot_height > tot_width) scale = 1.0f / tot_height; else scale = 1.0f / tot_width; - + for (i = 0; i < phandle->ncharts - unpacked; i++) { box = boxarray + i; trans[0] = box->x; trans[1] = box->y; - + chart = phandle->charts[box->index]; p_chart_uv_translate(chart, trans); p_chart_uv_scale(chart, scale); @@ -4601,54 +4601,54 @@ void param_average(ParamHandle *handle) float tot_fac, fac; float minv[2], maxv[2], trans[2]; PHandle *phandle = (PHandle *)handle; - + if (phandle->ncharts == 0) return; - + for (i = 0; i < phandle->ncharts; i++) { PFace *f; chart = phandle->charts[i]; if (chart->flag & PCHART_NOPACK) continue; - + chart->u.pack.area = 0.0f; /* 3d area */ chart->u.pack.rescale = 0.0f; /* UV area, abusing rescale for tmp storage, oh well :/ */ - + for (f = chart->faces; f; f = f->nextlink) { chart->u.pack.area += p_face_area(f); chart->u.pack.rescale += fabsf(p_face_uv_area_signed(f)); } - + tot_facearea += chart->u.pack.area; tot_uvarea += chart->u.pack.rescale; } - + if (tot_facearea == tot_uvarea || tot_facearea == 0.0f || tot_uvarea == 0.0f) { /* nothing to do */ return; } - + tot_fac = tot_facearea / tot_uvarea; - + for (i = 0; i < phandle->ncharts; i++) { chart = phandle->charts[i]; if (chart->flag & PCHART_NOPACK) continue; - + if (chart->u.pack.area != 0.0f && chart->u.pack.rescale != 0.0f) { fac = chart->u.pack.area / chart->u.pack.rescale; - + /* Get the island center */ p_chart_uv_bbox(chart, minv, maxv); trans[0] = (minv[0] + maxv[0]) / -2.0f; trans[1] = (minv[1] + maxv[1]) / -2.0f; - + /* Move center to 0,0 */ p_chart_uv_translate(chart, trans); p_chart_uv_scale(chart, sqrtf(fac / tot_fac)); - + /* Move to original center */ trans[0] = -trans[0]; trans[1] = -trans[1]; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h index 4322a3f7dfc..50b4ee66644 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.h +++ b/source/blender/editors/uvedit/uvedit_parametrizer.h @@ -30,7 +30,7 @@ #ifdef __cplusplus extern "C" { #endif - + #include "BLI_sys_types.h" // for intptr_t support typedef void ParamHandle; /* handle to a set of charts */ diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 057417b898f..e4452af4790 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -2265,7 +2265,7 @@ void UV_OT_stitch(wmOperatorType *ot) ot->description = "Stitch selected UV vertices by proximity"; ot->idname = "UV_OT_stitch"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->invoke = stitch_invoke; ot->modal = stitch_modal; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index bc38a1cd3bb..dbe8796ba8b 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -145,10 +145,10 @@ static bool ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) } } } - + if (ima) ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL); - + /* select new UV's (ignore UV_SYNC_SELECTION in this case) */ BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { BMIter liter; @@ -171,7 +171,7 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit) BMLoop *l; BMIter iter, liter; const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - + if (cd_loop_uv_offset == -1) { return (em->bm->totfacesel != 0); } @@ -185,15 +185,15 @@ static bool uvedit_have_selection(Scene *scene, BMEditMesh *em, bool implicit) } else if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) break; } - + if (implicit && !l) continue; - + return true; } @@ -267,7 +267,7 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm, BMEdge *eed; BMIter iter, liter; int i; - + const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV); handle = param_construct_begin(); @@ -280,10 +280,10 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm, if (aspx != aspy) param_aspect_ratio(handle, aspx, aspy); } - + /* we need the vert indices */ BM_mesh_elem_index_ensure(bm, BM_VERT); - + BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) { if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) { @@ -401,7 +401,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B smd.levels = smd_real->levels; smd.subdivType = smd_real->subdivType; - + initialDerived = CDDM_from_editbmesh(em, false, false); derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, NULL, SUBSURF_IN_EDIT_MODE); @@ -470,7 +470,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B co[1] = subsurfedVerts[mloop[1].v].co; co[2] = subsurfedVerts[mloop[2].v].co; co[3] = subsurfedVerts[mloop[3].v].co; - + /* This is where all the magic is done. If the vertex exists in the, we pass the original uv pointer to the solver, thus * flushing the solution to the edit mesh. */ texface_from_original_index(origFace, origVertIndices[mloop[0].v], &uv[0], &pin[0], &select[0], scene, cd_loop_uv_offset); @@ -698,7 +698,7 @@ void UV_OT_minimize_stretch(wmOperatorType *ot) ot->idname = "UV_OT_minimize_stretch"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING; ot->description = "Reduce UV stretching by relaxing angles"; - + /* api callbacks */ ot->exec = minimize_stretch_exec; ot->invoke = minimize_stretch_invoke; @@ -740,7 +740,7 @@ static int pack_islands_exec(bContext *C, wmOperator *op) RNA_float_set(op->ptr, "margin", scene->toolsettings->uvcalc_margin); ED_uvedit_pack_islands(scene, obedit, em->bm, true, true, do_rotate); - + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -755,7 +755,7 @@ void UV_OT_pack_islands(wmOperatorType *ot) ot->description = "Transform all islands so that they fill up the UV space as much as possible"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = pack_islands_exec; ot->poll = ED_operator_uvedit; @@ -783,7 +783,7 @@ static int average_islands_scale_exec(bContext *C, wmOperator *UNUSED(op)) param_average(handle); param_flush(handle); param_delete(handle); - + DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -798,7 +798,7 @@ void UV_OT_average_islands_scale(wmOperatorType *ot) ot->description = "Average the size of separate UV islands, based on their area in 3D space"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = average_islands_scale_exec; ot->poll = ED_operator_uvedit; @@ -836,7 +836,7 @@ void ED_uvedit_live_unwrap_re_solve(void) param_flush(liveHandle); } } - + void ED_uvedit_live_unwrap_end(short cancel) { if (liveHandle) { @@ -1025,7 +1025,7 @@ static void uv_map_transform(bContext *C, wmOperator *op, float rotmat[4][4]) /* be compatible to the "old" sphere/cylinder mode */ if (direction == ALIGN_TO_OBJECT) unit_m4(rotmat); - else + else uv_map_rotation_matrix(rotmat, rv3d, obedit, upangledeg, sideangledeg, radius); } @@ -1060,21 +1060,21 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em) MLoopUV *luv; BMFace *efa; float scale, aspx, aspy; - + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); ED_uvedit_get_aspect(scene, ob, em->bm, &aspx, &aspy); - + if (aspx == aspy) return; - + if (aspx > aspy) { scale = aspy / aspx; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv->uv[0] = ((luv->uv[0] - 0.5f) * scale) + 0.5f; @@ -1087,7 +1087,7 @@ static void correct_uv_aspect(Scene *scene, Object *ob, BMEditMesh *em) BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; - + BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv->uv[1] = ((luv->uv[1] - 0.5f) * scale) + 0.5f; @@ -1221,7 +1221,7 @@ static int unwrap_exec(bContext *C, wmOperator *op) if (!uvedit_have_selection(scene, em, implicit)) { return OPERATOR_CANCELLED; } - + /* add uvs if they don't exist yet */ if (!ED_uvedit_ensure_uvs(C, scene, obedit)) { return OPERATOR_CANCELLED; @@ -1284,7 +1284,7 @@ void UV_OT_unwrap(wmOperatorType *ot) ot->description = "Unwrap the mesh of the object being edited"; ot->idname = "UV_OT_unwrap"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = unwrap_exec; ot->poll = ED_operator_uvmap; @@ -1345,7 +1345,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "orthographic")) { uv_map_rotation_matrix(rotmat, rv3d, obedit, 90.0f, 0.0f, 1.0f); - + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { if (!BM_elem_flag_test(efa, BM_ELEM_SELECT)) continue; @@ -1372,7 +1372,7 @@ static int uv_from_view_exec(bContext *C, wmOperator *op) BLI_uvproject_from_camera(luv->uv, l->v->co, uci); } } - + MEM_freeN(uci); } } @@ -1416,7 +1416,7 @@ void UV_OT_project_from_view(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh as seen in current 3D view"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->invoke = uv_from_view_invoke; ot->exec = uv_from_view_exec; @@ -1447,7 +1447,7 @@ static int reset_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); - + return OPERATOR_FINISHED; } @@ -1459,7 +1459,7 @@ void UV_OT_reset(wmOperatorType *ot) ot->description = "Reset UV projection"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = reset_exec; ot->poll = ED_operator_uvmap; @@ -1478,7 +1478,7 @@ static void uv_sphere_project(float target[2], float source[3], float center[3], /* split line is always zero */ if (target[0] >= 1.0f) - target[0] -= 1.0f; + target[0] -= 1.0f; } static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf)) @@ -1565,7 +1565,7 @@ void UV_OT_sphere_project(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh over the curved surface of a sphere"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = sphere_project_exec; ot->poll = ED_operator_uvmap; @@ -1588,7 +1588,7 @@ static void uv_cylinder_project(float target[2], float source[3], float center[3 /* split line is always zero */ if (target[0] >= 1.0f) - target[0] -= 1.0f; + target[0] -= 1.0f; } static int cylinder_project_exec(bContext *C, wmOperator *op) @@ -1646,7 +1646,7 @@ void UV_OT_cylinder_project(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh over the curved wall of a cylinder"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = cylinder_project_exec; ot->poll = ED_operator_uvmap; @@ -1747,7 +1747,7 @@ void UV_OT_cube_project(wmOperatorType *ot) ot->description = "Project the UV vertices of the mesh over the six faces of a cube"; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - + /* api callbacks */ ot->exec = cube_project_exec; ot->poll = ED_operator_uvmap; -- cgit v1.2.3