diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-12-30 22:24:08 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2012-12-30 22:24:08 +0400 |
commit | 2e9cb31c02378fd5b9b3f26f6f26501d1aa999a2 (patch) | |
tree | 0721978f5d0649841e4c817edf16791e8e2fe8da /source/blender/bmesh/intern/bmesh_log.h | |
parent | 1b4b5f98cb2f568c55d00ca546878b1a6959dad9 (diff) |
Add BMLog for efficiently storing changes to vertices and faces
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:
- Adding and removing vertices
- Adding and removing faces
- Moving vertices
- Setting vertex paint-mask values
- Setting vertex hflags
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_log.h')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_log.h | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_log.h b/source/blender/bmesh/intern/bmesh_log.h new file mode 100644 index 00000000000..958ff340b43 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_log.h @@ -0,0 +1,102 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_LOG_H__ +#define __BMESH_LOG_H__ + +/* 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: + * + * - Adding and removing vertices + * - Adding and removing faces + * - Moving vertices + * - Setting vertex paint-mask values + * - Setting vertex hflags + */ + +struct BMFace; +struct BMVert; +struct BMesh; +struct RangeTreeUInt; + +typedef struct BMLog BMLog; +typedef struct BMLogEntry BMLogEntry; + +/* Allocate and initialize a new BMLog */ +BMLog *BM_log_create(BMesh *bm); + +/* Allocate and initialize a new BMLog using existing BMLogEntries */ +BMLog *BM_log_from_existing_entries_create(BMesh *bm, BMLogEntry *entry); + +/* Free all the data in a BMLog including the log itself */ +void BM_log_free(BMLog *log); + +/* Get the number of log entries */ +int BM_log_length(const BMLog *log); + +/* Apply a consistent ordering to BMesh vertices and faces */ +void BM_log_mesh_elems_reorder(BMesh *bm, BMLog *log); + +/* Start a new log entry and update the log entry list */ +BMLogEntry *BM_log_entry_add(BMLog *log); + +/* Remove an entry from the log */ +void BM_log_entry_drop(BMLogEntry *entry); + +/* Undo one BMLogEntry */ +void BM_log_undo(BMesh *bm, BMLog *log); + +/* Redo one BMLogEntry */ +void BM_log_redo(BMesh *bm, BMLog *log); + +/* Log a vertex before it is modified */ +void BM_log_vert_before_modified(BMesh *bm, BMLog *log, struct BMVert *v); + +/* Log a new vertex as added to the BMesh */ +void BM_log_vert_added(BMesh *bm, BMLog *log, struct BMVert *v); + +/* Log a new face as added to the BMesh */ +void BM_log_face_added(BMLog *log, struct BMFace *f); + +/* Log a vertex as removed from the BMesh */ +void BM_log_vert_removed(BMesh *bm, BMLog *log, struct BMVert *v); + +/* Log a face as removed from the BMesh */ +void BM_log_face_removed(BMLog *log, struct BMFace *f); + +/* Log all vertices/faces in the BMesh as added */ +void BM_log_all_added(BMesh *bm, BMLog *log); + +/* Log all vertices/faces in the BMesh as removed */ +void BM_log_before_all_removed(BMesh *bm, BMLog *log); + +/* Get the logged coordinates of a vertex */ +const float *BM_log_original_vert_co(BMLog *log, BMVert *v); + +/* Get the logged mask of a vertex */ +float BM_log_original_mask(BMLog *log, BMVert *v); + +/* For internal use only (unit testing) */ +BMLogEntry *BM_log_current_entry(BMLog *log); +struct RangeTreeUInt *BM_log_unused_ids(BMLog *log); + +#endif |