diff options
-rw-r--r-- | src/stage.c | 15 | ||||
-rw-r--r-- | src/stage.h | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/stage.c b/src/stage.c index 70c5424..280536a 100644 --- a/src/stage.c +++ b/src/stage.c @@ -43,6 +43,7 @@ struct stage_node_t { double angle; /* angle for the texture when composited */ unsigned active:1; /* node is active */ unsigned locked:1; /* node is locked */ + unsigned statik:1; /* node is static */ stage_render_func_t render; /* render object into a texture */ stage_free_func_t free; /* free object */ @@ -229,6 +230,12 @@ void stage_node_set_locked(const stage_t *stage, stage_node_t *node, int locked) } +/* set a node to static (isn't influenced by external position/origin/aabb changes, solely its own positin/origin/aabb) */ +void stage_node_set_static(const stage_t *stage, stage_node_t *node, int statik) +{ + /* I deliberately spelled statik to avoid language keyword collision */ + node->statik = statik; +} /* set a node's layer */ @@ -371,9 +378,11 @@ static void node_to_rect(const stage_t *stage, const stage_node_t *node, const S res_rect->x = stage_rect->x + floorf((float)stage_rect->w * .5f); res_rect->y = stage_rect->y + floorf((float)stage_rect->h * .5f); - /* apply stage->position (scaled relative to stage_rect) */ - res_rect->x += floorf(stage->position.x * .5f * (float)stage_rect->w); - res_rect->y += -floorf(stage->position.y * .5f * (float)stage_rect->h); + if (!node->statik) { + /* apply stage->position (scaled relative to stage_rect) */ + res_rect->x += floorf(stage->position.x * .5f * (float)stage_rect->w); + res_rect->y += -floorf(stage->position.y * .5f * (float)stage_rect->h); + } /* apply node->position (scaled relative to stage_rect) */ res_rect->x += floorf(node->position.x * .5f * (float)stage_rect->w); diff --git a/src/stage.h b/src/stage.h index f5d38e6..f157653 100644 --- a/src/stage.h +++ b/src/stage.h @@ -56,6 +56,7 @@ void stage_node_set_origin(const stage_t *stage, stage_node_t *node, v2f_t *orig void stage_node_get_origin(const stage_t *stage, const stage_node_t *node, v2f_t *res_origin); void stage_node_set_active(const stage_t *stage, stage_node_t *node, int active); void stage_node_set_locked(const stage_t *stage, stage_node_t *node, int locked); +void stage_node_set_static(const stage_t *stage, stage_node_t *node, int stationary); void stage_node_set_layer(stage_t *stage, stage_node_t *node, int layer); void stage_node_set_angle(const stage_t *stage, stage_node_t *node, double angle); void stage_node_get_angle(const stage_t *stage, stage_node_t *node, double *res_angle); |