Generally, it is advised to use C++ for querying vertex data, python is definitely slower (than C++) at computing mesh data, especially when the data set is large.
You can further test by running this against a simple cube or sphere. You should see higher fps. On Sun, May 20, 2018 at 8:51 PM, Daniele Dolci <[email protected]> wrote: > Hi, > > I built a rig whose speed is between 40 and 50 fps in playback. When I > started to use follicles, even by using a low res driver, the speed goes > down dramatically(to 10-15 fps in playback). Therefore I decided to give it > a try to build my own node to create some kind of vertex constraint. The > idea is to take in a mesh, the index of the vertex to attach the object to, > and outputing the world position of the vertex. > > Unfortunately what I made is even slower than maya's follicles, I was > wondering if there is something obviously wrong I am doing or if that > depends on the fact I used python rather than c++. I attach below the > compute method of the deformer. If anyone could help to optimize it to > speed it up would be great! > > def compute(self, plug, data): > input_geometry = data.inputValue(Vertstraint.input_mesh).asMesh() > > fn_input_geometry = OpenMaya.MFnMesh(input_geometry) > index = data.inputValue(Vertstraint.vertex).asFloat() > > vertex_position = OpenMaya.MPoint() > fn_input_geometry.getPoint(int(index), vertex_position, > OpenMaya.MSpace.kWorld) > > output = data.outputValue(Vertstraint.world_position) > result = OpenMaya.MFloatVector(vertex_position.x, > vertex_position.y, vertex_position.z) > output.setMFloatVector(result) > > data.setClean(plug) > > > Cheers, > Daniele > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/python_inside_maya/67132225-b25f-4d24-a343- > c14e41abcd1a%40googlegroups.com > <https://groups.google.com/d/msgid/python_inside_maya/67132225-b25f-4d24-a343-c14e41abcd1a%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPaTLMQqPRArZfBcde0d5tyKy838uOT-ew%2BG1czMVyJJuv%2BDLA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
