[Bf-blender-cvs] [1ce41b97265] soc-2018-npr: File RW OK
Nick Wu
noreply at git.blender.org
Mon Jul 16 16:25:59 CEST 2018
Commit: 1ce41b97265ab6dd3bd370c7d427c8d5afe78523
Author: Nick Wu
Date: Mon Jul 16 22:25:06 2018 +0800
Branches: soc-2018-npr
https://developer.blender.org/rB1ce41b97265ab6dd3bd370c7d427c8d5afe78523
File RW OK
===================================================================
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
M source/blender/draw/engines/lanpr/lanpr_all.h
M source/blender/draw/engines/lanpr/lanpr_ops.c
M source/blender/makesdna/DNA_scene_types.h
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6b356ac2e96..833d32023bb 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -89,6 +89,7 @@
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_lightprobe_types.h"
+#include "DNA_lanpr_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_text_types.h"
#include "DNA_view3d_types.h"
@@ -6393,6 +6394,12 @@ static void direct_link_scene(FileData *fd, Scene *sce)
}
}
+ /* LANPR things */
+ link_list(fd, &sce->lanpr.line_layers);
+ for (LANPR_LineLayer *ll = sce->lanpr.line_layers.first; ll; ll = ll->next) {
+ link_list(fd, &ll->components);
+ }
+
sce->layer_properties = newdataadr(fd, sce->layer_properties);
IDP_DirectLinkGroup_OrFree(&sce->layer_properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd);
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index a215b013b2a..7e3619ccb1f 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -134,6 +134,7 @@
#include "DNA_packedFile_types.h"
#include "DNA_particle_types.h"
#include "DNA_lightprobe_types.h"
+#include "DNA_lanpr_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_scene_types.h"
#include "DNA_sdna_types.h"
@@ -2632,6 +2633,14 @@ static void write_scene(WriteData *wd, Scene *sce)
write_lightcache(wd, sce->eevee.light_cache);
}
+ /* LANPR Line Layers */
+ for (LANPR_LineLayer *ll = sce->lanpr.line_layers.first; ll; ll = ll->next) {
+ writestruct(wd, DATA, LANPR_LineLayer, 1, ll);
+ for (LANPR_LineLayerComponent *llc = ll->components.first; llc; llc = llc->next) {
+ writestruct(wd, DATA, LANPR_LineLayerComponent, 1, llc);
+ }
+ }
+
/* Freed on doversion. */
BLI_assert(sce->layer_properties == NULL);
}
diff --git a/source/blender/draw/engines/lanpr/lanpr_all.h b/source/blender/draw/engines/lanpr/lanpr_all.h
index a54e0995986..5c0f3e6c031 100644
--- a/source/blender/draw/engines/lanpr/lanpr_all.h
+++ b/source/blender/draw/engines/lanpr/lanpr_all.h
@@ -2,6 +2,7 @@
#include "lanpr_util.h"
#include "BLI_mempool.h"
+#include "BLI_utildefines.h"
//#include "GPU_framebuffer.h"
#include "GPU_batch.h"
#include "GPU_framebuffer.h"
@@ -503,18 +504,6 @@ extern RenderEngineType DRW_engine_viewport_lanpr_type;
#define TNS_CLAMP(a, Min, Max) \
a = a < Min ? Min : (a > Max ? Max : a)
-#define TNS_MAX2(a, b) \
- (a > b ? a : b)
-
-#define TNS_MIN2(a, b) \
- (a < b ? a : b)
-
-#define TNS_MAX3(a, b, c) \
- (a > TNS_MAX2(b, c) ? a : TNS_MAX2(b, c))
-
-#define TNS_MIN3(a, b, c) \
- (a < TNS_MIN2(b, c) ? a : TNS_MIN2(b, c))
-
#define TNS_MAX2_INDEX(a, b) \
(a > b ? 0 : 1)
@@ -577,11 +566,11 @@ __inline void tMatConvert44df(tnsMatrix44d from, tnsMatrix44f to) {
}
__inline int lanpr_TrangleLineBoundBoxTest(LANPR_RenderTriangle *rt, LANPR_RenderLine *rl) {
- if (TNS_MAX3(rt->V[0]->FrameBufferCoord[2], rt->V[1]->FrameBufferCoord[2], rt->V[2]->FrameBufferCoord[2]) > TNS_MIN2(rl->L->FrameBufferCoord[2], rl->R->FrameBufferCoord[2])) return 0;
- if (TNS_MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]) < TNS_MIN2(rl->L->FrameBufferCoord[0], rl->R->FrameBufferCoord[0])) return 0;
- if (TNS_MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]) > TNS_MAX2(rl->L->FrameBufferCoord[0], rl->R->FrameBufferCoord[0])) return 0;
- if (TNS_MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]) < TNS_MIN2(rl->L->FrameBufferCoord[1], rl->R->FrameBufferCoord[1])) return 0;
- if (TNS_MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]) > TNS_MAX2(rl->L->FrameBufferCoord[1], rl->R->FrameBufferCoord[1])) return 0;
+ if (MAX3(rt->V[0]->FrameBufferCoord[2], rt->V[1]->FrameBufferCoord[2], rt->V[2]->FrameBufferCoord[2]) > MIN2(rl->L->FrameBufferCoord[2], rl->R->FrameBufferCoord[2])) return 0;
+ if (MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]) < MIN2(rl->L->FrameBufferCoord[0], rl->R->FrameBufferCoord[0])) return 0;
+ if (MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]) > MAX2(rl->L->FrameBufferCoord[0], rl->R->FrameBufferCoord[0])) return 0;
+ if (MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]) < MIN2(rl->L->FrameBufferCoord[1], rl->R->FrameBufferCoord[1])) return 0;
+ if (MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]) > MAX2(rl->L->FrameBufferCoord[1], rl->R->FrameBufferCoord[1])) return 0;
return 1;
}
@@ -628,7 +617,7 @@ __inline int lanpr_LineIntersectTest2d(tnsVector2d a1, tnsVector2d a2, tnsVector
if (b1[0] == b2[0]) {
y = tnsLinearItp(a1[1], a2[1], Ratio);
- if (y > TNS_MAX2(b1[1], b2[1]) || y < TNS_MIN2(b1[1], b2[1])) return 0;
+ if (y > MAX2(b1[1], b2[1]) || y < MIN2(b1[1], b2[1])) return 0;
}
else
if (Ratio <= 0 || Ratio > 1 ||
diff --git a/source/blender/draw/engines/lanpr/lanpr_ops.c b/source/blender/draw/engines/lanpr/lanpr_ops.c
index 2f18f6e2bbd..bc393956127 100644
--- a/source/blender/draw/engines/lanpr/lanpr_ops.c
+++ b/source/blender/draw/engines/lanpr/lanpr_ops.c
@@ -4,6 +4,7 @@
#include "BLI_linklist.h"
#include "BLI_math_matrix.h"
#include "BLI_task.h"
+#include "BLI_utildefines.h"
#include "lanpr_all.h"
#include "lanpr_util.h"
#include "DRW_render.h"
@@ -227,10 +228,10 @@ void lanpr_SplitBoundingArea(LANPR_RenderBuffer *rb, LANPR_BoundingArea *Root) {
while (rt = lstPopPointerNoFree(&Root->AssociatedTriangles)) {
LANPR_BoundingArea *ba = Root->Child;
real B[4];
- B[0] = TNS_MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
- B[1] = TNS_MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
- B[2] = TNS_MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
- B[3] = TNS_MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
+ B[0] = MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
+ B[1] = MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
+ B[2] = MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
+ B[3] = MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
if (TNS_BOUND_AREA_CROSSES(B, &ba[0].L)) lanpr_AssociateTriangleWithBoundingArea(rb, &ba[0], rt, B, 0);
if (TNS_BOUND_AREA_CROSSES(B, &ba[1].L)) lanpr_AssociateTriangleWithBoundingArea(rb, &ba[1], rt, B, 0);
if (TNS_BOUND_AREA_CROSSES(B, &ba[2].L)) lanpr_AssociateTriangleWithBoundingArea(rb, &ba[2], rt, B, 0);
@@ -244,10 +245,10 @@ int lanpr_LineCrossesBoundingArea(LANPR_RenderBuffer *fb, tnsVector2d L, tnsVect
tnsVector4d Converted;
real c1, c;
- if ((Converted[0] = (real)ba->L) > TNS_MAX2(L[0], R[0])) return 0;
- if ((Converted[1] = (real)ba->R) < TNS_MIN2(L[0], R[0])) return 0;
- if ((Converted[2] = (real)ba->B) > TNS_MAX2(L[1], R[1])) return 0;
- if ((Converted[3] = (real)ba->U) < TNS_MIN2(L[1], R[1])) return 0;
+ if ((Converted[0] = (real)ba->L) > MAX2(L[0], R[0])) return 0;
+ if ((Converted[1] = (real)ba->R) < MIN2(L[0], R[0])) return 0;
+ if ((Converted[2] = (real)ba->B) > MAX2(L[1], R[1])) return 0;
+ if ((Converted[3] = (real)ba->U) < MIN2(L[1], R[1])) return 0;
vx = L[0] - R[0];
vy = L[1] - R[1];
@@ -311,10 +312,10 @@ void lanpr_AssociateTriangleWithBoundingArea(LANPR_RenderBuffer *rb, LANPR_Bound
real *B1 = LRUB;
real B[4];
if (!LRUB) {
- B[0] = TNS_MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
- B[1] = TNS_MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
- B[2] = TNS_MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
- B[3] = TNS_MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
+ B[0] = MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
+ B[1] = MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
+ B[2] = MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
+ B[3] = MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
B1 = B;
}
if (TNS_BOUND_AREA_CROSSES(B1, &ba[0].L)) lanpr_AssociateTriangleWithBoundingArea(rb, &ba[0], rt, B1, Recursive);
@@ -329,10 +330,10 @@ int lanpr_GetTriangleBoundingTile(LANPR_RenderBuffer *rb, LANPR_RenderTriangle *
if (!rt->V[0] || !rt->V[1] || !rt->V[2]) return 0;
- B[0] = TNS_MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
- B[1] = TNS_MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
- B[2] = TNS_MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
- B[3] = TNS_MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
+ B[0] = MIN3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
+ B[1] = MAX3(rt->V[0]->FrameBufferCoord[0], rt->V[1]->FrameBufferCoord[0], rt->V[2]->FrameBufferCoord[0]);
+ B[2] = MIN3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
+ B[3] = MAX3(rt->V[0]->FrameBufferCoord[1], rt->V[1]->FrameBufferCoord[1], rt->V[2]->FrameBufferCoord[1]);
if (B[0] > 1 || B[1] < -1 || B[2] > 1 || B[3] < -1) return 0;
@@ -409,7 +410,7 @@ LANPR_BoundingArea *lanpr_GetNextBoundingArea(LANPR_BoundingArea *This, LANPR_Re
ux = x + (uy - y) / k;
r1 = tMatGetLine
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list