work
save startup to fix blender opening on 2nd monitor
This commit is contained in:
@@ -2,7 +2,8 @@ import bpy
|
||||
import os
|
||||
import numpy as np
|
||||
from bpy_extras import anim_utils
|
||||
import sys
|
||||
import bisect
|
||||
# import sys
|
||||
|
||||
from bpy.app.handlers import persistent
|
||||
from . import bake_ops
|
||||
@@ -270,6 +271,7 @@ def register_layers(obj, nla_tracks):
|
||||
continue
|
||||
strip = track.strips[0]
|
||||
use_animated_influence(strip)
|
||||
strip.influence = 1
|
||||
|
||||
#updating the ui list with the nla track names
|
||||
def visible_layers(obj, nla_tracks):
|
||||
@@ -342,15 +344,20 @@ def use_animated_influence(strip):
|
||||
return
|
||||
fcu_len = len(strip.fcurves)
|
||||
strip.use_animated_influence = True
|
||||
|
||||
if fcu_len != len(strip.fcurves):
|
||||
if hasattr(strip.fcurves[0].keyframe_points, 'clear'):
|
||||
strip.fcurves[0].keyframe_points.clear()
|
||||
else:
|
||||
keyframe = strip.fcurves[0].keyframe_points[0]
|
||||
strip.fcurves[0].keyframe_points.remove(keyframe)
|
||||
|
||||
strip.influence = 1
|
||||
if len(strip.fcurves[0].keyframe_points):
|
||||
keyframes = strip.fcurves[0].keyframe_points
|
||||
# value = keyframes[0].co.y
|
||||
# print('influence value ', keyframes[0])
|
||||
if hasattr(keyframes, 'clear'):
|
||||
keyframes.clear()
|
||||
else:
|
||||
keyframe = keyframes[0]
|
||||
keyframes.remove(keyframe)
|
||||
|
||||
strip.influence = 1
|
||||
|
||||
def check_override_layers(obj):
|
||||
if obj.override_library is None:
|
||||
return False
|
||||
@@ -1291,6 +1298,7 @@ def load_action(self, context):
|
||||
subscriptions.frameend_update_callback()
|
||||
strip.use_sync_length = False
|
||||
use_animated_influence(strip)
|
||||
strip.influence = 1
|
||||
return
|
||||
subscriptions.subscriptions_remove()
|
||||
strip = track.strips[0]
|
||||
@@ -1941,6 +1949,7 @@ def add_animlayer(layer_name = 'Anim_Layer' , duplicate = False, index = 1, blen
|
||||
new_strip.blend_type = blend_type
|
||||
new_strip.use_sync_length = False
|
||||
use_animated_influence(new_strip)
|
||||
new_strip.influence = 1
|
||||
|
||||
return new_track
|
||||
|
||||
@@ -2324,12 +2333,13 @@ class ShareLayerKeys(bpy.types.Operator):
|
||||
|
||||
#if the group doesn't exist in the current layer then create one and assign it
|
||||
if fcu.group is None:
|
||||
if group.name in anim_data.action.groups:
|
||||
new_group = anim_data.action.groups[group.name]
|
||||
else:
|
||||
new_group = anim_data.action.groups.new(group.name)
|
||||
new_group = add_group_to_fcurve(obj, fcu, group.name)
|
||||
# if group.name in anim_data.action.groups:
|
||||
# new_group = anim_data.action.groups[group.name]
|
||||
# else:
|
||||
# new_group = anim_data.action.groups.new(group.name)
|
||||
|
||||
fcu.group = new_group
|
||||
# fcu.group = new_group
|
||||
|
||||
#exclude the frames that already exist in the current layer action fcurve
|
||||
if len(fcu.keyframe_points):
|
||||
@@ -2771,6 +2781,110 @@ def sync_frame_range(context):
|
||||
if use_frame_range:
|
||||
action.use_frame_range = True
|
||||
|
||||
class InfluenceNextKeyframe(bpy.types.Operator):
|
||||
"""Select the influence keyframes of the current layer"""
|
||||
bl_idname = "anim.influence_next_key"
|
||||
bl_label = "Move to the next influence keyframe"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
anim_data = anim_data_type(context.object)
|
||||
return hasattr(anim_data,"nla_tracks") and len(anim_data.nla_tracks[context.object.als.layer_index].strips)
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
strips = influence_get_strips(context)
|
||||
|
||||
current_frame = context.scene.frame_current
|
||||
# The next keyframes from all the strips together
|
||||
next_keyframes = []
|
||||
|
||||
#Assign selection to all strips
|
||||
for strip in strips:
|
||||
for fcu in strip.fcurves:
|
||||
if fcu.data_path != 'influence':
|
||||
continue
|
||||
if not len(fcu.keyframe_points):
|
||||
continue
|
||||
keys_len = len(fcu.keyframe_points)
|
||||
|
||||
#Get the selection of the current keys or the next one in the list
|
||||
keyframes = np.zeros(keys_len*2)
|
||||
fcu.keyframe_points.foreach_get('co', keyframes)
|
||||
frames = keyframes[::2]
|
||||
next_i = bisect.bisect_right(frames, current_frame)
|
||||
if next_i >= len(frames):
|
||||
continue
|
||||
next_frame = frames[next_i]
|
||||
next_keyframes.append(next_frame)
|
||||
|
||||
if not len(next_keyframes):
|
||||
return {'CANCELLED'}
|
||||
next_keyframes.sort()
|
||||
|
||||
next_i = bisect.bisect_right(next_keyframes, current_frame)
|
||||
if next_i >= len(next_keyframes):
|
||||
return {'CANCELLED'}
|
||||
|
||||
next_frame = next_keyframes[next_i]
|
||||
|
||||
context.scene.frame_set(int(next_frame))
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
class InfluencePrevKeyframe(bpy.types.Operator):
|
||||
"""Select the influence keyframes of the current layer"""
|
||||
bl_idname = "anim.influence_prev_key"
|
||||
bl_label = "Move to the previous influence keyframe"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
anim_data = anim_data_type(context.object)
|
||||
return hasattr(anim_data,"nla_tracks") and len(anim_data.nla_tracks[context.object.als.layer_index].strips)
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
strips = influence_get_strips(context)
|
||||
|
||||
current_frame = context.scene.frame_current
|
||||
# The prev keyframes from all the strips together
|
||||
prev_keyframes = []
|
||||
|
||||
#Assign selection to all strips
|
||||
for strip in strips:
|
||||
for fcu in strip.fcurves:
|
||||
if fcu.data_path != 'influence':
|
||||
continue
|
||||
if not len(fcu.keyframe_points):
|
||||
continue
|
||||
keys_len = len(fcu.keyframe_points)
|
||||
|
||||
#Get the selection of the current keys or the prev one in the list
|
||||
keyframes = np.zeros(keys_len*2)
|
||||
fcu.keyframe_points.foreach_get('co', keyframes)
|
||||
frames = keyframes[::2]
|
||||
prev_i = bisect.bisect_left(frames, current_frame)
|
||||
if prev_i:
|
||||
prev_i -= 1
|
||||
prev_frame = frames[prev_i]
|
||||
prev_keyframes.append(prev_frame)
|
||||
|
||||
if not len(prev_keyframes):
|
||||
return {'CANCELLED'}
|
||||
prev_keyframes.sort()
|
||||
|
||||
prev_i = bisect.bisect_left(prev_keyframes, current_frame)
|
||||
if prev_i:
|
||||
prev_i -= 1
|
||||
|
||||
prev_frame = prev_keyframes[prev_i]
|
||||
context.scene.frame_set(int(prev_frame))
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class SelectInfluenceKeys(bpy.types.Operator):
|
||||
"""Select the influence keyframes of the current layer"""
|
||||
bl_idname = "anim.select_influence_keys"
|
||||
@@ -2921,8 +3035,8 @@ def panelFactory(space_type):
|
||||
|
||||
track = anim_data.nla_tracks[obj.als.layer_index]
|
||||
|
||||
col=layout.column(align = True)
|
||||
row = col.row()
|
||||
# col=layout.column(align = True)
|
||||
row = layout.row(align = True)
|
||||
|
||||
if not len(track.strips):
|
||||
return
|
||||
@@ -2933,18 +3047,22 @@ def panelFactory(space_type):
|
||||
#Drawing the influence slider
|
||||
if len(strip.fcurves[0].keyframe_points) and not strip.fcurves[0].mute:
|
||||
row.prop(strip, 'influence', slider = True, text = 'Influence')
|
||||
row.operator('anim.influence_prev_key', text = '', icon = 'PREV_KEYFRAME')
|
||||
row.separator(factor = 0.1)
|
||||
row.operator('anim.influence_next_key', text = '', icon = 'NEXT_KEYFRAME')
|
||||
else:
|
||||
row.prop(context.scene.als, 'influence', slider = True, text = 'Influence')
|
||||
# row.prop(obj.Anim_Layers[obj.als.layer_index], 'influence', slider = True, text = 'Influence')
|
||||
|
||||
#Influence SETTINGS
|
||||
row.separator(factor = 1.5)
|
||||
row.prop(context.scene.als, 'influence_settings', text ='', icon = 'SETTINGS')
|
||||
if context.scene.als.influence_settings:
|
||||
split = layout.split(factor = 0.4)
|
||||
global_local = 'Global' if context.scene.als.influence_global == True else 'Local'
|
||||
split.prop(context.scene.als, 'influence_global', text = global_local, toggle = True)
|
||||
|
||||
row = split.row()
|
||||
row = split.row(align = True)
|
||||
row.alignment = 'RIGHT'
|
||||
#Drawing Select influence keys
|
||||
row.operator('anim.select_influence_keys', text="", icon = 'RESTRICT_SELECT_OFF')
|
||||
@@ -2957,6 +3075,7 @@ def panelFactory(space_type):
|
||||
mute_icon = 'MUTE_IPO_OFF' if track.strips[0].fcurves[0].mute else 'MUTE_IPO_ON'
|
||||
row.prop(obj.als, 'influence_mute', icon_only=True, icon = mute_icon)
|
||||
|
||||
row.separator(factor = 1.5)
|
||||
lock_icon = 'DECORATE_LOCKED' if strip.fcurves[0].lock else 'DECORATE_UNLOCKED'
|
||||
row.prop(obj.als, 'influence_lock', icon_only=True, icon = lock_icon)
|
||||
|
||||
@@ -3289,7 +3408,7 @@ def remove_empty_slots(action):
|
||||
|
||||
classes = (AutoCustomFrameRange, ResetLayerKeyframes, LAYERS_UL_list, AddAnimLayer, ExtractSelection, ExtractMarkers, DuplicateAnimLayer, RemoveAnimLayer, CyclicFcurves, RemoveFcurves, MoveAnimLayerUp,
|
||||
MoveAnimLayerDown, SelectBonesInLayer, ClearNLA, ClearActiveAction, OverrideError, AddAction, SyncActionLength, RemoveAction, ShareLayerKeys, SelectInfluenceKeys,
|
||||
AddSlot, RemoveSlot, EditAllLayersOperator)
|
||||
AddSlot, RemoveSlot, EditAllLayersOperator, InfluencePrevKeyframe, InfluenceNextKeyframe)
|
||||
|
||||
spaceTypes = ['VIEW_3D', 'GRAPH_EDITOR', 'DOPESHEET_EDITOR', 'NLA_EDITOR']
|
||||
# panel_classes = (cls for spaceType in spaceTypes for cls in panelFactory(spaceType))
|
||||
|
||||
Reference in New Issue
Block a user