<commit_before>__author__ = '<NAME>'

import pymel.core as pm
from maya import mel

from mayaLib.rigLib.utils import name


def createFollicle(geo, u, v, prefix):
    follicleShape = pm.createNode('follicle', n=prefix+'_FLCShape')
    geoShape = geo.getShape()
    follicle = follicleShape.getParent()
    follicle.rename(prefix + '_FLC')

    pm.connectAttr(geoShape.outMesh, follicleShape.inputMesh)
    pm.connectAttr(geoShape.worldMatrix, follicleShape.inputWorldMatrix)

    pm.connectAttr(follicleShape.outRotate, follicle.rotate)
    pm.connectAttr(follicleShape.outTranslate, follicle.translate)

    follicleShape.parameterU.set(u)
    follicleShape.parameterV.set(v)

    return follicle

def findClosestUVCoordinate(geo, obj):
    closestPointOnMesh = pm.createNode("closestPointOnMesh")
    geoShape = geo.getShape()
    pm.connectAttr(geoShape.worldMesh, closestPointOnMesh.inMesh)
    pm.connectAttr(geoShape.worldMatrix, closestPointOnMesh.inputMatrix)
    loc = pm.spaceLocator(n=name.removeSuffix(geo.name())+'_LOC')
    pm.matchTransform(loc, obj)
    pm.connectAttr(loc.translate, closestPointOnMesh.inPosition)

    u = closestPointOnMesh.result.parameterU.get()
    v = closestPointOnMesh.result.parameterV.get()

    pm.delete(closestPointOnMesh, loc)

    return u, v

def makeControlFollowSkin(geo, ctrlTop):
    uv = findClosestUVCoordinate(geo, ctrlTop)
    prefix = name.removeSuffix(ctrlTop.name())
    follicle = createFollicle(geo, uv[0], uv[1], prefix)

    followGrp = pm.group(ctrlTop, n=prefix + 'Follow_GRP')
    compensateGrp = pm.group(ctrlTop, n=prefix + 'Compensate_GRP')

    pm.pointConstraint(follicle, followGrp, mo=True)

    multDivideNode = pm.createNode('multiplyDivide', n=prefix+'CompensateNode')
    pm.connectAttr(followGrp.translate, multDivideNode.input1)
    pm.connectAttr(multDivideNode.output, compensateGrp.translate)
    multDivideNode.input2X.set(-1)
    multDivideNode.input2Y.set(-1)
    multDivideNode.input2Z.set(-1)

    return follicle<commit_msg>return ctrl top group<commit_after>__author__ = '<NAME>'

import pymel.core as pm
from maya import mel

from mayaLib.rigLib.utils import name


def createFollicle(geo, u, v, prefix):
    follicleShape = pm.createNode('follicle', n=prefix+'_FLCShape')
    geoShape = geo.getShape()
    follicle = follicleShape.getParent()
    follicle.rename(prefix + '_FLC')

    pm.connectAttr(geoShape.outMesh, follicleShape.inputMesh)
    pm.connectAttr(geoShape.worldMatrix, follicleShape.inputWorldMatrix)

    pm.connectAttr(follicleShape.outRotate, follicle.rotate)
    pm.connectAttr(follicleShape.outTranslate, follicle.translate)

    follicleShape.parameterU.set(u)
    follicleShape.parameterV.set(v)

    return follicle

def findClosestUVCoordinate(geo, obj):
    closestPointOnMesh = pm.createNode("closestPointOnMesh")
    geoShape = geo.getShape()
    pm.connectAttr(geoShape.worldMesh, closestPointOnMesh.inMesh)
    pm.connectAttr(geoShape.worldMatrix, closestPointOnMesh.inputMatrix)
    loc = pm.spaceLocator(n=name.removeSuffix(geo.name())+'_LOC')
    pm.matchTransform(loc, obj)
    pm.connectAttr(loc.translate, closestPointOnMesh.inPosition)

    u = closestPointOnMesh.result.parameterU.get()
    v = closestPointOnMesh.result.parameterV.get()

    pm.delete(closestPointOnMesh, loc)

    return u, v

def makeControlFollowSkin(geo, ctrlTop):
    uv = findClosestUVCoordinate(geo, ctrlTop)
    prefix = name.removeSuffix(ctrlTop.name())
    follicle = createFollicle(geo, uv[0], uv[1], prefix)

    followGrp = pm.group(ctrlTop, n=prefix + 'Follow_GRP')
    compensateGrp = pm.group(ctrlTop, n=prefix + 'Compensate_GRP')

    pm.pointConstraint(follicle, followGrp, mo=True)

    multDivideNode = pm.createNode('multiplyDivide', n=prefix+'CompensateNode')
    pm.connectAttr(followGrp.translate, multDivideNode.input1)
    pm.connectAttr(multDivideNode.output, compensateGrp.translate)
    multDivideNode.input2X.set(-1)
    multDivideNode.input2Y.set(-1)
    multDivideNode.input2Z.set(-1)

    return followGrp, follicle
{'fraction_non_alphanumeric': 0.11297898640296662, 'fraction_numerical': 0.004449938195302843, 'mean_word_length': 4.872278664731495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3372556', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1371, 'n_words': 207}