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:
Diffstat (limited to 'source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c')
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c269
1 files changed, 166 insertions, 103 deletions
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 8665b316c43..6bea9314401 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -131,8 +131,8 @@ static void lineart_discard_segment(LineartRenderBuffer *rb, LineartLineSegment
memset(rls, 0, sizeof(LineartLineSegment));
- /* Storing the node for potentially reuse the memory for new segment data. Line Art data is not
- * freed after all calulations are done. */
+ /* Storing the node for potentially reuse the memory for new segment data.
+ * Line Art data is not freed after all calculations are done. */
BLI_addtail(&rb->wasted_cuts, rls);
BLI_spin_unlock(&rb->lock_cuts);
@@ -156,7 +156,9 @@ static LineartLineSegment *lineart_give_segment(LineartRenderBuffer *rb)
sizeof(LineartLineSegment));
}
-/* Cuts the edge in image space and mark occlusion level for each segment. */
+/**
+ * Cuts the edge in image space and mark occlusion level for each segment.
+ */
static void lineart_edge_cut(LineartRenderBuffer *rb,
LineartEdge *e,
double start,
@@ -219,7 +221,7 @@ static void lineart_edge_cut(LineartRenderBuffer *rb,
ns2 = cut_end_before;
break;
}
- /* This check is to prevent rls->at == 1.0 (where we don't need to cut because we are at the
+ /* This check is to prevent `rls->at == 1.0` (where we don't need to cut because we are at the
* end point). */
if (!rls->next && LRT_DOUBLE_CLOSE_ENOUGH(1, end)) {
cut_end_before = rls;
@@ -283,8 +285,8 @@ static void lineart_edge_cut(LineartRenderBuffer *rb,
BLI_addtail(&e->segments, ns2);
}
- /* If we touched the cut list, we assign the new cut position based on new cut position, this way
- * we accomomdate precision lost due to multiple cut inserts. */
+ /* If we touched the cut list, we assign the new cut position based on new cut position,
+ * this way we accommodate precision lost due to multiple cut inserts. */
ns->at = start;
if (!untouched) {
ns2->at = end;
@@ -322,7 +324,9 @@ static void lineart_edge_cut(LineartRenderBuffer *rb,
e->min_occ = min_occ;
}
-/* To see if given line is connected to an adjacent intersection line. */
+/**
+ * To see if given line is connected to an adjacent intersection line.
+ */
BLI_INLINE bool lineart_occlusion_is_adjacent_intersection(LineartEdge *e, LineartTriangle *rt)
{
LineartVertIntersection *v1 = (void *)e->v1;
@@ -373,13 +377,13 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
&r)) {
lineart_edge_cut(rb, e, l, r, rt->base.transparency_mask);
if (e->min_occ > rb->max_occlusion_level) {
- /* No need to caluclate any longer on this line because no level more than set value is
+ /* No need to calculate any longer on this line because no level more than set value is
* going to show up in the rendered result. */
return;
}
}
}
- /* Marching along e->v1 to e->v2, searching each possible bounding areas it may touch. */
+ /* Marching along `e->v1` to `e->v2`, searching each possible bounding areas it may touch. */
nba = lineart_bounding_area_next(nba, e, x, y, k, positive_x, positive_y, &x, &y);
}
}
@@ -449,9 +453,11 @@ static void lineart_occlusion_worker(TaskPool *__restrict UNUSED(pool), LineartR
}
}
-/* All internal functions starting with lineart_main_ is called inside
+/**
+ * All internal functions starting with lineart_main_ is called inside
* MOD_lineart_compute_feature_lines function.
- * This function handles all occlusion calculation. */
+ * This function handles all occlusion calculation.
+ */
static void lineart_main_occlusion_begin(LineartRenderBuffer *rb)
{
int thread_count = rb->thread_count;
@@ -478,10 +484,12 @@ static void lineart_main_occlusion_begin(LineartRenderBuffer *rb)
MEM_freeN(rti);
}
-/* Test if v lies with in the triangle formed by v0, v1, and v2. Returns false when v is exactly on
- * the edge.
+/**
+ * Test if v lies with in the triangle formed by v0, v1, and v2.
+ * Returns false when v is exactly on the edge.
+ *
* For v to be inside the triangle, it needs to be at the same side of v0->v1, v1->v2, and
- * v2->v0, where the "side" is determined by checking the sign of cross(v1-v0, v1-v) and so on.
+ * `v2->v0`, where the "side" is determined by checking the sign of `cross(v1-v0, v1-v)` and so on.
*/
static bool lineart_point_inside_triangle(const double v[2],
const double v0[2],
@@ -517,7 +525,7 @@ static bool lineart_point_inside_triangle(const double v[2],
static int lineart_point_on_line_segment(double v[2], double v0[2], double v1[2])
{
- /* c1!=c2 by default. */
+ /* `c1 != c2` by default. */
double c1 = 1, c2 = 0;
double l0[2], l1[2];
@@ -551,8 +559,10 @@ static int lineart_point_on_line_segment(double v[2], double v0[2], double v1[2]
return 0;
}
-/* Same algorithm as lineart_point_inside_triangle(), but returns differently:
- * 0-outside 1-on the edge 2-inside. */
+/**
+ * Same algorithm as lineart_point_inside_triangle(), but returns differently:
+ * 0-outside 1-on the edge 2-inside.
+ */
static int lineart_point_triangle_relation(double v[2], double v0[2], double v1[2], double v2[2])
{
double cl, c;
@@ -591,8 +601,10 @@ static int lineart_point_triangle_relation(double v[2], double v0[2], double v1[
return 2;
}
-/* Similar with lineart_point_inside_triangle, but in 3d.
- * Returns false when not co-plannar. */
+/**
+ * Similar with #lineart_point_inside_triangle, but in 3d.
+ * Returns false when not co-planar.
+ */
static bool lineart_point_inside_triangle3d(double v[3], double v0[3], double v1[3], double v2[3])
{
double l[3], r[3];
@@ -630,8 +642,10 @@ static bool lineart_point_inside_triangle3d(double v[3], double v0[3], double v1
return true;
}
-/* The following lineart_memory_get_XXX_space functions are for allocating new memory for some
- * modified geometries in the culling stage. */
+/**
+ * The following `lineart_memory_get_XXX_space` functions are for allocating new memory for some
+ * modified geometries in the culling stage.
+ */
static LineartElementLinkNode *lineart_memory_get_triangle_space(LineartRenderBuffer *rb)
{
LineartElementLinkNode *reln;
@@ -705,8 +719,10 @@ static bool lineart_edge_match(LineartTriangle *rt, LineartEdge *e, int v1, int
(rt->v[v2] == e->v1 && rt->v[v1] == e->v2));
}
-/* Does near-plane cut on 1 triangle only. When cutting with far-plane, the camera vectors gets
- * reversed by the caller so don't need to implement one in a different direction. */
+/**
+ * Does near-plane cut on 1 triangle only. When cutting with far-plane, the camera vectors gets
+ * reversed by the caller so don't need to implement one in a different direction.
+ */
static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
LineartTriangle *rt,
int in0,
@@ -750,7 +766,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
rb->triangle_size * (t_count + 1));
new_e = &((LineartEdge *)e_eln->pointer)[e_count];
- /* Init rl to the last rl entry. */
+ /* Init `rl` to the last `rl` entry. */
e = new_e;
#define INCREASE_RL \
@@ -811,8 +827,11 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
* generate 2 new points, 3 lines and 1 triangle. */
lineart_triangle_set_cull_flag(rt, LRT_CULL_USED);
- /* (!in0) means "when point 0 is visible".
- * conditons for point 1, 2 are the same idea.
+ /**
+ * (!in0) means "when point 0 is visible".
+ * conditions for point 1, 2 are the same idea.
+ *
+ * \code{.txt}
* 1-----|-------0
* | | ---
* | |---
@@ -826,6 +845,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
* |
* |
* (near)---------->(far)
+ * \endcode
*/
if (!in0) {
@@ -857,14 +877,13 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
e->flags = LRT_EDGE_FLAG_CONTOUR;
lineart_prepend_edge_direct(&rb->contours, e);
}
- /* Note: inverting e->v1/v2 (left/right point) doesn't matter as long as
- * rt->rl and rt->v has the same sequence. and the winding direction
- * can be either CW or CCW but needs to be consistent throughout the calculation.
- */
+ /* NOTE: inverting `e->v1/v2` (left/right point) doesn't matter as long as
+ * `rt->rl` and `rt->v` has the same sequence. and the winding direction
+ * can be either CW or CCW but needs to be consistent throughout the calculation. */
e->v1 = &rv[1];
e->v2 = &rv[0];
/* Only one adjacent triangle, because the other side is the near plane. */
- /* Use tl or tr doesn't matter. */
+ /* Use `tl` or `tr` doesn't matter. */
e->t1 = rt1;
e->object_ref = ob;
@@ -971,8 +990,10 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
* generate 2 new points, 4 lines and 2 triangles. */
lineart_triangle_set_cull_flag(rt, LRT_CULL_USED);
- /* (in0) means "when point 0 is invisible".
- * conditons for point 1, 2 are the same idea.
+ /**
+ * (in0) means "when point 0 is invisible".
+ * conditions for point 1, 2 are the same idea.
+ * \code{.txt}
* 0------|----------1
* -- | |
* ---| |
@@ -990,6 +1011,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
* | *** |
* | **2
* (near)---------->(far)
+ * \endcode
*/
if (in0) {
/* Cut point for line 0---|------1. */
@@ -1009,7 +1031,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot2 / (dot1 + dot2);
- /* Assign to aother new point. */
+ /* Assign to other new point. */
interp_v3_v3v3_db(rv[1].gloc, rt->v[0]->gloc, rt->v[2]->gloc, a);
mul_v4_m4v3_db(rv[1].fbcoord, vp, rv[1].gloc);
rv[1].index = rt->v[0]->index;
@@ -1026,8 +1048,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
e->object_ref = ob;
/* New line connects new point 0 and old point 1,
- * this is a border line.
- */
+ * this is a border line. */
SELECT_RL(0, rt->v[1], &rv[0], rt1)
SELECT_RL(2, rt->v[2], &rv[1], rt2)
@@ -1156,7 +1177,8 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
#undef REMOVE_TRIANGLE_RL
}
-/* This function cuts triangles with near- or far-plane. Setting clip_far = true for cutting with
+/**
+ * This function cuts triangles with near- or far-plane. Setting clip_far = true for cutting with
* far-plane. For triangles that's crossing the plane, it will generate new 1 or 2 triangles with
* new topology that represents the trimmed triangle. (which then became a triangle or a square
* formed by two triangles)
@@ -1288,8 +1310,10 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
#undef LRT_CULL_DECIDE_INSIDE
}
-/* Adjacent data is only used during the initial stages of computing. So we can free it using this
- * function when it is not needed anymore. */
+/**
+ * Adjacent data is only used during the initial stages of computing.
+ * So we can free it using this function when it is not needed anymore.
+ */
static void lineart_main_free_adjacent_data(LineartRenderBuffer *rb)
{
LinkData *ld;
@@ -1301,7 +1325,7 @@ static void lineart_main_free_adjacent_data(LineartRenderBuffer *rb)
int i;
for (i = 0; i < reln->element_count; i++) {
/* See definition of rt->intersecting_verts and the usage in
- * lineart_geometry_object_load() for detailes. */
+ * lineart_geometry_object_load() for detailed. */
rt->intersecting_verts = NULL;
rt = (LineartTriangle *)(((unsigned char *)rt) + rb->triangle_size);
}
@@ -1327,14 +1351,16 @@ static void lineart_main_perspective_division(LineartRenderBuffer *rb)
* at the moment.
* The algorithm currently doesn't need Z for operation, we use W instead. If Z is needed in
* the future, the line below correctly transforms it to view space coordinates. */
- /* rv[i].fbcoord[2] = -2 * rv[i].fbcoord[2] / (far - near) - (far + near) / (far - near);. */
+ // `rv[i].fbcoord[2] = -2 * rv[i].fbcoord[2] / (far - near) - (far + near) / (far - near);
rv[i].fbcoord[0] -= rb->shift_x * 2;
rv[i].fbcoord[1] -= rb->shift_y * 2;
}
}
}
-/* Transform a single vert to it's viewing position. */
+/**
+ * Transform a single vert to it's viewing position.
+ */
static void lineart_vert_transform(
BMVert *v, int index, LineartVert *RvBuf, double (*mv_mat)[4], double (*mvp_mat)[4])
{
@@ -1345,8 +1371,10 @@ static void lineart_vert_transform(
mul_v4_m4v3_db(rv->fbcoord, mvp_mat, co);
}
-/* Because we have a variable size for LineartTriangle, we need an access helper. See
- * LineartTriangleThread for more info. */
+/**
+ * Because we have a variable size for #LineartTriangle, we need an access helper.
+ * See #LineartTriangleThread for more info.
+ */
static LineartTriangle *lineart_triangle_from_index(LineartRenderBuffer *rb,
LineartTriangle *rt_array,
int index)
@@ -1588,7 +1616,7 @@ static void lineart_geometry_object_load(Depsgraph *dg,
use_crease = rb->crease_threshold;
}
- /* FIXME Yiming: Hack for getting clean 3D text, the seam that extruded text object creates
+ /* FIXME(Yiming): Hack for getting clean 3D text, the seam that extruded text object creates
* erroneous detection on creases. Future configuration should allow options. */
if (ob->type == OB_FONT) {
reln->flags |= LRT_ELEMENT_BORDER_ONLY;
@@ -1610,8 +1638,8 @@ static void lineart_geometry_object_load(Depsgraph *dg,
lineart_vert_transform(v, i, orv, new_mv, new_mvp);
orv[i].index = i + global_i;
}
- /* Register a global index increment. See lineart_triangle_share_edge() and
- * lineart_main_load_geometries() for detailes. It's okay that global_vindex might eventually
+ /* Register a global index increment. See #lineart_triangle_share_edge() and
+ * #lineart_main_load_geometries() for detailed. It's okay that global_vindex might eventually
* overflow, in such large scene it's virtually impossible for two vertex of the same numeric
* index to come close together. */
(*global_vindex) += bm->totvert;
@@ -1734,10 +1762,12 @@ static bool _lineart_object_not_in_source_collection(Collection *source, Object
return true;
}
-/* See if this object in such collection is used for generating line art,
- * Disabling a collection for line art will diable all objects inside.
- * "_rb" is used to provide source selection info. See the definition of rb->_source_type for
- * details. */
+/**
+ * See if this object in such collection is used for generating line art,
+ * Disabling a collection for line art will doable all objects inside.
+ * `_rb` is used to provide source selection info.
+ * See the definition of `rb->_source_type` for details.
+ */
static int lineart_usage_check(Collection *c, Object *ob, LineartRenderBuffer *_rb)
{
@@ -1850,8 +1880,10 @@ static void lineart_main_load_geometries(
DEG_OBJECT_ITER_END;
}
-/* Returns the two other verts of the triangle given a vertex. Returns false if the given vertex
- * doesn't belong to this triangle. */
+/**
+ * Returns the two other verts of the triangle given a vertex. Returns false if the given vertex
+ * doesn't belong to this triangle.
+ */
static bool lineart_triangle_get_other_verts(const LineartTriangle *rt,
const LineartVert *rv,
LineartVert **l,
@@ -1915,7 +1947,7 @@ static bool lineart_edge_from_triangle(const LineartTriangle *rt,
lst[2] = LRT_MAX3_INDEX(ia, ib, ic); \
}
-/* ia ib ic are ordered. */
+/* `ia ib ic` are ordered. */
#define INTERSECT_JUST_GREATER(is, order, num, index) \
{ \
index = (num < is[order[0]] ? \
@@ -1923,7 +1955,7 @@ static bool lineart_edge_from_triangle(const LineartTriangle *rt,
(num < is[order[1]] ? order[1] : (num < is[order[2]] ? order[2] : order[2]))); \
}
-/* ia ib ic are ordered. */
+/* `ia ib ic` are ordered. */
#define INTERSECT_JUST_SMALLER(is, order, num, index) \
{ \
index = (num > is[order[2]] ? \
@@ -1931,10 +1963,11 @@ static bool lineart_edge_from_triangle(const LineartTriangle *rt,
(num > is[order[1]] ? order[1] : (num > is[order[0]] ? order[0] : order[0]))); \
}
-/* This is the main function to calculate
+/**
+ * This is the main function to calculate
* the occlusion status between 1(one) triangle and 1(one) line.
- * if returns true, then from/to will carry the occludded segments
- * in ratio from e->v1 to e->v2. The line is later cut with these two values.
+ * if returns true, then from/to will carry the occluded segments
+ * in ratio from `e->v1` to `e->v2`. The line is later cut with these two values.
*/
static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
const LineartTriangle *rt,
@@ -1976,7 +2009,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
return false;
}
- /* If the the line is one of the edge in the triangle, then it's not occludded. */
+ /* If the the line is one of the edge in the triangle, then it's not occluded. */
if (lineart_edge_from_triangle(rt, e, allow_overlapping_edges)) {
return false;
}
@@ -2015,7 +2048,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
if (!a && !b && !c) {
if (!(st_l = lineart_point_triangle_relation(LFBC, FBC0, FBC1, FBC2)) &&
!(st_r = lineart_point_triangle_relation(RFBC, FBC0, FBC1, FBC2))) {
- return 0; /* Intersection point is not inside triangle. */
+ return 0; /* Intersection point is not inside triangle. */
}
}
@@ -2057,7 +2090,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
trans[0] -= cam_shift_x * 2;
trans[1] -= cam_shift_y * 2;
- /* To accomodate k=0 and k=inf (vertical) lines. here the cut is in image space. */
+ /* To accommodate `k=0` and `k=inf` (vertical) lines. here the cut is in image space. */
if (fabs(e->v1->fbcoord[0] - e->v2->fbcoord[0]) > fabs(e->v1->fbcoord[1] - e->v2->fbcoord[1])) {
cut = ratiod(e->v1->fbcoord[0], e->v2->fbcoord[0], trans[0]);
}
@@ -2164,8 +2197,10 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
#undef INTERSECT_JUST_GREATER
#undef INTERSECT_JUST_SMALLER
-/* At this stage of the computation we don't have triangle adjacent info anymore, so we can only
- * compare the global vert index. */
+/**
+ * At this stage of the computation we don't have triangle adjacent info anymore,
+ * so we can only compare the global vert index.
+ */
static bool lineart_triangle_share_edge(const LineartTriangle *l, const LineartTriangle *r)
{
if (l->v[0]->index == r->v[0]->index) {
@@ -2242,7 +2277,9 @@ static LineartVert *lineart_triangle_share_point(const LineartTriangle *l,
return NULL;
}
-/* To save time and prevent overlapping lines when computing intersection lines. */
+/**
+ * To save time and prevent overlapping lines when computing intersection lines.
+ */
static bool lineart_vert_already_intersected_2v(LineartVertIntersection *rv,
LineartVertIntersection *v1,
LineartVertIntersection *v2)
@@ -2258,9 +2295,10 @@ static void lineart_vert_set_intersection_2v(LineartVert *rv, LineartVert *v1, L
irv->isec2 = v2->index;
}
-/* This tests a triangle against a virtual line represented by v1---v2. The vertices returned
- * after
- * repeated calls to this function is then used to create a triangle/triangle intersection line.
+/**
+ * This tests a triangle against a virtual line represented by `v1---v2`.
+ * The vertices returned after repeated calls to this function
+ * is then used to create a triangle/triangle intersection line.
*/
static LineartVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *rb,
LineartVert *v1,
@@ -2327,7 +2365,9 @@ static LineartVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *r
return result;
}
-/* Test if two triangles intersect. Generates one intersection line if the check succeeds */
+/**
+ * Test if two triangles intersect. Generates one intersection line if the check succeeds.
+ */
static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
LineartTriangle *rt,
LineartTriangle *testing)
@@ -2351,8 +2391,8 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
LineartVert *share = lineart_triangle_share_point(testing, rt);
if (share) {
- /* If triangles have sharing points like (abc) and (acd), then we only need to detect bc
- * against acd or cd against abc.*/
+ /* If triangles have sharing points like `abc` and `acd`, then we only need to detect `bc`
+ * against `acd` or `cd` against `abc`. */
LineartVert *new_share;
lineart_triangle_get_other_verts(rt, share, &sv1, &sv2);
@@ -2448,8 +2488,8 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
/* This z transformation is not the same as the rest of the part, because the data don't go
* through normal perspective division calls in the pipeline, but this way the 3D result and
- * occlution on the generated line is correct, and we don't really use 2D for viewport stroke
- * generation anyway.*/
+ * occlusion on the generated line is correct, and we don't really use 2D for viewport stroke
+ * generation anyway. */
v1->fbcoord[2] = ZMin * ZMax / (ZMax - fabs(v1->fbcoord[2]) * (ZMax - ZMin));
v2->fbcoord[2] = ZMin * ZMax / (ZMax - fabs(v2->fbcoord[2]) * (ZMax - ZMin));
@@ -2539,7 +2579,9 @@ static void lineart_triangle_intersect_in_bounding_area(LineartRenderBuffer *rb,
}
}
-/* The calculated view vector will point towards the far-plane from the camera position. */
+/**
+ * The calculated view vector will point towards the far-plane from the camera position.
+ */
static void lineart_main_get_view_vector(LineartRenderBuffer *rb)
{
float direction[3] = {0, 0, 1};
@@ -2626,7 +2668,7 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene,
double clipping_offset = 0;
if (lmd->calculation_flags & LRT_ALLOW_CLIPPING_BOUNDARIES) {
- /* This way the clipped lines are "stablely visible" by prevents depth buffer artefacts. */
+ /* This way the clipped lines are "stably visible" by prevents depth buffer artifacts. */
clipping_offset = 0.0001;
}
@@ -2740,7 +2782,9 @@ static void lineart_main_bounding_area_make_initial(LineartRenderBuffer *rb)
}
}
-/* Re-link adjacent tiles after one gets subdivided. */
+/**
+ * Re-link adjacent tiles after one gets subdivided.
+ */
static void lineart_bounding_areas_connect_new(LineartRenderBuffer *rb, LineartBoundingArea *root)
{
LineartBoundingArea *ba = root->child, *tba;
@@ -2874,14 +2918,16 @@ static void lineart_bounding_areas_connect_new(LineartRenderBuffer *rb, LineartB
}
}
- /* Finally clear parent'scene adjacent list. */
+ /* Finally clear parent's adjacent list. */
BLI_listbase_clear(&root->lp);
BLI_listbase_clear(&root->rp);
BLI_listbase_clear(&root->up);
BLI_listbase_clear(&root->bp);
}
-/* Subdivide a tile after one tile contains too many triangles. */
+/**
+ * Subdivide a tile after one tile contains too many triangles.
+ */
static void lineart_bounding_area_split(LineartRenderBuffer *rb,
LineartBoundingArea *root,
int recursive_level)
@@ -3028,8 +3074,10 @@ static bool lineart_bounding_area_triangle_intersect(LineartRenderBuffer *fb,
return false;
}
-/* 1) Link triangles with bounding areas for later occlusion test.
- * 2) Test triangles with existing(added previously) triangles for intersection lines. */
+/**
+ * 1) Link triangles with bounding areas for later occlusion test.
+ * 2) Test triangles with existing(added previously) triangles for intersection lines.
+ */
static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
LineartBoundingArea *root_ba,
LineartTriangle *rt,
@@ -3045,9 +3093,9 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
lineart_list_append_pointer_pool(&root_ba->linked_triangles, &rb->render_data_pool, rt);
root_ba->triangle_count++;
/* If splitting doesn't improve triangle separation, then shouldn't allow splitting anymore.
- * Here we use recursive limit. This is espetially useful in ortho render, where a lot of
- * faces could easily line up perfectly in image space, which can not be separated by simply
- * slicing the image tile. */
+ * Here we use recursive limit. This is especially useful in orthographic render,
+ * where a lot of faces could easily line up perfectly in image space,
+ * which can not be separated by simply slicing the image tile. */
if (root_ba->triangle_count > 200 && recursive && recursive_level < 10) {
lineart_bounding_area_split(rb, root_ba, recursive_level);
}
@@ -3112,7 +3160,9 @@ static void lineart_bounding_area_link_line(LineartRenderBuffer *rb,
}
}
-/* Link lines to their respective bounding areas. */
+/**
+ * Link lines to their respective bounding areas.
+ */
static void lineart_main_link_lines(LineartRenderBuffer *rb)
{
LRT_ITER_ALL_LINES_BEGIN
@@ -3206,8 +3256,7 @@ static bool lineart_get_edge_bounding_areas(LineartRenderBuffer *rb,
(*rowend) = rb->tile_count_y - (int)((b[2] + 1.0) / sp_h) - 1;
(*rowbegin) = rb->tile_count_y - (int)((b[3] + 1.0) / sp_h) - 1;
- /* It'scene possible that the line stretches too much out to the side, resulting negative value
- . */
+ /* It's possible that the line stretches too much out to the side, resulting negative value. */
if ((*rowend) < (*rowbegin)) {
(*rowend) = rb->tile_count_y - 1;
}
@@ -3224,7 +3273,9 @@ static bool lineart_get_edge_bounding_areas(LineartRenderBuffer *rb,
return true;
}
-/* This only gets initial "biggest" tile. */
+/**
+ * This only gets initial "biggest" tile.
+ */
LineartBoundingArea *MOD_lineart_get_parent_bounding_area(LineartRenderBuffer *rb,
double x,
double y)
@@ -3296,7 +3347,9 @@ static LineartBoundingArea *lineart_get_bounding_area(LineartRenderBuffer *rb, d
return iba;
}
-/* Wrapper for more convenience. */
+/**
+ * Wrapper for more convenience.
+ */
LineartBoundingArea *MOD_lineart_get_bounding_area(LineartRenderBuffer *rb, double x, double y)
{
LineartBoundingArea *ba;
@@ -3306,7 +3359,9 @@ LineartBoundingArea *MOD_lineart_get_bounding_area(LineartRenderBuffer *rb, doub
return NULL;
}
-/* Sequentially add triangles into render buffer. This also does intersection along the way. */
+/**
+ * Sequentially add triangles into render buffer. This also does intersection along the way.
+ */
static void lineart_main_add_triangles(LineartRenderBuffer *rb)
{
LineartTriangle *rt;
@@ -3340,8 +3395,10 @@ static void lineart_main_add_triangles(LineartRenderBuffer *rb)
}
}
-/* This function gets the tile for the point e->v1, and later use lineart_bounding_area_next() to
- * get next along the way. */
+/**
+ * This function gets the tile for the point `e->v1`, and later use #lineart_bounding_area_next()
+ * to get next along the way.
+ */
static LineartBoundingArea *lineart_edge_first_bounding_area(LineartRenderBuffer *rb,
LineartEdge *e)
{
@@ -3374,8 +3431,10 @@ static LineartBoundingArea *lineart_edge_first_bounding_area(LineartRenderBuffer
return lineart_get_bounding_area(rb, data[0], data[1]);
}
-/* This march along one render line in image space and
- * get the next bounding area the line is crossing. */
+/**
+ * This march along one render line in image space and
+ * get the next bounding area the line is crossing.
+ */
static LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *this,
LineartEdge *e,
double x,
@@ -3458,7 +3517,7 @@ static LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *this
}
}
}
- /* If the line is compeletely horizontal, in which Y diffence == 0. */
+ /* If the line is completely horizontal, in which Y difference == 0. */
else {
r1 = ratiod(e->v1->fbcoord[0], e->v2->fbcoord[0], this->r);
if (r1 > 1) {
@@ -3588,14 +3647,16 @@ static LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *this
}
}
else {
- /* egment has no length. */
+ /* Segment has no length. */
return 0;
}
}
return 0;
}
-/* This is the entry point of all line art calculations. */
+/**
+ * This is the entry point of all line art calculations.
+ */
int MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, LineartGpencilModifierData *lmd)
{
LineartRenderBuffer *rb;
@@ -3616,7 +3677,7 @@ int MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, LineartGpencilModifi
* occlusion levels will get ignored. */
rb->max_occlusion_level = MAX2(lmd->level_start, lmd->level_end);
- /* FIXME: (Yiming) See definition of int LineartRenderBuffer::_source_type for detailes. */
+ /* FIXME(Yiming): See definition of int #LineartRenderBuffer::_source_type for detailed. */
rb->_source_type = lmd->source_type;
rb->_source_collection = lmd->source_collection;
rb->_source_object = lmd->source_object;
@@ -3638,7 +3699,7 @@ int MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, LineartGpencilModifi
* correct coordinates of those clipped lines. Done in two steps,
* setting clip_far==false for near plane. */
lineart_main_cull_triangles(rb, false);
- /* clip_far==true for far plane. */
+ /* `clip_far == true` for far plane. */
lineart_main_cull_triangles(rb, true);
/* At this point triangle adjacent info pointers is no longer needed, free them. */
@@ -3676,7 +3737,7 @@ int MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, LineartGpencilModifi
MOD_lineart_chain_split_for_fixed_occlusion(rb);
/* Then we connect chains based on the _proximity_ of their end points in image space, here's
- * the place threashold value gets involved. */
+ * the place threshold value gets involved. */
/* do_geometry_space = true. */
MOD_lineart_chain_connect(rb);
@@ -3795,8 +3856,8 @@ static void lineart_gpencil_generate(LineartRenderBuffer *rb,
}
}
- /* Preserved: If we ever do async generation, this picked flag should be set here. */
- /* rlc->picked = 1;. */
+ /* Preserved: If we ever do asynchronous generation, this picked flag should be set here. */
+ // rlc->picked = 1;
int array_idx = 0;
int count = MOD_lineart_chain_count(rlc);
@@ -3810,8 +3871,8 @@ static void lineart_gpencil_generate(LineartRenderBuffer *rb,
stroke_data[array_idx + 1] = rlci->gpos[1];
stroke_data[array_idx + 2] = rlci->gpos[2];
mul_m4_v3(gp_obmat_inverse, &stroke_data[array_idx]);
- stroke_data[array_idx + 3] = 1; /* thickness. */
- stroke_data[array_idx + 4] = opacity; /* hardness?. */
+ stroke_data[array_idx + 3] = 1; /* thickness. */
+ stroke_data[array_idx + 4] = opacity; /* hardness?. */
array_idx += 5;
}
@@ -3882,7 +3943,9 @@ static void lineart_gpencil_generate(LineartRenderBuffer *rb,
}
}
-/* Wrapper for external calls. */
+/**
+ * Wrapper for external calls.
+ */
void MOD_lineart_gpencil_generate(LineartRenderBuffer *rb,
Depsgraph *depsgraph,
Object *ob,