Blender
V3.3
|
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_mempool.h"
#include "BLI_utildefines.h"
#include "BKE_customdata.h"
#include "bmesh.h"
#include "bmesh_log.h"
#include "range_tree.h"
#include "BLI_strict_flags.h"
Go to the source code of this file.
Classes | |
struct | BMLogEntry |
struct | BMLog |
struct | BMLogVert |
struct | BMLogFace |
Macros | |
#define | logkey_hash BLI_ghashutil_inthash_p_simple |
#define | logkey_cmp BLI_ghashutil_intcmp |
The BMLog is an interface for storing undo/redo steps as a BMesh is modified. It only stores changes to the BMesh, not full copies.
Currently it supports the following types of changes:
Definition in file bmesh_log.c.
#define logkey_cmp BLI_ghashutil_intcmp |
Definition at line 112 of file bmesh_log.c.
#define logkey_hash BLI_ghashutil_inthash_p_simple |
Definition at line 111 of file bmesh_log.c.
Log all vertices/faces in the BMesh as added.
Definition at line 870 of file bmesh_log.c.
References BLI_ghash_len(), BLI_ghash_reserve(), bm, BM_FACES_OF_MESH, BM_ITER_MESH, BM_log_face_added(), BM_log_vert_added(), BM_VERTS_OF_MESH, CD_PAINT_MASK, CustomData_get_offset(), log(), BMesh::totface, BMesh::totvert, v, and BMesh::vdata.
Referenced by sculpt_symmetrize_exec(), and sculpt_undo_bmesh_push().
Definition at line 351 of file bmesh_log.c.
References bm, BM_FACES_OF_MESH, BM_ITER_MESH, bm_log_face_id_set(), bm_log_vert_id_set(), BM_VERTS_OF_MESH, log(), and v.
Referenced by BM_log_create().
Log all vertices/faces in the BMesh as removed.
Definition at line 897 of file bmesh_log.c.
References bm, BM_FACES_OF_MESH, BM_ITER_MESH, BM_log_face_removed(), BM_log_vert_removed(), BM_VERTS_OF_MESH, CD_PAINT_MASK, CustomData_get_offset(), log(), v, and BMesh::vdata.
Referenced by sculpt_symmetrize_exec(), and sculpt_undo_bmesh_push().
void BM_log_cleanup_entry | ( | BMLogEntry * | entry | ) |
Mark all used ids as unused for this node
Definition at line 476 of file bmesh_log.c.
References BMLogEntry::added_faces, BMLogEntry::added_verts, BLI_ghash_clear(), bm_log_id_ghash_retake(), BMLogEntry::deleted_faces, BMLogEntry::deleted_verts, log(), BMLogEntry::log, BMLogEntry::modified_faces, BMLogEntry::modified_verts, and NULL.
Definition at line 431 of file bmesh_log.c.
References BLI_ghash_insert(), BLI_ghash_int_new_ex(), map, POINTER_FROM_UINT, and uint_compare().
Referenced by BM_log_mesh_elems_reorder().
Allocate, initialize, and assign a new BMLog.
Definition at line 461 of file bmesh_log.c.
References BLI_ghash_new_ex(), BLI_ghash_ptr_new_ex(), bm, bm_log_assign_ids(), log(), logkey_cmp, logkey_hash, MEM_callocN, BMesh::totface, and BMesh::totvert.
Referenced by BM_log_from_existing_entries_create(), and SCULPT_dynamic_topology_enable_ex().
BMLogEntry* BM_log_current_entry | ( | BMLog * | log | ) |
BMLogEntry* BM_log_entry_add | ( | BMLog * | log | ) |
Start a new log entry and update the log entry list.
If the log entry list is empty, or if the current log entry is the last entry, the new entry is simply appended to the end.
Otherwise, the new entry is added after the current entry and all following entries are deleted.
In either case, the new entry is set as the current log entry.
Definition at line 620 of file bmesh_log.c.
References BLI_addtail(), BLI_freelinkN(), bm_log_entry_create(), bm_log_entry_free(), log(), BMLogEntry::log, BMLogEntry::next, and next.
Referenced by sculpt_undo_bmesh_push().
|
static |
Definition at line 371 of file bmesh_log.c.
References BMLogEntry::added_faces, BMLogEntry::added_verts, BLI_ghash_new(), BLI_mempool_create(), BLI_MEMPOOL_NOP, BMLogEntry::deleted_faces, BMLogEntry::deleted_verts, logkey_cmp, logkey_hash, MEM_callocN, BMLogEntry::modified_faces, BMLogEntry::modified_verts, BMLogEntry::pool_faces, and BMLogEntry::pool_verts.
Referenced by BM_log_entry_add().
void BM_log_entry_drop | ( | BMLogEntry * | entry | ) |
Remove an entry from the log.
Uses entry->log as the log. If the log is NULL, the entry will be free'd but not removed from any list, nor shall its IDs be released.
This operation is only valid on the first and last entries in the log. Deleting from the middle will assert.
Definition at line 647 of file bmesh_log.c.
References BMLogEntry::added_faces, BMLogEntry::added_verts, BLI_assert, BLI_assert_msg, BLI_freelinkN(), bm_log_entry_free(), bm_log_id_ghash_release(), log(), BMLogEntry::log, MEM_freeN, BMLogEntry::next, NULL, and BMLogEntry::prev.
Referenced by sculpt_undo_free_list().
|
static |
Definition at line 391 of file bmesh_log.c.
References BMLogEntry::added_faces, BMLogEntry::added_verts, BLI_ghash_free(), BLI_mempool_destroy(), BMLogEntry::deleted_faces, BMLogEntry::deleted_verts, BMLogEntry::modified_faces, BMLogEntry::modified_verts, NULL, BMLogEntry::pool_faces, and BMLogEntry::pool_verts.
Referenced by BM_log_entry_add(), and BM_log_entry_drop().
Log a new face as added to the BMesh.
The new face gets a unique ID assigned. It is then added to a map of added faces, with the key being its ID and the value containing everything needed to reconstruct that face.
Definition at line 807 of file bmesh_log.c.
References BLI_assert, BLI_ghash_insert(), bm_log_face_alloc(), bm_log_face_id_set(), BMFace::len, log(), and POINTER_FROM_UINT.
Referenced by BM_log_all_added(), and pbvh_bmesh_face_create().
Definition at line 206 of file bmesh_log.c.
References BLI_assert, BLI_mempool_alloc(), BM_face_as_array_vert_tri(), bm_log_vert_id_get(), BMFace::head, BMHeader::hflag, BMLogFace::hflag, BMFace::len, log(), BMLogEntry::pool_faces, v, and BMLogFace::v_ids.
Referenced by BM_log_face_added(), BM_log_face_modified(), and BM_log_face_removed().
Definition at line 155 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), log(), and POINTER_FROM_UINT.
Referenced by bm_log_face_values_swap(), and bm_log_faces_unmake().
Definition at line 139 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), log(), and POINTER_AS_UINT.
Referenced by BM_log_face_modified(), BM_log_face_removed(), and BM_log_mesh_elems_reorder().
Definition at line 146 of file bmesh_log.c.
References BLI_ghash_reinsert(), log(), NULL, and POINTER_FROM_UINT.
Referenced by bm_log_assign_ids(), BM_log_face_added(), and bm_log_faces_restore().
Log a face before it is modified.
This is intended to handle only header flags and we always assume face has been added before.
Definition at line 797 of file bmesh_log.c.
References BLI_ghash_insert(), bm_log_face_alloc(), bm_log_face_id_get(), log(), and POINTER_FROM_UINT.
Referenced by sculpt_undo_bmesh_push().
Log a face as removed from the BMesh.
A couple things can happen here:
If the face was added as part of the current log entry, then it's deleted and forgotten about entirely. Its unique ID is returned to the unused pool.
If the face was already part of the BMesh before the current log entry, it is added to a map of deleted faces, with the key being its ID and the value containing everything needed to reconstruct that face.
Definition at line 849 of file bmesh_log.c.
References BMLogEntry::added_faces, BLI_assert, BLI_ghash_haskey(), BLI_ghash_insert(), BLI_ghash_lookup(), BLI_ghash_remove(), bm_log_face_alloc(), bm_log_face_id_get(), BMLogEntry::deleted_faces, log(), NULL, and POINTER_FROM_UINT.
Referenced by BM_log_before_all_removed(), and pbvh_bmesh_face_remove().
Definition at line 335 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), bm_log_face_from_id(), faces, GHASH_ITER, BMFace::head, BMHeader::hflag, BMLogFace::hflag, log(), POINTER_AS_UINT, and SWAP.
Referenced by BM_log_redo(), and BM_log_undo().
Definition at line 288 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), bm, BM_CREATE_NOP, BM_ELEM_CD_SET_INT, BM_face_create_verts(), bm_log_face_id_set(), bm_log_vert_from_id(), CD_SCULPT_FACE_SETS, CustomData_get_offset(), faces, GHASH_ITER, BMFace::head, BMHeader::hflag, BMLogFace::hflag, log(), NULL, BMesh::pdata, POINTER_AS_UINT, v, and BMLogFace::v_ids.
Referenced by BM_log_redo(), and BM_log_undo().
Definition at line 246 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), bm, BM_edge_is_wire(), BM_edge_kill(), BM_FACE_FIRST_LOOP, BM_face_kill(), bm_log_face_from_id(), BMLoop::e, faces, GHASH_ITER, log(), BMLoop::next, and POINTER_AS_UINT.
Referenced by BM_log_redo(), and BM_log_undo().
Free all the data in a BMLog including the log itself.
Definition at line 539 of file bmesh_log.c.
References BLI_ghash_free(), log(), BMLogEntry::log, MEM_freeN, BMLogEntry::next, and NULL.
Referenced by BKE_sculptsession_free(), and SCULPT_dynamic_topology_disable_ex().
BMLog* BM_log_from_existing_entries_create | ( | BMesh * | bm, |
BMLogEntry * | entry | ||
) |
Allocate and initialize a new BMLog using existing #BMLogEntries
The 'entry' should be the last entry in the BMLog. Its prev pointer will be followed back to find the first entry.
The unused IDs field of the log will be initialized by taking all keys from all GHashes in the log entry.
Definition at line 498 of file bmesh_log.c.
References BMLogEntry::added_faces, BMLogEntry::added_verts, bm, BM_log_create(), bm_log_id_ghash_retake(), BMLogEntry::deleted_faces, BMLogEntry::deleted_verts, log(), BMLogEntry::log, BMLogEntry::modified_faces, BMLogEntry::modified_verts, BMLogEntry::next, NULL, and BMLogEntry::prev.
Referenced by sculpt_undo_bmesh_enable().
Definition at line 448 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), GHASH_ITER, log(), and POINTER_AS_UINT.
Referenced by BM_log_entry_drop().
Definition at line 404 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), GHASH_ITER, and POINTER_AS_UINT.
Referenced by BM_log_cleanup_entry(), and BM_log_from_existing_entries_create().
int BM_log_length | ( | const BMLog * | log | ) |
Get the number of log entries.
Definition at line 564 of file bmesh_log.c.
References BLI_listbase_count(), and log().
Apply a consistent ordering to BMesh vertices and faces.
Definition at line 569 of file bmesh_log.c.
References BLI_ghash_free(), BLI_ghash_lookup(), bm, BM_FACES_OF_MESH, BM_ITER_MESH_INDEX, bm_log_compress_ids_to_indices(), bm_log_face_id_get(), bm_log_vert_id_get(), BM_mesh_remap(), BM_VERTS_OF_MESH, log(), MEM_freeN, MEM_mallocN, NULL, POINTER_AS_UINT, POINTER_FROM_UINT, BMesh::totface, BMesh::totvert, and v.
Referenced by sculptsession_bm_to_me_update_data_only().
Get the logged mask of a vertex
Does not modify the log or the vertex.
Definition at line 945 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), bm_log_vert_id_get(), log(), BMLogVert::mask, BMLogEntry::modified_verts, POINTER_FROM_UINT, and v.
Referenced by SCULPT_orig_vert_data_update().
Get the logged coordinates of a vertex.
Does not modify the log or the vertex.
Definition at line 915 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), bm_log_vert_id_get(), BMLogVert::co, log(), BMLogEntry::modified_verts, POINTER_FROM_UINT, and v.
Referenced by sculpt_combine_proxies_task_cb().
void BM_log_original_vert_data | ( | BMLog * | log, |
BMVert * | v, | ||
const float ** | r_co, | ||
const float ** | r_no | ||
) |
Get the logged data of a vertex (avoid multiple lookups).
Definition at line 960 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), bm_log_vert_id_get(), BMLogVert::co, log(), BMLogEntry::modified_verts, BMLogVert::no, POINTER_FROM_UINT, and v.
Referenced by calc_area_normal_and_center_task_cb(), and SCULPT_orig_vert_data_update().
Get the logged normal of a vertex
Does not modify the log or the vertex.
Definition at line 930 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), bm_log_vert_id_get(), log(), BMLogEntry::modified_verts, BMLogVert::no, POINTER_FROM_UINT, and v.
Redo one BMLogEntry.
Has no effect if there's nothing left to redo.
Definition at line 734 of file bmesh_log.c.
References BMLogEntry::added_faces, BMLogEntry::added_verts, bm, bm_log_face_values_swap(), bm_log_faces_restore(), bm_log_faces_unmake(), bm_log_vert_values_swap(), bm_log_verts_restore(), bm_log_verts_unmake(), BMLogEntry::deleted_faces, BMLogEntry::deleted_verts, log(), BMLogEntry::modified_faces, BMLogEntry::modified_verts, and BMLogEntry::next.
Referenced by sculpt_undo_bmesh_restore_begin(), and sculpt_undo_bmesh_restore_generic().
Undo one BMLogEntry.
Has no effect if there's nothing left to undo.
Definition at line 713 of file bmesh_log.c.
References BMLogEntry::added_faces, BMLogEntry::added_verts, bm, bm_log_face_values_swap(), bm_log_faces_restore(), bm_log_faces_unmake(), bm_log_vert_values_swap(), bm_log_verts_restore(), bm_log_verts_unmake(), BMLogEntry::deleted_faces, BMLogEntry::deleted_verts, log(), BMLogEntry::modified_faces, BMLogEntry::modified_verts, and BMLogEntry::prev.
Referenced by sculpt_undo_bmesh_restore_end(), and sculpt_undo_bmesh_restore_generic().
RangeTreeUInt* BM_log_unused_ids | ( | BMLog * | log | ) |
Log a new vertex as added to the BMesh.
The new vertex gets a unique ID assigned. It is then added to a map of added vertices, with the key being its ID and the value containing everything needed to reconstruct that vertex.
Definition at line 786 of file bmesh_log.c.
References BLI_ghash_insert(), bm_log_vert_alloc(), bm_log_vert_id_set(), log(), POINTER_FROM_UINT, and v.
Referenced by BM_log_all_added(), and pbvh_bmesh_vert_create().
|
static |
Definition at line 195 of file bmesh_log.c.
References BLI_mempool_alloc(), bm_log_vert_bmvert_copy(), log(), BMLogEntry::pool_verts, and v.
Referenced by BM_log_vert_added(), BM_log_vert_before_modified(), and BM_log_vert_removed().
Log a vertex before it is modified.
Before modifying vertex coordinates, masks, or hflags, call this function to log its current values. This is better than logging after the coordinates have been modified, because only those vertices that are modified need to have their original values stored.
Handles two separate cases:
If the vertex was added in the current log entry, update the vertex in the map of added vertices.
If the vertex already existed prior to the current log entry, a separate key/value map of modified vertices is used (using the vertex's ID as the key). The values stored in that case are the vertex's original state so that an undo can restore the previous state.
On undo, the current vertex state will be swapped with the stored state so that a subsequent redo operation will restore the newer vertex state.
Definition at line 768 of file bmesh_log.c.
References BMLogEntry::added_verts, BLI_ghash_ensure_p(), BLI_ghash_lookup(), bm_log_vert_alloc(), bm_log_vert_bmvert_copy(), bm_log_vert_id_get(), log(), BMLogEntry::modified_verts, POINTER_FROM_UINT, and v.
Referenced by pbvh_bmesh_collapse_edge(), and sculpt_undo_bmesh_push().
|
static |
Definition at line 186 of file bmesh_log.c.
References BMVert::co, BMLogVert::co, copy_v3_v3(), BMVert::head, BMHeader::hflag, BMLogVert::hflag, BMLogVert::mask, BMVert::no, BMLogVert::no, v, and vert_mask_get().
Referenced by bm_log_vert_alloc(), BM_log_vert_before_modified(), and bm_log_verts_unmake().
Definition at line 131 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), log(), and POINTER_FROM_UINT.
Referenced by bm_log_faces_restore(), bm_log_vert_values_swap(), and bm_log_verts_unmake().
Definition at line 115 of file bmesh_log.c.
References BLI_assert, BLI_ghash_haskey(), BLI_ghash_lookup(), log(), POINTER_AS_UINT, and v.
Referenced by bm_log_face_alloc(), BM_log_mesh_elems_reorder(), BM_log_original_mask(), BM_log_original_vert_co(), BM_log_original_vert_data(), BM_log_original_vert_no(), BM_log_vert_before_modified(), and BM_log_vert_removed().
Definition at line 122 of file bmesh_log.c.
References BLI_ghash_reinsert(), log(), NULL, POINTER_FROM_UINT, and v.
Referenced by bm_log_assign_ids(), BM_log_vert_added(), and bm_log_verts_restore().
Log a vertex as removed from the BMesh.
A couple things can happen here:
If the vertex was added as part of the current log entry, then it's deleted and forgotten about entirely. Its unique ID is returned to the unused pool.
If the vertex was already part of the BMesh before the current log entry, it is added to a map of deleted vertices, with the key being its ID and the value containing everything needed to reconstruct that vertex.
If there's a move record for the vertex, that's used as the vertices original location, then the move record is deleted.
Definition at line 821 of file bmesh_log.c.
References BMLogEntry::added_verts, BLI_assert, BLI_ghash_haskey(), BLI_ghash_insert(), BLI_ghash_lookup(), BLI_ghash_remove(), bm_log_vert_alloc(), bm_log_vert_id_get(), BMLogEntry::deleted_verts, log(), BMLogEntry::modified_verts, NULL, POINTER_FROM_UINT, and v.
Referenced by BM_log_before_all_removed(), and pbvh_bmesh_collapse_edge().
Definition at line 314 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), bm, bm_log_vert_from_id(), CD_PAINT_MASK, BMVert::co, BMLogVert::co, CustomData_get_offset(), GHASH_ITER, BMVert::head, BMHeader::hflag, BMLogVert::hflag, log(), mask(), BMLogVert::mask, BMVert::no, BMLogVert::no, POINTER_AS_UINT, SWAP, swap_v3_v3(), v, BMesh::vdata, vert_mask_get(), vert_mask_set(), and verts.
Referenced by BM_log_redo(), and BM_log_undo().
Definition at line 272 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), bm, BM_CREATE_NOP, bm_log_vert_id_set(), BM_vert_create(), CD_PAINT_MASK, BMLogVert::co, copy_v3_v3(), CustomData_get_offset(), GHASH_ITER, BMVert::head, BMHeader::hflag, BMLogVert::hflag, log(), BMLogVert::mask, BMVert::no, BMLogVert::no, NULL, POINTER_AS_UINT, v, BMesh::vdata, vert_mask_set(), and verts.
Referenced by BM_log_redo(), and BM_log_undo().
Definition at line 227 of file bmesh_log.c.
References BLI_ghashIterator_getKey(), BLI_ghashIterator_getValue(), bm, bm_log_vert_bmvert_copy(), bm_log_vert_from_id(), BM_vert_kill(), CD_PAINT_MASK, CustomData_get_offset(), GHASH_ITER, log(), POINTER_AS_UINT, v, BMesh::vdata, and verts.
Referenced by BM_log_redo(), and BM_log_undo().
Definition at line 416 of file bmesh_log.c.
References Freestyle::a, and usdtokens::b().
Referenced by bm_log_compress_ids_to_indices().
Definition at line 167 of file bmesh_log.c.
References BM_ELEM_CD_GET_FLOAT, and v.
Referenced by bm_log_vert_bmvert_copy(), and bm_log_vert_values_swap().
|
static |
Definition at line 178 of file bmesh_log.c.
References BM_ELEM_CD_SET_FLOAT, and v.
Referenced by bm_log_vert_values_swap(), and bm_log_verts_restore().