Skip to content

Commit d4daea7

Browse files
committed
blender: Add a limitation hints to the panel
Hits show helpful scripting information like what the previous inserted position was, if enough time has passed to send a new command and how to get the slowest or fastest move possible.
1 parent 55b33ec commit d4daea7

2 files changed

Lines changed: 70 additions & 2 deletions

File tree

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,38 @@ Shortcuts
9393
The following keyboard shortcuts are registered (focus must be on the Video
9494
Sequencer Editor):
9595

96-
- `0-9`, `Numpad 0-9` : Insert postion at 0% - 90% at current frame.
96+
- `0-9`, `Numpad 0-9` : Insert position at 0% - 90% at current frame.
9797
- `-`, `Numpad period` : Insert position at 100% at current frame.
9898
- `` ` `` : Insert a copy of the previous stroke at current frame.
9999
- `=` : Fill up until the current frame with copies of the previous stroke.
100100

101+
Hint label descriptions
102+
-----------------------
103+
104+
In the funscripting panel there are a couple of hints displayed. These are just
105+
helpful hints, so feel free to ignore when you feel that's appropriate.
106+
107+
- **Previous**: The position of the previous action.
108+
- **Interval**: Time in ms since the previous action, icons:
109+
- *Warning triangle*: too soon, there is not enough time to technically send
110+
the action.
111+
- *Green check-mark*: sweet spot, the previous action will transition into
112+
this one.
113+
- *Clock*: there will be a 'pause' in the script, since the previous action
114+
has already finished.
115+
- **Slowest**: The amount of distance to get the slowest move possible for the
116+
current frame.
117+
- **Fastest**: The amount of distance to get the fastest move possible for the
118+
current frame.
119+
120+
The distance calculation for fastest and slowest is currently using
121+
Launchcontrol's 20-80 speed limits rules.
122+
123+
### Example
124+
125+
If previous position was 20, and the slowest hint gives 10. Inserting either 10
126+
or 30 will result in the slowest move in the specified direction.
127+
101128
Tips
102129
----
103130

funscripting.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,42 @@ def poll(cls, context):
5757
return context.selected_sequences is not None \
5858
and len(context.selected_sequences) == 1
5959

60-
def draw(self, context):
60+
def limitinfo(self, context):
61+
"""Labels with hints of the limitations"""
62+
scene = context.scene
63+
seq = context.selected_sequences[0]
64+
keyframes = launch_keyframes(seq.name)
6165
layout = self.layout
66+
row = layout.row(align=True)
67+
col = row.column(align=True)
68+
last = {"frame":0, "value":0}
69+
if keyframes is not None:
70+
for kf in reversed(keyframes):
71+
frame = kf.co[0]
72+
value = kf.co[1]
73+
if frame > scene.frame_current:
74+
continue
75+
if frame < scene.frame_current:
76+
last = {"frame":frame, "value":value}
77+
break
78+
interval = frame_to_ms(scene.frame_current) - frame_to_ms(last["frame"])
79+
icon = "FILE_TICK" if interval > 100 or last["frame"] == 0 else "ERROR"
80+
if interval > 1000:
81+
icon = "TIME"
82+
mindist = launch_distance(20, interval)
83+
maxdist = launch_distance(80, interval)
84+
col.label(text="Previous: %d" % last["value"])
85+
col = row.column(align=True)
86+
col.label("Slowest: %d" % mindist)
87+
row = layout.row(align=True)
88+
col = row.column(align=True)
89+
col.label(text="Interval: %d ms" % interval, icon=icon)
90+
col = row.column(align=True)
91+
col.label("Fastest: %d" % maxdist)
6292

93+
def draw(self, context):
94+
self.limitinfo(context)
95+
layout = self.layout
6396
for x in [0, 10, 40, 70, 100]:
6497
row = layout.row(align=True)
6598
row.alignment = 'EXPAND'
@@ -322,6 +355,14 @@ def ms_to_frame(time):
322355
fps_base = scene.render.fps_base
323356
return round(time/1000/fps_base*fps+1)
324357

358+
def launch_distance(speed, duration):
359+
"""Returns the launch movement distance for given speed and time in ms."""
360+
if speed <= 0 or duration <= 0:
361+
return 0
362+
time = pow(speed/25000, -0.95)
363+
diff = time - duration
364+
return 90 - int(diff/time*90)
365+
325366
def register():
326367
bpy.utils.register_class(FunscriptPositionButton)
327368
bpy.utils.register_class(FunscriptRepeatButton)

0 commit comments

Comments
 (0)