From 04d50b8bbe324fdb7a8a1e724fbc59c4050862f0 Mon Sep 17 00:00:00 2001 From: rodri Date: Sat, 13 Jul 2024 10:23:52 +0000 Subject: fix the geometry glitches when moving things around. it's possible for interactive programs to keep updating the geometry of the scene during rendering, which caused primitives to look deformed or shattered in the final image. to avoid this we take a snapshot of the current state of things (scene and camera), and render based on that copy. --- graphics.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'graphics.h') diff --git a/graphics.h b/graphics.h index fbeea2f..47a41cd 100644 --- a/graphics.h +++ b/graphics.h @@ -156,6 +156,7 @@ struct Model struct Entity { RFrame3; + char *name; Model *mdl; Entity *prev, *next; @@ -294,10 +295,10 @@ struct Camera }; /* camera */ +void reloadcamera(Camera*); void configcamera(Camera*, Viewport*, double, double, double, Projection); void placecamera(Camera*, Point3, Point3, Point3); void aimcamera(Camera*, Point3); -void reloadcamera(Camera*); void shootcamera(Camera*, Shadertab*); /* viewport */ @@ -326,10 +327,13 @@ void orthographic(Matrix3, double, double, double, double, double, double); /* scene */ int loadobjmodel(Model*, OBJ*); Model *newmodel(void); +Model *dupmodel(Model*); void delmodel(Model*); -Entity *newentity(Model*); +Entity *newentity(char*, Model*); +Entity *dupentity(Entity*); void delentity(Entity*); Scene *newscene(char*); +Scene *dupscene(Scene*); void delscene(Scene*); void clearscene(Scene*); @@ -339,6 +343,7 @@ Vertexattr *getvattr(Vertex*, char*); /* texture */ Texture *alloctexture(int, Memimage*); +Texture *duptexture(Texture*); void freetexture(Texture*); Color neartexsampler(Texture*, Point2); Color bilitexsampler(Texture*, Point2); @@ -353,6 +358,7 @@ double fmax(double, double); Point2 modulapt2(Point2, Point2); Point3 modulapt3(Point3, Point3); Memimage *rgb(ulong); +Memimage *dupmemimage(Memimage*); /* color */ Color srgb2linear(Color); -- cgit v1.2.3