[Closed] autosmooth in editpoly
Hi guys.
I seem to struggle with something, that in general seems a rather simple thing.
I’m attaching several objects depening on their parent and their geometry class.
I then weld all the vertices and auto-smooth all the faces.
This happens depending on wether the objects are editMesh or editPoly (I import a vrml file from a messy source).
The edit mesh works fine (it attaches, welds and smoothes properly – only issue I still need to fix are the face orientations, but that goes for the poly as well)
the autosmooth however does not work if I try it on an editable poly. Or in only works in a very specific manner.
the relevant code is:
finalNode = objArr[1]
finalNode.weldThreshold = 0.0001
polyOp.weldVertsByThreshold finalNode #all
finalNode.autoSmoothThreshold = 30
polyOp.autoSmooth finalNode
This welds all of my vertices just fine, it does not smooth the faces though. Only if I select all of the faces (and leave them selected, or weirdly enough deselect all of them again) it applies the smoothing.
So the question is:
Is there something wrong with the code I’m using? Or do I really have to select all of the faces before applying the autoSmooth?
One issue that comes to mind is: for speed purposes all of those commands happen within a “with redraw off()” but a quick move of the smoothing outside that function didn’t help either.
Any Ideas?
poly applies autosmooth to selected faces only. so something has to be selected. in your case all faces has to be selected because you don’t know which vertices were welded.
do you think it’s slow? it shouldn’t be.
almost all poly operations perform with redraw off. actually more… they perform without update. that’s why you have to call ‘update’ method after editing the poly object.
to make everything faster try to do your editing in ‘create’ mode or on unselected poly object.
okay, so there is no way doing that without selecting. Good to know, thanks
It gets slow once I apply that on a big scene hence the redraw off. It felt slower, but I changed the code so often the speed upgrade might have been something else entirely. Will have to check once the script does everything I need
let’s do an experiment:
make a test scene:
delete objects
s = converttopoly (geosphere segments:200) -- a poly with ~800K faces
do autosmooth for all faces:
t1 = timestamp()
faces = #{1..s.numfaces}
polyop.setfaceselection s face
polyop.autosmooth s
format "count: %(%) time: %
" faces.numberset s.numverts (timestamp() - t1)
it’s ~930mc on my machine
do it for fourth of faces
t1 = timestamp()
faces = #{1..s.numfaces/4}
polyop.setfaceselection s face
polyop.autosmooth s
format "count: %(%) time: %
" faces.numberset s.numverts (timestamp() - t1)
it’s ~340mc… faster. it looks like less faces – faster smooth
but…
we can possibly know only vertices (welded) that make the faces we need to smooth. so we have to find faces using verts first:
t1 = timestamp()
faces = polyop.getfacesusingvert s #{1..s.numverts/4}
polyop.setfaceselection s faces
polyop.autosmooth s
format "count: %(%) time: %
" faces.numberset s.numfaces (timestamp() - t1)
it’s ~1450mc. it’s a fourth of all faces but because we have to find them it makes whole smooth process slower than for all faces.
i guess if your function (method) is slow it’s not because of autosmooth applied to all faces.