solstice-solver

Solver library of the solstice app
git clone git://git.meso-star.com/solstice-solver.git
Log | Files | Refs | README | LICENSE

commit 9fb5490d9bc25b61cc8e625d98e4126a2056f279
parent 1d6ecd2a93c83c5eb495200d1d7f14aa3e9f9ef3
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Tue, 30 Aug 2016 18:41:47 +0200

Add a target mask on instances.

The realization's mask is the OR of every crossed instance's mask.
Used to sort good/bad rays.

Diffstat:
Msrc/ssol.h | 5+++++
Msrc/ssol_object_instance.c | 13+++++++++++++
Msrc/ssol_object_instance_c.h | 8++++++++
Msrc/test_ssol_object_instance.c | 5+++++
4 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/src/ssol.h b/src/ssol.h @@ -396,6 +396,11 @@ ssol_object_instance_set_receiver const char* name); /* May be NULL <=> it is no more a receiver */ SSOL_API res_T +ssol_object_instance_set_target_mask + (struct ssol_object_instance* instance, + const uint32_t mask); + +SSOL_API res_T ssol_object_instance_is_attached (struct ssol_object_instance* instance, char* is_attached); diff --git a/src/ssol_object_instance.c b/src/ssol_object_instance.c @@ -74,6 +74,7 @@ ssol_object_instantiate instance->dev = dev; instance->object = object; + instance->target_mask = 0; str_init(dev->allocator, &instance->receiver_name); SSOL(object_ref_get(object)); SSOL(device_ref_get(dev)); @@ -145,6 +146,18 @@ ssol_object_instance_set_receiver } res_T +ssol_object_instance_set_target_mask + (struct ssol_object_instance* instance, + const uint32_t mask) +{ + if (!instance) + return RES_BAD_ARG; + + instance->target_mask = mask; + return RES_OK; +} + +res_T ssol_object_instance_is_attached (struct ssol_object_instance* instance, char* is_attached) { diff --git a/src/ssol_object_instance_c.h b/src/ssol_object_instance_c.h @@ -25,6 +25,7 @@ struct ssol_object_instance struct ssol_object* object; /* Instantiated object */ struct s3d_shape* s3d_shape; /* Instantiated Star-3D shape */ struct str receiver_name; /* Empty if not a receiver */ + uint32_t target_mask; struct ssol_device* dev; ref_T ref; @@ -53,4 +54,11 @@ object_instance_get_receiver_name(const struct ssol_object_instance* instance) ? NULL : str_cget(&instance->receiver_name); } +static INLINE uint32_t +object_instance_get_target_mask(const struct ssol_object_instance* instance) +{ + ASSERT(instance); + return instance->target_mask; +} + #endif /* SSOL_OBJECT_INSTANCE_C_H */ diff --git a/src/test_ssol_object_instance.c b/src/test_ssol_object_instance.c @@ -63,6 +63,11 @@ main(int argc, char** argv) CHECK(ssol_object_instance_set_receiver(instance, "receiver 0"), RES_OK); CHECK(ssol_object_instance_set_receiver(instance, NULL), RES_OK); + CHECK(ssol_object_instance_set_target_mask(NULL, 1), RES_BAD_ARG); + CHECK(ssol_object_instance_set_target_mask(instance, 1), RES_OK); + CHECK(ssol_object_instance_set_target_mask(instance, 0), RES_OK); + CHECK(ssol_object_instance_set_target_mask(instance, 0x10), RES_OK); + CHECK(ssol_object_instance_ref_put(instance), RES_OK); CHECK(ssol_object_ref_put(object), RES_OK);