star-3d

Surface structuring for efficient 3D geometric queries
git clone git://git.meso-star.fr/star-3d.git
Log | Files | Refs | README | LICENSE

commit b97c95bbfbb089052a2e3ac65083d49fcf1528ef
parent 4db84f7e8be9da2f7e3d30758523daba0fb6d9d9
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 16 Jun 2015 15:12:42 +0200

Change the s3d_shape_flip_surface API

Remove the `flip' flag that defined if the origin shape surface had to
be flipped or not.

Diffstat:
Msrc/s3d.h | 3+--
Msrc/s3d_shape.c | 6+++---
Msrc/test_s3d_shape.c | 9++++-----
3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/s3d.h b/src/s3d.h @@ -307,8 +307,7 @@ s3d_shape_is_attached /* Flip the surface orientation, i.e. flip the geometric normal of the surface */ S3D_API res_T s3d_shape_flip_surface - (struct s3d_shape* shape, - const char flip); + (struct s3d_shape* shape); /******************************************************************************* * Sampler API diff --git a/src/s3d_shape.c b/src/s3d_shape.c @@ -202,13 +202,13 @@ s3d_shape_is_attached(struct s3d_shape* shape, char* is_attached) } res_T -s3d_shape_flip_surface(struct s3d_shape* shape, const char flip) +s3d_shape_flip_surface(struct s3d_shape* shape) { if(!shape) return RES_BAD_ARG; switch(shape->type) { - case SHAPE_MESH: shape->data.mesh->flip_surface = flip; break; - case SHAPE_INSTANCE: shape->data.instance->flip_surface = flip; break; + case SHAPE_MESH: shape->data.mesh->flip_surface ^= 1; break; + case SHAPE_INSTANCE: shape->data.instance->flip_surface ^= 1; break; default: FATAL("Unreachable code\n"); break; } return RES_OK; diff --git a/src/test_s3d_shape.c b/src/test_s3d_shape.c @@ -213,9 +213,9 @@ main(int argc, char** argv) CHECK(s3d_shape_is_enabled(shape, &c), RES_OK); CHECK(c, 0); - CHECK(s3d_shape_flip_surface(NULL, 0), RES_BAD_ARG); - CHECK(s3d_shape_flip_surface(shape, 0), RES_OK); - CHECK(s3d_shape_flip_surface(shape, 1), RES_OK); + CHECK(s3d_shape_flip_surface(NULL), RES_BAD_ARG); + CHECK(s3d_shape_flip_surface(shape), RES_OK); + CHECK(s3d_shape_flip_surface(shape), RES_OK); CHECK(s3d_scene_attach_shape(scn, shape), RES_OK); @@ -238,8 +238,7 @@ main(int argc, char** argv) CHECK(s3d_instance_translate(inst, S3D_WORLD_TRANSFORM, pos), RES_OK); CHECK(s3d_instance_translate(shape, S3D_WORLD_TRANSFORM, pos), RES_BAD_ARG); - CHECK(s3d_shape_flip_surface(inst, 0), RES_OK); - CHECK(s3d_shape_flip_surface(inst, 1), RES_OK); + CHECK(s3d_shape_flip_surface(inst), RES_OK); CHECK(s3d_shape_ref_get(NULL), RES_BAD_ARG); CHECK(s3d_shape_ref_get(shape), RES_OK);