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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-02-09 01:59:22 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-02-11 18:41:12 +0300
commit395e91b87cf73a9f4d6490f4eb1e462c2a02b71b (patch)
treebad503f8ff107d6309dd76c887f66c3cab453f82 /source/blender/editors/sculpt_paint/sculpt_undo.c
parentaf6ba4dce51136759d27d67a826eafdb421c2c74 (diff)
Cleanup: Sculpt, Comment formatting
Reviewed By: brecht Differential Revision: https://developer.blender.org/D6792
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_undo.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c87
1 files changed, 45 insertions, 42 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 366eeae219c..cdb27025404 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -119,7 +119,7 @@ static void update_cb_partial(PBVHNode *node, void *userdata)
static bool test_swap_v3_v3(float a[3], float b[3])
{
- /* no need for float comparison here (memory is exactly equal or not) */
+ /* No need for float comparison here (memory is exactly equal or not). */
if (memcmp(a, b, sizeof(float[3])) != 0) {
swap_v3_v3(a, b);
return true;
@@ -151,10 +151,10 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
int *index;
if (unode->maxvert) {
- /* regular mesh restore */
+ /* Regular mesh restore. */
if (ss->shapekey_active && !STREQ(ss->shapekey_active->name, unode->shapeName)) {
- /* shape key has been changed before calling undo operator */
+ /* Shape key has been changed before calling undo operator. */
Key *key = BKE_key_from_object(ob);
KeyBlock *kb = key ? BKE_keyblock_find_name(key, unode->shapeName) : NULL;
@@ -166,12 +166,12 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob);
}
else {
- /* key has been removed -- skip this undo node */
+ /* Key has been removed -- skip this undo node. */
return 0;
}
}
- /* no need for float comparison here (memory is exactly equal or not) */
+ /* No need for float comparison here (memory is exactly equal or not). */
index = unode->index;
mvert = ss->mvert;
@@ -197,11 +197,11 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
}
}
- /* propagate new coords to keyblock */
+ /* Propagate new coords to keyblock. */
sculpt_vertcos_to_key(ob, ss->shapekey_active, vertCos);
- /* pbvh uses it's own mvert array, so coords should be */
- /* propagated to pbvh here */
+ /* PBVH uses it's own mvert array, so coords should be */
+ /* propagated to PBVH here. */
BKE_pbvh_vert_coords_apply(ss->pbvh, vertCos, ss->shapekey_active->totelem);
MEM_freeN(vertCos);
@@ -230,7 +230,7 @@ static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, Sculpt
}
}
else if (unode->maxgrid && subdiv_ccg != NULL) {
- /* multires restore */
+ /* Multires restore. */
CCGElem **grids, *grid;
CCGKey key;
float(*co)[3];
@@ -295,7 +295,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
int *index, i, j;
if (unode->maxvert) {
- /* regular mesh restore */
+ /* Regular mesh restore. */
index = unode->index;
mvert = ss->mvert;
@@ -309,7 +309,7 @@ static bool sculpt_undo_restore_mask(bContext *C, SculptUndoNode *unode)
}
}
else if (unode->maxgrid && subdiv_ccg != NULL) {
- /* multires restore */
+ /* Multires restore. */
CCGElem **grids, *grid;
CCGKey key;
float *mask;
@@ -375,7 +375,7 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C,
}
}
-/* Create empty sculpt BMesh and enable logging */
+/* Create empty sculpt BMesh and enable logging. */
static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
{
SculptSession *ss = ob->sculpt;
@@ -383,7 +383,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
sculpt_pbvh_clear(ob);
- /* Create empty BMesh and enable logging */
+ /* Create empty BMesh and enable logging. */
ss->bm = BM_mesh_create(&bm_mesh_allocsize_default,
&((struct BMeshCreateParams){
.use_toolflags = false,
@@ -392,7 +392,7 @@ static void sculpt_undo_bmesh_enable(Object *ob, SculptUndoNode *unode)
sculpt_dyntopo_node_layers_add(ss);
me->flag |= ME_SCULPT_DYNAMIC_TOPOLOGY;
- /* Restore the BMLog using saved entries */
+ /* Restore the BMLog using saved entries. */
ss->bm_log = BM_log_from_existing_entries_create(ss->bm, unode->bm_entry);
}
@@ -408,7 +408,7 @@ static void sculpt_undo_bmesh_restore_begin(bContext *C,
else {
sculpt_undo_bmesh_enable(ob, unode);
- /* Restore the mesh from the first log entry */
+ /* Restore the mesh from the first log entry. */
BM_log_redo(ss->bm, ss->bm_log);
unode->applied = true;
@@ -423,13 +423,13 @@ static void sculpt_undo_bmesh_restore_end(bContext *C,
if (unode->applied) {
sculpt_undo_bmesh_enable(ob, unode);
- /* Restore the mesh from the last log entry */
+ /* Restore the mesh from the last log entry. */
BM_log_undo(ss->bm, ss->bm_log);
unode->applied = false;
}
else {
- /* Disable dynamic topology sculpting */
+ /* Disable dynamic topology sculpting. */
sculpt_dynamic_topology_disable(C, NULL);
unode->applied = true;
}
@@ -502,13 +502,13 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
bool need_mask = false;
for (unode = lb->first; unode; unode = unode->next) {
- /* restore pivot */
+ /* Restore pivot. */
copy_v3_v3(ss->pivot_pos, unode->pivot_pos);
copy_v3_v3(ss->pivot_rot, unode->pivot_rot);
if (STREQ(unode->idname, ob->id.name)) {
if (unode->type == SCULPT_UNDO_MASK) {
- /* is possible that we can't do the mask undo (below)
- * because of the vertex count */
+ /* Is possible that we can't do the mask undo (below)
+ * because of the vertex count. */
need_mask = true;
break;
}
@@ -550,8 +550,8 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
continue;
}
- /* check if undo data matches current data well enough to
- * continue */
+ /* Check if undo data matches current data well enough to
+ * continue. */
if (unode->maxvert) {
if (ss->totvert != unode->maxvert) {
continue;
@@ -609,9 +609,9 @@ static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase
if (update || rebuild) {
bool tag_update = false;
- /* we update all nodes still, should be more clever, but also
+ /* We update all nodes still, should be more clever, but also
* needs to work correct when exiting/entering sculpt mode and
- * the nodes get recreated, though in that case it could do all */
+ * the nodes get recreated, though in that case it could do all. */
struct PartialUpdateData data = {
.rebuild = rebuild,
.pbvh = ss->pbvh,
@@ -794,9 +794,9 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
maxgrid = 0;
}
- /* we will use this while sculpting, is mapalloc slow to access then? */
+ /* We will use this while sculpting, is mapalloc slow to access then? */
- /* general TODO, fix count_alloc */
+ /* General TODO, fix count_alloc. */
switch (type) {
case SCULPT_UNDO_COORDS:
unode->co = MEM_mapallocN(sizeof(float[3]) * allvert, "SculptUndoNode.co");
@@ -830,14 +830,14 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, Sculpt
BLI_addtail(&usculpt->nodes, unode);
if (maxgrid) {
- /* multires */
+ /* Multires. */
unode->maxgrid = maxgrid;
unode->totgrid = totgrid;
unode->gridsize = gridsize;
unode->grids = MEM_mapallocN(sizeof(int) * totgrid, "SculptUndoNode.grids");
}
else {
- /* regular mesh */
+ /* Regular mesh. */
unode->maxvert = ss->totvert;
unode->index = MEM_mapallocN(sizeof(int) * allvert, "SculptUndoNode.index");
}
@@ -877,7 +877,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode)
PBVHNode *node = unode->node;
if (unode->grids) {
- /* already stored during allocation */
+ /* Already stored during allocation. */
}
else {
MVert *mvert;
@@ -912,7 +912,7 @@ static SculptUndoNode *sculpt_undo_geometry_push(Object *ob, SculptUndoType type
bool applied;
SculptUndoNode *unode = usculpt->nodes.first;
- /* Store the original mesh in the first node, modifications in the second */
+ /* Store the original mesh in the first node, modifications in the second. */
applied = unode != NULL;
unode = MEM_callocN(sizeof(*unode), __func__);
@@ -961,7 +961,7 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt
* polys. A full copy like this is needed because entering
* dynamic-topology immediately does topological edits
* (converting polys to triangles) that the BMLog can't
- * fully restore from */
+ * fully restore from. */
CustomData_copy(
&me->vdata, &unode->geom_vdata, CD_MASK_MESH.vmask, CD_DUPLICATE, me->totvert);
CustomData_copy(
@@ -990,7 +990,7 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt
case SCULPT_UNDO_COORDS:
case SCULPT_UNDO_MASK:
/* Before any vertex values get modified, ensure their
- * original positions are logged */
+ * original positions are logged. */
BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_ALL)
{
BM_log_vert_before_modified(ss->bm_log, vd.bm_vert, vd.cd_vert_mask_offset);
@@ -1030,14 +1030,14 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
SculptSession *ss = ob->sculpt;
SculptUndoNode *unode;
- /* list is manipulated by multiple threads, so we lock */
+ /* List is manipulated by multiple threads, so we lock. */
BLI_thread_lock(LOCK_CUSTOM1);
ss->needs_flush_to_id = 1;
if (ss->bm || ELEM(type, SCULPT_UNDO_DYNTOPO_BEGIN, SCULPT_UNDO_DYNTOPO_END)) {
/* Dynamic topology stores only one undo node per stroke,
- * regardless of the number of PBVH nodes modified */
+ * regardless of the number of PBVH nodes modified. */
unode = sculpt_undo_bmesh_push(ob, node, type);
BLI_thread_unlock(LOCK_CUSTOM1);
return unode;
@@ -1090,11 +1090,11 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
break;
}
- /* store sculpt pivot */
+ /* Store sculpt pivot. */
copy_v3_v3(unode->pivot_pos, ss->pivot_pos);
copy_v3_v3(unode->pivot_rot, ss->pivot_rot);
- /* store active shape key */
+ /* Store active shape key. */
if (ss->shapekey_active) {
BLI_strncpy(unode->shapeName, ss->shapekey_active->name, sizeof(ss->shapekey_active->name));
}
@@ -1110,7 +1110,10 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType
void sculpt_undo_push_begin(const char *name)
{
UndoStack *ustack = ED_undo_stack_get();
- bContext *C = NULL; /* special case, we never read from this. */
+
+ /* Special case, we never read from this. */
+ bContext *C = NULL;
+
BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_SCULPT);
}
@@ -1119,7 +1122,7 @@ void sculpt_undo_push_end(void)
UndoSculpt *usculpt = sculpt_undo_get_nodes();
SculptUndoNode *unode;
- /* we don't need normals in the undo stack */
+ /* We don't need normals in the undo stack. */
for (unode = usculpt->nodes.first; unode; unode = unode->next) {
if (unode->no) {
MEM_freeN(unode->no);
@@ -1146,14 +1149,14 @@ void sculpt_undo_push_end(void)
typedef struct SculptUndoStep {
UndoStep step;
- /* note: will split out into list for multi-object-sculpt-mode. */
+ /* Note: will split out into list for multi-object-sculpt-mode. */
UndoSculpt data;
} SculptUndoStep;
static void sculpt_undosys_step_encode_init(struct bContext *UNUSED(C), UndoStep *us_p)
{
SculptUndoStep *us = (SculptUndoStep *)us_p;
- /* dummy, memory is cleared anyway. */
+ /* Dummy, memory is cleared anyway. */
BLI_listbase_clear(&us->data.nodes);
}
@@ -1161,7 +1164,7 @@ static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C),
struct Main *bmain,
UndoStep *us_p)
{
- /* dummy, encoding is done along the way by adding tiles
+ /* Dummy, encoding is done along the way by adding tiles
* to the current 'SculptUndoStep' added by encode_init. */
SculptUndoStep *us = (SculptUndoStep *)us_p;
us->step.data_size = us->data.undo_size;
@@ -1248,7 +1251,7 @@ static void sculpt_undosys_step_decode(
Object *ob = OBACT(view_layer);
if (ob && (ob->type == OB_MESH)) {
if (ob->mode & OB_MODE_SCULPT) {
- /* pass */
+ /* Pass. */
}
else {
ED_object_mode_generic_exit(bmain, depsgraph, scene, ob);