|
|
Chambers wrote:
...
> Anyway, I noticed that I'm still not happy with the simulation speed, so I
> looked at the code for the patch. Collisions are checked between masses by
> calculating the distance, which requires a sqrt call. The only way I can
> think of to speed that up is to use a box format first, such as this
> pseudocode:
>
> if ((abs(dx)<max) and (abs(dy)<max)) and (abs(dz)<max)))
> if (sqrt(dx^2+dy^2+dz^2)<max)
> collision is true
> end
> end
...
I've never looked at the code you're describing here, but it looks like
you don't need the sqrt at all. Wherever max gets set, square it and
store it in maxSquared, then do:
if ((dx^2+dy^2+dz^2)<maxSquared)
collision is true
end
Post a reply to this message
|
|