[Bf-blender-cvs] [625fa7f276b] soc-2019-npr: LANPR: Moved CPU side calculations to ED.
YimingWu
noreply at git.blender.org
Sat Jul 13 10:01:15 CEST 2019
Commit: 625fa7f276b29f16e074232d30886c10abbb4be9
Author: YimingWu
Date: Sat Jul 13 16:00:52 2019 +0800
Branches: soc-2019-npr
https://developer.blender.org/rB625fa7f276b29f16e074232d30886c10abbb4be9
LANPR: Moved CPU side calculations to ED.
===================================================================
M source/blender/draw/engines/lanpr/lanpr_all.h
M source/blender/draw/engines/lanpr/lanpr_ops.c
M source/blender/draw/engines/lanpr/lanpr_util.c
M source/blender/editors/include/ED_lanpr.h
M source/blender/editors/lanpr/lanpr_ops.c
===================================================================
diff --git a/source/blender/draw/engines/lanpr/lanpr_all.h b/source/blender/draw/engines/lanpr/lanpr_all.h
index ace31e976bd..facd1dfe0df 100644
--- a/source/blender/draw/engines/lanpr/lanpr_all.h
+++ b/source/blender/draw/engines/lanpr/lanpr_all.h
@@ -59,15 +59,13 @@
#define LANPR_ENGINE "BLENDER_LANPR"
-#define TNS_PI 3.1415926535897932384626433832795
-#define deg(r) r / TNS_PI * 180.0
-#define rad(d) d *TNS_PI / 180.0
+#define M_PI 3.1415926535897932384626433832795
+#define deg(r) r / M_PI * 180.0
+#define rad(d) d *M_PI / 180.0
#define tMatDist2v(p1, p2) \
sqrt(((p1)[0] - (p2)[0]) * ((p1)[0] - (p2)[0]) + ((p1)[1] - (p2)[1]) * ((p1)[1] - (p2)[1]))
-#define tnsLinearItp(l, r, T) ((l) * (1.0f - (T)) + (r) * (T))
-
extern struct RenderEngineType DRW_engine_viewport_lanpr_type;
extern struct DrawEngineType draw_engine_lanpr_type;
@@ -214,346 +212,6 @@ typedef struct LANPR_Data {
LANPR_StorageList *stl;
} LANPR_Data;
-/* Below ported from NUL_TNS.h */
-
-#define TNS_THREAD_LINE_COUNT 10000
-
-#define TNS_CALCULATION_IDLE 0
-#define TNS_CALCULATION_GEOMETRY 1
-#define TNS_CALCULATION_CONTOUR 2
-#define TNS_CALCULATION_INTERSECTION 3
-#define TNS_CALCULATION_OCCLUTION 4
-#define TNS_CALCULATION_FINISHED 100
-
-typedef struct LANPR_RenderTaskInfo {
- /* thrd_t ThreadHandle; */
-
- int thread_id;
-
- LinkData *contour;
- ListBase contour_pointers;
-
- LinkData *intersection;
- ListBase intersection_pointers;
-
- LinkData *crease;
- ListBase crease_pointers;
-
- LinkData *material;
- ListBase material_pointers;
-
- LinkData *edge_mark;
- ListBase edge_mark_pointers;
-
-} LANPR_RenderTaskInfo;
-
-#define TNS_CULL_DISCARD 2
-#define TNS_CULL_USED 1
-
-typedef struct LANPR_BoundingArea {
- real l, r, u, b;
- real cx, cy;
-
- struct LANPR_BoundingArea *child; /* 1,2,3,4 quadrant */
-
- ListBase lp;
- ListBase rp;
- ListBase up;
- ListBase bp;
-
- int triangle_count;
- ListBase linked_triangles;
- ListBase linked_lines;
-
- ListBase linked_chains; /* reserved for image space reduction && multithread chainning */
-} LANPR_BoundingArea;
-
-#define TNS_COMMAND_LINE 0
-#define TNS_COMMAND_MATERIAL 1
-#define TNS_COMMAND_EDGE 2
-
-#define TNS_TRANSPARENCY_DRAW_SIMPLE 0
-#define TNS_TRANSPARENCY_DRAW_LAYERED 1
-
-#define TNS_OVERRIDE_ONLY 0
-#define TNS_OVERRIDE_EXCLUDE 1
-/* #define TNS_OVERRIDE_ALL_OTHERS_OUTSIDE_GROUP 2 */
-/* #define TNS_OVERRIDE_ALL_OTHERS_IN_GROUP 3 */
-/* #define TNS_OVERRIDE_ALL_OTHERS 4 */
-
-#define tnsLinearItp(l, r, T) ((l) * (1.0f - (T)) + (r) * (T))
-
-#define TNS_TILE(tile, r, c, CCount) tile[r * CCount + c]
-
-#define TNS_CLAMP(a, Min, Max) a = a < Min ? Min : (a > Max ? Max : a)
-
-#define TNS_MAX2_INDEX(a, b) (a > b ? 0 : 1)
-
-#define TNS_MIN2_INDEX(a, b) (a < b ? 0 : 1)
-
-#define TNS_MAX3_INDEX(a, b, c) (a > b ? (a > c ? 0 : (b > c ? 1 : 2)) : (b > c ? 1 : 2))
-
-#define TNS_MIN3_INDEX(a, b, c) (a < b ? (a < c ? 0 : (b < c ? 1 : 2)) : (b < c ? 1 : 2))
-
-#define TNS_MAX3_INDEX_ABC(x, y, z) (x > y ? (x > z ? a : (y > z ? b : c)) : (y > z ? b : c))
-
-#define TNS_MIN3_INDEX_ABC(x, y, z) (x < y ? (x < z ? a : (y < z ? b : c)) : (y < z ? b : c))
-
-#define TNS_ABC(index) (index == 0 ? a : (index == 1 ? b : c))
-
-#define TNS_DOUBLE_CLOSE_ENOUGH(a, b) (((a) + DBL_EDGE_LIM) >= (b) && ((a)-DBL_EDGE_LIM) <= (b))
-
-/* #define TNS_DOUBLE_CLOSE_ENOUGH(a,b)\ */
-/* //(((a)+0.00000000001)>=(b) && ((a)-0.0000000001)<=(b)) */
-
-#define TNS_FLOAT_CLOSE_ENOUGH_WIDER(a, b) (((a) + 0.0000001) >= (b) && ((a)-0.0000001) <= (b))
-
-#define TNS_IN_TILE_X(RenderTile, Fx) (RenderTile->FX <= Fx && RenderTile->FXLim >= Fx)
-
-#define TNS_IN_TILE_Y(RenderTile, Fy) (RenderTile->FY <= Fy && RenderTile->FYLim >= Fy)
-
-#define TNS_IN_TILE(RenderTile, Fx, Fy) \
- (TNS_IN_TILE_X(RenderTile, Fx) && TNS_IN_TILE_Y(RenderTile, Fy))
-
-BLI_INLINE void tMatConvert44df(tnsMatrix44d from, tnsMatrix44f to)
-{
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
- to[3] = from[3];
- to[4] = from[4];
- to[5] = from[5];
- to[6] = from[6];
- to[7] = from[7];
- to[8] = from[8];
- to[9] = from[9];
- to[10] = from[10];
- to[11] = from[11];
- to[12] = from[12];
- to[13] = from[13];
- to[14] = from[14];
- to[15] = from[15];
-}
-
-BLI_INLINE int lanpr_TrangleLineBoundBoxTest(LANPR_RenderTriangle *rt, LANPR_RenderLine *rl)
-{
- if (MAX3(rt->v[0]->fbcoord[2], rt->v[1]->fbcoord[2], rt->v[2]->fbcoord[2]) >
- MIN2(rl->l->fbcoord[2], rl->r->fbcoord[2]))
- return 0;
- if (MAX3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]) <
- MIN2(rl->l->fbcoord[0], rl->r->fbcoord[0]))
- return 0;
- if (MIN3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]) >
- MAX2(rl->l->fbcoord[0], rl->r->fbcoord[0]))
- return 0;
- if (MAX3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]) <
- MIN2(rl->l->fbcoord[1], rl->r->fbcoord[1]))
- return 0;
- if (MIN3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]) >
- MAX2(rl->l->fbcoord[1], rl->r->fbcoord[1]))
- return 0;
- return 1;
-}
-
-BLI_INLINE double tMatGetLinearRatio(real l, real r, real FromL);
-BLI_INLINE int lanpr_LineIntersectTest2d(
- const double *a1, const double *a2, const double *b1, const double *b2, double *aRatio)
-{
- double k1, k2;
- double x;
- double y;
- double Ratio;
- double xDiff = (a2[0] - a1[0]); /* +DBL_EPSILON; */
- double xDiff2 = (b2[0] - b1[0]);
-
- if (xDiff == 0) {
- if (xDiff2 == 0) {
- *aRatio = 0;
- return 0;
- }
- double r2 = tMatGetLinearRatio(b1[0], b2[0], a1[0]);
- x = tnsLinearItp(b1[0], b2[0], r2);
- y = tnsLinearItp(b1[1], b2[1], r2);
- *aRatio = Ratio = tMatGetLinearRatio(a1[1], a2[1], y);
- }
- else {
- if (xDiff2 == 0) {
- Ratio = tMatGetLinearRatio(a1[0], a2[0], b1[0]);
- x = tnsLinearItp(a1[0], a2[0], Ratio);
- *aRatio = Ratio;
- }
- else {
- k1 = (a2[1] - a1[1]) / xDiff;
- k2 = (b2[1] - b1[1]) / xDiff2;
-
- if ((k1 == k2))
- return 0;
-
- x = (a1[1] - b1[1] - k1 * a1[0] + k2 * b1[0]) / (k2 - k1);
-
- Ratio = (x - a1[0]) / xDiff;
-
- *aRatio = Ratio;
- }
- }
-
- if (b1[0] == b2[0]) {
- y = tnsLinearItp(a1[1], a2[1], Ratio);
- if (y > MAX2(b1[1], b2[1]) || y < MIN2(b1[1], b2[1]))
- return 0;
- }
- else if (Ratio <= 0 || Ratio > 1 || (b1[0] > b2[0] && x > b1[0]) ||
- (b1[0] < b2[0] && x < b1[0]) || (b2[0] > b1[0] && x > b2[0]) ||
- (b2[0] < b1[0] && x < b2[0]))
- return 0;
-
- return 1;
-}
-BLI_INLINE double lanpr_GetLineZ(tnsVector3d l, tnsVector3d r, real Ratio)
-{
- /* double z = 1 / tnsLinearItp(1 / l[2], 1 / r[2], Ratio); */
- double z = tnsLinearItp(l[2], r[2], Ratio);
- return z;
-}
-BLI_INLINE double lanpr_GetLineZPoint(tnsVector3d l, tnsVector3d r, tnsVector3d FromL)
-{
- double ra = (FromL[0] - l[0]) / (r[0] - l[0]);
- return tnsLinearItp(l[2], r[2], ra);
- /* return 1 / tnsLinearItp(1 / l[2], 1 / r[2], r); */
-}
-BLI_INLINE double lanpr_GetLinearRatio(tnsVector3d l, tnsVector3d r, tnsVector3d FromL)
-{
- double ra = (FromL[0] - l[0]) / (r[0] - l[0]);
- return ra;
-}
-
-BLI_INLINE double tMatGetLinearRatio(real l, real r, real FromL)
-{
- double ra = (FromL - l) / (r - l);
- return ra;
-}
-BLI_INLINE void tMatVectorMinus2d(tnsVector2d result, tnsVector2d l, tnsVector2d r)
-{
- result[0] = l[0] - r[0];
- result[1] = l[1] - r[1];
-}
-
-BLI_INLINE void tMatVectorMinus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r)
-{
- result[0] = l[0] - r[0];
- result[1] = l[1] - r[1];
- result[2] = l[2] - r[2];
-}
-BLI_INLINE void tMatVectorSubtract3d(tnsVector3d l, tnsVector3d r)
-{
- l[0] = l[0] - r[0];
- l[1] = l[1] - r[1];
- l[2] = l[2] - r[2];
-}
-BLI_INLINE void tMatVectorPlus3d(tnsVector3d result, tnsVector3d l, tnsVector3d r)
-{
- result[0] = l[0] + r[0];
- result[1] = l[1] + r[1];
- result[2] = l[2] + r[2];
-}
-BLI_INLINE void tMatVectorAccum3d(tnsVector3d l, tnsVector3d r)
-{
- l[0] = l[0] + r[0];
- l[1] = l[1] + r[1];
- l[2] = l[2] + r[2];
-}
-BLI_INLINE void tMatVectorAccum2d(tnsVector2d l, tnsVector2d r)
-{
- l[0] = l[0] + r[0];
- l[1] = l[1] + r[1];
-}
-BLI_INLINE void tMatVectorNegate3d(tnsVector3d result, tnsVector3d l)
-{
- result[0] = -l[0];
- result[1] = -l[1];
- result[2] = -l[2];
-}
-BLI_INLINE void tMatVectorNegateSelf3d(tnsVector3d l)
-{
- l[0] = -l[0];
- l[1] = -l[1];
- l[2] = -l[2];
-}
-BLI_INLINE void tMatVectorCopy2d(tnsVector2d from, tnsVector2d to)
-{
- to[0] = from[0];
- to[1] = from[1];
-}
-BLI_INLINE void tMatVectorCopy3d(tnsVector3d from, tnsVector3d to)
-{
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
-}
-BLI_INLINE void tMatVectorCopy4d(tnsVector4d from, tnsVector4d to)
-{
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
- to[3] = from[3];
-}
-BLI_INLINE void tMatVectorMultiSelf4d(tnsVector3d from, real num)
-{
- from[0] *= num;
- from[1] *= num;
- from[2] *= num;
- from[3] *= num;
-}
-BLI_INLINE void tMatVectorMultiSelf3d(tnsVector3d from, real num)
-{
- from[0] *= num;
- from[1] *= num;
- from[2] *= num;
-}
-BLI_INLINE void tMatVectorMultiSelf2d(tnsVector3d from, real num)
-{
- from[0] *= num;
- from[1] *= num;
-}
-
-BLI_INLINE real tMatDirectionToRad(tnsVector2d Dir)
-{
- real arcc = acos(Dir[0]);
- real arcs = asin(Dir[1]);
-
- if (Dir[0] >= 0) {
- if (Dir[1] >= 0)
- return arcc;
- else
- return TNS_PI * 2 - arcc;
- }
- else {
- if (Dir[1] >= 0)
- return arcs + TNS_PI / 2;
- else
- return TNS_PI + arcs;
- }
-}
-
-BLI_INLINE void tMatVectorConvert4fd(tnsVector4f from, tnsVector4d to)
-{
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
- to[3] = from[3];
-}
-
-BLI_INLINE void tMatVectorConvert3fd(tnsVector3f from, tnsVector3d to)
-{
- to[0] = from[0];
- to[1] = from[1];
- to[2] = from[2];
-}
-
-int lanpr_point_inside_triangled(tnsVector2d v, tnsVector2d v0, tnsVector2d v1, tnsVector2d v2);
-real lanpr_LinearInterpolate(real l, real r, real T);
-void lanpr_LinearInterpolate2dv(real *l, real *r, real T, real *Result);
-void lanpr_LinearInterpolate3dv(real *l, real *r, real T, real *Result);
/* functions */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list