[Bf-blender-cvs] [18f1d17898e] lineart-shadow: Merge branch 'temp-lineart-contained' into lineart-shadow

YimingWu noreply at git.blender.org
Sun Nov 7 15:44:38 CET 2021


Commit: 18f1d17898ef22daee78818df204976f3bb05d90
Author: YimingWu
Date:   Sun Nov 7 22:43:48 2021 +0800
Branches: lineart-shadow
https://developer.blender.org/rB18f1d17898ef22daee78818df204976f3bb05d90

Merge branch 'temp-lineart-contained' into lineart-shadow

===================================================================



===================================================================

diff --cc source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 5a4d4df27a8,f8ecb4bdff5..e000c54c9a7
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@@ -556,14 -492,18 +556,22 @@@ typedef struct LineartBoundingArea 
  #define LRT_MIN3_INDEX_ABC(x, y, z) (x < y ? (x < z ? a : (y < z ? b : c)) : (y < z ? b : c))
  
  #define LRT_ABC(index) (index == 0 ? a : (index == 1 ? b : c))
+ #define LRT_PABC(index) (index == 0 ? pa : (index == 1 ? pb : pc))
  
  #define LRT_DOUBLE_CLOSE_ENOUGH(a, b) (((a) + DBL_EDGE_LIM) >= (b) && ((a)-DBL_EDGE_LIM) <= (b))
 +
 +#define LRT_SHADOW_CLOSE_ENOUGH(a, b) \
 +  (((a) + DBL_SHADOW_LIM) >= (b) && ((a)-DBL_SHADOW_LIM) <= (b))
 +
- BLI_INLINE int lineart_LineIntersectTest2d(
-     const double *a1, const double *a2, const double *b1, const double *b2, double *aRatio)
+ #define LRT_DOUBLE_CLOSE_ENOUGH_TRI(a, b) \
+   (((a) + DBL_TRIANGLE_LIM) >= (b) && ((a)-DBL_TRIANGLE_LIM) <= (b))
+ 
+ BLI_INLINE int lineart_LineIntersectTest2d(const double *a1,
+                                            const double *a2,
+                                            const double *b1,
+                                            const double *b2,
+                                            double *aRatio,
+                                            bool *aAligned)
  {
  /* Legacy intersection math aligns better with occlusion function quirks. */
  /* #define USE_VECTOR_LINE_INTERSECTION */
diff --cc source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 7d75551abeb,b2a8881a98b..1d6eb25ed5a
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@@ -547,8 -539,11 +547,12 @@@ static void lineart_main_occlusion_begi
    rb->edge_mark.last = rb->edge_mark.first;
    rb->floating.last = rb->floating.first;
    rb->light_contour.last = rb->light_contour.first;
 +  rb->shadow.last = rb->shadow.first;
  
+   /* This is needed because the occlusion function needs camera vector to be in the direction of
+    * point to camera. */
+   negate_v3_db(rb->view_vector);
+ 
    TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH);
  
    for (i = 0; i < thread_count; i++) {
@@@ -4139,30 -4097,34 +4172,35 @@@ static void lineart_main_add_triangles(
   * to get next along the way.
   */
  static LineartBoundingArea *lineart_edge_first_bounding_area(LineartRenderBuffer *rb,
 -                                                             LineartEdge *e)
 +                                                             double *fbcoord1,
 +                                                             double *fbcoord2)
  {
 -  double data[2] = {e->v1->fbcoord[0], e->v1->fbcoord[1]};
 +  double data[2] = {fbcoord1[0], fbcoord1[1]};
    double LU[2] = {-1, 1}, RU[2] = {1, 1}, LB[2] = {-1, -1}, RB[2] = {1, -1};
    double r = 1, sr = 1;
+   bool p_unused;
  
    if (data[0] > -1 && data[0] < 1 && data[1] > -1 && data[1] < 1) {
      return lineart_get_bounding_area(rb, data[0], data[1]);
    }
  
-   if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, LU, RU, &sr) && sr < r && sr > 0) {
 -  if (lineart_LineIntersectTest2d(e->v1->fbcoord, e->v2->fbcoord, LU, RU, &sr, &p_unused) &&
 -      sr < r && sr > 0) {
++  if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, LU, RU, &sr, &p_unused) && sr < r &&
++      sr > 0) {
      r = sr;
    }
-   if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, LB, RB, &sr) && sr < r && sr > 0) {
 -  if (lineart_LineIntersectTest2d(e->v1->fbcoord, e->v2->fbcoord, LB, RB, &sr, &p_unused) &&
 -      sr < r && sr > 0) {
++  if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, LB, RB, &sr, &p_unused) && sr < r &&
++      sr > 0) {
      r = sr;
    }
-   if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, LB, LU, &sr) && sr < r && sr > 0) {
 -  if (lineart_LineIntersectTest2d(e->v1->fbcoord, e->v2->fbcoord, LB, LU, &sr, &p_unused) &&
 -      sr < r && sr > 0) {
++  if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, LB, LU, &sr, &p_unused) && sr < r &&
++      sr > 0) {
      r = sr;
    }
-   if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, RB, RU, &sr) && sr < r && sr > 0) {
 -  if (lineart_LineIntersectTest2d(e->v1->fbcoord, e->v2->fbcoord, RB, RU, &sr, &p_unused) &&
 -      sr < r && sr > 0) {
++  if (lineart_LineIntersectTest2d(fbcoord1, fbcoord2, RB, RU, &sr, &p_unused) && sr < r &&
++      sr > 0) {
      r = sr;
    }
 -  interp_v2_v2v2_db(data, e->v1->fbcoord, e->v2->fbcoord, r);
 +  interp_v2_v2v2_db(data, fbcoord1, fbcoord2, r);
  
    return lineart_get_bounding_area(rb, data[0], data[1]);
  }



More information about the Bf-blender-cvs mailing list