Skip to content

Commit 0515ef9

Browse files
authored
Merge pull request #2 from korarei/refactor/center
Refactor: Change method of retrieving center coordinates
2 parents 23a9903 + 48e755d commit 0515ef9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

scripts/ObjectMotionBlur_LK_template.anm2

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
--track@t6:Object ID,0,15000,0,1
1111
--track@t5:Mix,0,100,0,0.01
1212
--check@c2:Print Information,0
13-
--track0:X Center,-10000,10000,0,0.01
14-
--track1:Y Center,-10000,10000,0,0.01
1513
--value@_0:PI,{}
1614
--[[pixelshader@motion_blur:
1715
${SHADER_MOTION_BLUR}
1816
]]
1917

18+
if (not pcall(obj.getvalue, "cx")) then
19+
debug_print("AviUtl ExEdit2 beta12 or later is required.")
20+
return
21+
end
22+
2023
local function tobool(v, d)
2124
if (type(v) == "boolean") then
2225
return v
@@ -38,8 +41,6 @@ local geo_ctrl = tonumber(_0.geo_ctrl or s2) s2 = nil
3841
local obj_id = tonumber(_0.object_id) or t6 t6 = nil -- beta 11a
3942
local mix = math.min(math.max(tonumber(_0.mix) or t5, 0.0), 100.0) * 0.01 t5 = nil
4043
local print_info = tobool(_0.print_info, c2 ~= 0) c2 = nil
41-
local cx = (tonumber(_0.cx) or obj.track0) -- beta 11a
42-
local cy = (tonumber(_0.cy) or obj.track1) -- beta 11a
4344
_0 = nil
4445

4546
local ffi = require("ffi")
@@ -84,12 +85,17 @@ local Output = ffi.typeof("Output")
8485
local gv = obj.getvalue
8586

8687
local dll_path = obj.getinfo("script_path") .. "ObjectMotionBlur_LK.dll"
87-
local lib = ffi.load(dll_path)
88+
local ok, lib = pcall(ffi.load, dll_path)
89+
if (not ok) then
90+
debug_print("Dynamic library not found. Hint: Ensure the file path contains only ASCII characters.")
91+
return
92+
end
8893

8994
local smp_lim = (preview_smp_lim == 0 or obj.getinfo("saving")) and render_smp_lim or preview_smp_lim
9095
local w, h = obj.getpixel()
96+
local cx, cy = gv("cx"), gv("cy")
9197
local dt = 1.0 / obj.framerate
92-
local targets = {0, 1, "x", "y", "rz", "zoom"}
98+
local targets = {"cx", "cy", "x", "y", "rz", "zoom"}
9399

94100
local param = Param(shutter_angle, smp_lim, ext, resize, geo_cache, geo_ctrl)
95101

0 commit comments

Comments
 (0)