PDA

View Full Version : Is "polyColorPerVertex" a bug?


cgerchenhp
09-26-2007, 04:28 PM
Hello everyone, I am a newbie here.
In my Mel, I want to export polygen's soft/hard edges information for my DirectX program, so I use "polyColorPerVertex" command to query. But this command will take more and more time when run in a loop.
Please try this code below:


polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -tx 2 -ch 1 -n sphereForTest;
for($i = 0; $i<10;$i ++)
{
$startTime = `timerX`;
for($j = 0;$j <1000 ; $j++) {
polyNormalPerVertex -q -xyz sphereForTest.vtxFace[0][0];}
$totalTime = `timerX -startTime $startTime`;
print ("Total Time: "+$totalTime+"\n");
}

It will create a polySphere, and report how lont it consumed.
On my computer, the first time it will take 0.03second, after 10 loops it become 0.3second. If run it time by time ,it will take a very long time. Dose it’s a bug? Memory leaking? By the way, this happen in maya 7.0 and 8.5, Maya 2008 is OK.

cgerchenhp
09-27-2007, 01:43 AM
It seems both "polyNormalPerVertex" and "polyColorPerVertex" have the same problerm.


polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -tx 2 -ch 1 -n sphereForTest;
for($i = 0; $i<10;$i ++)
{
$startTime = `timerX`;
for($j = 0;$j <1000 ; $j++) {
polyColorPerVertex -q -rgb sphereForTest.vtx[0];
}

$totalTime = `timerX -startTime $startTime`;
print ("Total Time: "+$totalTime+"\n");

}

Are my codes wrong?
Thanks again.

ewerybody
09-27-2007, 08:42 AM
hmm .. I don't have the problem:
but if it takes 0.03 in the first loop its pretty coherent that 10 loops take 0.3seconds, isn't it?

Total Time: 0.07
Total Time: 0.06
Total Time: 0.08
Total Time: 0.09
Total Time: 0.1
Total Time: 0.13
Total Time: 0.14
Total Time: 0.16
Total Time: 0.17
Total Time: 0.19 < for the polyColorPerVertex test

Total Time: 0.05
Total Time: 0.06
Total Time: 0.08
Total Time: 0.09
Total Time: 0.11
Total Time: 0.13
Total Time: 0.14
Total Time: 0.15
Total Time: 0.18
Total Time: 0.18 < for the polyNormalPerVertex test

btw: If the code in your loop is a one liner you can also do the following:
for($j = 0;$j <1000 ; $j++)
polyColorPerVertex -q -rgb sphereForTest.vtx[$j];

I don't know if I got you right... pardon me ;]

cgerchenhp
09-27-2007, 10:32 AM
Oh, maybe i haven't explain clearly. forgive my poor English.
ewerybody, you have the same problerm.
In maya 2008 the result is like this:

Total Time: 0.03
Total Time: 0.04
Total Time: 0.03
Total Time: 0.03
Total Time: 0.03
Total Time: 0.03
Total Time: 0.02
Total Time: 0.02
Total Time: 0.03
Total Time: 0.03

every time the time is nearly same. It will not increase.
The "1000 loop code" is to make the "polyColorPerVertex" run 1000 times, actually no matter how may vertices it query,(in the test code, i only query sphereForTest.vtx[0]), if this cmd run again and again, it will take more and more time.
Thanks.

ewerybody
09-27-2007, 03:53 PM
Ahhh DOh! :scream:
I see i see. Now I get it. Yea thats pretty fcked up.

But.. such export stuff is better embedded in API anyway, isn't it?
Accessing those functions in API is very clearly documented i heard.

Robert Bateman
09-28-2007, 03:07 AM
yes, this stuff is much easier to do in the API. Anyhow, the cause of this sort of stuff is having either the undo queue enabled, or by printing stuff to the script output window. Anyhow, who cares if older versions of maya are causing problems if the latest release works....

ewerybody
09-28-2007, 08:14 AM
NO! They have to fix it back in time!! :scream:

hey rob! but these are good hints. I gonna try...

WOW! Its surely the undo! Seems the printing doesn't count at all:

{
int $undoState = `undoInfo -q -state`;
undoInfo -state off;
float $startTime, $times[];
int $numTimes = 0;
polySphere -r 1 -sx 20 -sy 20 -ax 0 1 0 -tx 2 -ch 1 -n sphereForTest;
for($i = 0; $i<10;$i ++)
{
$startTime = `timerX`;
for($j = 0;$j <1000 ; $j++)
polyColorPerVertex -q -rgb sphereForTest.vtx[$j];

$times[$numTimes++] = `timerX -startTime $startTime`;
}
print $times;
delete sphereForTest;
undoInfo -state $undoState;
};
0.04
0.05
0.05
0.05
0.04
0.05
0.05
0.04
0.05
0.05with the undo lines commented its as "slow" as before.

cgerchenhp
09-28-2007, 10:27 AM
WOO, now it works good.
ewerybody, Robert, Thanks a lot. ^o^

CGTalk Moderation
09-28-2007, 10:27 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.