Use words_separated instead of mixedCase for common functions
This commit is contained in:
104
common.py
104
common.py
@ -2,7 +2,7 @@ import bpy
|
||||
import mathutils
|
||||
|
||||
|
||||
def getArmatureData(context):
|
||||
def get_armature_data(context):
|
||||
try:
|
||||
arm_object = context.active_object
|
||||
if arm_object and arm_object.type == "ARMATURE":
|
||||
@ -15,18 +15,18 @@ def getArmatureData(context):
|
||||
return None, None
|
||||
|
||||
|
||||
def getArmatureAction(context):
|
||||
def get_armature_action(context):
|
||||
try:
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
arm_object, pose_library = get_armature_data(context)
|
||||
if getattr(arm_object.animation_data.action, "pose_markers", None):
|
||||
return getattr(arm_object.animation_data, "action", None)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def searchPoseMarker(context, posename, type):
|
||||
def search_pose_marker(context, posename, type):
|
||||
try:
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
arm_object, pose_library = get_armature_data(context)
|
||||
if type == "marker":
|
||||
return pose_library.pose_markers.get(posename, None)
|
||||
if type == "frame":
|
||||
@ -37,8 +37,8 @@ def searchPoseMarker(context, posename, type):
|
||||
pass
|
||||
|
||||
|
||||
def findFcurve(context, bone_name, transform, index_int):
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
def find_fcurve(context, bone_name, transform, index_int):
|
||||
arm_object, pose_library = get_armature_data(context)
|
||||
pose_markers = pose_library.pose_markers
|
||||
active_frame = pose_markers.active.frame
|
||||
|
||||
@ -50,8 +50,8 @@ def findFcurve(context, bone_name, transform, index_int):
|
||||
return None
|
||||
|
||||
|
||||
def createFcurve(context, bone_name, transform, index_int):
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
def create_fcurve(context, bone_name, transform, index_int):
|
||||
arm_object, pose_library = get_armature_data(context)
|
||||
pose_markers = pose_library.pose_markers
|
||||
|
||||
try:
|
||||
@ -62,8 +62,8 @@ def createFcurve(context, bone_name, transform, index_int):
|
||||
pass
|
||||
|
||||
|
||||
def createKeyframe(context, bone_name, transform, index_int, new_marker, loc):
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
def create_keyframe(context, bone_name, transform, index_int, new_marker, loc):
|
||||
arm_object, pose_library = get_armature_data(context)
|
||||
pose_markers = pose_library.pose_markers
|
||||
|
||||
try:
|
||||
@ -74,7 +74,7 @@ def createKeyframe(context, bone_name, transform, index_int, new_marker, loc):
|
||||
pass
|
||||
|
||||
|
||||
def setKeyframesFromBones(context, arm_object, new_marker):
|
||||
def set_keyframes_from_bones(context, arm_object, new_marker):
|
||||
none_selected = True
|
||||
for bone in arm_object.pose.bones:
|
||||
if bone.bone.select:
|
||||
@ -99,47 +99,47 @@ def setKeyframesFromBones(context, arm_object, new_marker):
|
||||
loc_x = bone.location[0]
|
||||
loc_y = bone.location[1]
|
||||
loc_z = bone.location[2]
|
||||
createFcurve(context, bone_name, "location", 0)
|
||||
createFcurve(context, bone_name, "location", 1)
|
||||
createFcurve(context, bone_name, "location", 2)
|
||||
createKeyframe(context, bone_name, "location", 0, new_marker, loc_x)
|
||||
createKeyframe(context, bone_name, "location", 1, new_marker, loc_y)
|
||||
createKeyframe(context, bone_name, "location", 2, new_marker, loc_z)
|
||||
create_fcurve(context, bone_name, "location", 0)
|
||||
create_fcurve(context, bone_name, "location", 1)
|
||||
create_fcurve(context, bone_name, "location", 2)
|
||||
create_keyframe(context, bone_name, "location", 0, new_marker, loc_x)
|
||||
create_keyframe(context, bone_name, "location", 1, new_marker, loc_y)
|
||||
create_keyframe(context, bone_name, "location", 2, new_marker, loc_z)
|
||||
if rot_mode == "rotation_quaternion":
|
||||
rot_w = bone.rotation_quaternion[0]
|
||||
rot_x = bone.rotation_quaternion[1]
|
||||
rot_y = bone.rotation_quaternion[2]
|
||||
rot_z = bone.rotation_quaternion[3]
|
||||
createFcurve(context, bone_name, rot_mode, 0)
|
||||
createFcurve(context, bone_name, rot_mode, 1)
|
||||
createFcurve(context, bone_name, rot_mode, 2)
|
||||
createFcurve(context, bone_name, rot_mode, 3)
|
||||
createKeyframe(context, bone_name, rot_mode, 0, new_marker, rot_w)
|
||||
createKeyframe(context, bone_name, rot_mode, 1, new_marker, rot_x)
|
||||
createKeyframe(context, bone_name, rot_mode, 2, new_marker, rot_y)
|
||||
createKeyframe(context, bone_name, rot_mode, 3, new_marker, rot_z)
|
||||
create_fcurve(context, bone_name, rot_mode, 0)
|
||||
create_fcurve(context, bone_name, rot_mode, 1)
|
||||
create_fcurve(context, bone_name, rot_mode, 2)
|
||||
create_fcurve(context, bone_name, rot_mode, 3)
|
||||
create_keyframe(context, bone_name, rot_mode, 0, new_marker, rot_w)
|
||||
create_keyframe(context, bone_name, rot_mode, 1, new_marker, rot_x)
|
||||
create_keyframe(context, bone_name, rot_mode, 2, new_marker, rot_y)
|
||||
create_keyframe(context, bone_name, rot_mode, 3, new_marker, rot_z)
|
||||
elif rot_mode == "rotation_euler":
|
||||
rot_x = bone.rotation_euler[0]
|
||||
rot_y = bone.rotation_euler[1]
|
||||
rot_z = bone.rotation_euler[2]
|
||||
createFcurve(context, bone_name, rot_mode, 0)
|
||||
createFcurve(context, bone_name, rot_mode, 1)
|
||||
createFcurve(context, bone_name, rot_mode, 2)
|
||||
createKeyframe(context, bone_name, rot_mode, 0, new_marker, rot_x)
|
||||
createKeyframe(context, bone_name, rot_mode, 1, new_marker, rot_y)
|
||||
createKeyframe(context, bone_name, rot_mode, 2, new_marker, rot_z)
|
||||
create_fcurve(context, bone_name, rot_mode, 0)
|
||||
create_fcurve(context, bone_name, rot_mode, 1)
|
||||
create_fcurve(context, bone_name, rot_mode, 2)
|
||||
create_keyframe(context, bone_name, rot_mode, 0, new_marker, rot_x)
|
||||
create_keyframe(context, bone_name, rot_mode, 1, new_marker, rot_y)
|
||||
create_keyframe(context, bone_name, rot_mode, 2, new_marker, rot_z)
|
||||
scl_x = bone.scale[0]
|
||||
scl_y = bone.scale[1]
|
||||
scl_z = bone.scale[2]
|
||||
createFcurve(context, bone_name, "scale", 0)
|
||||
createFcurve(context, bone_name, "scale", 1)
|
||||
createFcurve(context, bone_name, "scale", 2)
|
||||
createKeyframe(context, bone_name, "scale", 0, new_marker, scl_x)
|
||||
createKeyframe(context, bone_name, "scale", 1, new_marker, scl_y)
|
||||
createKeyframe(context, bone_name, "scale", 2, new_marker, scl_z)
|
||||
create_fcurve(context, bone_name, "scale", 0)
|
||||
create_fcurve(context, bone_name, "scale", 1)
|
||||
create_fcurve(context, bone_name, "scale", 2)
|
||||
create_keyframe(context, bone_name, "scale", 0, new_marker, scl_x)
|
||||
create_keyframe(context, bone_name, "scale", 1, new_marker, scl_y)
|
||||
create_keyframe(context, bone_name, "scale", 2, new_marker, scl_z)
|
||||
|
||||
|
||||
def setBonesfromKeyframes(context, arm_object, active_marker):
|
||||
def set_bones_from_keyframes(context, arm_object, active_marker):
|
||||
none_selected = True
|
||||
for bone in arm_object.pose.bones:
|
||||
if bone.bone.select:
|
||||
@ -161,21 +161,21 @@ def setBonesfromKeyframes(context, arm_object, active_marker):
|
||||
self.report({'WARNING'}, "DSPL: Unsupported bone: " + bone.name + ": " + bone.rotation_mode)
|
||||
rot_mode = None
|
||||
|
||||
loc_x = findFcurve(context, bone_name, "location", 0) or 0.0
|
||||
loc_y = findFcurve(context, bone_name, "location", 1) or 0.0
|
||||
loc_z = findFcurve(context, bone_name, "location", 2) or 0.0
|
||||
loc_x = find_fcurve(context, bone_name, "location", 0) or 0.0
|
||||
loc_y = find_fcurve(context, bone_name, "location", 1) or 0.0
|
||||
loc_z = find_fcurve(context, bone_name, "location", 2) or 0.0
|
||||
if rot_mode == "rotation_quaternion":
|
||||
rot_w = findFcurve(context, bone_name, rot_mode, 0) or 1.0
|
||||
rot_x = findFcurve(context, bone_name, rot_mode, 1) or 0.0
|
||||
rot_y = findFcurve(context, bone_name, rot_mode, 2) or 0.0
|
||||
rot_z = findFcurve(context, bone_name, rot_mode, 3) or 0.0
|
||||
rot_w = find_fcurve(context, bone_name, rot_mode, 0) or 1.0
|
||||
rot_x = find_fcurve(context, bone_name, rot_mode, 1) or 0.0
|
||||
rot_y = find_fcurve(context, bone_name, rot_mode, 2) or 0.0
|
||||
rot_z = find_fcurve(context, bone_name, rot_mode, 3) or 0.0
|
||||
elif rot_mode == "rotation_euler":
|
||||
rot_x = findFcurve(context, bone_name, rot_mode, 0) or 0.0
|
||||
rot_y = findFcurve(context, bone_name, rot_mode, 1) or 0.0
|
||||
rot_z = findFcurve(context, bone_name, rot_mode, 2) or 0.0
|
||||
scl_x = findFcurve(context, bone_name, "scale", 0) or 1.0
|
||||
scl_y = findFcurve(context, bone_name, "scale", 1) or 1.0
|
||||
scl_z = findFcurve(context, bone_name, "scale", 2) or 1.0
|
||||
rot_x = find_fcurve(context, bone_name, rot_mode, 0) or 0.0
|
||||
rot_y = find_fcurve(context, bone_name, rot_mode, 1) or 0.0
|
||||
rot_z = find_fcurve(context, bone_name, rot_mode, 2) or 0.0
|
||||
scl_x = find_fcurve(context, bone_name, "scale", 0) or 1.0
|
||||
scl_y = find_fcurve(context, bone_name, "scale", 1) or 1.0
|
||||
scl_z = find_fcurve(context, bone_name, "scale", 2) or 1.0
|
||||
|
||||
bone.location = mathutils.Vector((loc_x, loc_y, loc_z))
|
||||
if bone.rotation_mode == "XYZ":
|
||||
|
Reference in New Issue
Block a user