Hello all.

I am trying to figure out the best way to emit particles from a plane based on the vertices height.

So if the height is over 1 then that vertex will emit particles.

I am using the per particle emission rate. However they way I have set it up so far is very inefficient. In fact its pretty much unusable for the object I wanted to use which has 10298 verts.

Its an animated object so I need it to evaluate each frame, so I created a function and then I plug this into the expression.

I’m not sure if there is a more efficient way of doing it, as surely your going to need to run through each vertex and test its height every frame and with something with so many verts its going to take time.

I think I’m going to be better off creating a lower geometry version of the model and use that just for the emission calculations.

Just wanted to check if there was another way.

```
def emitheight():
ppemit = "pPlaneShape1.emitter1RatePP"
for i in range(0,121):
vposy = mc.xform("pPlane1.vtx[%d]"% i ,q=True, t=True, ws=True)[1]
if vposy > 1:
mc.setAttr(ppemit + "[%d]" % i, 50)
else:
mc.setAttr(ppemit + "[%d]" % i, 0)
```

Cheers.

One thing that could speed it up is to save the result of the first round of the loop and use it later. Just check every vertex and see if it has potential of hitting the 1 height mark. If it doesn’t you can skip it for the next round maybe? I guess it depends on your animation of the object.

So if you check every vertex the first time, you don’t have to check everyone the next time around because you have already sorted out the ones that doesn’t have potential of hitting.

I’m not sure how fast it is but i still think your best option is to make a low poly mesh that you check against.

Thanks for the reply, sadly most of the verts need to be checked.

I went ahead and created a lower res version with only 400 verts and this seems to produce the result I wanted and does’nt take much time at all.

Find the bottleneck- is it math, indexers, getters/setters, or something else.

Prioritize your optimizations accordingly.

That’s really the way to optimize anything. I think you came up with an ideal component of the solution, but I’m sure you can optimize it even more if needed.

Find the bottleneck- is it math, indexers, getters/setters, or something else.

Prioritize your optimizations accordingly.

That’s really the way to optimize anything. I think you came up with an ideal component of the solution, but I’m sure you can optimize it even more if needed.