summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-08-25 16:10:04 +0000
committerrodri <rgl@antares-labs.eu>2024-08-25 16:10:04 +0000
commit5ebbe977e9a25feff261b7c5fbbfe7af777dd681 (patch)
tree63ded2755cc1836339e512608a2eeb22c6053cc9
parent7dc2c0d02e6fb4fbdafb15bd66aa7d45768eb6ac (diff)
downloadlibgraphics-5ebbe977e9a25feff261b7c5fbbfe7af777dd681.tar.gz
libgraphics-5ebbe977e9a25feff261b7c5fbbfe7af777dd681.tar.bz2
libgraphics-5ebbe977e9a25feff261b7c5fbbfe7af777dd681.zip
scene: add a method to get an entity from a scene.
-rw-r--r--graphics.h1
-rw-r--r--scene.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/graphics.h b/graphics.h
index a2c42e2..61f4bf4 100644
--- a/graphics.h
+++ b/graphics.h
@@ -187,6 +187,7 @@ struct Scene
void (*addent)(Scene*, Entity*);
void (*delent)(Scene*, Entity*);
+ Entity *(*getent)(Scene*, char*);
};
/* shader params */
diff --git a/scene.c b/scene.c
index 7cf6868..8971c30 100644
--- a/scene.c
+++ b/scene.c
@@ -153,6 +153,17 @@ scene_delent(Scene *s, Entity *e)
s->nents--;
}
+static Entity *
+scene_getent(Scene *s, char *name)
+{
+ Entity *e;
+
+ for(e = s->ents.next; e != &s->ents; e = e->next)
+ if(strcmp(e->name, name) == 0)
+ return e;
+ return nil;
+}
+
Scene *
newscene(char *name)
{
@@ -165,6 +176,7 @@ newscene(char *name)
s->skybox = nil;
s->addent = scene_addent;
s->delent = scene_delent;
+ s->getent = scene_getent;
return s;
}