Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bmesh_log.h « intern « bmesh « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d81aa1dc5ae85762cd246fd9639888bad8431c42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * 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.
 */

#pragma once

/** \file
 * \ingroup bmesh
 */

struct BMFace;
struct BMVert;
struct BMesh;
struct RangeTreeUInt;

typedef struct BMLog BMLog;
typedef struct BMLogEntry BMLogEntry;

typedef struct BMLogCallbacks {
  void (*on_vert_add)(struct BMVert *v, void *userdata);
  void (*on_vert_kill)(struct BMVert *v, void *userdata);
  void (*on_vert_change)(struct BMVert *v, void *userdata, void *old_customdata);

  void (*on_edge_add)(struct BMEdge *e, void *userdata);
  void (*on_edge_kill)(struct BMEdge *e, void *userdata);
  void (*on_edge_change)(struct BMEdge *e, void *userdata, void *old_customdata);

  void (*on_face_add)(struct BMFace *f, void *userdata);
  void (*on_face_kill)(struct BMFace *f, void *userdata);
  void (*on_face_change)(struct BMFace *f, void *userdata, void *old_customdata);

  void (*on_full_mesh_load)(void *userdata);
  void (*on_mesh_id_restore)(void *userdata);
  void *userdata;
} BMLogCallbacks;

/* Allocate and initialize a new BMLog */
BMLog *BM_log_create(BMesh *bm, int cd_dyn_vert);
void BM_log_set_cd_offsets(BMLog *log, int cd_dyn_vert);

/* 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 */
bool BM_log_free(BMLog *log, bool safe_mode);

BMLog *BM_log_unfreeze(BMesh *bm, BMLogEntry *entry);

void BM_log_set_bm(BMesh *bm, 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(BMesh *bm, BMLog *log);
BMLogEntry *BM_log_entry_add_ex(BMesh *bm, BMLog *log, bool combine_with_last);
BMLogEntry *BM_log_all_ids(BMesh *bm, BMLog *log, BMLogEntry *entry);

BMLogEntry *BM_log_entry_check_customdata(BMesh *bm, BMLog *log);

/* Mark all used ids as unused for this node */
void BM_log_cleanup_entry(BMLogEntry *entry);

/* Remove an entry from the log */
void BM_log_entry_drop(BMLogEntry *entry);

/* Undo one BMLogEntry.  node_layer_id is necassary to preserve node idxs with customdata, whose
 * layout might have changed */
void BM_log_undo(BMesh *bm, BMLog *log, BMLogCallbacks *callbacks, const char *node_layer_id);

/* Redo one BMLogEntry */
void BM_log_redo(BMesh *bm, BMLog *log, BMLogCallbacks *callbacks, const char *node_layer_id);

/* Log a vertex before it is modified */
void BM_log_vert_before_modified(BMLog *log,
                                 struct BMVert *v,
                                 const int cd_vert_mask_offset,
                                 bool log_customdata);

/* Log an edge before it is modified */
void BM_log_edge_before_modified(BMLog *log, BMEdge *v, bool log_customdata);

/* Log a new vertex as added to the BMesh */
void BM_log_vert_added(BMLog *log, struct BMVert *v, const int cd_vert_mask_offset);

/* Log a new edge as added to the BMesh */
void BM_log_edge_added(BMLog *log, BMEdge *e);

/* Log a face before it is modified */
void BM_log_face_modified(BMLog *log, struct BMFace *f);

/* 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(BMLog *log, struct BMVert *v, const int cd_vert_mask_offset);

/* Log an edge as removed from the BMesh */
void BM_log_edge_removed(BMLog *log, BMEdge *e);

/* 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);

void BM_log_full_mesh(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 normal of a vertex */
const float *BM_log_original_vert_no(BMLog *log, BMVert *v);

/* Get the logged mask of a vertex */
float BM_log_original_mask(BMLog *log, BMVert *v);

/* Get the logged data of a vertex (avoid multiple lookups) */
void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const float **r_no);

/* For internal use only (unit testing) */
BMLogEntry *BM_log_current_entry(BMLog *log);
void BM_log_set_current_entry(BMLog *log, BMLogEntry *entry);
BMLogEntry *BM_log_entry_prev(BMLogEntry *entry);
BMLogEntry *BM_log_entry_next(BMLogEntry *entry);

uint BM_log_vert_id_get(BMLog *log, BMVert *v);
BMVert *BM_log_id_vert_get(BMLog *log, uint id);
uint BM_log_face_id_get(BMLog *log, BMFace *f);
BMFace *BM_log_id_face_get(BMLog *log, uint id);

void BM_log_print_entry(BMLog *log, BMLogEntry *entry);
void BM_log_redo_skip(BMesh *bm, BMLog *log);
void BM_log_undo_skip(BMesh *bm, BMLog *log);
BMVert *BM_log_edge_split_do(BMLog *log, BMEdge *e, BMVert *v, BMEdge **newe, float t);

int BM_log_entry_size(BMLogEntry *entry);