shithub: 3dee

Download patch

ref: 6be6567db5798c155fe53167d4ea0b143ca8faa7
parent: b96ad12087f158ec5449ebd7e8562193094e0936
author: rodri <rgl@antares-labs.eu>
date: Sat Feb 28 13:09:26 EST 2026

solar: use the planets's rframes to scale them correctly

instead of setting up a scaling matrix in the vertex shader
just scale the rframes once during init and the model2world(2)
will take care of it.

i should've done this a long time ago. this is exactly what
rframes are for.

--- a/solar.c
+++ b/solar.c
@@ -310,6 +310,9 @@
 	msel = newmodel();
 	esel = newentity("selection", msel);
 	esel->RFrame3 = e->RFrame3;
+	esel->bx = mulpt3(esel->bx, 0.8);
+	esel->by = mulpt3(esel->by, 0.8);
+	esel->bz = mulpt3(esel->bz, 0.8);
 
 	infobox = mkplanetinfobox(p, Rpt(subpt(viewr.max, Pt(500,250)), viewr.max));
 
@@ -319,8 +322,6 @@
 		aabb.min = minpt3(aabb.min, *pt);
 		aabb.max = maxpt3(aabb.max, *pt);
 	}
-	aabb.min = mulpt3(aabb.min, p->scale*0.8);
-	aabb.max = mulpt3(aabb.max, p->scale*0.8);
 	aabb.min.w = aabb.max.w = 1;
 
 	l = mkprim(PLine);
@@ -477,19 +478,10 @@
 	Planet *p;
 
 	p = getplanet(sp->entity->name);
-
 	if(p != nil){
-		Matrix3 S = {
-			p->scale, 0, 0, 0,
-			0, p->scale, 0, 0,
-			0, 0, p->scale, 0,
-			0, 0, 0, 1,
-		};
-		sp->v->p = xform3(sp->v->p, S);
 		sp->v->mtl = p->mtl;
 		sp->v->c = p->mtl->diffuse;
 	}
-
 	return world2clip(sp->camera, model2world(sp->entity, sp->v->p));
 }
 
@@ -932,9 +924,11 @@
 				planets[i].mtl = &model->materials[j];
 		if(i == 0){
 			subject->p = Pt3(0,0,0,1);
-			continue;
 		}else if(museummode)
 			subject->p.x = planets[i-1].body->p.x + 1.5*planets[i-1].scale + planets[i].scale;
+		subject->bx = mulpt3(subject->bx, planets[i].scale);
+		subject->by = mulpt3(subject->by, planets[i].scale);
+		subject->bz = mulpt3(subject->bz, planets[i].scale);
 	}
 	tmnow(&date, nil);
 	snprint(datestr, sizeof datestr, "%τ", tmfmt(&date, datefmt));
--