Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include "CLG_log.h"
#include "DNA_key_types.h"
#include "DNA_layer_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_array_utils.h"
#include "BLI_listbase.h"
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_editmesh.h"
#include "BKE_key.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_undo_system.h"
#include "DEG_depsgraph.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_undo.h"
#include "ED_util.h"
#include "WM_api.h"
#include "WM_types.h"
#include "BLI_array_store.h"
#include "BLI_array_store_utils.h"
#include "BLI_task.h"
Go to the source code of this file.
Classes | |
struct | BArrayCustomData |
struct | UndoMesh |
struct | UMArrayData |
struct | MeshUndoStep_Elem |
struct | MeshUndoStep |
Macros | |
#define | USE_ARRAY_STORE |
#define | ARRAY_CHUNK_SIZE 256 |
#define | USE_ARRAY_STORE_THREAD |
Typedefs | |
Undo Conversion | |
typedef struct BArrayCustomData | BArrayCustomData |
typedef struct UndoMesh | UndoMesh |
Functions | |
static void * | undomesh_from_editmesh (UndoMesh *um, BMEditMesh *em, Key *key, UndoMesh *um_ref) |
static void | undomesh_to_editmesh (UndoMesh *um, Object *ob, BMEditMesh *em) |
static void | undomesh_free_data (UndoMesh *um) |
static Object * | editmesh_object_from_context (bContext *C) |
Array Store Utilities | |
static UndoMesh ** | mesh_undostep_reference_elems_from_objects (Object **object, int object_len) |
Variables | |
static CLG_LogRef | LOG = {"ed.undo.mesh"} |
Implements ED Undo System | |
| |
typedef struct MeshUndoStep_Elem | MeshUndoStep_Elem |
typedef struct MeshUndoStep | MeshUndoStep |
static bool | mesh_undosys_poll (bContext *C) |
static bool | mesh_undosys_step_encode (struct bContext *C, struct Main *bmain, UndoStep *us_p) |
static void | mesh_undosys_step_decode (struct bContext *C, struct Main *bmain, UndoStep *us_p, const eUndoStepDir UNUSED(dir), bool UNUSED(is_final)) |
static void | mesh_undosys_step_free (UndoStep *us_p) |
static void | mesh_undosys_foreach_ID_ref (UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data) |
void | ED_mesh_undosys_type (UndoType *ut) |
Array Store | |
struct { | |
struct BArrayStore_AtSize bs_stride | |
int users | |
ListBase local_links | |
TaskPool * task_pool | |
} | um_arraystore = {{NULL}} |
static void | um_arraystore_cd_compact (struct CustomData *cdata, const size_t data_len, bool create, const BArrayCustomData *bcd_reference, BArrayCustomData **r_bcd_first) |
static void | um_arraystore_cd_expand (const BArrayCustomData *bcd, struct CustomData *cdata, const size_t data_len) |
static void | um_arraystore_cd_free (BArrayCustomData *bcd) |
static void | um_arraystore_compact_ex (UndoMesh *um, const UndoMesh *um_ref, bool create) |
static void | um_arraystore_compact (UndoMesh *um, const UndoMesh *um_ref) |
static void | um_arraystore_compact_with_info (UndoMesh *um, const UndoMesh *um_ref) |
static void | um_arraystore_compact_cb (TaskPool *__restrict UNUSED(pool), void *taskdata) |
static void | um_arraystore_expand_clear (UndoMesh *um) |
static void | um_arraystore_expand (UndoMesh *um) |
static void | um_arraystore_free (UndoMesh *um) |
#define ARRAY_CHUNK_SIZE 256 |
Definition at line 54 of file editmesh_undo.c.
#define USE_ARRAY_STORE |
Definition at line 42 of file editmesh_undo.c.
#define USE_ARRAY_STORE_THREAD |
Definition at line 56 of file editmesh_undo.c.
typedef struct BArrayCustomData BArrayCustomData |
typedef struct MeshUndoStep MeshUndoStep |
typedef struct MeshUndoStep_Elem MeshUndoStep_Elem |
Export for ED_undo_sys.
Definition at line 888 of file editmesh_undo.c.
References UndoType::flags, mesh_undosys_foreach_ID_ref(), mesh_undosys_poll(), mesh_undosys_step_decode(), mesh_undosys_step_encode(), mesh_undosys_step_free(), UndoType::name, UndoType::poll, UndoType::step_decode, UndoType::step_encode, UndoType::step_foreach_ID_ref, UndoType::step_free, UndoType::step_size, and UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE.
Referenced by ED_undosys_type_init().
Definition at line 732 of file editmesh_undo.c.
References C, CTX_data_view_layer(), Object::data, Mesh::edit_mesh, NULL, OB_MESH, OBEDIT_FROM_VIEW_LAYER, and Object::type.
Referenced by mesh_undosys_poll().
|
static |
Create an array of UndoMesh from objects
.
where each element in the resulting array is the most recently created undo-mesh for the object's mesh. When no undo-mesh can be found that array index is NULL.
This is used for de-duplicating memory between undo steps, failure to find the undo step will store a full duplicate in memory. define DEBUG_PRINT
to check memory is de-duplicating as expected.
Definition at line 535 of file editmesh_undo.c.
References BLI_assert, BLI_ghash_free(), BLI_ghash_insert(), BLI_ghash_len(), BLI_ghash_popkey(), BLI_ghash_ptr_new_ex(), Mesh::id, UndoMesh::local_prev, UndoMesh::me, MEM_callocN, MEM_freeN, NULL, POINTER_FROM_INT, ID::session_uuid, and um_arraystore.
Referenced by mesh_undosys_step_encode().
|
static |
Definition at line 876 of file editmesh_undo.c.
References MeshUndoStep::elems, MeshUndoStep::elems_len, MeshUndoStep_Elem::obedit_ref, and user_data.
Referenced by ED_mesh_undosys_type().
Definition at line 764 of file editmesh_undo.c.
References C, editmesh_object_from_context(), and NULL.
Referenced by ED_mesh_undosys_type(), and mesh_undosys_step_decode().
|
static |
Definition at line 818 of file editmesh_undo.c.
References BKE_object_is_in_editmode(), BLI_assert, C, CLOG_ERROR, CTX_data_scene(), CTX_data_view_layer(), MeshUndoStep_Elem::data, Object::data, DEG_id_tag_update(), ED_undo_object_editmode_restore_helper(), ED_undo_object_set_active_or_warn(), Mesh::edit_mesh, MeshUndoStep::elems, MeshUndoStep::elems_len, Mesh::id, Object::id, ID_RECALC_GEOMETRY, Main::is_memfile_undo_flush_needed, LOG, mesh_undosys_poll(), UndoStep::name, ID::name, NC_GEOM, ND_DATA, BMEditMesh::needs_flush_to_id, NULL, MeshUndoStep_Elem::obedit_ref, scene, UndoMesh::selectmode, ToolSettings::selectmode, Scene::toolsettings, undomesh_to_editmesh(), UndoMesh::uv_selectmode, ToolSettings::uv_selectmode, and WM_event_add_notifier().
Referenced by ED_mesh_undosys_type().
|
static |
As this is only data storage it is safe to set the session ID here.
Definition at line 769 of file editmesh_undo.c.
References C, CTX_data_tool_settings(), CTX_data_view_layer(), MeshUndoStep_Elem::data, UndoStep::data_size, ED_undo_editmode_objects_from_view_layer(), Mesh::edit_mesh, MeshUndoStep::elems, MeshUndoStep::elems_len, Mesh::id, Main::is_memfile_undo_flush_needed, Mesh::key, UndoMesh::me, MEM_callocN, MEM_freeN, mesh_undostep_reference_elems_from_objects(), BMEditMesh::needs_flush_to_id, NULL, MeshUndoStep_Elem::obedit_ref, ID::session_uuid, MeshUndoStep::step, UndoMesh::undo_size, undomesh_from_editmesh(), UndoMesh::uv_selectmode, and ToolSettings::uv_selectmode.
Referenced by ED_mesh_undosys_type().
Definition at line 865 of file editmesh_undo.c.
References MeshUndoStep_Elem::data, MeshUndoStep::elems, MeshUndoStep::elems_len, MEM_freeN, and undomesh_free_data().
Referenced by ED_mesh_undosys_type().
|
static |
Definition at line 137 of file editmesh_undo.c.
References ARRAY_CHUNK_SIZE, BLI_array_store_at_size_ensure(), BLI_array_store_state_add(), blender::bke::idprop::create(), CustomData_layertype_is_dynamic(), CustomData_sizeof(), CustomDataLayer::data, if(), CustomData::layers, MEM_callocN, MEM_freeN, BArrayCustomData::next, NULL, BArrayCustomData::states, BArrayCustomData::states_len, stride, CustomData::totlayer, BArrayCustomData::type, type, CustomDataLayer::type, and um_arraystore.
Referenced by um_arraystore_compact_ex().
|
static |
Definition at line 262 of file editmesh_undo.c.
References BLI_array_store_state_data_get_alloc(), BLI_assert, CustomData_sizeof(), CustomDataLayer::data, CustomData::layers, BArrayCustomData::next, NULL, BArrayCustomData::states, BArrayCustomData::states_len, stride, BArrayCustomData::type, CustomDataLayer::type, and UNUSED_VARS_NDEBUG.
Referenced by um_arraystore_expand().
|
static |
Definition at line 286 of file editmesh_undo.c.
References BLI_array_store_at_size_get(), BLI_array_store_state_remove(), CustomData_sizeof(), MEM_freeN, BArrayCustomData::next, BArrayCustomData::states, BArrayCustomData::states_len, stride, BArrayCustomData::type, and um_arraystore.
Referenced by um_arraystore_free().
Move data from allocated arrays to de-duplicated states and clear arrays.
Definition at line 371 of file editmesh_undo.c.
References um_arraystore_compact_ex().
Referenced by um_arraystore_compact_with_info().
Definition at line 423 of file editmesh_undo.c.
References UMArrayData::um, um_arraystore_compact_with_info(), and UMArrayData::um_ref.
create | When false, only free the arrays. This is done since when reading from an undo state, they must be temporarily expanded. then discarded afterwards, having this argument avoids having 2x code paths. |
Definition at line 307 of file editmesh_undo.c.
References ARRAY_CHUNK_SIZE, BKE_mesh_update_customdata_pointers(), BLI_array_store_at_size_ensure(), BLI_array_store_state_add(), BLI_assert, Key::block, blender::bke::idprop::create(), KeyBlock::data, UndoMesh::edata, Mesh::edata, Key::elemsize, ListBase::first, Mesh::key, UndoMesh::keyblocks, UndoMesh::ldata, Mesh::ldata, UndoMesh::me, MEM_freeN, MEM_mallocN, UndoMesh::mselect, Mesh::mselect, KeyBlock::next, NULL, UndoMesh::pdata, Mesh::pdata, UndoMesh::store, stride, Mesh::totedge, KeyBlock::totelem, Key::totkey, Mesh::totloop, Mesh::totpoly, Mesh::totselect, Mesh::totvert, um_arraystore, um_arraystore_cd_compact(), UndoMesh::vdata, and Mesh::vdata.
Referenced by um_arraystore_compact(), and um_arraystore_expand_clear().
Definition at line 376 of file editmesh_undo.c.
References BLI_array_store_at_size_calc_memory_usage(), double(), TIMEIT_END, TIMEIT_START, um_arraystore, and um_arraystore_compact().
Referenced by um_arraystore_compact_cb().
Definition at line 439 of file editmesh_undo.c.
References BKE_mesh_update_customdata_pointers(), BLI_array_store_state_data_get_alloc(), BLI_assert, Key::block, KeyBlock::data, UndoMesh::edata, Mesh::edata, Key::elemsize, ListBase::first, Mesh::key, UndoMesh::keyblocks, UndoMesh::ldata, Mesh::ldata, UndoMesh::me, UndoMesh::mselect, Mesh::mselect, KeyBlock::next, UndoMesh::pdata, Mesh::pdata, state, UndoMesh::store, stride, Mesh::totedge, KeyBlock::totelem, Key::totkey, Mesh::totloop, Mesh::totpoly, Mesh::totselect, Mesh::totvert, UMArrayData::um, um_arraystore_cd_expand(), UNUSED_VARS_NDEBUG, UndoMesh::vdata, and Mesh::vdata.
Referenced by undomesh_free_data(), and undomesh_to_editmesh().
Remove data we only expanded for temporary use.
Definition at line 434 of file editmesh_undo.c.
References NULL, UMArrayData::um, and um_arraystore_compact_ex().
Referenced by undomesh_to_editmesh().
Definition at line 473 of file editmesh_undo.c.
References BLI_array_store_at_size_clear(), BLI_array_store_at_size_get(), BLI_array_store_state_remove(), BLI_assert, BLI_task_pool_free(), UndoMesh::edata, Key::elemsize, Mesh::key, UndoMesh::keyblocks, UndoMesh::ldata, UndoMesh::me, MEM_freeN, UndoMesh::mselect, Mesh::mselect, NULL, UndoMesh::pdata, state, UndoMesh::store, stride, Key::totkey, UMArrayData::um, um_arraystore, um_arraystore_cd_free(), and UndoMesh::vdata.
Referenced by undomesh_free_data().
Definition at line 704 of file editmesh_undo.c.
References BKE_key_free_data(), BKE_mesh_free_data_for_undo(), BLI_assert, BLI_findindex(), BLI_remlink(), BLI_task_pool_work_and_wait(), Mesh::key, UndoMesh::me, MEM_freeN, UMArrayData::um, um_arraystore, um_arraystore_expand(), and um_arraystore_free().
Referenced by mesh_undosys_step_free().
|
static |
um_ref | The reference to use for de-duplicating memory between undo-steps. |
Definition at line 576 of file editmesh_undo.c.
References BKE_id_copy_ex(), BLI_array_is_zeroed, BLI_assert, BLI_task_pool_work_and_wait(), BMEditMesh::bm, BM_mesh_bm_to_me(), Key::id, Mesh::key, LIB_ID_COPY_LOCALIZE, LIB_ID_COPY_NO_ANIMDATA, UndoMesh::me, NULL, UMArrayData::um, and um_arraystore.
Referenced by mesh_undosys_step_encode().
|
static |
Definition at line 638 of file editmesh_undo.c.
References BKE_editmesh_create(), BKE_editmesh_looptri_and_normals_calc(), BKE_mesh_vertex_normals_are_dirty(), BLI_assert, BLI_task_pool_work_and_wait(), BMEditMesh::bm, bm, BM_mesh_bm_from_me(), BM_mesh_create(), BM_SPACEARR_DIRTY_ALL, BMALLOC_TEMPLATE_FROM_ME, EDBM_mesh_free_data(), UndoMesh::me, MEM_freeN, BMEditMesh::selectmode, BMesh::selectmode, UndoMesh::selectmode, BMesh::shapenr, UndoMesh::shapenr, Object::shapenr, BMesh::spacearr_dirty, TIMEIT_END, TIMEIT_START, UMArrayData::um, um_arraystore, um_arraystore_expand(), and um_arraystore_expand_clear().
Referenced by mesh_undosys_step_decode().
struct BArrayStore_AtSize bs_stride |
Definition at line 108 of file editmesh_undo.c.
ListBase local_links |
A list of UndoMesh items ordered from oldest to newest used to access previous undo data for a mesh.
Definition at line 129 of file editmesh_undo.c.
|
static |
We only need this locally.
Definition at line 64 of file editmesh_undo.c.
Referenced by mesh_undosys_step_decode().
TaskPool* task_pool |
Definition at line 132 of file editmesh_undo.c.
Referenced by BKE_editmesh_loop_tangent_calc(), BKE_lib_override_library_main_operations_create(), BKE_mesh_calc_loop_tangent_ex(), BKE_mesh_normals_loop_split(), BLI_task_parallel_mempool(), bvh_reference_sort(), bvh_reference_sort_threaded(), blender::deg::deg_evaluate_on_refresh(), distribute_particles_on_dm(), do_sequence_proxy(), IMB_processor_apply_threaded(), project_paint_op(), psys_cache_child_paths(), blender::modifiers::geometry_nodes::GeometryNodesEvaluator::run_node_from_task_pool(), start_prefetch_threads(), and task_parallel_iterator_do().
struct { ... } um_arraystore |
int users |
Definition at line 123 of file editmesh_undo.c.