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
collide.cpp File Reference
#include "cmd/collide.h"
#include "vegastrike.h"
#include "unit_generic.h"
#include "beam.h"
#include "bolt.h"
#include "gfx/mesh.h"
#include "unit_collide.h"
#include "physics.h"
#include "collide2/CSopcodecollider.h"
#include "collide2/csgeom2/optransfrm.h"
#include "collide2/basecollider.h"
#include "hashtable.h"
#include <string>
#include "vs_globals.h"
#include "configxml.h"

Go to the source code of this file.

Functions

bool TableLocationChanged (const QVector &Mini, const QVector &minz)
 
bool TableLocationChanged (const LineCollide &lc, const QVector &minx, const QVector &maxx)
 
void KillCollideTable (LineCollide *lc, StarSystem *ss)
 
bool EradicateCollideTable (LineCollide *lc, StarSystem *ss)
 
void AddCollideQueue (LineCollide &tmp, StarSystem *ss)
 
bool lcwithin (const LineCollide &lc, const LineCollide &tmp)
 
bool usehuge_table ()
 
static bool beamCheckCollision (QVector pos, float len, const Collidable &un)
 

Variables

static Hashtable< std::string,
collideTrees, 127 > 
unitColliders
 
float loge2 = log( 2.f )
 

Function Documentation

void AddCollideQueue ( LineCollide tmp,
StarSystem ss 
)

Definition at line 108 of file collide.cpp.

References CollideTable::c, StarSystem::collidetable, LineCollide::object, UnitHash3d< CTSIZ, CTACCURACY, CTHUGE >::Put(), LineCollide::type, and LineCollide::UNIT.

Referenced by Beam::UpdatePhysics().

109 {
110  if (tmp.type == LineCollide::UNIT)
111  ss->collidetable->c.Put( &tmp, tmp.object.u );
112  else
113  printf( "such collide types as %d not allowed", tmp.type );
114 }
static bool beamCheckCollision ( QVector  pos,
float  len,
const Collidable un 
)
static

Definition at line 141 of file collide.cpp.

References Collidable::GetPosition(), and Collidable::radius.

142 {
143  return (un.GetPosition()-pos).MagnitudeSquared() <= len*len+2*len*un.radius+un.radius*un.radius;
144 }
bool EradicateCollideTable ( LineCollide lc,
StarSystem ss 
)

Definition at line 98 of file collide.cpp.

References CollideTable::c, StarSystem::collidetable, UnitHash3d< CTSIZ, CTACCURACY, CTHUGE >::Eradicate(), LineCollide::object, LineCollide::type, and LineCollide::UNIT.

99 {
100  if (lc->type == LineCollide::UNIT) {
101  return ss->collidetable->c.Eradicate( lc->object.u );
102  } else {
103  printf( "such collide types as %d not allowed", lc->type );
104  return false;
105  }
106 }
void KillCollideTable ( LineCollide lc,
StarSystem ss 
)

Definition at line 90 of file collide.cpp.

References CollideTable::c, StarSystem::collidetable, LineCollide::object, UnitHash3d< CTSIZ, CTACCURACY, CTHUGE >::Remove(), LineCollide::type, and LineCollide::UNIT.

91 {
92  if (lc->type == LineCollide::UNIT)
93  ss->collidetable->c.Remove( lc, lc->object.u );
94  else
95  printf( "such collide types as %d not allowed", lc->type );
96 }
bool lcwithin ( const LineCollide lc,
const LineCollide tmp 
)

Definition at line 116 of file collide.cpp.

References LineCollide::Maxi, and LineCollide::Mini.

117 {
118  return lc.Mini.i< tmp.Maxi.i
119  && lc.Mini.j< tmp.Maxi.j
120  && lc.Mini.k< tmp.Maxi.k
121  && lc.Maxi.i >tmp.Mini.i
122  && lc.Maxi.j >tmp.Mini.j
123  && lc.Maxi.k >tmp.Mini.k;
124 }
bool TableLocationChanged ( const LineCollide lc,
const QVector minx,
const QVector maxx 
)

Definition at line 85 of file collide.cpp.

References LineCollide::Maxi, LineCollide::Mini, and TableLocationChanged().

86 {
88 }
bool usehuge_table ( )

Definition at line 126 of file collide.cpp.

References M.

127 {
128  const unsigned int A = 9301;
129  const unsigned int C = 49297;
130  const unsigned int M = 233280;
131  static unsigned int seed = 3259235;
132  seed = (seed*A+C)%M;
133  return seed < (M/100);
134 }

Variable Documentation

float loge2 = log( 2.f )

Definition at line 30 of file collide.cpp.

Hashtable< std::string, collideTrees, 127 > unitColliders
static

Definition at line 18 of file collide.cpp.