POV-Ray : Newsgroups : povray.unofficial.patches : Speed of collision tests in mechsim : Speed of collision tests in mechsim Server Time
28 Jun 2024 15:11:32 EDT (-0400)
  Speed of collision tests in mechsim  
From: Chambers
Date: 28 May 2004 15:10:00
Message: <web.40b78e73622f64d6ca11893c0@news.povray.org>
So I was writing a general particle system capable of spitting out POV-Ray
code (as SDL solutions are too slow for my tastes), and I found MegaPOV
with mechsim.  Needless to say, I've been busy playing with it, and find it
both complete and effective.  Good job on a good patch!

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

But, as this requires three tests which could screw branch prediction up,
before you even get to the sqrt, I'm not sure it would save any time.

Or, you could do one test:

if (abs(dx)+abs(dy)+abs(dz) < max*3)
 if (sqrt...

Other than that, the only way to improve the speed would be to improve
POV-Ray's internal handling of geometry.

So, would such things actually help a lot?  And, because I'm not familiar
with POV-Ray's internals, would my writing a separate system be likely to
work any faster than the mechsim compiled in POV-Ray?

....Chambers, who wants to simulate millions of mass points but is currently
waiting for a trace with only 17000...


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.