commit 4054e678f54f7b7d41629261fafb6b2b19d72923
parent 2308c508f036e4771ebad8957bce86964da4af49
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 9 Jan 2017 17:00:26 +0100
Remove pivot's transform.
As an entity, a pivot has already a transform
Diffstat:
4 files changed, 19 insertions(+), 49 deletions(-)
diff --git a/src/parser/solparser.c b/src/parser/solparser.c
@@ -2509,7 +2509,7 @@ parse_pivot
const yaml_node_t* pivot,
struct solparser_pivot_id* out_isolpivot)
{
- enum { NORMAL, POINT, TARGET, TRANSFORM };
+ enum { NORMAL, POINT, TARGET };
struct solparser_pivot* solpivot = NULL;
size_t isolpivot = SIZE_MAX;
int mask = 0; /* Register the parsed attributes */
@@ -2563,10 +2563,6 @@ parse_pivot
} else if(!strcmp((char*)key->data.scalar.value, "target")) {
SETUP_MASK(TARGET, "target");
res = parse_target(parser, doc, val, solpivot);
- } else if(!strcmp((char*)key->data.scalar.value, "transform")) {
- SETUP_MASK(TRANSFORM, "transform");
- res = parse_transform
- (parser, doc, val, solpivot->translation, solpivot->rotation);
} else {
log_err(parser, key, "unknown pivot parameter `%s'.\n",
key->data.scalar.value);
diff --git a/src/parser/solparser_pivot.h b/src/parser/solparser_pivot.h
@@ -70,8 +70,6 @@ solparser_anchor_copy_and_release
struct solparser_pivot {
double point[3];
double normal[3];
- double rotation[3];
- double translation[3];
enum solparser_target_type target_type;
union {
double position[3]; /* World space position */
@@ -80,7 +78,7 @@ struct solparser_pivot {
} target;
};
-#define SOLPARSER_PIVOT_NULL__ { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, SOLPARSER_TARGET_TYPES_COUNT__, {0,0,0} };
+#define SOLPARSER_PIVOT_NULL__ { {0,0,0}, {0,0,0}, SOLPARSER_TARGET_TYPES_COUNT__, {0,0,0} };
static const struct solparser_pivot SOLPARSER_PIVOT_NULL = SOLPARSER_PIVOT_NULL__;
@@ -90,6 +88,7 @@ static INLINE void
solparser_pivot_init
(struct mem_allocator* allocator, struct solparser_pivot* pivot)
{
+ (void) allocator;
ASSERT(pivot);
*pivot = SOLPARSER_PIVOT_NULL;
}
diff --git a/src/solstice.c b/src/solstice.c
@@ -334,7 +334,7 @@ solstice_release(struct solstice* solstice)
clear_materials(&solstice->materials);
clear_objects(&solstice->objects);
clear_nodes(&solstice->roots);
- clear_nodes(&solstice->pivots);
+ /* don't clear pivots, as they are cleared from some root */
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);
diff --git a/src/solstice_entity.c b/src/solstice_entity.c
@@ -97,28 +97,14 @@ error:
static struct score_node*
setup_entity_pivot
(struct solstice* solstice,
- const struct solparser_entity* entity,
- struct score_node** atchmnt_node)
+ const struct solparser_entity* entity)
{
- /* TODO: remove pivot positionning? */
- struct score_node* entity_node = NULL;
struct score_node* pivot_node = NULL;
const struct solparser_pivot* parser_pivot = NULL;
struct sanim_pivot anim_pivot = SANIM_PIVOT_NULL;
struct sanim_tracking anim_tracking = SANIM_TRACKING_NULL;
res_T res = RES_OK;
- ASSERT(solstice && entity && atchmnt_node);
-
- /*
- * Each entity introduces a new coordinate system and each object or pivot
- * has some positionning in this system. This behaviour is implemented
- * through 2 levels of sanim_node.
- */
-
- res = score_node_empty_create(solstice->score, &entity_node);
- if(res != RES_OK) goto error;
- score_node_set_translation(entity_node, entity->translation);
- score_node_set_rotations(entity_node, entity->rotation);
+ ASSERT(solstice && entity);
parser_pivot = solparser_get_pivot(solstice->parser, entity->data.pivot);
res = score_node_pivot_create(solstice->score, &pivot_node);
@@ -155,35 +141,26 @@ setup_entity_pivot
res = score_node_pivot_setup(pivot_node, &anim_pivot, &anim_tracking);
if(res != RES_OK) goto error;
- score_node_set_translation(pivot_node, parser_pivot->translation);
- score_node_set_rotations(pivot_node, parser_pivot->rotation);
+ score_node_set_translation(pivot_node, entity->translation);
+ score_node_set_rotations(pivot_node, entity->rotation);
res = darray_nodes_push_back(&solstice->pivots, &pivot_node);
if(res != RES_OK) goto error;
- res = score_node_add_child(entity_node, pivot_node);
- if (res != RES_OK) goto error;
-
exit:
- *atchmnt_node = pivot_node;
- return entity_node;
+ return pivot_node;
error:
if(pivot_node) {
score_node_ref_put(pivot_node);
pivot_node = NULL;
}
- if(entity_node) {
- score_node_ref_put(entity_node);
- entity_node = NULL;
- }
goto exit;
}
static struct score_node*
setup_entity(struct solstice* solstice, const struct solparser_entity* entity)
{
- struct score_node* root_node = NULL;
- struct score_node* atchmnt_node = NULL;
+ struct score_node* entity_node = NULL;
struct score_node* tgt = NULL;
struct score_node* child_root = NULL;
size_t i;
@@ -192,18 +169,18 @@ setup_entity(struct solstice* solstice, const struct solparser_entity* entity)
switch(entity->type) {
case SOLPARSER_ENTITY_EMPTY:
- atchmnt_node = root_node = setup_entity_empty(solstice, entity);
+ entity_node = setup_entity_empty(solstice, entity);
break;
case SOLPARSER_ENTITY_GEOMETRY:
- atchmnt_node = root_node = setup_entity_geometry(solstice, entity);
+ entity_node = setup_entity_geometry(solstice, entity);
break;
case SOLPARSER_ENTITY_PIVOT:
- root_node = setup_entity_pivot(solstice, entity, &atchmnt_node);
+ entity_node = setup_entity_pivot(solstice, entity);
break;
default: FATAL("Unreachable code.\n"); break;
}
- if(!root_node || !atchmnt_node) {
+ if(!entity_node) {
fprintf(stderr, "Could not setup the entity node.\n");
goto error;
}
@@ -223,7 +200,7 @@ setup_entity(struct solstice* solstice, const struct solparser_entity* entity)
if(res != RES_OK) goto error;
score_node_set_translation(tgt, anchor->position);
- res = score_node_add_child(atchmnt_node, tgt);
+ res = score_node_add_child(entity_node, tgt);
if(res != RES_OK) goto error;
tgt = NULL;
@@ -240,7 +217,7 @@ setup_entity(struct solstice* solstice, const struct solparser_entity* entity)
child_root = setup_entity(solstice, child);
if(!child_root) goto error;
- res = score_node_add_child(atchmnt_node, child_root);
+ res = score_node_add_child(entity_node, child_root);
if(res != RES_OK) goto error;
score_node_ref_put(child_root);
@@ -248,14 +225,12 @@ setup_entity(struct solstice* solstice, const struct solparser_entity* entity)
}
exit:
- return root_node;
+ return entity_node;
error:
if(tgt) score_node_ref_put(tgt);
if(child_root) score_node_ref_put(child_root);
- if(atchmnt_node && atchmnt_node!=root_node) score_node_ref_put(atchmnt_node);
- if(root_node) score_node_ref_put(root_node);
- atchmnt_node = NULL;
- root_node = NULL;
+ if(entity_node) score_node_ref_put(entity_node);
+ entity_node = NULL;
goto exit;
}