Notifications
Clear all

[Closed] Memory leak when creating faces in Editable Poly?

I am trying to create faces in an Editable_Poly, but have found that both the createFace and createPolygon commands seem to have weird performance issues and become slower the more often they’re used. Here’s an example:

curObj = editable_mesh name:"NewGeo" select:true
convertToPoly curObj
select $NewGeo
setCommandPanelTaskMode #modify

for loop=1 to 10 do (
    t1 = timeStamp()

    cnv = curObj.createVertex
    cnf = curObj.createFace

    allNewVrtPos = for i=1 to 200 collect ( z = i * 0.1 ; #([1,(loop),z],[0,(1+loop),z],[0,(loop),z]))
    for posGrp in allNewVrtPos do (
        newVrtIdx = for i=1 to 3 collect (cnv posGrp[i] pointInLocalCoords:false select:false)
        cnf newVrtIdx select:false
    )

    format "maxscript\nresult:%\ntime:% ms\n" test (timeStamp() - t1)
)

For me the first stack of polygons takes 21ms, and then each new one takes 20-40ms longer then the previous.
Could someone help me to understand what I’m doing wrong, or if there’s a completely different way I should be constructing faces in an editable poly?

4 Replies

the time needed is unpredictable , but not more and more
what you need is disable Undo system

if you can do it in editable mesh, editable poly is extremely flakey and cannot be trusted.

Maybe the problem is because the “editable poly data” has to be updated, so next time when you create new faces MAX has to update data for all existing faces + the new one(for example 100 old + 10 new faces). The next time MAX has to update 110 old + 10 new faces and so on.

Thanks for the input guys.

Sadly looks like miauu is right, and creating faces via Maxscipt is going to be very slow on all but the simplest of models. The strangest thing though is that doing the same thing on an Edit_Poly modifier is 2-3 faster then on a regular Editable Poly, while I’m used to it being the complete opposite.