i'm writing a little collision detector and 1 method is making the simulator crash... i'm new to objective c and iphone dev, so i don't doubt that i'm doing something silly!
everything behaves as i'd expect it to except that it crashes somewhere inside the method below. i assume there's something i'm doing incorrectly with my min and max pointers because when i remove them from the equation, the simulator chugs along happily. though all tests i do to isolate an issue in this regard pass without fail.
and here's how i'm calling the method
any help is appreciated!
everything behaves as i'd expect it to except that it crashes somewhere inside the method below. i assume there's something i'm doing incorrectly with my min and max pointers because when i remove them from the equation, the simulator chugs along happily. though all tests i do to isolate an issue in this regard pass without fail.
Code:
+ (void) getProjectionPoly:(Polygon *)poly direction:(CGPoint)dir min:(float *)min max:(float *)max
{
*min = FLT_MAX;
*max = -FLT_MAX;
Edge *edge = [poly edges];
while( edge != nil )
{
float projection = edge.A.x * dir.x + edge.A.y * dir.y;
if( projection < *min ) *min = projection;
if( projection > *max ) *max = projection;
edge = edge.next;
}
[edge release];
}
Code:
float min;
float max;
[CollisionDetector getProjectionPoly:p1 direction:dir min:&min max:&max];