|
Blender V4.3
|
#include <variant>#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_implicit_sharing.hh"#include "BLI_listbase.h"#include "BLI_string.h"#include "BLI_task.hh"#include "BLI_vector.hh"#include "BKE_context.hh"#include "BKE_customdata.hh"#include "BKE_editmesh.hh"#include "BKE_key.hh"#include "BKE_layer.hh"#include "BKE_lib_id.hh"#include "BKE_main.hh"#include "BKE_mesh.hh"#include "BKE_object.hh"#include "BKE_undo_system.hh"#include "DEG_depsgraph.hh"#include "ED_mesh.hh"#include "ED_object.hh"#include "ED_undo.hh"#include "ED_util.hh"#include "WM_api.hh"#include "WM_types.hh"#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_IN_BYTES 65536 |
| #define | ARRAY_CHUNK_NUM_MIN 256 |
| #define | USE_ARRAY_STORE_THREAD |
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) |
Undo Conversion | |
| static size_t | array_chunk_size_calc (const size_t stride) |
Array Store Utilities | |
| static UndoMesh ** | mesh_undostep_reference_elems_from_objects (Object **object, int object_len) |
Implements ED Undo System | |
| |
| static bool | mesh_undosys_poll (bContext *C) |
| static bool | mesh_undosys_step_encode (bContext *C, Main *bmain, UndoStep *us_p) |
| static void | mesh_undosys_step_decode (bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir, bool) |
| 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) |
Variables | |
| static CLG_LogRef | LOG = {"ed.undo.mesh"} |
| #define ARRAY_CHUNK_NUM_MIN 256 |
Definition at line 69 of file editmesh_undo.cc.
Referenced by array_chunk_size_calc().
| #define ARRAY_CHUNK_SIZE_IN_BYTES 65536 |
This used to be much smaller (256), but this caused too much overhead when selection moved to boolean arrays. Especially with high-poly meshes where managing a large number of small chunks could be slow, blocking user interactivity. Use a larger value (in bytes) which calculates the chunk size using array_chunk_size_calc. See: #105046 & #105205.
Definition at line 68 of file editmesh_undo.cc.
Referenced by array_chunk_size_calc().
| #define ARRAY_STORE_INDEX_NUM (ARRAY_STORE_INDEX_MSEL + 1) |
Definition at line 160 of file editmesh_undo.cc.
Referenced by um_arraystore_compact_with_info(), and um_arraystore_free().
| #define USE_ARRAY_STORE |
Definition at line 50 of file editmesh_undo.cc.
| #define USE_ARRAY_STORE_THREAD |
Definition at line 71 of file editmesh_undo.cc.
| anonymous enum |
Store separate BArrayStore_AtSize so multiple threads can access array stores without locking.
| Enumerator | |
|---|---|
| ARRAY_STORE_INDEX_VERT | |
| ARRAY_STORE_INDEX_EDGE | |
| ARRAY_STORE_INDEX_LOOP | |
| ARRAY_STORE_INDEX_POLY | |
| ARRAY_STORE_INDEX_POLY_OFFSETS | |
| ARRAY_STORE_INDEX_SHAPE | |
| ARRAY_STORE_INDEX_MSEL | |
Definition at line 151 of file editmesh_undo.cc.
|
static |
Definition at line 87 of file editmesh_undo.cc.
References ARRAY_CHUNK_NUM_MIN, ARRAY_CHUNK_SIZE_IN_BYTES, and power_of_2_max_i().
Referenced by um_arraystore_cd_compact().
| void ED_mesh_undosys_type | ( | UndoType * | ut | ) |
Export for ED_undo_sys.
Definition at line 1062 of file editmesh_undo.cc.
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 901 of file editmesh_undo.cc.
References BKE_view_layer_edit_object_get(), BKE_view_layer_synced_ensure(), CTX_data_scene(), CTX_data_view_layer(), Object::data, OB_MESH, 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 nullptr.
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 701 of file editmesh_undo.cc.
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, MEM_callocN, MEM_freeN(), UndoMesh::mesh, POINTER_FROM_INT, ID::session_uid, and um_arraystore.
Referenced by mesh_undosys_step_encode().
|
static |
Definition at line 1049 of file editmesh_undo.cc.
References MeshUndoStep::elems, MeshUndoStep::elems_len, MeshUndoStep_Elem::obedit_ref, and MeshUndoStep::scene_ref.
Referenced by ED_mesh_undosys_type().
|
static |
Definition at line 937 of file editmesh_undo.cc.
References editmesh_object_from_context().
Referenced by ED_mesh_undosys_type(), and mesh_undosys_step_decode().
|
static |
Definition at line 991 of file editmesh_undo.cc.
References BKE_object_is_in_editmode(), BLI_assert, CLOG_ERROR, CTX_data_scene(), CTX_data_view_layer(), CTX_wm_manager(), MeshUndoStep_Elem::data, Object::data, DEG_id_tag_update(), ED_undo_object_editmode_restore_helper(), ED_undo_object_editmode_validate_scene_from_windows(), ED_undo_object_set_active_or_warn(), MeshUndoStep::elems, MeshUndoStep::elems_len, Object::id, ID_RECALC_GEOMETRY, Main::is_memfile_undo_flush_needed, LOG, mesh_undosys_poll(), ID::name, UndoStep::name, NC_GEOM, ND_DATA, BMEditMesh::needs_flush_to_id, MeshUndoStep_Elem::obedit_ref, MeshUndoStep::scene_ref, UndoMesh::selectmode, undomesh_to_editmesh(), UndoMesh::uv_selectmode, and WM_event_add_notifier().
Referenced by ED_mesh_undosys_type().
As this is only data storage it is safe to set the session ID here.
Definition at line 942 of file editmesh_undo.cc.
References CTX_data_scene(), CTX_data_view_layer(), MeshUndoStep_Elem::data, UndoStep::data_size, ED_undo_editmode_objects_from_view_layer(), MeshUndoStep::elems, MeshUndoStep::elems_len, Mesh::id, Main::is_memfile_undo_flush_needed, MEM_callocN, MEM_freeN(), UndoMesh::mesh, mesh_undostep_reference_elems_from_objects(), BMEditMesh::needs_flush_to_id, MeshUndoStep_Elem::obedit_ref, scene, MeshUndoStep::scene_ref, ID::session_uid, MeshUndoStep::step, UndoMesh::undo_size, undomesh_from_editmesh(), ToolSettings::uv_selectmode, and UndoMesh::uv_selectmode.
Referenced by ED_mesh_undosys_type().
|
static |
Definition at line 1038 of file editmesh_undo.cc.
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 178 of file editmesh_undo.cc.
References blender::ImplicitSharingInfo::add_user(), array_chunk_size_calc(), BLI_array_store_at_size_ensure(), BLI_array_store_state_add(), CustomData_layertype_is_dynamic(), CustomData_sizeof(), blender::Array< T, InlineBufferCapacity, Allocator >::data(), CustomData::layers, MEM_SAFE_FREE, BArrayCustomData::next, blender::Array< T, InlineBufferCapacity, Allocator >::reinitialize(), BArrayCustomData::states, CustomData::totlayer, BArrayCustomData::type, CustomDataLayer::type, and um_arraystore.
|
static |
Definition at line 320 of file editmesh_undo.cc.
References BLI_array_store_state_data_get_alloc(), BLI_assert, CustomData_sizeof(), CustomData::layers, BArrayCustomData::next, blender::Array< T, InlineBufferCapacity, Allocator >::size(), state, BArrayCustomData::states, BArrayCustomData::type, and UNUSED_VARS_NDEBUG.
Referenced by um_arraystore_expand().
|
static |
Definition at line 354 of file editmesh_undo.cc.
References BLI_array_store_at_size_get(), BLI_array_store_state_remove(), CustomData_sizeof(), BArrayCustomData::next, blender::Array< T, InlineBufferCapacity, Allocator >::size(), state, BArrayCustomData::states, 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 505 of file editmesh_undo.cc.
References um_arraystore_compact_ex().
Referenced by um_arraystore_compact_with_info().
|
static |
Definition at line 569 of file editmesh_undo.cc.
References UMArrayData::um, um_arraystore_compact_with_info(), and UMArrayData::um_ref.
Referenced by undomesh_from_editmesh().
| 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 382 of file editmesh_undo.cc.
References UndoMesh::mesh, and blender::threading::parallel_invoke().
Referenced by um_arraystore_compact(), and um_arraystore_expand_clear().
Definition at line 510 of file editmesh_undo.cc.
References ARRAY_STORE_INDEX_NUM, BLI_array_store_at_size_calc_memory_usage(), double(), printf, TIMEIT_END, TIMEIT_START, um_arraystore, and um_arraystore_compact().
Referenced by um_arraystore_compact_cb(), and undomesh_from_editmesh().
|
static |
Definition at line 585 of file editmesh_undo.cc.
References BLI_array_store_state_data_get_alloc(), BLI_assert, KeyBlock::data, UndoMesh::edata, UndoMesh::face_offset_indices, blender::implicit_sharing::info_for_mem_free(), UndoMesh::keyblocks, UndoMesh::ldata, UndoMesh::mesh, UndoMesh::mselect, KeyBlock::next, UndoMesh::pdata, state, UndoMesh::store, KeyBlock::totelem, um_arraystore_cd_expand(), UNUSED_VARS_NDEBUG, and UndoMesh::vdata.
Referenced by undomesh_free_data(), and undomesh_to_editmesh().
|
static |
Remove data we only expanded for temporary use.
Definition at line 580 of file editmesh_undo.cc.
References um_arraystore_compact_ex().
Referenced by undomesh_to_editmesh().
|
static |
Definition at line 628 of file editmesh_undo.cc.
References ARRAY_STORE_INDEX_EDGE, ARRAY_STORE_INDEX_LOOP, ARRAY_STORE_INDEX_MSEL, ARRAY_STORE_INDEX_NUM, ARRAY_STORE_INDEX_POLY, ARRAY_STORE_INDEX_POLY_OFFSETS, ARRAY_STORE_INDEX_SHAPE, ARRAY_STORE_INDEX_VERT, 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, UndoMesh::face_offset_indices, UndoMesh::keyblocks, UndoMesh::ldata, MEM_freeN(), UndoMesh::mesh, UndoMesh::mselect, UndoMesh::pdata, printf, state, UndoMesh::store, um_arraystore, um_arraystore_cd_free(), and UndoMesh::vdata.
Referenced by undomesh_free_data().
|
static |
Definition at line 873 of file editmesh_undo.cc.
References BKE_key_free_data(), BKE_mesh_free_data_for_undo(), BLI_assert, BLI_findindex(), BLI_remlink(), BLI_task_pool_work_and_wait(), MEM_freeN(), UndoMesh::mesh, 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 745 of file editmesh_undo.cc.
References BKE_id_copy_ex(), BLI_addtail(), BLI_array_is_zeroed, BLI_assert, BLI_task_pool_create_background(), BLI_task_pool_push(), BLI_task_pool_work_and_wait(), BMEditMesh::bm, BM_mesh_bm_to_me(), CD_MASK_SHAPE_KEYINDEX, Key::id, Mesh::id, Mesh::key, LIB_ID_COPY_LOCALIZE, LIB_ID_COPY_NO_ANIMDATA, MEM_mallocN, UndoMesh::mesh, ID::name, params, Mesh::runtime, BMEditMesh::selectmode, UndoMesh::selectmode, BMesh::shapenr, UndoMesh::shapenr, STRNCPY, TASK_PRIORITY_LOW, UMArrayData::um, um_arraystore, um_arraystore_compact_cb(), um_arraystore_compact_with_info(), UMArrayData::um_ref, UNUSED_VARS, and CustomData_MeshMasks::vmask.
Referenced by mesh_undosys_step_encode().
|
static |
Definition at line 814 of file editmesh_undo.cc.
References BKE_editmesh_create(), BKE_editmesh_looptris_and_normals_calc(), BLI_task_pool_work_and_wait(), bm, BMEditMesh::bm, BM_mesh_bm_from_me(), BM_mesh_create(), BM_SPACEARR_DIRTY_ALL, BMALLOC_TEMPLATE_FROM_ME, BMeshFromMeshParams::calc_face_normal, EDBM_mesh_free_data(), UndoMesh::mesh, BMEditMesh::selectmode, BMesh::selectmode, UndoMesh::selectmode, BMesh::shapenr, Object::shapenr, UndoMesh::shapenr, BMesh::spacearr_dirty, TIMEIT_END, TIMEIT_START, um_arraystore, um_arraystore_expand(), um_arraystore_expand_clear(), and BMeshCreateParams::use_toolflags.
Referenced by mesh_undosys_step_decode().
| BArrayStore_AtSize bs_stride[ARRAY_STORE_INDEX_NUM] |
Definition at line 163 of file editmesh_undo.cc.
| 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 170 of file editmesh_undo.cc.
|
static |
We only need this locally.
Definition at line 79 of file editmesh_undo.cc.
Referenced by mesh_undosys_step_decode().
| TaskPool* task_pool |
Definition at line 173 of file editmesh_undo.cc.
Referenced by BKE_editmesh_loop_tangent_calc(), BKE_lib_override_library_main_operations_create(), BKE_mesh_calc_loop_tangent_ex(), BLI_task_parallel_mempool(), bvh_reference_sort(), bvh_reference_sort_threaded(), blender::deg::deg_evaluate_on_refresh(), distribute_particles_on_dm(), do_sequence_proxy(), blender::fn::lazy_function::Executor::execute(), execute_read_sound_waveform_task(), free_read_sound_waveform_task(), IMB_processor_apply_threaded(), preview_startjob(), project_paint_op(), psys_cache_child_paths(), push_preview_job_audio_task(), start_prefetch_threads(), and blender::fn::lazy_function::Executor::~Executor().
| struct { ... } um_arraystore |
| int users |
Definition at line 164 of file editmesh_undo.cc.