Cleanup: Use references for sculpt undo and restore functions
This commit is contained in:
@@ -134,7 +134,7 @@ void mesh_show_all(Object &object, const Span<PBVHNode *> nodes)
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
const Span<int> verts = BKE_pbvh_node_get_vert_indices(node);
|
||||
if (std::any_of(verts.begin(), verts.end(), [&](const int i) { return hide_vert[i]; })) {
|
||||
undo::push_node(&object, node, undo::Type::HideVert);
|
||||
undo::push_node(object, node, undo::Type::HideVert);
|
||||
BKE_pbvh_node_mark_rebuild_draw(node);
|
||||
}
|
||||
}
|
||||
@@ -163,7 +163,7 @@ void grids_show_all(Depsgraph &depsgraph, Object &object, const Span<PBVHNode *>
|
||||
}))
|
||||
{
|
||||
any_changed = true;
|
||||
undo::push_node(&object, node, undo::Type::HideVert);
|
||||
undo::push_node(object, node, undo::Type::HideVert);
|
||||
BKE_pbvh_node_mark_rebuild_draw(node);
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ static void vert_hide_update(Object &object,
|
||||
}
|
||||
|
||||
any_changed = true;
|
||||
undo::push_node(&object, node, undo::Type::HideVert);
|
||||
undo::push_node(object, node, undo::Type::HideVert);
|
||||
array_utils::scatter(new_hide.as_span(), verts, hide_vert.span);
|
||||
|
||||
BKE_pbvh_node_mark_update_visibility(node);
|
||||
@@ -266,7 +266,7 @@ static void grid_hide_update(Depsgraph &depsgraph,
|
||||
}
|
||||
|
||||
any_changed = true;
|
||||
undo::push_node(&object, node, undo::Type::HideVert);
|
||||
undo::push_node(object, node, undo::Type::HideVert);
|
||||
|
||||
for (const int i : grids.index_range()) {
|
||||
grid_hidden[grids[i]].copy_from(new_hide[i].as_span());
|
||||
@@ -327,7 +327,7 @@ static void partialvis_update_bmesh_nodes(Object *ob,
|
||||
bool any_changed = false;
|
||||
bool any_visible = false;
|
||||
|
||||
undo::push_node(ob, node, undo::Type::HideVert);
|
||||
undo::push_node(*ob, node, undo::Type::HideVert);
|
||||
|
||||
partialvis_update_bmesh_verts(
|
||||
BKE_pbvh_bmesh_node_unique_verts(node), action, vert_test_fn, &any_changed, &any_visible);
|
||||
@@ -619,7 +619,7 @@ static void invert_visibility_mesh(Object &object, const Span<PBVHNode *> nodes)
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
Vector<int> &faces = all_index_data.local();
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(&object, node, undo::Type::HideFace);
|
||||
undo::push_node(object, node, undo::Type::HideFace);
|
||||
bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, faces);
|
||||
for (const int face : faces) {
|
||||
hide_poly.span[face] = !hide_poly.span[face];
|
||||
@@ -643,7 +643,7 @@ static void invert_visibility_grids(Depsgraph &depsgraph,
|
||||
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(&object, node, undo::Type::HideVert);
|
||||
undo::push_node(object, node, undo::Type::HideVert);
|
||||
for (const int i : BKE_pbvh_node_get_grid_indices(*node)) {
|
||||
bits::invert(grid_hidden[i]);
|
||||
}
|
||||
@@ -660,7 +660,7 @@ static void invert_visibility_bmesh(Object &object, const Span<PBVHNode *> nodes
|
||||
{
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(&object, node, undo::Type::HideVert);
|
||||
undo::push_node(object, node, undo::Type::HideVert);
|
||||
bool fully_hidden = true;
|
||||
for (BMVert *vert : BKE_pbvh_bmesh_node_unique_verts(node)) {
|
||||
BM_elem_flag_toggle(vert, BM_ELEM_HIDDEN);
|
||||
|
||||
@@ -219,7 +219,7 @@ static bool try_remove_mask_mesh(Object &object, const Span<PBVHNode *> nodes)
|
||||
if (std::all_of(verts.begin(), verts.end(), [&](const int i) { return mask[i] == 0.0f; })) {
|
||||
continue;
|
||||
}
|
||||
undo::push_node(&object, node, undo::Type::Mask);
|
||||
undo::push_node(object, node, undo::Type::Mask);
|
||||
BKE_pbvh_node_mark_redraw(node);
|
||||
}
|
||||
});
|
||||
@@ -250,7 +250,7 @@ static void fill_mask_mesh(Object &object, const float value, const Span<PBVHNod
|
||||
if (std::all_of(verts.begin(), verts.end(), [&](int i) { return mask.span[i] == value; })) {
|
||||
continue;
|
||||
}
|
||||
undo::push_node(&object, node, undo::Type::Mask);
|
||||
undo::push_node(object, node, undo::Type::Mask);
|
||||
mask.span.fill_indices(verts, value);
|
||||
BKE_pbvh_node_mark_redraw(node);
|
||||
}
|
||||
@@ -296,7 +296,7 @@ static void fill_mask_grids(Main &bmain,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
undo::push_node(&object, node, undo::Type::Mask);
|
||||
undo::push_node(object, node, undo::Type::Mask);
|
||||
|
||||
if (grid_hidden.is_empty()) {
|
||||
for (const int grid : grid_indices) {
|
||||
@@ -337,7 +337,7 @@ static void fill_mask_bmesh(Object &object, const float value, const Span<PBVHNo
|
||||
return;
|
||||
}
|
||||
|
||||
undo::push_node(&object, nodes.first(), undo::Type::Mask);
|
||||
undo::push_node(object, nodes.first(), undo::Type::Mask);
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
bool redraw = false;
|
||||
@@ -389,7 +389,7 @@ static void invert_mask_mesh(Object &object, const Span<PBVHNode *> nodes)
|
||||
".sculpt_mask", bke::AttrDomain::Point);
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(&object, node, undo::Type::Mask);
|
||||
undo::push_node(object, node, undo::Type::Mask);
|
||||
for (const int vert : BKE_pbvh_node_get_unique_vert_indices(node)) {
|
||||
if (!hide_vert.is_empty() && hide_vert[vert]) {
|
||||
continue;
|
||||
@@ -420,7 +420,7 @@ static void invert_mask_grids(Main &bmain,
|
||||
const Span<CCGElem *> grids = subdiv_ccg.grids;
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(&object, node, undo::Type::Mask);
|
||||
undo::push_node(object, node, undo::Type::Mask);
|
||||
|
||||
const Span<int> grid_indices = BKE_pbvh_node_get_grid_indices(*node);
|
||||
if (grid_hidden.is_empty()) {
|
||||
@@ -456,7 +456,7 @@ static void invert_mask_bmesh(Object &object, const Span<PBVHNode *> nodes)
|
||||
return;
|
||||
}
|
||||
|
||||
undo::push_node(&object, nodes.first(), undo::Type::Mask);
|
||||
undo::push_node(object, nodes.first(), undo::Type::Mask);
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
for (BMVert *vert : BKE_pbvh_bmesh_node_unique_verts(node)) {
|
||||
@@ -584,7 +584,7 @@ static void mask_gesture_apply_task(gesture::GestureData &gesture_data,
|
||||
if (!any_masked) {
|
||||
any_masked = true;
|
||||
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
|
||||
if (is_multires) {
|
||||
BKE_pbvh_node_mark_positions_update(node);
|
||||
|
||||
@@ -1787,7 +1787,7 @@ static void vpaint_paint_leaves(bContext *C,
|
||||
Span<PBVHNode *> nodes)
|
||||
{
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(ob, node, undo::Type::Color);
|
||||
undo::push_node(*ob, node, undo::Type::Color);
|
||||
}
|
||||
|
||||
const Brush *brush = ob->sculpt->cache->brush;
|
||||
@@ -2235,7 +2235,7 @@ static int vertex_color_set_exec(bContext *C, wmOperator *op)
|
||||
undo::push_begin(obact, op);
|
||||
Vector<PBVHNode *> nodes = blender::bke::pbvh::search_gather(obact->sculpt->pbvh, {});
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(obact, node, undo::Type::Color);
|
||||
undo::push_node(*obact, node, undo::Type::Color);
|
||||
}
|
||||
|
||||
paint_object_attributes_active_color_fill_ex(obact, paintcol, true, affect_alpha);
|
||||
|
||||
@@ -314,7 +314,7 @@ static void transform_active_color(bContext *C,
|
||||
|
||||
Vector<PBVHNode *> nodes = blender::bke::pbvh::search_gather(obact->sculpt->pbvh, {});
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(obact, node, undo::Type::Color);
|
||||
undo::push_node(*obact, node, undo::Type::Color);
|
||||
}
|
||||
|
||||
transform_active_color_data(*BKE_mesh_from_object(obact), transform_fn);
|
||||
|
||||
@@ -1229,7 +1229,7 @@ void SCULPT_orig_vert_data_init(SculptOrigVertData *data,
|
||||
blender::ed::sculpt_paint::undo::Type type)
|
||||
{
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
undo::Node *unode = undo::push_node(ob, node, type);
|
||||
undo::Node *unode = undo::push_node(*ob, node, type);
|
||||
SCULPT_orig_vert_data_unode_init(data, ob, unode);
|
||||
}
|
||||
|
||||
@@ -1297,12 +1297,12 @@ bool stroke_is_dyntopo(const SculptSession *ss, const Brush *brush)
|
||||
/** \name Sculpt Paint Mesh
|
||||
* \{ */
|
||||
|
||||
static void restore_mask(Object *ob, const Span<PBVHNode *> nodes)
|
||||
static void restore_mask(Object &object, const Span<PBVHNode *> nodes)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob->data);
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
|
||||
bke::SpanAttributeWriter<float> mask = attributes.lookup_or_add_for_write_span<float>(
|
||||
".sculpt_mask", bke::AttrDomain::Point);
|
||||
@@ -1323,7 +1323,7 @@ static void restore_mask(Object *ob, const Span<PBVHNode *> nodes)
|
||||
&ss->bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");
|
||||
if (offset != -1) {
|
||||
for (PBVHNode *node : nodes) {
|
||||
if (undo::push_node(ob, node, undo::Type::Mask)) {
|
||||
if (undo::push_node(object, node, undo::Type::Mask)) {
|
||||
for (BMVert *vert : BKE_pbvh_bmesh_node_unique_verts(node)) {
|
||||
const float orig_mask = BM_log_original_mask(ss->bm_log, vert);
|
||||
BM_ELEM_CD_SET_FLOAT(vert, offset, orig_mask);
|
||||
@@ -1361,12 +1361,12 @@ static void restore_mask(Object *ob, const Span<PBVHNode *> nodes)
|
||||
}
|
||||
}
|
||||
|
||||
static void restore_color(Object *ob, const Span<PBVHNode *> nodes)
|
||||
static void restore_color(Object &object, const Span<PBVHNode *> nodes)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
const auto restore_generic = [&](PBVHNode *node, undo::Node *unode) {
|
||||
SculptOrigVertData orig_vert_data;
|
||||
SCULPT_orig_vert_data_unode_init(&orig_vert_data, ob, unode);
|
||||
SCULPT_orig_vert_data_unode_init(&orig_vert_data, &object, unode);
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
SCULPT_orig_vert_data_update(&orig_vert_data, &vd);
|
||||
@@ -1388,7 +1388,7 @@ static void restore_color(Object *ob, const Span<PBVHNode *> nodes)
|
||||
}
|
||||
case PBVH_BMESH: {
|
||||
for (PBVHNode *node : nodes) {
|
||||
if (undo::Node *unode = undo::push_node(ob, node, undo::Type::Color)) {
|
||||
if (undo::Node *unode = undo::push_node(object, node, undo::Type::Color)) {
|
||||
restore_generic(node, unode);
|
||||
}
|
||||
}
|
||||
@@ -1407,13 +1407,13 @@ static void restore_color(Object *ob, const Span<PBVHNode *> nodes)
|
||||
}
|
||||
}
|
||||
|
||||
static void restore_face_set(Object *ob, const Span<PBVHNode *> nodes)
|
||||
static void restore_face_set(Object &object, const Span<PBVHNode *> nodes)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES:
|
||||
case PBVH_GRIDS: {
|
||||
bke::SpanAttributeWriter<int> attribute = face_set::ensure_face_sets_mesh(*ob);
|
||||
bke::SpanAttributeWriter<int> attribute = face_set::ensure_face_sets_mesh(object);
|
||||
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
if (undo::Node *unode = undo::get_node(node, undo::Type::FaceSet)) {
|
||||
@@ -1432,9 +1432,9 @@ static void restore_face_set(Object *ob, const Span<PBVHNode *> nodes)
|
||||
}
|
||||
}
|
||||
|
||||
static void restore_position(Object *ob, const Span<PBVHNode *> nodes)
|
||||
static void restore_position(Object &object, const Span<PBVHNode *> nodes)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
switch (BKE_pbvh_type(ss->pbvh)) {
|
||||
case PBVH_FACES: {
|
||||
MutableSpan positions = BKE_pbvh_get_vert_positions(ss->pbvh);
|
||||
@@ -1451,7 +1451,7 @@ static void restore_position(Object *ob, const Span<PBVHNode *> nodes)
|
||||
}
|
||||
case PBVH_BMESH: {
|
||||
for (PBVHNode *node : nodes) {
|
||||
if (undo::push_node(ob, node, undo::Type::Position)) {
|
||||
if (undo::push_node(object, node, undo::Type::Position)) {
|
||||
for (BMVert *vert : BKE_pbvh_bmesh_node_unique_verts(node)) {
|
||||
copy_v3_v3(vert->co, BM_log_original_vert_co(ss->bm_log, vert));
|
||||
}
|
||||
@@ -1492,31 +1492,31 @@ static void restore_position(Object *ob, const Span<PBVHNode *> nodes)
|
||||
bke::pbvh::update_normals(*ss->pbvh, ss->subdiv_ccg);
|
||||
}
|
||||
|
||||
static void restore_from_undo_step(Sculpt *sd, Object *ob)
|
||||
static void restore_from_undo_step(const Sculpt &sd, Object &object)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Brush *brush = BKE_paint_brush(&sd->paint);
|
||||
SculptSession *ss = object.sculpt;
|
||||
const Brush *brush = BKE_paint_brush_for_read(&sd.paint);
|
||||
|
||||
Vector<PBVHNode *> nodes = bke::pbvh::search_gather(ss->pbvh, {});
|
||||
|
||||
switch (brush->sculpt_tool) {
|
||||
case SCULPT_TOOL_MASK:
|
||||
restore_mask(ob, nodes);
|
||||
restore_mask(object, nodes);
|
||||
break;
|
||||
case SCULPT_TOOL_PAINT:
|
||||
case SCULPT_TOOL_SMEAR:
|
||||
restore_color(ob, nodes);
|
||||
restore_color(object, nodes);
|
||||
break;
|
||||
case SCULPT_TOOL_DRAW_FACE_SETS:
|
||||
if (ss->cache->alt_smooth) {
|
||||
restore_position(ob, nodes);
|
||||
restore_position(object, nodes);
|
||||
}
|
||||
else {
|
||||
restore_face_set(ob, nodes);
|
||||
restore_face_set(object, nodes);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
restore_position(ob, nodes);
|
||||
restore_position(object, nodes);
|
||||
break;
|
||||
}
|
||||
/* Disable multi-threading when dynamic-topology is enabled. Otherwise,
|
||||
@@ -1882,7 +1882,7 @@ static void calc_area_normal_and_center_task(Object *ob,
|
||||
bool normal_test_r, area_test_r;
|
||||
|
||||
if (ss->cache && !ss->cache->accum) {
|
||||
unode = undo::push_node(ob, node, undo::Type::Position);
|
||||
unode = undo::push_node(*ob, node, undo::Type::Position);
|
||||
use_original = (!unode->position.is_empty() || unode->bm_entry);
|
||||
}
|
||||
|
||||
@@ -3299,7 +3299,7 @@ static void sculpt_topology_update(Sculpt *sd,
|
||||
}
|
||||
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(ob,
|
||||
undo::push_node(*ob,
|
||||
node,
|
||||
brush->sculpt_tool == SCULPT_TOOL_MASK ? undo::Type::Mask :
|
||||
undo::Type::Position);
|
||||
@@ -3340,15 +3340,15 @@ static void do_brush_action_task(Object *ob, const Brush *brush, PBVHNode *node)
|
||||
need_coords = true;
|
||||
}
|
||||
else {
|
||||
undo::push_node(ob, node, undo::Type::FaceSet);
|
||||
undo::push_node(*ob, node, undo::Type::FaceSet);
|
||||
}
|
||||
}
|
||||
else if (brush->sculpt_tool == SCULPT_TOOL_MASK) {
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
BKE_pbvh_node_mark_update_mask(node);
|
||||
}
|
||||
else if (SCULPT_tool_is_paint(brush->sculpt_tool)) {
|
||||
undo::push_node(ob, node, undo::Type::Color);
|
||||
undo::push_node(*ob, node, undo::Type::Color);
|
||||
BKE_pbvh_node_mark_update_color(node);
|
||||
}
|
||||
else {
|
||||
@@ -3356,7 +3356,7 @@ static void do_brush_action_task(Object *ob, const Brush *brush, PBVHNode *node)
|
||||
}
|
||||
|
||||
if (need_coords) {
|
||||
undo::push_node(ob, node, undo::Type::Position);
|
||||
undo::push_node(*ob, node, undo::Type::Position);
|
||||
BKE_pbvh_node_mark_update(node);
|
||||
}
|
||||
}
|
||||
@@ -3689,7 +3689,7 @@ static void sculpt_combine_proxies_node(Object &object,
|
||||
float(*orco)[3] = nullptr;
|
||||
if (use_orco && !ss->bm) {
|
||||
orco = reinterpret_cast<float(*)[3]>(
|
||||
(undo::push_node(&object, &node, undo::Type::Position)->position.data()));
|
||||
(undo::push_node(object, &node, undo::Type::Position)->position.data()));
|
||||
}
|
||||
|
||||
MutableSpan<PBVHProxyNode> proxies = BKE_pbvh_node_get_proxies(&node);
|
||||
@@ -5277,7 +5277,7 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
|
||||
(brush->flag & BRUSH_DRAG_DOT))
|
||||
{
|
||||
|
||||
restore_from_undo_step(sd, ob);
|
||||
restore_from_undo_step(*sd, *ob);
|
||||
|
||||
if (ss->cache) {
|
||||
MEM_SAFE_FREE(ss->cache->layer_displacement_factor);
|
||||
@@ -5816,7 +5816,7 @@ static void sculpt_brush_stroke_cancel(bContext *C, wmOperator *op)
|
||||
/* XXX Canceling strokes that way does not work with dynamic topology,
|
||||
* user will have to do real undo for now. See #46456. */
|
||||
if (ss->cache && !dyntopo::stroke_is_dyntopo(ss, brush)) {
|
||||
restore_from_undo_step(sd, ob);
|
||||
restore_from_undo_step(*sd, *ob);
|
||||
}
|
||||
|
||||
paint_stroke_cancel(C, op, static_cast<PaintStroke *>(op->customdata));
|
||||
|
||||
@@ -124,7 +124,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op)
|
||||
BKE_pbvh_bmesh_detail_size_set(ss->pbvh, object_space_constant_detail);
|
||||
|
||||
undo::push_begin(ob, op);
|
||||
undo::push_node(ob, nullptr, undo::Type::Position);
|
||||
undo::push_node(*ob, nullptr, undo::Type::Position);
|
||||
|
||||
const double start_time = BLI_time_now_seconds();
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ void disable_with_undo(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *
|
||||
const bool use_undo = G.background ? (ED_undo_stack_get() != nullptr) : true;
|
||||
if (use_undo) {
|
||||
undo::push_begin_ex(ob, "Dynamic topology disable");
|
||||
undo::push_node(ob, nullptr, undo::Type::DyntopoEnd);
|
||||
undo::push_node(*ob, nullptr, undo::Type::DyntopoEnd);
|
||||
}
|
||||
SCULPT_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, nullptr);
|
||||
if (use_undo) {
|
||||
@@ -230,7 +230,7 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, Depsgraph *dep
|
||||
}
|
||||
enable_ex(bmain, depsgraph, ob);
|
||||
if (use_undo) {
|
||||
undo::push_node(ob, nullptr, undo::Type::DyntopoBegin);
|
||||
undo::push_node(*ob, nullptr, undo::Type::DyntopoBegin);
|
||||
undo::push_end(ob);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2037,17 +2037,17 @@ static void sculpt_expand_undo_push(Object *ob, Cache *expand_cache)
|
||||
switch (expand_cache->target) {
|
||||
case SCULPT_EXPAND_TARGET_MASK:
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
}
|
||||
break;
|
||||
case SCULPT_EXPAND_TARGET_FACE_SETS:
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(ob, node, undo::Type::FaceSet);
|
||||
undo::push_node(*ob, node, undo::Type::FaceSet);
|
||||
}
|
||||
break;
|
||||
case SCULPT_EXPAND_TARGET_COLORS:
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(ob, node, undo::Type::Color);
|
||||
undo::push_node(*ob, node, undo::Type::Color);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ static void do_draw_face_sets_brush_faces(Object *ob,
|
||||
BKE_pbvh_vertex_iter_end;
|
||||
|
||||
if (changed) {
|
||||
undo::push_node(ob, node, undo::Type::FaceSet);
|
||||
undo::push_node(*ob, node, undo::Type::FaceSet);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -310,7 +310,7 @@ static void do_draw_face_sets_brush_grids(Object *ob,
|
||||
BKE_pbvh_vertex_iter_end;
|
||||
|
||||
if (changed) {
|
||||
undo::push_node(ob, node, undo::Type::FaceSet);
|
||||
undo::push_node(*ob, node, undo::Type::FaceSet);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -397,7 +397,7 @@ static void do_draw_face_sets_brush_bmesh(Object *ob,
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
undo::push_node(ob, node, undo::Type::FaceSet);
|
||||
undo::push_node(*ob, node, undo::Type::FaceSet);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -521,7 +521,7 @@ static void face_sets_update(Object &object,
|
||||
continue;
|
||||
}
|
||||
|
||||
undo::push_node(&object, node, undo::Type::FaceSet);
|
||||
undo::push_node(object, node, undo::Type::FaceSet);
|
||||
array_utils::scatter(new_face_sets.as_span(), faces, face_sets.span);
|
||||
BKE_pbvh_node_mark_update_face_sets(node);
|
||||
}
|
||||
@@ -559,7 +559,7 @@ static void clear_face_sets(Object &object, const Span<PBVHNode *> nodes)
|
||||
return face_sets[face] != default_face_set;
|
||||
}))
|
||||
{
|
||||
undo::push_node(&object, node, undo::Type::FaceSet);
|
||||
undo::push_node(object, node, undo::Type::FaceSet);
|
||||
BKE_pbvh_node_mark_update_face_sets(node);
|
||||
}
|
||||
}
|
||||
@@ -826,7 +826,7 @@ static int sculpt_face_set_init_exec(bContext *C, wmOperator *op)
|
||||
|
||||
undo::push_begin(ob, op);
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(ob, node, undo::Type::FaceSet);
|
||||
undo::push_node(*ob, node, undo::Type::FaceSet);
|
||||
}
|
||||
|
||||
const float threshold = RNA_float_get(op->ptr, "threshold");
|
||||
@@ -1026,7 +1026,7 @@ static void face_hide_update(Object &object,
|
||||
}
|
||||
|
||||
any_changed = true;
|
||||
undo::push_node(&object, node, undo::Type::HideFace);
|
||||
undo::push_node(object, node, undo::Type::HideFace);
|
||||
array_utils::scatter(new_hide.as_span(), faces, hide_poly.span);
|
||||
BKE_pbvh_node_mark_update_visibility(node);
|
||||
}
|
||||
@@ -1512,7 +1512,7 @@ static void sculpt_face_set_edit_modify_coordinates(
|
||||
undo::push_begin(ob, op);
|
||||
for (PBVHNode *node : nodes) {
|
||||
BKE_pbvh_node_mark_update(node);
|
||||
undo::push_node(ob, node, undo::Type::Position);
|
||||
undo::push_node(*ob, node, undo::Type::Position);
|
||||
}
|
||||
switch (mode) {
|
||||
case EditMode::FairPositions:
|
||||
@@ -1710,7 +1710,7 @@ static void face_set_gesture_apply_mesh(gesture::GestureData &gesture_data,
|
||||
threading::parallel_for(gesture_data.nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
TLS &tls = all_tls.local();
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(gesture_data.vc.obact, node, undo::Type::FaceSet);
|
||||
undo::push_node(*gesture_data.vc.obact, node, undo::Type::FaceSet);
|
||||
const Span<int> node_faces =
|
||||
BKE_pbvh_type(&pbvh) == PBVH_FACES ?
|
||||
bke::pbvh::node_face_indices_calc_mesh(pbvh, *node, tls.face_indices) :
|
||||
@@ -1751,7 +1751,7 @@ static void face_set_gesture_apply_bmesh(gesture::GestureData &gesture_data,
|
||||
|
||||
threading::parallel_for(gesture_data.nodes.index_range(), 1, [&](const IndexRange range) {
|
||||
for (PBVHNode *node : nodes.slice(range)) {
|
||||
undo::push_node(gesture_data.vc.obact, node, undo::Type::FaceSet);
|
||||
undo::push_node(*gesture_data.vc.obact, node, undo::Type::FaceSet);
|
||||
|
||||
bool any_updated = false;
|
||||
for (BMFace *face : BKE_pbvh_bmesh_node_faces(node)) {
|
||||
|
||||
@@ -171,7 +171,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op)
|
||||
undo::push_begin(ob, op);
|
||||
|
||||
for (PBVHNode *node : nodes) {
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
}
|
||||
|
||||
Array<float> prev_mask;
|
||||
|
||||
@@ -130,7 +130,7 @@ void cache_init(bContext *C,
|
||||
}
|
||||
|
||||
for (const int i : ss->filter_cache->nodes.index_range()) {
|
||||
undo::push_node(ob, ss->filter_cache->nodes[i], undo_type);
|
||||
undo::push_node(*ob, ss->filter_cache->nodes[i], undo_type);
|
||||
}
|
||||
|
||||
/* Setup orientation matrices. */
|
||||
|
||||
@@ -1612,7 +1612,7 @@ void SCULPT_cache_free(blender::ed::sculpt_paint::StrokeCache *cache);
|
||||
|
||||
namespace blender::ed::sculpt_paint::undo {
|
||||
|
||||
undo::Node *push_node(const Object *ob, const PBVHNode *node, undo::Type type);
|
||||
undo::Node *push_node(const Object &object, const PBVHNode *node, undo::Type type);
|
||||
undo::Node *get_node(const PBVHNode *node, undo::Type type);
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,7 +53,7 @@ static void mask_init_task(Object *ob,
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
PBVHVertexIter vd;
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
float mask;
|
||||
switch (mode) {
|
||||
|
||||
@@ -199,7 +199,7 @@ static int sculpt_symmetrize_exec(bContext *C, wmOperator *op)
|
||||
* are logged as added (as opposed to attempting to store just the
|
||||
* parts that symmetrize modifies). */
|
||||
undo::push_begin(ob, op);
|
||||
undo::push_node(ob, nullptr, undo::Type::DyntopoSymmetrize);
|
||||
undo::push_node(*ob, nullptr, undo::Type::DyntopoSymmetrize);
|
||||
BM_log_before_all_removed(ss->bm, ss->bm_log);
|
||||
|
||||
BM_mesh_toolflags_set(ss->bm, true);
|
||||
@@ -417,7 +417,7 @@ void ED_object_sculptmode_enter_ex(Main *bmain,
|
||||
}
|
||||
dyntopo::enable_ex(bmain, depsgraph, ob);
|
||||
if (has_undo) {
|
||||
undo::push_node(ob, nullptr, undo::Type::DyntopoBegin);
|
||||
undo::push_node(*ob, nullptr, undo::Type::DyntopoBegin);
|
||||
undo::push_end(ob);
|
||||
}
|
||||
}
|
||||
@@ -758,7 +758,7 @@ static void do_mask_by_color_contiguous_update_node(Object *ob,
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
bool update_node = false;
|
||||
|
||||
PBVHVertexIter vd;
|
||||
@@ -869,7 +869,7 @@ static void do_mask_by_color_task(Object *ob,
|
||||
using namespace blender::ed::sculpt_paint;
|
||||
SculptSession *ss = ob->sculpt;
|
||||
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
bool update_node = false;
|
||||
|
||||
float active_color[4];
|
||||
@@ -1044,7 +1044,7 @@ static void sculpt_bake_cavity_exec_task(Object *ob,
|
||||
SculptSession *ss = ob->sculpt;
|
||||
PBVHVertexIter vd;
|
||||
|
||||
undo::push_node(ob, node, undo::Type::Mask);
|
||||
undo::push_node(*ob, node, undo::Type::Mask);
|
||||
|
||||
auto_mask::NodeData automask_data = auto_mask::node_begin(*ob, &automasking, *node);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ static void apply_projection(gesture::GestureData &gesture_data, PBVHNode *node)
|
||||
PBVHVertexIter vd;
|
||||
bool any_updated = false;
|
||||
|
||||
undo::push_node(gesture_data.vc.obact, node, undo::Type::Position);
|
||||
undo::push_node(*gesture_data.vc.obact, node, undo::Type::Position);
|
||||
|
||||
BKE_pbvh_vertex_iter_begin (gesture_data.ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
float vertex_normal[3];
|
||||
|
||||
@@ -149,7 +149,7 @@ static void sculpt_transform_task(Object *ob, const float transform_mats[8][4][4
|
||||
|
||||
PBVHVertexIter vd;
|
||||
|
||||
undo::push_node(ob, node, undo::Type::Position);
|
||||
undo::push_node(*ob, node, undo::Type::Position);
|
||||
BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
SCULPT_orig_vert_data_update(&orig_data, &vd);
|
||||
float *start_co;
|
||||
@@ -220,7 +220,7 @@ static void sculpt_elastic_transform_task(Object *ob,
|
||||
const float poisson_ratio = 0.4f;
|
||||
BKE_kelvinlet_init_params(¶ms, transform_radius, force, shear_modulus, poisson_ratio);
|
||||
|
||||
undo::push_node(ob, node, undo::Type::Position);
|
||||
undo::push_node(*ob, node, undo::Type::Position);
|
||||
|
||||
PBVHVertexIter vd;
|
||||
BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
|
||||
|
||||
@@ -454,7 +454,7 @@ static void gesture_begin(bContext &C, gesture::GestureData &gesture_data)
|
||||
generate_geometry(gesture_data);
|
||||
SCULPT_topology_islands_invalidate(ss);
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, gesture_data.vc.obact, false);
|
||||
undo::push_node(gesture_data.vc.obact, nullptr, undo::Type::Geometry);
|
||||
undo::push_node(*gesture_data.vc.obact, nullptr, undo::Type::Geometry);
|
||||
}
|
||||
|
||||
static int bm_face_isect_pair(BMFace *f, void * /*user_data*/)
|
||||
@@ -591,7 +591,7 @@ static void gesture_end(bContext & /*C*/, gesture::GestureData &gesture_data)
|
||||
|
||||
free_geometry(gesture_data);
|
||||
|
||||
undo::push_node(gesture_data.vc.obact, nullptr, undo::Type::Geometry);
|
||||
undo::push_node(*gesture_data.vc.obact, nullptr, undo::Type::Geometry);
|
||||
BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
|
||||
DEG_id_tag_update(&gesture_data.vc.obact->id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ struct SculptUndoStep {
|
||||
};
|
||||
|
||||
static UndoSculpt *get_nodes();
|
||||
static void sculpt_save_active_attribute(Object *ob, SculptAttrRef *attr);
|
||||
static void sculpt_save_active_attribute(Object &object, SculptAttrRef *attr);
|
||||
static UndoSculpt *sculpt_undosys_step_get_nodes(UndoStep *us_p);
|
||||
|
||||
#ifdef SCULPT_UNDO_DEBUG
|
||||
@@ -193,7 +193,7 @@ static void print_sculpt_node(Object *ob, Node *node)
|
||||
printf(" %s:%s {applied=%d}\n", undo_type_to_str(node->type), node->idname, node->applied);
|
||||
|
||||
if (node->bm_entry) {
|
||||
BM_log_print_entry(ob->sculpt ? ob->sculpt->bm : nullptr, node->bm_entry);
|
||||
BM_log_print_entry(object.sculpt ? object.sculpt->bm : nullptr, node->bm_entry);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,10 +413,13 @@ static bool restore_deformed(
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool restore_coords(
|
||||
bContext *C, Object *ob, Depsgraph *depsgraph, Node &unode, MutableSpan<bool> modified_verts)
|
||||
static bool restore_coords(bContext *C,
|
||||
Object &object,
|
||||
Depsgraph *depsgraph,
|
||||
Node &unode,
|
||||
MutableSpan<bool> modified_verts)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
|
||||
if (unode.mesh_verts_num) {
|
||||
@@ -425,14 +428,14 @@ static bool restore_coords(
|
||||
if (ss->shapekey_active && !STREQ(ss->shapekey_active->name, unode.shapeName)) {
|
||||
/* Shape key has been changed before calling undo operator. */
|
||||
|
||||
Key *key = BKE_key_from_object(ob);
|
||||
Key *key = BKE_key_from_object(&object);
|
||||
KeyBlock *kb = key ? BKE_keyblock_find_name(key, unode.shapeName) : nullptr;
|
||||
|
||||
if (kb) {
|
||||
ob->shapenr = BLI_findindex(&key->block, kb) + 1;
|
||||
object.shapenr = BLI_findindex(&key->block, kb) + 1;
|
||||
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, ob, false);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, &object, false);
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, &object);
|
||||
}
|
||||
else {
|
||||
/* Key has been removed -- skip this undo node. */
|
||||
@@ -445,7 +448,7 @@ static bool restore_coords(
|
||||
MutableSpan<float3> positions = ss->vert_positions;
|
||||
|
||||
if (ss->shapekey_active) {
|
||||
float(*vertCos)[3] = BKE_keyblock_convert_to_vertcos(ob, ss->shapekey_active);
|
||||
float(*vertCos)[3] = BKE_keyblock_convert_to_vertcos(&object, ss->shapekey_active);
|
||||
MutableSpan key_positions(reinterpret_cast<float3 *>(vertCos), ss->shapekey_active->totelem);
|
||||
|
||||
if (!unode.orig_position.is_empty()) {
|
||||
@@ -467,7 +470,7 @@ static bool restore_coords(
|
||||
}
|
||||
|
||||
/* Propagate new coords to keyblock. */
|
||||
SCULPT_vertcos_to_key(ob, ss->shapekey_active, key_positions);
|
||||
SCULPT_vertcos_to_key(&object, ss->shapekey_active, key_positions);
|
||||
|
||||
/* PBVH uses its own vertex array, so coords should be */
|
||||
/* propagated to PBVH here. */
|
||||
@@ -518,13 +521,13 @@ static bool restore_coords(
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool restore_hidden(Object *ob, Node &unode, MutableSpan<bool> modified_vertices)
|
||||
static bool restore_hidden(Object &object, Node &unode, MutableSpan<bool> modified_vertices)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
|
||||
if (unode.mesh_verts_num) {
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob->data);
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
bke::MutableAttributeAccessor attributes = mesh.attributes_for_write();
|
||||
bke::SpanAttributeWriter<bool> hide_vert = attributes.lookup_or_add_for_write_span<bool>(
|
||||
".hide_vert", bke::AttrDomain::Point);
|
||||
@@ -586,9 +589,9 @@ static bool restore_hidden_face(Object &object, Node &unode, MutableSpan<bool> m
|
||||
return modified;
|
||||
}
|
||||
|
||||
static bool restore_color(Object *ob, Node &unode, MutableSpan<bool> modified_vertices)
|
||||
static bool restore_color(Object &object, Node &unode, MutableSpan<bool> modified_vertices)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
|
||||
bool modified = false;
|
||||
|
||||
@@ -600,7 +603,7 @@ static bool restore_color(Object *ob, Node &unode, MutableSpan<bool> modified_ve
|
||||
modified = true;
|
||||
}
|
||||
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
Mesh *mesh = BKE_object_get_original_mesh(&object);
|
||||
|
||||
if (!unode.loop_col.is_empty() && unode.mesh_corners_num == mesh->corners_num) {
|
||||
BKE_pbvh_swap_colors(ss->pbvh, unode.corner_indices, unode.loop_col);
|
||||
@@ -614,10 +617,10 @@ static bool restore_color(Object *ob, Node &unode, MutableSpan<bool> modified_ve
|
||||
return modified;
|
||||
}
|
||||
|
||||
static bool restore_mask(Object *ob, Node &unode, MutableSpan<bool> modified_vertices)
|
||||
static bool restore_mask(Object &object, Node &unode, MutableSpan<bool> modified_vertices)
|
||||
{
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = BKE_object_get_original_mesh(&object);
|
||||
SculptSession *ss = object.sculpt;
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
|
||||
if (unode.mesh_verts_num) {
|
||||
@@ -656,11 +659,13 @@ static bool restore_mask(Object *ob, Node &unode, MutableSpan<bool> modified_ver
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool restore_face_sets(Object *ob, Node &unode, MutableSpan<bool> modified_face_set_faces)
|
||||
static bool restore_face_sets(Object &object,
|
||||
Node &unode,
|
||||
MutableSpan<bool> modified_face_set_faces)
|
||||
{
|
||||
const Span<int> face_indices = unode.face_indices;
|
||||
|
||||
bke::SpanAttributeWriter<int> face_sets = face_set::ensure_face_sets_mesh(*ob);
|
||||
bke::SpanAttributeWriter<int> face_sets = face_set::ensure_face_sets_mesh(object);
|
||||
bool modified = false;
|
||||
for (const int i : face_indices.index_range()) {
|
||||
const int face = face_indices[i];
|
||||
@@ -675,7 +680,7 @@ static bool restore_face_sets(Object *ob, Node &unode, MutableSpan<bool> modifie
|
||||
return modified;
|
||||
}
|
||||
|
||||
static void bmesh_restore_generic(Node &unode, Object *ob, SculptSession *ss)
|
||||
static void bmesh_restore_generic(Node &unode, Object &object, SculptSession *ss)
|
||||
{
|
||||
if (unode.applied) {
|
||||
BM_log_undo(ss->bm, ss->bm_log);
|
||||
@@ -693,17 +698,17 @@ static void bmesh_restore_generic(Node &unode, Object *ob, SculptSession *ss)
|
||||
}
|
||||
}
|
||||
else {
|
||||
SCULPT_pbvh_clear(ob);
|
||||
SCULPT_pbvh_clear(&object);
|
||||
}
|
||||
}
|
||||
|
||||
/* Create empty sculpt BMesh and enable logging. */
|
||||
static void bmesh_enable(Object *ob, Node &unode)
|
||||
static void bmesh_enable(Object &object, Node &unode)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
SculptSession *ss = object.sculpt;
|
||||
Mesh *mesh = static_cast<Mesh *>(object.data);
|
||||
|
||||
SCULPT_pbvh_clear(ob);
|
||||
SCULPT_pbvh_clear(&object);
|
||||
|
||||
/* Create empty BMesh and enable logging. */
|
||||
BMeshCreateParams bmesh_create_params{};
|
||||
@@ -718,14 +723,14 @@ static void bmesh_enable(Object *ob, Node &unode)
|
||||
ss->bm_log = BM_log_from_existing_entries_create(ss->bm, unode.bm_entry);
|
||||
}
|
||||
|
||||
static void bmesh_restore_begin(bContext *C, Node &unode, Object *ob, SculptSession *ss)
|
||||
static void bmesh_restore_begin(bContext *C, Node &unode, Object &object, SculptSession *ss)
|
||||
{
|
||||
if (unode.applied) {
|
||||
dyntopo::disable(C, &unode);
|
||||
unode.applied = false;
|
||||
}
|
||||
else {
|
||||
bmesh_enable(ob, unode);
|
||||
bmesh_enable(object, unode);
|
||||
|
||||
/* Restore the mesh from the first log entry. */
|
||||
BM_log_redo(ss->bm, ss->bm_log);
|
||||
@@ -734,10 +739,10 @@ static void bmesh_restore_begin(bContext *C, Node &unode, Object *ob, SculptSess
|
||||
}
|
||||
}
|
||||
|
||||
static void bmesh_restore_end(bContext *C, Node &unode, Object *ob, SculptSession *ss)
|
||||
static void bmesh_restore_end(bContext *C, Node &unode, Object &object, SculptSession *ss)
|
||||
{
|
||||
if (unode.applied) {
|
||||
bmesh_enable(ob, unode);
|
||||
bmesh_enable(object, unode);
|
||||
|
||||
/* Restore the mesh from the last log entry. */
|
||||
BM_log_undo(ss->bm, ss->bm_log);
|
||||
@@ -751,9 +756,9 @@ static void bmesh_restore_end(bContext *C, Node &unode, Object *ob, SculptSessio
|
||||
}
|
||||
}
|
||||
|
||||
static void store_geometry_data(NodeGeometry *geometry, const Object *object)
|
||||
static void store_geometry_data(NodeGeometry *geometry, const Object &object)
|
||||
{
|
||||
const Mesh *mesh = static_cast<const Mesh *>(object->data);
|
||||
const Mesh *mesh = static_cast<const Mesh *>(object.data);
|
||||
|
||||
BLI_assert(!geometry->is_initialized);
|
||||
geometry->is_initialized = true;
|
||||
@@ -774,9 +779,9 @@ static void store_geometry_data(NodeGeometry *geometry, const Object *object)
|
||||
geometry->faces_num = mesh->faces_num;
|
||||
}
|
||||
|
||||
static void restore_geometry_data(NodeGeometry *geometry, Object *object)
|
||||
static void restore_geometry_data(NodeGeometry *geometry, Object &object)
|
||||
{
|
||||
Mesh *mesh = static_cast<Mesh *>(object->data);
|
||||
Mesh *mesh = static_cast<Mesh *>(object.data);
|
||||
|
||||
BLI_assert(geometry->is_initialized);
|
||||
|
||||
@@ -809,10 +814,10 @@ static void geometry_free_data(NodeGeometry *geometry)
|
||||
&geometry->face_offsets_sharing_info);
|
||||
}
|
||||
|
||||
static void restore_geometry(Node &unode, Object *object)
|
||||
static void restore_geometry(Node &unode, Object &object)
|
||||
{
|
||||
if (unode.geometry_clear_pbvh) {
|
||||
SCULPT_pbvh_clear(object);
|
||||
SCULPT_pbvh_clear(&object);
|
||||
}
|
||||
|
||||
if (unode.applied) {
|
||||
@@ -829,19 +834,19 @@ static void restore_geometry(Node &unode, Object *object)
|
||||
*
|
||||
* Returns true if this was a dynamic-topology undo step, otherwise
|
||||
* returns false to indicate the non-dyntopo code should run. */
|
||||
static int bmesh_restore(bContext *C, Node &unode, Object *ob, SculptSession *ss)
|
||||
static int bmesh_restore(bContext *C, Node &unode, Object &object, SculptSession *ss)
|
||||
{
|
||||
switch (unode.type) {
|
||||
case Type::DyntopoBegin:
|
||||
bmesh_restore_begin(C, unode, ob, ss);
|
||||
bmesh_restore_begin(C, unode, object, ss);
|
||||
return true;
|
||||
|
||||
case Type::DyntopoEnd:
|
||||
bmesh_restore_end(C, unode, ob, ss);
|
||||
bmesh_restore_end(C, unode, object, ss);
|
||||
return true;
|
||||
default:
|
||||
if (ss->bm_log) {
|
||||
bmesh_restore_generic(unode, ob, ss);
|
||||
bmesh_restore_generic(unode, object, ss);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
@@ -865,14 +870,14 @@ static int bmesh_restore(bContext *C, Node &unode, Object *ob, SculptSession *ss
|
||||
* so if the object's modifier stack references other object it is all fine. */
|
||||
static void refine_subdiv(Depsgraph *depsgraph,
|
||||
SculptSession *ss,
|
||||
Object *object,
|
||||
Object &object,
|
||||
bke::subdiv::Subdiv *subdiv)
|
||||
{
|
||||
Array<float3> deformed_verts = BKE_multires_create_deformed_base_mesh_vert_coords(
|
||||
depsgraph, object, ss->multires.modifier);
|
||||
depsgraph, &object, ss->multires.modifier);
|
||||
|
||||
bke::subdiv::eval_refine_from_mesh(subdiv,
|
||||
static_cast<const Mesh *>(object->data),
|
||||
static_cast<const Mesh *>(object.data),
|
||||
reinterpret_cast<float(*)[3]>(deformed_verts.data()));
|
||||
}
|
||||
|
||||
@@ -882,8 +887,8 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, UndoSculpt &usculpt)
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
Object *ob = BKE_view_layer_active_object_get(view_layer);
|
||||
SculptSession *ss = ob->sculpt;
|
||||
Object &object = *BKE_view_layer_active_object_get(view_layer);
|
||||
SculptSession *ss = object.sculpt;
|
||||
SubdivCCG *subdiv_ccg = ss->subdiv_ccg;
|
||||
|
||||
bool clear_automask_cache = false;
|
||||
@@ -907,10 +912,10 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, UndoSculpt &usculpt)
|
||||
* ensure object is updated after the node is handled. */
|
||||
const Node *first_unode = usculpt.nodes.first().get();
|
||||
if (first_unode->type != Type::Geometry) {
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, ob, false);
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, &object, false);
|
||||
}
|
||||
|
||||
if (bmesh_restore(C, *usculpt.nodes.first(), ob, ss)) {
|
||||
if (bmesh_restore(C, *usculpt.nodes.first(), object, ss)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -936,7 +941,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, UndoSculpt &usculpt)
|
||||
Vector<bool> modified_faces_face_set;
|
||||
Vector<bool> modified_grids;
|
||||
for (std::unique_ptr<Node> &unode : usculpt.nodes) {
|
||||
if (!STREQ(unode->idname, ob->id.name)) {
|
||||
if (!STREQ(unode->idname, object.id.name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -959,44 +964,44 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, UndoSculpt &usculpt)
|
||||
switch (unode->type) {
|
||||
case Type::Position:
|
||||
modified_verts_position.resize(ss->totvert, false);
|
||||
if (restore_coords(C, ob, depsgraph, *unode, modified_verts_position)) {
|
||||
if (restore_coords(C, object, depsgraph, *unode, modified_verts_position)) {
|
||||
changed_position = true;
|
||||
}
|
||||
break;
|
||||
case Type::HideVert:
|
||||
modified_verts_hide.resize(ss->totvert, false);
|
||||
if (restore_hidden(ob, *unode, modified_verts_hide)) {
|
||||
if (restore_hidden(object, *unode, modified_verts_hide)) {
|
||||
changed_hide_vert = true;
|
||||
}
|
||||
break;
|
||||
case Type::HideFace:
|
||||
modified_faces_hide.resize(ss->totfaces, false);
|
||||
if (restore_hidden_face(*ob, *unode, modified_faces_hide)) {
|
||||
if (restore_hidden_face(object, *unode, modified_faces_hide)) {
|
||||
changed_hide_face = true;
|
||||
}
|
||||
break;
|
||||
case Type::Mask:
|
||||
modified_verts_mask.resize(ss->totvert, false);
|
||||
if (restore_mask(ob, *unode, modified_verts_mask)) {
|
||||
if (restore_mask(object, *unode, modified_verts_mask)) {
|
||||
changed_mask = true;
|
||||
}
|
||||
break;
|
||||
case Type::FaceSet:
|
||||
modified_faces_face_set.resize(ss->totfaces, false);
|
||||
if (restore_face_sets(ob, *unode, modified_faces_face_set)) {
|
||||
if (restore_face_sets(object, *unode, modified_faces_face_set)) {
|
||||
changed_face_sets = true;
|
||||
}
|
||||
break;
|
||||
case Type::Color:
|
||||
modified_verts_color.resize(ss->totvert, false);
|
||||
if (restore_color(ob, *unode, modified_verts_color)) {
|
||||
if (restore_color(object, *unode, modified_verts_color)) {
|
||||
changed_color = true;
|
||||
}
|
||||
break;
|
||||
case Type::Geometry:
|
||||
restore_geometry(*unode, ob);
|
||||
restore_geometry(*unode, object);
|
||||
changed_all_geometry = true;
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, ob, false);
|
||||
BKE_sculpt_update_object_for_edit(depsgraph, &object, false);
|
||||
break;
|
||||
|
||||
case Type::DyntopoBegin:
|
||||
@@ -1009,7 +1014,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, UndoSculpt &usculpt)
|
||||
|
||||
if (use_multires_undo) {
|
||||
for (std::unique_ptr<Node> &unode : usculpt.nodes) {
|
||||
if (!STREQ(unode->idname, ob->id.name)) {
|
||||
if (!STREQ(unode->idname, object.id.name)) {
|
||||
continue;
|
||||
}
|
||||
modified_grids.resize(unode->mesh_grids_num, false);
|
||||
@@ -1018,10 +1023,10 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, UndoSculpt &usculpt)
|
||||
}
|
||||
|
||||
if (subdiv_ccg != nullptr && changed_all_geometry) {
|
||||
refine_subdiv(depsgraph, ss, ob, subdiv_ccg->subdiv);
|
||||
refine_subdiv(depsgraph, ss, object, subdiv_ccg->subdiv);
|
||||
}
|
||||
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_SHADING);
|
||||
DEG_id_tag_update(&object.id, ID_RECALC_SHADING);
|
||||
|
||||
if (!changed_position && !changed_hide_vert && !changed_hide_face && !changed_mask &&
|
||||
!changed_face_sets && !changed_color)
|
||||
@@ -1060,37 +1065,37 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, UndoSculpt &usculpt)
|
||||
bke::pbvh::update_mask(*ss->pbvh);
|
||||
}
|
||||
if (changed_hide_face) {
|
||||
hide::sync_all_from_faces(*ob);
|
||||
hide::sync_all_from_faces(object);
|
||||
bke::pbvh::update_visibility(*ss->pbvh);
|
||||
}
|
||||
if (changed_hide_vert) {
|
||||
if (ELEM(BKE_pbvh_type(ss->pbvh), PBVH_FACES, PBVH_GRIDS)) {
|
||||
Mesh &mesh = *static_cast<Mesh *>(ob->data);
|
||||
Mesh &mesh = *static_cast<Mesh *>(object.data);
|
||||
BKE_pbvh_sync_visibility_from_verts(ss->pbvh, &mesh);
|
||||
}
|
||||
bke::pbvh::update_visibility(*ss->pbvh);
|
||||
}
|
||||
|
||||
if (BKE_sculpt_multires_active(scene, ob)) {
|
||||
if (BKE_sculpt_multires_active(scene, &object)) {
|
||||
if (changed_hide_vert) {
|
||||
multires_mark_as_modified(depsgraph, ob, MULTIRES_HIDDEN_MODIFIED);
|
||||
multires_mark_as_modified(depsgraph, &object, MULTIRES_HIDDEN_MODIFIED);
|
||||
}
|
||||
else if (changed_position) {
|
||||
multires_mark_as_modified(depsgraph, ob, MULTIRES_COORDS_MODIFIED);
|
||||
multires_mark_as_modified(depsgraph, &object, MULTIRES_COORDS_MODIFIED);
|
||||
}
|
||||
}
|
||||
|
||||
const bool tag_update = ID_REAL_USERS(ob->data) > 1 ||
|
||||
!BKE_sculptsession_use_pbvh_draw(ob, rv3d) || ss->shapekey_active ||
|
||||
const bool tag_update = ID_REAL_USERS(object.data) > 1 ||
|
||||
!BKE_sculptsession_use_pbvh_draw(&object, rv3d) || ss->shapekey_active ||
|
||||
ss->deform_modifiers_active;
|
||||
|
||||
if (tag_update) {
|
||||
Mesh *mesh = static_cast<Mesh *>(ob->data);
|
||||
Mesh *mesh = static_cast<Mesh *>(object.data);
|
||||
if (changed_position) {
|
||||
mesh->tag_positions_changed();
|
||||
BKE_sculptsession_free_deformMats(ss);
|
||||
}
|
||||
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
|
||||
DEG_id_tag_update(&object.id, ID_RECALC_GEOMETRY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1146,7 +1151,7 @@ static size_t alloc_and_store_hidden(const SculptSession *ss, Node *unode)
|
||||
|
||||
/* Allocate node and initialize its default fields specific for the given undo type.
|
||||
* Will also add the node to the list in the undo step. */
|
||||
static Node *alloc_node_type(const Object *object, const Type type)
|
||||
static Node *alloc_node_type(const Object &object, const Type type)
|
||||
{
|
||||
UndoSculpt *usculpt = get_nodes();
|
||||
std::unique_ptr<Node> unode = std::make_unique<Node>();
|
||||
@@ -1154,7 +1159,7 @@ static Node *alloc_node_type(const Object *object, const Type type)
|
||||
usculpt->undo_size += sizeof(Node);
|
||||
|
||||
Node *node_ptr = usculpt->nodes.last().get();
|
||||
STRNCPY(node_ptr->idname, object->id.name);
|
||||
STRNCPY(node_ptr->idname, object.id.name);
|
||||
node_ptr->type = type;
|
||||
|
||||
return node_ptr;
|
||||
@@ -1163,7 +1168,7 @@ static Node *alloc_node_type(const Object *object, const Type type)
|
||||
/* Will return first existing undo node of the given type.
|
||||
* If such node does not exist will allocate node of this type, register it in the undo step and
|
||||
* return it. */
|
||||
static Node *find_or_alloc_node_type(const Object *object, const Type type)
|
||||
static Node *find_or_alloc_node_type(const Object &object, const Type type)
|
||||
{
|
||||
UndoSculpt *usculpt = get_nodes();
|
||||
|
||||
@@ -1176,12 +1181,12 @@ static Node *find_or_alloc_node_type(const Object *object, const Type type)
|
||||
return alloc_node_type(object, type);
|
||||
}
|
||||
|
||||
static Node *alloc_node(const Object *ob, const PBVHNode *node, const Type type)
|
||||
static Node *alloc_node(const Object &object, const PBVHNode *node, const Type type)
|
||||
{
|
||||
UndoSculpt *usculpt = get_nodes();
|
||||
const SculptSession *ss = ob->sculpt;
|
||||
const SculptSession *ss = object.sculpt;
|
||||
|
||||
Node *unode = alloc_node_type(ob, type);
|
||||
Node *unode = alloc_node_type(object, type);
|
||||
unode->node = node;
|
||||
|
||||
int verts_num;
|
||||
@@ -1211,7 +1216,7 @@ static Node *alloc_node(const Object *ob, const PBVHNode *node, const Type type)
|
||||
|
||||
if (need_loops) {
|
||||
unode->corner_indices = BKE_pbvh_node_get_corner_indices(node);
|
||||
unode->mesh_corners_num = static_cast<Mesh *>(ob->data)->corners_num;
|
||||
unode->mesh_corners_num = static_cast<Mesh *>(object.data)->corners_num;
|
||||
|
||||
usculpt->undo_size += unode->corner_indices.as_span().size_in_bytes();
|
||||
}
|
||||
@@ -1292,9 +1297,9 @@ static Node *alloc_node(const Object *ob, const PBVHNode *node, const Type type)
|
||||
return unode;
|
||||
}
|
||||
|
||||
static void store_coords(const Object *ob, Node *unode)
|
||||
static void store_coords(const Object &object, Node *unode)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
|
||||
if (!unode->grids.is_empty()) {
|
||||
const SubdivCCG &subdiv_ccg = *ss->subdiv_ccg;
|
||||
@@ -1336,13 +1341,13 @@ static void store_coords(const Object *ob, Node *unode)
|
||||
}
|
||||
}
|
||||
|
||||
static void store_hidden(const Object *ob, Node *unode)
|
||||
static void store_hidden(const Object &object, Node *unode)
|
||||
{
|
||||
if (!unode->grids.is_empty()) {
|
||||
/* Already stored during allocation. */
|
||||
}
|
||||
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob->data);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
const VArraySpan<bool> hide_vert = *attributes.lookup<bool>(".hide_vert",
|
||||
bke::AttrDomain::Point);
|
||||
@@ -1372,9 +1377,9 @@ static void store_face_hidden(const Object &object, Node &unode)
|
||||
}
|
||||
}
|
||||
|
||||
static void store_mask(const Object *ob, Node *unode)
|
||||
static void store_mask(const Object &object, Node *unode)
|
||||
{
|
||||
const SculptSession *ss = ob->sculpt;
|
||||
const SculptSession *ss = object.sculpt;
|
||||
|
||||
if (!unode->grids.is_empty()) {
|
||||
const SubdivCCG &subdiv_ccg = *ss->subdiv_ccg;
|
||||
@@ -1395,7 +1400,7 @@ static void store_mask(const Object *ob, Node *unode)
|
||||
}
|
||||
}
|
||||
else {
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(ob->data);
|
||||
const Mesh &mesh = *static_cast<const Mesh *>(object.data);
|
||||
const bke::AttributeAccessor attributes = mesh.attributes();
|
||||
if (const VArray mask = *attributes.lookup<float>(".sculpt_mask", bke::AttrDomain::Point)) {
|
||||
array_utils::gather(mask, unode->vert_indices.as_span(), unode->mask.as_mutable_span());
|
||||
@@ -1406,9 +1411,9 @@ static void store_mask(const Object *ob, Node *unode)
|
||||
}
|
||||
}
|
||||
|
||||
static void store_color(const Object *ob, Node *unode)
|
||||
static void store_color(const Object &object, Node *unode)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
|
||||
BLI_assert(BKE_pbvh_type(ss->pbvh) == PBVH_FACES);
|
||||
|
||||
@@ -1433,7 +1438,7 @@ static NodeGeometry *geometry_get(Node *unode)
|
||||
return &unode->geometry_modified;
|
||||
}
|
||||
|
||||
static Node *geometry_push(const Object *object, const Type type)
|
||||
static Node *geometry_push(const Object &object, const Type type)
|
||||
{
|
||||
Node *unode = find_or_alloc_node_type(object, type);
|
||||
unode->applied = false;
|
||||
@@ -1453,10 +1458,10 @@ static void store_face_sets(const Mesh &mesh, Node &unode)
|
||||
unode.face_sets.as_mutable_span());
|
||||
}
|
||||
|
||||
static Node *bmesh_push(const Object *ob, const PBVHNode *node, Type type)
|
||||
static Node *bmesh_push(const Object &object, const PBVHNode *node, Type type)
|
||||
{
|
||||
UndoSculpt *usculpt = get_nodes();
|
||||
const SculptSession *ss = ob->sculpt;
|
||||
const SculptSession *ss = object.sculpt;
|
||||
|
||||
Node *unode = usculpt->nodes.is_empty() ? nullptr : usculpt->nodes.first().get();
|
||||
|
||||
@@ -1464,7 +1469,7 @@ static Node *bmesh_push(const Object *ob, const PBVHNode *node, Type type)
|
||||
usculpt->nodes.append(std::make_unique<Node>());
|
||||
unode = usculpt->nodes.last().get();
|
||||
|
||||
STRNCPY(unode->idname, ob->id.name);
|
||||
STRNCPY(unode->idname, object.id.name);
|
||||
unode->type = type;
|
||||
unode->applied = true;
|
||||
|
||||
@@ -1479,7 +1484,7 @@ static Node *bmesh_push(const Object *ob, const PBVHNode *node, Type type)
|
||||
* (converting faces to triangles) that the BMLog can't
|
||||
* fully restore from. */
|
||||
NodeGeometry *geometry = &unode->geometry_bmesh_enter;
|
||||
store_geometry_data(geometry, ob);
|
||||
store_geometry_data(geometry, object);
|
||||
|
||||
unode->bm_entry = BM_log_entry_add(ss->bm_log);
|
||||
BM_log_all_added(ss->bm, ss->bm_log);
|
||||
@@ -1537,9 +1542,9 @@ static Node *bmesh_push(const Object *ob, const PBVHNode *node, Type type)
|
||||
return unode;
|
||||
}
|
||||
|
||||
Node *push_node(const Object *ob, const PBVHNode *node, Type type)
|
||||
Node *push_node(const Object &object, const PBVHNode *node, Type type)
|
||||
{
|
||||
SculptSession *ss = ob->sculpt;
|
||||
SculptSession *ss = object.sculpt;
|
||||
|
||||
Node *unode;
|
||||
|
||||
@@ -1552,13 +1557,13 @@ Node *push_node(const Object *ob, const PBVHNode *node, Type type)
|
||||
if (ss->bm || ELEM(type, Type::DyntopoBegin, Type::DyntopoEnd)) {
|
||||
/* Dynamic topology stores only one undo node per stroke,
|
||||
* regardless of the number of PBVH nodes modified. */
|
||||
unode = bmesh_push(ob, node, type);
|
||||
unode = bmesh_push(object, node, type);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
// return unode;
|
||||
return;
|
||||
}
|
||||
if (type == Type::Geometry) {
|
||||
unode = geometry_push(ob, type);
|
||||
unode = geometry_push(object, type);
|
||||
BLI_thread_unlock(LOCK_CUSTOM1);
|
||||
// return unode;
|
||||
return;
|
||||
@@ -1569,26 +1574,26 @@ Node *push_node(const Object *ob, const PBVHNode *node, Type type)
|
||||
return;
|
||||
}
|
||||
|
||||
unode = alloc_node(ob, node, type);
|
||||
unode = alloc_node(object, node, type);
|
||||
|
||||
/* NOTE: If this ever becomes a bottleneck, make a lock inside of the node.
|
||||
* so we release global lock sooner, but keep data locked for until it is
|
||||
* fully initialized. */
|
||||
switch (type) {
|
||||
case Type::Position:
|
||||
store_coords(ob, unode);
|
||||
store_coords(object, unode);
|
||||
break;
|
||||
case Type::HideVert:
|
||||
store_hidden(ob, unode);
|
||||
store_hidden(object, unode);
|
||||
break;
|
||||
case Type::HideFace:
|
||||
store_face_hidden(*ob, *unode);
|
||||
store_face_hidden(object, *unode);
|
||||
break;
|
||||
case Type::Mask:
|
||||
store_mask(ob, unode);
|
||||
store_mask(object, unode);
|
||||
break;
|
||||
case Type::Color:
|
||||
store_color(ob, unode);
|
||||
store_color(object, unode);
|
||||
break;
|
||||
case Type::DyntopoBegin:
|
||||
case Type::DyntopoEnd:
|
||||
@@ -1597,7 +1602,7 @@ Node *push_node(const Object *ob, const PBVHNode *node, Type type)
|
||||
case Type::Geometry:
|
||||
break;
|
||||
case Type::FaceSet:
|
||||
store_face_sets(*static_cast<const Mesh *>(ob->data), *unode);
|
||||
store_face_sets(*static_cast<const Mesh *>(object.data), *unode);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1619,9 +1624,9 @@ Node *push_node(const Object *ob, const PBVHNode *node, Type type)
|
||||
return unode;
|
||||
}
|
||||
|
||||
static void sculpt_save_active_attribute(Object *ob, SculptAttrRef *attr)
|
||||
static void sculpt_save_active_attribute(Object &object, SculptAttrRef *attr)
|
||||
{
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
Mesh *mesh = BKE_object_get_original_mesh(&object);
|
||||
attr->was_set = true;
|
||||
attr->domain = NO_ACTIVE_LAYER;
|
||||
attr->name[0] = 0;
|
||||
@@ -1667,14 +1672,14 @@ void push_begin_ex(Object *ob, const char *name)
|
||||
ustack, C, name, BKE_UNDOSYS_TYPE_SCULPT);
|
||||
|
||||
if (!us->active_color_start.was_set) {
|
||||
sculpt_save_active_attribute(ob, &us->active_color_start);
|
||||
sculpt_save_active_attribute(*ob, &us->active_color_start);
|
||||
}
|
||||
|
||||
/* Set end attribute in case push_end is not called,
|
||||
* so we don't end up with corrupted state.
|
||||
*/
|
||||
if (!us->active_color_end.was_set) {
|
||||
sculpt_save_active_attribute(ob, &us->active_color_end);
|
||||
sculpt_save_active_attribute(*ob, &us->active_color_end);
|
||||
us->active_color_end.was_set = false;
|
||||
}
|
||||
}
|
||||
@@ -1709,7 +1714,7 @@ void push_end_ex(Object *ob, const bool use_nested_undo)
|
||||
SculptUndoStep *us = (SculptUndoStep *)BKE_undosys_stack_init_or_active_with_type(
|
||||
ustack, BKE_UNDOSYS_TYPE_SCULPT);
|
||||
|
||||
sculpt_save_active_attribute(ob, &us->active_color_end);
|
||||
sculpt_save_active_attribute(*ob, &us->active_color_end);
|
||||
print_nodes(ob, nullptr);
|
||||
}
|
||||
|
||||
@@ -1727,7 +1732,7 @@ static void set_active_layer(bContext *C, SculptAttrRef *attr)
|
||||
Mesh *mesh = BKE_object_get_original_mesh(ob);
|
||||
|
||||
SculptAttrRef existing;
|
||||
sculpt_save_active_attribute(ob, &existing);
|
||||
sculpt_save_active_attribute(*ob, &existing);
|
||||
|
||||
CustomDataLayer *layer = BKE_id_attribute_find(&mesh->id, attr->name, attr->type, attr->domain);
|
||||
|
||||
@@ -1933,18 +1938,18 @@ static void sculpt_undosys_step_free(UndoStep *us_p)
|
||||
void geometry_begin(Object *ob, const wmOperator *op)
|
||||
{
|
||||
push_begin(ob, op);
|
||||
push_node(ob, nullptr, Type::Geometry);
|
||||
push_node(*ob, nullptr, Type::Geometry);
|
||||
}
|
||||
|
||||
void geometry_begin_ex(Object *ob, const char *name)
|
||||
{
|
||||
push_begin_ex(ob, name);
|
||||
push_node(ob, nullptr, Type::Geometry);
|
||||
push_node(*ob, nullptr, Type::Geometry);
|
||||
}
|
||||
|
||||
void geometry_end(Object *ob)
|
||||
{
|
||||
push_node(ob, nullptr, Type::Geometry);
|
||||
push_node(*ob, nullptr, Type::Geometry);
|
||||
push_end(ob);
|
||||
}
|
||||
|
||||
@@ -2035,7 +2040,7 @@ static void push_all_grids(Object *object)
|
||||
|
||||
Vector<PBVHNode *> nodes = bke::pbvh::search_gather(ss->pbvh, {});
|
||||
for (PBVHNode *node : nodes) {
|
||||
Node *unode = push_node(object, node, Type::Position);
|
||||
Node *unode = push_node(*object, node, Type::Position);
|
||||
unode->node = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -2050,7 +2055,7 @@ void push_multires_mesh_begin(bContext *C, const char *str)
|
||||
|
||||
push_begin_ex(object, str);
|
||||
|
||||
Node *geometry_unode = push_node(object, nullptr, Type::Geometry);
|
||||
Node *geometry_unode = push_node(*object, nullptr, Type::Geometry);
|
||||
geometry_unode->geometry_clear_pbvh = false;
|
||||
|
||||
push_all_grids(object);
|
||||
@@ -2065,7 +2070,7 @@ void push_multires_mesh_end(bContext *C, const char *str)
|
||||
|
||||
Object *object = CTX_data_active_object(C);
|
||||
|
||||
Node *geometry_unode = push_node(object, nullptr, Type::Geometry);
|
||||
Node *geometry_unode = push_node(*object, nullptr, Type::Geometry);
|
||||
geometry_unode->geometry_clear_pbvh = false;
|
||||
|
||||
push_end(object);
|
||||
|
||||
Reference in New Issue
Block a user