Cube  Check-in [e258bfb559]

Overview
Comment:Use OFColor instead of abusing OFVector3D
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e258bfb55971eda526191cd09458ce6be1b02bc147eafc7d58259bb7c9647028
User & Date: js on 2025-03-22 21:29:47
Other Links: manifest | tags
Context
2025-03-22
23:10
Clean up DynamicEntity check-in: b787ad5a04 user: js tags: trunk
21:29
Use OFColor instead of abusing OFVector3D check-in: e258bfb559 user: js tags: trunk
2025-03-20
23:02
Fix -Wgnu-folding-constant check-in: e79356d2a6 user: js tags: trunk
Changes

Modified src/MD2.h from [abc59220a9] to [56302384a5].

8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22







-
+







@property (nonatomic) MapModelInfo *mmi;
@property (copy, nonatomic) OFString *loadname;
@property (nonatomic) int mdlnum;
@property (nonatomic) bool loaded;

+ (instancetype)md2;
- (bool)loadWithIRI:(OFIRI *)IRI;
- (void)renderWithLight:(OFVector3D)light
- (void)renderWithLight:(OFColor *)light
                  frame:(int)frame
                  range:(int)range
               position:(OFVector3D)position
                    yaw:(float)yaw
                  pitch:(float)pitch
                  scale:(float)scale
                  speed:(float)speed

Modified src/MD2.m from [9f4a91ba94] to [92d0f266d8].

134
135
136
137
138
139
140
141

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160


161

162
163
164
165
166
167
168
134
135
136
137
138
139
140

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

163
164
165
166
167
168
169
170







-
+



















+
+
-
+







		v->x = (snap(sn, cv[0] * cf->scale[0]) + cf->translate[0]) / sc;
		v->y =
		    -(snap(sn, cv[1] * cf->scale[1]) + cf->translate[1]) / sc;
		v->z = (snap(sn, cv[2] * cf->scale[2]) + cf->translate[2]) / sc;
	}
}

- (void)renderWithLight:(OFVector3D)light
- (void)renderWithLight:(OFColor *)light
                  frame:(int)frame
                  range:(int)range
               position:(OFVector3D)position
                    yaw:(float)yaw
                  pitch:(float)pitch
                  scale:(float)sc
                  speed:(float)speed
                   snap:(int)sn
               basetime:(int)basetime
{
	loopi(range) if (!_mverts[frame + i])[self scaleWithFrame:frame + i
	                                                    scale:sc
	                                                     snap:sn];

	glPushMatrix();
	glTranslatef(position.x, position.y, position.z);
	glRotatef(yaw + 180, 0, -1, 0);
	glRotatef(pitch, 0, 0, 1);

	float red, green, blue;
	[light getRed:&red green:&green blue:&blue alpha:NULL];
	glColor3fv((float *)&light);
	glColor3f(red, green, blue);

	if (_displaylist && frame == 0 && range == 1) {
		glCallList(_displaylist);
		xtraverts += _displaylistverts;
	} else {
		if (frame == 0 && range == 1) {
			static int displaylistn = 10;

Modified src/rendermd2.m from [315b2acb14] to [820ea372aa].

101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116




117
118
119


120
121
122




123
124
125
126
127
128
129
101
102
103
104
105
106
107

108
109
110
111
112
113



114
115
116
117
118
119
120
121
122



123
124
125
126
127
128
129
130
131
132
133







-
+





-
-
-
+
+
+
+



+
+
-
-
-
+
+
+
+








	int xs, ys;
	glBindTexture(GL_TEXTURE_2D,
	    tex ? lookuptexture(tex, &xs, &ys) : FIRSTMDL + m.mdlnum);

	int ix = (int)position.x;
	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)) {
		struct sqr *s = S(ix, iy);
		float ll = 256.0f; // 0.96f;
		float of = 0.0f;   // 0.1f;
		light.x = s->r / ll + of;
		light.y = s->g / ll + of;
		light.z = s->b / ll + of;
		light = [OFColor colorWithRed:s->r / ll + of
		                        green:s->g / ll + of
		                         blue:s->b / ll + of
		                        alpha:1];
	}

	if (teammate) {
		float red, green, blue;
		[light getRed:&red green:&green blue:&blue alpha:NULL];
		light.x *= 0.6f;
		light.y *= 0.7f;
		light.z *= 1.2f;
		light = [OFColor colorWithRed:red * 0.6f
		                        green:green * 0.7f
		                         blue:blue * 1.2f
		                        alpha:1];
	}

	[m renderWithLight:light
	             frame:frame
	             range:range
	          position:position
	               yaw:yaw