solstice-solver

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

commit d9d32daba4f04bfc6e89b72c340b5f61c2f80e3a
parent 34b150cc9046ec92d26a1cc4d758e94f9d765ef9
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date:   Wed, 13 Jul 2016 13:50:58 +0200

Add API call ssol_object_instance_set_receiver

Diffstat:
Msrc/ssol.h | 6++++++
Msrc/ssol_object_instance.c | 17+++++++++++++++++
Msrc/ssol_object_instance_c.h | 1+
Msrc/test_ssol_object_instance.c | 4++++
4 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/ssol.h b/src/ssol.h @@ -120,6 +120,7 @@ static const struct ssol_vertex_data SSOL_VERTEX_DATA_NULL = struct ssol_quadric_plane { char unused; /* Define z = 0 */ }; + struct ssol_quadric_parabol { double focal; /* Define x^2 + y^2 - 4 focal z = 0 */ }; @@ -412,6 +413,11 @@ ssol_object_instance_set_transform const double transform[12]); /* 3x4 column major matrix */ SSOL_API res_T +ssol_object_instance_set_receiver + (struct ssol_object_instance* instance, + const char* name); + +SSOL_API res_T ssol_object_instance_set_receiver_image (struct ssol_object_instance* instance, struct ssol_image* image, diff --git a/src/ssol_object_instance.c b/src/ssol_object_instance.c @@ -42,6 +42,7 @@ object_instance_release(ref_T* ref) if (instance->image) SSOL(image_ref_put(instance->image)); SSOL(device_ref_put(instance->dev)); + MEM_RM(instance->dev->allocator, instance->receiver_name); MEM_RM(instance->dev->allocator, instance); } @@ -118,6 +119,22 @@ ssol_object_instance_set_transform } res_T +ssol_object_instance_set_receiver + (struct ssol_object_instance* instance, + const char* name) +{ + if (!instance || !name) + return RES_BAD_ARG; + + /* keep name */ + instance->receiver_name = MEM_ALLOC(instance->dev->allocator, strlen(name) + 1); + if (!instance->receiver_name) return RES_MEM_ERR; + strcpy(instance->receiver_name, name); + + return RES_OK; +} + +res_T ssol_object_instance_set_receiver_image (struct ssol_object_instance* instance, struct ssol_image* image, 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_image* image; enum ssol_parametrization_type param_type; struct list_node scene_attachment; + char* receiver_name; /* NULL if not a receiver */ struct ssol_device* dev; ref_T ref; diff --git a/src/test_ssol_object_instance.c b/src/test_ssol_object_instance.c @@ -58,6 +58,10 @@ main(int argc, char** argv) CHECK(ssol_object_instance_set_transform(instance, NULL), RES_BAD_ARG); CHECK(ssol_object_instance_set_transform(instance, transform), RES_OK); + CHECK(ssol_object_instance_set_receiver(NULL, "receiver 1"), RES_BAD_ARG); + CHECK(ssol_object_instance_set_receiver(instance, NULL), RES_BAD_ARG); + CHECK(ssol_object_instance_set_receiver(instance, "receiver 1"), RES_OK); + CHECK(ssol_image_create(dev, &image), RES_OK); CHECK(ssol_object_instance_set_receiver_image (NULL, image, SSOL_PARAMETRIZATION_PRIMITIVE_ID), RES_BAD_ARG);