POV-Ray : Newsgroups : povray.advanced-users : Collision detection : Collision detection Server Time
29 Jul 2024 04:26:34 EDT (-0400)
  Collision detection  
From: John Haiducek
Date: 5 Dec 2002 16:45:05
Message: <web.3defc7928d5d129d890025210@news.povray.org>
For those who have written particle systems: I'm using trace() and a large
number of collisions are missed.  How can I ensure that collisions are
detected?

Here's my collision handling macro:

#macro detect(X,Xold,V,T,elast,r)
  #local N=<0,0,0>;
  #local dir=X-Xold;
  #local contact=trace(blockobj,X,dir+vnormalize(dir)*r,N);
  #if(vlength(N)>0 & vlength(contact-X)<vlength(dir))
      #declare
V=((V-vnormalize(N)*vdot(V,N))-vnormalize(N)*vdot(V,N))*elast;
      #declare X=Xold;
  #end
#end


Post a reply to this message

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