def smoothPoints(num = 5, push = 0.05):
"""
tries to smooth the surrounding pts around an outlier cv
num = number of points on either side to affect
push = amount to push out along tangent
"""
tgtPts = cmds.ls(sl=True, fl=True)
for tgtPt in tgtPts:
tgtPtPos = cmds.pointPosition(tgtPt)
tgtNum = int(tgtPt.partition("[")[2].rpartition("]")[0])
tgtBase = tgtPt.partition("[")[0]
#crv = tgtBase.partition(".")[0]
tgtTan = getNormalizedTangent(tgtPt)
for x in range(-num, num+1):
if x != 0:
origPt = "{0}[{1}]".format(tgtBase, tgtNum + x)
origPtPos = cmds.pointPosition(origPt)
perc = (float(abs(x))/(num + 1.0))
#print origPt, perc
newPosRaw = om.MVector(*lerp(tgtPtPos, origPtPos, math.sin(perc*3.14*0.5)))
tan = om.MVector(tgtTan[0]*math.pow(1-perc/num, num)*push, tgtTan[1]*math.pow(1-perc/num, num)*push, tgtTan[2]*math.pow(1-perc/num, num)*push)
#tan = om.MVector(tgtTan[0]*push, tgtTan[1]*push, tgtTan[2]*push)
if x<0:
newPos = newPosRaw + tan
if x>0:
newPos = newPosRaw - tan
#print origPt, newPosRaw.x, newPosRaw.y, newPosRaw.z
cmds.xform(origPt, ws=True, t=newPos)
评论列表
文章目录