Merge branch 'master' into xr-dev

This commit is contained in:
Peter Kim 2022-06-10 06:33:32 +09:00
commit 7948150ca3
63 changed files with 419 additions and 329 deletions

View File

@ -754,8 +754,6 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel):
layout.use_property_split = True
layout.use_property_decorate = False
with_freestyle = bpy.app.build_options.freestyle
scene = context.scene
rd = scene.render
view_layer = context.view_layer

View File

@ -121,11 +121,9 @@ MetalDeviceQueue::~MetalDeviceQueue()
double total_time = 0.0;
/* Show per-kernel timings, if gathered (see CYCLES_METAL_PROFILING). */
int64_t total_work_size = 0;
int64_t num_dispatches = 0;
for (auto &stat : timing_stats) {
total_time += stat.total_time;
total_work_size += stat.total_work_size;
num_dispatches += stat.num_dispatches;
}

View File

@ -402,9 +402,10 @@ extern GHOST_TSuccess GHOST_SetCursorPosition(GHOST_SystemHandle systemhandle,
int32_t x,
int32_t y);
GHOST_TSuccess GHOST_GetCursorGrabState(GHOST_WindowHandle windowhandle,
GHOST_TAxisFlag *r_wrap_axis,
int r_bounds[4]);
void GHOST_GetCursorGrabState(GHOST_WindowHandle windowhandle,
GHOST_TGrabCursorMode *r_mode,
GHOST_TAxisFlag *r_wrap_axis,
int r_bounds[4]);
/**
* Grabs the cursor for a modal operation, to keep receiving

View File

@ -256,7 +256,9 @@ class GHOST_IWindow {
virtual GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds) = 0;
virtual GHOST_TSuccess getCursorGrabState(GHOST_TAxisFlag &axis_flag, GHOST_Rect &bounds) = 0;
virtual void getCursorGrabState(GHOST_TGrabCursorMode &mode,
GHOST_TAxisFlag &axis_flag,
GHOST_Rect &bounds) = 0;
/**
* Test if the standard cursor shape is supported by current platform.

View File

@ -376,21 +376,18 @@ GHOST_TSuccess GHOST_SetCursorGrab(GHOST_WindowHandle windowhandle,
mode, wrap_axis, bounds ? &bounds_rect : nullptr, mouse_ungrab_xy ? mouse_xy : nullptr);
}
GHOST_TSuccess GHOST_GetCursorGrabState(GHOST_WindowHandle windowhandle,
GHOST_TAxisFlag *r_axis_flag,
int r_bounds[4])
void GHOST_GetCursorGrabState(GHOST_WindowHandle windowhandle,
GHOST_TGrabCursorMode *r_mode,
GHOST_TAxisFlag *r_axis_flag,
int r_bounds[4])
{
GHOST_IWindow *window = (GHOST_IWindow *)windowhandle;
GHOST_Rect bounds_rect;
if (!window->getCursorGrabState(*r_axis_flag, bounds_rect)) {
return GHOST_kFailure;
}
window->getCursorGrabState(*r_mode, *r_axis_flag, bounds_rect);
r_bounds[0] = bounds_rect.m_l;
r_bounds[1] = bounds_rect.m_t;
r_bounds[2] = bounds_rect.m_r;
r_bounds[3] = bounds_rect.m_b;
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,

View File

@ -71,7 +71,7 @@ struct cursor_t {
struct wl_cursor_theme *theme = nullptr;
int size;
std::string theme_name;
// outputs on which the cursor is visible
/** Outputs on which the cursor is visible. */
std::unordered_set<const output_t *> outputs;
int scale = 1;
};
@ -121,11 +121,11 @@ struct input_t {
struct xkb_context *xkb_context;
struct xkb_state *xkb_state;
struct {
/* Key repetition in character per second. */
/** Key repetition in character per second. */
int32_t rate;
/* Time (milliseconds) after which to start repeating keys. */
/** Time (milliseconds) after which to start repeating keys. */
int32_t delay;
/* Timer for key repeats. */
/** Timer for key repeats. */
GHOST_ITimerTask *timer = nullptr;
} key_repeat;
@ -133,8 +133,10 @@ struct input_t {
struct wl_surface *focus_keyboard = nullptr;
struct wl_data_device *data_device = nullptr;
struct data_offer_t *data_offer_dnd; /* Drag & Drop. */
struct data_offer_t *data_offer_copy_paste; /* Copy & Paste. */
/** Drag & Drop. */
struct data_offer_t *data_offer_dnd;
/** Copy & Paste. */
struct data_offer_t *data_offer_copy_paste;
struct data_source_t *data_source;
};
@ -828,7 +830,7 @@ static const struct wl_data_device_listener data_device_listener = {
/** \} */
/* -------------------------------------------------------------------- */
/** \name Listener (Pointer), #wl_pointer_listener
/** \name Listener (Surface), #wl_surface_listener
* \{ */
static void cursor_buffer_release(void *data, struct wl_buffer *wl_buffer)
@ -911,6 +913,12 @@ struct wl_surface_listener cursor_surface_listener = {
cursor_surface_leave,
};
/** \} */
/* -------------------------------------------------------------------- */
/** \name Listener (Pointer), #wl_pointer_listener
* \{ */
static void pointer_enter(void *data,
struct wl_pointer * /*wl_pointer*/,
uint32_t serial,
@ -1607,6 +1615,7 @@ void GHOST_SystemWayland::putClipboard(const char *buffer, bool /*selection*/) c
data_source_t *data_source = d->inputs[0]->data_source;
/* Copy buffer. */
free(data_source->buffer_out);
const size_t buffer_size = strlen(buffer) + 1;
data_source->buffer_out = static_cast<char *>(malloc(buffer_size));
std::memcpy(data_source->buffer_out, buffer, buffer_size);
@ -2019,7 +2028,7 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorGrab(const GHOST_TGrabCursorMode mo
const bool was_lock = MODE_NEEDS_LOCK(mode_current);
const bool use_lock = MODE_NEEDS_LOCK(mode);
/* Check for wrap as #supportsCursorWarp isn't supproted. */
/* Check for wrap as #supportsCursorWarp isn't supported. */
const bool was_hide = MODE_NEEDS_HIDE(mode_current) || (mode_current == GHOST_kGrabWrap);
const bool use_hide = MODE_NEEDS_HIDE(mode) || (mode == GHOST_kGrabWrap);

View File

@ -162,12 +162,11 @@ GHOST_TSuccess GHOST_Window::getCursorGrabBounds(GHOST_Rect &bounds)
return (bounds.m_l == -1 && bounds.m_r == -1) ? GHOST_kFailure : GHOST_kSuccess;
}
GHOST_TSuccess GHOST_Window::getCursorGrabState(GHOST_TAxisFlag &wrap_axis, GHOST_Rect &bounds)
void GHOST_Window::getCursorGrabState(GHOST_TGrabCursorMode &mode,
GHOST_TAxisFlag &wrap_axis,
GHOST_Rect &bounds)
{
if (m_cursorGrab == GHOST_kGrabDisable) {
return GHOST_kFailure;
}
mode = m_cursorGrab;
if (m_cursorGrab == GHOST_kGrabWrap) {
bounds = m_cursorGrabBounds;
wrap_axis = m_cursorGrabAxis;
@ -179,7 +178,6 @@ GHOST_TSuccess GHOST_Window::getCursorGrabState(GHOST_TAxisFlag &wrap_axis, GHOS
bounds.m_b = -1;
wrap_axis = GHOST_kGrabAxisNone;
}
return GHOST_kSuccess;
}
GHOST_TSuccess GHOST_Window::setCursorShape(GHOST_TStandardCursor cursorShape)

View File

@ -152,7 +152,9 @@ class GHOST_Window : public GHOST_IWindow {
*/
GHOST_TSuccess getCursorGrabBounds(GHOST_Rect &bounds);
GHOST_TSuccess getCursorGrabState(GHOST_TAxisFlag &axis_flag, GHOST_Rect &bounds);
void getCursorGrabState(GHOST_TGrabCursorMode &mode,
GHOST_TAxisFlag &axis_flag,
GHOST_Rect &bounds);
/**
* Sets the progress bar value displayed in the window/application icon

Binary file not shown.

View File

@ -678,6 +678,7 @@ class DATA_PT_vertex_colors(DATA_PT_mesh_attributes, Panel):
self.draw_attribute_warnings(context, layout)
classes = (
MESH_MT_vertex_group_context_menu,
MESH_MT_shape_key_context_menu,

View File

@ -387,6 +387,7 @@ class CurvesGeometry : public ::CurvesGeometry {
void update_customdata_pointers();
void remove_points(IndexMask points_to_delete);
void remove_curves(IndexMask curves_to_delete);
/**

View File

@ -1100,6 +1100,165 @@ static void *ensure_customdata_layer(CustomData &custom_data,
&custom_data, data_type, CD_DEFAULT, nullptr, tot_elements, name.c_str());
}
static void copy_between_buffers(const CPPType &type,
const void *src_buffer,
void *dst_buffer,
const IndexRange src_range,
const IndexRange dst_range)
{
BLI_assert(src_range.size() == dst_range.size());
type.copy_construct_n(POINTER_OFFSET(src_buffer, type.size() * src_range.start()),
POINTER_OFFSET(dst_buffer, type.size() * dst_range.start()),
src_range.size());
}
template<typename T>
static void copy_with_map(const Span<T> src, const Span<int> map, MutableSpan<T> dst)
{
threading::parallel_for(map.index_range(), 1024, [&](const IndexRange range) {
for (const int i : range) {
dst[i] = src[map[i]];
}
});
}
static void copy_with_map(const GSpan src, const Span<int> map, GMutableSpan dst)
{
attribute_math::convert_to_static_type(src.type(), [&](auto dummy) {
using T = decltype(dummy);
copy_with_map(src.typed<T>(), map, dst.typed<T>());
});
}
/**
* Builds an array that for every point, contains the corresponding curve index.
*/
static Array<int> build_point_to_curve_map(const CurvesGeometry &curves)
{
Array<int> point_to_curve_map(curves.points_num());
threading::parallel_for(curves.curves_range(), 1024, [&](const IndexRange curves_range) {
for (const int i_curve : curves_range) {
point_to_curve_map.as_mutable_span().slice(curves.points_for_curve(i_curve)).fill(i_curve);
}
});
return point_to_curve_map;
}
static CurvesGeometry copy_with_removed_points(const CurvesGeometry &curves,
const IndexMask points_to_delete)
{
/* Use a map from points to curves to facilitate using an #IndexMask input. */
const Array<int> point_to_curve_map = build_point_to_curve_map(curves);
const Vector<IndexRange> copy_point_ranges = points_to_delete.extract_ranges_invert(
curves.points_range());
/* For every range of points to copy, find the offset in the result curves point layers. */
int new_point_count = 0;
Array<int> copy_point_range_dst_offsets(copy_point_ranges.size());
for (const int i : copy_point_ranges.index_range()) {
copy_point_range_dst_offsets[i] = new_point_count;
new_point_count += copy_point_ranges[i].size();
}
BLI_assert(new_point_count == (curves.points_num() - points_to_delete.size()));
/* Find out how many non-deleted points there are in every curve. */
Array<int> curve_point_counts(curves.curves_num(), 0);
for (const IndexRange range : copy_point_ranges) {
for (const int point_i : range) {
curve_point_counts[point_to_curve_map[point_i]]++;
}
}
/* Build the offsets for the new curve points, skipping curves that had all points deleted.
* Also store the original indices of the corresponding input curves, to facilitate parallel
* copying of curve domain data. */
int new_curve_count = 0;
int curve_point_offset = 0;
Vector<int> new_curve_offsets;
Vector<int> new_curve_orig_indices;
new_curve_offsets.append(0);
for (const int i : curve_point_counts.index_range()) {
if (curve_point_counts[i] > 0) {
curve_point_offset += curve_point_counts[i];
new_curve_offsets.append(curve_point_offset);
new_curve_count++;
new_curve_orig_indices.append(i);
}
}
CurvesGeometry new_curves{new_point_count, new_curve_count};
threading::parallel_invoke(
/* Initialize curve offsets. */
[&]() { new_curves.offsets_for_write().copy_from(new_curve_offsets); },
/* Copy over point attributes. */
[&]() {
const CustomData &old_point_data = curves.point_data;
CustomData &new_point_data = new_curves.point_data;
for (const int layer_i : IndexRange(old_point_data.totlayer)) {
const CustomDataLayer &old_layer = old_point_data.layers[layer_i];
const eCustomDataType data_type = static_cast<eCustomDataType>(old_layer.type);
const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type);
void *dst_buffer = ensure_customdata_layer(
new_point_data, old_layer.name, data_type, new_point_count);
threading::parallel_for(
copy_point_ranges.index_range(), 128, [&](const IndexRange ranges_range) {
for (const int range_i : ranges_range) {
const IndexRange src_range = copy_point_ranges[range_i];
copy_between_buffers(type,
old_layer.data,
dst_buffer,
src_range,
{copy_point_range_dst_offsets[range_i], src_range.size()});
}
});
}
},
/* Copy over curve attributes.
* In some cases points are just dissolved, so the the number of
* curves will be the same. That could be optimized in the future. */
[&]() {
const CustomData &old_curve_data = curves.curve_data;
CustomData &new_curve_data = new_curves.curve_data;
for (const int layer_i : IndexRange(old_curve_data.totlayer)) {
const CustomDataLayer &old_layer = old_curve_data.layers[layer_i];
const eCustomDataType data_type = static_cast<eCustomDataType>(old_layer.type);
const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type);
void *dst_buffer = ensure_customdata_layer(
new_curve_data, old_layer.name, data_type, new_curve_count);
if (new_curves.curves_num() == curves.curves_num()) {
type.copy_construct_n(old_layer.data, dst_buffer, new_curves.curves_num());
}
else {
copy_with_map({type, old_layer.data, curves.curves_num()},
new_curve_orig_indices,
{type, dst_buffer, new_curves.curves_num()});
}
}
});
new_curves.update_curve_types();
return new_curves;
}
void CurvesGeometry::remove_points(const IndexMask points_to_delete)
{
if (points_to_delete.is_empty()) {
return;
}
if (points_to_delete.size() == this->points_num()) {
*this = {};
}
*this = copy_with_removed_points(*this, points_to_delete);
}
static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
const IndexMask curves_to_delete)
{
@ -1159,20 +1318,17 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
const eCustomDataType data_type = static_cast<eCustomDataType>(old_layer.type);
const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type);
const void *src_buffer = old_layer.data;
void *dst_buffer = ensure_customdata_layer(
new_point_data, old_layer.name, data_type, new_tot_points);
threading::parallel_for(
old_curve_ranges.index_range(), 128, [&](const IndexRange ranges_range) {
for (const int range_i : ranges_range) {
const IndexRange old_point_range = old_point_ranges[range_i];
const IndexRange new_point_range = new_point_ranges[range_i];
type.copy_construct_n(
POINTER_OFFSET(src_buffer, type.size() * old_point_range.start()),
POINTER_OFFSET(dst_buffer, type.size() * new_point_range.start()),
old_point_range.size());
copy_between_buffers(type,
old_layer.data,
dst_buffer,
old_point_ranges[range_i],
new_point_ranges[range_i]);
}
});
}
@ -1186,20 +1342,17 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
const eCustomDataType data_type = static_cast<eCustomDataType>(old_layer.type);
const CPPType &type = *bke::custom_data_type_to_cpp_type(data_type);
const void *src_buffer = old_layer.data;
void *dst_buffer = ensure_customdata_layer(
new_curve_data, old_layer.name, data_type, new_tot_curves);
threading::parallel_for(
old_curve_ranges.index_range(), 128, [&](const IndexRange ranges_range) {
for (const int range_i : ranges_range) {
const IndexRange old_curve_range = old_curve_ranges[range_i];
const IndexRange new_curve_range = new_curve_ranges[range_i];
type.copy_construct_n(
POINTER_OFFSET(src_buffer, type.size() * old_curve_range.start()),
POINTER_OFFSET(dst_buffer, type.size() * new_curve_range.start()),
old_curve_range.size());
copy_between_buffers(type,
old_layer.data,
dst_buffer,
old_curve_ranges[range_i],
new_curve_ranges[range_i]);
}
});
}
@ -1212,6 +1365,12 @@ static CurvesGeometry copy_with_removed_curves(const CurvesGeometry &curves,
void CurvesGeometry::remove_curves(const IndexMask curves_to_delete)
{
if (curves_to_delete.is_empty()) {
return;
}
if (curves_to_delete.size() == this->curves_num()) {
*this = {};
}
*this = copy_with_removed_curves(*this, curves_to_delete);
}

View File

@ -256,12 +256,11 @@ FCurve *BKE_fcurve_find(ListBase *list, const char rna_path[], const int array_i
/* Check paths of curves, then array indices... */
for (fcu = list->first; fcu; fcu = fcu->next) {
/* Check indices first, much cheaper than a string comparison. */
/* Simple string-compare (this assumes that they have the same root...) */
if (fcu->rna_path && STREQ(fcu->rna_path, rna_path)) {
/* Now check indices. */
if (fcu->array_index == array_index) {
return fcu;
}
if (UNLIKELY(fcu->array_index == array_index && fcu->rna_path &&
fcu->rna_path[0] == rna_path[0] && STREQ(fcu->rna_path, rna_path))) {
return fcu;
}
}

View File

@ -2284,7 +2284,7 @@ void BKE_sculpt_bvh_update_from_ccg(PBVH *pbvh, SubdivCCG *subdiv_ccg)
subdiv_ccg->grid_hidden);
}
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const View3D *v3d)
bool BKE_sculptsession_use_pbvh_draw(const Object *ob, const View3D *UNUSED(v3d))
{
SculptSession *ss = ob->sculpt;
if (ss == NULL || ss->pbvh == NULL || ss->mode_type != OB_MODE_SCULPT) {

View File

@ -460,17 +460,18 @@ static size_t unit_as_string(char *str,
}
double value_conv = (value / unit->scalar) - unit->bias;
bool strip_skip;
bool strip_skip = false;
/* Adjust precision to expected number of significant digits.
* Note that here, we shall not have to worry about very big/small numbers, units are expected
* to replace 'scientific notation' in those cases. */
prec -= integer_digits_d(value_conv);
/* Negative precision is used to disable stripping of zeroes. This reduces text jumping when changing values. */
/* Negative precision is used to disable stripping of zeroes.
* This reduces text jumping when changing values. */
if (prec < 0) {
strip_skip = true;
prec *= -1;
strip_skip = true;
prec *= -1;
}
CLAMP(prec, 0, 6);

View File

@ -209,11 +209,11 @@ template<typename Key, Key EmptyValue, Key RemovedValue> struct TemplatedKeyInfo
};
/**
* 0xffff...ffff indicates an empty slot.
* 0xffff...fffe indicates a removed slot.
* `0xffff...ffff` indicates an empty slot.
* `0xffff...fffe` indicates a removed slot.
*
* Those specific values are used, because with them a single comparison is enough to check whether
* a slot is occupied. The keys 0x0000...0000 and 0x0000...0001 also satisfy this constraint.
* a slot is occupied. The keys `0x0000...0000` and `0x0000...0001` also satisfy this constraint.
* However, nullptr is much more likely to be used as valid key.
*/
template<typename Pointer> struct PointerKeyInfo {

View File

@ -99,8 +99,8 @@ bool BLI_tridiagonal_solve_cyclic(
/* Degenerate case that works but can be simplified. */
if (count == 2) {
float a2[2] = {0, a[1] + c[1]};
float c2[2] = {a[0] + c[0], 0};
const float a2[2] = {0, a[1] + c[1]};
const float c2[2] = {a[0] + c[0], 0};
return BLI_tridiagonal_solve(a2, b, c2, d, r_x, count);
}

View File

@ -81,8 +81,8 @@ class TonemapOperation : public MultiThreadedOperation {
};
/**
* \brief class of tonemap, implementing the photoreceptor tonemap
* most parts have already been done in TonemapOperation
* \brief class of tone-map, implementing the photo-receptor tone-map
* most parts have already been done in #TonemapOperation.
* \ingroup operation
*/

View File

@ -222,7 +222,7 @@ void DRW_opengl_context_activate(bool drw_state);
void DRW_draw_cursor_2d_ex(const struct ARegion *region, const float cursor[2]);
void DRW_cdlayer_attr_aliases_add(struct GPUVertFormat *format,
char *base_name,
const char *base_name,
const struct CustomData *data,
const struct CustomDataLayer *cl,
bool is_active_render,

View File

@ -41,7 +41,7 @@ class ShadingView {
/** Matrix to apply to the viewmat. */
const float (*face_matrix_)[4];
/** Post-fx modules. */
/** Post-FX modules. */
// DepthOfField dof_;
// MotionBlur mb_;
VelocityView velocity_;

View File

@ -5,7 +5,7 @@ void main()
float dist_squared = dot(centered, centered);
const float rad_squared = 0.25;
// round point with jaggy edges
/* Round point with jaggy edges. */
if (dist_squared > rad_squared) {
discard;
}

View File

@ -3412,8 +3412,8 @@ void DRW_batch_cache_free_old(Object *ob, int ctime)
/** \} */
void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format,
char *base_name,
const CustomData *data,
const char *base_name,
const CustomData *UNUSED(data),
const CustomDataLayer *cl,
bool is_active_render,
bool is_active_layer)

View File

@ -1238,7 +1238,8 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
&update_frustum,
&draw_frustum,
(void (*)(void *, GPU_PBVH_Buffers *))sculpt_draw_cb,
scd, scd->use_mats);
scd,
scd->use_mats);
if (SCULPT_DEBUG_BUFFERS) {
int debug_node_nr = 0;

View File

@ -711,14 +711,14 @@ static bool animedit_poll_channels_active(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
return false;
}
/* animation editor test */
if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
return false;
}
return 1;
return true;
}
/* Poll callback for Animation Editor channels list region + not in NLA-tweak-mode for NLA. */
@ -730,21 +730,21 @@ static bool animedit_poll_channels_nla_tweakmode_off(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
return false;
}
/* animation editor test */
if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH, SPACE_NLA) == 0) {
return 0;
return false;
}
/* NLA tweak-mode test. */
if (area->spacetype == SPACE_NLA) {
if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) {
return 0;
return false;
}
}
return 1;
return true;
}
/* ****************** Rearrange Channels Operator ******************* */
@ -791,7 +791,7 @@ static bool rearrange_island_ok(tReorderChannelIsland *island)
{
/* island must not be untouchable */
if (island->flag & REORDER_ISLAND_UNTOUCHABLE) {
return 0;
return false;
}
/* island should be selected to be moved */
@ -809,10 +809,10 @@ static bool rearrange_island_top(ListBase *list, tReorderChannelIsland *island)
/* make it first element */
BLI_insertlinkbefore(list, list->first, island);
return 1;
return true;
}
return 0;
return false;
}
static bool rearrange_island_up(ListBase *list, tReorderChannelIsland *island)
@ -833,11 +833,11 @@ static bool rearrange_island_up(ListBase *list, tReorderChannelIsland *island)
/* push it up */
BLI_insertlinkbefore(list, prev, island);
return 1;
return true;
}
}
return 0;
return false;
}
static bool rearrange_island_down(ListBase *list, tReorderChannelIsland *island)
@ -1083,7 +1083,7 @@ static bool rearrange_animchannel_islands(ListBase *list,
/* don't waste effort on an empty list */
if (BLI_listbase_is_empty(list)) {
return 0;
return false;
}
/* group channels into islands */
@ -1589,7 +1589,7 @@ static bool animchannels_grouping_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
return false;
}
/* animation editor test - must be suitable modes only */
@ -1602,7 +1602,7 @@ static bool animchannels_grouping_poll(bContext *C)
/* dopesheet and action only - all others are for other datatypes or have no groups */
if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_DOPESHEET) == 0) {
return 0;
return false;
}
break;
@ -1612,17 +1612,17 @@ static bool animchannels_grouping_poll(bContext *C)
/* drivers can't have groups... */
if (sipo->mode != SIPO_MODE_ANIMATION) {
return 0;
return false;
}
break;
}
/* unsupported... */
default:
return 0;
return false;
}
return 1;
return true;
}
/* ----------------------------------------------------------- */
@ -2428,15 +2428,15 @@ static bool animchannels_enable_poll(bContext *C)
/* channels region test */
/* TODO: could enhance with actually testing if channels region? */
if (ELEM(NULL, area, CTX_wm_region(C))) {
return 0;
return false;
}
/* animation editor test - Action/Dopesheet/etc. and Graph only */
if (ELEM(area->spacetype, SPACE_ACTION, SPACE_GRAPH) == 0) {
return 0;
return false;
}
return 1;
return true;
}
static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op))
@ -2504,7 +2504,7 @@ static bool animchannels_select_filter_poll(bContext *C)
ScrArea *area = CTX_wm_area(C);
if (area == NULL) {
return 0;
return false;
}
/* animation editor with dopesheet */
@ -2791,13 +2791,35 @@ static bool rename_anim_channels(bAnimContext *ac, int channel_index)
return false;
}
/* don't allow renaming linked channels */
if ((ale->fcurve_owner_id != NULL &&
(ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) ||
(ale->id != NULL && (ID_IS_LINKED(ale->id) || ID_IS_OVERRIDE_LIBRARY(ale->id)))) {
/* Don't allow renaming linked/liboverride channels. */
if (ale->fcurve_owner_id != NULL &&
(ID_IS_LINKED(ale->fcurve_owner_id) || ID_IS_OVERRIDE_LIBRARY(ale->fcurve_owner_id))) {
ANIM_animdata_freelist(&anim_data);
return false;
}
if (ale->id != NULL) {
if (ID_IS_LINKED(ale->id)) {
ANIM_animdata_freelist(&anim_data);
return false;
}
/* There is one exception to not allowing renaming on liboverride channels: locally-inserted
* NLA tracks. */
if (ID_IS_OVERRIDE_LIBRARY(ale->id)) {
switch (ale->type) {
case ANIMTYPE_NLATRACK: {
NlaTrack *nlt = (NlaTrack *)ale->data;
if ((nlt->flag & NLATRACK_OVERRIDELIBRARY_LOCAL) == 0) {
ANIM_animdata_freelist(&anim_data);
return false;
}
break;
}
default:
ANIM_animdata_freelist(&anim_data);
return false;
}
}
}
/* check that channel can be renamed */
acf = ANIM_channel_get_typeinfo(ale);

View File

@ -3119,7 +3119,8 @@ bool ED_autokeyframe_property(bContext *C,
fcu = BKE_fcurve_find_by_rna_context_ui(
C, ptr, prop, rnaindex_check, NULL, &action, &driven, &special);
/* Only early out when we actually want an existing fcurve already (e.g. auto-keyframing from buttons). */
/* Only early out when we actually want an existing F-curve already
* (e.g. auto-keyframing from buttons). */
if (fcu == NULL && (driven || special || only_if_property_keyed)) {
return changed;
}

View File

@ -1431,7 +1431,7 @@ static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, con
ret = OPERATOR_PASS_THROUGH;
break;
/* quicky compare to original */
/* Quickly compare to original. */
case EVT_TABKEY:
pld->flag &= ~PL_PREVIEW_SHOWORIGINAL;
pld->redraw = PL_PREVIEW_REDRAWALL;

View File

@ -843,7 +843,7 @@ static bool insert_point_to_segment(const ViewContext *vc, const wmEvent *event)
{
Curve *cu = vc->obedit->data;
CutData cd = init_cut_data(event);
float mval[2] = {UNPACK2(event->mval)};
const float mval[2] = {UNPACK2(event->mval)};
const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR;
const bool near_spline = update_cut_data_for_all_nurbs(
vc, BKE_curve_editNurbs_get(cu), mval, threshold_dist_px, &cd);
@ -1134,7 +1134,7 @@ static bool is_spline_nearby(ViewContext *vc,
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
CutData cd = init_cut_data(event);
float mval[2] = {UNPACK2(event->mval)};
const float mval[2] = {UNPACK2(event->mval)};
const bool nearby = update_cut_data_for_all_nurbs(vc, nurbs, mval, sel_dist, &cd);
if (nearby) {

View File

@ -782,6 +782,7 @@ set_property(GLOBAL PROPERTY ICON_GEOM_NAMES
ops.curves.sculpt_puff
ops.curves.sculpt_smooth
ops.curves.sculpt_snake_hook
ops.curves.slide
ops.generic.cursor
ops.generic.select
ops.generic.select_box

View File

@ -80,9 +80,9 @@ typedef enum eDrawStrokeFlags {
GP_DRAWDATA_ONLYI2D = (1 << 3),
/** special hack for drawing strokes in Image Editor (weird coordinates) */
GP_DRAWDATA_IEDITHACK = (1 << 4),
/** don't draw xray in 3D view (which is default) */
/** Don't draw XRAY in 3D view (which is default). */
GP_DRAWDATA_NO_XRAY = (1 << 5),
/** no onionskins should be drawn (for animation playback) */
/** No onion-skins should be drawn (for animation playback). */
GP_DRAWDATA_NO_ONIONS = (1 << 6),
/** draw strokes as "volumetric" circular billboards */
GP_DRAWDATA_VOLUMETRIC = (1 << 7),

View File

@ -1701,7 +1701,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
const bool select = (sel_op != SEL_OP_SUB);
bool changed = false;
/* for bounding rect around circle (for quicky intersection testing) */
/* For bounding `rect` around circle (for quickly intersection testing). */
rcti rect = {0};
rect.xmin = mx - radius;
rect.ymin = my - radius;

View File

@ -1747,7 +1747,7 @@ static void gpencil_brush_cursor_draw(bContext *C, int x, int y, void *customdat
float darkcolor[3];
float radius = 3.0f;
int mval_i[2] = {x, y};
const int mval_i[2] = {x, y};
/* Check if cursor is in drawing region and has valid data-block. */
if ((!gpencil_check_cursor_region(C, mval_i)) || (gpd == NULL)) {
return;

View File

@ -60,7 +60,7 @@ bool ED_space_clip_get_position(struct SpaceClip *sc,
*/
bool ED_space_clip_color_sample(struct SpaceClip *sc,
struct ARegion *region,
int mval[2],
const int mval[2],
float r_col[3]);
void ED_clip_update_frame(const struct Main *mainp, int cfra);

View File

@ -64,8 +64,11 @@ bool ED_space_image_get_position(struct SpaceImage *sima,
/**
* Returns color in linear space, matching #ED_space_node_color_sample().
*/
bool ED_space_image_color_sample(
struct SpaceImage *sima, struct ARegion *region, int mval[2], float r_col[3], bool *r_is_data);
bool ED_space_image_color_sample(struct SpaceImage *sima,
struct ARegion *region,
const int mval[2],
float r_col[3],
bool *r_is_data);
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock, int tile);
/**
* Get the #SpaceImage flag that is valid for the given ibuf.

View File

@ -662,8 +662,8 @@ bool ED_autokeyframe_pchan(struct bContext *C,
/**
* Use for auto-key-framing
* \param only_if_property_keyed: if true, auto-key-framing only creates keyframes on already keyed
* properties. This is by design when using buttons. For other callers such as gizmos or VSE preview
* transform, creating new animation/keyframes also on non-keyed properties is desired.
* properties. This is by design when using buttons. For other callers such as gizmos or VSE
* preview transform, creating new animation/keyframes also on non-keyed properties is desired.
*/
bool ED_autokeyframe_property(struct bContext *C,
struct Scene *scene,

View File

@ -130,7 +130,7 @@ void UI_draw_roundbox_4fv_ex(const rctf *rect,
void UI_draw_roundbox_3ub_alpha(
const rctf *rect, bool filled, float rad, const uchar col[3], uchar alpha)
{
float colv[4] = {
const float colv[4] = {
((float)col[0]) / 255,
((float)col[1]) / 255,
((float)col[2]) / 255,
@ -142,7 +142,7 @@ void UI_draw_roundbox_3ub_alpha(
void UI_draw_roundbox_3fv_alpha(
const rctf *rect, bool filled, float rad, const float col[3], float alpha)
{
float colv[4] = {col[0], col[1], col[2], alpha};
const float colv[4] = {col[0], col[1], col[2], alpha};
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
}

View File

@ -329,7 +329,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) {
SpaceImage *sima = area->spacedata.first;
int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_image_color_sample(sima, region, region_mval, r_col, NULL)) {
return;
@ -340,7 +340,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) {
SpaceNode *snode = area->spacedata.first;
int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_node_color_sample(bmain, snode, region, region_mval, r_col)) {
return;
@ -351,7 +351,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) {
SpaceClip *sc = area->spacedata.first;
int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_clip_color_sample(sc, region, region_mval, r_col)) {
return;

View File

@ -7408,8 +7408,7 @@ static bool ui_numedit_but_CURVEPROFILE(uiBlock *block,
const float zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&profile->view_rect);
if (snap) {
float d[2] = {mx - data->dragstartx, data->dragstarty};
const float d[2] = {mx - data->dragstartx, data->dragstarty};
if (len_squared_v2(d) < (9.0f * U.dpi_fac)) {
snap = false;
}

View File

@ -1167,7 +1167,9 @@ static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
/* identifiers */
ot->name = "Copy to Selected";
ot->idname = "UI_OT_copy_to_selected_button";
ot->description = "Copy property from this object to selected objects or bones";
ot->description =
"Copy the property's value from the active item to the same property of all selected items "
"if the same property exists";
/* callbacks */
ot->poll = copy_to_selected_button_poll;

View File

@ -458,7 +458,7 @@ static bool object_transfer_mode_to_base(bContext *C, wmOperator *op, Base *base
return false;
}
bool mode_transfered = false;
bool mode_transferred = false;
ED_undo_group_begin(C);
@ -480,11 +480,11 @@ static bool object_transfer_mode_to_base(bContext *C, wmOperator *op, Base *base
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
WM_toolsystem_update_from_context_view3d(C);
mode_transfered = true;
mode_transferred = true;
}
ED_undo_group_end(C);
return mode_transfered;
return mode_transferred;
}
static int object_transfer_mode_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@ -493,8 +493,8 @@ static int object_transfer_mode_invoke(bContext *C, wmOperator *op, const wmEven
const eObjectMode src_mode = (eObjectMode)ob_src->mode;
Base *base_dst = ED_view3d_give_base_under_cursor(C, event->mval);
const bool mode_transfered = object_transfer_mode_to_base(C, op, base_dst);
if (!mode_transfered) {
const bool mode_transferred = object_transfer_mode_to_base(C, op, base_dst);
if (!mode_transferred) {
return OPERATOR_CANCELLED;
}

View File

@ -17,8 +17,8 @@
#include "WM_api.h"
#include "WM_toolsystem.h"
#include "ED_image.h"
#include "ED_curves_sculpt.h"
#include "ED_image.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_view3d.h"

View File

@ -83,6 +83,9 @@ struct SelectionPaintOperationExecutor {
curves_id_ = static_cast<Curves *>(object_->data);
curves_ = &CurvesGeometry::wrap(curves_id_->geometry);
curves_id_->flag |= CV_SCULPT_SELECTION_ENABLED;
if (curves_->curves_num() == 0) {
return;
}
brush_ = BKE_paint_brush_for_read(&ctx_.scene->toolsettings->curves_sculpt->paint);
brush_radius_base_re_ = BKE_brush_size_get(ctx_.scene, brush_);

View File

@ -38,6 +38,7 @@
#include "IMB_imbuf_types.h"
#include "ED_image.h"
#include "ED_view3d.h"
#include "DEG_depsgraph.h"

View File

@ -1584,7 +1584,7 @@ static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmE
SculptSession *ss = ob->sculpt;
SculptCursorGeometryInfo sgi;
float mouse[2] = {event->mval[0], event->mval[1]};
const float mouse[2] = {event->mval[0], event->mval[1]};
SCULPT_vertex_random_access_ensure(ss);
ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
if (ss->gesture_initial_hit) {
@ -1625,7 +1625,7 @@ static int sculpt_trim_gesture_lasso_invoke(bContext *C, wmOperator *op, const w
SculptSession *ss = ob->sculpt;
SculptCursorGeometryInfo sgi;
float mouse[2] = {event->mval[0], event->mval[1]};
const float mouse[2] = {event->mval[0], event->mval[1]};
SCULPT_vertex_random_access_ensure(ss);
ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
if (ss->gesture_initial_hit) {

View File

@ -55,8 +55,8 @@
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "ED_image.h"
#include "ED_armature.h"
#include "ED_image.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"

View File

@ -272,7 +272,7 @@ bool ED_space_clip_get_position(struct SpaceClip *sc,
return true;
}
bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, int mval[2], float r_col[3])
bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, const int mval[2], float r_col[3])
{
ImBuf *ibuf;
float fx, fy, co[2];

View File

@ -3204,7 +3204,7 @@ bool ED_space_image_get_position(SpaceImage *sima,
}
bool ED_space_image_color_sample(
SpaceImage *sima, ARegion *region, int mval[2], float r_col[3], bool *r_is_data)
SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
{
if (r_is_data) {
*r_is_data = false;

View File

@ -317,7 +317,7 @@ static void image_listener(const wmSpaceTypeListenerParams *params)
break;
case ND_MODE:
ED_paint_cursor_start(&params->scene->toolsettings->imapaint.paint,
ED_image_tools_paint_poll);
ED_image_tools_paint_poll);
if (wmn->subtype == NS_EDITMODE_MESH) {
ED_area_tag_refresh(area);

View File

@ -594,7 +594,7 @@ static char *view3d_mat_drop_tooltip(bContext *C,
{
const char *name = WM_drag_get_item_name(drag);
ARegion *region = CTX_wm_region(C);
int mval[2] = {
const int mval[2] = {
xy[0] - region->winrct.xmin,
xy[1] - region->winrct.ymin,
};

View File

@ -283,8 +283,10 @@ static SnapData_Mesh *snap_object_data_mesh_get(SnapObjectContext *sctx,
}
}
else {
/* Any existing #SnapData_EditMesh is now invalid. */
sctx->editmesh_caches.remove(BKE_editmesh_from_object(ob_eval));
if (ob_eval->type == OB_MESH) {
/* Any existing #SnapData_EditMesh is now invalid. */
sctx->editmesh_caches.remove(BKE_editmesh_from_object(ob_eval));
}
std::unique_ptr<SnapData_Mesh> sod_ptr = std::make_unique<SnapData_Mesh>();
sod = sod_ptr.get();
@ -2743,11 +2745,8 @@ static void snap_obj_fn(SnapObjectContext *sctx,
dt->r_index);
break;
case OB_CURVES_LEGACY:
retval = snapCurve(
sctx, params, ob_eval, obmat, dt->dist_px, dt->r_loc, dt->r_no, dt->r_index);
break; /* Use ATTR_FALLTHROUGH if we want to snap to the generated mesh. */
case OB_SURF:
if (BKE_object_is_in_editmode(ob_eval)) {
if (ob_eval->type == OB_CURVES_LEGACY || BKE_object_is_in_editmode(ob_eval)) {
retval = snapCurve(
sctx, params, ob_eval, obmat, dt->dist_px, dt->r_loc, dt->r_no, dt->r_index);
if (params->edit_mode_type != SNAP_GEOM_FINAL) {

View File

@ -151,7 +151,7 @@ struct GPUBatch *GPU_pbvh_buffers_batch_get(GPU_PBVH_Buffers *buffers, bool fast
short GPU_pbvh_buffers_material_index_get(GPU_PBVH_Buffers *buffers);
bool GPU_pbvh_buffers_has_overlays(GPU_PBVH_Buffers *buffers);
PBVHGPUFormat *GPU_pbvh_make_format();
PBVHGPUFormat *GPU_pbvh_make_format(void);
void GPU_pbvh_free_format(PBVHGPUFormat *vbo_id);
#ifdef __cplusplus

View File

@ -109,7 +109,7 @@ typedef struct PBVHGPUFormat {
bool active_attrs_only;
} PBVHGPUFormat;
PBVHGPUFormat *GPU_pbvh_make_format()
PBVHGPUFormat *GPU_pbvh_make_format(void)
{
PBVHGPUFormat *vbo_id = MEM_callocN(sizeof(PBVHGPUFormat), "PBVHGPUFormat");
@ -1206,17 +1206,17 @@ static int gpu_pbvh_make_attr_offs(eAttrDomainMask domain_mask,
const CustomDataLayer *active_layer,
const CustomDataLayer *render_layer)
{
const CustomData *cdata = active_domain == ATTR_DOMAIN_POINT ? vdata : ldata;
const CustomData *cdata_active = active_domain == ATTR_DOMAIN_POINT ? vdata : ldata;
if (!cdata) {
if (!cdata_active) {
return 0;
}
if (active_only) {
int idx = active_layer ? active_layer - cdata->layers : -1;
int idx = active_layer ? active_layer - cdata_active->layers : -1;
if (idx >= 0 && idx < cdata->totlayer) {
r_cd_attrs[0].cd_offset = cdata->layers[idx].offset;
if (idx >= 0 && idx < cdata_active->totlayer) {
r_cd_attrs[0].cd_offset = cdata_active->layers[idx].offset;
r_cd_attrs[0].domain = active_domain;
r_cd_attrs[0].type = active_type;
r_cd_attrs[0].layer_idx = idx;

View File

@ -256,7 +256,7 @@ bool MTLBackend::metal_is_supported()
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
/* Metal Viewport requires macOS Version 10.15 onwards. */
/* Metal Viewport requires macOS Version 10.15 onward. */
bool supported_os_version = version.majorVersion >= 11 ||
(version.majorVersion == 10 ? version.minorVersion >= 15 : false);
if (!supported_os_version) {

View File

@ -5,7 +5,7 @@ void main()
float dist_squared = dot(centered, centered);
const float rad_squared = 0.25;
// round point with jaggy edges
/* Round point with jaggy edges. */
if (dist_squared > rad_squared) {
discard;
}

View File

@ -19,7 +19,7 @@ namespace blender::io::stl {
class Triangle {
public:
int v1, v2, v3;
/* Based on an old version of Python's frozenset hash
/* Based on an old version of Python's frozen-set hash
* https://web.archive.org/web/20220520211017/https://stackoverflow.com/questions/20832279/python-frozenset-hashing-algorithm-implementation
*/
uint64_t hash() const

View File

@ -111,7 +111,7 @@ class obj_importer_test : public BlendfileLoadingBaseTest {
int endpoint = (nurb->flagu & CU_NURB_ENDPOINT) ? 1 : 0;
EXPECT_EQ(nurb->orderu, exp.mesh_totpoly_or_curve_order);
EXPECT_EQ(endpoint, exp.mesh_totedge_or_curve_endp);
// Cyclic flag is not set by the importer yet
/* Cyclic flag is not set by the importer yet. */
// int cyclic = (nurb->flagu & CU_NURB_CYCLIC) ? 1 : 0;
// EXPECT_EQ(cyclic, exp.mesh_totloop_or_curve_cyclic);
}

View File

@ -532,7 +532,7 @@ struct StructRNA {
/* property to iterate over properties */
PropertyRNA *iteratorproperty;
/* struct this is derivedfrom */
/** Struct this is derived from. */
struct StructRNA *base;
/* only use for nested structs, where both the parent and child access

View File

@ -339,6 +339,7 @@ static void rna_LayerCollection_update(Main *UNUSED(bmain), Scene *UNUSED(scene)
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
WM_main_add_notifier(NC_SCENE | ND_LAYER_CONTENT, NULL);
WM_main_add_notifier(NC_IMAGE | ND_LAYER_CONTENT, NULL);
}
static bool rna_LayerCollection_has_objects(LayerCollection *lc)

View File

@ -176,7 +176,8 @@ static void nurbs_to_bezier_assign(const Span<T> src,
dst.last() = src.last();
break;
default:
/* Every 3rd NURBS position (starting from index 1) should have its attributes transfered. */
/* Every 3rd NURBS position (starting from index 1) should have its attributes transferred.
*/
scale_input_assign<T>(src, 3, 1, dst);
}
}
@ -448,7 +449,7 @@ static void convert_to_bezier(const CurveComponent &src_component,
Vector<float3> nurbs_positions_vector;
if (src_cyclic[i] && is_nurbs_to_bezier_one_to_one(knots_mode)) {
/* For conversion treat this as periodic closed curve. Extend NURBS hull to first and
* second point which will act as a sceleton for placing Bezier handles. */
* second point which will act as a skeleton for placing Bezier handles. */
nurbs_positions_vector.extend(src_curve_positions);
nurbs_positions_vector.append(src_curve_positions[0]);
nurbs_positions_vector.append(src_curve_positions[1]);

View File

@ -8,10 +8,10 @@
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BKE_curves.hh"
#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_pointcloud.h"
#include "BKE_spline.hh"
#include "node_geometry_util.hh"
@ -311,161 +311,35 @@ static void copy_masked_polys_to_new_mesh(const Mesh &src_mesh,
}
}
static void spline_copy_builtin_attributes(const Spline &spline,
Spline &r_spline,
const IndexMask mask)
{
copy_data_based_on_mask(spline.positions(), r_spline.positions(), mask);
copy_data_based_on_mask(spline.radii(), r_spline.radii(), mask);
copy_data_based_on_mask(spline.tilts(), r_spline.tilts(), mask);
switch (spline.type()) {
case CURVE_TYPE_POLY:
break;
case CURVE_TYPE_BEZIER: {
const BezierSpline &src = static_cast<const BezierSpline &>(spline);
BezierSpline &dst = static_cast<BezierSpline &>(r_spline);
copy_data_based_on_mask(src.handle_positions_left(), dst.handle_positions_left(), mask);
copy_data_based_on_mask(src.handle_positions_right(), dst.handle_positions_right(), mask);
copy_data_based_on_mask(src.handle_types_left(), dst.handle_types_left(), mask);
copy_data_based_on_mask(src.handle_types_right(), dst.handle_types_right(), mask);
break;
}
case CURVE_TYPE_NURBS: {
const NURBSpline &src = static_cast<const NURBSpline &>(spline);
NURBSpline &dst = static_cast<NURBSpline &>(r_spline);
copy_data_based_on_mask(src.weights(), dst.weights(), mask);
break;
}
case CURVE_TYPE_CATMULL_ROM: {
BLI_assert_unreachable();
break;
}
}
}
static void copy_dynamic_attributes(const CustomDataAttributes &src,
CustomDataAttributes &dst,
const IndexMask mask)
{
src.foreach_attribute(
[&](const AttributeIDRef &attribute_id, const AttributeMetaData &meta_data) {
std::optional<GSpan> src_attribute = src.get_for_read(attribute_id);
BLI_assert(src_attribute);
if (!dst.create(attribute_id, meta_data.data_type)) {
/* Since the source spline of the same type had the attribute, adding it should work.
*/
BLI_assert_unreachable();
}
std::optional<GMutableSpan> new_attribute = dst.get_for_write(attribute_id);
BLI_assert(new_attribute);
attribute_math::convert_to_static_type(new_attribute->type(), [&](auto dummy) {
using T = decltype(dummy);
copy_data_based_on_mask(src_attribute->typed<T>(), new_attribute->typed<T>(), mask);
});
return true;
},
ATTR_DOMAIN_POINT);
}
/**
* Deletes points in the spline. Those not in the mask are deleted. The spline is not split into
* multiple newer splines.
*/
static SplinePtr spline_delete(const Spline &spline, const IndexMask mask)
{
SplinePtr new_spline = spline.copy_only_settings();
new_spline->resize(mask.size());
spline_copy_builtin_attributes(spline, *new_spline, mask);
copy_dynamic_attributes(spline.attributes, new_spline->attributes, mask);
return new_spline;
}
static std::unique_ptr<CurveEval> curve_separate(const CurveEval &input_curve,
const Span<bool> selection,
const eAttrDomain selection_domain)
{
Span<SplinePtr> input_splines = input_curve.splines();
std::unique_ptr<CurveEval> output_curve = std::make_unique<CurveEval>();
/* Keep track of which splines were copied to the result to copy spline domain attributes. */
Vector<int64_t> copied_splines;
if (selection_domain == ATTR_DOMAIN_CURVE) {
/* Operates on each of the splines as a whole, i.e. not on the points in the splines
* themselves. */
for (const int i : selection.index_range()) {
if (selection[i]) {
output_curve->add_spline(input_splines[i]->copy());
copied_splines.append(i);
}
}
}
else {
/* Operates on the points in the splines themselves. */
/* Reuse index vector for each spline. */
Vector<int64_t> indices_to_copy;
int selection_index = 0;
for (const int i : input_splines.index_range()) {
const Spline &spline = *input_splines[i];
indices_to_copy.clear();
for (const int i_point : IndexRange(spline.size())) {
if (selection[selection_index]) {
/* Append i_point instead of selection_index because we need indices local to the spline
* for copying. */
indices_to_copy.append(i_point);
}
selection_index++;
}
/* Avoid creating an empty spline. */
if (indices_to_copy.is_empty()) {
continue;
}
SplinePtr new_spline = spline_delete(spline, IndexMask(indices_to_copy));
output_curve->add_spline(std::move(new_spline));
copied_splines.append(i);
}
}
if (copied_splines.is_empty()) {
return {};
}
output_curve->attributes.reallocate(output_curve->splines().size());
copy_dynamic_attributes(
input_curve.attributes, output_curve->attributes, IndexMask(copied_splines));
return output_curve;
}
static void separate_curve_selection(GeometrySet &geometry_set,
const Field<bool> &selection_field,
const eAttrDomain selection_domain)
static void delete_curves_selection(GeometrySet &geometry_set,
const Field<bool> &selection_field,
const eAttrDomain selection_domain)
{
const CurveComponent &src_component = *geometry_set.get_component_for_read<CurveComponent>();
GeometryComponentFieldContext field_context{src_component, selection_domain};
fn::FieldEvaluator evaluator{field_context,
src_component.attribute_domain_num(selection_domain)};
evaluator.add(selection_field);
const int domain_num = src_component.attribute_domain_num(selection_domain);
fn::FieldEvaluator evaluator{field_context, domain_num};
evaluator.set_selection(selection_field);
evaluator.evaluate();
const VArray_Span<bool> &selection = evaluator.get_evaluated<bool>(0);
std::unique_ptr<CurveEval> r_curve = curve_separate(
*curves_to_curve_eval(*src_component.get_for_read()), selection, selection_domain);
if (r_curve) {
geometry_set.replace_curves(curve_eval_to_curves(*r_curve));
const IndexMask selection = evaluator.get_evaluated_selection_as_mask();
if (selection.is_empty()) {
return;
}
else {
geometry_set.replace_curves(nullptr);
if (selection.size() == domain_num) {
geometry_set.remove<CurveComponent>();
return;
}
CurveComponent &component = geometry_set.get_component_for_write<CurveComponent>();
Curves &curves_id = *component.get_for_write();
bke::CurvesGeometry &curves = bke::CurvesGeometry::wrap(curves_id.geometry);
if (selection_domain == ATTR_DOMAIN_POINT) {
curves.remove_points(selection);
}
else if (selection_domain == ATTR_DOMAIN_CURVE) {
curves.remove_curves(selection);
}
}
@ -1224,7 +1098,8 @@ void separate_geometry(GeometrySet &geometry_set,
}
if (geometry_set.has_curves()) {
if (ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_CURVE)) {
file_ns::separate_curve_selection(geometry_set, selection_field, domain);
file_ns::delete_curves_selection(
geometry_set, fn::invert_boolean_field(selection_field), domain);
some_valid_domain = true;
}
}

View File

@ -981,7 +981,7 @@ static void render_result_uncrop(Render *re)
render_result_free(re->result);
re->result = rres;
/* weak... the display callback wants an active renderlayer pointer... */
/* Weak, the display callback wants an active render-layer pointer. */
re->result->renlay = render_get_active_layer(re, re->result);
BLI_rw_mutex_unlock(&re->resultmutex);
@ -1313,8 +1313,8 @@ static void do_render_sequencer(Render *re)
true,
&context);
/* the renderresult gets destroyed during the rendering, so we first collect all ibufs
* and then we populate the final renderesult */
/* The render-result gets destroyed during the rendering, so we first collect all ibufs
* and then we populate the final render-result. */
for (view_id = 0; view_id < tot_views; view_id++) {
context.view_id = view_id;

View File

@ -827,7 +827,7 @@ static void wm_drag_draw_icon(bContext *UNUSED(C),
x = xy[0] - (wm_drag_imbuf_icon_width_get(drag) / 2);
y = xy[1] - (wm_drag_imbuf_icon_height_get(drag) / 2);
float col[4] = {1.0f, 1.0f, 1.0f, 0.65f}; /* this blends texture */
const float col[4] = {1.0f, 1.0f, 1.0f, 0.65f}; /* this blends texture */
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTexTiled_scaling(&state,
x,

View File

@ -137,6 +137,13 @@ static struct {
.winid = -1,
};
/** Reuse the result from #GHOST_GetCursorGrabState. */
struct GrabState {
GHOST_TGrabCursorMode mode;
GHOST_TAxisFlag wrap_axis;
int bounds[4];
};
static bool wm_software_cursor_needed(void)
{
if (UNLIKELY(g_software_cursor.enabled == -1)) {
@ -145,10 +152,19 @@ static bool wm_software_cursor_needed(void)
return g_software_cursor.enabled;
}
static bool wm_software_cursor_needed_for_window(const wmWindow *win)
static bool wm_software_cursor_needed_for_window(const wmWindow *win, struct GrabState *grab_state)
{
BLI_assert(wm_software_cursor_needed());
return (win->grabcursor == GHOST_kGrabWrap) && GHOST_GetCursorVisibility(win->ghostwin);
if (GHOST_GetCursorVisibility(win->ghostwin)) {
/* NOTE: The value in `win->grabcursor` can't be used as it
* doesn't always match GHOST's value in the case of tablet events. */
GHOST_GetCursorGrabState(
win->ghostwin, &grab_state->mode, &grab_state->wrap_axis, grab_state->bounds);
if (grab_state->mode == GHOST_kGrabWrap) {
return true;
}
}
return false;
}
static bool wm_software_cursor_motion_test(const wmWindow *win)
@ -173,28 +189,24 @@ static void wm_software_cursor_motion_clear(void)
g_software_cursor.xy[1] = -1;
}
static void wm_software_cursor_draw(wmWindow *win)
static void wm_software_cursor_draw(wmWindow *win, const struct GrabState *grab_state)
{
int x = win->eventstate->xy[0];
int y = win->eventstate->xy[1];
int bounds[4];
GHOST_TAxisFlag wrap_axis = 0;
if (GHOST_GetCursorGrabState(win->ghostwin, &wrap_axis, bounds) != GHOST_kFailure) {
if (wrap_axis & GHOST_kAxisX) {
const int min = bounds[0];
const int max = bounds[2];
if (min != max) {
x = mod_i(x - min, max - min) + min;
}
if (grab_state->wrap_axis & GHOST_kAxisX) {
const int min = grab_state->bounds[0];
const int max = grab_state->bounds[2];
if (min != max) {
x = mod_i(x - min, max - min) + min;
}
if (wrap_axis & GHOST_kGrabAxisY) {
const int height = WM_window_pixels_y(win);
const int min = height - bounds[1];
const int max = height - bounds[3];
if (min != max) {
y = mod_i(y - max, min - max) + max;
}
}
if (grab_state->wrap_axis & GHOST_kGrabAxisY) {
const int height = WM_window_pixels_y(win);
const int min = height - grab_state->bounds[1];
const int max = height - grab_state->bounds[3];
if (min != max) {
y = mod_i(y - max, min - max) + max;
}
}
@ -979,8 +991,9 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view)
}
if (wm_software_cursor_needed()) {
if (wm_software_cursor_needed_for_window(win)) {
wm_software_cursor_draw(win);
struct GrabState grab_state;
if (wm_software_cursor_needed_for_window(win, &grab_state)) {
wm_software_cursor_draw(win, &grab_state);
wm_software_cursor_motion_update(win);
}
else {
@ -1139,7 +1152,9 @@ static bool wm_draw_update_test_window(Main *bmain, bContext *C, wmWindow *win)
}
if (wm_software_cursor_needed()) {
if (wm_software_cursor_needed_for_window(win) && wm_software_cursor_motion_test(win)) {
struct GrabState grab_state;
if (wm_software_cursor_needed_for_window(win, &grab_state) &&
wm_software_cursor_motion_test(win)) {
return true;
}
}

View File

@ -1379,7 +1379,7 @@ static int wm_operator_invoke(bContext *C,
if (op->type->invoke && event) {
/* Temporarily write into `mval` (not technically `const` correct) but this is restored. */
int mval_prev[2] = {UNPACK2(event->mval)};
const int mval_prev[2] = {UNPACK2(event->mval)};
wm_region_mouse_co(C, (wmEvent *)event);
if (op->type->flag & OPTYPE_UNDO) {
@ -3393,7 +3393,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
else {
/* Position is where the actual click happens, for more
* accurate selecting in case the mouse drifts a little. */
int xy[2] = {UNPACK2(event->xy)};
const int xy[2] = {UNPACK2(event->xy)};
copy_v2_v2_int(event->xy, event->prev_press_xy);
event->val = KM_CLICK;