More performance in VP2 for a custom locator?

483 views
Skip to first unread message

Andrea Pinto

unread,
Dec 3, 2016, 12:39:57 PM12/3/16
to Python Programming for Autodesk Maya
Hello everyone,
I am trying to create a custom locator, drawing a circle always face to camera

I noticed when duplicate the locator 500 times, the scene is very very slow.
but If I create 500 spaceLocator that isn't happens

Can you know why?

thanks a lot 
Andrea

Chad Vernon

unread,
Dec 3, 2016, 3:09:20 PM12/3/16
to Python Programming for Autodesk Maya
It depends on your draw calls. Make sure you are not reading plug data in the draw function.

Andrea Pinto

unread,
Dec 4, 2016, 4:32:51 AM12/4/16
to Python Programming for Autodesk Maya
Hi chad! thanks for reply.

I started from the footPrintNode example

Yesterday I tried the footPrint in maya 2016/2017 and I had the same result, viewport 1 e 2 very slow.

Sorry I am noob
thanks again

Andrea Pinto

unread,
Dec 4, 2016, 5:10:34 AM12/4/16
to Python Programming for Autodesk Maya

Chad Vernon

unread,
Dec 4, 2016, 5:10:43 PM12/4/16
to Python Programming for Autodesk Maya
The problem with the first example is that getMultiplier function. It's reading the plug value to get the multiplier and is called in both the boundingBox function and prepareForDraw function. The second example looks like it caches the plug values and only reads them when they change.

Andrea Pinto

unread,
Dec 4, 2016, 8:31:04 PM12/4/16
to Python Programming for Autodesk Maya
I tried again the first example.
drawing only a simple circle, but nothing it is still slow.

Can you suggest to me a way to create a custom shape face the camera?

In the attachment a snapshot of the my custom locator
The scene becomes slow with 40 locators :(

Alex Hrazhdan

unread,
Dec 7, 2016, 5:44:52 PM12/7/16
to Python Programming for Autodesk Maya
Hi, Andrea. the significant slowdown is because of one shader per override locator instance, and because of transparency (MShaderInstance::setIsTransparent())...

Andrea Pinto

unread,
Dec 9, 2016, 8:00:11 PM12/9/16
to Python Programming for Autodesk Maya
Hi Alex thanks, Do you mean I have to create a MShaderIstance?
I am using the MPxDrawOverride method of the footPrintNode example.
In that example the footPrint isn't trasparent, but it is slow.

I don't know, Probably I have to find a way to don't create the position list and triangles for every update. 
I am creating the circle face the camera, multiplying every point with cameraPath.inclusiveMatrix() and objPath.inclusiveMatrix().inverse()

Alex Hrazhdan

unread,
Dec 10, 2016, 5:39:59 AM12/10/16
to Python Programming for Autodesk Maya
Hi Andrea. Isn't it more efficient to draw simple sphere than circle? In that case you dont have to multiply vectors by matrix every draw update...
And instad of MPxDrawOverride, I recoment to use MPxGeometryOverride... You can declare couple of MShaderInstance as static variables and use it for every locator instance in different cases (selection lead, selection active, defoult state). 
But in that case you will lose your ability to switch color per locator instance.

Andrea Pinto

unread,
Dec 10, 2016, 8:03:24 AM12/10/16
to Python Programming for Autodesk Maya
thanks again for your advice, you are right, the sphere was my first idea.
My fault I would like to do something more 2D hehe.
Create different shapes when changing the segments.
Surely in c++ would be better.

Andrea Pinto

unread,
Dec 20, 2016, 6:57:33 AM12/20/16
to Python Programming for Autodesk Maya
Hi, sorry if I continue to ask some question here, I was trying to create a sphere with MPxGeometryOverride.
This is the result.
Wireframe is ok, but the shaded it is strange.
Is it a problem with the normals?

Andrea Pinto

unread,
Feb 3, 2017, 8:47:40 AM2/3/17
to Python Programming for Autodesk Maya


Hi! I was working about it again in these Days.
In the geometryOverride I tried to print out the semanticName of the vertexBufferDescriptor 
The result is only "POSITION", it hasn't a semantic "Normals"

How I can create the Normals? or Do you have some solution for this problem?

Is it possible to use a geometryOverride and drawOverride togheter? 

thanks in advance 

Andrea Pinto

unread,
Feb 8, 2017, 11:42:09 AM2/8/17
to Python Programming for Autodesk Maya
Hello! Yesterday I saw the example of apiMeshShape.
More or less I understand how to create the shape.
I'll try to follow that example.

Andrea Pinto

unread,
Sep 1, 2017, 2:04:34 AM9/1/17
to Python Programming for Autodesk Maya
Hi, after so long, I resume this discussion.
I wanted ask you.
Do you know if there is a way to update the function populategeometry in the method geometryOverride when I am scaling the transforme node.

I would like to have the shape with same size multiplying it with inverse matrix
I mean I did that, but it update when I deselect and select the transform node after the scaling

do you know how can I update it directly with scaling?

thanks in advance
Andrea
Reply all
Reply to author
Forward
0 new messages