<commit_before>import pymel.core as pymel

from omtk.libs import libCtrlShapes
from omtk.libs import libRigging
from omtk.modules import rigFaceAvar
from omtk.modules import rigFaceAvarGrps


class CtrlJaw(rigFaceAvar.BaseCtrlFace):
    def __createNode__(self, **kwargs):
        node = libCtrlShapes.create_triangle_low()
        node.r.lock()
        node.s.lock()
        return node


class AvarJaw(rigFaceAvar.AvarSimple):
    """
    This avar is not designed to use any surface.
    """
    SHOW_IN_UI = False
    _CLS_CTRL = CtrlJaw
    IS_SIDE_SPECIFIC = False

    def get_module_name(self):
        return 'Jaw'

    def get_ctrl_tm(self, rig):
        """
        Find the chin location using raycast. This is the prefered location for the jaw doritos.
        If raycast don't return any information, use the default behavior.
        """
        ref = self.jnt.getMatrix(worldSpace=True)
        pos_s = pymel.datatypes.Point(self.jnt.getTranslation(space='world'))
        pos_e = pymel.datatypes.Point(1,0,0) * ref
        dir = pos_e - pos_s
        result = rig.raycast_farthest(pos_s, dir)
        if not result:
            return super(AvarJaw, self).get_ctrl_tm(rig)

        tm = pymel.datatypes.Matrix([1,0,0,0, 0,1,0,0, 0,0,1,0, result.x, result.y, result.z, 1])
        return tm

    def connect_ctrl(self, rig, ctrl, **kwargs):
        attr_pt_inn = ctrl.translateY
        attr_yw_inn = ctrl.translateX

        # UD Low
        attr_pt_low = libRigging.create_utility_node('multiplyDivide', input1X=attr_pt_inn, input2X=-1).outputX
        '''
        attr_pt_inn = libRigging.create_utility_node('condition', operation=4,  # Less than
                                       firstTerm=attr_pt_inn,
                                       colorIfTrueR=attr_pt_low,
                                       colorIfFalseR=0.0
                                       ).outColorR
        '''

        libRigging.connectAttr_withLinearDrivenKeys(
            attr_pt_low, self.attr_pt, kv=[0.0, 0.0, 10.0]
        )
        libRigging.connectAttr_withLinearDrivenKeys(
            attr_yw_inn, self.attr_yw, kv=[-5.0, 0.0, 5.0]
        )

    def build(self, *args, **kwargs):
        super(AvarJaw, self).build(*args, **kwargs)<commit_msg>FaceJaw: ud avar create a 45 degree opening at 1<commit_after>import pymel.core as pymel

from omtk.libs import libCtrlShapes
from omtk.libs import libRigging
from omtk.modules import rigFaceAvar
from omtk.modules import rigFaceAvarGrps


class CtrlJaw(rigFaceAvar.BaseCtrlFace):
    def __createNode__(self, **kwargs):
        node = libCtrlShapes.create_triangle_low()
        node.r.lock()
        node.s.lock()
        return node


class AvarJaw(rigFaceAvar.AvarSimple):
    """
    This avar is not designed to use any surface.
    """
    SHOW_IN_UI = False
    _CLS_CTRL = CtrlJaw
    IS_SIDE_SPECIFIC = False

    def get_module_name(self):
        return 'Jaw'

    def get_ctrl_tm(self, rig):
        """
        Find the chin location using raycast. This is the prefered location for the jaw doritos.
        If raycast don't return any information, use the default behavior.
        """
        ref = self.jnt.getMatrix(worldSpace=True)
        pos_s = pymel.datatypes.Point(self.jnt.getTranslation(space='world'))
        pos_e = pymel.datatypes.Point(1,0,0) * ref
        dir = pos_e - pos_s
        result = rig.raycast_farthest(pos_s, dir)
        if not result:
            return super(AvarJaw, self).get_ctrl_tm(rig)

        tm = pymel.datatypes.Matrix([1,0,0,0, 0,1,0,0, 0,0,1,0, result.x, result.y, result.z, 1])
        return tm

    def connect_ctrl(self, rig, ctrl, **kwargs):
        attr_pt_inn = ctrl.translateY
        attr_yw_inn = ctrl.translateX

        # UD Low
        attr_pt_low = libRigging.create_utility_node('multiplyDivide', input1X=attr_pt_inn, input2X=-1).outputX
        '''
        attr_pt_inn = libRigging.create_utility_node('condition', operation=4,  # Less than
                                       firstTerm=attr_pt_inn,
                                       colorIfTrueR=attr_pt_low,
                                       colorIfFalseR=0.0
                                       ).outColorR
        '''

        libRigging.connectAttr_withLinearDrivenKeys(
            attr_pt_low, self.attr_pt, kv=[0.0, 0.0, 45.0]
        )
        libRigging.connectAttr_withLinearDrivenKeys(
            attr_yw_inn, self.attr_yw, kv=[-5.0, 0.0, 5.0]
        )

    def build(self, *args, **kwargs):
        super(AvarJaw, self).build(*args, **kwargs)
{'fraction_non_alphanumeric': 0.09852973447443493, 'fraction_numerical': 0.016019310950186525, 'mean_word_length': 2.1874125874125876, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5275137', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1532, 'n_words': 312}