This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
import maya.api.OpenMaya as om | |
from typing import List, Optional | |
def get_locator_position(locator_name: str) -> om.MVector: | |
"""Retrieve the position of a given locator""" | |
if not cmds.objExists(locator_name): | |
raise ValueError(f"Locator '{locator_name}' does not exist.") | |
return om.MVector( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
solving for 2023 | |
((0, 2023), (7, 1792), (28, 1575), (63, 1372), (112, 1183), (175, 1008), (252, 847), (343, 700), (448, 567), (567, 448), (700, 343), (847, 252), (1008, 175), (1183, 112), (1372, 63), (1575, 28), (1792, 7), (2023, 0)) | |
solving for 897289125379227 | |
num results for the large number test: 17294404 | |
Process finished with exit code 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "-------------------------------------------" | |
import sys | |
import os | |
import platform | |
from maya import cmds | |
print "Environment info:" | |
print "Maya version:", cmds.about(installedVersion=True) | |
print "Maya API version:", cmds.about(apiVersion=True) | |
print "OS:", cmds.about(operatingSystem=True), cmds.about(operatingSystemVersion=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def curve_mapping(x, s, t): | |
""" | |
provides a linear-to-smooth curve mapping | |
based on a paper https://arxiv.org/abs/2010.09714 | |
""" | |
epsilon = 0.000001 | |
if x < 0: | |
return 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a test for Autodesk Maya to demonstrate that when skin cluster inputs are not transform nodes, | |
Maya simply crashes using MFnSkinCluster.setWeights() API call. | |
1. Run this script a few times to demonstrate that everything works as expected: you have a simple skinned mesh, | |
and you set weights for single joint, single vertex. | |
2. set "enable_bug_and_crash_maya" to True and rerun script - might need few reruns of the script. | |
Eventually, maya crashes. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cProfile | |
import pstats | |
from random import random | |
class SampleObject: | |
def __init__(self): | |
self.sample_data = random() | |
class SampleObjectNew(object): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print "-------------------------------------------" | |
import sys | |
import os | |
from maya import cmds | |
print "Environment info:" | |
print "Maya version:", cmds.about(installedVersion=True) | |
print "Maya API version:", cmds.about(apiVersion=True) | |
print cmds.about(operatingSystem=True), cmds.about(operatingSystemVersion=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ngSkinTools.importExport import JsonImporter | |
from ngSkinTools.influenceMapping import InfluenceMapping | |
from ngSkinTools.mllInterface import MllInterface | |
from ngSkinTools.ui.events import LayerEvents | |
from ngSkinTools.ui.layerDataModel import LayerDataModel | |
def ngSkinToolsImport(fileName, targetMesh): | |
''' | |
loads a JSON file (previously exported with ngSkinTools exporter) and loads data onto provided mesh. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is an example script how ngSkinTools can be automated | |
# to configure left-right influence mapping | |
# this example assumes that the scene has a skinned pPlane1 | |
# which has ngSkinTools info already initialized. if not, | |
# see http://www.ngskintools.com/documentation/api/mll-interface.html | |
# for tips to how to do that programatically | |
# for this we use "manual mapping overrides" feature: | |
# the same where you can correct automatic associations by hand, | |
# only this time we choose to 'bake' the whole mapping using the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// how I'd "fix" https://akrzemi1.wordpress.com/2017/01/02/not-detecting-bugs/ | |
// | |
// * Explicitly state "code assumes input vectors are same length" | |
// * Explicitly request inlining of loop's inner funcion | |
// * real world code will probably not use "v1, v2" naming | |
// * instead of relying "compiler will optimize away helper constructs", | |
// just don't use any. | |
// | |
// in general, it's a similar case, when instead of ... | |
// struct x = {a[++i], b[i]} |
NewerOlder