It is usually better to calculate distance squared, since you eliminate the root op.
Quote:
Originally Posted by Scorpious2k
Took a little time to look at the dist calcs... in Mob::Dist it reads
Code:
float Mob::Dist(const Mob &other) {
double xDiff = other.x_pos - x_pos;
double yDiff = other.y_pos - y_pos;
double zDiff = other.z_pos - z_pos;
return sqrt( (xDiff * xDiff)
+ (yDiff * yDiff)
+ (zDiff * zDiff) );
}
Which looks about as efficient as you can get without going to assembler... but if you went to that level it might look like
...<snip>...
|