Skip to content

Instantly share code, notes, and snippets.

Avatar

Glenn Maynard zewt

View GitHub Profile
@zewt
zewt / gist:73bd5f83927f3ccf20c32cf0440120a4
Created Aug 19, 2020
Reset bind position to joint position
View gist:73bd5f83927f3ccf20c32cf0440120a4
# Public domain
from pymel import core as pm
import re
def resetJointOnCluster(joint, skinClusterPreMatrixPlug):
inverseMatrix = joint.attr('worldInverseMatrix').get()
curMatrix = skinClusterPreMatrixPlug.get()
if curMatrix is not None:
different = any(abs(a-b) > 0.00001 for a, b in zip(inverseMatrix, curMatrix))
View gist:7090ed6aa800109b8019e596280406ac
# Public domain
import pymel.core as pm
from pymel import core as pm
from maya.api import OpenMaya as om
def getSkinClusterConnection(node):
for conn in pm.listConnections(node.attr('worldMatrix'), d=True, s=False, p=True, type='skinCluster') or []:
skinCluster = conn.node()
idx = conn.index()
View gist:8c8ea3f0589b3235e1f09f6173e4ad07
namespace std
{
// Compare two MObjects. This allows them to be used as keys in std::map.
template<>
struct less<MObject>
{
size_t operator()(const MObject &lhs, const MObject &rhs) const;
};
// A hash for MObject. This allows them to be used as keys in std::unordered_map.
@zewt
zewt / gist:4f5e54d20839697c94df0afbf67e41a9
Created Apr 3, 2018
Aborted Maya pick walking script
View gist:4f5e54d20839697c94df0afbf67e41a9
import sys
import pymel.core as pm
def pick_walk(direction, add=False):
nodes = pm.ls(sl=True)
new_nodes = []
non_dag_nodes = []
for node in nodes:
# Make a list of non-DAG nodes.
if not isinstance(node, pm.nodetypes.DagNode):
@zewt
zewt / gist:b4829c63500de72682785dc40a9cb4c6
Created Dec 20, 2017
Remap animation sources in Maya's time editor
View gist:b4829c63500de72682785dc40a9cb4c6
import pymel.core as pm
def remap_clip(clip_name, new_anim_source):
clip_id = pm.timeEditorClip(clip_name, q=True, clipIdFromNodeName=True)
print 'Remapping clip:', clip_name
sources = pm.timeEditorClip(clip_id, q=True, remappedSourceAttrs=True)
source_indices, source_paths = sources[0::2], sources[1::2]
# targets = pm.timeEditorClip(clip_id, q=True, remappedTargetAttrs=True)
@zewt
zewt / gist:5323bbf8f46ef161b20601c75052948a
Created Dec 6, 2017
Python script to give 10000 Eden tokens in Binding of Isaac
View gist:5323bbf8f46ef161b20601c75052948a
# This gives 10000 Eden tokens.
import struct
CrcTable = [ 0x00000000L, 0x09073096L, 0x120E612CL, 0x1B0951BAL, 0xFF6DC419L, 0xF66AF48FL, 0xED63A535L, 0xE46495A3L, 0xFEDB8832L, 0xF7DCB8A4L, 0xECD5E91EL, 0xE5D2D988L, 0x01B64C2BL, 0x08B17CBDL, 0x13B82D07L, 0x1ABF1D91L, 0xFDB71064L, 0xF4B020F2L, 0xEFB97148L, 0xE6BE41DEL, 0x02DAD47DL, 0x0BDDE4EBL, 0x10D4B551L, 0x19D385C7L, 0x036C9856L, 0x0A6BA8C0L, 0x1162F97AL, 0x1865C9ECL, 0xFC015C4FL, 0xF5066CD9L, 0xEE0F3D63L, 0xE7080DF5L, 0xFB6E20C8L, 0xF269105EL, 0xE96041E4L, 0xE0677172L, 0x0403E4D1L, 0x0D04D447L, 0x160D85FDL, 0x1F0AB56BL, 0x05B5A8FAL, 0x0CB2986CL, 0x17BBC9D6L, 0x1EBCF940L, 0xFAD86CE3L, 0xF3DF5C75L, 0xE8D60DCFL, 0xE1D13D59L, 0x06D930ACL, 0x0FDE003AL, 0x14D75180L, 0x1DD06116L, 0xF9B4F4B5L, 0xF0B3C423L, 0xEBBA9599L, 0xE2BDA50FL, 0xF802B89EL, 0xF1058808L, 0xEA0CD9B2L, 0xE30BE924L, 0x076F7C87L, 0x0E684C11L, 0x15611DABL, 0x1C662D3DL, 0xF6DC4190L, 0xFFDB7106L, 0xE4D220BCL, 0xEDD5102AL, 0x09B18589L, 0x00B6B51FL, 0x1BBFE4A5L, 0x12B8D433L, 0x0807C9A2L, 0x0100F934L, 0
View gist:f8d8d90b70bd406ea71250d4db5713bd
Don't nest conditionals when you can return. Don't do this:
int do_task()
{
if(get_task())
{
// Success. Do lots of stuff with the data.
// (insert 30 lines of code here)
return n;
} else {
You can’t perform that action at this time.