Blender  V3.3
Typedefs | Functions
bmesh_log.h File Reference

Go to the source code of this file.

Typedefs

typedef struct BMLog BMLog
 
typedef struct BMLogEntry BMLogEntry
 

Functions

BMLogBM_log_create (BMesh *bm)
 
BMLogBM_log_from_existing_entries_create (BMesh *bm, BMLogEntry *entry)
 
void BM_log_free (BMLog *log)
 
int BM_log_length (const BMLog *log)
 
void BM_log_mesh_elems_reorder (BMesh *bm, BMLog *log)
 
BMLogEntryBM_log_entry_add (BMLog *log)
 
void BM_log_cleanup_entry (BMLogEntry *entry)
 
void BM_log_entry_drop (BMLogEntry *entry)
 
void BM_log_undo (BMesh *bm, BMLog *log)
 
void BM_log_redo (BMesh *bm, BMLog *log)
 
void BM_log_vert_before_modified (BMLog *log, struct BMVert *v, int cd_vert_mask_offset)
 
void BM_log_vert_added (BMLog *log, struct BMVert *v, int cd_vert_mask_offset)
 
void BM_log_face_modified (BMLog *log, struct BMFace *f)
 
void BM_log_face_added (BMLog *log, struct BMFace *f)
 
void BM_log_vert_removed (BMLog *log, struct BMVert *v, int cd_vert_mask_offset)
 
void BM_log_face_removed (BMLog *log, struct BMFace *f)
 
void BM_log_all_added (BMesh *bm, BMLog *log)
 
void BM_log_before_all_removed (BMesh *bm, BMLog *log)
 
const floatBM_log_original_vert_co (BMLog *log, BMVert *v)
 
const floatBM_log_original_vert_no (BMLog *log, BMVert *v)
 
float BM_log_original_mask (BMLog *log, BMVert *v)
 
void BM_log_original_vert_data (BMLog *log, BMVert *v, const float **r_co, const float **r_no)
 
BMLogEntryBM_log_current_entry (BMLog *log)
 
struct RangeTreeUInt * BM_log_unused_ids (BMLog *log)
 

Typedef Documentation

◆ BMLog

typedef struct BMLog BMLog

Definition at line 1 of file bmesh_log.h.

◆ BMLogEntry

typedef struct BMLogEntry BMLogEntry

Definition at line 1 of file bmesh_log.h.

Function Documentation

◆ BM_log_all_added()

void BM_log_all_added ( BMesh bm,
BMLog log 
)

◆ BM_log_before_all_removed()

void BM_log_before_all_removed ( BMesh bm,
BMLog log 
)

◆ BM_log_cleanup_entry()

void BM_log_cleanup_entry ( BMLogEntry entry)

◆ BM_log_create()

BMLog* BM_log_create ( BMesh bm)

◆ BM_log_current_entry()

BMLogEntry* BM_log_current_entry ( BMLog log)

For internal use only (unit testing).

Definition at line 978 of file bmesh_log.c.

References log().

◆ BM_log_entry_add()

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().

◆ BM_log_entry_drop()

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().

◆ BM_log_face_added()

void BM_log_face_added ( BMLog log,
struct BMFace f 
)

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().

◆ BM_log_face_modified()

void BM_log_face_modified ( BMLog log,
struct BMFace f 
)

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().

◆ BM_log_face_removed()

void BM_log_face_removed ( BMLog log,
struct BMFace f 
)

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().

◆ BM_log_free()

void BM_log_free ( BMLog log)

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().

◆ BM_log_from_existing_entries_create()

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().

◆ BM_log_length()

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().

◆ BM_log_mesh_elems_reorder()

void BM_log_mesh_elems_reorder ( BMesh bm,
BMLog log 
)

◆ BM_log_original_mask()

float BM_log_original_mask ( BMLog log,
BMVert v 
)

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().

◆ BM_log_original_vert_co()

const float* BM_log_original_vert_co ( BMLog log,
BMVert v 
)

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().

◆ BM_log_original_vert_data()

void BM_log_original_vert_data ( BMLog log,
BMVert v,
const float **  r_co,
const float **  r_no 
)

◆ BM_log_original_vert_no()

const float* BM_log_original_vert_no ( BMLog log,
BMVert v 
)

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.

◆ BM_log_redo()

void BM_log_redo ( BMesh bm,
BMLog log 
)

◆ BM_log_undo()

void BM_log_undo ( BMesh bm,
BMLog log 
)

◆ BM_log_unused_ids()

struct RangeTreeUInt* BM_log_unused_ids ( BMLog log)

For internal use only (unit testing)

Definition at line 983 of file bmesh_log.c.

References log().

◆ BM_log_vert_added()

void BM_log_vert_added ( BMLog log,
struct BMVert v,
int  cd_vert_mask_offset 
)

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().

◆ BM_log_vert_before_modified()

void BM_log_vert_before_modified ( BMLog log,
struct BMVert v,
int  cd_vert_mask_offset 
)

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().

◆ BM_log_vert_removed()

void BM_log_vert_removed ( BMLog log,
struct BMVert v,
int  cd_vert_mask_offset 
)

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().