Cube  Check-in [da90479adf]

Overview
Comment:Remove dotprod
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: da90479adfbf8157d7f203d06b68ddc6b9d5d2667e54e6ac8b6380d96ce05048
User & Date: js on 2025-03-23 17:41:32
Other Links: manifest | tags
Context
2025-03-23
17:45
Remove fast_f2nat check-in: 51fb59fc93 user: js tags: trunk
17:41
Remove dotprod check-in: da90479adf user: js tags: trunk
14:49
Remove vadd/vsub/vmul/vdiv check-in: 0c8fc2f148 user: js tags: trunk
Changes

Modified src/cube.h from [38ea0aa1b6] to [96eff6d77d].

283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#define FONTH 64
#define PIXELTAB (VIRTW / 12)

#define PI (3.1415927f)
#define PI2 (2 * PI)

// simplistic vector ops
#define dotprod(u, v) ((u).x * (v).x + (u).y * (v).y + (u).z * (v).z)
#define vdist(d, v, e, s)                         \
	OFVector3D v = OFSubtractVectors3D(s, e); \
	float d = (float)sqrt(dotprod(v, v));
#define vreject(v, u, max)                                 \
	((v).x > (u).x + (max) || (v).x < (u).x - (max) || \
	    (v).y > (u).y + (max) || (v).y < (u).y - (max))
#define vlinterp(v, f, u, g)                   \
	{                                      \
		(v).x = (v).x * f + (u).x * g; \
		(v).y = (v).y * f + (u).y * g; \







<


|







283
284
285
286
287
288
289

290
291
292
293
294
295
296
297
298
299
#define FONTH 64
#define PIXELTAB (VIRTW / 12)

#define PI (3.1415927f)
#define PI2 (2 * PI)

// simplistic vector ops

#define vdist(d, v, e, s)                         \
	OFVector3D v = OFSubtractVectors3D(s, e); \
	float d = sqrtf(OFDotProductOfVectors3D(v, v));
#define vreject(v, u, max)                                 \
	((v).x > (u).x + (max) || (v).x < (u).x - (max) || \
	    (v).y > (u).y + (max) || (v).y < (u).y - (max))
#define vlinterp(v, f, u, g)                   \
	{                                      \
		(v).x = (v).x * f + (u).x * g; \
		(v).y = (v).y * f + (u).y * g; \

Modified src/weapon.m from [da3cdeb33a] to [d7a9ce79c2].

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
static bool
intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to)
{
	OFVector3D v = *to, w = d.origin;
	const OFVector3D *p;
	v = OFSubtractVectors3D(v, *from);
	w = OFSubtractVectors3D(w, *from);
	float c1 = dotprod(w, v);

	if (c1 <= 0)
		p = from;
	else {
		float c2 = dotprod(v, v);
		if (c2 <= c1)
			p = to;
		else {
			v = OFMultiplyVector3D(v, c1 / c2);
			v = OFAddVectors3D(v, *from);
			p = &v;
		}







|




|







86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
static bool
intersect(DynamicEntity *d, const OFVector3D *from, const OFVector3D *to)
{
	OFVector3D v = *to, w = d.origin;
	const OFVector3D *p;
	v = OFSubtractVectors3D(v, *from);
	w = OFSubtractVectors3D(w, *from);
	float c1 = OFDotProductOfVectors3D(w, v);

	if (c1 <= 0)
		p = from;
	else {
		float c2 = OFDotProductOfVectors3D(v, v);
		if (c2 <= c1)
			p = to;
		else {
			v = OFMultiplyVector3D(v, c1 / c2);
			v = OFAddVectors3D(v, *from);
			p = &v;
		}