star-gf

Compute Gebhart factors
git clone git://git.meso-star.fr/star-gf.git
Log | Files | Refs | README | LICENSE

commit d11fb15b71b267eb97a793d17c33f6db492d4538
parent 7ceb37f296d7c1e4a7500a6c4a0605b0508e9ee4
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 19 Oct 2016 10:57:27 +0200

Add a filter function to the S3D shape

Diffstat:
Mcmake/CMakeLists.txt | 8++++----
Msrc/sgf_shape.c | 21+++++++++++++++++++++
Msrc/sgf_shape_c.h | 6++++++
3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -47,14 +47,14 @@ set(VERSION_MINOR 1) set(VERSION_PATCH 0) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) -set(SGF_FILES_SRC - sgf_device.c +set(SGF_FILES_SRC + sgf_device.c sgf_estimator.c sgf_scene.c sgf_shape.c) set(SGF_FILES_INC_API sgf.h) -set(SGF_FILES_INC - sgf_device_c.h +set(SGF_FILES_INC + sgf_device_c.h sgf_realisation.h) set(SGF_FILES_DOC COPYING README.md) diff --git a/src/sgf_shape.c b/src/sgf_shape.c @@ -22,6 +22,25 @@ /******************************************************************************* * Local functions ******************************************************************************/ +static int +hit_filter + (const struct s3d_hit* hit, + const float org[3], + const float dir[3], + void* ray_data, + void* filter_data) +{ + struct ray_data* rdata = ray_data; + (void)org, (void)dir, (void)filter_data; + + if(!ray_data) return 0; + /* Discard primitive from which the ray starts from */ + if(S3D_PRIMITIVE_EQ(&rdata->prim_from, &hit->prim)) return 1; + /* Ray starts on an edge and intersect the neighbor triangle */ + if(hit->distance <= 0) return 1; + return 0; +} + static FINLINE int check_shape3d_desc(const struct sgf_shape3d_desc* desc) { @@ -78,6 +97,8 @@ sgf_shape3d_create(struct sgf_device* dev, struct sgf_shape** out_shape) res = s3d_shape_create_mesh(dev->s3d, &shape->s3d_shape); if(res != RES_OK) goto error; + res = s3d_mesh_set_hit_filter_function(shape->s3d_shape, &hit_filter, NULL); + if(res != RES_OK) goto error; darray_double_init(dev->allocator, &shape->abs); darray_double_init(dev->allocator, &shape->emi); diff --git a/src/sgf_shape_c.h b/src/sgf_shape_c.h @@ -19,6 +19,8 @@ #include <rsys/dynamic_array_double.h> #include <rsys/ref_count.h> +#include <star/s3d.h> + struct s3d_shape; struct sgf_device; @@ -34,5 +36,9 @@ struct sgf_shape { struct sgf_device* dev; }; +struct ray_data { + struct s3d_primitive prim_from; +}; + #endif /* SGF_SHAPE_C_H */