commit 3cec628d24c852b0b28ce9f453ae7c3a7f56ee31
parent 08051a445b4e0a211cc2e31dd89894f63ad3bd49
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 4 Jan 2017 09:58:31 +0100
Update the solstice geometry instantiation
Attach the SSol instance to the SSol scene on the instantiation of a
solstice geometry.
Diffstat:
4 files changed, 34 insertions(+), 13 deletions(-)
diff --git a/src/solstice.c b/src/solstice.c
@@ -206,6 +206,12 @@ solstice_init
goto error;
}
+ res = ssol_scene_create(solstice->ssol, &solstice->scene);
+ if(res != RES_OK) {
+ fprintf(stderr, "Could not create the Solstice Solver scene.\n");
+ goto error;
+ }
+
res = solparser_create(allocator, &solstice->parser);
if(res != RES_OK) {
fprintf(stderr, "Could not create the Solstice Parser.\n");
@@ -236,6 +242,7 @@ solstice_release(struct solstice* solstice)
clear_materials(&solstice->materials);
clear_objects(&solstice->objects);
if(solstice->ssol) SSOL(device_ref_put(solstice->ssol));
+ if(solstice->scene) SSOL(scene_ref_put(solstice->scene));
if(solstice->parser) solparser_ref_put(solstice->parser);
if(solstice->camera) SSOL(camera_ref_put(solstice->camera));
if(solstice->framebuffer) SSOL(image_ref_put(solstice->framebuffer));
diff --git a/src/solstice.h b/src/solstice.h
@@ -50,6 +50,8 @@ struct score_node;
struct solstice {
struct ssol_device* ssol;
+ struct ssol_scene* scene;
+
struct solparser* parser;
struct score_device* score;
diff --git a/src/solstice_entity.c b/src/solstice_entity.c
@@ -1,17 +1,17 @@
/* Copyright (C) CNRS 2016-2017
*
- * This program is free software: you can redistribute it and/or modify it under
- * the terms of the GNU General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>. */
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "solstice.h"
#include "solstice_c.h"
@@ -58,9 +58,8 @@ solstice_setup_entity
if (res != RES_OK) goto error;
score_node_set_translation(geometry_node, entity->translation);
score_node_set_rotations(geometry_node, entity->rotation);
- res = solstice_instantiate_geometry(
- /* TODO: attach instance to solver */
- solstice, entity->data.geometry, &instance);
+ res = solstice_instantiate_geometry
+ (solstice, entity->data.geometry, &instance);
if (res != RES_OK) goto error;
res = score_node_geometry_setup(geometry_node, instance);
if (res != RES_OK) goto error;
diff --git a/src/solstice_object.c b/src/solstice_object.c
@@ -429,6 +429,8 @@ solstice_instantiate_geometry
struct ssol_object** pssol_obj = NULL;
struct ssol_object* ssol_obj = NULL;
struct ssol_object* ssol_obj_new = NULL;
+ int is_attached_to_scn = 0;
+ int is_registered = 0;
res_T res = RES_OK;
ASSERT(solstice && out_inst);
@@ -473,16 +475,27 @@ solstice_instantiate_geometry
goto error;
}
+ res = ssol_scene_attach_instance(solstice->scene, inst);
+ if(res != RES_OK) {
+ fprintf(stderr,
+ "Could not attach the instance against the Solstice Solver scene.\n");
+ goto error;
+ }
+ is_attached_to_scn = 1;
+
res = htable_object_set(&solstice->objects, &geom_id.i, &ssol_obj);
if(res != RES_OK) {
fprintf(stderr, "Could not register a Solstice Solver object.\n");
goto error;
}
+ is_registered = 1;
exit:
*out_inst = inst;
return res;
error:
+ if(is_attached_to_scn) SSOL(scene_detach_instance(solstice->scene, inst));
+ if(is_registered) htable_object_erase(&solstice->objects, &geom_id.i);
if(inst) SSOL(instance_ref_put(inst)), inst = NULL;
if(ssol_obj_new) SSOL(object_ref_put(ssol_obj_new));
goto exit;