Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mpr.hpp
Go to the documentation of this file.
1 // This code is based off the Minkowski Portal Refinement algorithm by Gary Snethen in XenoCollide & Game Programming Gems 7.
2 #pragma once
3 
4 #include "inexor/shared/geom.hpp"
8 #include "inexor/shared/ents.hpp"
9 
10 namespace mpr
11 {
12  struct CubePlanes
13  {
14  const clipplanes &p;
15 
16  CubePlanes(const clipplanes &p) : p(p) {}
17 
18  vec center() const { return p.o; }
19 
20  vec supportpoint(const vec &n) const
21  {
22  int besti = 7;
23  float bestd = n.dot(p.v[7]);
24  loopi(7)
25  {
26  float d = n.dot(p.v[i]);
27  if(d > bestd) { besti = i; bestd = d; }
28  }
29  return p.v[besti];
30  }
31  };
32 
33  struct SolidCube
34  {
35  vec o;
36  int size;
37 
38  SolidCube(float x, float y, float z, int size) : o(x, y, z), size(size) {}
39  SolidCube(const vec &o, int size) : o(o), size(size) {}
40  SolidCube(const ivec &o, int size) : o(o), size(size) {}
41 
42  vec center() const { return vec(o).add(size/2); }
43 
44  vec supportpoint(const vec &n) const
45  {
46  vec p(o);
47  if(n.x > 0) p.x += size;
48  if(n.y > 0) p.y += size;
49  if(n.z > 0) p.z += size;
50  return p;
51  }
52  };
53 
54  struct Ent
55  {
57 
58  Ent(physent *ent) : ent(ent) {}
59 
60  vec center() const { return vec(ent->o.x, ent->o.y, ent->o.z + (ent->aboveeye - ent->eyeheight)/2); }
61  };
62 
63  struct EntOBB : Ent
64  {
66  float zmargin;
67 
68  EntOBB(physent *ent, float zmargin = 0) : Ent(ent), zmargin(zmargin)
69  {
70  orient.setyaw(ent->yaw*RAD);
71  }
72 
73  vec center() const { return vec(ent->o.x, ent->o.y, ent->o.z + (ent->aboveeye - ent->eyeheight - zmargin)/2); }
74 
75  vec contactface(const vec &wn, const vec &wdir) const
76  {
78  dir = orient.transform(wdir),
79  an(fabs(n.x), fabs(n.y), dir.z ? fabs(n.z) : 0),
80  fn(0, 0, 0);
81  if(an.x > an.y)
82  {
83  if(an.x > an.z) fn.x = n.x*dir.x < 0 ? (n.x > 0 ? 1 : -1) : 0;
84  else if(an.z > 0) fn.z = n.z*dir.z < 0 ? (n.z > 0 ? 1 : -1) : 0;
85  }
86  else if(an.y > an.z) fn.y = n.y*dir.y < 0 ? (n.y > 0 ? 1 : -1) : 0;
87  else if(an.z > 0) fn.z = n.z*dir.z < 0 ? (n.z > 0 ? 1 : -1) : 0;
88  return orient.transposedtransform(fn);
89  }
90 
91  vec localsupportpoint(const vec &ln) const
92  {
93  return vec(ln.x > 0 ? ent->xradius : -ent->xradius,
94  ln.y > 0 ? ent->yradius : -ent->yradius,
95  ln.z > 0 ? ent->aboveeye : -ent->eyeheight - zmargin);
96  }
97 
98  vec supportpoint(const vec &n) const
99  {
101  }
102 
103  float supportcoordneg(float a, float b, float c) const
104  {
105  return localsupportpoint(vec(-a, -b, -c)).dot(vec(a, b, c));
106  }
107  float supportcoord(float a, float b, float c) const
108  {
109  return localsupportpoint(vec(a, b, c)).dot(vec(a, b, c));
110  }
111 
112  float left() const { return supportcoordneg(orient.a.x, orient.b.x, orient.c.x) + ent->o.x; }
113  float right() const { return supportcoord(orient.a.x, orient.b.x, orient.c.x) + ent->o.x; }
114  float back() const { return supportcoordneg(orient.a.y, orient.b.y, orient.c.y) + ent->o.y; }
115  float front() const { return supportcoord(orient.a.y, orient.b.y, orient.c.y) + ent->o.y; }
116  float bottom() const { return ent->o.z - ent->eyeheight - zmargin; }
117  float top() const { return ent->o.z + ent->aboveeye; }
118  };
119 
120  struct EntFuzzy : Ent
121  {
122  EntFuzzy(physent *ent) : Ent(ent) {}
123 
124  float left() const { return ent->o.x - ent->radius; }
125  float right() const { return ent->o.x + ent->radius; }
126  float back() const { return ent->o.y - ent->radius; }
127  float front() const { return ent->o.y + ent->radius; }
128  float bottom() const { return ent->o.z - ent->eyeheight; }
129  float top() const { return ent->o.z + ent->aboveeye; }
130  };
131 
133  {
134  float zmargin;
135 
137 
138  vec center() const { return vec(ent->o.x, ent->o.y, ent->o.z + (ent->aboveeye - ent->eyeheight - zmargin)/2); }
139 
140  float bottom() const { return ent->o.z - ent->eyeheight - zmargin; }
141 
142  vec contactface(const vec &n, const vec &dir) const
143  {
144  float dxy = n.dot2(n)/(ent->radius*ent->radius), dz = n.z*n.z*4/(ent->aboveeye + ent->eyeheight + zmargin);
145  vec fn(0, 0, 0);
146  if(dz > dxy && dir.z) fn.z = n.z*dir.z < 0 ? (n.z > 0 ? 1 : -1) : 0;
147  else if(n.dot2(dir) < 0)
148  {
149  fn.x = n.x;
150  fn.y = n.y;
151  fn.normalize();
152  }
153  return fn;
154  }
155 
156  vec supportpoint(const vec &n) const
157  {
158  vec p(ent->o);
159  if(n.z > 0) p.z += ent->aboveeye;
160  else p.z -= ent->eyeheight + zmargin;
161  if(n.x || n.y)
162  {
163  float r = ent->radius / n.magnitude2();
164  p.x += n.x*r;
165  p.y += n.y*r;
166  }
167  return p;
168  }
169  };
170 
172  {
174 
175  vec supportpoint(const vec &n) const
176  {
177  vec p(ent->o);
178  if(n.z > 0) p.z += ent->aboveeye - ent->radius;
179  else p.z -= ent->eyeheight - ent->radius;
180  p.add(vec(n).mul(ent->radius / n.magnitude()));
181  return p;
182  }
183  };
184 
186  {
188 
189  vec supportpoint(const vec &dir) const
190  {
191  vec p(ent->o), n = vec(dir).normalize();
192  p.x += ent->radius*n.x;
193  p.y += ent->radius*n.y;
194  p.z += (ent->aboveeye + ent->eyeheight)/2*(1 + n.z) - ent->eyeheight;
195  return p;
196  }
197  };
198 
199  struct Model
200  {
203 
204  Model(const vec &ent, const vec &center, const vec &radius, int yaw) : o(ent), radius(radius)
205  {
206  orient.setyaw(yaw*RAD);
207  o.add(orient.transposedtransform(center));
208  }
209 
210  vec center() const { return o; }
211  };
212 
213  struct ModelOBB : Model
214  {
215  ModelOBB(const vec &ent, const vec &center, const vec &radius, int yaw) :
216  Model(ent, center, radius, yaw)
217  {}
218 
219  vec contactface(const vec &wn, const vec &wdir) const
220  {
221  vec n = orient.transform(wn).div(radius), dir = orient.transform(wdir),
222  an(fabs(n.x), fabs(n.y), dir.z ? fabs(n.z) : 0),
223  fn(0, 0, 0);
224  if(an.x > an.y)
225  {
226  if(an.x > an.z) fn.x = n.x*dir.x < 0 ? (n.x > 0 ? 1 : -1) : 0;
227  else if(an.z > 0) fn.z = n.z*dir.z < 0 ? (n.z > 0 ? 1 : -1) : 0;
228  }
229  else if(an.y > an.z) fn.y = n.y*dir.y < 0 ? (n.y > 0 ? 1 : -1) : 0;
230  else if(an.z > 0) fn.z = n.z*dir.z < 0 ? (n.z > 0 ? 1 : -1) : 0;
231  return orient.transposedtransform(fn);
232  }
233 
234  vec supportpoint(const vec &n) const
235  {
236  vec ln = orient.transform(n), p(0, 0, 0);
237  if(ln.x > 0) p.x += radius.x;
238  else p.x -= radius.x;
239  if(ln.y > 0) p.y += radius.y;
240  else p.y -= radius.y;
241  if(ln.z > 0) p.z += radius.z;
242  else p.z -= radius.z;
243  return orient.transposedtransform(p).add(o);
244  }
245  };
246 
248  {
249  ModelEllipse(const vec &ent, const vec &center, const vec &radius, int yaw) :
250  Model(ent, center, radius, yaw)
251  {}
252 
253  vec contactface(const vec &wn, const vec &wdir) const
254  {
255  vec n = orient.transform(wn).div(radius), dir = orient.transform(wdir);
256  float dxy = n.dot2(n), dz = n.z*n.z;
257  vec fn(0, 0, 0);
258  if(dz > dxy && dir.z) fn.z = n.z*dir.z < 0 ? (n.z > 0 ? 1 : -1) : 0;
259  else if(n.dot2(dir) < 0)
260  {
261  fn.x = n.x*radius.y;
262  fn.y = n.y*radius.x;
263  fn.normalize();
264  }
265  return orient.transposedtransform(fn);
266  }
267 
268  vec supportpoint(const vec &n) const
269  {
270  vec ln = orient.transform(n), p(0, 0, 0);
271  if(ln.z > 0) p.z += radius.z;
272  else p.z -= radius.z;
273  if(ln.x || ln.y)
274  {
275  float r = ln.magnitude2();
276  p.x += ln.x*radius.x/r;
277  p.y += ln.y*radius.y/r;
278  }
279  return orient.transposedtransform(p).add(o);
280  }
281  };
282 
283  const float boundarytolerance = 1e-3f;
284 
285  template<class T, class U>
286  bool collide(const T &p1, const U &p2)
287  {
288  // v0 = center of Minkowski difference
289  vec v0 = p2.center().sub(p1.center());
290  if(v0.iszero()) return true; // v0 and origin overlap ==> hit
291 
292  // v1 = support in direction of origin
293  vec n = vec(v0).neg();
294  vec v1 = p2.supportpoint(n).sub(p1.supportpoint(vec(n).neg()));
295  if(v1.dot(n) <= 0) return false; // origin outside v1 support plane ==> miss
296 
297  // v2 = support perpendicular to plane containing origin, v0 and v1
298  n.cross(v1, v0);
299  if(n.iszero()) return true; // v0, v1 and origin colinear (and origin inside v1 support plane) == > hit
300  vec v2 = p2.supportpoint(n).sub(p1.supportpoint(vec(n).neg()));
301  if(v2.dot(n) <= 0) return false; // origin outside v2 support plane ==> miss
302 
303  // v3 = support perpendicular to plane containing v0, v1 and v2
304  n.cross(v0, v1, v2);
305 
306  // If the origin is on the - side of the plane, reverse the direction of the plane
307  if(n.dot(v0) > 0)
308  {
309  swap(v1, v2);
310  n.neg();
311  }
312 
314  // Phase One: Find a valid portal
315 
316  loopi(100)
317  {
318  // Obtain the next support point
319  vec v3 = p2.supportpoint(n).sub(p1.supportpoint(vec(n).neg()));
320  if(v3.dot(n) <= 0) return false; // origin outside v3 support plane ==> miss
321 
322  // If origin is outside (v1,v0,v3), then portal is invalid -- eliminate v2 and find new support outside face
323  vec v3xv0;
324  v3xv0.cross(v3, v0);
325  if(v1.dot(v3xv0) < 0)
326  {
327  v2 = v3;
328  n.cross(v0, v1, v3);
329  continue;
330  }
331 
332  // If origin is outside (v3,v0,v2), then portal is invalid -- eliminate v1 and find new support outside face
333  if(v2.dot(v3xv0) > 0)
334  {
335  v1 = v3;
336  n.cross(v0, v3, v2);
337  continue;
338  }
339 
341  // Phase Two: Refine the portal
342 
343  for(int j = 0;; j++)
344  {
345  // Compute outward facing normal of the portal
346  n.cross(v1, v2, v3);
347 
348  // If the origin is inside the portal, we have a hit
349  if(n.dot(v1) >= 0) return true;
350 
351  n.normalize();
352 
353  // Find the support point in the direction of the portal's normal
354  vec v4 = p2.supportpoint(n).sub(p1.supportpoint(vec(n).neg()));
355 
356  // If the origin is outside the support plane or the boundary is thin enough, we have a miss
357  if(v4.dot(n) <= 0 || vec(v4).sub(v3).dot(n) <= boundarytolerance || j > 100) return false;
358 
359  // Test origin against the three planes that separate the new portal candidates: (v1,v4,v0) (v2,v4,v0) (v3,v4,v0)
360  // Note: We're taking advantage of the triple product identities here as an optimization
361  // (v1 % v4) * v0 == v1 * (v4 % v0) > 0 if origin inside (v1, v4, v0)
362  // (v2 % v4) * v0 == v2 * (v4 % v0) > 0 if origin inside (v2, v4, v0)
363  // (v3 % v4) * v0 == v3 * (v4 % v0) > 0 if origin inside (v3, v4, v0)
364  vec v4xv0;
365  v4xv0.cross(v4, v0);
366  if(v1.dot(v4xv0) > 0)
367  {
368  if(v2.dot(v4xv0) > 0) v1 = v4; // Inside v1 & inside v2 ==> eliminate v1
369  else v3 = v4; // Inside v1 & outside v2 ==> eliminate v3
370  }
371  else
372  {
373  if(v3.dot(v4xv0) > 0) v2 = v4; // Outside v1 & inside v3 ==> eliminate v2
374  else v1 = v4; // Outside v1 & outside v3 ==> eliminate v1
375  }
376  }
377  }
378  return false;
379  }
380 
381  template<class T, class U>
382  bool collide(const T &p1, const U &p2, vec *contactnormal, vec *contactpoint1, vec *contactpoint2)
383  {
384  // v0 = center of Minkowski sum
385  vec v01 = p1.center();
386  vec v02 = p2.center();
387  vec v0 = vec(v02).sub(v01);
388 
389  // Avoid case where centers overlap -- any direction is fine in this case
390  if(v0.iszero()) v0 = vec(0, 0, 1e-5f);
391 
392  // v1 = support in direction of origin
393  vec n = vec(v0).neg();
394  vec v11 = p1.supportpoint(vec(n).neg());
395  vec v12 = p2.supportpoint(n);
396  vec v1 = vec(v12).sub(v11);
397  if(v1.dot(n) <= 0)
398  {
399  if(contactnormal) *contactnormal = n;
400  return false;
401  }
402 
403  // v2 - support perpendicular to v1,v0
404  n.cross(v1, v0);
405  if(n.iszero())
406  {
407  n = vec(v1).sub(v0);
408  n.normalize();
409  if(contactnormal) *contactnormal = n;
410  if(contactpoint1) *contactpoint1 = v11;
411  if(contactpoint2) *contactpoint2 = v12;
412  return true;
413  }
414  vec v21 = p1.supportpoint(vec(n).neg());
415  vec v22 = p2.supportpoint(n);
416  vec v2 = vec(v22).sub(v21);
417  if(v2.dot(n) <= 0)
418  {
419  if(contactnormal) *contactnormal = n;
420  return false;
421  }
422 
423  // Determine whether origin is on + or - side of plane (v1,v0,v2)
424  n.cross(v0, v1, v2);
425  ASSERT( !n.iszero() );
426  // If the origin is on the - side of the plane, reverse the direction of the plane
427  if(n.dot(v0) > 0)
428  {
429  swap(v1, v2);
430  swap(v11, v21);
431  swap(v12, v22);
432  n.neg();
433  }
434 
436  // Phase One: Identify a portal
437 
438  loopi(100)
439  {
440  // Obtain the support point in a direction perpendicular to the existing plane
441  // Note: This point is guaranteed to lie off the plane
442  vec v31 = p1.supportpoint(vec(n).neg());
443  vec v32 = p2.supportpoint(n);
444  vec v3 = vec(v32).sub(v31);
445  if(v3.dot(n) <= 0)
446  {
447  if(contactnormal) *contactnormal = n;
448  return false;
449  }
450 
451  // If origin is outside (v1,v0,v3), then eliminate v2 and loop
452  vec v3xv0;
453  v3xv0.cross(v3, v0);
454  if(v1.dot(v3xv0) < 0)
455  {
456  v2 = v3;
457  v21 = v31;
458  v22 = v32;
459  n.cross(v0, v1, v3);
460  continue;
461  }
462 
463  // If origin is outside (v3,v0,v2), then eliminate v1 and loop
464  if(v2.dot(v3xv0) > 0)
465  {
466  v1 = v3;
467  v11 = v31;
468  v12 = v32;
469  n.cross(v0, v3, v2);
470  continue;
471  }
472 
473  bool hit = false;
474 
476  // Phase Two: Refine the portal
477 
478  // We are now inside of a wedge...
479  for(int j = 0;; j++)
480  {
481  // Compute normal of the wedge face
482  n.cross(v1, v2, v3);
483 
484  // Can this happen??? Can it be handled more cleanly?
485  if(n.iszero())
486  {
487  ASSERT(0);
488  return true;
489  }
490 
491  n.normalize();
492 
493  // If the origin is inside the wedge, we have a hit
494  if(n.dot(v1) >= 0 && !hit)
495  {
496  if(contactnormal) *contactnormal = n;
497 
498  // Compute the barycentric coordinates of the origin
499  if(contactpoint1 || contactpoint2)
500  {
501  float b0 = v3.scalartriple(v1, v2),
502  b1 = v0.scalartriple(v3, v2),
503  b2 = v3.scalartriple(v0, v1),
504  b3 = v0.scalartriple(v2, v1),
505  sum = b0 + b1 + b2 + b3;
506  if(sum <= 0)
507  {
508  b0 = 0;
509  b1 = n.scalartriple(v2, v3);
510  b2 = n.scalartriple(v3, v1);
511  b3 = n.scalartriple(v1, v2);
512  sum = b1 + b2 + b3;
513  }
514  if(contactpoint1)
515  *contactpoint1 = (vec(v01).mul(b0).add(vec(v11).mul(b1)).add(vec(v21).mul(b2)).add(vec(v31).mul(b3))).mul(1.0f/sum);
516  if(contactpoint2)
517  *contactpoint2 = (vec(v02).mul(b0).add(vec(v12).mul(b1)).add(vec(v22).mul(b2)).add(vec(v32).mul(b3))).mul(1.0f/sum);
518  }
519 
520  // HIT!!!
521  hit = true;
522  }
523 
524  // Find the support point in the direction of the wedge face
525  vec v41 = p1.supportpoint(vec(n).neg());
526  vec v42 = p2.supportpoint(n);
527  vec v4 = vec(v42).sub(v41);
528 
529  // If the boundary is thin enough or the origin is outside the support plane for the newly discovered vertex, then we can terminate
530  if(v4.dot(n) <= 0 || vec(v4).sub(v3).dot(n) <= boundarytolerance || j > 100)
531  {
532  if(contactnormal) *contactnormal = n;
533  return hit;
534  }
535 
536  // Test origin against the three planes that separate the new portal candidates: (v1,v4,v0) (v2,v4,v0) (v3,v4,v0)
537  // Note: We're taking advantage of the triple product identities here as an optimization
538  // (v1 % v4) * v0 == v1 * (v4 % v0) > 0 if origin inside (v1, v4, v0)
539  // (v2 % v4) * v0 == v2 * (v4 % v0) > 0 if origin inside (v2, v4, v0)
540  // (v3 % v4) * v0 == v3 * (v4 % v0) > 0 if origin inside (v3, v4, v0)
541  vec v4xv0;
542  v4xv0.cross(v4, v0);
543  if(v1.dot(v4xv0) > 0) // Compute the tetrahedron dividing face d1 = (v4,v0,v1)
544  {
545  if(v2.dot(v4xv0) > 0) // Compute the tetrahedron dividing face d2 = (v4,v0,v2)
546  {
547  // Inside d1 & inside d2 ==> eliminate v1
548  v1 = v4;
549  v11 = v41;
550  v12 = v42;
551  }
552  else
553  {
554  // Inside d1 & outside d2 ==> eliminate v3
555  v3 = v4;
556  v31 = v41;
557  v32 = v42;
558  }
559  }
560  else
561  {
562  if(v3.dot(v4xv0) > 0) // Compute the tetrahedron dividing face d3 = (v4,v0,v3)
563  {
564  // Outside d1 & inside d3 ==> eliminate v2
565  v2 = v4;
566  v21 = v41;
567  v22 = v42;
568  }
569  else
570  {
571  // Outside d1 & outside d3 ==> eliminate v1
572  v1 = v4;
573  v11 = v41;
574  v12 = v42;
575  }
576  }
577  }
578  }
579  return false;
580  }
581 }
582 
float dot2(const T &o) const
dot product (line by line) of 2 dimensions
Definition: geom.hpp:161
float back() const
Definition: mpr.hpp:114
#define RAD
Definition: cube_types.hpp:32
Definition: mpr.hpp:12
Definition: mpr.hpp:213
float front() const
Definition: mpr.hpp:127
vec b
Definition: geom.hpp:670
const float boundarytolerance
Definition: mpr.hpp:283
CubePlanes(const clipplanes &p)
Definition: mpr.hpp:16
float scalartriple(const vec &a, const vec &b) const
scalar triple product can be used to calculate the volume of a 3 dimensional parallelogram ...
Definition: geom.hpp:216
EntCapsule(physent *ent)
Definition: mpr.hpp:173
float zmargin
Definition: mpr.hpp:134
float xradius
Definition: ents.hpp:136
Definition: mpr.hpp:63
float supportcoord(float a, float b, float c) const
Definition: mpr.hpp:107
vec center() const
Definition: mpr.hpp:60
vec center() const
Definition: mpr.hpp:210
SolidCube(const vec &o, int size)
Definition: mpr.hpp:39
vec o
Definition: mpr.hpp:35
float front() const
Definition: mpr.hpp:115
vec center() const
Definition: mpr.hpp:73
vec & mul(const vec &o)
scalar multiplication
Definition: geom.hpp:168
vec center() const
Definition: mpr.hpp:138
Definition: octree.hpp:173
Definition: mpr.hpp:185
vec center() const
Definition: mpr.hpp:42
EntCylinder(physent *ent, float zmargin=0)
Definition: mpr.hpp:136
vec transform(const vec &o) const
Definition: geom.hpp:843
vec supportpoint(const vec &n) const
Definition: mpr.hpp:98
const clipplanes & p
Definition: mpr.hpp:14
matrix3 orient
Definition: mpr.hpp:65
vec supportpoint(const vec &n) const
Definition: mpr.hpp:234
vec contactface(const vec &wn, const vec &wdir) const
Definition: mpr.hpp:75
float back() const
Definition: mpr.hpp:126
float right() const
Definition: mpr.hpp:113
void hit(int damage, dynent *d, fpsent *at, const vec &vel, int gun, float info1, int info2=1)
Definition: weapon.cpp:422
ModelOBB(const vec &ent, const vec &center, const vec &radius, int yaw)
Definition: mpr.hpp:215
Definition: geom.hpp:668
Model(const vec &ent, const vec &center, const vec &radius, int yaw)
Definition: mpr.hpp:204
Definition: ents.hpp:128
vec supportpoint(const vec &n) const
Definition: mpr.hpp:44
vec c
Definition: geom.hpp:670
float top() const
Definition: mpr.hpp:129
vec supportpoint(const vec &dir) const
Definition: mpr.hpp:189
ICOMMAND * f(float *a, float *b), floatret(*a **b)
Definition: mpr.hpp:199
float magnitude() const
vector's magnitude in all 3 (XYZ) dimensions
Definition: geom.hpp:195
vec & neg()
turn all 3 (XYZ) coordinates into its negative values
Definition: geom.hpp:183
float yaw
Definition: ents.hpp:132
Definition: mpr.hpp:171
else loopi(numargs)
Definition: command.cpp:3019
ModelEllipse(const vec &ent, const vec &center, const vec &radius, int yaw)
Definition: mpr.hpp:249
float yradius
Definition: ents.hpp:136
bool iszero() const
"do all cartesian coordinates (XYZ) of this vector have the value zero?"
Definition: geom.hpp:157
vec v[8]
Definition: octree.hpp:175
float eyeheight
Definition: ents.hpp:135
float dot(const vec &o) const
dot product (line by line) of all 3 dimensions
Definition: geom.hpp:163
float bottom() const
Definition: mpr.hpp:116
vec supportpoint(const vec &n) const
Definition: mpr.hpp:175
float left() const
Definition: mpr.hpp:112
float aboveeye
Definition: ents.hpp:135
void setyaw(float ck, float sk)
Definition: geom.hpp:778
vector with 3 floats and some useful methods.
Definition: geom.hpp:110
vec o
Definition: mpr.hpp:201
SolidCube(float x, float y, float z, int size)
Definition: mpr.hpp:38
float right() const
Definition: mpr.hpp:125
float bottom() const
Definition: mpr.hpp:128
float bottom() const
Definition: mpr.hpp:140
Definition: mpr.hpp:120
float radius
Definition: ents.hpp:135
vec & sub(const vec &o)
scalar subtraction
Definition: geom.hpp:177
EntEllipsoid(physent *ent)
Definition: mpr.hpp:187
vec transposedtransform(const vec &o) const
Definition: geom.hpp:847
vec a
Definition: geom.hpp:670
vec radius
Definition: mpr.hpp:201
float zmargin
Definition: mpr.hpp:66
float left() const
Definition: mpr.hpp:124
vec supportpoint(const vec &n) const
Definition: mpr.hpp:156
vec contactface(const vec &wn, const vec &wdir) const
Definition: mpr.hpp:219
EntOBB(physent *ent, float zmargin=0)
Definition: mpr.hpp:68
int d
Definition: octaedit.cpp:1749
vec supportpoint(const vec &n) const
Definition: mpr.hpp:268
EntFuzzy(physent *ent)
Definition: mpr.hpp:122
vec supportpoint(const vec &n) const
Definition: mpr.hpp:20
#define dir(name, v, d, s, os)
Definition: physics.cpp:2014
vec contactface(const vec &wn, const vec &wdir) const
Definition: mpr.hpp:253
matrix3 orient
Definition: mpr.hpp:202
physent * ent
Definition: mpr.hpp:56
GLuint GLuint GLintptr GLsizeiptr size
Definition: glexts.hpp:412
vec o
Definition: ents.hpp:130
Definition: mpr.hpp:247
vec & add(const vec &o)
scalar sum
Definition: geom.hpp:174
int size
Definition: mpr.hpp:36
float magnitude2() const
vector's magnitude in XY dimension
Definition: geom.hpp:193
Definition: mpr.hpp:132
float top() const
Definition: mpr.hpp:117
bool collide(const T &p1, const U &p2)
Definition: mpr.hpp:286
vec localsupportpoint(const vec &ln) const
Definition: mpr.hpp:91
Definition: mpr.hpp:33
vec o
Definition: octree.hpp:175
static map entities ("entity") and dynamic entities (players/monsters, "dynent") the gamecode extends...
vec & div(const vec &o)
scalar division
Definition: geom.hpp:171
mathmatics for vectors, matrices, quaterions and more
SolidCube(const ivec &o, int size)
Definition: mpr.hpp:40
vec center() const
Definition: mpr.hpp:18
Ent(physent *ent)
Definition: mpr.hpp:58
vec & cross(const A &a, const B &b)
template based vector cross product
Definition: geom.hpp:211
3-dimensional INTEGER vectors
Definition: geom.hpp:1226
vec & normalize()
normalize vector: divide it by its length (magnitude)
Definition: geom.hpp:198
Definition: mpr.hpp:54
float supportcoordneg(float a, float b, float c) const
Definition: mpr.hpp:103
vec contactface(const vec &n, const vec &dir) const
Definition: mpr.hpp:142
#define ASSERT(c)
Definition: cube_tools.hpp:12