Optimize and increase speed of script
Was wondering if some of you scripters out there could help me improve the speed at which this script processes. All it does is collect the number of verts used in each smoothing group and then returns the total number of verts.
-- Returns actual smoothing group number fn getFaceSmoothGroupB obj face = ( local sgroup_val=getFaceSmoothGroup obj face local sg_bitarray=#{} if sgroup_val < 0 do ( sg_bitarray[32]=true sgroup_val -= 2^31 ) for i = 1 to 31 do ( sg_bitarray[i]= (mod sgroup_val 2 > .5) sgroup_val /= 2 ) local sgAsArr = sg_bitarray as array sgAsArr[1] ) -- Get count of smoothing group verts per geo vert fn getVertCountForSG obj vert = ( local faceArr = meshop.getFacesUsingVert obj vert as array local sgArr = #() for i in faceArr do ( local sg1 = getFaceSmoothGroupB obj i if findItem sgArr sg1 == 0 then append sgArr sg1 for j in faceArr do ( if i == j then continue local sg2 = getFaceSmoothGroupB obj j if sg1 != sg2 and findItem sgArr sg1 == 0 then append sgArr sg1 ) ) sgArr.count ) t1 = timestamp() m1 = heapfree -------------------------------------------------------------- tp = teapot smooth:false radius:5 objMesh = tp.mesh _numMeshVerts = objMesh.numVerts _totalSGrpVerts = 0 for i = 1 to _numMeshVerts do ( _sgrpVerts = getVertCountForSG objMesh i _totalSGrpVerts += _sgrpVerts ) --------------------------------------------------------------- clearlistener() format "% -- %\n" selection[1].name _totalSGrpVerts format "time:% memory:%\n" (timestamp() - t1) (m1 - heapfree)