PDA

View Full Version : Processing arrays in mesh SO mode.


Moosley
09-13-2005, 12:28 PM
Anyone know why is it much slower to go through an array of verts when in Mesh sub object mode? Is there a way around it without having to come out of SO mode or converting to poly first?

j-man
09-13-2005, 04:44 PM
That might be a question for Larry or Bobo, but I wouldn't imagine changing to an Epoly would change much. Have you considered using bitarray's?

J.

Moosley
09-13-2005, 05:05 PM
The loop is through a bitarray at the moment, though the speed difference is not noticable, we're talking a few seconds for Editable_Mesh sub-object mode compared to nearly instant when not in SO mode (with the modify panel still open), but when in Editable_Poly SO mode it's near instant regardless... Basically the script is going through and setting the vertex alpha and illumination channels for all the map faces in the object using polyop/meshop.setMapVert, retaining some values and changing others based on the user input. I've worked around by leaving SO mode (if the the object is a mesh) before the loop and going back in after, though it causes a slight delay due to the screen being redrawn... Still faster than waiting for it to chug through all the verts in SO mode!

Impus
09-13-2005, 10:44 PM
Do you have the chunk of your code that does the looping?

Moosley
09-14-2005, 11:10 AM
Here's the code, in this version it loops from 1 to the number of map verts rather than a bitarray:


arr1 = #("r","g","b")
arr2 = #(1,2,3)
arr3 = #([256,0,0],[0,256,0],[0,0,256])

mapped fn changeFlagView theObj =
(
local stateType = test.col.state

if classOf theObj == Editable_Mesh do
(
if meshop.getMapSupport theObj -2 == true then
(
mapVerts = (meshop.getNumMapVerts theObj -2)

for mV=1 to mapVerts do
(
curCol = meshop.getMapVert theObj -2 mV

if stateType == true and (bit.get curCol.y 10 == true) then meshop.setMapVert theObj -1 mV ([256,256,0]/[256,256,256])
else
(
if curCol.x == 0 or curCol.z ==1 or (findItem arr2 curCol.x) == 0 then surfCol = [1,1,1]
else surfCol = (arr3[(findItem arr2 curCol.x)]) / [256,256,256]
if stateType == false then meshop.setMapVert theObj -1 mV surfCol
)
)
)
)

if classOf theObj == Editable_Poly do
(
if polyop.getMapSupport theObj -2 == true then
(
mapVerts = (polyop.getNumMapVerts theObj -2)

for mV=1 to mapVerts do
(
curCol = polyop.getMapVert theObj -2 mV

if stateType == true and (bit.get curCol.y 10 == true) then polyop.setMapVert theObj -1 mV ([256,256,0]/[256,256,256])
else
(
if curCol.x == 0 or curCol.z ==1 or (findItem arr2 curCol.x) == 0 then surfCol = [1,1,1]
else surfCol = (arr3[(findItem arr2 curCol.x)]) / [256,256,256]
if stateType == false then polyop.setMapVert theObj -1 mV surfCol
)
)
)
)
)

rollout test "Test" width:104 height:64
(
checkButton col "Change Col" pos:[16,16] width:72 height:32

on col changed state do
(
changeFlagView selection
completeRedraw()
)
)
createDialog test


try it with the attached scene (just rename it from .zip to .max, it's not actually zipped)

Cheers!

f97ao
09-16-2005, 05:29 PM
Is it the same situation for Editable_Poly object? I haven't seen any such differences myself, but haven't looked that hard.

The reason is probably that when you are in sub mode max is in a special "edit mode" and many things are slower here.
/Andreas

Moosley
09-18-2005, 04:05 PM
Editable_Poly is much much faster at processing the verts when in SO mode... Ah well. I've bunged in a workaround involving setting subobjectlevel = 0 if it's != 0 and setting it back after :)

f97ao
09-19-2005, 06:37 AM
Remember that it takes some time to move in and out of subobject mode as well!

Hmm, perhaps that "optimization" would work for me as well. But I really don't like that the command panel flickers so much when you do it. :(

/Andreas

Moosley
09-19-2005, 09:05 AM
Yeah, I can't stand the flickers either, but it's MUCH faster than waiting for the verts to process in SO mode...

CGTalk Moderation
09-19-2005, 09:05 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.