On Thu, May 4, 2017, 2:06 AM Aren Voorhees <are...@gmail.com> wrote:

> Thanks to you both for the tips - this is what I came up with:
>
> https://pastebin.com/sRNqxARX
>
> Now it takes .3 seconds on a 75k vert mesh - pretty good speed increase
> I'd say!
>

Nice job.
Does it apply the gradient the way you wanted, considering it is still
using a sorted vert list and a color list that is in the order of the
unsorted points?


>
> On Tuesday, May 2, 2017 at 2:50:15 PM UTC-5, Andres Weber wrote:
>>
>> Also I haven't done ANY timing to see if this actually helps, but you're
>> casting a sublist to a set and back to a list...you could get a super minor
>> speed up by just doing xrange(selMesh.numVertices()) to get the full vertex
>> list.  You're also wasting time with the enumerate and index lookup on the
>> second same size list.  You could just zip the two generators and normalize
>> on demand by using a generator comprehension for pointsDirList and that
>> might speed things up a little.  I'm sure these are extremely minimal if at
>> all but just some ideas.  Justin's is going to be a huge speed increase I'm
>> sure.
>>
>>
>> On Monday, May 1, 2017 at 5:52:46 PM UTC-4, Justin Israel wrote:
>>>
>>>
>>>
>>> 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/560048e2-02cb-4b90-a1ed-9ceca09b4a50%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/560048e2-02cb-4b90-a1ed-9ceca09b4a50%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/CAPGFgA0E3OmvG106qa%2BbFZyN1HJ%2Bg9UArZua5D%2BZuqh6NVEg_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to