[Bf-blender-cvs] [5ee1c7f6953] master: Cleanup: spelling, comments
Campbell Barton
noreply at git.blender.org
Fri May 1 04:38:58 CEST 2020
Commit: 5ee1c7f695390c4cd3800319e6f032b0293e63ad
Author: Campbell Barton
Date: Fri May 1 12:36:11 2020 +1000
Branches: master
https://developer.blender.org/rB5ee1c7f695390c4cd3800319e6f032b0293e63ad
Cleanup: spelling, comments
===================================================================
M source/blender/blenkernel/intern/multires_unsubdivide.c
M source/blender/blenkernel/intern/multires_unsubdivide.h
===================================================================
diff --git a/source/blender/blenkernel/intern/multires_unsubdivide.c b/source/blender/blenkernel/intern/multires_unsubdivide.c
index a2c6aa02554..49de88db521 100644
--- a/source/blender/blenkernel/intern/multires_unsubdivide.c
+++ b/source/blender/blenkernel/intern/multires_unsubdivide.c
@@ -19,6 +19,9 @@
/** \file
* \ingroup bke
+ *
+ * This implements the un-subdivide algorithm, which generates a lower resolution base mesh and
+ * its corresponding grids to match a given original mesh.
*/
#include "MEM_guardedalloc.h"
@@ -47,33 +50,36 @@
#include "multires_reshape.h"
#include "multires_unsubdivide.h"
-/* This implements the unsubdivide algorithm, which generates a lower resolution base mesh and its
- * corresponding grids to match a given original mesh. */
-
/* This is done in the following steps:
- * - If there are already grids in the original mesh, convert them from tangent displacement to
-object space coordinates.
- * - Assign datalayers to the original mesh to map vertices to a new base mesh. These datalayes
-store the indicies of the elements in the original mesh. This way the original inidices are
-preserved when doing mesh modifications (removing and disolving vertices) when building the new
-base mesh.
+ *
+ * - If there are already grids in the original mesh,
+ * convert them from tangent displacement to object space coordinates.
+ * - Assign data-layers to the original mesh to map vertices to a new base mesh.
+ * These data-layers store the indices of the elements in the original mesh.
+ * This way the original indices are
+ * preserved when doing mesh modifications (removing and dissolving vertices)
+ * when building the new base mesh.
* - Try to find a lower resolution base mesh. This is done by flood fill operation that tags the
-center vertices of the lower level grid. If the algorithm can tag all vertices correctly, the lower
-level base mesh is generated by dissolving the tagged vertices.
- * - Use the datalayers to map vertices from the base mesh to the original mesh and original to
-base mesh.
+ * center vertices of the lower level grid.
+ * If the algorithm can tag all vertices correctly,
+ * the lower level base mesh is generated by dissolving the tagged vertices.
+ * - Use the data-layers to map vertices from the base mesh to the original mesh and original to
+ * base mesh.
* - Find two adjacent vertices on the base mesh to a given vertex to map that loop from base mesh
-to original mesh
+ * to original mesh
* - Extract the grid from the original mesh from that loop. If there are no grids in the original
-mesh, build the new grid directly from the vertex coordinates by iterating in a grid pattern over
-them. If there are grids in the original mesh, iterate in a grid pattern over the polys, reorder
-all the coordinates of the grid in that poly and copy those coordinates to the new base mesh grid.
- * - Copy the new grid data over to a new allocated MDISP layer with the appropiate size to store
-the new levels.
+ * mesh, build the new grid directly from the vertex coordinates by iterating in a grid pattern
+ * over them. If there are grids in the original mesh, iterate in a grid pattern over the polys,
+ * reorder all the coordinates of the grid in that poly and copy those coordinates to the new
+ * base mesh grid.
+ * - Copy the new grid data over to a new allocated MDISP layer with the appropriate size to store
+ * the new levels.
* - Convert the grid data from object space to tangent displacement.
*/
-/* Used to check if a vertex is in a disconnected element ID. */
+/**
+ * Used to check if a vertex is in a disconnected element ID.
+ */
static bool is_vertex_in_id(BMVert *v, int *elem_id, int elem)
{
const int v_index = BM_elem_index_get(v);
@@ -90,9 +96,12 @@ static bool is_vertex_pole(BMVert *v)
return !BM_vert_is_boundary(v) && (BM_vert_edge_count(v) == 3 || BM_vert_edge_count(v) >= 5);
}
-/* Returns the first pole that is found in an element ID. */
-/* Tries to give priority to 3 vert poles as they generally generate better results in cases were
- * the unsubdivide solution is ambiguous. */
+/**
+ * Returns the first pole that is found in an element ID.
+ *
+ * Tries to give priority to 3 vert poles as they generally generate better results in cases were
+ * the un-subdivide solution is ambiguous.
+ */
static BMVert *unsubdivide_find_any_pole(BMesh *bm, int *elem_id, int elem)
{
BMIter iter;
@@ -109,9 +118,12 @@ static BMVert *unsubdivide_find_any_pole(BMesh *bm, int *elem_id, int elem)
return pole;
}
-/* Checks if the mesh is all quads. */
-/* TODO(pablodp606). This can perform additional checks if they are faster than trying to search
- * for an unsubidivide solution. This way it is possible to cancel the operation faster. */
+/**
+ * Checks if the mesh is all quads.
+ *
+ * TODO(pablodp606): This can perform additional checks if they are faster than trying to search
+ * for an un-subdivide solution. This way it is possible to cancel the operation faster.
+ */
static bool unsubdivide_is_all_quads(BMesh *bm)
{
BMIter iter;
@@ -146,17 +158,23 @@ static bool unsubdivide_is_all_quads(BMesh *bm)
return true;
}
-/* Returns true if from_v and to_v, which should be part of the same quad face, are diagonals. */
+/**
+ * Returns true if from_v and to_v, which should be part of the same quad face, are diagonals.
+ */
static bool is_vertex_diagonal(BMVert *from_v, BMVert *to_v)
{
return !BM_edge_exists(from_v, to_v);
}
-/* Generates a possible solution for unsubdivision by tagging the (0,0) vertices of the possible
- * grids. */
-/* This works using a flood fill operation using the quads diagonals to jump to the next vertex. */
-/* If initial_vertex is part of the base mesh solution, the flood fill should tag only the (0.0)
- * vertices of the grids that need to be dissolved, and nothing else. */
+/**
+ * Generates a possible solution for un-subdivision by tagging the (0,0)
+ * vertices of the possible grids.
+ *
+ * This works using a flood fill operation using the quads diagonals to jump to the next vertex.
+ *
+ * If initial_vertex is part of the base mesh solution, the flood fill should tag only the (0.0)
+ * vertices of the grids that need to be dissolved, and nothing else.
+ */
static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex)
{
bool *visited_vertices = MEM_calloc_arrayN(sizeof(bool), bm->totvert, "visited vertices");
@@ -225,10 +243,13 @@ static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex
MEM_freeN(visited_vertices);
}
-/* This function checks if the current status of the BMVert tags corresponds to a valid unsubdivide
- * solution. */
-/* This means that all vertices corresponding to the (0,0) grid coordinate should be tagged. */
-/* On a valid solution, the following things should happen:
+/**
+ * This function checks if the current status of the #BMVert tags
+ * corresponds to a valid un-subdivide solution.
+ *
+ * This means that all vertices corresponding to the (0,0) grid coordinate should be tagged.
+ *
+ * On a valid solution, the following things should happen:
* - No boundary vertices should be tagged
* - No vertices connected by an edge or a quad diagonal to a tagged vertex should be tagged
* - All boundary vertices should have one vertex connected by an edge or a diagonal tagged
@@ -256,7 +277,7 @@ static bool unsubdivide_is_center_vertex_tag_valid(BMesh *bm, int *elem_id, int
}
}
if (BM_vert_is_boundary(v)) {
- /* Untagged vertex in boundary without connected tagged vertices. */
+ /* Un-tagged vertex in boundary without connected tagged vertices. */
bool any_tagged = false;
BM_ITER_ELEM (f, &iter_a, v, BM_FACES_OF_VERT) {
BM_ITER_ELEM (neighbor_v, &iter_b, f, BM_VERTS_OF_FACE) {
@@ -275,12 +296,14 @@ static bool unsubdivide_is_center_vertex_tag_valid(BMesh *bm, int *elem_id, int
return true;
}
-/* Searchs and validates an unsubdivide solution for a given element ID. */
+/**
+ * Search and validates an un-subdivide solution for a given element ID.
+ */
static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, int elem)
{
- /* First, get vertex candidates to try to generate possible unsubdivide solution. */
+ /* First, get vertex candidates to try to generate possible un-subdivide solution. */
/* Find a vertex pole. If there is a solution on an all quad base mesh, this vertex should be
- * part of the base mesh. If it isnt, then there is no solution. */
+ * part of the base mesh. If it isn't, then there is no solution. */
GSQueue *initial_vertex = BLI_gsqueue_new(sizeof(BMVert *));
BMVert *initial_vertex_pole = unsubdivide_find_any_pole(bm, elem_id, elem);
if (initial_vertex_pole != NULL) {
@@ -340,7 +363,9 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i
return valid_tag_found;
}
-/* Uses a flood fill operation to generate a different ID for each disconnected mesh element. */
+/**
+ * Uses a flood fill operation to generate a different ID for each disconnected mesh element.
+ */
static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id)
{
bool *visited_vertices = MEM_calloc_arrayN(sizeof(bool), bm->totvert, "visited vertices");
@@ -378,8 +403,10 @@ static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id)
return current_id;
}
-/* Builds a base mesh one subdiv level down from the current original mesh if the original mesh has
- * a valid solution stored in the BMVert tags. */
+/**
+ * Builds a base mesh one subdivision level down from the current original mesh if the original
+ * mesh has a valid solution stored in the #BMVert tags.
+ */
static void unsubdivide_build_base_mesh_from_tags(BMesh *bm)
{
BMVert *v;
@@ -425,37 +452,42 @@ static void unsubdivide_build_base_mesh_from_tags(BMesh *bm)
true);
}
-/* Main function to get a base mesh one level down from the current original mesh if it exists. */
-/* This searchs for different unsubdivide solutions and stores them as a combination of BMVert
- * flags for each disconnected mesh element. */
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list