Merge branch 'blender-v4.3-release'

This commit is contained in:
Clément Foucault
2024-11-05 16:40:52 +01:00
19 changed files with 75 additions and 31 deletions

View File

@@ -3131,7 +3131,10 @@ static void ui_textedit_set_cursor_pos(uiBut *but, const ARegion *region, const
startx += UI_ICON_SIZE / aspect;
}
}
startx += (UI_TEXT_MARGIN_X * U.widget_unit - U.pixelsize) / aspect;
startx -= U.pixelsize / aspect;
if (!(but->drawflag & UI_BUT_NO_TEXT_PADDING)) {
startx += UI_TEXT_MARGIN_X * U.widget_unit / aspect;
}
/* mouse dragged outside the widget to the left */
if (x < startx) {

View File

@@ -466,25 +466,17 @@ static void draw_keyframes(bAnimContext *ac,
ED_channel_list_free(draw_list);
}
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region)
void draw_channel_strips(bAnimContext *ac,
SpaceAction *saction,
ARegion *region,
ListBase *anim_data)
{
ListBase anim_data = {nullptr, nullptr};
View2D *v2d = &region->v2d;
/* build list of channels to draw */
eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS);
size_t items = ANIM_animdata_filter(
ac, &anim_data, filter, ac->data, eAnimCont_Types(ac->datatype));
const int height = ANIM_UI_get_channels_total_height(v2d, items);
const float pad_bottom = BLI_listbase_is_empty(ac->markers) ? 0 : UI_MARKER_MARGIN_Y;
v2d->tot.ymin = -(height + pad_bottom);
/* Draw the manual frame ranges for actions in the background of the dopesheet.
* The action editor has already drawn the range for its action so it's not needed. */
if (ac->datatype == ANIMCONT_DOPESHEET) {
draw_channel_action_ranges(&anim_data, v2d);
draw_channel_action_ranges(anim_data, v2d);
}
/* Draw the background strips. */
@@ -496,7 +488,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
GPU_blend(GPU_BLEND_ALPHA);
/* first backdrop strips */
draw_backdrops(ac, anim_data, v2d, pos);
draw_backdrops(ac, *anim_data, v2d, pos);
GPU_blend(GPU_BLEND_NONE);
@@ -511,10 +503,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
}
immUnbindProgram();
draw_keyframes(ac, v2d, saction, anim_data);
draw_keyframes(ac, v2d, saction, *anim_data);
/* free temporary channels used for drawing */
ANIM_animdata_freelist(&anim_data);
ANIM_animdata_freelist(anim_data);
}
/** \} */

View File

@@ -37,7 +37,10 @@ void draw_channel_names(bContext *C,
/**
* Draw keyframes in each channel.
*/
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region);
void draw_channel_strips(bAnimContext *ac,
SpaceAction *saction,
ARegion *region,
ListBase /* bAnimListElem */ *anim_data);
void timeline_draw_cache(const SpaceAction *saction, const Object *ob, const Scene *scene);

View File

@@ -163,6 +163,16 @@ static void action_main_region_init(wmWindowManager *wm, ARegion *region)
WM_event_add_keymap_handler(&region->handlers, keymap);
}
static void set_v2d_height(View2D *v2d, const size_t item_count, const bool add_marker_padding)
{
const int height = ANIM_UI_get_channels_total_height(v2d, item_count);
float pad_bottom = add_marker_padding ? UI_MARKER_MARGIN_Y : 0;
/* Add padding for the collapsed redo panel. */
pad_bottom += HEADERY;
v2d->tot.ymin = -(height + pad_bottom);
UI_view2d_curRect_clamp_y(v2d);
}
static void action_main_region_draw(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */
@@ -172,6 +182,19 @@ static void action_main_region_draw(const bContext *C, ARegion *region)
View2D *v2d = &region->v2d;
short marker_flag = 0;
ListBase anim_data = {nullptr, nullptr};
const bool has_anim_context = ANIM_animdata_get_context(C, &ac);
if (has_anim_context) {
/* Build list of channels to draw. */
const eAnimFilter_Flags filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE |
ANIMFILTER_LIST_CHANNELS);
const size_t items = ANIM_animdata_filter(
&ac, &anim_data, filter, ac.data, eAnimCont_Types(ac.datatype));
/* The View2D's height needs to be set before calling UI_view2d_view_ortho because the latter
* uses the View2D's `cur` rect which might be modified when setting the height. */
set_v2d_height(v2d, items, !BLI_listbase_is_empty(ac.markers));
}
UI_view2d_view_ortho(v2d);
/* clear and setup matrix */
@@ -196,8 +219,8 @@ static void action_main_region_draw(const bContext *C, ARegion *region)
}
/* data */
if (ANIM_animdata_get_context(C, &ac)) {
draw_channel_strips(&ac, saction, region);
if (has_anim_context) {
draw_channel_strips(&ac, saction, region, &anim_data);
}
/* markers */
@@ -271,16 +294,6 @@ static void action_channel_region_init(wmWindowManager *wm, ARegion *region)
WM_event_add_keymap_handler(&region->handlers, keymap);
}
static void set_v2d_height(View2D *v2d, const size_t item_count, const bool add_marker_padding)
{
const int height = ANIM_UI_get_channels_total_height(v2d, item_count);
float pad_bottom = add_marker_padding ? UI_MARKER_MARGIN_Y : 0;
/* Add padding for the collapsed redo panel. */
pad_bottom += HEADERY;
v2d->tot.ymin = -(height + pad_bottom);
UI_view2d_curRect_clamp_y(v2d);
}
static void action_channel_region_draw(const bContext *C, ARegion *region)
{
/* draw entirely, view changes should be handled here */

View File

@@ -107,6 +107,7 @@ static void update_depsgraph(ModifierData *md, const ModifierUpdateDepsgraphCont
static void modify_curves(ModifierData &md, const ModifierEvalContext &ctx, Drawing &drawing)
{
auto &amd = reinterpret_cast<GreasePencilArmatureModifierData &>(md);
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &curves = drawing.strokes_for_write();
/* The influence flag is where the "invert" flag is stored,

View File

@@ -550,6 +550,7 @@ static void build_drawing(const GreasePencilBuildModifierData &mmd,
const int current_time,
const float scene_fps)
{
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {

View File

@@ -328,6 +328,7 @@ static void modify_drawing(const GreasePencilDashModifierData &dmd,
const PatternInfo &pattern_info,
bke::greasepencil::Drawing &drawing)
{
modifier::greasepencil::ensure_no_bezier_curves(drawing);
const bke::CurvesGeometry &src_curves = drawing.strokes();
if (src_curves.curve_num == 0) {
return;

View File

@@ -630,6 +630,8 @@ static void modify_drawing(const GreasePencilEnvelopeModifierData &emd,
{
const EnvelopeInfo info = get_envelope_info(emd, ctx);
modifier::greasepencil::ensure_no_bezier_curves(drawing);
IndexMaskMemory mask_memory;
const IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask(
ctx.object, drawing.strokes(), emd.influence, mask_memory);

View File

@@ -154,7 +154,9 @@ static void deform_drawing(const ModifierData &md,
bke::greasepencil::Drawing &drawing)
{
const auto &mmd = reinterpret_cast<const GreasePencilHookModifierData &>(md);
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {
return;
}

View File

@@ -101,6 +101,7 @@ static void modify_curves(ModifierData *md,
Drawing &drawing)
{
const auto *lmd = reinterpret_cast<GreasePencilLatticeModifierData *>(md);
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &curves = drawing.strokes_for_write();
IndexMaskMemory mask_memory;

View File

@@ -110,6 +110,7 @@ static void deform_drawing(const ModifierData &md,
{
const GreasePencilLengthModifierData &mmd =
reinterpret_cast<const GreasePencilLengthModifierData &>(md);
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {

View File

@@ -98,6 +98,7 @@ static void deform_drawing(const GreasePencilNoiseModifierData &mmd,
const int start_frame_number,
bke::greasepencil::Drawing &drawing)
{
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &strokes = drawing.strokes_for_write();
bke::MutableAttributeAccessor attributes = strokes.attributes_for_write();
if (strokes.points_num() == 0) {

View File

@@ -178,6 +178,8 @@ static void modify_drawing(const GreasePencilOutlineModifierData &omd,
bke::greasepencil::Drawing &drawing,
const float4x4 &viewmat)
{
modifier::greasepencil::ensure_no_bezier_curves(drawing);
if (drawing.strokes().curve_num == 0) {
return;
}

View File

@@ -141,6 +141,7 @@ static void modify_drawing(const GreasePencilShrinkwrapModifierData &smd,
const ModifierEvalContext &ctx,
bke::greasepencil::Drawing &drawing)
{
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &curves = drawing.strokes_for_write();
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
const Span<MDeformVert> dverts = curves.deform_verts();

View File

@@ -100,8 +100,10 @@ static void simplify_drawing(const GreasePencilSimplifyModifierData &mmd,
const Object &ob,
bke::greasepencil::Drawing &drawing)
{
IndexMaskMemory memory;
modifier::greasepencil::ensure_no_bezier_curves(drawing);
const bke::CurvesGeometry &curves = drawing.strokes();
IndexMaskMemory memory;
const IndexMask strokes = modifier::greasepencil::get_filtered_stroke_mask(
&ob, curves, mmd.influence, memory);
if (strokes.is_empty()) {

View File

@@ -109,6 +109,7 @@ static void deform_drawing(const ModifierData &md,
return;
}
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry &curves = drawing.strokes_for_write();
if (curves.points_num() == 0) {
return;

View File

@@ -86,6 +86,7 @@ static void subdivide_drawing(ModifierData &md, Object &ob, bke::greasepencil::D
&ob, drawing.strokes_for_write(), mmd.influence, memory);
if (use_catmull_clark) {
modifier::greasepencil::ensure_no_bezier_curves(drawing);
bke::CurvesGeometry subdivided_curves = drawing.strokes();
for ([[maybe_unused]] const int level_i : IndexRange(mmd.level)) {
VArray<int> one_cut = VArray<int>::ForSingle(1, subdivided_curves.points_num());

View File

@@ -31,6 +31,8 @@
#include "UI_interface.hh"
#include "GEO_resample_curves.hh"
namespace blender::modifier::greasepencil {
using bke::greasepencil::Drawing;
@@ -383,4 +385,16 @@ Vector<FrameDrawingInfo> get_drawing_infos_by_frame(GreasePencil &grease_pencil,
return drawing_infos;
}
void ensure_no_bezier_curves(Drawing &drawing)
{
const bke::CurvesGeometry &curves = drawing.strokes();
IndexMaskMemory memory;
const IndexMask bezier_selection = curves.indices_for_curve_type(CURVE_TYPE_BEZIER, memory);
if (bezier_selection.is_empty()) {
return;
}
drawing.strokes_for_write() = geometry::resample_to_evaluated(curves, bezier_selection);
drawing.tag_topology_changed();
}
} // namespace blender::modifier::greasepencil

View File

@@ -82,4 +82,6 @@ Vector<FrameDrawingInfo> get_drawing_infos_by_frame(GreasePencil &grease_pencil,
const IndexMask &layer_mask,
int frame);
void ensure_no_bezier_curves(bke::greasepencil::Drawing &drawing);
} // namespace blender::modifier::greasepencil