diff options
author | rodri <rgl@antares-labs.eu> | 2024-08-25 16:10:04 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-08-25 16:10:04 +0000 |
commit | 5ebbe977e9a25feff261b7c5fbbfe7af777dd681 (patch) | |
tree | 63ded2755cc1836339e512608a2eeb22c6053cc9 | |
parent | 7dc2c0d02e6fb4fbdafb15bd66aa7d45768eb6ac (diff) | |
download | libgraphics-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.h | 1 | ||||
-rw-r--r-- | scene.c | 12 |
2 files changed, 13 insertions, 0 deletions
@@ -187,6 +187,7 @@ struct Scene void (*addent)(Scene*, Entity*); void (*delent)(Scene*, Entity*); + Entity *(*getent)(Scene*, char*); }; /* shader params */ @@ -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; } |