obj.getobjectにフレーム指定引数を追加
このコミットが含まれているのは:
5ファイル変更
+118
-52
検索条件に一致するファイルはありません
@@ -59,7 +59,7 @@ namespace LuaScript
|
||||
private bool _isFirst = true;
|
||||
private ID2D1Image? _cachedInput;
|
||||
private RenderKey _cachedKey;
|
||||
private SceneObjectInfo[] _cachedSceneObjects = [];
|
||||
private SceneObjectQuery[] _cachedQueries = [];
|
||||
private DrawDescription? _cachedOutputDesc;
|
||||
private bool _cachedPixelsModified;
|
||||
|
||||
@@ -113,10 +113,10 @@ namespace LuaScript
|
||||
desc.TimelineDuration.Time.TotalSeconds,
|
||||
inDesc);
|
||||
|
||||
var sceneObjects = BuildSceneObjects(desc);
|
||||
var resolver = BuildSceneObjectResolver(desc);
|
||||
|
||||
if (!_isFirst && key == _cachedKey &&
|
||||
_cachedSceneObjects.AsSpan().SequenceEqual(sceneObjects))
|
||||
QueriesMatch(_cachedQueries, resolver))
|
||||
{
|
||||
effectOutput = _cachedPixelsModified ? _transformEffect?.Output : null;
|
||||
return _cachedOutputDesc ?? inDesc;
|
||||
@@ -126,7 +126,7 @@ namespace LuaScript
|
||||
int imgW = Math.Max(1, (int)Math.Ceiling(bounds.Right - bounds.Left));
|
||||
int imgH = Math.Max(1, (int)Math.Ceiling(bounds.Bottom - bounds.Top));
|
||||
|
||||
var ctx = BuildContext(in key, imgW, imgH, sceneObjects);
|
||||
var ctx = BuildContext(in key, imgW, imgH, resolver);
|
||||
ctx.SetPixelLoader(() => LoadInputPixels(bounds, imgW, imgH));
|
||||
|
||||
DrawDescription outDesc = inDesc;
|
||||
@@ -165,18 +165,18 @@ namespace LuaScript
|
||||
|
||||
_isFirst = false;
|
||||
_cachedKey = key;
|
||||
_cachedSceneObjects = sceneObjects;
|
||||
_cachedQueries = [.. ctx.ObjectQueries];
|
||||
_cachedOutputDesc = outDesc;
|
||||
_cachedPixelsModified = pixelsModified;
|
||||
|
||||
return outDesc;
|
||||
}
|
||||
|
||||
private static SceneObjectInfo[] BuildSceneObjects(EffectDescription desc)
|
||||
private static SceneObjectResolver BuildSceneObjectResolver(EffectDescription desc)
|
||||
{
|
||||
var scenes = desc.Scenes;
|
||||
if (scenes is null)
|
||||
return [];
|
||||
return new SceneObjectResolver([], desc.FPS);
|
||||
|
||||
Scene? scene = null;
|
||||
foreach (var info in scenes)
|
||||
@@ -188,12 +188,10 @@ namespace LuaScript
|
||||
}
|
||||
}
|
||||
if (scene is null)
|
||||
return [];
|
||||
return new SceneObjectResolver([], desc.FPS);
|
||||
|
||||
int timelineFrame = desc.TimelinePosition.Frame;
|
||||
int fps = desc.FPS;
|
||||
var items = scene.Timeline.Items;
|
||||
var result = new List<SceneObjectInfo>(items.Count);
|
||||
var entries = new List<SceneObjectResolver.Entry>(items.Count);
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
@@ -203,30 +201,25 @@ namespace LuaScript
|
||||
if (string.IsNullOrEmpty(tag))
|
||||
continue;
|
||||
|
||||
int length = item.Length;
|
||||
int local = Math.Clamp(timelineFrame - item.Frame, 0, length);
|
||||
bool exist = item.Frame <= timelineFrame && timelineFrame < item.Frame + length;
|
||||
|
||||
double x = visual.X.GetValue(local, length, fps);
|
||||
double y = visual.Y.GetValue(local, length, fps);
|
||||
double z = visual.Z.GetValue(local, length, fps);
|
||||
double zoom = visual.Zoom.GetValue(local, length, fps) / 100d;
|
||||
double rz = visual.Rotation.GetValue(local, length, fps);
|
||||
|
||||
double opacity = visual.Opacity.GetValue(local, length, fps) / 100d;
|
||||
double timeSec = fps > 0 ? local / (double)fps : 0d;
|
||||
double durationSec = fps > 0 ? length / (double)fps : 0d;
|
||||
double fadeIn = visual.FadeIn <= 0d ? 1d : Math.Min(1d, timeSec / visual.FadeIn);
|
||||
double fadeOut = visual.FadeOut <= 0d ? 1d : Math.Min(1d, (durationSec - timeSec) / visual.FadeOut);
|
||||
double alpha = opacity * Math.Min(fadeIn, fadeOut) * 255d;
|
||||
|
||||
result.Add(new SceneObjectInfo(tag, exist, x, y, z, zoom, rz, alpha, item.Layer));
|
||||
entries.Add(new SceneObjectResolver.Entry(tag, item.Frame, item.Length, item.Layer, visual));
|
||||
}
|
||||
|
||||
return [.. result];
|
||||
return new SceneObjectResolver([.. entries], desc.FPS);
|
||||
}
|
||||
|
||||
private static AviUtlScriptContext BuildContext(in RenderKey key, int imgW, int imgH, SceneObjectInfo[] sceneObjects)
|
||||
private static bool QueriesMatch(SceneObjectQuery[] queries, SceneObjectResolver resolver)
|
||||
{
|
||||
for (int i = 0; i < queries.Length; i++)
|
||||
{
|
||||
var query = queries[i];
|
||||
SceneObjectInfo? current = resolver.TryResolve(query.Tag, query.Frame, out var info) ? info : null;
|
||||
if (!Nullable.Equals(current, query.Result))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static AviUtlScriptContext BuildContext(in RenderKey key, int imgW, int imgH, SceneObjectResolver resolver)
|
||||
{
|
||||
var zoom = key.InputDesc.Zoom;
|
||||
double zoomAvg = (zoom.X + zoom.Y) / 2d;
|
||||
@@ -277,7 +270,7 @@ namespace LuaScript
|
||||
IsPaused = key.Usage == TimelineSourceUsage.Paused,
|
||||
SceneId = key.SceneId.ToString(),
|
||||
TimeRatio = key.Length > 0 ? key.Frame / (double)key.Length : 0d,
|
||||
SceneObjects = sceneObjects,
|
||||
Resolver = resolver,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする