PDA

View Full Version : why this function runs too slow in max 5?


hblan
03-08-2006, 12:56 AM
i have write a fn for collapse objects with same material . but i dont know why this function runs too too slow in max 5 , but works fast in max6 and max7 . maybe some setting wrong with my max 5 ? thanks for reply .
fn code :

fn objsByMat selectObjs =
(
local end_array=for i in sceneMaterials collect #()
for i=1 to sceneMaterials.count do
(
for j in selectObjs do
(
if (j.material)!=undefined do
(
if (j.material)==sceneMaterials[i] do
(
append end_array[i] j--.name
)

)
)
)
return end_array
)

galagast
03-08-2006, 02:18 AM
Hi, try this, although im not sure if there will be a significant change in speed coz this one is also from max6


fn objsByMat selectObjs =
(
count = sceneMaterials.count
local end_array = for i in 1 to count collect #()
for i in selectObjs where i.material != undefined do
(
index = finditem sceneMaterials i.material
if index != 0 do append end_array[index] i
)
return end_array
)


there's also a good section in the reference titled: "How to Make it Faster" just in case you havent bumped into it yet. :D

arketip
03-08-2006, 02:52 AM
Is that slow with this function too ?

fn objByMat selectObjs = (
local theMats = for m in sceneMaterials collect m
local objByMatArray = for m=1 to theMats.count collect #()
for obj in selectObjs do (
local posMat = findItem theMats obj.material
if posMat!=0 do append objByMatArray[posMat] obj.name
)
objByMatArray
)

objByMat selection

hblan
03-08-2006, 03:40 AM
yes , i have read the topic , learned more ,thanks .

by the way ,arketip`s head portrait makes me missing my friend "prettyPixel" . :)

arketip
03-08-2006, 12:17 PM
Yes it's me :)

My hypothesis is that the access to 'sceneMaterials' is slower in 3DSmax5. This is why I store it in an array. That is just an hypothesis...

CGTalk Moderation
03-08-2006, 12:17 PM
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.