Blender V4.3
sculpt_undo.cc File Reference
#include "sculpt_undo.hh"
#include <mutex>
#include "MEM_guardedalloc.h"
#include "BLI_array.hh"
#include "BLI_bit_group_vector.hh"
#include "BLI_enumerable_thread_specific.hh"
#include "BLI_listbase.h"
#include "BLI_map.hh"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "BLI_vector.hh"
#include "DNA_key_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BKE_attribute.hh"
#include "BKE_ccg.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_global.hh"
#include "BKE_key.hh"
#include "BKE_layer.hh"
#include "BKE_main.hh"
#include "BKE_mesh.hh"
#include "BKE_multires.hh"
#include "BKE_object.hh"
#include "BKE_paint.hh"
#include "BKE_scene.hh"
#include "BKE_subdiv_ccg.hh"
#include "BKE_subsurf.hh"
#include "BKE_undo_system.hh"
#include "BKE_subdiv_eval.hh"
#include "DEG_depsgraph.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_geometry.hh"
#include "ED_object.hh"
#include "ED_sculpt.hh"
#include "ED_undo.hh"
#include "bmesh.hh"
#include "mesh_brush_common.hh"
#include "paint_hide.hh"
#include "paint_intern.hh"
#include "sculpt_automask.hh"
#include "sculpt_color.hh"
#include "sculpt_dyntopo.hh"
#include "sculpt_face_set.hh"
#include "sculpt_intern.hh"

Go to the source code of this file.

Classes

struct  blender::ed::sculpt_paint::undo::Node
 
struct  blender::ed::sculpt_paint::undo::SculptAttrRef
 
struct  blender::ed::sculpt_paint::undo::NodeGeometry
 
struct  blender::ed::sculpt_paint::undo::StepData
 
struct  blender::ed::sculpt_paint::undo::SculptUndoStep
 

Namespaces

namespace  blender
 
namespace  blender::ed
 
namespace  blender::ed::sculpt_paint
 
namespace  blender::ed::sculpt_paint::undo
 

Macros

#define NO_ACTIVE_LAYER   bke::AttrDomain::Auto
 

Functions

static SculptUndoStepblender::ed::sculpt_paint::undo::get_active_step ()
 
static StepDatablender::ed::sculpt_paint::undo::get_step_data ()
 
static bool blender::ed::sculpt_paint::undo::use_multires_undo (const StepData &step_data, const SculptSession &ss)
 
static bool blender::ed::sculpt_paint::undo::topology_matches (const StepData &step_data, const Object &object)
 
static bool blender::ed::sculpt_paint::undo::indices_contain_true (const Span< bool > data, const Span< int > indices)
 
static bool blender::ed::sculpt_paint::undo::restore_active_shape_key (bContext &C, Depsgraph &depsgraph, const StepData &step_data, Object &object)
 
static void blender::ed::sculpt_paint::undo::update_shapekeys (const Object &ob, KeyBlock *kb, const Span< float3 > new_positions)
 
static void blender::ed::sculpt_paint::undo::restore_position_mesh (const Depsgraph &depsgraph, Object &object, const Span< std::unique_ptr< Node > > unodes, MutableSpan< bool > modified_verts)
 
static void blender::ed::sculpt_paint::undo::restore_position_grids (MutableSpan< float3 > positions, const CCGKey &key, Node &unode, MutableSpan< bool > modified_grids)
 
static void blender::ed::sculpt_paint::undo::restore_vert_visibility_mesh (Object &object, Node &unode, MutableSpan< bool > modified_vertices)
 
static void blender::ed::sculpt_paint::undo::restore_vert_visibility_grids (SubdivCCG &subdiv_ccg, Node &unode, MutableSpan< bool > modified_grids)
 
static void blender::ed::sculpt_paint::undo::restore_hidden_face (Object &object, Node &unode, MutableSpan< bool > modified_faces)
 
static void blender::ed::sculpt_paint::undo::restore_color (Object &object, StepData &step_data, MutableSpan< bool > modified_vertices)
 
static void blender::ed::sculpt_paint::undo::restore_mask_mesh (Object &object, Node &unode, MutableSpan< bool > modified_vertices)
 
static void blender::ed::sculpt_paint::undo::restore_mask_grids (Object &object, Node &unode, MutableSpan< bool > modified_grids)
 
static bool blender::ed::sculpt_paint::undo::restore_face_sets (Object &object, Node &unode, MutableSpan< bool > modified_face_set_faces)
 
static void blender::ed::sculpt_paint::undo::bmesh_restore_generic (StepData &step_data, Object &object, SculptSession &ss)
 
static void blender::ed::sculpt_paint::undo::bmesh_enable (Object &object, StepData &step_data)
 
static void blender::ed::sculpt_paint::undo::bmesh_restore_begin (bContext *C, StepData &step_data, Object &object, SculptSession &ss)
 
static void blender::ed::sculpt_paint::undo::bmesh_restore_end (bContext *C, StepData &step_data, Object &object, SculptSession &ss)
 
static void blender::ed::sculpt_paint::undo::store_geometry_data (NodeGeometry *geometry, const Object &object)
 
static void blender::ed::sculpt_paint::undo::restore_geometry_data (const NodeGeometry *geometry, Mesh *mesh)
 
static void blender::ed::sculpt_paint::undo::geometry_free_data (NodeGeometry *geometry)
 
static void blender::ed::sculpt_paint::undo::restore_geometry (StepData &step_data, Object &object)
 
static int blender::ed::sculpt_paint::undo::bmesh_restore (bContext *C, Depsgraph &depsgraph, StepData &step_data, Object &object, SculptSession &ss)
 
void blender::ed::sculpt_paint::undo::restore_from_bmesh_enter_geometry (const StepData &step_data, Mesh &mesh)
 
BMLogEntryblender::ed::sculpt_paint::undo::get_bmesh_log_entry ()
 
static void blender::ed::sculpt_paint::undo::refine_subdiv (Depsgraph *depsgraph, SculptSession &ss, Object &object, bke::subdiv::Subdiv *subdiv)
 
static void blender::ed::sculpt_paint::undo::restore_list (bContext *C, Depsgraph *depsgraph, StepData &step_data)
 
static void blender::ed::sculpt_paint::undo::free_step_data (StepData &step_data)
 
static const Nodeblender::ed::sculpt_paint::undo::get_node (const bke::pbvh::Node *node, const Type type)
 
static void blender::ed::sculpt_paint::undo::store_vert_visibility_grids (const SubdivCCG &subdiv_ccg, const bke::pbvh::GridsNode &node, Node &unode)
 
static void blender::ed::sculpt_paint::undo::store_positions_mesh (const Depsgraph &depsgraph, const Object &object, Node &unode)
 
static void blender::ed::sculpt_paint::undo::store_positions_grids (const SubdivCCG &subdiv_ccg, Node &unode)
 
static void blender::ed::sculpt_paint::undo::store_vert_visibility_mesh (const Mesh &mesh, const bke::pbvh::Node &node, Node &unode)
 
static void blender::ed::sculpt_paint::undo::store_face_visibility (const Mesh &mesh, Node &unode)
 
static void blender::ed::sculpt_paint::undo::store_mask_mesh (const Mesh &mesh, Node &unode)
 
static void blender::ed::sculpt_paint::undo::store_mask_grids (const SubdivCCG &subdiv_ccg, Node &unode)
 
static void blender::ed::sculpt_paint::undo::store_color (const Mesh &mesh, const bke::pbvh::MeshNode &node, Node &unode)
 
static NodeGeometryblender::ed::sculpt_paint::undo::geometry_get (StepData &step_data)
 
static void blender::ed::sculpt_paint::undo::geometry_push (const Object &object)
 
static void blender::ed::sculpt_paint::undo::store_face_sets (const Mesh &mesh, Node &unode)
 
static void blender::ed::sculpt_paint::undo::fill_node_data_mesh (const Depsgraph &depsgraph, const Object &object, const bke::pbvh::MeshNode &node, const Type type, Node &unode)
 
static void blender::ed::sculpt_paint::undo::fill_node_data_grids (const Object &object, const bke::pbvh::GridsNode &node, const Type type, Node &unode)
 
static BLI_NOINLINE void blender::ed::sculpt_paint::undo::bmesh_push (const Object &object, const bke::pbvh::BMeshNode *node, Type type)
 
static Nodeblender::ed::sculpt_paint::undo::ensure_node (StepData &step_data, const bke::pbvh::Node &node, bool &r_new)
 
void blender::ed::sculpt_paint::undo::push_node (const Depsgraph &depsgraph, const Object &object, const bke::pbvh::Node *node, Type type)
 
void blender::ed::sculpt_paint::undo::push_nodes (const Depsgraph &depsgraph, Object &object, const IndexMask &node_mask, const Type type)
 
static void blender::ed::sculpt_paint::undo::save_active_attribute (Object &object, SculptAttrRef *attr)
 
void blender::ed::sculpt_paint::undo::push_begin_ex (const Scene &, Object &ob, const char *name)
 
void blender::ed::sculpt_paint::undo::push_begin (const Scene &scene, Object &ob, const wmOperator *op)
 
static size_t blender::ed::sculpt_paint::undo::node_size_in_bytes (const Node &node)
 
void blender::ed::sculpt_paint::undo::push_end_ex (Object &ob, const bool use_nested_undo)
 
void blender::ed::sculpt_paint::undo::push_end (Object &ob)
 
std::optional< OrigPositionDatablender::ed::sculpt_paint::orig_position_data_lookup_mesh_all_verts (const Object &object, const bke::pbvh::MeshNode &node)
 
std::optional< OrigPositionDatablender::ed::sculpt_paint::orig_position_data_lookup_mesh (const Object &object, const bke::pbvh::MeshNode &node)
 
std::optional< OrigPositionDatablender::ed::sculpt_paint::orig_position_data_lookup_grids (const Object &object, const bke::pbvh::GridsNode &node)
 
void blender::ed::sculpt_paint::orig_position_data_gather_bmesh (const BMLog &bm_log, const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions, MutableSpan< float3 > normals)
 
std::optional< Span< float4 > > blender::ed::sculpt_paint::orig_color_data_lookup_mesh (const Object &object, const bke::pbvh::MeshNode &node)
 
std::optional< Span< int > > blender::ed::sculpt_paint::orig_face_set_data_lookup_mesh (const Object &object, const bke::pbvh::MeshNode &node)
 
std::optional< Span< int > > blender::ed::sculpt_paint::orig_face_set_data_lookup_grids (const Object &object, const bke::pbvh::GridsNode &node)
 
std::optional< Span< float > > blender::ed::sculpt_paint::orig_mask_data_lookup_mesh (const Object &object, const bke::pbvh::MeshNode &node)
 
std::optional< Span< float > > blender::ed::sculpt_paint::orig_mask_data_lookup_grids (const Object &object, const bke::pbvh::GridsNode &node)
 
Implements ED Undo System
static void blender::ed::sculpt_paint::undo::set_active_layer (bContext *C, SculptAttrRef *attr)
 
static void blender::ed::sculpt_paint::undo::step_encode_init (bContext *, UndoStep *us_p)
 
static bool blender::ed::sculpt_paint::undo::step_encode (bContext *, Main *bmain, UndoStep *us_p)
 
static void blender::ed::sculpt_paint::undo::step_decode_undo_impl (bContext *C, Depsgraph *depsgraph, SculptUndoStep *us)
 
static void blender::ed::sculpt_paint::undo::step_decode_redo_impl (bContext *C, Depsgraph *depsgraph, SculptUndoStep *us)
 
static void blender::ed::sculpt_paint::undo::step_decode_undo (bContext *C, Depsgraph *depsgraph, SculptUndoStep *us, const bool is_final)
 
static void blender::ed::sculpt_paint::undo::step_decode_redo (bContext *C, Depsgraph *depsgraph, SculptUndoStep *us)
 
static void blender::ed::sculpt_paint::undo::step_decode (bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir dir, bool is_final)
 
static void blender::ed::sculpt_paint::undo::step_free (UndoStep *us_p)
 
void blender::ed::sculpt_paint::undo::geometry_begin (const Scene &scene, Object &ob, const wmOperator *op)
 
void blender::ed::sculpt_paint::undo::geometry_begin_ex (const Scene &scene, Object &ob, const char *name)
 
void blender::ed::sculpt_paint::undo::geometry_end (Object &ob)
 
void blender::ed::sculpt_paint::undo::register_type (UndoType *ut)
 
Undo for changes happening on a base mesh for multires sculpting.

Use this for multires operators which changes base mesh and which are to be possible. Example of such operators is Apply Base.

Usage:

static int operator_exec((bContext *C, wmOperator *op) {

ED_sculpt_undo_push_mixed_begin(C, op->type->name); // Modify base mesh. ED_sculpt_undo_push_mixed_end(C, op->type->name);

return OPERATOR_FINISHED; }

If object is not in sculpt mode or sculpt does not happen on multires then regular ED_undo_push() is used.

static bool blender::ed::sculpt_paint::undo::use_multires_mesh (bContext *C)
 
static void blender::ed::sculpt_paint::undo::push_all_grids (const Depsgraph &depsgraph, Object *object)
 
void blender::ed::sculpt_paint::undo::push_multires_mesh_begin (bContext *C, const char *str)
 
void blender::ed::sculpt_paint::undo::push_multires_mesh_end (bContext *C, const char *str)
 

Detailed Description

Implements the Sculpt Mode tools.

Usage Guide

The sculpt undo system is a delta-based system. Each undo step stores the difference with the prior one.

To use the sculpt undo system, you must call push_begin inside an operator exec or invoke callback (geometry_begin may be called if you wish to save a non-delta copy of the entire mesh). This will initialize the sculpt undo stack and set up an undo step.

At the end of the operator you should call push_end.

push_begin and geometry_begin both take a wmOperatorType as an argument. There are _ex versions that allow a custom name; try to avoid using them. These can break the redo panel since it requires the undo push to have the same name as the calling operator.

NOTE: Sculpt undo steps are not appended to the global undo stack until the operator finishes. We use BKE_undosys_step_push_init_with_type to build a tentative undo step with is appended later when the operator ends. Operators must have the OPTYPE_UNDO flag set for this to work properly.

Definition in file sculpt_undo.cc.

Macro Definition Documentation

◆ NO_ACTIVE_LAYER

#define NO_ACTIVE_LAYER   bke::AttrDomain::Auto