24 return memcmp( &a, &b,
sizeof (
Collidable) ) == 0;
32 printf(
"NONFATAL NULL activeStarSystem detected...please fix\n" );
35 static bool collidemap_sanity_check =
37 if (collidemap_sanity_check) {
46 printf(
"hussah %d\n", *i == *this->
location[locind] );
50 printf(
"(%f %f %f) and (%f %f %f) %f < %f %d!!!",
51 (**i).GetPosition().i,
52 (**i).GetPosition().j,
53 (**i).GetPosition().k,
54 (**j).GetPosition().i,
55 (**j).GetPosition().j,
56 (**j).GetPosition().k,
57 (**i).GetPosition().MagnitudeSquared(),
58 (**j).GetPosition().MagnitudeSquared(),
59 (**i).GetPosition().MagnitudeSquared()
60 < (**j).GetPosition().MagnitudeSquared() );
64 printf(
"fin %d %d ", *(
int*) &i, found );
75 mounts[j].ref.gun->RemoveFromSystem(
true );
108 return Vector( in.i >= 0 ? in.i : -in.i,
109 in.j >= 0 ? in.j : -in.j,
110 in.k >= 0 ? in.k : -in.k );
142 normal = ( target-
Position() ).Cast();
143 ::Normalize( normal );
158 if (smaller->
colTrees == NULL || this->colTrees == NULL)
160 if (
hull < 0)
return false;
181 smallpos.Set( (mycollide[0].
a1.x+mycollide[0].
b1.
x+mycollide[0].
c1.
x)/3.0f,
182 (mycollide[0].
a1.
y+mycollide[0].
b1.
y+mycollide[0].
c1.
y)/3.0f,
183 (mycollide[0].
a1.
z+mycollide[0].
b1.
z+mycollide[0].
c1.
z)/3.0f );
185 bigpos.Set( (mycollide[0].a2.x+mycollide[0].
b2.
x+mycollide[0].
c2.
x)/3.0f,
186 (mycollide[0].
a2.
y+mycollide[0].
b2.
y+mycollide[0].
c2.
y)/3.0f,
187 (mycollide[0].
a2.
z+mycollide[0].
b2.
z+mycollide[0].
c2.
z)/3.0f );
190 sn.
Cross( mycollide[0].b1-mycollide[0].
a1, mycollide[0].c1-mycollide[0].a1 );
191 bn.
Cross( mycollide[0].b2-mycollide[0].a2, mycollide[0].c2-mycollide[0].a2 );
194 smallNormal.Set( sn.
x, sn.
y, sn.
z );
195 bigNormal.Set( bn.
x, bn.
y, bn.
z );
208 float rad = smaller->
rSize();
209 for (
Unit *un; (un = *i); ++i) {
210 float subrad = un->rSize();
215 if ( ( un->InsideCollideTree( smaller, bigpos, bigNormal, smallpos, smallNormal, bigtype ==
ASTEROIDPTR,
224 float rad = bigger->
rSize();
225 for (
Unit *un; (un = *i); ++i) {
226 float subrad = un->rSize();
256 this->
Velocity *= (1-NEBULA_SPACE_DRAG);
268 last_collisions->insert( std::pair< Unit*, Unit* > (
this, target ) );
287 Vector bigNormal, smallNormal;
288 if ( bigger->
InsideCollideTree( smaller, bigpos, bigNormal, smallpos, smallNormal ) ) {
290 bigger->
reactToCollision( smaller, bigpos, bigNormal, smallpos, smallNormal, 10 );
292 }
else {
return false; }
294 Vector normal( -1, -1, -1 );
310 float temp1 = radius;
314 b = 2.0f*( dir.Dot( st ) );
322 float tmp = ( -b+
sqrt( c ) )/a;
323 c = ( -b-
sqrt( c ) )/a;
324 if (tmp > 0 && tmp <= 1)
325 return (c > 0 && c < tmp) ? c : tmp;
326 else if (c > 0 && c <= 1)
334 if (st.MagnitudeSquared() < radius*radius)
349 float rad = this->
rSize();
358 for (
Unit *un; (un = *
i); ++
i)
359 if ( ( tmp = un->
rayCollide( start, end, norm, distance) ) != 0 )
378 norm = ((start+del*distance)-
Position()).Cast();
385 if(tmpCol->
rayCollide(boltbeam,norm,distance)){
412 #ifdef VARIABLE_LENGTH_PQR
414 double SizeScaleFactor =
sqrt( TargetPoint.Dot( TargetPoint ) );
417 TargetPoint = (tmpo->
p-pnt).Cast();
418 if (TargetPoint.Dot( TargetPoint )
421 #ifdef VARIABLE_LENGTH_PQR
422 *SizeScaleFactor*SizeScaleFactor
425 #ifdef VARIABLE_LENGTH_PQR
432 for (i = 0; i <
nummesh(); i++) {
434 if (TargetPoint.Dot( TargetPoint )
437 #ifdef VARIABLE_LENGTH_PQR
438 *SizeScaleFactor*SizeScaleFactor
441 #ifdef VARIABLE_LENGTH_PQR
452 for (
const Unit *un; (un = *i); ++i)
453 if ( (un)->querySphere( pnt, err ) )
464 for (
const Unit *un; (un = *i); ++i) {
466 if ( ( tmp = un->querySphere( start, end, min_radius ) ) != 0 )
478 for (i = 0; i <
nummesh(); i++) {
488 double temp1 = ( min_radius+
meshdata[i]->rSize() );
491 if (min_radius != -FLT_MAX)
495 #ifdef VARIABLE_LENGTH_PQR
496 c *= SizeScaleFactor*SizeScaleFactor;
498 b = 2.0f*( dir.Dot( st ) );
501 if (min_radius != -FLT_MAX)
509 tmp = ( -b+
sqrt( c ) )/a;
510 c = ( -b-
sqrt( c ) )/a;
511 if (tmp > 0 && tmp <= 1)
512 return (c > 0 && c < tmp) ? c : tmp;
513 else if (c > 0 && c <= 1)