Use OFColor instead of abusing OFVector3D

FossilOrigin-Name: e258bfb55971eda526191cd09458ce6be1b02bc147eafc7d58259bb7c9647028
This commit is contained in:
Jonathan Schleifer 2025-03-22 21:29:47 +00:00
parent 6bd7c25ec3
commit fd2b1dddf0
3 changed files with 16 additions and 10 deletions

View file

@ -12,7 +12,7 @@ OF_ASSUME_NONNULL_BEGIN
+ (instancetype)md2; + (instancetype)md2;
- (bool)loadWithIRI:(OFIRI *)IRI; - (bool)loadWithIRI:(OFIRI *)IRI;
- (void)renderWithLight:(OFVector3D)light - (void)renderWithLight:(OFColor *)light
frame:(int)frame frame:(int)frame
range:(int)range range:(int)range
position:(OFVector3D)position position:(OFVector3D)position

View file

@ -138,7 +138,7 @@ snap(int sn, float f)
} }
} }
- (void)renderWithLight:(OFVector3D)light - (void)renderWithLight:(OFColor *)light
frame:(int)frame frame:(int)frame
range:(int)range range:(int)range
position:(OFVector3D)position position:(OFVector3D)position
@ -158,7 +158,9 @@ snap(int sn, float f)
glRotatef(yaw + 180, 0, -1, 0); glRotatef(yaw + 180, 0, -1, 0);
glRotatef(pitch, 0, 0, 1); glRotatef(pitch, 0, 0, 1);
glColor3fv((float *)&light); float red, green, blue;
[light getRed:&red green:&green blue:&blue alpha:NULL];
glColor3f(red, green, blue);
if (_displaylist && frame == 0 && range == 1) { if (_displaylist && frame == 0 && range == 1) {
glCallList(_displaylist); glCallList(_displaylist);

View file

@ -105,21 +105,25 @@ rendermodel(OFString *mdl, int frame, int range, int tex, float rad,
int ix = (int)position.x; int ix = (int)position.x;
int iy = (int)position.z; int iy = (int)position.z;
OFVector3D light = OFMakeVector3D(1, 1, 1); OFColor *light = [OFColor colorWithRed:1 green:1 blue:1 alpha:1];
if (!OUTBORD(ix, iy)) { if (!OUTBORD(ix, iy)) {
struct sqr *s = S(ix, iy); struct sqr *s = S(ix, iy);
float ll = 256.0f; // 0.96f; float ll = 256.0f; // 0.96f;
float of = 0.0f; // 0.1f; float of = 0.0f; // 0.1f;
light.x = s->r / ll + of; light = [OFColor colorWithRed:s->r / ll + of
light.y = s->g / ll + of; green:s->g / ll + of
light.z = s->b / ll + of; blue:s->b / ll + of
alpha:1];
} }
if (teammate) { if (teammate) {
light.x *= 0.6f; float red, green, blue;
light.y *= 0.7f; [light getRed:&red green:&green blue:&blue alpha:NULL];
light.z *= 1.2f; light = [OFColor colorWithRed:red * 0.6f
green:green * 0.7f
blue:blue * 1.2f
alpha:1];
} }
[m renderWithLight:light [m renderWithLight:light