andymoorer

11-06-2009, 09:45 PM

Hi folks. Heres a question for you. I want to control (kill, move etc) particles based on their distance from the mesh from which they were emitted. I'm currently querying the nearestPointOnMesh node and getting the magnitude of the vector between a given particle and the closest point on the mesh. Like this:

$meshObject = "pSphere1"

$posPP = particleShape1.position;

$x = $posPP.x;

$y = $posPP.y;

$z = $posPP.z;

float $nearestPoint[] = `nearestPointOnMesh -ip ($x) ($y) ($z) -q -p $meshObject`;

float $distance = sqrt( pow(($x - $nearestPoint[0]),2)+pow(($y - $nearestPoint[1]),2)+pow(($z - $nearestPoint[2]),2));

if ($distance > 1.5){

particleShape1.goalPP = 1;}

else{

particleShape1.goalPP = 0;}

But this approach is far too slow with hundreds of thousands of particles. Is there an inherent attribute already in my system which I could use to measure? Or is there a 'standard' approach to this kind of thing?

$meshObject = "pSphere1"

$posPP = particleShape1.position;

$x = $posPP.x;

$y = $posPP.y;

$z = $posPP.z;

float $nearestPoint[] = `nearestPointOnMesh -ip ($x) ($y) ($z) -q -p $meshObject`;

float $distance = sqrt( pow(($x - $nearestPoint[0]),2)+pow(($y - $nearestPoint[1]),2)+pow(($z - $nearestPoint[2]),2));

if ($distance > 1.5){

particleShape1.goalPP = 1;}

else{

particleShape1.goalPP = 0;}

But this approach is far too slow with hundreds of thousands of particles. Is there an inherent attribute already in my system which I could use to measure? Or is there a 'standard' approach to this kind of thing?