Vulkan: Clearing Framebuffer + Scissors #106044
|
@ -1117,7 +1117,7 @@ using GWL_RegistryHandler_UpdateFn = void (*)(GWL_Display *display,
|
|||
using GWL_RegistryEntry_RemoveFn = void (*)(GWL_Display *display, void *user_data, bool on_exit);
|
||||
|
||||
struct GWL_RegistryHandler {
|
||||
/** Pointer to the name (not the name it's self), needed as the values aren't set on startup. */
|
||||
/** Pointer to the name (not the name itself), needed as the values aren't set on startup. */
|
||||
const char *const *interface_p = nullptr;
|
||||
|
||||
/** Add the interface. */
|
||||
|
@ -2017,11 +2017,11 @@ static char *read_file_as_buffer(const int fd, const bool nil_terminate, size_t
|
|||
struct ByteChunk {
|
||||
ByteChunk *next;
|
||||
/* NOTE(@ideasman42): On GNOME-SHELL-43.3, non powers of two values
|
||||
* (1023 or 4088 for e.g.) makes `read()` return longer values than are actually read
|
||||
* (causing uninitialized memory to be used) as well as truncating the end of the buffer.
|
||||
* (1023 or 4088 for e.g.) makes `read()` *intermittently* include uninitialized memory
|
||||
* (failing to read the end of the chunk) as well as truncating the end of the whole buffer.
|
||||
* The WAYLAND spec doesn't mention buffer-size so this may be a bug in GNOME-SHELL.
|
||||
* Whatever the case, using a power of two isn't a problem (besides some slop-space waste).
|
||||
* This works in KDE & WLROOTS based compositors, see: #106040. */
|
||||
* This workaround isn't necessary for KDE & WLROOTS based compositors, see: #106040. */
|
||||
char data[4096];
|
||||
};
|
||||
ByteChunk *chunk_first = nullptr, **chunk_link_p = &chunk_first;
|
||||
|
@ -3627,7 +3627,7 @@ static void tablet_seat_handle_tool_added(void *data,
|
|||
GWL_TabletTool *tablet_tool = new GWL_TabletTool();
|
||||
tablet_tool->seat = seat;
|
||||
|
||||
/* Every tool has it's own cursor wl_surface. */
|
||||
/* Every tool has its own cursor wl_surface. */
|
||||
tablet_tool->wl_surface_cursor = wl_compositor_create_surface(seat->system->wl_compositor());
|
||||
ghost_wl_surface_tag_cursor_tablet(tablet_tool->wl_surface_cursor);
|
||||
|
||||
|
@ -3969,7 +3969,7 @@ static void keyboard_handle_key(void *data,
|
|||
}
|
||||
else if (xkb_keymap_key_repeats(xkb_state_get_keymap(seat->xkb_state), key_code)) {
|
||||
if (etype == GHOST_kEventKeyDown) {
|
||||
/* Any other key-down always cancels (and may start it's own repeat timer). */
|
||||
/* Any other key-down always cancels (and may start its own repeat timer). */
|
||||
timer_action = CANCEL;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -70,7 +70,7 @@ _script_module_dirs = "startup", "modules"
|
|||
# Base scripts, this points to the directory containing: "modules" & "startup" (see `_script_module_dirs`).
|
||||
# In Blender's code-base this is `./scripts`.
|
||||
#
|
||||
# NOTE: in virtually all cases this should match `BLENDER_SYSTEM_SCRIPTS` as this script is it's self a system script,
|
||||
# NOTE: in virtually all cases this should match `BLENDER_SYSTEM_SCRIPTS` as this script is itself a system script,
|
||||
# it must be in the `BLENDER_SYSTEM_SCRIPTS` by definition and there is no need for a look-up from `_bpy_script_paths`.
|
||||
_script_base_dir = _os.path.dirname(_os.path.dirname(_os.path.dirname(_os.path.dirname(__file__))))
|
||||
|
||||
|
|
|
@ -330,6 +330,7 @@ class GRAPH_MT_slider(Menu):
|
|||
layout.operator("graph.blend_to_neighbor", text="Blend to Neighbor")
|
||||
layout.operator("graph.blend_to_default", text="Blend to Default Value")
|
||||
layout.operator("graph.ease", text="Ease")
|
||||
layout.operator("graph.gaussian_smooth", text="Smooth")
|
||||
|
||||
|
||||
class GRAPH_MT_view_pie(Menu):
|
||||
|
|
|
@ -58,7 +58,7 @@ struct bDeformGroup *BKE_object_defgroup_find_name(const struct Object *ob, cons
|
|||
*
|
||||
* \param use_default: How to handle cases where no symmetrical group is found.
|
||||
* - false: sets these indices to -1, indicating the group should be ignored.
|
||||
* - true: sets the index to its location in the array (making the group point to it's self).
|
||||
* - true: sets the index to its location in the array (making the group point to itself).
|
||||
* Enable this for symmetrical actions which apply weight operations on symmetrical vertices
|
||||
* where the symmetrical group will be used (if found), otherwise the same group is used.
|
||||
*
|
||||
|
|
|
@ -392,7 +392,56 @@ void blend_to_default_fcurve(PointerRNA *id_ptr, FCurve *fcu, const float factor
|
|||
move_key(&fcu->bezt[i], key_y_value);
|
||||
}
|
||||
}
|
||||
/* ---------------- */
|
||||
|
||||
void ED_ANIM_get_1d_gauss_kernel(const float sigma, const int kernel_size, double *r_kernel)
|
||||
{
|
||||
BLI_assert(sigma > 0.0f);
|
||||
BLI_assert(kernel_size > 0);
|
||||
const double sigma_sq = 2.0 * sigma * sigma;
|
||||
double sum = 0.0;
|
||||
|
||||
for (int i = 0; i < kernel_size; i++) {
|
||||
const double normalized_index = (double)i / (kernel_size - 1);
|
||||
r_kernel[i] = exp(-normalized_index * normalized_index / sigma_sq);
|
||||
if (i == 0) {
|
||||
sum += r_kernel[i];
|
||||
}
|
||||
else {
|
||||
/* We only calculate half the kernel,
|
||||
* the normalization needs to take that into account. */
|
||||
sum += r_kernel[i] * 2;
|
||||
}
|
||||
}
|
||||
|
||||
/* Normalize kernel values. */
|
||||
for (int i = 0; i < kernel_size; i++) {
|
||||
r_kernel[i] /= sum;
|
||||
}
|
||||
}
|
||||
|
||||
void smooth_fcurve_segment(FCurve *fcu,
|
||||
FCurveSegment *segment,
|
||||
float *samples,
|
||||
const float factor,
|
||||
const int kernel_size,
|
||||
double *kernel)
|
||||
{
|
||||
const int segment_end_index = segment->start_index + segment->length;
|
||||
const int segment_start_x = fcu->bezt[segment->start_index].vec[1][0];
|
||||
for (int i = segment->start_index; i < segment_end_index; i++) {
|
||||
const int sample_index = (int)(fcu->bezt[i].vec[1][0] - segment_start_x) + kernel_size;
|
||||
/* Apply the kernel. */
|
||||
double filter_result = samples[sample_index] * kernel[0];
|
||||
for (int j = 1; j <= kernel_size; j++) {
|
||||
const double kernel_value = kernel[j];
|
||||
filter_result += samples[sample_index + j] * kernel_value;
|
||||
filter_result += samples[sample_index - j] * kernel_value;
|
||||
}
|
||||
const float key_y_value = interpf((float)filter_result, samples[sample_index], factor);
|
||||
move_key(&fcu->bezt[i], key_y_value);
|
||||
}
|
||||
}
|
||||
/* ---------------- */
|
||||
|
||||
void ease_fcurve_segment(FCurve *fcu, FCurveSegment *segment, const float factor)
|
||||
|
@ -680,6 +729,16 @@ typedef struct TempFrameValCache {
|
|||
float frame, val;
|
||||
} TempFrameValCache;
|
||||
|
||||
void sample_fcurve_segment(FCurve *fcu,
|
||||
const float start_frame,
|
||||
float *samples,
|
||||
const int sample_count)
|
||||
{
|
||||
for (int i = 0; i < sample_count; i++) {
|
||||
samples[i] = evaluate_fcurve(fcu, start_frame + i);
|
||||
}
|
||||
}
|
||||
|
||||
void sample_fcurve(FCurve *fcu)
|
||||
{
|
||||
BezTriple *bezt, *start = NULL, *end = NULL;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "BKE_asset.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_icons.h"
|
||||
#include "BKE_idtype.h"
|
||||
#include "BKE_lib_id.h"
|
||||
|
@ -52,7 +53,7 @@ void ED_asset_generate_preview(const bContext *C, ID *id)
|
|||
BKE_previewimg_clear(preview);
|
||||
}
|
||||
|
||||
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, true);
|
||||
UI_icon_render_id(C, nullptr, id, ICON_SIZE_PREVIEW, !G.background);
|
||||
}
|
||||
|
||||
bool ED_asset_clear_id(ID *id)
|
||||
|
|
|
@ -425,6 +425,17 @@ void blend_to_neighbor_fcurve_segment(struct FCurve *fcu,
|
|||
struct FCurveSegment *segment,
|
||||
float factor);
|
||||
void breakdown_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor);
|
||||
/** Get a 1D gauss kernel. Since the kernel is symmetrical, only calculates the positive side.
|
||||
* \param sigma The shape of the gauss distribution.
|
||||
* \param kernel_size How long the kernel array is.
|
||||
*/
|
||||
void ED_ANIM_get_1d_gauss_kernel(const float sigma, int kernel_size, double *r_kernel);
|
||||
void smooth_fcurve_segment(struct FCurve *fcu,
|
||||
struct FCurveSegment *segment,
|
||||
float *samples,
|
||||
float factor,
|
||||
int kernel_size,
|
||||
double *kernel);
|
||||
void ease_fcurve_segment(struct FCurve *fcu, struct FCurveSegment *segment, float factor);
|
||||
bool decimate_fcurve(struct bAnimListElem *ale, float remove_ratio, float error_sq_max);
|
||||
void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, float factor);
|
||||
|
@ -433,6 +444,10 @@ void blend_to_default_fcurve(struct PointerRNA *id_ptr, struct FCurve *fcu, floa
|
|||
*/
|
||||
void smooth_fcurve(struct FCurve *fcu);
|
||||
void sample_fcurve(struct FCurve *fcu);
|
||||
void sample_fcurve_segment(struct FCurve *fcu,
|
||||
float start_frame,
|
||||
float *r_samples,
|
||||
int sample_count);
|
||||
|
||||
/* ----------- */
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class AbstractView {
|
|||
* \note This drop target may be requested for each event. The view doesn't keep the drop target
|
||||
* around currently. So it cannot contain persistent state.
|
||||
*/
|
||||
virtual std::unique_ptr<AbstractViewDropTarget> create_drop_target() const;
|
||||
virtual std::unique_ptr<AbstractViewDropTarget> create_drop_target();
|
||||
|
||||
/** Listen to a notifier, returning true if a redraw is needed. */
|
||||
virtual bool listen(const wmNotifier &) const;
|
||||
|
@ -166,7 +166,7 @@ class AbstractViewItem {
|
|||
* \note This drop target may be requested for each event. The view doesn't keep a drop target
|
||||
* around currently. So it can not contain persistent state.
|
||||
*/
|
||||
virtual std::unique_ptr<AbstractViewItemDropTarget> create_drop_target() const;
|
||||
virtual std::unique_ptr<AbstractViewItemDropTarget> create_drop_target();
|
||||
|
||||
/** Get the view this item is registered for using #AbstractView::register_item(). */
|
||||
AbstractView &get_view() const;
|
||||
|
|
|
@ -111,8 +111,8 @@ bool drop_target_apply_drop(bContext &C,
|
|||
*/
|
||||
char *drop_target_tooltip(const DropTargetInterface &drop_target, const wmDrag &drag);
|
||||
|
||||
std::unique_ptr<DropTargetInterface> view_drop_target(const uiViewHandle *view_handle);
|
||||
std::unique_ptr<DropTargetInterface> view_item_drop_target(const uiViewItemHandle *item_handle);
|
||||
std::unique_ptr<DropTargetInterface> view_drop_target(uiViewHandle *view_handle);
|
||||
std::unique_ptr<DropTargetInterface> view_item_drop_target(uiViewItemHandle *item_handle);
|
||||
/**
|
||||
* Try to find a view item with a drop target under the mouse cursor, or if not found, a view
|
||||
* with a drop target.
|
||||
|
|
|
@ -2014,7 +2014,11 @@ void UI_block_end_ex(const bContext *C, uiBlock *block, const int xy[2], int r_x
|
|||
break;
|
||||
}
|
||||
|
||||
ui_block_views_bounds_calc(block);
|
||||
/* Update bounds of all views in this block. If this block is a panel, this will be done later in
|
||||
* #UI_panels_end(), because buttons are offset there. */
|
||||
if (!block->panel) {
|
||||
ui_block_views_bounds_calc(block);
|
||||
}
|
||||
|
||||
if (block->rect.xmin == 0.0f && block->rect.xmax == 0.0f) {
|
||||
UI_block_bounds_set_normal(block, 0);
|
||||
|
|
|
@ -1831,6 +1831,10 @@ void UI_panels_end(const bContext *C, ARegion *region, int *r_x, int *r_y)
|
|||
LISTBASE_FOREACH (uiBlock *, block, ®ion->uiblocks) {
|
||||
if (block->active && block->panel) {
|
||||
ui_offset_panel_block(block);
|
||||
|
||||
/* Update bounds for all "views" in this block. Usually this is done in #UI_block_end(), but
|
||||
* that wouldn't work because of the offset applied above. */
|
||||
ui_block_views_bounds_calc(block);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ void AbstractView::update_from_old(uiBlock &new_block)
|
|||
/** \name Default implementations of virtual functions
|
||||
* \{ */
|
||||
|
||||
std::unique_ptr<AbstractViewDropTarget> AbstractView::create_drop_target() const
|
||||
std::unique_ptr<AbstractViewDropTarget> AbstractView::create_drop_target()
|
||||
{
|
||||
/* There's no drop target (and hence no drop support) by default. */
|
||||
return nullptr;
|
||||
|
@ -121,9 +121,9 @@ std::optional<rcti> AbstractView::get_bounds() const
|
|||
/** \name General API functions
|
||||
* \{ */
|
||||
|
||||
std::unique_ptr<DropTargetInterface> view_drop_target(const uiViewHandle *view_handle)
|
||||
std::unique_ptr<DropTargetInterface> view_drop_target(uiViewHandle *view_handle)
|
||||
{
|
||||
const AbstractView &view = reinterpret_cast<const AbstractView &>(*view_handle);
|
||||
AbstractView &view = reinterpret_cast<AbstractView &>(*view_handle);
|
||||
return view.create_drop_target();
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ std::unique_ptr<AbstractViewItemDragController> AbstractViewItem::create_drag_co
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractViewItemDropTarget> AbstractViewItem::create_drop_target() const
|
||||
std::unique_ptr<AbstractViewItemDropTarget> AbstractViewItem::create_drop_target()
|
||||
{
|
||||
/* There's no drop target (and hence no drop support) by default. */
|
||||
return nullptr;
|
||||
|
@ -221,9 +221,9 @@ bool AbstractViewItem::is_active() const
|
|||
/** \name General API functions
|
||||
* \{ */
|
||||
|
||||
std::unique_ptr<DropTargetInterface> view_item_drop_target(const uiViewItemHandle *item_handle)
|
||||
std::unique_ptr<DropTargetInterface> view_item_drop_target(uiViewItemHandle *item_handle)
|
||||
{
|
||||
const AbstractViewItem &item = reinterpret_cast<const AbstractViewItem &>(*item_handle);
|
||||
AbstractViewItem &item = reinterpret_cast<AbstractViewItem &>(*item_handle);
|
||||
return item.create_drop_target();
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ namespace blender::ui {
|
|||
std::unique_ptr<DropTargetInterface> region_views_find_drop_target_at(const ARegion *region,
|
||||
const int xy[2])
|
||||
{
|
||||
const uiViewItemHandle *hovered_view_item = UI_region_views_find_item_at(region, xy);
|
||||
uiViewItemHandle *hovered_view_item = UI_region_views_find_item_at(region, xy);
|
||||
if (hovered_view_item) {
|
||||
std::unique_ptr<DropTargetInterface> drop_target = view_item_drop_target(hovered_view_item);
|
||||
if (drop_target) {
|
||||
|
@ -204,7 +204,7 @@ std::unique_ptr<DropTargetInterface> region_views_find_drop_target_at(const AReg
|
|||
|
||||
/* Get style for some sensible padding around the view items. */
|
||||
const uiStyle *style = UI_style_get_dpi();
|
||||
const uiViewHandle *hovered_view = UI_region_view_find_at(region, xy, style->buttonspacex);
|
||||
uiViewHandle *hovered_view = UI_region_view_find_at(region, xy, style->buttonspacex);
|
||||
if (hovered_view) {
|
||||
std::unique_ptr<DropTargetInterface> drop_target = view_drop_target(hovered_view);
|
||||
if (drop_target) {
|
||||
|
|
|
@ -344,9 +344,9 @@ static void um_arraystore_compact_ex(UndoMesh *um, const UndoMesh *um_ref, bool
|
|||
/* Compacting can be time consuming, run in parallel.
|
||||
*
|
||||
* NOTE(@ideasman42): this could be further parallelized with every custom-data layer
|
||||
* running in it's own thread. If this is a bottleneck it's worth considering.
|
||||
* At the moment it seems fast enough to split by element type.
|
||||
* Since this is it's self a background thread, using too many threads here could
|
||||
* running in its own thread. If this is a bottleneck it's worth considering.
|
||||
* At the moment it seems fast enough to split by domain.
|
||||
* Since this is itself a background thread, using too many threads here could
|
||||
* interfere with foreground tasks. */
|
||||
blender::threading::parallel_invoke(
|
||||
4096 < (me->totvert + me->totedge + me->totloop + me->totpoly),
|
||||
|
|
|
@ -90,7 +90,7 @@ class AssetCatalogTreeViewItem : public ui::BasicTreeViewItem {
|
|||
/** Add drag support for catalog items. */
|
||||
std::unique_ptr<ui::AbstractViewItemDragController> create_drag_controller() const override;
|
||||
/** Add dropping support for catalog items. */
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> create_drop_target() const override;
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> create_drop_target() override;
|
||||
};
|
||||
|
||||
class AssetCatalogDragController : public ui::AbstractViewItemDragController {
|
||||
|
@ -154,7 +154,7 @@ class AssetCatalogTreeViewAllItem : public ui::BasicTreeViewItem {
|
|||
bool on_drop(struct bContext *C, const wmDrag &drag) const override;
|
||||
};
|
||||
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> create_drop_target() const override;
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> create_drop_target() override;
|
||||
};
|
||||
|
||||
class AssetCatalogTreeViewUnassignedItem : public ui::BasicTreeViewItem {
|
||||
|
@ -168,7 +168,7 @@ class AssetCatalogTreeViewUnassignedItem : public ui::BasicTreeViewItem {
|
|||
bool on_drop(struct bContext *C, const wmDrag &drag) const override;
|
||||
};
|
||||
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> create_drop_target() const override;
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> create_drop_target() override;
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -340,7 +340,6 @@ bool AssetCatalogTreeViewItem::rename(StringRefNull new_name)
|
|||
}
|
||||
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> AssetCatalogTreeViewItem::create_drop_target()
|
||||
const
|
||||
{
|
||||
return std::make_unique<AssetCatalogDropTarget>(
|
||||
static_cast<AssetCatalogTreeView &>(get_tree_view()), catalog_item_);
|
||||
|
@ -580,7 +579,6 @@ void AssetCatalogTreeViewAllItem::build_row(uiLayout &row)
|
|||
}
|
||||
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> AssetCatalogTreeViewAllItem::create_drop_target()
|
||||
const
|
||||
{
|
||||
return std::make_unique<AssetCatalogTreeViewAllItem::DropTarget>(
|
||||
static_cast<AssetCatalogTreeView &>(get_tree_view()));
|
||||
|
@ -635,7 +633,7 @@ bool AssetCatalogTreeViewAllItem::DropTarget::on_drop(struct bContext * /*C*/,
|
|||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
std::unique_ptr<ui::AbstractViewItemDropTarget> AssetCatalogTreeViewUnassignedItem::
|
||||
create_drop_target() const
|
||||
create_drop_target()
|
||||
{
|
||||
return std::make_unique<AssetCatalogTreeViewUnassignedItem::DropTarget>(
|
||||
static_cast<AssetCatalogTreeView &>(get_tree_view()));
|
||||
|
|
|
@ -116,6 +116,7 @@ void GRAPH_OT_breakdown(struct wmOperatorType *ot);
|
|||
void GRAPH_OT_ease(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_decimate(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_blend_to_default(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_gaussian_smooth(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_sample(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_bake(struct wmOperatorType *ot);
|
||||
void GRAPH_OT_unbake(struct wmOperatorType *ot);
|
||||
|
|
|
@ -464,6 +464,7 @@ void graphedit_operatortypes(void)
|
|||
WM_operatortype_append(GRAPH_OT_breakdown);
|
||||
WM_operatortype_append(GRAPH_OT_ease);
|
||||
WM_operatortype_append(GRAPH_OT_blend_to_default);
|
||||
WM_operatortype_append(GRAPH_OT_gaussian_smooth);
|
||||
WM_operatortype_append(GRAPH_OT_euler_filter);
|
||||
WM_operatortype_append(GRAPH_OT_delete);
|
||||
WM_operatortype_append(GRAPH_OT_duplicate);
|
||||
|
|
|
@ -69,6 +69,10 @@ typedef struct tGraphSliderOp {
|
|||
/* Each operator has a specific update function. */
|
||||
void (*modal_update)(struct bContext *, struct wmOperator *);
|
||||
|
||||
/* If an operator stores custom data, it also needs to provide the function to clean it up. */
|
||||
void *operator_data;
|
||||
void (*free_operator_data)(void *operator_data);
|
||||
|
||||
NumInput num;
|
||||
} tGraphSliderOp;
|
||||
|
||||
|
@ -191,6 +195,10 @@ static void graph_slider_exit(bContext *C, wmOperator *op)
|
|||
return;
|
||||
}
|
||||
|
||||
if (gso->free_operator_data != NULL) {
|
||||
gso->free_operator_data(gso->operator_data);
|
||||
}
|
||||
|
||||
ScrArea *area = gso->area;
|
||||
LinkData *link;
|
||||
|
||||
|
@ -1053,3 +1061,258 @@ void GRAPH_OT_ease(wmOperatorType *ot)
|
|||
}
|
||||
|
||||
/** \} */
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Gauss Smooth Operator
|
||||
* \{ */
|
||||
|
||||
/* It is necessary to store data for smoothing when running in modal, because the sampling of
|
||||
* FCurves shouldn't be done on every update. */
|
||||
typedef struct tGaussOperatorData {
|
||||
double *kernel;
|
||||
ListBase segment_links; /* tFCurveSegmentLink */
|
||||
ListBase anim_data; /* bAnimListElem */
|
||||
} tGaussOperatorData;
|
||||
|
||||
/* Store data to smooth an FCurve segment. */
|
||||
typedef struct tFCurveSegmentLink {
|
||||
struct tFCurveSegmentLink *prev, *next;
|
||||
FCurve *fcu;
|
||||
FCurveSegment *segment;
|
||||
float *samples; /* Array of y-values of the FCurve segment. */
|
||||
} tFCurveSegmentLink;
|
||||
|
||||
static void gaussian_smooth_allocate_operator_data(tGraphSliderOp *gso,
|
||||
const int filter_width,
|
||||
const float sigma)
|
||||
{
|
||||
tGaussOperatorData *operator_data = MEM_callocN(sizeof(tGaussOperatorData),
|
||||
"tGaussOperatorData");
|
||||
const int kernel_size = filter_width + 1;
|
||||
double *kernel = MEM_callocN(sizeof(double) * kernel_size, "Gauss Kernel");
|
||||
ED_ANIM_get_1d_gauss_kernel(sigma, kernel_size, kernel);
|
||||
operator_data->kernel = kernel;
|
||||
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
ANIM_animdata_filter(&gso->ac, &anim_data, OPERATOR_DATA_FILTER, gso->ac.data, gso->ac.datatype);
|
||||
|
||||
ListBase segment_links = {NULL, NULL};
|
||||
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
ListBase fcu_segments = find_fcurve_segments(fcu);
|
||||
LISTBASE_FOREACH (FCurveSegment *, segment, &fcu_segments) {
|
||||
tFCurveSegmentLink *segment_link = MEM_callocN(sizeof(tFCurveSegmentLink),
|
||||
"FCurve Segment Link");
|
||||
segment_link->fcu = fcu;
|
||||
segment_link->segment = segment;
|
||||
BezTriple left_bezt = fcu->bezt[segment->start_index];
|
||||
BezTriple right_bezt = fcu->bezt[segment->start_index + segment->length - 1];
|
||||
const int sample_count = (int)(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
|
||||
(filter_width * 2 + 1);
|
||||
float *samples = MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples");
|
||||
sample_fcurve_segment(fcu, left_bezt.vec[1][0] - filter_width, samples, sample_count);
|
||||
segment_link->samples = samples;
|
||||
BLI_addtail(&segment_links, segment_link);
|
||||
}
|
||||
}
|
||||
|
||||
operator_data->anim_data = anim_data;
|
||||
operator_data->segment_links = segment_links;
|
||||
gso->operator_data = operator_data;
|
||||
}
|
||||
|
||||
static void gaussian_smooth_free_operator_data(void *operator_data)
|
||||
{
|
||||
tGaussOperatorData *gauss_data = (tGaussOperatorData *)operator_data;
|
||||
LISTBASE_FOREACH (tFCurveSegmentLink *, segment_link, &gauss_data->segment_links) {
|
||||
MEM_freeN(segment_link->samples);
|
||||
MEM_freeN(segment_link->segment);
|
||||
}
|
||||
MEM_freeN(gauss_data->kernel);
|
||||
BLI_freelistN(&gauss_data->segment_links);
|
||||
ANIM_animdata_freelist(&gauss_data->anim_data);
|
||||
MEM_freeN(gauss_data);
|
||||
}
|
||||
|
||||
static void gaussian_smooth_draw_status_header(bContext *C, tGraphSliderOp *gso)
|
||||
{
|
||||
char status_str[UI_MAX_DRAW_STR];
|
||||
char mode_str[32];
|
||||
char slider_string[UI_MAX_DRAW_STR];
|
||||
|
||||
ED_slider_status_string_get(gso->slider, slider_string, UI_MAX_DRAW_STR);
|
||||
|
||||
strcpy(mode_str, TIP_("Gauss Smooth"));
|
||||
|
||||
if (hasNumInput(&gso->num)) {
|
||||
char str_ofs[NUM_STR_REP_LEN];
|
||||
|
||||
outputNumInput(&gso->num, str_ofs, &gso->scene->unit);
|
||||
|
||||
BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, str_ofs);
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, slider_string);
|
||||
}
|
||||
|
||||
ED_workspace_status_text(C, status_str);
|
||||
}
|
||||
|
||||
static void gaussian_smooth_modal_update(bContext *C, wmOperator *op)
|
||||
{
|
||||
tGraphSliderOp *gso = op->customdata;
|
||||
|
||||
bAnimContext ac;
|
||||
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
gaussian_smooth_draw_status_header(C, gso);
|
||||
|
||||
const float factor = slider_factor_get_and_remember(op);
|
||||
tGaussOperatorData *operator_data = (tGaussOperatorData *)gso->operator_data;
|
||||
const int filter_width = RNA_int_get(op->ptr, "filter_width");
|
||||
|
||||
LISTBASE_FOREACH (tFCurveSegmentLink *, segment, &operator_data->segment_links) {
|
||||
smooth_fcurve_segment(segment->fcu,
|
||||
segment->segment,
|
||||
segment->samples,
|
||||
factor,
|
||||
filter_width,
|
||||
operator_data->kernel);
|
||||
}
|
||||
|
||||
LISTBASE_FOREACH (bAnimListElem *, ale, &operator_data->anim_data) {
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
}
|
||||
|
||||
ANIM_animdata_update(&ac, &operator_data->anim_data);
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
}
|
||||
|
||||
static int gaussian_smooth_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
const int invoke_result = graph_slider_invoke(C, op, event);
|
||||
|
||||
if (invoke_result == OPERATOR_CANCELLED) {
|
||||
return invoke_result;
|
||||
}
|
||||
|
||||
tGraphSliderOp *gso = op->customdata;
|
||||
gso->modal_update = gaussian_smooth_modal_update;
|
||||
gso->factor_prop = RNA_struct_find_property(op->ptr, "factor");
|
||||
|
||||
const float sigma = RNA_float_get(op->ptr, "sigma");
|
||||
const int filter_width = RNA_int_get(op->ptr, "filter_width");
|
||||
|
||||
gaussian_smooth_allocate_operator_data(gso, filter_width, sigma);
|
||||
gso->free_operator_data = gaussian_smooth_free_operator_data;
|
||||
|
||||
ED_slider_allow_overshoot_set(gso->slider, false);
|
||||
ED_slider_factor_set(gso->slider, 0.0f);
|
||||
gaussian_smooth_draw_status_header(C, gso);
|
||||
|
||||
return invoke_result;
|
||||
}
|
||||
|
||||
static void gaussian_smooth_graph_keys(bAnimContext *ac,
|
||||
const float factor,
|
||||
double *kernel,
|
||||
const int filter_width)
|
||||
{
|
||||
ListBase anim_data = {NULL, NULL};
|
||||
ANIM_animdata_filter(ac, &anim_data, OPERATOR_DATA_FILTER, ac->data, ac->datatype);
|
||||
|
||||
LISTBASE_FOREACH (bAnimListElem *, ale, &anim_data) {
|
||||
FCurve *fcu = (FCurve *)ale->key_data;
|
||||
ListBase segments = find_fcurve_segments(fcu);
|
||||
|
||||
LISTBASE_FOREACH (FCurveSegment *, segment, &segments) {
|
||||
BezTriple left_bezt = fcu->bezt[segment->start_index];
|
||||
BezTriple right_bezt = fcu->bezt[segment->start_index + segment->length - 1];
|
||||
const int sample_count = (int)(right_bezt.vec[1][0] - left_bezt.vec[1][0]) +
|
||||
(filter_width * 2 + 1);
|
||||
float *samples = MEM_callocN(sizeof(float) * sample_count, "Smooth FCurve Op Samples");
|
||||
sample_fcurve_segment(fcu, left_bezt.vec[1][0] - filter_width, samples, sample_count);
|
||||
smooth_fcurve_segment(fcu, segment, samples, factor, filter_width, kernel);
|
||||
MEM_freeN(samples);
|
||||
}
|
||||
|
||||
BLI_freelistN(&segments);
|
||||
ale->update |= ANIM_UPDATE_DEFAULT;
|
||||
}
|
||||
|
||||
ANIM_animdata_update(ac, &anim_data);
|
||||
ANIM_animdata_freelist(&anim_data);
|
||||
}
|
||||
|
||||
static int gaussian_smooth_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bAnimContext ac;
|
||||
|
||||
if (ANIM_animdata_get_context(C, &ac) == 0) {
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
const float factor = RNA_float_get(op->ptr, "factor");
|
||||
const int filter_width = RNA_int_get(op->ptr, "filter_width");
|
||||
const int kernel_size = filter_width + 1;
|
||||
double *kernel = MEM_callocN(sizeof(double) * kernel_size, "Gauss Kernel");
|
||||
ED_ANIM_get_1d_gauss_kernel(RNA_float_get(op->ptr, "sigma"), kernel_size, kernel);
|
||||
|
||||
gaussian_smooth_graph_keys(&ac, factor, kernel, filter_width);
|
||||
|
||||
MEM_freeN(kernel);
|
||||
|
||||
/* Set notifier that keyframes have changed. */
|
||||
WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void GRAPH_OT_gaussian_smooth(wmOperatorType *ot)
|
||||
{
|
||||
/* Identifiers. */
|
||||
ot->name = "Gaussian Smooth";
|
||||
ot->idname = "GRAPH_OT_gaussian_smooth";
|
||||
ot->description = "Smooth the curve using a Gauss filter";
|
||||
|
||||
/* API callbacks. */
|
||||
ot->invoke = gaussian_smooth_invoke;
|
||||
ot->modal = graph_slider_modal;
|
||||
ot->exec = gaussian_smooth_exec;
|
||||
ot->poll = graphop_editable_keyframes_poll;
|
||||
|
||||
/* Flags. */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_float_factor(ot->srna,
|
||||
"factor",
|
||||
1.0f,
|
||||
0.0f,
|
||||
FLT_MAX,
|
||||
"Factor",
|
||||
"How much to blend to the default value",
|
||||
0.0f,
|
||||
1.0f);
|
||||
|
||||
RNA_def_float(ot->srna,
|
||||
"sigma",
|
||||
0.33f,
|
||||
0.001f,
|
||||
FLT_MAX,
|
||||
"Sigma",
|
||||
"The shape of the gauss distribution, lower values make it sharper",
|
||||
0.001f,
|
||||
100.0f);
|
||||
|
||||
RNA_def_int(ot->srna,
|
||||
"filter_width",
|
||||
6,
|
||||
1,
|
||||
64,
|
||||
"Filter Width",
|
||||
"How far to each side the operator will average the key values",
|
||||
1,
|
||||
32);
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
* would be used for this purpose. The problem with using poll is once the gizmo is visible again
|
||||
* is there is a visible flicker showing the previous location before cursor motion causes the
|
||||
* pre selection to be updated. While this is only a glitch, it's distracting.
|
||||
* The gizmo system it's self could support this use case by tracking which gizmos draw and ensure
|
||||
* The gizmo system itself could support this use case by tracking which gizmos draw and ensure
|
||||
* gizmos always run #wmGizmoType.test_select before drawing, however pre-selection is already
|
||||
* outside the scope of what gizmos are meant to be used for, so keep this workaround localized
|
||||
* to this gizmo type unless this seems worth supporting for more typical use-cases.
|
||||
|
|
|
@ -374,7 +374,7 @@ typedef struct LineartData {
|
|||
bool do_shadow_cast;
|
||||
bool light_reference_available;
|
||||
|
||||
/* Keep an copy of these data so when line art is running it's self-contained. */
|
||||
/* Keep an copy of these data so when line art is running itself contained. */
|
||||
bool cam_is_persp;
|
||||
/* "Secondary" ones are from viewing camera
|
||||
* (as opposed to shadow camera), during shadow calculation. */
|
||||
|
|
|
@ -526,7 +526,7 @@ static int py_to_array(PyObject *seq,
|
|||
// totdim = RNA_property_array_dimension(ptr, prop, dim_size); /* UNUSED */
|
||||
const int flag = RNA_property_flag(prop);
|
||||
|
||||
/* Use #ParameterDynAlloc which defines it's own array length. */
|
||||
/* Use #ParameterDynAlloc which defines its own array length. */
|
||||
const bool prop_is_param_dyn_alloc = param_data && (flag & PROP_DYNAMIC);
|
||||
|
||||
if (validate_array(seq,
|
||||
|
|
|
@ -129,7 +129,7 @@ wmGizmoGroupTypeRef *WM_gizmogrouptype_append_and_link(wmGizmoMapType *gzmap_typ
|
|||
*/
|
||||
static void gizmogrouptype_free(wmGizmoGroupType *gzgt)
|
||||
{
|
||||
/* Python gizmo group, allocates it's own string. */
|
||||
/* Python gizmo group, allocates its own string. */
|
||||
if (gzgt->rna_ext.srna) {
|
||||
MEM_freeN((void *)gzgt->idname);
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ void WM_gizmotype_append_ptr(void (*gtfunc)(struct wmGizmoType *, void *), void
|
|||
|
||||
void WM_gizmotype_free_ptr(wmGizmoType *gzt)
|
||||
{
|
||||
/* Python gizmo, allocates it's own string. */
|
||||
/* Python gizmo, allocates its own string. */
|
||||
if (gzt->rna_ext.srna) {
|
||||
MEM_freeN((void *)gzt->idname);
|
||||
}
|
||||
|
|
|
@ -1149,7 +1149,7 @@ static void wm_operator_finished(bContext *C,
|
|||
}
|
||||
}
|
||||
else if (has_undo_step) {
|
||||
/* An undo step was added but the operator wasn't registered (and won't register it's self),
|
||||
/* An undo step was added but the operator wasn't registered (and won't register itself),
|
||||
* therefor a redo panel wouldn't redo this action but the previous registered action,
|
||||
* causing the "redo" to remove/loose this operator. See: #101743.
|
||||
* Register check is needed so nested operator calls don't clear the HUD. See: #103587. */
|
||||
|
|
|
@ -1112,7 +1112,7 @@ void wm_homefile_read_ex(bContext *C,
|
|||
const bool use_userdef = params_homefile->use_userdef;
|
||||
bool use_factory_settings = params_homefile->use_factory_settings;
|
||||
/* Currently this only impacts preferences as it doesn't make much sense to keep the default
|
||||
* startup open in the case the app-template doesn't happen to define it's own startup.
|
||||
* startup open in the case the app-template doesn't happen to define its own startup.
|
||||
* Unlike preferences where we might want to only reset the app-template part of the preferences
|
||||
* so as not to reset the preferences for all other Blender instances, see: #96427. */
|
||||
const bool use_factory_settings_app_template_only =
|
||||
|
@ -1604,7 +1604,7 @@ static void wm_history_file_update(void)
|
|||
*
|
||||
* - An image is saved to the thumbnail cache, sized at #PREVIEW_RENDER_LARGE_HEIGHT.
|
||||
*
|
||||
* - A smaller thumbnail is stored in the `.blend` file it's self, sized at #BLEN_THUMB_SIZE.
|
||||
* - A smaller thumbnail is stored in the `.blend` file itself, sized at #BLEN_THUMB_SIZE.
|
||||
* The size is kept small to prevent thumbnails bloating the size of `.blend` files.
|
||||
*
|
||||
* The this thumbnail will be extracted if the file is shared or the local thumbnail cache
|
||||
|
|
|
@ -187,7 +187,7 @@ static void operatortype_ghash_free_cb(wmOperatorType *ot)
|
|||
}
|
||||
|
||||
if (ot->rna_ext.srna) {
|
||||
/* A Python operator, allocates it's own string. */
|
||||
/* A Python operator, allocates its own string. */
|
||||
MEM_freeN((void *)ot->idname);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,10 @@ endif()
|
|||
get_property(_test_libs GLOBAL PROPERTY BLENDER_TEST_LIBS)
|
||||
if(WIN32 OR APPLE)
|
||||
# Windows and macOS set target_link_options after target creation.
|
||||
#
|
||||
# Still need to ensure dependency between the test libraries and the blender_test binary, so that
|
||||
# the latter one is re-linked when the test library is re-compiled.
|
||||
list(APPEND TEST_LIBS ${_test_libs})
|
||||
elseif(UNIX)
|
||||
list(APPEND TEST_LIBS "-Wl,--whole-archive" ${_test_libs} "-Wl,--no-whole-archive")
|
||||
else()
|
||||
|
|
|
@ -234,7 +234,7 @@ class TestPropArrayDynamicAssign(unittest.TestCase):
|
|||
|
||||
class TestPropArrayDynamicArg(unittest.TestCase):
|
||||
"""
|
||||
Index array, a dynamic array argument which defines it's own length.
|
||||
Index array, a dynamic array argument which defines its own length.
|
||||
"""
|
||||
|
||||
dims = 8
|
||||
|
|
|
@ -418,7 +418,7 @@ def main() -> None:
|
|||
source_paths_include=(".",),
|
||||
source_paths_exclude=(
|
||||
# Directories:
|
||||
# This is an exception, it has it's own CMake files we do not maintain.
|
||||
# This is an exception, it has its own CMake files we do not maintain.
|
||||
"./extern/audaspace",
|
||||
"./extern/quadriflow/3rd/lemon-1.3.1",
|
||||
),
|
||||
|
@ -428,7 +428,7 @@ def main() -> None:
|
|||
source_paths_include=(".",),
|
||||
source_paths_exclude=(
|
||||
# Directories:
|
||||
# This is an exception, it has it's own CMake files we do not maintain.
|
||||
# This is an exception, it has its own CMake files we do not maintain.
|
||||
"./extern",
|
||||
"./scripts/addons_contrib",
|
||||
# Just data.
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
|
||||
##----------------------------------------------------------------------##
|
||||
# Python Calls aren't so useful unless we're debugging Python it's self
|
||||
# Python Calls aren't so useful unless we're debugging Python itself
|
||||
|
||||
# _PyObject_Free
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue