Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
opbox.cpp File Reference
#include <math.h>
#include "cmd/collide2/opcodesysdef.h"
#include "opbox.h"

Go to the source code of this file.

Classes

struct  Outline
 

Macros

#define MIN(a, b)   ((a)<(b)?(a):(b))
 
#define MAX(a, b)   ((a)>(b)?(a):(b))
 

Functions

csBox3 operator+ (const csBox3 &box1, const csBox3 &box2)
 
csBox3 operator+ (const csBox3 &box, const csVector3 &point)
 
csBox3 operator* (const csBox3 &box1, const csBox3 &box2)
 
bool operator== (const csBox3 &box1, const csBox3 &box2)
 
bool operator!= (const csBox3 &box1, const csBox3 &box2)
 
bool operator< (const csBox3 &box1, const csBox3 &box2)
 
bool operator> (const csBox3 &box1, const csBox3 &box2)
 
bool operator< (const csVector3 &point, const csBox3 &box)
 

Variables

static Outline outlines [27]
 Outline lookup table. More...
 

Macro Definition Documentation

#define MAX (   a,
  b 
)    ((a)>(b)?(a):(b))

Definition at line 20 of file opbox.cpp.

Referenced by HPoint::Max(), Point::Max(), operator*(), operator+(), and csBox3::SquaredOriginMaxDist().

#define MIN (   a,
  b 
)    ((a)<(b)?(a):(b))

Definition at line 19 of file opbox.cpp.

Referenced by csBox3::GetConvexOutline(), HPoint::Min(), Point::Min(), operator*(), and operator+().

Function Documentation

bool operator!= ( const csBox3 box1,
const csBox3 box2 
)

Definition at line 414 of file opbox.cpp.

References csBox3::maxbox, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

415 {
416  return ( (box1.minbox.x != box2.minbox.x)
417  || (box1.minbox.y != box2.minbox.y)
418  || (box1.minbox.z != box2.minbox.z)
419  || (box1.maxbox.x != box2.maxbox.x)
420  || (box1.maxbox.y != box2.maxbox.y)
421  || (box1.maxbox.z != box2.maxbox.z) );
422 }
csBox3 operator* ( const csBox3 box1,
const csBox3 box2 
)

Definition at line 393 of file opbox.cpp.

References MAX, csBox3::maxbox, MIN, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

394 {
395  return csBox3(
396  MAX(box1.minbox.x,box2.minbox.x),
397  MAX(box1.minbox.y,box2.minbox.y),
398  MAX(box1.minbox.z,box2.minbox.z),
399  MIN(box1.maxbox.x,box2.maxbox.x),
400  MIN(box1.maxbox.y,box2.maxbox.y),
401  MIN(box1.maxbox.z,box2.maxbox.z));
402 }
csBox3 operator+ ( const csBox3 box1,
const csBox3 box2 
)

Definition at line 371 of file opbox.cpp.

References MAX, csBox3::maxbox, MIN, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

372 {
373  return csBox3(
374  MIN(box1.minbox.x,box2.minbox.x),
375  MIN(box1.minbox.y,box2.minbox.y),
376  MIN(box1.minbox.z,box2.minbox.z),
377  MAX(box1.maxbox.x,box2.maxbox.x),
378  MAX(box1.maxbox.y,box2.maxbox.y),
379  MAX(box1.maxbox.z,box2.maxbox.z) );
380 }
csBox3 operator+ ( const csBox3 box,
const csVector3 point 
)

Definition at line 382 of file opbox.cpp.

References MAX, csBox3::maxbox, MIN, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

383 {
384  return csBox3(
385  MIN(box.minbox.x,point.x),
386  MIN(box.minbox.y,point.y),
387  MIN(box.minbox.z,point.z),
388  MAX(box.maxbox.x,point.x),
389  MAX(box.maxbox.y,point.y),
390  MAX(box.maxbox.z,point.z) );
391 }
bool operator< ( const csBox3 box1,
const csBox3 box2 
)

Definition at line 424 of file opbox.cpp.

References csBox3::maxbox, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

425 {
426  return ( (box1.minbox.x >= box2.minbox.x)
427  && (box1.minbox.y >= box2.minbox.y)
428  && (box1.minbox.z >= box2.minbox.z)
429  && (box1.maxbox.x <= box2.maxbox.x)
430  && (box1.maxbox.y <= box2.maxbox.y)
431  && (box1.maxbox.z <= box2.maxbox.z) );
432 }
bool operator< ( const csVector3 point,
const csBox3 box 
)

Definition at line 444 of file opbox.cpp.

References csBox3::maxbox, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

445 {
446  return ( (point.x >= box.minbox.x)
447  && (point.x <= box.maxbox.x)
448  && (point.y >= box.minbox.y)
449  && (point.y <= box.maxbox.y)
450  && (point.z >= box.minbox.z)
451  && (point.z <= box.maxbox.z) );
452 }
bool operator== ( const csBox3 box1,
const csBox3 box2 
)

Definition at line 404 of file opbox.cpp.

References csBox3::maxbox, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

405 {
406  return ( (box1.minbox.x == box2.minbox.x)
407  && (box1.minbox.y == box2.minbox.y)
408  && (box1.minbox.z == box2.minbox.z)
409  && (box1.maxbox.x == box2.maxbox.x)
410  && (box1.maxbox.y == box2.maxbox.y)
411  && (box1.maxbox.z == box2.maxbox.z) );
412 }
bool operator> ( const csBox3 box1,
const csBox3 box2 
)

Definition at line 434 of file opbox.cpp.

References csBox3::maxbox, csBox3::minbox, csVector3::x, csVector3::y, and csVector3::z.

435 {
436  return ( (box2.minbox.x >= box1.minbox.x)
437  && (box2.minbox.y >= box1.minbox.y)
438  && (box2.minbox.z >= box1.minbox.z)
439  && (box2.maxbox.x <= box1.maxbox.x)
440  && (box2.maxbox.y <= box1.maxbox.y)
441  && (box2.maxbox.z <= box1.maxbox.z) );
442 }

Variable Documentation

Outline outlines[27]
static
Initial value:
=
{
{ 7, {3,2,6,4,5,1,0}, 3, {BOX_SIDE_x,BOX_SIDE_y,BOX_SIDE_z} },
{ 6, {3,2,0,4,5,1,-1}, 2, {BOX_SIDE_x,BOX_SIDE_y,-1} },
{ 7, {7,3,2,0,4,5,1}, 3, {BOX_SIDE_x,BOX_SIDE_y,BOX_SIDE_Z} },
{ 6, {3,2,6,4,0,1,-1}, 2, {BOX_SIDE_x,BOX_SIDE_z,-1} },
{ 4, {3,2,0,1,-1,-1,-1}, 1, {BOX_SIDE_x,-1,-1} },
{ 6, {7,3,2,0,1,5,-1}, 2, {BOX_SIDE_x,BOX_SIDE_Z,-1} },
{ 7, {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