I wonder… The results on my tests are as I previously mentioned. I suppose you are testing both functions together (mine first) without rebuilding the whole test case.
In that case the function you test at last, will appear to be faster. But try the following test and put back your result please.
(
fn uvToMesh node channel:1 scaleFactor:1.0 =
(
_mesh = snapshotasmesh node
sc = point3 scaleFactor scaleFactor scaleFactor
verts = for v=1 to meshop.getnummapverts _mesh channel collect (meshop.getmapvert _mesh channel v)*sc
faces = for f=1 to meshop.getnummapfaces _mesh channel collect meshop.getmapface _mesh channel f
mesh name:(node.name + "_uvmesh") vertices:verts faces:faces
)
fn BuildUvMesh node channel:1 fixelements:false size:1.0 realscale:true =
(
local m1 = snapshotasmesh node
local numtverts = meshop.getnummapverts m1 channel
local getmapvert = meshop.getmapvert
local getmapface = meshop.getmapface
local verts = for j = 1 to numtverts collect (getmapvert m1 channel j)*[size,size,0]
meshop.setnumverts m1 numtverts
meshop.setvert m1 #{1..numtverts} verts
for j = 1 to m1.numfaces do
(
face = getmapface m1 channel j
setface m1 j face[1] face[2] face[3]
)
mesh mesh:m1
delete m1
gc light:true
)
for nn = 1 to 2 do
(
delete objects
b = box()
modi = Unwrap_UVW()
addmodifier b modi
max modify mode
select b
modpanel.setcurrentobject modi
modi.flattenMapNoParams()
max create mode
clearselection()
addmodifier b (tessellate tension:0 iterations:3)
addmodifier b (tessellate tension:0 iterations:1)
gc()
st = timestamp(); sh = heapfree
if nn == 1 then uvToMesh b scaleFactor:100.0
else BuildUvMesh b size:100.0
format "faces:% time:% memory:%
" b.numfaces (timestamp()-st) (sh-heapfree)
)
)
I’ve tested with 3 and 4 iterations on this line:
addmodifier b (tessellate tension:0 iterations:3)
3 Iterations
faces:49152 time:94 memory:9569776L
faces:49152 time:118 memory:1654936L
4 Iterations
faces:196608 time:1174 memory:37993360L
faces:196608 time:1225 memory:6422696L