On Tue, May 2, 2017 at 9:31 AM Aren Voorhees <are...@gmail.com> wrote:

> Ah, got it.  I didn't think about the fact that I was rearranging the
> order of the point list, making it not correspond to the vertex list.  To
> get it working, my only change was to take out the sorted() on line 14.
>
> Getting it working brought another issue to light though...it works really
> slowly.  In a test just now, it took nearly a minute to run on a 4k vert
> mesh, which is on the much lower end of mesh size I'd expect this to be
> used on.  The slowdown seems to be happening completely in the last for
> loop starting on line 24.  Any ideas on how I could optimize this?
>

If you look at the API docs for setVertexColor
<http://help.autodesk.com/cloudhelp/2016/ENU/Maya-SDK/cpp_ref/class_m_fn_mesh.html#a7b2000791e09a5ab2759ee23044257a9>,
it has this note:

NOTE: To change the colors of many vertices, it is more efficient to use
the batch updating method setVertexColors()
<http://help.autodesk.com/cloudhelp/2016/ENU/Maya-SDK/cpp_ref/class_m_fn_mesh.html#ac87fe328d734133476d0ae30796c7400>
 instead.

So you could build the color and vertex arrays up front, and then make one
call to set the colors.


>
>
> On Monday, May 1, 2017 at 3:24:47 PM UTC-5, Andres Weber wrote:
>>
>> The problme is that you sorted the points list (and got it out of order
>> from the original vertex list) and then used that to as the basis for
>> building your normalized list of values.  So, ignoring optimization or
>> anything, just put the comprehension on the for loop at line 19: for val in
>> [p[1] for p in pointsList]
>> instead of reusing the pointsDirList that you used to determine the
>> min/max.  That should get it back to working.
>>
>> On Monday, May 1, 2017 at 3:10:00 PM UTC-4, Aren Voorhees wrote:
>>>
>>> I have an old script that assigns vertex colors to a mesh, based on the
>>> vert's position (can be used to create worldspace gradients - useful for
>>> world position offset vertex animation in real-time applications).  Anyway,
>>> I'm working on re-writing this tool using the python API to hopefully make
>>> it quicker on dense meshes.  This is my first time really trying to use the
>>> api, so I'm kind of stumbling my way through it.  I've found a way to get
>>> the point positions and a list of vertex IDs on a given mesh.  However,
>>> those two lists don't correspond to each other so when I run the below
>>> code, it doesn't assign the right vert colors to the correct mesh.  Is
>>> there some way I can make the two lists, or two sets of information match
>>> together to fix this issue? (Note: Currently I'm just trying to create a Y
>>> gradient which is why I am just getting 2nd value for each point).
>>>
>>> https://pastebin.com/s3fGRPNG
>>>
>>> --
> 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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/16ecb20f-46e5-4ab2-b467-72c34f784e9d%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/16ecb20f-46e5-4ab2-b467-72c34f784e9d%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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0rdDuRDUY4kpQ3E3UFpb1%2BynLUMxyg0kkc%2Bgw%2B7dP_WA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to