commit de40c5cf8fc7cb68c1d6f8a62df9da8a18220fad
parent 1e8bdac5d12e5fa571847c9cb3fd9dcf360294ab
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Tue, 21 Jul 2020 16:24:32 +0200
Allow new tricks in creating test scenes
Diffstat:
8 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/src/test_sg3d_cube_behind_cube.c b/src/test_sg3d_cube_behind_cube.c
@@ -77,7 +77,7 @@ main(int argc, char** argv)
OK(sg3d_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx));
d3(ctx.offset, -2, -2, 20);
- ctx.scale = 5;
+ d3_splat(ctx.scale, 5);
/* Second cube (front: 0, back: 1), right-handed normal outside */
OK(sg3d_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx));
@@ -92,7 +92,7 @@ main(int argc, char** argv)
SG3D_C_DUMP_CONST | SG3D_C_DUMP_STATIC));
d3(ctx.offset, -3, -3, 30);
- ctx.scale = 7;
+ d3_splat(ctx.scale, 7);
ctx.front_media = medium1;
ctx.back_media = medium0;
diff --git a/src/test_sg3d_cube_in_cube.c b/src/test_sg3d_cube_in_cube.c
@@ -67,7 +67,7 @@ main(int argc, char** argv)
OK(sg3d_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx));
d3(ctx.offset, -1, -1, -1);
- ctx.scale = 3;
+ d3_splat(ctx.scale, 3);
ctx.reverse_vrtx = 1;
/* Second cube (front: 0, back: 1), right-handed normal inside */
@@ -83,7 +83,7 @@ main(int argc, char** argv)
SG3D_C_DUMP_CONST | SG3D_C_DUMP_STATIC));
d3(ctx.offset, -4, -4, -4);
- ctx.scale = 10;
+ d3_splat(ctx.scale, 10);
ctx.reverse_vrtx = 1;
ctx.reverse_med = 1;
ctx.front_media = medium1;
diff --git a/src/test_sg3d_cube_on_cube.c b/src/test_sg3d_cube_on_cube.c
@@ -74,7 +74,7 @@ main(int argc, char** argv)
ctx.positions = box_vertices; /* Can use distorded cube for cube #3 */
d3(ctx.offset, 0, 0, 0);
- ctx.scale = 4;
+ d3_splat(ctx.scale, 4);
ctx.reverse_vrtx = 1;
ctx.reverse_med = 1;
ctx.front_media = medium2;
diff --git a/src/test_sg3d_invalid_models.c b/src/test_sg3d_invalid_models.c
@@ -74,7 +74,7 @@ main(int argc, char** argv)
ctx.indices = cube_indices2;
/* Second cube (front: 0, back: 1), right-handed normal outside
- * Same cube location, but opposite diagonals on sides han first cube */
+ * Same cube location, but opposite diagonals on sides than first cube */
OK(sg3d_geometry_add(geom, nvertices, ntriangles, &callbacks, &ctx));
OK(sg3d_geometry_get_unique_triangles_with_merge_conflict_count(geom, &count));
diff --git a/src/test_sg3d_many_enclosures.c b/src/test_sg3d_many_enclosures.c
@@ -74,7 +74,7 @@ main(int argc, char** argv)
double center_y = 2 * (1 + NB_CYL_Z) * (j - NB_CYL_Y / 2);
m_in = (unsigned)k;
m_out = (unsigned)(k + 1);
- ctx.ctx.scale = k + 1;
+ d3_splat(ctx.ctx.scale, k + 1);
#ifdef MITIGATE_EMBREE_181
/* Mitigate Embree issue #181
* We cannot keep perfect alignment of cylinders
diff --git a/src/test_sg3d_some_enclosures.c b/src/test_sg3d_some_enclosures.c
@@ -74,7 +74,7 @@ main(int argc, char** argv)
double center_y = 2 * (1 + NB_CYL_Z) * (j - NB_CYL_Y / 2);
m_in = (unsigned)k;
m_out = (unsigned)(k + 1);
- ctx.ctx.scale = k + 1;
+ d3_splat(ctx.ctx.scale, k + 1);
#ifdef MITIGATE_EMBREE_181
/* Mitigate Embree issue #181
* We cannot keep perfect alignment of cylinders
diff --git a/src/test_sg3d_utils.h b/src/test_sg3d_utils.h
@@ -17,6 +17,8 @@
#define TEST_SG3D_UTILS_H
#include <rsys/mem_allocator.h>
+#include <rsys/double3.h>
+
#include <stdio.h>
#define OK(Cond) CHK((Cond) == RES_OK)
@@ -97,11 +99,11 @@ struct context {
const unsigned* intface;
void* custom;
double offset[3];
- double scale;
+ double scale[3];
char reverse_vrtx, reverse_med;
};
#define CONTEXT_NULL__ {\
- NULL, NULL, NULL, NULL, NULL, NULL, {0,0,0}, 1, 0, 0\
+ NULL, NULL, NULL, NULL, NULL, NULL, {0,0,0}, {1, 1, 1}, 0, 0\
}
static const unsigned medium0[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
@@ -128,10 +130,9 @@ static INLINE void
get_position(const unsigned ivert, double pos[3], void* context)
{
const struct context* ctx = context;
+ double tmp[3];
ASSERT(pos && ctx);
- pos[0] = ctx->positions[ivert * 3 + 0] * ctx->scale + ctx->offset[0];
- pos[1] = ctx->positions[ivert * 3 + 1] * ctx->scale + ctx->offset[1];
- pos[2] = ctx->positions[ivert * 3 + 2] * ctx->scale + ctx->offset[2];
+ d3_add(pos, d3_mul(tmp, ctx->positions + ivert * 3, ctx->scale), ctx->offset);
}
static INLINE void
diff --git a/src/test_sg3d_utils2.h b/src/test_sg3d_utils2.h
@@ -48,7 +48,7 @@ get_s3dut_position(const unsigned ivert, double pos[3], void* context)
ASSERT(pos && ctx);
ASSERT(ivert < ctx->data.nvertices);
(void)ivert;
- d3_add(pos, d3_muld(tmp, ctx->data.positions + ivert * 3, ctx->ctx.scale),
+ d3_add(pos, d3_mul(tmp, ctx->data.positions + ivert * 3, ctx->ctx.scale),
ctx->ctx.offset);
}