summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-05-24 01:00:48 -0700
committerVito Caputo <vcaputo@pengaru.com>2018-05-24 01:06:12 -0700
commit635e2e8f2b0007a52121c0240d445d0fcf82a231 (patch)
tree2e776732e3bb84c253b25dee6734451be46eabd7
parentb021a32ac44f5d92fb8dc210d08510d1850a260c (diff)
libstage: add stage_node_[sg]et_origin()
A way to specify how the node's position relates to the node's AABB rather than always being centered. An origin of -1,-1 would place position at the bottom left corner of the node's AABB, and +1,+1 the top right corner.
-rw-r--r--src/stage.c16
-rw-r--r--src/stage.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/stage.c b/src/stage.c
index 7871f8f..35d6835 100644
--- a/src/stage.c
+++ b/src/stage.c
@@ -38,6 +38,7 @@ struct stage_node_t {
stage_cached_t cached;
aabb_t aabb; /* node coordinates expressed in the space of -1.0...1.0 */
v2f_t position; /* position of node, optionally used to move aabb as a whole */
+ v2f_t origin; /* origin of node, 0,0 being center of aabb (the default) this determines how position relates to aabb. -1...1 being aabb.min ... aabb.max */
float alpha; /* alpha for the texture when composited */
double angle; /* angle for the texture when composited */
unsigned active:1; /* node is active */
@@ -199,6 +200,21 @@ void stage_node_get_position(const stage_t *stage, const stage_node_t *node, v2f
}
+/* set the origin for a node */
+void stage_node_set_origin(const stage_t *stage, stage_node_t *node, v2f_t *origin)
+{
+ node->origin = *origin;
+}
+
+
+/* get the origin for a node */
+void stage_node_get_origin(const stage_t *stage, const stage_node_t *node, v2f_t *res_origin)
+{
+
+ *res_origin = node->origin;
+}
+
+
/* set a node to active (participates in rendering) */
void stage_node_set_active(const stage_t *stage, stage_node_t *node)
{
diff --git a/src/stage.h b/src/stage.h
index e16f917..edb35dd 100644
--- a/src/stage.h
+++ b/src/stage.h
@@ -51,6 +51,8 @@ void stage_node_set_aabb(const stage_t *stage, stage_node_t *node, const aabb_t
void stage_node_get_aabb(const stage_t *stage, const stage_node_t *node, aabb_t *res_aabb);
void stage_node_set_position(const stage_t *stage, stage_node_t *node, v2f_t *position);
void stage_node_get_position(const stage_t *stage, const stage_node_t *node, v2f_t *res_position);
+void stage_node_set_origin(const stage_t *stage, stage_node_t *node, v2f_t *origin);
+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);
void stage_node_set_inactive(const stage_t *stage, stage_node_t *node);
void stage_node_set_locked(const stage_t *stage, stage_node_t *node);
© All Rights Reserved