mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
make VCA animation line intensity multiplier implicit
This commit is contained in:
parent
bac0d43fd7
commit
6b36992119
2 changed files with 16 additions and 4 deletions
|
|
@ -15,7 +15,13 @@ local exclude_patters = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- TODO: replace with actual expression -> lua translator
|
-- TODO: replace with actual expression -> lua translator
|
||||||
local function process_expression(src, memoised)
|
local function process_expression(src, memoised, ismul)
|
||||||
|
if ismul then
|
||||||
|
src = string.format("(%s) * intensity + (1.0 - intensity)", src)
|
||||||
|
else
|
||||||
|
src = string.format("(%s) * intensity", src)
|
||||||
|
end
|
||||||
|
|
||||||
for i, pattern in ipairs(exclude_patters) do
|
for i, pattern in ipairs(exclude_patters) do
|
||||||
if src:find(pattern) then
|
if src:find(pattern) then
|
||||||
debug.print(exclude_patters)
|
debug.print(exclude_patters)
|
||||||
|
|
@ -127,6 +133,11 @@ for _, name in ipairs(math_funcs) do
|
||||||
env[name] = math[name]
|
env[name] = math[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
is_multiplier = {
|
||||||
|
[animation.CH_SCALE] = true,
|
||||||
|
[animation.CH_ZOOM] = true,
|
||||||
|
}
|
||||||
|
|
||||||
local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
||||||
local lines = lineset.lines
|
local lines = lineset.lines
|
||||||
local code = ""
|
local code = ""
|
||||||
|
|
@ -137,7 +148,7 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
if line.expression then
|
if line.expression then
|
||||||
code = code .. "\n local l" .. i .. " = (" ..
|
code = code .. "\n local l" .. i .. " = (" ..
|
||||||
process_expression(line.expression, memoised) .. ")"
|
process_expression(line.expression, memoised, is_multiplier[line.channel]) .. ")"
|
||||||
elseif line.keys then
|
elseif line.keys then
|
||||||
local target_keysets = keysets[lineset.target_name]
|
local target_keysets = keysets[lineset.target_name]
|
||||||
if not target_keysets then
|
if not target_keysets then
|
||||||
|
|
@ -290,7 +301,7 @@ function internals.compile_animation_track(raw_track, track_name)
|
||||||
code = memoised_code .. "\n" .. code
|
code = memoised_code .. "\n" .. code
|
||||||
end
|
end
|
||||||
|
|
||||||
local src = "return function(target, t, m)\n"
|
local src = "return function(target, t, intensity, m)\n m = m or 1\n"
|
||||||
.. code .. "\nend"
|
.. code .. "\nend"
|
||||||
|
|
||||||
if animation.TRACE_CODEGEN then
|
if animation.TRACE_CODEGEN then
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ class Time {
|
||||||
uint64_t frame = 0;
|
uint64_t frame = 0;
|
||||||
double lastTime = 0.0;
|
double lastTime = 0.0;
|
||||||
double delta = 0.0;
|
double delta = 0.0;
|
||||||
|
double timeMultiplier = 1.0;
|
||||||
public:
|
public:
|
||||||
Time() {}
|
Time() {}
|
||||||
|
|
||||||
void update(double currentTime) {
|
void update(double currentTime) {
|
||||||
frame++;
|
frame++;
|
||||||
delta = currentTime - lastTime;
|
delta = (currentTime - lastTime) * timeMultiplier;
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue