shithub: libgraphics

Download patch

ref: 39d66c58951286ec82b8ee283ad0dd42c479bbd4
parent: 596647fb035740e178293a37faef8b6af5f6e428
author: rodri <rgl@antares-labs.eu>
date: Mon Apr 7 08:43:16 EDT 2025

get rid of job scene field and copy the skybox correctly when shooting

--- a/camera.c
+++ b/camera.c
@@ -248,8 +248,7 @@
 	job->fb = fbctl->getbb(fbctl);
 	job->camera = _emalloc(sizeof *c);
 	*job->camera = *c;
-	job->scene = dupscene(c->scene);	/* take a snapshot */
-	job->camera->scene = job->scene;
+	job->camera->scene = dupscene(c->scene);	/* take a snapshot */
 	job->shaders = s;
 	job->donec = chancreate(sizeof(void*), 0);
 
@@ -256,7 +255,7 @@
 	t0 = nanosec();
 	sendp(c->rctl->jobq, job);
 	recvp(job->donec);
-	delscene(job->scene);			/* destroy the snapshot */
+	delscene(job->camera->scene);			/* destroy the snapshot */
 	/*
 	 * if the scene has a skybox, do another render pass,
 	 * filling in the pixels left untouched.
@@ -270,12 +269,12 @@
 		job->camera->cullmode = CullNone;
 		job->camera->fov = 90*DEG;
 		reloadcamera(job->camera);
-		job->scene = dupscene(skyboxscene);
-		job->camera->scene = job->scene;
+		job->camera->scene = dupscene(skyboxscene);
+		job->camera->scene->skybox = dupcubemap(c->scene->skybox);
 		job->shaders = &skyboxshader;
 		sendp(c->rctl->jobq, job);
 		recvp(job->donec);
-		delscene(job->scene);
+		delscene(job->camera->scene);
 	}
 	t1 = nanosec();
 	fbctl->swap(fbctl);
--- a/graphics.h
+++ b/graphics.h
@@ -262,7 +262,6 @@
 	Renderer *rctl;
 	Framebuf *fb;
 	Camera *camera;
-	Scene *scene;
 	Shadertab *shaders;
 	Channel *donec;
 	Rectangle *cliprects;	/* one per rasterizer */
--- a/render.c
+++ b/render.c
@@ -781,7 +781,7 @@
 		time = nanosec();
 		if(job->rctl->doprof) job->times.R.t0 = time;
 		job->id = lastid++;
-		sc = job->scene;
+		sc = job->camera->scene;
 		if(sc->nents < 1){
 			nbsend(job->donec, nil);
 			continue;