28 float y1,
float x2,
float y2,
vec2 *crash );
40 xmlr_attr_int_def( base,
"num", n, 32 );
43 xmlNodePtr node = base->children;
45 if ( !xml_isNode( node,
"polygon" ) )
56 xmlNodePtr cur = node->children;
58 if ( xml_isNode( cur,
"x" ) ) {
60 char *list = xml_get( cur );
62 char *ch = SDL_strtokr( list,
",", &saveptr );
63 while ( ch != NULL ) {
68 ch = SDL_strtokr( NULL,
",", &saveptr );
71 }
else if ( xml_isNode( cur,
"y" ) ) {
73 char *list = xml_get( cur );
75 char *ch = SDL_strtokr( list,
",", &saveptr );
76 while ( ch != NULL ) {
81 ch = SDL_strtokr( NULL,
",", &saveptr );
85 }
while ( xml_nextNode( cur ) );
89 WARN( _(
"Polygon with mismatch of number of |x|=%d and |y|=%d "
90 "coordinates detected!" ),
92 }
while ( xml_nextNode( node ) );
95 polygon->dir_inc = 2. * M_PI /
array_size( polygon->views );
96 polygon->dir_off = polygon->dir_inc * 0.5;
100 for (
int i = 0; i <
array_size( polygon->views ); i++ ) {
103 WARN( _(
"Polygon '%s' has under 3 points for view %d!" ), name, i );
108 for (
int i = 0; i <
array_size( polygon->views ); i++ ) {
110 if ( (
double)view->
npt < floor( mean * 0.4 ) )
111 WARN( _(
"Polygon '%s' has very few points for view %d (%d points "
112 "compared to %f mean)!" ),
113 name, i, view->
npt, mean );
122 for (
int i = 0; i <
array_size( poly->views ); i++ ) {
150 const int bsy,
const vec2 *bp,
vec2 *crash )
153 int ax1, ax2, ay1, ay2;
154 int bx1, bx2, by1, by2;
155 int inter_x0, inter_x1, inter_y0, inter_y1;
157 int abx, aby, bbx, bby;
161 if ( at->
trans == NULL ) {
162 WARN( _(
"Texture '%s' has no transparency map" ), at->
name );
165 if ( bt->
trans == NULL ) {
166 WARN( _(
"Texture '%s' has no transparency map" ), bt->
name );
172 ax1 = (int)VX( *ap ) - (int)( at->
sw ) / 2;
173 ay1 = (int)VY( *ap ) - (int)( at->
sh ) / 2;
174 ax2 = ax1 + (int)( at->
sw ) - 1;
175 ay2 = ay1 + (int)( at->
sh ) - 1;
178 bx1 = (int)VX( *bp ) - (int)( bt->
sw ) / 2;
179 by1 = (int)VY( *bp ) - (int)( bt->
sh ) / 2;
180 bx2 = bx1 + bt->
sw - 1;
181 by2 = by1 + bt->
sh - 1;
184 if ( ( bx2 < ax1 ) || ( ax2 < bx1 ) )
186 if ( ( by2 < ay1 ) || ( ay2 < by1 ) )
190 inter_x0 =
MAX( ax1, bx1 );
191 inter_x1 =
MIN( ax2, bx2 );
192 inter_y0 =
MAX( ay1, by1 );
193 inter_y1 =
MIN( ay2, by2 );
196 rasy = at->
sy - asy - 1;
197 rbsy = bt->
sy - bsy - 1;
200 abx = asx * (int)( at->
sw ) - ax1;
201 aby = rasy * (int)( at->
sh ) - ay1;
202 bbx = bsx * (int)( bt->
sw ) - bx1;
203 bby = rbsy * (int)( bt->
sh ) - by1;
205 for ( y = inter_y0; y <= inter_y1; y++ )
206 for ( x = inter_x0; x <= inter_x1; x++ )
208 if ( ( !
gl_isTrans( at, abx + x, aby + y ) ) &&
238 int ax1, ax2, ay1, ay2;
239 int bx1, bx2, by1, by2;
240 int inter_x0, inter_x1, inter_y0, inter_y1;
246 if ( bt->
trans == NULL ) {
247 WARN( _(
"Texture '%s' has no transparency map" ), bt->
name );
253 ax1 = (int)VX( *ap ) + (int)( at->
xmin );
254 ay1 = (int)VY( *ap ) + (int)( at->
ymin );
255 ax2 = (int)VX( *ap ) + (int)( at->
xmax );
256 ay2 = (int)VY( *ap ) + (int)( at->
ymax );
259 bx1 = (int)VX( *bp ) - (int)( bt->
sw ) / 2;
260 by1 = (int)VY( *bp ) - (int)( bt->
sh ) / 2;
261 bx2 = bx1 + bt->
sw - 1;
262 by2 = by1 + bt->
sh - 1;
265 if ( ( bx2 < ax1 ) || ( ax2 < bx1 ) )
267 if ( ( by2 < ay1 ) || ( ay2 < by1 ) )
271 inter_x0 =
MAX( ax1, bx1 );
272 inter_x1 =
MIN( ax2, bx2 );
273 inter_y0 =
MAX( ay1, by1 );
274 inter_y1 =
MIN( ay2, by2 );
277 rbsy = bt->
sy - bsy - 1;
280 bbx = bsx * (int)( bt->
sw ) - bx1;
281 bby = rbsy * (int)( bt->
sh ) - by1;
282 for ( y = inter_y0; y <= inter_y1; y++ ) {
283 for ( x = inter_x0; x <= inter_x1; x++ ) {
285 if ( ( !
gl_isTrans( bt, bbx + x, bby + y ) ) ) {
314 int ax1, ax2, ay1, ay2;
315 int bx1, bx2, by1, by2;
316 int inter_x0, inter_x1, inter_y0, inter_y1;
317 float x1, y1, x2, y2;
320 ax1 = (int)VX( *ap ) + (int)( at->
xmin );
321 ay1 = (int)VY( *ap ) + (int)( at->
ymin );
322 ax2 = (int)VX( *ap ) + (int)( at->
xmax );
323 ay2 = (int)VY( *ap ) + (int)( at->
ymax );
326 bx1 = (int)VX( *bp ) + (int)( bt->
xmin );
327 by1 = (int)VY( *bp ) + (int)( bt->
ymin );
328 bx2 = (int)VX( *bp ) + (int)( bt->
xmax );
329 by2 = (int)VY( *bp ) + (int)( bt->
ymax );
332 if ( ( bx2 < ax1 ) || ( ax2 < bx1 ) )
334 if ( ( by2 < ay1 ) || ( ay2 < by1 ) )
338 inter_x0 =
MAX( ax1, bx1 );
339 inter_x1 =
MIN( ax2, bx2 );
340 inter_y0 =
MAX( ay1, by1 );
341 inter_y1 =
MIN( ay2, by2 );
344 for (
int i = 0; i <= bt->
npt - 1; i++ ) {
346 xabs = bt->
x[i] + VX( *bp );
347 yabs = bt->
y[i] + VY( *bp );
349 if ( ( xabs < inter_x0 ) || ( xabs > inter_x1 ) || ( yabs < inter_y0 ) ||
350 ( yabs > inter_y1 ) ) {
352 crash->
x = (int)xabs;
353 crash->
y = (int)yabs;
360 x1 = bt->
x[0] + VX( *bp );
361 y1 = bt->
y[0] + VY( *bp );
362 x2 = bt->
x[bt->
npt - 1] + VX( *bp );
363 y2 = bt->
y[bt->
npt - 1] + VY( *bp );
366 for (
int i = 0; i <= bt->
npt - 2; i++ ) {
367 x1 = bt->
x[i] + VX( *bp );
368 y1 = bt->
y[i] + VY( *bp );
369 x2 = bt->
x[i + 1] + VX( *bp );
370 y2 = bt->
y[i + 1] + VY( *bp );
390 rpolygon->
npt = ipolygon->
npt;
391 rpolygon->
x = malloc( ipolygon->
npt *
sizeof(
float ) );
392 rpolygon->
y = malloc( ipolygon->
npt *
sizeof(
float ) );
401 for (
int i = 0; i <= rpolygon->
npt - 1; i++ ) {
402 float d = ipolygon->
x[i] * ct - ipolygon->
y[i] *
st;
407 d = ipolygon->
x[i] *
st + ipolygon->
y[i] * ct;
420 if ( ( dir > 2. * M_PI ) || ( dir < 0. ) ) {
421 WARN( _(
"Angle not between 0 and 2.*M_PI [%f]." ), dir );
422 dir = angle_clean( dir );
426 int s = ( dir + poly->dir_off ) / poly->dir_inc;
428 return &poly->views[s];
443 float vprod, sprod, angle;
444 float dxi, dxip, dyi, dyip;
451 for (
int i = 0; i <= at->
npt - 2; i++ ) {
452 dxi = at->
x[i] + VX( *ap ) - x;
453 dxip = at->
x[i + 1] + VX( *ap ) - x;
454 dyi = at->
y[i] + VY( *ap ) - y;
455 dyip = at->
y[i + 1] + VY( *ap ) - y;
456 sprod = dxi * dxip + dyi * dyip;
457 vprod = dxi * dyip - dyi * dxip;
458 angle += atan2( vprod, sprod );
460 dxi = at->
x[at->
npt - 1] + VX( *ap ) - x;
461 dxip = at->
x[0] + VX( *ap ) - x;
462 dyi = at->
y[at->
npt - 1] + VY( *ap ) - y;
463 dyip = at->
y[0] + VY( *ap ) - y;
464 sprod = dxi * dxip + dyi * dyip;
465 vprod = dxi * dyip - dyi * dxip;
466 angle += atan2( vprod, sprod );
468 if (
FABS( angle ) < DOUBLE_TOL )
487 float y1,
float x2,
float y2,
vec2 *crash )
489 float xi, xip, yi, yip;
493 xi = at->
x[at->
npt - 1] + ap->
x;
494 xip = at->
x[0] + ap->
x;
495 yi = at->
y[at->
npt - 1] + ap->
y;
496 yip = at->
y[0] + ap->
y;
499 for (
int i = 0; i <= at->
npt - 2; i++ ) {
500 xi = at->
x[i] + ap->
x;
501 xip = at->
x[i + 1] + ap->
x;
502 yi = at->
y[i] + ap->
y;
503 yip = at->
y[i + 1] + ap->
y;
527 double s2y,
double e2x,
double e2y,
vec2 *crash )
529 double ua_t, ub_t, u_b;
531 ua_t = ( e2x - s2x ) * ( s1y - s2y ) - ( e2y - s2y ) * ( s1x - s2x );
532 ub_t = ( e1x - s1x ) * ( s1y - s2y ) - ( e1y - s1y ) * ( s1x - s2x );
533 u_b = ( e2y - s2y ) * ( e1x - s1x ) - ( e2x - s2x ) * ( e1y - s1y );
541 if ( ( 0. <= ua ) && ( ua <= 1. ) && ( 0. <= ub ) && ( ub <= 1. ) ) {
542 crash->
x = s1x + ua * ( e1x - s1x );
543 crash->
y = s1y + ua * ( e1y - s1y );
551 if ( ( ua_t == 0. ) || ( ub_t == 0. ) )
579 const glTexture *bt,
const int bsx,
const int bsy,
582 int x, y, rbsy, bbx, bby;
583 double ep[2], bl[2], tr[2], v[2], mod;
585 vec2 tmp_crash, border[2];
588 if ( bt->
trans == NULL ) {
589 WARN( _(
"Texture '%s' has no transparency map" ), bt->
name );
594 ep[0] = ap->
x + al * cos( ad );
595 ep[1] = ap->
y + al * sin( ad );
598 tr[0] = bp->
x + bt->
sw / 2.;
599 tr[1] = bp->
y + bt->
sh / 2.;
601 bl[0] = bp->
x - bt->
sw / 2.;
602 bl[1] = bp->
y - bt->
sh / 2.;
610 &tmp_crash ) == 1 ) {
611 border[hits].x = tmp_crash.
x;
612 border[hits].y = tmp_crash.
y;
617 &tmp_crash ) == 1 ) {
618 border[hits].x = tmp_crash.
x;
619 border[hits].y = tmp_crash.
y;
626 &tmp_crash ) == 1 ) {
627 border[hits].x = tmp_crash.
x;
628 border[hits].y = tmp_crash.
y;
634 &tmp_crash ) == 1 ) {
635 border[hits].x = tmp_crash.
x;
636 border[hits].y = tmp_crash.
y;
655 v[0] = border[1].x - border[0].x;
656 v[1] = border[1].y - border[0].y;
658 mod = MOD( v[0], v[1] ) / 2.;
663 rbsy = bt->
sy - bsy - 1;
665 bbx = bsx * (int)( bt->
sw );
666 bby = rbsy * (int)( bt->
sh );
669 x = border[0].x - bl[0] + v[0];
670 y = border[0].y - bl[1] + v[1];
671 while ( ( x > 0. ) && ( x < bt->sw ) && ( y > 0. ) && ( y < bt->sh ) ) {
673 if ( !
gl_isTrans( bt, bbx + (
int)x, bby + (
int)y ) ) {
674 crash[real_hits].
x = x + bl[0];
675 crash[real_hits].
y = y + bl[1];
684 x = border[1].x - bl[0] - v[0];
685 y = border[1].y - bl[1] - v[1];
686 while ( ( x > 0. ) && ( x < bt->sw ) && ( y > 0. ) && ( y < bt->sh ) ) {
688 if ( !
gl_isTrans( bt, bbx + (
int)x, bby + (
int)y ) ) {
689 crash[real_hits].
x = x + bl[0];
690 crash[real_hits].
y = y + bl[1];
699 if ( real_hits == 0 )
704 if ( real_hits == 1 ) {
705 crash[1].
x = crash[0].
x;
706 crash[1].
y = crash[0].
y;
733 double xi, yi, xip, yip;
738 ep[0] = ap->
x + al * cos( ad );
739 ep[1] = ap->
y + al * sin( ad );
742 vectnull( &tmp_crash );
746 crash[real_hits].
x = ap->
x;
747 crash[real_hits].
y = ap->
y;
753 crash[real_hits].
x = ep[0];
754 crash[real_hits].
y = ep[1];
759 if ( real_hits == 2 )
763 if ( real_hits == 0 ) {
767 tr[0] = bp->
x + (double)bt->
xmax;
768 tr[1] = bp->
y + (double)bt->
ymax;
770 bl[0] = bp->
x + (double)bt->
xmin;
771 bl[1] = bp->
y + (double)bt->
ymin;
779 tr[1], &tmp_crash ) == 1 )
784 tr[0], tr[1], &tmp_crash ) == 1 )
789 tr[0], bl[1], &tmp_crash ) == 1 )
794 bl[0], bl[1], &tmp_crash ) == 1 )
805 xi = (double)bt->
x[bt->
npt - 1] + bp->
x;
806 xip = (double)bt->
x[0] + bp->
x;
807 yi = (double)bt->
y[bt->
npt - 1] + bp->
y;
808 yip = (double)bt->
y[0] + bp->
y;
811 crash[real_hits].
x = tmp_crash.
x;
812 crash[real_hits].
y = tmp_crash.
y;
814 if ( real_hits == 2 )
817 for (
int i = 0; i <= bt->
npt - 2; i++ ) {
818 xi = (double)bt->
x[i] + bp->
x;
819 xip = (double)bt->
x[i + 1] + bp->
x;
820 yi = (double)bt->
y[i] + bp->
y;
821 yip = (double)bt->
y[i + 1] + bp->
y;
824 crash[real_hits].
x = tmp_crash.
x;
825 crash[real_hits].
y = tmp_crash.
y;
827 if ( real_hits == 2 )
833 if ( real_hits == 0 )
838 if ( real_hits == 1 ) {
839 crash[1].
x = crash[0].
x;
840 crash[1].
y = crash[0].
y;
870 vectnull( &tmp_crash[0] );
871 vectnull( &tmp_crash[1] );
874 p1.
x = bp->
x + (double)bt->
xmax;
875 p1.
y = bp->
y + (double)bt->
ymax;
877 p2.
x = bp->
x + (double)bt->
xmin;
878 p2.
y = bp->
y + (double)bt->
ymin;
881 if ( ( ap->
x - ar > p1.
x ) && ( ap->
x + ar < p2.
x ) &&
882 ( ap->
y - ar > p1.
y ) && ( ap->
y + ar < p2.
y ) )
888 p1.
x = (double)bt->
x[bt->
npt - 1] + bp->
x;
889 p2.
x = (double)bt->
x[0] + bp->
x;
890 p1.
y = (double)bt->
y[bt->
npt - 1] + bp->
y;
891 p2.
y = (double)bt->
y[0] + bp->
y;
893 crash[real_hits].
x = tmp_crash[0].
x;
894 crash[real_hits].
y = tmp_crash[0].
y;
896 if ( real_hits == 2 )
899 for (
int i = 0; i <= bt->
npt - 2; i++ ) {
900 p1.
x = (double)bt->
x[i] + bp->
x;
901 p2.
x = (double)bt->
x[i + 1] + bp->
x;
902 p1.
y = (double)bt->
y[i] + bp->
y;
903 p2.
y = (double)bt->
y[i + 1] + bp->
y;
905 crash[real_hits].
x = tmp_crash[0].
x;
906 crash[real_hits].
y = tmp_crash[0].
y;
908 if ( real_hits == 2 )
914 if ( real_hits == 0 )
919 if ( real_hits == 1 ) {
920 crash[1].
x = crash[0].
x;
921 crash[1].
y = crash[0].
y;
942 const int bsx,
const int bsy,
const vec2 *bp,
945 int r, acx, acy, ax1, ax2, ay1, ay2;
946 int bx1, bx2, by1, by2;
947 int inter_x0, inter_x1, inter_y0, inter_y1;
953 if ( bt->
trans == NULL ) {
954 WARN( _(
"Texture '%s' has no transparency map" ), bt->
name );
961 acx = (int)VX( *ap );
962 acy = (int)VY( *ap );
969 bx1 = (int)VX( *bp ) - (int)( bt->
sw ) / 2;
970 by1 = (int)VY( *bp ) - (int)( bt->
sh ) / 2;
971 bx2 = bx1 + bt->
sw - 1;
972 by2 = by1 + bt->
sh - 1;
975 if ( ( bx2 < ax1 ) || ( ax2 < bx1 ) )
977 if ( ( by2 < ay1 ) || ( ay2 < by1 ) )
981 inter_x0 =
MAX( ax1, bx1 );
982 inter_x1 =
MIN( ax2, bx2 );
983 inter_y0 =
MAX( ay1, by1 );
984 inter_y1 =
MIN( ay2, by2 );
987 rbsy = bt->
sy - bsy - 1;
990 bbx = bsx * (int)( bt->
sw ) - bx1;
991 bby = rbsy * (int)( bt->
sh ) - by1;
992 for (
int y = inter_y0; y <= inter_y1; y++ ) {
993 for (
int x = inter_x0; x <= inter_x1; x++ ) {
995 if ( ( !
gl_isTrans( bt, bbx + x, bby + y ) ) ) {
996 if (
pow2( x - acx ) +
pow2( y - acy ) <= r * r ) {
1008static int linePointOnSegment(
double d1,
double x1,
double y1,
double x2,
1009 double y2,
double x,
double y )
1012 double d2 = hypot( x - x1, y - y1 );
1013 double d3 = hypot( x2 - x, y2 - y );
1014 return fabs( d1 - d2 - d3 ) <
1018#define FX( A, B, C, x ) ( -( A * x + C ) / B )
1019#define FY( A, B, C, y ) ( -( B * y + C ) / A )
1031 double cr,
vec2 crash[2] )
1041 double r2 = cr * cr;
1042 if ( ( vec2_dist2( p1, cc ) < r2 ) && ( vec2_dist2( p2, cc ) < r2 ) ) {
1043 crash[0].
x = ( x1 + x2 ) * 0.5;
1044 crash[0].
y = ( y1 + y2 ) * 0.5;
1050 double C = x2 * y1 - x1 * y2;
1060 if ( fabs( B ) >= 1e-8 ) {
1061 b = 2. * ( A *
C + A * B * y0 -
pow2( B ) * x0 );
1062 c =
pow2(
C ) + 2. * B *
C * y0 -
1068 b = 2. * ( B *
C + A * B * x0 -
pow2( A ) * y0 );
1069 c =
pow2(
C ) + 2. * A *
C * x0 -
1073 d =
pow2( b ) - 4. * a *
c;
1078 d1 = hypot( x2 - x1, y2 - y1 );
1082 x = -b / ( 2. * a );
1083 y = FX( A, B,
C, x );
1084 if ( linePointOnSegment( d1, x1, y1, x2, y2, x, y ) ) {
1090 y = -b / ( 2. * a );
1091 x = FY( A, B,
C, y );
1092 if ( linePointOnSegment( d1, x1, y1, x2, y2, x, y ) ) {
1103 x = ( -b +
d ) / ( 2. * a );
1104 y = FX( A, B,
C, x );
1105 if ( linePointOnSegment( d1, x1, y1, x2, y2, x, y ) ) {
1110 x = ( -b -
d ) / ( 2. * a );
1111 y = FX( A, B,
C, x );
1112 if ( linePointOnSegment( d1, x1, y1, x2, y2, x, y ) ) {
1118 y = ( -b +
d ) / ( 2. * a );
1119 x = FY( A, B,
C, y );
1120 if ( linePointOnSegment( d1, x1, y1, x2, y2, x, y ) ) {
1125 y = ( -b -
d ) / ( 2. * a );
1126 x = FY( A, B,
C, y );
1127 if ( linePointOnSegment( d1, x1, y1, x2, y2, x, y ) ) {
1145 double dist2 = vec2_dist2( p1, p2 );
1148 if ( dist2 >
pow2( r1 + r2 ) )
1151 crash->
x = ( p1->
x * r1 + p2->
x * r2 ) / ( r1 + r2 );
1152 crash->
y = ( p1->
y * r1 + p2->
y * r2 ) / ( r1 + r2 );
1162 double dist2 = vec2_dist2( p1, p2 );
1165 if ( dist2 >
pow2( r1 + r2 ) )
1169 if ( dist2 <=
pow2( fabs( r1 - r2 ) ) )
1170 return M_PI *
pow2(
MIN( r1, r2 ) );
1174 if ((dist2==0.) && (r1==r2))
1175 return M_PI *
pow2(r1);
1179 double dist = sqrt( dist2 );
1180 double distc1 = (
pow2( r1 ) -
pow2( r2 ) + dist2 ) /
1182 double distc2 = dist - distc1;
1184 sqrt(
pow2( r1 ) -
pow2( distc1 ) );
1186 double ang1 = fmod( atan2( height, distc1 ) * 2. + 2. * M_PI,
1188 double ang2 = fmod( atan2( height, distc2 ) * 2. + 2. * M_PI,
1191 double A1 =
pow2( r1 ) / 2.0 *
1192 ( ang1 - sin( ang1 ) );
1193 double A2 =
pow2( r2 ) / 2.0 *
1194 ( ang2 - sin( ang2 ) );
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_create_size(basic_type, capacity)
Creates a new dynamic array of ‘basic_type’ with an initial capacity.
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
int CollideCircleCircle(const vec2 *p1, double r1, const vec2 *p2, double r2, vec2 crash[2])
Computes the collision between two circles.
int CollideSpritePolygon(const CollPolyView *at, const vec2 *ap, const glTexture *bt, int bsx, int bsy, const vec2 *bp, vec2 *crash)
Checks whether or not a sprite collides with a polygon.
static int PointInPolygon(const CollPolyView *at, const vec2 *ap, float x, float y)
Checks whether or not a point is inside a polygon.
void poly_rotate(CollPolyView *rpolygon, const CollPolyView *ipolygon, float theta)
Rotates a polygon.
int CollideLineCircle(const vec2 *p1, const vec2 *p2, const vec2 *cc, double cr, vec2 crash[2])
Checks to see if a line collides with a circle.
int CollideLineSprite(const vec2 *ap, double ad, double al, const glTexture *bt, const int bsx, const int bsy, const vec2 *bp, vec2 crash[2])
Checks to see if a line collides with a sprite.
int CollideCircleSprite(const vec2 *ap, double ar, const glTexture *bt, const int bsx, const int bsy, const vec2 *bp, vec2 *crash)
Checks whether or not a sprite collides with a polygon.
int CollideCirclePolygon(const vec2 *ap, double ar, const CollPolyView *bt, const vec2 *bp, vec2 crash[2])
Checks to see if a circle collides with a polygon.
int CollideLinePolygon(const vec2 *ap, double ad, double al, const CollPolyView *bt, const vec2 *bp, vec2 crash[2])
Checks to see if a line collides with a polygon.
int CollideLineLine(double s1x, double s1y, double e1x, double e1y, double s2x, double s2y, double e2x, double e2y, vec2 *crash)
Checks to see if two lines collide.
void poly_load(CollPoly *polygon, xmlNodePtr base, const char *name)
Loads a polygon from an xml node.
int CollideSprite(const glTexture *at, const int asx, const int asy, const vec2 *ap, const glTexture *bt, const int bsx, const int bsy, const vec2 *bp, vec2 *crash)
Checks whether or not two sprites collide.
static int LineOnPolygon(const CollPolyView *at, const vec2 *ap, float x1, float y1, float x2, float y2, vec2 *crash)
Checks whether or not a line intersects a polygon.
double CollideCircleIntersection(const vec2 *p1, double r1, const vec2 *p2, double r2)
Calculates the area of intersection between two circles.
int CollidePolygon(const CollPolyView *at, const vec2 *ap, const CollPolyView *bt, const vec2 *bp, vec2 *crash)
Checks whether or not two polygons collide. /!\ The function is not symmetric: the points of polygon ...
Header file with generic functions and naev-specifics.
int gl_isTrans(const glTexture *t, const int x, const int y)
Checks to see if a pixel is transparent in a texture.
Represents a polygon used for collision detection.
Abstraction for rendering sprite sheets.