[Bf-blender-cvs] [328772f2d90] master: Mesh: Add operator to flip quad tessellation

2023-01-27 Thread Colin Basnett
Commit: 328772f2d90ec7f98cf724dd832a1c211bb4b5eb
Author: Colin Basnett
Date:   Fri Jan 27 11:00:36 2023 -0800
Branches: master
https://developer.blender.org/rB328772f2d90ec7f98cf724dd832a1c211bb4b5eb

Mesh: Add operator to flip quad tessellation

This adds a new operator: bpy.ops.mesh.flip_quad_tessellation()

This operator rotates the internal loops of the selected quads, allowing
the user to control tessellation without destructively altering the
mesh.

{F14201995}

This operator can be found in the "Face" menu (Ctrl+F) under "Face
Data".

{F14201997}

Reviewed By: campbellbarton, dbystedt

Differential Revision: https://developer.blender.org/D17056

===

M   release/scripts/startup/bl_ui/space_view3d.py
M   source/blender/bmesh/intern/bmesh_opdefines.c
M   source/blender/bmesh/intern/bmesh_operators_private.h
M   source/blender/bmesh/intern/bmesh_polygon.h
M   source/blender/bmesh/operators/bmo_utils.c
M   source/blender/editors/mesh/editmesh_tools.c
M   source/blender/editors/mesh/mesh_intern.h
M   source/blender/editors/mesh/mesh_ops.c

===

diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index c66acb0509f..cccb5389037 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -4274,7 +4274,10 @@ class VIEW3D_MT_edit_mesh_faces_data(Menu):
 
 layout.separator()
 
+layout.operator("mesh.flip_quad_tessellation")
+
 if with_freestyle:
+layout.separator()
 layout.operator("mesh.mark_freestyle_face").clear = False
 layout.operator("mesh.mark_freestyle_face", text="Clear Freestyle 
Face").clear = True
 
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c 
b/source/blender/bmesh/intern/bmesh_opdefines.c
index 0ffb3f6652e..4e0df875740 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -270,6 +270,23 @@ static BMOpDefine bmo_reverse_faces_def = {
BMO_OPTYPE_FLAG_NORMALS_CALC),
 };
 
+/*
+ * Flip Quad Tessellation
+ *
+ * Flip the tessellation direction of the selected quads.
+*/
+static BMOpDefine bmo_flip_quad_tessellation_def = {
+  "flip_quad_tessellation",
+  /* slot_in */
+  {
+{"faces", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}},
+{{'\0'}}
+  },
+  {{{'\0'}}}, /* no output */
+  bmo_flip_quad_tessellation_exec,
+  (BMO_OPTYPE_FLAG_UNTAN_MULTIRES | BMO_OPTYPE_FLAG_NORMALS_CALC),
+};
+
 /*
  * Edge Bisect.
  *
@@ -2128,6 +2145,7 @@ const BMOpDefine *bmo_opdefines[] = {
 _extrude_face_region_def,
 _extrude_vert_indiv_def,
 _find_doubles_def,
+_flip_quad_tessellation_def,
 _grid_fill_def,
 _inset_individual_def,
 _inset_region_def,
diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h 
b/source/blender/bmesh/intern/bmesh_operators_private.h
index 0f628c04d98..3562b4da71a 100644
--- a/source/blender/bmesh/intern/bmesh_operators_private.h
+++ b/source/blender/bmesh/intern/bmesh_operators_private.h
@@ -88,3 +88,4 @@ void bmo_triangulate_exec(BMesh *bm, BMOperator *op);
 void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op);
 void bmo_weld_verts_exec(BMesh *bm, BMOperator *op);
 void bmo_wireframe_exec(BMesh *bm, BMOperator *op);
+void bmo_flip_quad_tessellation_exec(BMesh *bm, BMOperator *op);
diff --git a/source/blender/bmesh/intern/bmesh_polygon.h 
b/source/blender/bmesh/intern/bmesh_polygon.h
index bff1d1d587d..5ca7c3bafaf 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.h
+++ b/source/blender/bmesh/intern/bmesh_polygon.h
@@ -177,6 +177,7 @@ void BM_face_normal_flip_ex(BMesh *bm,
 int cd_loop_mdisp_offset,
 bool use_loop_mdisp_flip) ATTR_NONNULL();
 void BM_face_normal_flip(BMesh *bm, BMFace *f) ATTR_NONNULL();
+
 /**
  * BM POINT IN FACE
  *
diff --git a/source/blender/bmesh/operators/bmo_utils.c 
b/source/blender/bmesh/operators/bmo_utils.c
index a821fa2b744..8d4ba5c11f8 100644
--- a/source/blender/bmesh/operators/bmo_utils.c
+++ b/source/blender/bmesh/operators/bmo_utils.c
@@ -147,6 +147,22 @@ void bmo_reverse_faces_exec(BMesh *bm, BMOperator *op)
 #define SEL_FLAG 1
 #define SEL_ORIG 2
 
+void bmo_flip_quad_tessellation_exec(BMesh *bm, BMOperator *op)
+{
+  BMOIter siter;
+  BMFace *f;
+  bool changed = false;
+  BMO_ITER (f, , op->slots_in, "faces", BM_FACE) {
+if (f->len == 4) {
+  f->l_first = f->l_first->next;
+  changed = true;
+}
+  }
+  if (changed) {
+bm->elem_index_dirty |= BM_LOOP;
+  }
+}
+
 static void bmo_face_flag_set_flush(BMesh *bm, BMFace *f, const short oflag, 
const bool value)
 {
   BMLoop *l_iter;
diff --git a/source/blender/editors/mesh/editmesh_tools.

[Bf-blender-cvs] [39c6953462d] master: UI: Fix alignment of custom properties edit & remove buttons

2023-01-16 Thread Colin Basnett
Commit: 39c6953462d9652ad54952100dc83a32e925553d
Author: Colin Basnett
Date:   Mon Jan 16 12:54:25 2023 -0800
Branches: master
https://developer.blender.org/rB39c6953462d9652ad54952100dc83a32e925553d

UI: Fix alignment of custom properties edit & remove buttons

This fixes the UI alignment issues that were introduced by {D12815} with the 
addition of the boolean custom properties.

Reviewed By: HooglyBoogly

Differential Revision: https://developer.blender.org/D17012

===

M   release/scripts/modules/rna_prop_ui.py

===

diff --git a/release/scripts/modules/rna_prop_ui.py 
b/release/scripts/modules/rna_prop_ui.py
index f6c01bde9cd..8b889d8ca4b 100644
--- a/release/scripts/modules/rna_prop_ui.py
+++ b/release/scripts/modules/rna_prop_ui.py
@@ -181,6 +181,7 @@ def draw(layout, context, context_member, property_type, *, 
use_edit=True):
 value_column.prop(rna_item, '["%s"]' % escape_identifier(key), 
text="")
 
 operator_row = value_row.row()
+operator_row.alignment = 'RIGHT'
 
 # Do not allow editing of overridden properties (we cannot use a poll 
function
 # of the operators here since they's have no access to the specific 
property).

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c47b6978e32] master: Animation: Make Bake Animation operator use preview range when enabled

2022-11-28 Thread Colin Basnett
Commit: c47b6978e327c654109f78cea4935a577010bad1
Author: Colin Basnett
Date:   Mon Nov 28 08:04:02 2022 -0800
Branches: master
https://developer.blender.org/rBc47b6978e327c654109f78cea4935a577010bad1

Animation: Make Bake Animation operator use preview range when enabled

This patch makes the Bake Actions operator fills the Start Frame & End From 
with that of the Preview Range if "Use Preview Range" is enabled.

{F13973619}

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16630

===

M   release/scripts/startup/bl_operators/anim.py

===

diff --git a/release/scripts/startup/bl_operators/anim.py 
b/release/scripts/startup/bl_operators/anim.py
index 0f4c6c4b9c3..1c92ee81345 100644
--- a/release/scripts/startup/bl_operators/anim.py
+++ b/release/scripts/startup/bl_operators/anim.py
@@ -282,8 +282,12 @@ class NLA_OT_bake(Operator):
 
 def invoke(self, context, _event):
 scene = context.scene
-self.frame_start = scene.frame_start
-self.frame_end = scene.frame_end
+if scene.use_preview_range:
+self.frame_start = scene.frame_preview_start
+self.frame_end = scene.frame_preview_end
+else:
+self.frame_start = scene.frame_start
+self.frame_end = scene.frame_end
 self.bake_types = {'POSE'} if context.mode == 'POSE' else {'OBJECT'}
 
 wm = context.window_manager

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [58c8c4fde35] master: Animation: Improve performance of Bake Action operator

2022-11-24 Thread Colin Basnett
Commit: 58c8c4fde35c158407ca2ba0c0bc099d1455f691
Author: Colin Basnett
Date:   Thu Nov 24 11:26:17 2022 -0800
Branches: master
https://developer.blender.org/rB58c8c4fde35c158407ca2ba0c0bc099d1455f691

Animation: Improve performance of Bake Action operator

This dramatically improves baking performance by batch-adding keyframes
instead of adding them individually, reducing unnecessary overhead.

Testing indicates an approximate 4x performance uplift.

Reviewed By: sybren, RiggingDojo

Differential Revision: https://developer.blender.org/D8808

===

M   release/scripts/modules/bpy_extras/anim_utils.py

===

diff --git a/release/scripts/modules/bpy_extras/anim_utils.py 
b/release/scripts/modules/bpy_extras/anim_utils.py
index f66dfd6eb0a..7bc9125a767 100644
--- a/release/scripts/modules/bpy_extras/anim_utils.py
+++ b/release/scripts/modules/bpy_extras/anim_utils.py
@@ -9,7 +9,13 @@ __all__ = (
 )
 
 import bpy
+from typing import  Mapping, List, Tuple, Sequence
 
+# (fcurve.data_path, fcurve.array_index)
+FCurveKey = Tuple[str, int]
+# [frame0, value0, frame1, value1, ...]
+ListKeyframes = List[float]
+Action = bpy.types.Action
 
 def bake_action(
 obj,
@@ -143,6 +149,18 @@ def bake_action_iter(
 'bbone_scalein', 'bbone_scaleout',
 'bbone_easein', 'bbone_easeout'
 ]
+BBONE_PROPS_LENGTHS = {
+"bbone_curveinx": 1,
+"bbone_curveoutx": 1,
+"bbone_curveinz": 1,
+"bbone_curveoutz": 1,
+"bbone_rollin": 1,
+"bbone_rollout": 1,
+"bbone_scalein": 3,
+"bbone_scaleout": 3,
+"bbone_easein": 1,
+"bbone_easeout": 1,
+}
 
 def pose_frame_info(obj):
 matrix = {}
@@ -225,7 +243,8 @@ def bake_action_iter(
 
 # in case animation data hasn't been created
 atd = obj.animation_data_create()
-if action is None:
+is_new_action = action is None
+if is_new_action:
 action = bpy.data.actions.new("Action")
 
 # Only leave tweak mode if we actually need to modify the action (T57159)
@@ -244,6 +263,7 @@ def bake_action_iter(
 # Apply transformations to action
 
 # pose
+lookup_fcurves = {(fcurve.data_path, fcurve.array_index): fcurve for 
fcurve in action.fcurves}
 if do_pose:
 for name, pbone in obj.pose.bones.items():
 if only_selected and not pbone.bone.select:
@@ -257,12 +277,32 @@ def bake_action_iter(
 euler_prev = None
 quat_prev = None
 
+base_fcurve_path = pbone.path_from_id() + "."
+path_location = base_fcurve_path + "location"
+path_quaternion = base_fcurve_path + "rotation_quaternion"
+path_axis_angle = base_fcurve_path + "rotation_axis_angle"
+path_euler = base_fcurve_path + "rotation_euler"
+path_scale = base_fcurve_path + "scale"
+paths_bbprops = [(base_fcurve_path + bbprop) for bbprop in 
BBONE_PROPS]
+
+keyframes = KeyframesCo()
+keyframes.add_paths(path_location, 3)
+keyframes.add_paths(path_quaternion, 4)
+keyframes.add_paths(path_axis_angle, 4)
+keyframes.add_paths(path_euler, 3)
+keyframes.add_paths(path_scale, 3)
+
+if pbone.bone.bbone_segments > 1:
+for prop_name, path in zip(BBONE_PROPS, paths_bbprops):
+keyframes.add_paths(path, BBONE_PROPS_LENGTHS[prop_name])
+
+rotation_mode = pbone.rotation_mode
+total_new_keys = len(pose_info)
 for (f, matrix, bbones) in pose_info:
 pbone.matrix_basis = matrix[name].copy()
 
-pbone.keyframe_insert("location", index=-1, frame=f, 
group=name)
+keyframes.extend_co_values(path_location, 3, f, pbone.location)
 
-rotation_mode = pbone.rotation_mode
 if rotation_mode == 'QUATERNION':
 if quat_prev is not None:
 quat = pbone.rotation_quaternion.copy()
@@ -272,26 +312,37 @@ def bake_action_iter(
 del quat
 else:
 quat_prev = pbone.rotation_quaternion.copy()
-pbone.keyframe_insert("rotation_quaternion", index=-1, 
frame=f, group=name)
+keyframes.extend_co_values(path_quaternion, 4, f, 
pbone.rotation_quaternion)
 elif rotation_mode == 'AXIS_ANGLE':
-pbone.keyframe_insert("rotation_axis_angle", index=-1, 
frame=f, group=name)
+keyframes.extend_co_values(path_axis_angle, 4, f, 
pbone.rotat

[Bf-blender-cvs] [cdcbf05ea88] master: BLI: Make Report Missing Files display message when no files are missing

2022-11-22 Thread Colin Basnett
Commit: cdcbf05ea884978c23e38912edda93b15dd0949c
Author: Colin Basnett
Date:   Tue Nov 22 16:44:57 2022 -0800
Branches: master
https://developer.blender.org/rBcdcbf05ea884978c23e38912edda93b15dd0949c

BLI: Make Report Missing Files display message when no files are missing

Before this, if there were no missing files, the operator would run
successfully but there would be no user feedback at all, making the
user wonder if the operator was even run.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D16585

===

M   source/blender/blenkernel/intern/bpath.c

===

diff --git a/source/blender/blenkernel/intern/bpath.c 
b/source/blender/blenkernel/intern/bpath.c
index 61893ca25ed..95d6121fc13 100644
--- a/source/blender/blenkernel/intern/bpath.c
+++ b/source/blender/blenkernel/intern/bpath.c
@@ -236,6 +236,10 @@ void BKE_bpath_missing_files_check(Main *bmain, ReportList 
*reports)
   .flag = BKE_BPATH_FOREACH_PATH_ABSOLUTE | 
BKE_BPATH_FOREACH_PATH_SKIP_PACKED |
   BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN | 
BKE_BPATH_TRAVERSE_SKIP_WEAK_REFERENCES,
   .user_data = reports});
+
+  if (BLI_listbase_is_empty(>list)) {
+BKE_reportf(reports, RPT_INFO, "No missing files");
+  }
 }
 
 /** \} */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4dd19a1ad60] master: UI: disable curve map & profile zoom buttons at max/min zoom level

2022-11-14 Thread Colin Basnett
Commit: 4dd19a1ad60e9bb390a155cdd90bbed8002f0324
Author: Colin Basnett
Date:   Mon Nov 14 13:11:18 2022 +0100
Branches: master
https://developer.blender.org/rB4dd19a1ad60e9bb390a155cdd90bbed8002f0324

UI: disable curve map & profile zoom buttons at max/min zoom level

Disable the zoom in and out buttons on the when they would have no effect.

This also removes an incorrect comment that indicates the maximum zoom level
was 20x when in fact it was 25x.

Differential Revision: https://developer.blender.org/D16252

===

M   source/blender/editors/interface/interface_templates.c

===

diff --git a/source/blender/editors/interface/interface_templates.c 
b/source/blender/editors/interface/interface_templates.c
index b32aa82ad9e..94abfe54328 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -4122,12 +4122,23 @@ void uiTemplateVectorscope(uiLayout *layout, PointerRNA 
*ptr, const char *propna
 /** \name CurveMapping Template
  * \{ */
 
+#define CURVE_ZOOM_MAX (1.0f / 25.0f)
+
+static bool curvemap_can_zoom_out(CurveMapping *cumap)
+{
+  return BLI_rctf_size_x(>curr) < BLI_rctf_size_x(>clipr);
+}
+
+static bool curvemap_can_zoom_in(CurveMapping *cumap)
+{
+  return BLI_rctf_size_x(>curr) > CURVE_ZOOM_MAX * 
BLI_rctf_size_x(>clipr);
+}
+
 static void curvemap_buttons_zoom_in(bContext *C, void *cumap_v, void 
*UNUSED(arg))
 {
   CurveMapping *cumap = cumap_v;
 
-  /* we allow 20 times zoom */
-  if (BLI_rctf_size_x(>curr) > 0.04f * BLI_rctf_size_x(>clipr)) {
+  if (curvemap_can_zoom_in(cumap)) {
 const float dx = 0.1154f * BLI_rctf_size_x(>curr);
 cumap->curr.xmin += dx;
 cumap->curr.xmax -= dx;
@@ -4144,8 +4155,7 @@ static void curvemap_buttons_zoom_out(bContext *C, void 
*cumap_v, void *UNUSED(u
   CurveMapping *cumap = cumap_v;
   float d, d1;
 
-  /* we allow 20 times zoom, but don't view outside clip */
-  if (BLI_rctf_size_x(>curr) < 20.0f * BLI_rctf_size_x(>clipr)) {
+  if (curvemap_can_zoom_out(cumap)) {
 d = d1 = 0.15f * BLI_rctf_size_x(>curr);
 
 if (cumap->flag & CUMA_DO_CLIP) {
@@ -4633,6 +4643,9 @@ static void curvemap_buttons_layout(uiLayout *layout,
 0.0,
 TIP_("Zoom in"));
   UI_but_func_set(bt, curvemap_buttons_zoom_in, cumap, NULL);
+  if (!curvemap_can_zoom_in(cumap)) {
+UI_but_disable(bt, "");
+  }
 
   /* Zoom out */
   bt = uiDefIconBut(block,
@@ -4650,8 +4663,11 @@ static void curvemap_buttons_layout(uiLayout *layout,
 0.0,
 TIP_("Zoom out"));
   UI_but_func_set(bt, curvemap_buttons_zoom_out, cumap, NULL);
+  if (!curvemap_can_zoom_out(cumap)) {
+UI_but_disable(bt, "");
+  }
 
-  /* Clippoing button. */
+  /* Clipping button. */
   const int icon = (cumap->flag & CUMA_DO_CLIP) ? ICON_CLIPUV_HLT : 
ICON_CLIPUV_DEHLT;
   bt = uiDefIconBlockBut(
   block, curvemap_clipping_func, cumap, 0, icon, 0, 0, dx, dx, 
TIP_("Clipping Options"));
@@ -5080,12 +5096,21 @@ static uiBlock *CurveProfile_buttons_tools(bContext *C, 
ARegion *region, void *p
   return CurveProfile_tools_func(C, region, (CurveProfile *)profile_v);
 }
 
+static bool CurveProfile_can_zoom_in(CurveProfile *profile)
+{
+  return BLI_rctf_size_x(>view_rect) > CURVE_ZOOM_MAX * 
BLI_rctf_size_x(>clip_rect);
+}
+
+static bool CurveProfile_can_zoom_out(CurveProfile *profile)
+{
+  return BLI_rctf_size_x(>view_rect) < 
BLI_rctf_size_x(>clip_rect);
+}
+
 static void CurveProfile_buttons_zoom_in(bContext *C, void *profile_v, void 
*UNUSED(arg))
 {
   CurveProfile *profile = profile_v;
 
-  /* Allow a 20x zoom. */
-  if (BLI_rctf_size_x(>view_rect) > 0.04f * 
BLI_rctf_size_x(>clip_rect)) {
+  if (CurveProfile_can_zoom_in(profile)) {
 const float dx = 0.1154f * BLI_rctf_size_x(>view_rect);
 profile->view_rect.xmin += dx;
 profile->view_rect.xmax -= dx;
@@ -5101,8 +5126,7 @@ static void CurveProfile_buttons_zoom_out(bContext *C, 
void *profile_v, void *UN
 {
   CurveProfile *profile = profile_v;
 
-  /* Allow 20 times zoom, but don't view outside clip */
-  if (BLI_rctf_size_x(>view_rect) < 20.0f * 
BLI_rctf_size_x(>clip_rect)) {
+  if (CurveProfile_can_zoom_out(profile)) {
 float d = 0.15f * BLI_rctf_size_x(>view_rect);
 float d1 = d;
 
@@ -5250,6 +5274,9 @@ static void CurveProfile_buttons_layout(uiLayout *layout, 
PointerRNA *ptr, RNAUp
 0.0,
 TIP_("Zoom in"));
   UI_but_func_set(bt, CurveProfile_buttons_zoom_in, profile, NULL);
+  if (!CurveProfile_can_zoom_in(profile)) {
+UI_but_disable(bt, "");
+  }
 
   /* Zoom out */
   bt = uiDefIconBut(block,
@@ -526

[Bf-blender-cvs] [1fdaf748bf4] master: Add poll messages for marker operators

2022-11-11 Thread Colin Basnett
Commit: 1fdaf748bf4a6b65465602aefa36868e69b4c30f
Author: Colin Basnett
Date:   Fri Nov 11 11:13:00 2022 -0800
Branches: master
https://developer.blender.org/rB1fdaf748bf4a6b65465602aefa36868e69b4c30f

Add poll messages for marker operators

A number of operators were missing poll messages when disabled.

These are the following new error messages:

1. "No markers are selected"
2. "Markers are locked"

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16403

===

M   source/blender/editors/animation/anim_markers.c

===

diff --git a/source/blender/editors/animation/anim_markers.c 
b/source/blender/editors/animation/anim_markers.c
index 94746837259..c980fd73342 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -663,11 +663,16 @@ static bool ed_markers_poll_selected_markers(bContext *C)
   ListBase *markers = ED_context_get_markers(C);
 
   if (!ED_operator_markers_region_active(C)) {
-return 0;
+return false;
   }
 
   /* check if some marker is selected */
-  return ED_markers_get_first_selected(markers) != NULL;
+  if (ED_markers_get_first_selected(markers) == NULL) {
+CTX_wm_operator_poll_msg_set(C, "No markers are selected");
+return false;
+  }
+
+  return true;
 }
 
 static bool ed_markers_poll_selected_no_locked_markers(bContext *C)
@@ -675,12 +680,22 @@ static bool 
ed_markers_poll_selected_no_locked_markers(bContext *C)
   ListBase *markers = ED_context_get_markers(C);
   ToolSettings *ts = CTX_data_tool_settings(C);
 
-  if (ts->lock_markers || !ED_operator_markers_region_active(C)) {
-return 0;
+  if (!ED_operator_markers_region_active(C)) {
+return false;
+  }
+
+  if (ts->lock_markers) {
+CTX_wm_operator_poll_msg_set(C, "Markers are locked");
+return false;
   }
 
   /* check if some marker is selected */
-  return ED_markers_get_first_selected(markers) != NULL;
+  if (ED_markers_get_first_selected(markers) == NULL) {
+CTX_wm_operator_poll_msg_set(C, "No markers are selected");
+return false;
+  }
+
+  return true;
 }
 
 /* special poll() which checks if there are any markers at all first */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5671e7a92c3] master: Cleanup: Fixing anti-patterns in fcurve.c

2022-11-11 Thread Colin Basnett
Commit: 5671e7a92c397e3558f346cc2796da452f016b17
Author: Colin Basnett
Date:   Fri Nov 11 11:07:30 2022 -0800
Branches: master
https://developer.blender.org/rB5671e7a92c397e3558f346cc2796da452f016b17

Cleanup: Fixing anti-patterns in fcurve.c

This is a clean-up pass that eliminates a few problematic patterns:

* Eliminating redundant parentheses around simple expressions.
* Combing declaration and assignment of variables where appropriate.
* Moving variable declarations closer to their first use.
* Many variables and arguments have been marked as `const`.
* Using `LISTBASE_FOREACH_*` variants where applicable instead of
  manually managing loop control flow.

There are no functional changes.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16459

===

M   source/blender/blenkernel/intern/fcurve.c

===

diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index aa99a5f605a..3e772e37177 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -85,8 +85,6 @@ void BKE_fcurve_free(FCurve *fcu)
 
 void BKE_fcurves_free(ListBase *list)
 {
-  FCurve *fcu, *fcn;
-
   /* Sanity check. */
   if (list == NULL) {
 return;
@@ -96,7 +94,8 @@ void BKE_fcurves_free(ListBase *list)
* as we store reference to next, and freeing only touches the curve
* it's given.
*/
-  for (fcu = list->first; fcu; fcu = fcn) {
+  FCurve *fcn = NULL;
+  for (FCurve *fcu = list->first; fcu; fcu = fcn) {
 fcn = fcu->next;
 BKE_fcurve_free(fcu);
   }
@@ -113,15 +112,13 @@ void BKE_fcurves_free(ListBase *list)
 
 FCurve *BKE_fcurve_copy(const FCurve *fcu)
 {
-  FCurve *fcu_d;
-
   /* Sanity check. */
   if (fcu == NULL) {
 return NULL;
   }
 
   /* Make a copy. */
-  fcu_d = MEM_dupallocN(fcu);
+  FCurve *fcu_d = MEM_dupallocN(fcu);
 
   fcu_d->next = fcu_d->prev = NULL;
   fcu_d->grp = NULL;
@@ -145,8 +142,6 @@ FCurve *BKE_fcurve_copy(const FCurve *fcu)
 
 void BKE_fcurves_copy(ListBase *dst, ListBase *src)
 {
-  FCurve *dfcu, *sfcu;
-
   /* Sanity checks. */
   if (ELEM(NULL, dst, src)) {
 return;
@@ -156,8 +151,8 @@ void BKE_fcurves_copy(ListBase *dst, ListBase *src)
   BLI_listbase_clear(dst);
 
   /* Copy one-by-one. */
-  for (sfcu = src->first; sfcu; sfcu = sfcu->next) {
-dfcu = BKE_fcurve_copy(sfcu);
+  LISTBASE_FOREACH (FCurve *, sfcu, src) {
+FCurve *dfcu = BKE_fcurve_copy(sfcu);
 BLI_addtail(dst, dfcu);
   }
 }
@@ -203,12 +198,10 @@ FCurve *id_data_find_fcurve(
 {
   /* Anim vars */
   AnimData *adt = BKE_animdata_from_id(id);
-  FCurve *fcu = NULL;
 
   /* Rna vars */
   PointerRNA ptr;
   PropertyRNA *prop;
-  char *path;
 
   if (r_driven) {
 *r_driven = false;
@@ -225,7 +218,7 @@ FCurve *id_data_find_fcurve(
 return NULL;
   }
 
-  path = RNA_path_from_ID_to_property(, prop);
+  char *path = RNA_path_from_ID_to_property(, prop);
   if (path == NULL) {
 return NULL;
   }
@@ -233,7 +226,7 @@ FCurve *id_data_find_fcurve(
   /* FIXME: The way drivers are handled here (always NULL-ifying `fcu`) is 
very weird, this needs
* to be re-checked I think?. */
   bool is_driven = false;
-  fcu = BKE_animadata_fcurve_find_by_rna_path(adt, path, index, NULL, 
_driven);
+  FCurve *fcu = BKE_animadata_fcurve_find_by_rna_path(adt, path, index, NULL, 
_driven);
   if (is_driven) {
 if (r_driven != NULL) {
   *r_driven = is_driven;
@@ -248,15 +241,13 @@ FCurve *id_data_find_fcurve(
 
 FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], const int 
array_index)
 {
-  FCurve *fcu;
-
   /* Sanity checks. */
-  if (ELEM(NULL, list, rna_path) || (array_index < 0)) {
+  if (ELEM(NULL, list, rna_path) || array_index < 0) {
 return NULL;
   }
 
   /* Check paths of curves, then array indices... */
-  for (fcu = list->first; fcu; fcu = fcu->next) {
+  LISTBASE_FOREACH (FCurve *, fcu, list) {
 /* Check indices first, much cheaper than a string comparison. */
 /* Simple string-compare (this assumes that they have the same root...) */
 if (UNLIKELY(fcu->array_index == array_index && fcu->rna_path &&
@@ -276,15 +267,13 @@ FCurve *BKE_fcurve_find(ListBase *list, const char 
rna_path[], const int array_i
 
 FCurve *BKE_fcurve_iter_step(FCurve *fcu_iter, const char rna_path[])
 {
-  FCurve *fcu;
-
   /* Sanity checks. */
   if (ELEM(NULL, fcu_iter, rna_path)) {
 return NULL;
   }
 
   /* Check paths of curves, then array indices... */
-  for (fcu = fcu_iter; fcu; fcu = fcu->next) {
+  for (FCurve *fcu = fcu_iter; fcu; fcu = fcu->next) {
 /* Simple string-compare (this assumes that they have the same root...) */
 if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) {
   return fcu;
@@ -296,7 +285,6 @@ FCurve *BKE_fcurve_iter_ste

[Bf-blender-cvs] [a5b2a3041f7] master: Fix const-correctness for a number of F-Curve functions

2022-11-10 Thread Colin Basnett
Commit: a5b2a3041f7553eabf7e24834982ebf908ea3a85
Author: Colin Basnett
Date:   Thu Nov 10 10:22:03 2022 -0800
Branches: master
https://developer.blender.org/rBa5b2a3041f7553eabf7e24834982ebf908ea3a85

Fix const-correctness for a number of F-Curve functions

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16445

===

M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/blenkernel/intern/fmodifier.c

===

diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index cbdf37e14bd..b4de24e3b64 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -167,7 +167,7 @@ void set_active_fmodifier(ListBase *modifiers, struct 
FModifier *fcm);
  * \param mtype: Type of modifier (if 0, doesn't matter).
  * \param acttype: Type of action to perform (if -1, doesn't matter).
  */
-bool list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short 
acttype);
+bool list_has_suitable_fmodifier(const ListBase *modifiers, int mtype, short 
acttype);
 
 typedef struct FModifiersStackStorage {
   uint modifier_count;
@@ -369,12 +369,12 @@ int BKE_fcurve_pathcache_find_array(struct 
FCurvePathCache *fcache,
  * Calculate the extents of F-Curve's keyframes.
  */
 bool BKE_fcurve_calc_range(
-struct FCurve *fcu, float *min, float *max, bool do_sel_only, bool 
do_min_length);
+const struct FCurve *fcu, float *min, float *max, bool do_sel_only, bool 
do_min_length);
 
 /**
  * Calculate the extents of F-Curve's data.
  */
-bool BKE_fcurve_calc_bounds(struct FCurve *fcu,
+bool BKE_fcurve_calc_bounds(const struct FCurve *fcu,
 float *xmin,
 float *xmax,
 float *ymin,
@@ -421,14 +421,14 @@ void BKE_fcurve_keyframe_move_value_with_handles(struct 
BezTriple *keyframe, flo
  * Usability of keyframes refers to whether they should be displayed,
  * and also whether they will have any influence on the final result.
  */
-bool BKE_fcurve_are_keyframes_usable(struct FCurve *fcu);
+bool BKE_fcurve_are_keyframes_usable(const struct FCurve *fcu);
 
 /**
  * Can keyframes be added to F-Curve?
  * Keyframes can only be added if they are already visible.
  */
-bool BKE_fcurve_is_keyframable(struct FCurve *fcu);
-bool BKE_fcurve_is_protected(struct FCurve *fcu);
+bool BKE_fcurve_is_keyframable(const struct FCurve *fcu);
+bool BKE_fcurve_is_protected(const struct FCurve *fcu);
 
 /**
  * Are any of the keyframe control points selected on the F-Curve?
@@ -439,7 +439,7 @@ bool BKE_fcurve_has_selected_control_points(const struct 
FCurve *fcu);
  * Checks if the F-Curve has a Cycles modifier with simple settings
  * that warrant transition smoothing.
  */
-bool BKE_fcurve_is_cyclic(struct FCurve *fcu);
+bool BKE_fcurve_is_cyclic(const struct FCurve *fcu);
 
 /* Type of infinite cycle for a curve. */
 typedef enum eFCU_Cycle_Type {
@@ -453,7 +453,7 @@ typedef enum eFCU_Cycle_Type {
 /**
  * Checks if the F-Curve has a Cycles modifier, and returns the type of the 
cycle behavior.
  */
-eFCU_Cycle_Type BKE_fcurve_get_cycle_type(struct FCurve *fcu);
+eFCU_Cycle_Type BKE_fcurve_get_cycle_type(const struct FCurve *fcu);
 
 /**
  * Recompute bezier handles of all three given BezTriples, so that `bezt` can 
be inserted between
@@ -544,7 +544,7 @@ float evaluate_fcurve_driver(struct PathResolvedRNA 
*anim_rna,
 /**
  * Checks if the curve has valid keys, drivers or modifiers that produce an 
actual curve.
  */
-bool BKE_fcurve_is_empty(struct FCurve *fcu);
+bool BKE_fcurve_is_empty(const struct FCurve *fcu);
 /**
  * Calculate the value of the given F-Curve at the given frame,
  * and store it's value in #FCurve.curval.
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index d248faaab00..aa99a5f605a 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -571,7 +571,7 @@ int BKE_fcurve_bezt_binarysearch_index(const BezTriple 
array[],
 /* .. */
 
 /* Helper for calc_fcurve_* functions -> find first and last BezTriple to be 
used. */
-static short get_fcurve_end_keyframes(FCurve *fcu,
+static short get_fcurve_end_keyframes(const FCurve *fcu,
   BezTriple **first,
   BezTriple **last,
   const bool do_sel_only)
@@ -621,7 +621,7 @@ static short get_fcurve_end_keyframes(FCurve *fcu,
   return found;
 }
 
-bool BKE_fcurve_calc_bounds(FCurve *fcu,
+bool BKE_fcurve_calc_bounds(const FCurve *fcu,
 float *xmin,
 float *xmax,
 float *ymin,
@@ -752,7 +75

[Bf-blender-cvs] [3836b6ff8cb] master: Cancel Equalize Handles & Snap Keys when no control points are selected

2022-11-08 Thread Colin Basnett
Commit: 3836b6ff8cba135d185e147dbffca7847870e6cd
Author: Colin Basnett
Date:   Tue Nov 8 19:19:59 2022 -0800
Branches: master
https://developer.blender.org/rB3836b6ff8cba135d185e147dbffca7847870e6cd

Cancel Equalize Handles & Snap Keys when no control points are selected

The Equalize Handles and Snap Keys operators would allow the user to
invoke them successfully even when they would have no effect due to
there not being any selected control points.

This patch makes it so that an error is displayed when these operators
are invoked with no control points are selected.

The reason this is in the `invoke` function is because it would be too
expensive to run this check in the `poll` function since it requires a
linear search through all the keys of all the visible F-Curves.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16390

===

M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/editors/space_graph/graph_edit.c

===

diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index c11e6353bc0..cbdf37e14bd 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -430,6 +430,11 @@ bool BKE_fcurve_are_keyframes_usable(struct FCurve *fcu);
 bool BKE_fcurve_is_keyframable(struct FCurve *fcu);
 bool BKE_fcurve_is_protected(struct FCurve *fcu);
 
+/**
+ * Are any of the keyframe control points selected on the F-Curve?
+ */
+bool BKE_fcurve_has_selected_control_points(const struct FCurve *fcu);
+
 /**
  * Checks if the F-Curve has a Cycles modifier with simple settings
  * that warrant transition smoothing.
diff --git a/source/blender/blenkernel/intern/fcurve.c 
b/source/blender/blenkernel/intern/fcurve.c
index beea3217126..d248faaab00 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -965,6 +965,18 @@ bool BKE_fcurve_is_protected(FCurve *fcu)
   return ((fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & 
AGRP_PROTECTED)));
 }
 
+bool BKE_fcurve_has_selected_control_points(const FCurve *fcu)
+{
+  int i;
+  BezTriple *bezt;
+  for (bezt = fcu->bezt, i = 0; i < fcu->totvert; ++i, ++bezt) {
+if ((bezt->f2 & SELECT) != 0) {
+  return true;
+}
+  }
+  return false;
+}
+
 bool BKE_fcurve_is_keyframable(FCurve *fcu)
 {
   /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on 
final result) */
diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index a23b33dde95..c605ba6776f 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2333,6 +2333,48 @@ static int graphkeys_snap_exec(bContext *C, wmOperator 
*op)
   return OPERATOR_FINISHED;
 }
 
+bool graph_has_selected_control_points(struct bContext *C)
+{
+  bAnimContext ac;
+  ListBase anim_data = {NULL, NULL};
+
+  /* Get editor data. */
+  if (ANIM_animdata_get_context(C, ) == 0) {
+return OPERATOR_CANCELLED;
+  }
+
+  /* Filter data. */
+  const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | 
ANIMFILTER_FCURVESONLY |
+  ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS);
+  ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
+
+  /* Check if any of the visible and editable f-curves have at least one 
selected control point. */
+  bool has_selected_control_points = false;
+  LISTBASE_FOREACH (bAnimListElem *, ale, _data) {
+const FCurve *fcu = ale->key_data;
+if (BKE_fcurve_has_selected_control_points(fcu)) {
+  has_selected_control_points = true;
+  break;
+}
+  }
+
+  ANIM_animdata_freelist(_data);
+
+  return has_selected_control_points;
+}
+
+int graphkeys_selected_control_points_invoke(struct bContext *C,
+ struct wmOperator *op,
+ const struct wmEvent *event)
+{
+  if (!graph_has_selected_control_points(C)) {
+BKE_report(op->reports, RPT_ERROR, "No control points are selected");
+return OPERATOR_CANCELLED;
+  }
+
+  return WM_menu_invoke(C, op, event);
+}
+
 void GRAPH_OT_snap(wmOperatorType *ot)
 {
   /* Identifiers */
@@ -2341,7 +2383,7 @@ void GRAPH_OT_snap(wmOperatorType *ot)
   ot->description = "Snap selected keyframes to the chosen times/values";
 
   /* API callbacks */
-  ot->invoke = WM_menu_invoke;
+  ot->invoke = graphkeys_selected_control_points_invoke;
   ot->exec = graphkeys_snap_exec;
   ot->poll = graphop_editable_keyframes_poll;
 
@@ -2418,7 +2460,7 @@ void GRAPH_OT_equalize_handles(wmOperatorType *ot)
   "Ensure selected keyframes' handles have equal le

[Bf-blender-cvs] [335082dcd32] master: Merge branch 'blender-v3.4-release'

2022-11-08 Thread Colin Basnett
Commit: 335082dcd329dc74f3788a14eb7aefd84358aa50
Author: Colin Basnett
Date:   Tue Nov 8 15:31:33 2022 -0800
Branches: master
https://developer.blender.org/rB335082dcd329dc74f3788a14eb7aefd84358aa50

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [ee5b6f71501] blender-v3.4-release: Hide ratio when using error margin mode in decimate keyframes operator

2022-11-08 Thread Colin Basnett
Commit: ee5b6f7150109a62b2a435ecd011316ffceb9e59
Author: Colin Basnett
Date:   Tue Nov 8 15:29:57 2022 -0800
Branches: blender-v3.4-release
https://developer.blender.org/rBee5b6f7150109a62b2a435ecd011316ffceb9e59

Hide ratio when using error margin mode in decimate keyframes operator

This fixes a bug in the function that determines what properties to show
on the Decimate Keyframes operator.

Before the fix, the "Remove" (i.e., `factor`) slider was visible no
matter what "Mode" was being used. This meant that the slider was
visible and modifiable when it had no effect, creating confusion.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D16318

===

M   source/blender/editors/space_graph/graph_slider_ops.c

===

diff --git a/source/blender/editors/space_graph/graph_slider_ops.c 
b/source/blender/editors/space_graph/graph_slider_ops.c
index f3d92911155..62aecf930d3 100644
--- a/source/blender/editors/space_graph/graph_slider_ops.c
+++ b/source/blender/editors/space_graph/graph_slider_ops.c
@@ -458,16 +458,13 @@ static bool decimate_poll_property(const bContext 
*UNUSED(C),
const PropertyRNA *prop)
 {
   const char *prop_id = RNA_property_identifier(prop);
+  const int mode = RNA_enum_get(op->ptr, "mode");
 
-  if (STRPREFIX(prop_id, "remove")) {
-int mode = RNA_enum_get(op->ptr, "mode");
-
-if (STREQ(prop_id, "factor") && mode != DECIM_RATIO) {
-  return false;
-}
-if (STREQ(prop_id, "remove_error_margin") && mode != DECIM_ERROR) {
-  return false;
-}
+  if (STREQ(prop_id, "factor") && mode != DECIM_RATIO) {
+return false;
+  }
+  if (STREQ(prop_id, "remove_error_margin") && mode != DECIM_ERROR) {
+return false;
   }
 
   return true;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d6b2f4ad8e8] master: Merge branch 'blender-v3.4-release'

2022-11-04 Thread Colin Basnett
Commit: d6b2f4ad8e8dcdb821e53da091faed265833d886
Author: Colin Basnett
Date:   Fri Nov 4 00:03:47 2022 -0700
Branches: master
https://developer.blender.org/rBd6b2f4ad8e8dcdb821e53da091faed265833d886

Merge branch 'blender-v3.4-release'

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [11a705c2d00] blender-v3.4-release: Fix T102218: Baked f-curves display incorrectly when normalized

2022-11-04 Thread Colin Basnett
Commit: 11a705c2d003854ac21d81ea3261a6c9dc804a70
Author: Colin Basnett
Date:   Thu Nov 3 23:55:18 2022 -0700
Branches: blender-v3.4-release
https://developer.blender.org/rB11a705c2d003854ac21d81ea3261a6c9dc804a70

Fix T102218: Baked f-curves display incorrectly when normalized

This fixes T102218, where baked f-curves would display incorrectly when 
normalized.

This bug was a result of the code making no effort to determine the y-range of 
baked f-curves, so it fell back to a default that looked horrible.

I've added specific handling for finding the y-range of each f-curve (I 
extracted this functionality out to a new function, 
`fcurve_scene_coord_range_get`, for organization purposes). In addition, a 
minor optimization was made to eliminate redundant range-checks when in preview 
range mode.

{F13838304}

Reviewed By: sybren

Maniphest Tasks: T102218

Differential Revision: https://developer.blender.org/D16363

===

M   release/scripts/addons
M   source/blender/editors/animation/anim_draw.c

===

diff --git a/release/scripts/addons b/release/scripts/addons
index 05f475f231a..5a818af9508 16
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 05f475f231abce2701b7424ed6b8231dadc64da8
+Subproject commit 5a818af95080cccf04dfa8317f0e966bff515c64
diff --git a/source/blender/editors/animation/anim_draw.c 
b/source/blender/editors/animation/anim_draw.c
index 06a0077df9b..329bc2b46eb 100644
--- a/source/blender/editors/animation/anim_draw.c
+++ b/source/blender/editors/animation/anim_draw.c
@@ -329,6 +329,121 @@ short ANIM_get_normalization_flags(bAnimContext *ac)
   return 0;
 }
 
+static void fcurve_scene_coord_range_get(Scene *scene,
+ FCurve *fcu,
+ float *r_min_coord,
+ float *r_max_coord)
+{
+  float min_coord = FLT_MAX;
+  float max_coord = -FLT_MAX;
+  const bool use_preview_only = PRVRANGEON;
+
+  if (fcu->bezt || fcu->fpt) {
+int start = 0;
+int end = fcu->totvert;
+
+if (use_preview_only) {
+  start = scene->r.psfra;
+  end = min_ii(scene->r.pefra + 1, fcu->totvert);
+}
+
+if (fcu->bezt) {
+  const BezTriple *bezt = fcu->bezt + start;
+  for (int i = start; i < end; i++, bezt++) {
+
+if (i == 0) {
+  /* We ignore extrapolation flags and handle here, and use the
+   * control point position only. so we normalize "interesting"
+   * part of the curve.
+   *
+   * Here we handle left extrapolation.
+   */
+  max_coord = max_ff(max_coord, bezt->vec[1][1]);
+  min_coord = min_ff(min_coord, bezt->vec[1][1]);
+}
+else {
+  const BezTriple *prev_bezt = bezt - 1;
+  if (!ELEM(prev_bezt->ipo, BEZT_IPO_BEZ, BEZT_IPO_BACK, 
BEZT_IPO_ELASTIC)) {
+/* The points on the curve will lie inside the start and end 
points.
+ * Calculate min/max using both previous and current CV.
+ */
+max_coord = max_ff(max_coord, bezt->vec[1][1]);
+min_coord = min_ff(min_coord, bezt->vec[1][1]);
+max_coord = max_ff(max_coord, prev_bezt->vec[1][1]);
+min_coord = min_ff(min_coord, prev_bezt->vec[1][1]);
+  }
+  else {
+const int resol = fcu->driver ?
+  32 :
+  min_ii((int)(5.0f * len_v2v2(bezt->vec[1], 
prev_bezt->vec[1])),
+ 32);
+if (resol < 2) {
+  max_coord = max_ff(max_coord, prev_bezt->vec[1][1]);
+  min_coord = min_ff(min_coord, prev_bezt->vec[1][1]);
+}
+else {
+  if (!ELEM(prev_bezt->ipo, BEZT_IPO_BACK, BEZT_IPO_ELASTIC)) {
+/* Calculate min/max using bezier forward differencing. */
+float data[120];
+float v1[2], v2[2], v3[2], v4[2];
+
+v1[0] = prev_bezt->vec[1][0];
+v1[1] = prev_bezt->vec[1][1];
+v2[0] = prev_bezt->vec[2][0];
+v2[1] = prev_bezt->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];
+
+BKE_fcurve_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 (int j = 0; j <= resol; 

[Bf-blender-cvs] [cee6c07f9ee] master: Set operator poll message when vertex group is locked

2022-10-08 Thread Colin Basnett
Commit: cee6c07f9ee85ac68d0479638af832e4fc97c49f
Author: Colin Basnett
Date:   Sat Oct 8 11:43:38 2022 -0700
Branches: master
https://developer.blender.org/rBcee6c07f9ee85ac68d0479638af832e4fc97c49f

Set operator poll message when vertex group is locked

Differential Revision: https://developer.blender.org/D16190

===

M   source/blender/editors/object/object_vgroup.cc

===

diff --git a/source/blender/editors/object/object_vgroup.cc 
b/source/blender/editors/object/object_vgroup.cc
index 02a247dd15e..a63e06d6866 100644
--- a/source/blender/editors/object/object_vgroup.cc
+++ b/source/blender/editors/object/object_vgroup.cc
@@ -2850,8 +2850,9 @@ static bool 
vertex_group_vert_select_unlocked_poll(bContext *C)
   if (def_nr != 0) {
 const ListBase *defbase = BKE_object_defgroup_list(ob);
 const bDeformGroup *dg = static_cast(BLI_findlink(defbase, def_nr - 1));
-if (dg) {
-  return !(dg->flag & DG_LOCK_WEIGHT);
+if (dg && (dg->flag & DG_LOCK_WEIGHT)) {
+  CTX_wm_operator_poll_msg_set(C, "The active vertex group is locked");
+  return false;
 }
   }
   return true;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [564bda241a9] feature-imformat: Merge branch 'master' into feature-imformat

2022-09-16 Thread Colin Basnett
Commit: 564bda241a973396da51d7c3ccd9efd97d51728a
Author: Colin Basnett
Date:   Fri Sep 16 17:50:37 2022 -0700
Branches: feature-imformat
https://developer.blender.org/rB564bda241a973396da51d7c3ccd9efd97d51728a

Merge branch 'master' into feature-imformat

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0fff238150d] feature-imformat: Moved some things around, finally have a global hash table for registered image formats

2022-09-16 Thread Colin Basnett
Commit: 0fff238150d076576053c25b646f653d6e3b0edb
Author: Colin Basnett
Date:   Mon Jun 20 16:52:14 2022 -0700
Branches: feature-imformat
https://developer.blender.org/rB0fff238150d076576053c25b646f653d6e3b0edb

Moved some things around, finally have a global hash table for registered image 
formats

===

M   source/blender/blentranslation/BLT_translation.h
M   source/blender/makesdna/DNA_image_types.h
M   source/blender/makesrna/intern/rna_image.c
M   source/blender/makesrna/intern/rna_wm.c
A   source/blender/python/intern/bpy_imageformat_wrap.c
A   source/blender/python/intern/bpy_imageformat_wrap.h
M   source/blender/windowmanager/WM_api.h
A   source/blender/windowmanager/intern/wm_imageformat_type.c
M   source/blender/windowmanager/intern/wm_init_exit.c

===

diff --git a/source/blender/blentranslation/BLT_translation.h 
b/source/blender/blentranslation/BLT_translation.h
index 129eba3de2f..247be831aad 100644
--- a/source/blender/blentranslation/BLT_translation.h
+++ b/source/blender/blentranslation/BLT_translation.h
@@ -69,6 +69,9 @@ const char *BLT_translate_do_new_dataname(const char 
*msgctxt, const char *msgid
 /* Default context for operator names/labels. */
 #define BLT_I18NCONTEXT_OPERATOR_DEFAULT "Operator"
 
+/* Default context for image format names/labels. */
+#define BLT_I18CONTEXT_IMAGEFORMAT_DEFAULT "Image Format"
+
 /* Context for events/keymaps (necessary, since those often use one or two 
letters,
  * easy to get collisions with other areas...). */
 #define BLT_I18NCONTEXT_UI_EVENTS "UI_Events_KeyMaps"
diff --git a/source/blender/makesdna/DNA_image_types.h 
b/source/blender/makesdna/DNA_image_types.h
index e521dae219d..07b1928717a 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -276,9 +276,6 @@ enum {
 
 typedef struct imfImageFormat {
   struct imfImageFormat *next, *prev;
-
-  const char *bl_extensions;
-
   struct imfImageFormatType *type;
 } imfImageFormat;
 
diff --git a/source/blender/makesrna/intern/rna_image.c 
b/source/blender/makesrna/intern/rna_image.c
index 38706606997..abf3d5cfcde 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -53,45 +53,6 @@ static const EnumPropertyItem image_source_items[] = {
 {0, NULL, 0, NULL, NULL},
 };
 
-#ifdef WITH_PYTHON
-
-static bool rna_imageformat_is_a_bytes_cb(const struct bContext *C,
-  struct imfImageFormatType *ift,
-  const char *bytes)
-{
-  extern FunctionRNA rna_ImageFormat_is_a_bytes_func;
-
-  PointerRNA ptr;
-  ParameterList list;
-  FunctionRNA *func;
-  void *ret;
-  bool is_a_bytes;
-
-  /* seems to be some sort of temporary rna pointer?? */
-  RNA_pointer_create(NULL, ift->rna_ext.srna, NULL, );
-  func = _ImageFormat_is_a_bytes_func;
-
-  /* set up arguments */
-  RNA_parameter_list_create(, , func);
-  RNA_parameter_set_lookup(, "data", bytes);
-
-  /* call function */
-  ift->rna_ext.call((struct bContext *)C, , func, );
-
-  /* get return value */
-  RNA_parameter_get_lookup(, "result", );
-  is_a_bytes = *(bool *)ret;
-
-  return is_a_bytes;
-}
-
-static Image *rna_imageformat_load_cb(struct imfImageFormatType *ift, const 
char *bytes)
-{
-  return NULL;
-}
-
-#endif /* WITH_PYTHON */
-
 
 #ifdef RNA_RUNTIME
 
@@ -731,129 +692,6 @@ static void rna_UDIMTile_remove(Image *image, PointerRNA 
*ptr)
   WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
 }
 
-static StructRNA *rna_ImageFormat_register(Main *bmain,
-   ReportList *reports,
-   void *data,
-   const char *identifier,
-   StructValidateFunc validate,
-   StructCallbackFunc call,
-   StructFreeFunc free)
-{
-  struct {
-char idname[MAX_NAME];
-char extensions[MAX_NAME];
-  } temp_buffers;
-
-  imfImageFormatType dummy_type = {NULL};
-  imfImageFormat dummy = {NULL};
-  PointerRNA mnp_ptr;
-
-  /* TODO: how is the size determined? magic of rna defs? */
-  int have_function[2];
-
-  /* setup dummy gizmo & gizmo type to store static properties in */
-  dummy.type = _type;
-  dummy_type.idname = temp_buffers.idname;
-  dummy_type.extensions = temp_buffers.extensions;
-  RNA_pointer_create(NULL, _ImageFormat, , _ptr);
-
-  /* Clear so we can detect if it's left unset. */
-  temp_buffers.idname[0] = '\0';
-  temp_buffers.extensions[0] = '\0';
-
-  /* validate the python class */
-  if (validate(_ptr, data, have_function) != 0) {
-return NULL;
-  }
-
-  /* make sure the id does not exceeed buffer lengt

[Bf-blender-cvs] [a9077cefd44] feature-imformat: Initial commit for imformat branch

2022-09-16 Thread Colin Basnett
Commit: a9077cefd4482fb84093fc447f06ccbd2b0ec842
Author: Colin Basnett
Date:   Thu Jun 2 02:33:16 2022 -0700
Branches: feature-imformat
https://developer.blender.org/rBa9077cefd4482fb84093fc447f06ccbd2b0ec842

Initial commit for imformat branch

===

M   source/blender/makesdna/DNA_image_types.h
M   source/blender/makesrna/intern/rna_image.c
M   source/blender/makesrna/intern/rna_wm_gizmo.c
M   source/blender/windowmanager/WM_types.h

===

diff --git a/source/blender/makesdna/DNA_image_types.h 
b/source/blender/makesdna/DNA_image_types.h
index 6e4e515a0fe..e521dae219d 100644
--- a/source/blender/makesdna/DNA_image_types.h
+++ b/source/blender/makesdna/DNA_image_types.h
@@ -21,6 +21,7 @@ struct PackedFile;
 struct RenderResult;
 struct Scene;
 struct anim;
+struct imfImageFormatType;
 
 /* ImageUser is in Texture, in Nodes, Background Image, Image Window,  */
 /* should be used in conjunction with an ID * to Image. */
@@ -273,6 +274,14 @@ enum {
   IMA_ALPHA_IGNORE = 3,
 };
 
+typedef struct imfImageFormat {
+  struct imfImageFormat *next, *prev;
+
+  const char *bl_extensions;
+
+  struct imfImageFormatType *type;
+} imfImageFormat;
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/makesrna/intern/rna_image.c 
b/source/blender/makesrna/intern/rna_image.c
index 269ebe1581f..440e99ad277 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -4,6 +4,8 @@
  * \ingroup RNA
  */
 
+#pragma optimize("", off)
+
 #include 
 
 #include "DNA_image_types.h"
@@ -28,6 +30,8 @@
 #include "WM_api.h"
 #include "WM_types.h"
 
+struct bContext;
+
 const EnumPropertyItem rna_enum_image_generated_type_items[] = {
 {IMA_GENTYPE_BLANK, "BLANK", 0, "Blank", "Generate a blank image"},
 {IMA_GENTYPE_GRID, "UV_GRID", 0, "UV Grid", "Generated grid to test UV 
mappings"},
@@ -49,6 +53,46 @@ static const EnumPropertyItem image_source_items[] = {
 {0, NULL, 0, NULL, NULL},
 };
 
+#ifdef WITH_PYTHON
+
+static bool rna_imageformat_is_a_bytes_cb(const struct bContext *C,
+  struct imfImageFormatType *ift,
+  const char *bytes)
+{
+  extern FunctionRNA rna_ImageFormat_is_a_bytes_func;
+
+  PointerRNA ptr;
+  ParameterList list;
+  FunctionRNA *func;
+  void *ret;
+  bool is_a_bytes;
+
+  /* seems to be some sort of temporary rna pointer?? */
+  RNA_pointer_create(NULL, ift->rna_ext.srna, NULL, );
+  func = _ImageFormat_is_a_bytes_func;
+
+  /* set up arguments */
+  RNA_parameter_list_create(, , func);
+  RNA_parameter_set_lookup(, "data", bytes);
+
+  /* call function */
+  ift->rna_ext.call((struct bContext *)C, , func, );
+
+  /* get return value */
+  RNA_parameter_get_lookup(, "result", );
+  is_a_bytes = *(bool *)ret;
+
+  return is_a_bytes;
+}
+
+static Image *rna_imageformat_load_cb(struct imfImageFormatType *ift, const 
char *bytes)
+{
+  return NULL;
+}
+
+#endif /* WITH_PYTHON */
+
+
 #ifdef RNA_RUNTIME
 
 #  include "BLI_math_base.h"
@@ -642,6 +686,129 @@ static void rna_UDIMTile_remove(Image *image, PointerRNA 
*ptr)
   WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
 }
 
+static StructRNA *rna_ImageFormat_register(Main *bmain,
+   ReportList *reports,
+   void *data,
+   const char *identifier,
+   StructValidateFunc validate,
+   StructCallbackFunc call,
+   StructFreeFunc free)
+{
+  struct {
+char idname[MAX_NAME];
+char extensions[MAX_NAME];
+  } temp_buffers;
+
+  imfImageFormatType dummy_type = {NULL};
+  imfImageFormat dummy = {NULL};
+  PointerRNA mnp_ptr;
+
+  /* TODO: how is the size determined? magic of rna defs? */
+  int have_function[2];
+
+  /* setup dummy gizmo & gizmo type to store static properties in */
+  dummy.type = _type;
+  dummy_type.idname = temp_buffers.idname;
+  dummy_type.extensions = temp_buffers.extensions;
+  RNA_pointer_create(NULL, _ImageFormat, , _ptr);
+
+  /* Clear so we can detect if it's left unset. */
+  temp_buffers.idname[0] = '\0';
+  temp_buffers.extensions[0] = '\0';
+
+  /* validate the python class */
+  if (validate(_ptr, data, have_function) != 0) {
+return NULL;
+  }
+
+  /* make sure the id does not exceeed buffer length */
+  if (strlen(identifier) >= sizeof(temp_buffers.idname)) {
+BKE_reportf(reports,
+RPT_ERROR,
+"Registering image format class: '%s' is too long, maximum 
length is %d",
+ide

[Bf-blender-cvs] [579784eff99] feature-imformat: Merge branch 'master' into feature-imformat

2022-09-16 Thread Colin Basnett
Commit: 579784eff99a57e1b827ff71d921bd07db7649fb
Author: Colin Basnett
Date:   Sat Jun 18 19:00:48 2022 -0700
Branches: feature-imformat
https://developer.blender.org/rB579784eff99a57e1b827ff71d921bd07db7649fb

Merge branch 'master' into feature-imformat

===



===



___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [48d7ff68f0d] master: Make File Select dialog update operator's file & path properties

2022-09-16 Thread Colin Basnett
Commit: 48d7ff68f0df209c77bbb081ab46fbc109fd825a
Author: Colin Basnett
Date:   Fri Sep 16 00:22:16 2022 -0700
Branches: master
https://developer.blender.org/rB48d7ff68f0df209c77bbb081ab46fbc109fd825a

Make File Select dialog update operator's file & path properties

When an operator is attached to a file select dialog, the update
callback function for the operator's directory, filename and filepath
properties will be called as the user navigates through the dialog.

This will allow add-on authors to make more interactive import
operators.

Differential Revision: https://developer.blender.org/D15543

===

M   source/blender/editors/space_file/file_intern.h
M   source/blender/editors/space_file/file_ops.c
M   source/blender/editors/space_file/filesel.c

===

diff --git a/source/blender/editors/space_file/file_intern.h 
b/source/blender/editors/space_file/file_intern.h
index 655a7983e2b..788bafe8089 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -95,11 +95,15 @@ int file_highlight_set(struct SpaceFile *sfile, struct 
ARegion *region, int mx,
  * Use to set the file selector path from some arbitrary source.
  */
 void file_sfile_filepath_set(struct SpaceFile *sfile, const char *filepath);
-void file_sfile_to_operator_ex(struct Main *bmain,
+void file_sfile_to_operator_ex(struct bContext *C,
+   struct Main *bmain,
struct wmOperator *op,
struct SpaceFile *sfile,
char *filepath);
-void file_sfile_to_operator(struct Main *bmain, struct wmOperator *op, struct 
SpaceFile *sfile);
+void file_sfile_to_operator(struct bContext *C,
+struct Main *bmain,
+struct wmOperator *op,
+struct SpaceFile *sfile);
 
 void file_operator_to_sfile(struct Main *bmain, struct SpaceFile *sfile, 
struct wmOperator *op);
 
@@ -113,7 +117,7 @@ void fileselect_refresh_params(struct SpaceFile *sfile);
 /**
  * Sets #FileSelectParams.file (name of selected file)
  */
-void fileselect_file_set(SpaceFile *sfile, int index);
+void fileselect_file_set(struct bContext *C, SpaceFile *sfile, int index);
 bool file_attribute_column_type_enabled(const FileSelectParams *params,
 FileAttributeColumnType column);
 /**
diff --git a/source/blender/editors/space_file/file_ops.c 
b/source/blender/editors/space_file/file_ops.c
index 721c58fc34e..26fb85ca2af 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -213,7 +213,7 @@ static FileSelect file_select_do(bContext *C, int 
selected_idx, bool do_diropen)
 else {
   retval = FILE_SELECT_FILE;
 }
-fileselect_file_set(sfile, selected_idx);
+fileselect_file_set(C, sfile, selected_idx);
   }
   return retval;
 }
@@ -484,7 +484,7 @@ static int file_box_select_modal(bContext *C, wmOperator 
*op, const wmEvent *eve
   else {
 params->highlight_file = -1;
 params->sel_first = params->sel_last = -1;
-fileselect_file_set(sfile, params->active_file);
+fileselect_file_set(C, sfile, params->active_file);
 file_select_deselect_all(sfile, FILE_SEL_HIGHLIGHTED);
 WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
   }
@@ -702,7 +702,8 @@ void FILE_OT_select(wmOperatorType *ot)
 /**
  * \returns true if selection has changed
  */
-static bool file_walk_select_selection_set(wmWindow *win,
+static bool file_walk_select_selection_set(struct bContext* C,
+   wmWindow *win,
ARegion *region,
SpaceFile *sfile,
const int direction,
@@ -808,7 +809,7 @@ static bool file_walk_select_selection_set(wmWindow *win,
   }
 
   BLI_assert(IN_RANGE(active, -1, numfiles));
-  fileselect_file_set(sfile, params->active_file);
+  fileselect_file_set(C, sfile, params->active_file);
 
   /* ensure newly selected file is inside viewbounds */
   file_ensure_inside_viewbounds(region, sfile, params->active_file);
@@ -889,7 +890,8 @@ static bool file_walk_select_do(bContext *C,
 }
   }
 
-  return file_walk_select_selection_set(win,
+  return file_walk_select_selection_set(C,
+win,
 region,
 sfile,
 direction,
@@ -1555,7 +1557,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot)
 /** \name Operator Utilities
  * \{ */
 
-void file_sfile_to_operator_ex(Main *bmain, wmOperator *op, SpaceFile *sfile, 
char *filepath)
+void file_sfil

[Bf-blender-cvs] [ddfce277e0c] master: NLA: actionclip_add now fails on invoke if no NLA track is selected

2022-09-12 Thread Colin Basnett
Commit: ddfce277e0cbf0997c1366d366416dd43f997b7c
Author: Colin Basnett
Date:   Mon Sep 12 18:11:00 2022 -0700
Branches: master
https://developer.blender.org/rBddfce277e0cbf0997c1366d366416dd43f997b7c

NLA: actionclip_add now fails on invoke if no NLA track is selected

This makes the NLA_OT_actionclip_add operation (Shift+A while mousing
over the NLA strips area) fail on invocation if no tracks are active.

This stops the annoyance of using the Shift+A menu to select an action
to add, but only getting the error after you select an action.

Differential Revision: https://developer.blender.org/D15737

===

M   source/blender/editors/space_nla/nla_edit.c

===

diff --git a/source/blender/editors/space_nla/nla_edit.c 
b/source/blender/editors/space_nla/nla_edit.c
index 801d032a861..bcdbbb00d1c 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -606,6 +606,36 @@ void NLA_OT_view_frame(wmOperatorType *ot)
  * (or the active block if no space in the track).
  * \{ */
 
+/* Get a list of the editable tracks being shown in the NLA. */
+static int nlaedit_get_editable_tracks(bAnimContext *ac, ListBase *anim_data)
+{
+  const int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | 
ANIMFILTER_FOREDIT |
+ANIMFILTER_FCURVESONLY);
+  return ANIM_animdata_filter(ac, anim_data, filter, ac->data, ac->datatype);
+}
+
+static int nlaedit_add_actionclip_invoke(bContext *C, wmOperator *op, const 
wmEvent *event)
+{
+  /* Get editor data. */
+  bAnimContext ac;
+  if (ANIM_animdata_get_context(C, ) == 0) {
+return OPERATOR_CANCELLED;
+  }
+
+  ListBase anim_data = {NULL, NULL};
+  const size_t items = nlaedit_get_editable_tracks(, _data);
+
+  if (items == 0) {
+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;
+  }
+
+  return WM_enum_search_invoke(C, op, event);
+}
+
 /* add the specified action as new strip */
 static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op)
 {
@@ -615,8 +645,6 @@ static int nlaedit_add_actionclip_exec(bContext *C, 
wmOperator *op)
 
   ListBase anim_data = {NULL, NULL};
   bAnimListElem *ale;
-  size_t items;
-  int filter;
 
   bAction *act;
 
@@ -654,20 +682,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, 
wmOperator *op)
*/
   nlaedit_add_tracks_empty();
 
-  /* 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
-   */
-  filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT |
-ANIMFILTER_FCURVESONLY);
-  items = ANIM_animdata_filter(, _data, filter, ac.data, ac.datatype);
-
-  if (items == 0) {
-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;
-  }
+  nlaedit_get_editable_tracks(, _data);
 
   /* for every active track,
* try to add strip to free space in track or to the top of the stack if no 
space */
@@ -736,7 +751,7 @@ void NLA_OT_actionclip_add(wmOperatorType *ot)
   "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->invoke = nlaedit_add_actionclip_invoke;
   ot->exec = nlaedit_add_actionclip_exec;
   ot->poll = nlaop_poll_tweakmode_off;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [c36c403cdb7] master: Cleanup: Removed handling of unused flag in TimeMarkers

2022-09-07 Thread Colin Basnett
Commit: c36c403cdb7e8a9d9c0b7aa1765e42fc0e9818d0
Author: Colin Basnett
Date:   Wed Sep 7 18:12:32 2022 -0700
Branches: master
https://developer.blender.org/rBc36c403cdb7e8a9d9c0b7aa1765e42fc0e9818d0

Cleanup: Removed handling of unused flag in TimeMarkers

This removes the defunct handling of the ACTIVE flag in
TimeMarker::flags. It's not possible for that flag to be set though
normal operation.

Differential Revision: https://developer.blender.org/D15828

===

M   source/blender/editors/animation/anim_markers.c

===

diff --git a/source/blender/editors/animation/anim_markers.c 
b/source/blender/editors/animation/anim_markers.c
index 2e324cb3ed8..e96e561c537 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -459,9 +459,7 @@ static void draw_marker_line(const uchar *color, int xpos, 
int ymin, int ymax)
 static int marker_get_icon_id(TimeMarker *marker, int flag)
 {
   if (flag & DRAW_MARKERS_LOCAL) {
-return (marker->flag & ACTIVE) ? ICON_PMARKER_ACT :
-   (marker->flag & SELECT) ? ICON_PMARKER_SEL :
- ICON_PMARKER;
+return (marker->flag & SELECT) ? ICON_PMARKER_SEL : ICON_PMARKER;
   }
 #ifdef DURIAN_CAMERA_SWITCH
   if (marker->camera) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f5234474bde] master: Fix T97618: Clipped text labels intermittently missing ellipses

2022-08-17 Thread Colin Basnett
Commit: f5234474bde953356c72633bd05a1c6c9f747758
Author: Colin Basnett
Date:   Thu Aug 18 10:15:27 2022 +1000
Branches: master
https://developer.blender.org/rBf5234474bde953356c72633bd05a1c6c9f747758

Fix T97618: Clipped text labels intermittently missing ellipses

The offending line was attempting to artificially add width to the
length of the string in order to "avoid ellipsing text that nearly
fits". The line doesn't actually appear to do anything beneficial, and
it causes the nasty text bug.

Old:
{F13029695}

New:
{F13327308}

Reviewed By: campbellbarton

Ref D15585

===

M   source/blender/editors/interface/interface_widgets.c

===

diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index 855e72788d2..94e9e98c685 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1524,11 +1524,6 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
  const size_t max_len,
  const char rpart_sep)
 {
-  /* Add some epsilon to OK width, avoids 'ellipsing' text that nearly fits!
-   * Better to have a small piece of the last char cut out,
-   * than two remaining chars replaced by an ellipsis... */
-  okwidth += 1.0f + UI_DPI_FAC;
-
   BLI_assert(str[0]);
 
   /* need to set this first */
@@ -1627,7 +1622,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle,
 strwidth = BLF_width(fstyle->uifont_id, str, max_len);
   }
 
-  BLI_assert(strwidth <= okwidth);
+  BLI_assert((strwidth <= okwidth) || (okwidth <= 0.0f));
 
   return strwidth;
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [9da0cfb86ee] master: Python: Add more useful information when attempting to pass incorrect attributes to GPUVertBuf.attr_fill

2022-08-04 Thread Colin Basnett
Commit: 9da0cfb86ee098b9172da69bb43703aa2efba691
Author: Colin Basnett
Date:   Thu Aug 4 15:51:54 2022 -0700
Branches: master
https://developer.blender.org/rB9da0cfb86ee098b9172da69bb43703aa2efba691

Python: Add more useful information when attempting to pass incorrect 
attributes to GPUVertBuf.attr_fill

This simply adds the name of the incorrect parameter to the error message.

Differential Revision: https://developer.blender.org/D14103

Reviewed by Jeroen Bakker

===

M   source/blender/python/gpu/gpu_py_vertex_buffer.c

===

diff --git a/source/blender/python/gpu/gpu_py_vertex_buffer.c 
b/source/blender/python/gpu/gpu_py_vertex_buffer.c
index ac050128a1d..ab2ff59a689 100644
--- a/source/blender/python/gpu/gpu_py_vertex_buffer.c
+++ b/source/blender/python/gpu/gpu_py_vertex_buffer.c
@@ -292,7 +292,7 @@ static PyObject *pygpu_vertbuf_attr_fill(BPyGPUVertBuf 
*self, PyObject *args, Py
 const char *name = PyUnicode_AsUTF8(identifier);
 id = GPU_vertformat_attr_id_get(format, name);
 if (id == -1) {
-  PyErr_SetString(PyExc_ValueError, "Unknown attribute name");
+  PyErr_Format(PyExc_ValueError, "Unknown attribute '%s'", name);
   return NULL;
 }
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [abc46d5aeb4] master: Fix: Timeline marker names are not correctly clipped in some cases

2022-08-02 Thread Colin Basnett
Commit: abc46d5aeb49a71ad537c86daa3d78451f63e6d3
Author: Colin Basnett
Date:   Tue Aug 2 20:59:44 2022 -0700
Branches: master
https://developer.blender.org/rBabc46d5aeb49a71ad537c86daa3d78451f63e6d3

Fix: Timeline marker names are not correctly clipped in some cases

Timeline marker names are now correctly clipped instead of messily
overlapping each other and being unreadable. This change affects all
the animation editors (graph editor, NLA, action editor etc.) as well
as the VSE.

This also makes a change to when text is elevated. In the previous
behavior, a marker's text would be elevated if it was selected or if
the current frame was <= 4 frames away from the marker. This seems
like a completely arbitrary thing (probably added in to alleviate text
overlapping for markers that the user would be interested in). This
patch changes the behavior such that the marker's text will be elevated
if it is either selected or it is the last marker encountered relative
to the current frame.

===

M   source/blender/editors/animation/anim_markers.c

===

diff --git a/source/blender/editors/animation/anim_markers.c 
b/source/blender/editors/animation/anim_markers.c
index 3608140a29d..e7c7f679b16 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -402,6 +402,7 @@ static void draw_marker_name(const uchar *text_color,
  const uiFontStyle *fstyle,
  TimeMarker *marker,
  float marker_x,
+ float xmax,
  float text_y)
 {
   const char *name = marker->name;
@@ -419,8 +420,16 @@ static void draw_marker_name(const uchar *text_color,
   }
 #endif
 
-  int name_x = marker_x + UI_DPI_ICON_SIZE * 0.6;
-  UI_fontstyle_draw_simple(fstyle, name_x, text_y, name, final_text_color);
+  const int icon_half_width = UI_DPI_ICON_SIZE * 0.6;
+  const struct uiFontStyleDraw_Params fs_params = {.align = 
UI_STYLE_TEXT_LEFT, .word_wrap = 0};
+  const struct rcti rect = {
+  .xmin = marker_x + icon_half_width,
+  .xmax = xmax - icon_half_width,
+  .ymin = text_y,
+  .ymax = text_y,
+  };
+
+  UI_fontstyle_draw(fstyle, , name, strlen(name), final_text_color, 
_params);
 }
 
 static void draw_marker_line(const uchar *color, int xpos, int ymin, int ymax)
@@ -462,8 +471,13 @@ static int marker_get_icon_id(TimeMarker *marker, int flag)
   return (marker->flag & SELECT) ? ICON_MARKER_HLT : ICON_MARKER;
 }
 
-static void draw_marker(
-const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int 
flag, int region_height)
+static void draw_marker(const uiFontStyle *fstyle,
+TimeMarker *marker,
+int xpos,
+int xmax,
+int flag,
+int region_height,
+bool is_elevated)
 {
   uchar line_color[4], text_color[4];
 
@@ -479,12 +493,11 @@ static void draw_marker(
   GPU_blend(GPU_BLEND_NONE);
 
   float name_y = UI_DPI_FAC * 18;
-  /* Give an offset to the marker name when selected,
-   * or when near the current frame (5 frames range, starting from the current 
one). */
-  if ((marker->flag & SELECT) || (cfra - 4 <= marker->frame && marker->frame 
<= cfra)) {
+  /* Give an offset to the marker that is elevated. */
+  if (is_elevated) {
 name_y += UI_DPI_FAC * 10;
   }
-  draw_marker_name(text_color, fstyle, marker, xpos, name_y);
+  draw_marker_name(text_color, fstyle, marker, xpos, xmax, name_y);
 }
 
 static void draw_markers_background(rctf *rect)
@@ -532,6 +545,14 @@ static void get_marker_clip_frame_range(View2D *v2d, float 
xscale, int r_range[2
   r_range[1] = v2d->cur.xmax + font_width_max;
 }
 
+static int markers_frame_sort(const void *a, const void *b)
+{
+  const TimeMarker *marker_a = a;
+  const TimeMarker *marker_b = b;
+
+  return marker_a->frame > marker_b->frame;
+}
+
 void ED_markers_draw(const bContext *C, int flag)
 {
   ListBase *markers = ED_context_get_markers(C);
@@ -561,22 +582,69 @@ void ED_markers_draw(const bContext *C, int flag)
 
   const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
 
-  /* Separate loops in order to draw selected markers on top */
-  LISTBASE_FOREACH (TimeMarker *, marker, markers) {
-if ((marker->flag & SELECT) == 0) {
-  if (marker_is_in_frame_range(marker, clip_frame_range)) {
-draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, 
region->winy);
-  }
+  /* Markers are not stored by frame order, so we need to sort it here. */
+  ListBase sorted_markers;
+
+  BLI_duplicatelist(_markers, markers);
+  BLI_listbase_sort(_markers, markers_frame_sort);
+
+  /**
+   * Set a temporary bit in the marker's flag to indicate

[Bf-blender-cvs] [2f834bfc148] master: Fix T97559: Undoing of NLA strip duplication requires two undo steps

2022-07-19 Thread Colin Basnett
Commit: 2f834bfc14824c224f99ab7d9a9e561fa86aef6b
Author: Colin Basnett
Date:   Tue Jul 19 16:06:00 2022 +0200
Branches: master
https://developer.blender.org/rB2f834bfc14824c224f99ab7d9a9e561fa86aef6b

Fix T97559: Undoing of NLA strip duplication requires two undo steps

Fix the issue where undoing a "duplicate NLA strip" operation would
require two undo steps.

The cause of this was that the operator was not using the operator macro
system to combine both the duplication and the translate operators into
one. Instead, the old code was simply manually invoking invoking the
translate operator after the duplicate operator had completed.

This patch requires the default keymap to be modified to include the two
new macro operators, `NLA_OT_duplicate_move` and
`NLA_OT_duplicate_linked_move` in favour of the old keymap that simply
called `NLA_OT_duplicate` and passed along a `linked` argument.

`duplicate_move` and `duplicate_move_linked` are two different enough
operations to justify having their own operators from user's
point-of-view, especially since we cannot yet have different tool-tips
based on an operator's settings.

Reviewed By: sybren, mont29

Differential Revision: https://developer.blender.org/D15086

===

M   release/scripts/presets/keyconfig/keymap_data/blender_default.py
M   source/blender/editors/include/ED_anim_api.h
M   source/blender/editors/space_api/spacetypes.c
M   source/blender/editors/space_nla/nla_edit.c
M   source/blender/editors/space_nla/nla_ops.c

===

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py 
b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index e1e88a0e48d..d08efc6909b 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -2578,10 +2578,8 @@ def km_nla_editor(params):
 ("nla.soundclip_add", {"type": 'K', "value": 'PRESS', "shift": True}, 
None),
 ("nla.meta_add", {"type": 'G', "value": 'PRESS', "ctrl": True}, None),
 ("nla.meta_remove", {"type": 'G', "value": 'PRESS', "ctrl": True, 
"alt": True}, None),
-("nla.duplicate", {"type": 'D', "value": 'PRESS', "shift": True},
- {"properties": [("linked", False)]}),
-("nla.duplicate", {"type": 'D', "value": 'PRESS', "alt": True},
- {"properties": [("linked", True)]}),
+("nla.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, 
None),
+("nla.duplicate_linked_move", {"type": 'D', "value": 'PRESS', "alt": 
True}, None),
 ("nla.make_single_user", {"type": 'U', "value": 'PRESS'}, None),
 ("nla.delete", {"type": 'X', "value": 'PRESS'}, None),
 ("nla.delete", {"type": 'DEL', "value": 'PRESS'}, None),
diff --git a/source/blender/editors/include/ED_anim_api.h 
b/source/blender/editors/include/ED_anim_api.h
index ac3b4133007..cc3c68abc55 100644
--- a/source/blender/editors/include/ED_anim_api.h
+++ b/source/blender/editors/include/ED_anim_api.h
@@ -1046,6 +1046,8 @@ void ED_keymap_anim(struct wmKeyConfig *keyconf);
 void ED_operatormacros_graph(void);
 /* space_action */
 void ED_operatormacros_action(void);
+/* space_nla*/
+void ED_operatormacros_nla(void);
 
 /** \} */
 
diff --git a/source/blender/editors/space_api/spacetypes.c 
b/source/blender/editors/space_api/spacetypes.c
index d53fe2efb03..3d964a95bc0 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -163,6 +163,7 @@ void ED_spacemacros_init(void)
   ED_operatormacros_sequencer();
   ED_operatormacros_paint();
   ED_operatormacros_gpencil();
+  ED_operatormacros_nla();
 
   /* Register dropboxes (can use macros). */
   ED_dropboxes_ui();
diff --git a/source/blender/editors/space_nla/nla_edit.c 
b/source/blender/editors/space_nla/nla_edit.c
index d1a667c6e4e..801d032a861 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -1216,13 +1216,10 @@ static int nlaedit_duplicate_exec(bContext *C, 
wmOperator *op)
   return OPERATOR_CANCELLED;
 }
 
-static int nlaedit_duplicate_invoke(bContext *C, wmOperator *op, const wmEvent 
*event)
+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_TRANSLATIO

[Bf-blender-cvs] [4812eda3c5d] master: Animation RNA: Add `clear()` method to FCurveKeyframePoints

2022-07-19 Thread Colin Basnett
Commit: 4812eda3c5d14c672e91ef11182e1a875c070b10
Author: Colin Basnett
Date:   Tue Jul 19 15:57:31 2022 +0200
Branches: master
https://developer.blender.org/rB4812eda3c5d14c672e91ef11182e1a875c070b10

Animation RNA: Add `clear()` method to FCurveKeyframePoints

Add `FCurveKeyframePoints.clear()` method to delete all keyframe points
from an FCurve.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15283

===

M   source/blender/makesrna/intern/rna_fcurve.c

===

diff --git a/source/blender/makesrna/intern/rna_fcurve.c 
b/source/blender/makesrna/intern/rna_fcurve.c
index 461536ffb8a..727d329781d 100644
--- a/source/blender/makesrna/intern/rna_fcurve.c
+++ b/source/blender/makesrna/intern/rna_fcurve.c
@@ -1031,6 +1031,13 @@ static void rna_FKeyframe_points_remove(
   rna_tag_animation_update(bmain, id);
 }
 
+static void rna_FKeyframe_points_clear(ID *id, FCurve *fcu, Main *bmain)
+{
+  BKE_fcurve_delete_keys_all(fcu);
+
+  rna_tag_animation_update(bmain, id);
+}
+
 static FCM_EnvelopeData *rna_FModifierEnvelope_points_add(
 ID *id, FModifier *fmod, Main *bmain, ReportList *reports, float frame)
 {
@@ -2310,6 +2317,10 @@ static void rna_def_fcurve_keyframe_points(BlenderRNA 
*brna, PropertyRNA *cprop)
   /* optional */
   RNA_def_boolean(
   func, "fast", 0, "Fast", "Fast keyframe removal to avoid recalculating 
the curve each time");
+
+  func = RNA_def_function(srna, "clear", "rna_FKeyframe_points_clear");
+  RNA_def_function_ui_description(func, "Remove all keyframes from an 
F-Curve");
+  RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_MAIN);
 }
 
 static void rna_def_fcurve(BlenderRNA *brna)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [1e4c557d82b] master: Fix T99039: bpy.ops.sound.mixdown returns indecipherable error

2022-07-16 Thread Colin Basnett
Commit: 1e4c557d82b005578dd2b361701241b66ccee42f
Author: Colin Basnett
Date:   Sat Jul 16 20:57:28 2022 +0200
Branches: master
https://developer.blender.org/rB1e4c557d82b005578dd2b361701241b66ccee42f

Fix T99039: bpy.ops.sound.mixdown returns indecipherable error

Fix for {T99039}.

The problem was that `AUD_mixdown` and `AUD_mixdown_per_channel` were returning 
pointers to freed memory.

Two key changes are made:
1. The return value of those functions now simply return a bool as to whether 
the operation succeeded, instead of an optional error string pointer.
2. The error string buffer is now passed into the function to be filled in case 
an error occurs. In this way, the onus of memory ownership is unamibiguously on 
the caller.

Differential Revision: https://developer.blender.org/D15260

===

M   extern/audaspace/bindings/C/AUD_Special.cpp
M   extern/audaspace/bindings/C/AUD_Special.h
M   source/blender/editors/sound/sound_ops.c

===

diff --git a/extern/audaspace/bindings/C/AUD_Special.cpp 
b/extern/audaspace/bindings/C/AUD_Special.cpp
index 1ce25dcd41c..686187bc70c 100644
--- a/extern/audaspace/bindings/C/AUD_Special.cpp
+++ b/extern/audaspace/bindings/C/AUD_Special.cpp
@@ -270,7 +270,7 @@ AUD_API int AUD_readSound(AUD_Sound* sound, float* buffer, 
int length, int sampl
return length;
 }
 
-AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned 
int length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs 
specs, AUD_Container format, AUD_Codec codec, unsigned int bitrate, 
void(*callback)(float, void*), void* data)
+AUD_API int AUD_mixdown(AUD_Sound* sound, unsigned int start, unsigned int 
length, unsigned int buffersize, const char* filename, AUD_DeviceSpecs specs, 
AUD_Container format, AUD_Codec codec, unsigned int bitrate, 
void(*callback)(float, void*), void* data, char* error, size_t errorsize)
 {
try
{
@@ -282,15 +282,19 @@ AUD_API const char* AUD_mixdown(AUD_Sound* sound, 
unsigned int start, unsigned i
std::shared_ptr writer = 
FileWriter::createWriter(filename, convCToDSpec(specs), 
static_cast(format), static_cast(codec), bitrate);
FileWriter::writeReader(reader, writer, length, buffersize, 
callback, data);
 
-   return nullptr;
+   return 1;
}
catch(Exception& e)
{
-   return e.getMessage().c_str();
+   if(error && errorsize) {
+   std::strncpy(error, e.getMessage().c_str(), errorsize);
+   error[errorsize - 1] = '\0';
+   }
+   return 0;
}
 }
 
-AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int 
start, unsigned int length, unsigned int buffersize, const char* filename, 
AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int 
bitrate, void(*callback)(float, void*), void* data)
+AUD_API int AUD_mixdown_per_channel(AUD_Sound* sound, unsigned int start, 
unsigned int length, unsigned int buffersize, const char* filename, 
AUD_DeviceSpecs specs, AUD_Container format, AUD_Codec codec, unsigned int 
bitrate, void(*callback)(float, void*), void* data, char* error, size_t 
errorsize)
 {
try
{
@@ -328,11 +332,15 @@ AUD_API const char* AUD_mixdown_per_channel(AUD_Sound* 
sound, unsigned int start
reader->seek(start);
FileWriter::writeReader(reader, writers, length, buffersize, 
callback, data);
 
-   return nullptr;
+   return 1;
}
catch(Exception& e)
{
-   return e.getMessage().c_str();
+   if(error && errorsize) {
+   std::strncpy(error, e.getMessage().c_str(), errorsize);
+   error[errorsize - 1] = '\0';
+   }
+   return 0;
}
 }
 
diff --git a/extern/audaspace/bindings/C/AUD_Special.h 
b/extern/audaspace/bindings/C/AUD_Special.h
index 2f5d13c6fd9..1d181d33f87 100644
--- a/extern/audaspace/bindings/C/AUD_Special.h
+++ b/extern/audaspace/bindings/C/AUD_Special.h
@@ -70,13 +70,15 @@ extern AUD_API int AUD_readSound(AUD_Sound* sound, float* 
buffer, int length, in
  * \param bitrate The bitrate for encoding.
  * \param callback A callback function that is called periodically during 
mixdown, reporting progress if length > 0. Can be NULL.
  * \param data Pass through parameter that is passed to the callback.
- * \return An error message or NULL in case of success.
+ * \param error String buffer to copy the error message to in case of failure.
+ * \param errorsize The size of the error buffer.
+ * \return Whether or not the operation succeeded.
  */
-extern AUD_API const char* AUD_mixdown(AUD_Sound* sound, unsigned int start, 
unsigned int length,
+extern AUD

[Bf-blender-cvs] [8e3879ab527] master: Cleanup: Rename & refactor several F-curve functions

2022-07-14 Thread Colin Basnett
Commit: 8e3879ab5276cf24ebd59a7bf0df69232fd5e4e6
Author: Colin Basnett
Date:   Thu Jul 14 10:22:30 2022 +0200
Branches: master
https://developer.blender.org/rB8e3879ab5276cf24ebd59a7bf0df69232fd5e4e6

Cleanup: Rename & refactor several F-curve functions

Rename and refactor several F-curve key manipulation functions, and move
them from `editors` to `blenkernel`.

The functions formerly known as `delete_fcurve_key`,
`delete_fcurve_keys`, and `clear_fcurve_keys` have been moved from
`ED_keyframes_edit.h` to `BKE_fcurve.h` and have been renamed according
to hierarchical naming rules.

Below is a table of the naming changes.

| From | To |
| -- | -- |
| `delete_fcurve_key(fcu, index, do_recalc)` | `BKE_fcurve_delete_key(fcu, 
index)` |
| `delete_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_selected(fcu)` |
| `clear_fcurve_keys(fcu)` | `BKE_fcurve_delete_keys_all(fcu)` |
| `calchandles_fcurve()` | `BKE_fcurve_handles_recalc()` |
| `calchandles_fcurve_ex()`| `BKE_fcurve_handles_recalc_ex()` |

The function formerly known as `delete_fcurve_key` no longer takes a
`do_fast` parameter, which determined whether or not to call
`calchandles_fcurve`. Now, the responsibility is on the caller to run
the new `BKE_fcurve_handles_recalc` function if they have want to
recalculate the handles.

In addition, there is now a new static private function called
`fcurve_bezt_free` which sets the key count to zero and frees the key
array. This function is now used in couple of instances of functionally
equivalent code. Note that `BKE_fcurve_delete_keys_all` is just a
wrapper around `fcurve_bezt_free`.

This change was initially spurred by the fact that `delete_fcurve_keys`
was improperly named; this was a good opportunity to fix the location
and naming of a few of these functions.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15282

===

M   source/blender/blenkernel/BKE_fcurve.h
M   source/blender/blenkernel/intern/action_mirror.c
M   source/blender/blenkernel/intern/fcurve.c
M   source/blender/blenkernel/intern/fmodifier.c
M   source/blender/editors/animation/anim_deps.c
M   source/blender/editors/animation/drivers.c
M   source/blender/editors/animation/fmodifier_ui.c
M   source/blender/editors/animation/keyframes_edit.c
M   source/blender/editors/animation/keyframes_general.c
M   source/blender/editors/animation/keyframing.c
M   source/blender/editors/armature/pose_lib.c
M   source/blender/editors/gpencil/gpencil_convert.c
M   source/blender/editors/include/ED_keyframes_edit.h
M   source/blender/editors/space_action/action_edit.c
M   source/blender/editors/space_graph/graph_buttons.c
M   source/blender/editors/space_graph/graph_edit.c
M   source/blender/editors/space_nla/nla_edit.c
M   source/blender/editors/transform/transform_convert.c
M   source/blender/editors/transform/transform_convert_graph.c
M   source/blender/io/collada/AnimationImporter.cpp
M   source/blender/io/collada/BCAnimationCurve.cpp
M   source/blender/makesrna/intern/rna_fcurve.c
M   source/blender/python/intern/bpy_rna_anim.c

===

diff --git a/source/blender/blenkernel/BKE_fcurve.h 
b/source/blender/blenkernel/BKE_fcurve.h
index 10d9ce3364d..3ccbd2ac1da 100644
--- a/source/blender/blenkernel/BKE_fcurve.h
+++ b/source/blender/blenkernel/BKE_fcurve.h
@@ -463,23 +463,38 @@ bool BKE_fcurve_bezt_subdivide_handles(struct BezTriple 
*bezt,
struct BezTriple *next,
float *r_pdelta);
 
+/**
+ * Delete a keyframe from an F-curve at a specific index.
+ */
+void BKE_fcurve_delete_key(struct FCurve *fcu, int index);
+
+/**
+ * Delete selected keyframes from an F-curve.
+ */
+bool BKE_fcurve_delete_keys_selected(struct FCurve *fcu);
+
+/**
+ * Delete all keyframes from an F-curve.
+ */
+void BKE_fcurve_delete_keys_all(struct FCurve *fcu);
+
 /*  Curve Sanity  */
 
 /**
  * This function recalculates the handles of an F-Curve. Acts based on 
selection with `SELECT`
- * flag. To use a different flag, use #calchandles_fcurve_ex().
+ * flag. To use a different flag, use #BKE_fcurve_handles_recalc_ex().
  *
  * If the BezTriples have been rearranged, sort them first before using this.
  */
-void calchandles_fcurve(struct FCurve *fcu);
+void BKE_fcurve_handles_recalc(struct FCurve *fcu);
 /**
- * Variant of #calchandles_fcurve() that allows calculating based on a 
different select flag.
+ * Variant of #BKE_fcurve_handles_recalc() that allows calculating based on a 
different select flag.
  *
  * \param handle_sel_flag: The flag (bezt.f1/2/3) value to use to determine 
selection.
  * Usually `SELECT`, but may want to use a different one at times
  * (if caller does not operate on selection).
  */
-void calchandles_fcurve_ex(struct FCurve 

[Bf-blender-cvs] [091100bfd75] master: Animation: Add function to remove all FCurves from an Action

2022-06-23 Thread Colin Basnett
Commit: 091100bfd757b886527b465aef19a88ba261d7ec
Author: Colin Basnett
Date:   Thu Jun 23 11:41:44 2022 +0200
Branches: master
https://developer.blender.org/rB091100bfd757b886527b465aef19a88ba261d7ec

Animation: Add function to remove all FCurves from an Action

Add a `BKE_action_fcurves_clear(action)` function, which removes all the
Action's FCurves, and expose it as `ActionFCurves.clear()` in RNA.

This is more ergonomic than calling `remove` on f-curves until the list
is empty.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14660

===

M   source/blender/blenkernel/BKE_action.h
M   source/blender/blenkernel/intern/action.c
M   source/blender/makesrna/intern/rna_action.c

===

diff --git a/source/blender/blenkernel/BKE_action.h 
b/source/blender/blenkernel/BKE_action.h
index d5487b3558a..79d0fe6e20a 100644
--- a/source/blender/blenkernel/BKE_action.h
+++ b/source/blender/blenkernel/BKE_action.h
@@ -92,6 +92,11 @@ bool action_has_motion(const struct bAction *act);
  */
 bool BKE_action_is_cyclic(const struct bAction *act);
 
+/**
+ * Remove all fcurves from the action.
+ */
+void BKE_action_fcurves_clear(struct bAction *act);
+
 /* Action Groups API - */
 
 /**
diff --git a/source/blender/blenkernel/intern/action.c 
b/source/blender/blenkernel/intern/action.c
index 05b51e0c9fa..fee7582acb3 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -1983,3 +1983,16 @@ void BKE_pose_blend_read_expand(BlendExpander *expander, 
bPose *pose)
 BLO_expand(expander, chan->custom);
   }
 }
+
+void BKE_action_fcurves_clear(bAction *act)
+{
+  if (!act) {
+return;
+  }
+  while (act->curves.first) {
+FCurve *fcu = act->curves.first;
+action_groups_remove_channel(act, fcu);
+BKE_fcurve_free(fcu);
+  }
+  DEG_id_tag_update(>id, ID_RECALC_ANIMATION_NO_FLUSH);
+}
diff --git a/source/blender/makesrna/intern/rna_action.c 
b/source/blender/makesrna/intern/rna_action.c
index a1266443631..ac90ec69784 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -168,6 +168,12 @@ static void rna_Action_fcurve_remove(bAction *act, 
ReportList *reports, PointerR
   WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
 }
 
+static void rna_Action_fcurve_clear(bAction *act)
+{
+  BKE_action_fcurves_clear(act);
+  WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
+}
+
 static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[])
 {
   TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker");
@@ -788,6 +794,10 @@ static void rna_def_action_fcurves(BlenderRNA *brna, 
PropertyRNA *cprop)
   parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve to remove");
   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);
   RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0);
+
+  /* Action.fcurves.clear() */
+  func = RNA_def_function(srna, "clear", "rna_Action_fcurve_clear");
+  RNA_def_function_ui_description(func, "Remove all F-Curves");
 }
 
 static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop)

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2ae4397ec99] master: Armature: Add poll message explaining bone groups need pose mode

2022-06-23 Thread Colin Basnett
Commit: 2ae4397ec9905a0055ad80675ade2696137a7ca2
Author: Colin Basnett
Date:   Thu Jun 23 11:21:43 2022 +0200
Branches: master
https://developer.blender.org/rB2ae4397ec9905a0055ad80675ade2696137a7ca2

Armature: Add poll message explaining bone groups need pose mode

Add a poll message to the bone group operators, to explain they only
work in pose mode. Before, the buttons would be greyed out with no
explanation.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D15119

===

M   source/blender/editors/armature/pose_group.c

===

diff --git a/source/blender/editors/armature/pose_group.c 
b/source/blender/editors/armature/pose_group.c
index d0f0bd55eea..1b78d3cc77e 100644
--- a/source/blender/editors/armature/pose_group.c
+++ b/source/blender/editors/armature/pose_group.c
@@ -42,6 +42,7 @@
 static bool pose_group_poll(bContext *C)
 {
   if (!ED_operator_posemode_context(C)) {
+CTX_wm_operator_poll_msg_set(C, "Bone groups can only be edited in pose 
mode");
 return false;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [57816a6435c] master: Dopesheet: Add Custom Properties panel

2022-06-23 Thread Colin Basnett
Commit: 57816a6435c3a6efc98c575ec0a02ad0dd07622c
Author: Colin Basnett
Date:   Thu Jun 23 11:11:53 2022 +0200
Branches: master
https://developer.blender.org/rB57816a6435c3a6efc98c575ec0a02ad0dd07622c

Dopesheet: Add Custom Properties panel

Adds a custom property panel for the active `Action` to the Dopesheet
editor. There was previously no way to edit these properties outside of
the Python API.

This panel will show up when
`context.active_object.animation_data.action` is set.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14646

===

M   release/scripts/startup/bl_ui/space_dopesheet.py

===

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py 
b/release/scripts/startup/bl_ui/space_dopesheet.py
index 3d792eec3e0..d4b55d5e536 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -15,6 +15,8 @@ from bl_ui.properties_grease_pencil_common import (
 GreasePencilLayerDisplayPanel,
 )
 
+from rna_prop_ui import PropertyPanel
+
 ###
 # DopeSheet Filtering - Header Buttons
 
@@ -544,6 +546,20 @@ class DopesheetActionPanelBase:
 col.prop(action, "use_cyclic")
 
 
+class DOPESHEET_PT_custom_props_action(PropertyPanel, Panel):
+bl_space_type = 'DOPESHEET_EDITOR'
+bl_region_type = 'UI'
+bl_context = 'data'
+_context_path = "active_object.animation_data.action"
+_property_type = bpy.types.Action
+
+@classmethod
+def poll(cls, context):
+return context.active_object \
+and context.active_object.animation_data \
+and context.active_object.animation_data.action
+
+
 class DOPESHEET_PT_action(DopesheetActionPanelBase, Panel):
 bl_space_type = 'DOPESHEET_EDITOR'
 bl_category = "Item"
@@ -817,6 +833,7 @@ classes = (
 DOPESHEET_PT_gpencil_layer_adjustments,
 DOPESHEET_PT_gpencil_layer_relations,
 DOPESHEET_PT_gpencil_layer_display,
+DOPESHEET_PT_custom_props_action,
 )
 
 if __name__ == "__main__":  # only for live edit.

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d90b320444d] master: Fix T97533: Extrapolation of NLA strips outside current view are not rendered

2022-06-21 Thread Colin Basnett
Commit: d90b320444d5addf6dc5473dc0b94c975a2f9479
Author: Colin Basnett
Date:   Tue Jun 21 14:43:19 2022 +0200
Branches: master
https://developer.blender.org/rBd90b320444d5addf6dc5473dc0b94c975a2f9479

Fix T97533: Extrapolation of NLA strips outside current view are not rendered

Do a more thorough search for strips that are not visible themselves,
but still influence the viewed time range.

The problem before was that tracks not immediately visible would not be
drawn at all. The strategy for fixing this was to simply include strips
that are visible only because of their extrapolation mode.

To do this, there is now a new function `get_visible_nla_strips` which
gives a first and last `NlaTrack` that needs to  be drawn.

Tagging along with this is the removal of the strip index indicator from
the name on meta tracks. Because of the new structure of the code, it
would incur a performance penalty to restore the previous behavior
(requiring a linear search for the index). Since this number is of
virtually no utility to the user anyways (it has the look & feel of
developer debugging information), this is something I think we can
safely remove without regret.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14738

===

M   source/blender/editors/space_nla/nla_draw.c

===

diff --git a/source/blender/editors/space_nla/nla_draw.c 
b/source/blender/editors/space_nla/nla_draw.c
index 6c631f46069..bb9e201d94a 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -621,7 +621,6 @@ static void nla_draw_strip(SpaceNla *snla,
 static void nla_draw_strip_text(AnimData *adt,
 NlaTrack *nlt,
 NlaStrip *strip,
-int index,
 View2D *v2d,
 float xminc,
 float xmaxc,
@@ -636,7 +635,7 @@ static void nla_draw_strip_text(AnimData *adt,
 
   /* 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);
+str_len = BLI_snprintf_rlen(str, sizeof(str), "Temp-Meta");
   }
   else {
 str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str));
@@ -702,6 +701,89 @@ static void nla_draw_strip_frames_text(
 
 /* -- */
 
+/**
+ * Gets the first and last visible NLA strips on a track.
+ * Note that this also includes tracks that might only be
+ * visible because of their extendmode.
+ */
+static ListBase get_visible_nla_strips(NlaTrack *nlt, View2D *v2d)
+{
+  if (BLI_listbase_is_empty(>strips)) {
+ListBase empty = {NULL, NULL};
+return empty;
+  }
+
+  NlaStrip *first = NULL;
+  NlaStrip *last = NULL;
+
+  /* Find the first strip that is within the bounds of the view. */
+  LISTBASE_FOREACH (NlaStrip *, strip, >strips) {
+if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) {
+  first = last = strip;
+  break;
+}
+  }
+
+  const bool has_strips_within_bounds = first != NULL;
+
+  if (has_strips_within_bounds) {
+/* Find the last visible strip. */
+for (NlaStrip *strip = first->next; strip; strip = strip->next) {
+  if (!BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) {
+break;
+  }
+  last = strip;
+}
+/* Check if the first strip is adjacent to a strip outside the view to the 
left
+ * that has an extendmode region that should be drawn.
+ * If so, adjust the first strip to include drawing that strip as well.
+ */
+NlaStrip *prev = first->prev;
+if (prev && prev->extendmode != NLASTRIP_EXTEND_NOTHING) {
+  first = prev;
+}
+  }
+  else {
+/* No immediately visible strips.
+ * Figure out where our view is relative to the strips, then determine
+ * if the view is adjacent to a strip that should have its extendmode
+ * rendered.
+ */
+NlaStrip *first_strip = nlt->strips.first;
+NlaStrip *last_strip = nlt->strips.last;
+if (first_strip && v2d->cur.xmax < first_strip->start &&
+first_strip->extendmode == NLASTRIP_EXTEND_HOLD) {
+  /* The view is to the left of all strips and the first strip has an
+   * extendmode that should be drawn.
+   */
+  first = last = first_strip;
+}
+else if (last_strip && v2d->cur.xmin > last_strip->end &&
+ last_strip->extendmode != NLASTRIP_EXTEND_NOTHING) {
+  /* The view is to the right of all strips and the last strip has an
+   * extendmode that should be drawn.
+   */
+  first = last = last_strip;
+}
+else {
+  /* The view is in the middl

[Bf-blender-cvs] [8d53ead69bb] master: Fix T97500: NLA strip names drawn outside strip

2022-05-27 Thread Colin Basnett
Commit: 8d53ead69bb536acb6ce582440df2dec0b53343a
Author: Colin Basnett
Date:   Fri May 27 11:24:03 2022 +0200
Branches: master
https://developer.blender.org/rB8d53ead69bb536acb6ce582440df2dec0b53343a

Fix T97500: NLA strip names drawn outside strip

Fix T97500 by removing the logic that for some unknown reason draws the
entire string if the min/max were swapped.

This function is only called in two places, once here in the NLA, and
the VSE. The bug only materializes in the NLA though.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14742

===

M   source/blender/editors/interface/view2d.cc

===

diff --git a/source/blender/editors/interface/view2d.cc 
b/source/blender/editors/interface/view2d.cc
index 66171dc13e4..6ece7eb4ffa 100644
--- a/source/blender/editors/interface/view2d.cc
+++ b/source/blender/editors/interface/view2d.cc
@@ -2103,21 +2103,12 @@ void UI_view2d_text_cache_draw(ARegion *region)
   col_pack_prev = v2s->col.pack;
 }
 
-if (v2s->rect.xmin >= v2s->rect.xmax) {
-  BLF_draw_default((float)(v2s->mval[0] + xofs),
-   (float)(v2s->mval[1] + yofs),
-   0.0,
-   v2s->str,
-   BLF_DRAW_STR_DUMMY_MAX);
-}
-else {
-  BLF_enable(font_id, BLF_CLIPPING);
-  BLF_clipping(
-  font_id, v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, 
v2s->rect.ymax + 4);
-  BLF_draw_default(
-  v2s->rect.xmin + xofs, v2s->rect.ymin + yofs, 0.0f, v2s->str, 
BLF_DRAW_STR_DUMMY_MAX);
-  BLF_disable(font_id, BLF_CLIPPING);
-}
+BLF_enable(font_id, BLF_CLIPPING);
+BLF_clipping(
+font_id, v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, 
v2s->rect.ymax + 4);
+BLF_draw_default(
+v2s->rect.xmin + xofs, v2s->rect.ymin + yofs, 0.0f, v2s->str, 
BLF_DRAW_STR_DUMMY_MAX);
+BLF_disable(font_id, BLF_CLIPPING);
   }
   g_v2d_strings = nullptr;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f45a735aad0] master: Fix T97974: Marker line affected by NLA strip mute

2022-05-27 Thread Colin Basnett
Commit: f45a735aad00cb20ba465069156bff79a7634072
Author: Colin Basnett
Date:   Fri May 27 11:11:27 2022 +0200
Branches: master
https://developer.blender.org/rBf45a735aad00cb20ba465069156bff79a7634072

Fix T97974: Marker line affected by NLA strip mute

Fix T97974 by having the marker rendering code explicitly set the
required line width.

Reviewed By: sybren

Differential Revision: https://developer.blender.org/D14890

===

M   source/blender/editors/animation/anim_markers.c

===

diff --git a/source/blender/editors/animation/anim_markers.c 
b/source/blender/editors/animation/anim_markers.c
index 1a3ab100768..8519b2061f2 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -543,6 +543,9 @@ void ED_markers_draw(const bContext *C, int flag)
   View2D *v2d = UI_view2d_fromcontext(C);
   int cfra = CTX_data_scene(C)->r.cfra;
 
+  const float line_width = GPU_line_width_get();
+  GPU_line_width(1.0f);
+
   rctf markers_region_rect;
   get_marker_region_rect(v2d, _region_rect);
 
@@ -575,6 +578,7 @@ void ED_markers_draw(const bContext *C, int flag)
 }
   }
 
+  GPU_line_width(line_width);
   GPU_matrix_pop();
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [4ac6177b8d6] master: Fix T97529: NLA track buttons still work when hidden

2022-05-09 Thread Colin Basnett
Commit: 4ac6177b8d676d9e678126af71067cad3674ff3b
Author: Colin Basnett
Date:   Mon May 9 12:12:20 2022 +0200
Branches: master
https://developer.blender.org/rB4ac6177b8d676d9e678126af71067cad3674ff3b

Fix T97529: NLA track buttons still work when hidden

NLA track option buttons (lock track, etc.) now no longer respond to
clicks when they are hidden.

The bug stems from the fact that there was duplicate input handling
going on for the buttons: once in the normal button UI system, and then
again in the `mouse_nla_channels` function. The logic in
`mouse_nla_channels` does not inspect whether or not the setting button
is there or not, it just assumes that it is.

This function should no longer be handling mouse input for buttons
(there is even comment suggesting that the button handling to be
deprecated) since the button UI system already handles it. Therefore,
the button handling code has been removed from that
`mouse_nla_channels`.

In addition, the redundant mouse button handling for pressing the "Push
Down Action" button has also been removed from this function as well.

Reviewed By: sybren, lichtwerk

Differential Revision: https://developer.blender.org/D14868

===

M   source/blender/editors/space_nla/nla_channels.c

===

diff --git a/source/blender/editors/space_nla/nla_channels.c 
b/source/blender/editors/space_nla/nla_channels.c
index 8b059b33a9a..40082b08806 100644
--- a/source/blender/editors/space_nla/nla_channels.c
+++ b/source/blender/editors/space_nla/nla_channels.c
@@ -58,14 +58,12 @@
  * --> Most channels are now selection only.
  */
 
-static int mouse_nla_channels(
-bContext *C, bAnimContext *ac, float x, int channel_index, short 
selectmode)
+static int mouse_nla_channels(bContext *C, bAnimContext *ac, int 
channel_index, short selectmode)
 {
   ListBase anim_data = {NULL, NULL};
   bAnimListElem *ale;
   int filter;
 
-  View2D *v2d = >region->v2d;
   int notifierFlags = 0;
 
   /* get the channel that was clicked on */
@@ -203,47 +201,8 @@ static int mouse_nla_channels(
 }
 case ANIMTYPE_NLATRACK: {
   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 */
-if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) {
-  offset = 21 + NLACHANNEL_BUTTON_WIDTH;
-}
-else {
-  offset = 14;
-}
-  }
-  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);
-ale->update |= ANIM_UPDATE_DEPS;
-  }
-  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);
-ale->update |= ANIM_UPDATE_DEPS;
-  }
-  else if (nlaedit_is_tweakmode_on(ac) == 0) {
+  if (nlaedit_is_tweakmode_on(ac) == 0) {
 /* set selection */
 if (selectmode == SELECT_INVERT) {
   /* inverse selection status of this F-Curve only */
@@ -269,61 +228,40 @@ static int mouse_nla_channels(
 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) {
-  /* 'push-down' action - only usable when not in tweak-mode */
-  /* TODO: make this use the operator instead of calling the function 
directly
-   * however, calling the operator requires that we supply the args,
-   * and that works with proper buttons only */
-  BKE_nla_action_pushdown(adt, ID_IS_OVERRIDE_LIBRARY(ale->id));
-}
-else {
-  /* When in tweak-mode, this button becomes the toggle for mapped 
editing. */
-  adt->flag ^= ADT_NLA_EDIT_NOMAP;
-}
+  /* 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 tweak-mode, clicking here gets us out of tweak-mode, as changing 
sele

[Bf-blender-cvs] [9e3bca4d1b1] draw-deferred-compilation-experiment: Fix T97497: NLA strip names are now properly contained within the strip bounds

2022-04-21 Thread Colin Basnett
Commit: 9e3bca4d1b1e2a85c7f37f8f81a2b5c6dd4c7a7e
Author: Colin Basnett
Date:   Thu Apr 21 10:45:17 2022 +0200
Branches: draw-deferred-compilation-experiment
https://developer.blender.org/rB9e3bca4d1b1e2a85c7f37f8f81a2b5c6dd4c7a7e

Fix T97497: NLA strip names are now properly contained within the strip bounds

Very easy fix, the bug seemed to be a result of a typo on the right-most margin.

Old: {F13013777}

New: {F13013782}

Maniphest Tasks: T97497

Differential Revision: https://developer.blender.org/D14711

===

M   source/blender/editors/space_nla/nla_draw.c

===

diff --git a/source/blender/editors/space_nla/nla_draw.c 
b/source/blender/editors/space_nla/nla_draw.c
index eda9f89b51c..80efaf4ed9f 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -744,7 +744,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, 
ARegion *region)
   for (strip = nlt->strips.first, index = 1; strip; strip = 
strip->next, index++) {
 if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, 
v2d->cur.xmax)) {
   const float xminc = strip->start + text_margin_x;
-  const float xmaxc = strip->end + text_margin_x;
+  const float xmaxc = strip->end - text_margin_x;
 
   /* draw the visualization of the strip */
   nla_draw_strip(snla, adt, nlt, strip, v2d, ymin, ymax);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [2882cbe685e] master: Fix T97497: NLA strip names are now properly contained within the strip bounds

2022-04-21 Thread Colin Basnett
Commit: 2882cbe685e7eca2a79438998354035c5d665205
Author: Colin Basnett
Date:   Thu Apr 21 10:45:17 2022 +0200
Branches: master
https://developer.blender.org/rB2882cbe685e7eca2a79438998354035c5d665205

Fix T97497: NLA strip names are now properly contained within the strip bounds

Very easy fix, the bug seemed to be a result of a typo on the right-most margin.

Old: {F13013777}

New: {F13013782}

Maniphest Tasks: T97497

Differential Revision: https://developer.blender.org/D14711

===

M   source/blender/editors/space_nla/nla_draw.c

===

diff --git a/source/blender/editors/space_nla/nla_draw.c 
b/source/blender/editors/space_nla/nla_draw.c
index eda9f89b51c..80efaf4ed9f 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -744,7 +744,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, 
ARegion *region)
   for (strip = nlt->strips.first, index = 1; strip; strip = 
strip->next, index++) {
 if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, 
v2d->cur.xmax)) {
   const float xminc = strip->start + text_margin_x;
-  const float xmaxc = strip->end + text_margin_x;
+  const float xmaxc = strip->end - text_margin_x;
 
   /* draw the visualization of the strip */
   nla_draw_strip(snla, adt, nlt, strip, v2d, ymin, ymax);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [549f68149d8] master: UI: Fix typo in UI description for bpy.types.ActionFCurves.remove function

2022-04-18 Thread Colin Basnett
Commit: 549f68149d8d5a90067d3488ebffb522ff6c3d8c
Author: Colin Basnett
Date:   Mon Apr 18 20:10:56 2022 -0400
Branches: master
https://developer.blender.org/rB549f68149d8d5a90067d3488ebffb522ff6c3d8c

UI: Fix typo in UI description for bpy.types.ActionFCurves.remove function

The UI description for the `bpy.types.ActionFCurves.remove` was incorrect;
seemingly a copy-paste typo from the `rna_Action_groups_remove` function.

Reviewed By: sybren, Blendify

Differential Revision: https://developer.blender.org/D14659

===

M   source/blender/makesrna/intern/rna_action.c

===

diff --git a/source/blender/makesrna/intern/rna_action.c 
b/source/blender/makesrna/intern/rna_action.c
index 11d5298dfd7..76d2087d904 100644
--- a/source/blender/makesrna/intern/rna_action.c
+++ b/source/blender/makesrna/intern/rna_action.c
@@ -783,7 +783,7 @@ static void rna_def_action_fcurves(BlenderRNA *brna, 
PropertyRNA *cprop)
 
   /* Action.fcurves.remove(...) */
   func = RNA_def_function(srna, "remove", "rna_Action_fcurve_remove");
-  RNA_def_function_ui_description(func, "Remove action group");
+  RNA_def_function_ui_description(func, "Remove F-Curve");
   RNA_def_function_flag(func, FUNC_USE_REPORTS);
   parm = RNA_def_pointer(func, "fcurve", "FCurve", "", "F-Curve to remove");
   RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f1ae6952a86] master: Animation: Select markers before/after current frame

2022-04-14 Thread Colin Basnett
Commit: f1ae6952a86ba1b74e0b4a9d50e83d41b2019d1a
Author: Colin Basnett
Date:   Thu Apr 14 11:30:12 2022 +0200
Branches: master
https://developer.blender.org/rBf1ae6952a86ba1b74e0b4a9d50e83d41b2019d1a

Animation: Select markers before/after current frame

Add operator to select markers left/right of the current frame
(including the current frame).

`bpy.ops.marker.select_leftright(mode='LEFT', extend=False)`

`mode` can be either 'LEFT' or 'RIGHT'.

The naming and defaults of the above variables match similar operators
(e.g., `bpy.ops.nla.select_leftright`)

This also adds a new sub-menu to the Marker menu found in animation
editors, exposing both the new `bpy.ops.marker.select_leftright`
operator as well as the `bpy.ops.marker.select_all` operator.

Despite the name "Before Current Frame" and "After Current Frame", it
also selects a marker that falls on the current from for both of the
modes. This is to match the behavior found in the `nla.select_leftright`
operator.

RCS: https://blender.community/c/rightclickselect/OgmG/

Reviewed by: sybren, looch

Differential Revision: https://developer.blender.org/D14176

===

M   release/scripts/startup/bl_ui/space_nla.py
M   release/scripts/startup/bl_ui/space_time.py
M   source/blender/editors/animation/anim_markers.c

===

diff --git a/release/scripts/startup/bl_ui/space_nla.py 
b/release/scripts/startup/bl_ui/space_nla.py
index 99324ac5d50..961d6525a69 100644
--- a/release/scripts/startup/bl_ui/space_nla.py
+++ b/release/scripts/startup/bl_ui/space_nla.py
@@ -150,6 +150,23 @@ class NLA_MT_marker(Menu):
 marker_menu_generic(layout, context)
 
 
+class NLA_MT_marker_select(Menu):
+bl_label = 'Select'
+
+def draw(self, context):
+layout = self.layout
+
+layout.operator("marker.select_all", text="All").action = 'SELECT'
+layout.operator("marker.select_all", text="None").action = 'DESELECT'
+layout.operator("marker.select_all", text="Invert").action = 'INVERT'
+
+layout.separator()
+
+layout.operator("marker.select_leftright", text="Before Current 
Frame").mode = 'LEFT'
+layout.operator("marker.select_leftright", text="After Current 
Frame").mode = 'RIGHT'
+
+
+
 class NLA_MT_edit(Menu):
 bl_label = "Edit"
 
@@ -312,6 +329,7 @@ classes = (
 NLA_MT_view,
 NLA_MT_select,
 NLA_MT_marker,
+NLA_MT_marker_select,
 NLA_MT_add,
 NLA_MT_edit_transform,
 NLA_MT_snap_pie,
diff --git a/release/scripts/startup/bl_ui/space_time.py 
b/release/scripts/startup/bl_ui/space_time.py
index b5b124253f3..13ab6e67b00 100644
--- a/release/scripts/startup/bl_ui/space_time.py
+++ b/release/scripts/startup/bl_ui/space_time.py
@@ -194,6 +194,10 @@ def marker_menu_generic(layout, context):
 
 layout.separator()
 
+layout.menu('NLA_MT_marker_select')
+
+layout.separator()
+
 layout.operator("marker.camera_bind")
 
 layout.separator()
diff --git a/source/blender/editors/animation/anim_markers.c 
b/source/blender/editors/animation/anim_markers.c
index d7bbc0eab2b..1a3ab100768 100644
--- a/source/blender/editors/animation/anim_markers.c
+++ b/source/blender/editors/animation/anim_markers.c
@@ -1464,6 +1464,83 @@ static void MARKER_OT_select_all(wmOperatorType *ot)
 
 /** \} */
 
+/*  */
+/** \name Select Left/Right of Frame
+ * \{ */
+
+typedef enum eMarkers_LeftRightSelect_Mode {
+  MARKERS_LRSEL_LEFT = 0,
+  MARKERS_LRSEL_RIGHT,
+} eMarkers_LeftRightSelect_Mode;
+
+static const EnumPropertyItem prop_markers_select_leftright_modes[] = {
+{MARKERS_LRSEL_LEFT, "LEFT", 0, "Before Current Frame", ""},
+{MARKERS_LRSEL_RIGHT, "RIGHT", 0, "After Current Frame", ""},
+{0, NULL, 0, NULL, NULL},
+};
+
+static void ED_markers_select_leftright(bAnimContext *ac,
+const eMarkers_LeftRightSelect_Mode 
mode,
+const bool extend)
+{
+  ListBase *markers = ac->markers;
+  Scene *scene = ac->scene;
+
+  if (markers == NULL) {
+return;
+  }
+
+  if (!extend) {
+deselect_markers(markers);
+  }
+
+  LISTBASE_FOREACH (TimeMarker *, marker, markers) {
+if ((mode == MARKERS_LRSEL_LEFT && marker->frame <= CFRA) ||
+(mode == MARKERS_LRSEL_RIGHT && marker->frame >= CFRA)) {
+  marker->flag |= SELECT;
+}
+  }
+}
+
+static int ed_marker_select_leftright_exec(bContext *C, wmOperator *op)
+{
+  const eMarkers_LeftRightSelect_Mode mode = RNA_enum_get(op->ptr, "mode");
+  const bool extend = RNA_boolean_get(op->ptr, "extend");

[Bf-blender-cvs] [6f01758b47c] master: Added a "Sharpen Less" kernel for the Filter Compositor node

2022-02-09 Thread Colin Basnett
Commit: 6f01758b47c5cde0f8bf70d67e6240a092c04e27
Author: Colin Basnett
Date:   Wed Feb 9 10:27:35 2022 +0100
Branches: master
https://developer.blender.org/rB6f01758b47c5cde0f8bf70d67e6240a092c04e27

Added a "Sharpen Less" kernel for the Filter Compositor node

Added a new "Sharpen Less" kernel to the filter compositor node. The intent 
here is to provide a much less aggressive sharpening filter that can't simply 
be solved by toning down the factor on the existing sharpen filter.

The existing "Sharpen" filter uses a "box" kernel:

```
-1 -1 -1
-1  9 -1
-1 -1 -1
```

The new "Sharpen Less" filter uses a "diamond" kernel:

```
 0 -1  0
-1  5 -1
 0 -1  0
```

The difference between the two is clear to see in the following side-by-side:

{F12847431}

Below shows the difference between the filtering kernels as applied to a B 
render of Suzanne with the UV grid as a texture. The left side of the render 
using the existing "Sharpen" filter, and the right side showing the new 
"Sharpen Less" filter. Notice that the left side is more aggressive in 
accentuating localized contrasts across the image. This can lead to what 
appears to be aliasing or striations in the resulting image:

{F12847429}

https://developer.blender.org/T95275
https://blender.community/c/rightclickselect/57Kq/?sorting=hot
{F12847428}

Reviewed By: #compositing, jbakker

Differential Revision: https://developer.blender.org/D14019

===

M   source/blender/blenkernel/BKE_node.h
M   source/blender/compositor/nodes/COM_FilterNode.cc
M   source/blender/makesrna/intern/rna_nodetree.c

===

diff --git a/source/blender/blenkernel/BKE_node.h 
b/source/blender/blenkernel/BKE_node.h
index 7ffa180b523..359a5662a13 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1303,12 +1303,13 @@ void BKE_nodetree_remove_layer_n(struct bNodeTree 
*ntree, struct Scene *scene, i
 
 /* filter types */
 #define CMP_FILT_SOFT 0
-#define CMP_FILT_SHARP 1
+#define CMP_FILT_SHARP_BOX 1
 #define CMP_FILT_LAPLACE 2
 #define CMP_FILT_SOBEL 3
 #define CMP_FILT_PREWITT 4
 #define CMP_FILT_KIRSCH 5
 #define CMP_FILT_SHADOW 6
+#define CMP_FILT_SHARP_DIAMOND 7
 
 /* scale node type, in custom1 */
 #define CMP_SCALE_RELATIVE 0
diff --git a/source/blender/compositor/nodes/COM_FilterNode.cc 
b/source/blender/compositor/nodes/COM_FilterNode.cc
index 2108e68cbec..4eca1492fe9 100644
--- a/source/blender/compositor/nodes/COM_FilterNode.cc
+++ b/source/blender/compositor/nodes/COM_FilterNode.cc
@@ -48,7 +48,7 @@ void FilterNode::convert_to_operations(NodeConverter 
,
   2 / 16.0f,
   1 / 16.0f);
   break;
-case CMP_FILT_SHARP:
+case CMP_FILT_SHARP_BOX:
   operation = new ConvolutionFilterOperation();
   operation->set3x3Filter(-1, -1, -1, -1, 9, -1, -1, -1, -1);
   break;
@@ -80,6 +80,10 @@ void FilterNode::convert_to_operations(NodeConverter 
,
   operation = new ConvolutionFilterOperation();
   operation->set3x3Filter(1, 2, 1, 0, 1, 0, -1, -2, -1);
   break;
+case CMP_FILT_SHARP_DIAMOND:
+  operation = new ConvolutionFilterOperation();
+  operation->set3x3Filter(0, -1, 0, -1, 5, -1, 0, -1, 0);
+  break;
 default:
   operation = new ConvolutionFilterOperation();
   operation->set3x3Filter(0, 0, 0, 0, 1, 0, 0, 0, 0);
diff --git a/source/blender/makesrna/intern/rna_nodetree.c 
b/source/blender/makesrna/intern/rna_nodetree.c
index 13c8444de1d..bd74f86c79a 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -465,7 +465,8 @@ static const EnumPropertyItem 
rna_enum_node_tex_dimensions_items[] = {
 
 const EnumPropertyItem rna_enum_node_filter_items[] = {
 {0, "SOFTEN", 0, "Soften", ""},
-{1, "SHARPEN", 0, "Sharpen", ""},
+{1, "SHARPEN", 0, "Box Sharpen", "An aggressive sharpening filter"},
+{7, "SHARPEN_DIAMOND", 0, "Diamond Sharpen", "A moderate sharpening 
filter"},
 {2, "LAPLACE", 0, "Laplace", ""},
 {3, "SOBEL", 0, "Sobel", ""},
 {4, "PREWITT", 0, "Prewitt", ""},

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [f0f189de76a] master: Fix ImBuf.load failure showing filename as garbage bytes

2019-10-01 Thread Colin Basnett
Commit: f0f189de76a3ac44208053a441a81c86718e6ef2
Author: Colin Basnett
Date:   Tue Oct 1 19:36:15 2019 +0200
Branches: master
https://developer.blender.org/rBf0f189de76a3ac44208053a441a81c86718e6ef2

Fix ImBuf.load failure showing filename as garbage bytes

Differential Revision: https://developer.blender.org/D5879

===

M   source/blender/python/generic/imbuf_py_api.c

===

diff --git a/source/blender/python/generic/imbuf_py_api.c 
b/source/blender/python/generic/imbuf_py_api.c
index ff5e4769f19..6a7f899488b 100644
--- a/source/blender/python/generic/imbuf_py_api.c
+++ b/source/blender/python/generic/imbuf_py_api.c
@@ -463,7 +463,7 @@ static PyObject *M_imbuf_load(PyObject *UNUSED(self), 
PyObject *args, PyObject *
 
   const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
   if (file == -1) {
-PyErr_Format(PyExc_IOError, "load: %s, failed to open file '%s'", 
strerror(errno));
+PyErr_Format(PyExc_IOError, "load: %s, failed to open file '%s'", 
strerror(errno), filepath);
 return NULL;
   }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs