obj.drawをネイティブエンジンへ対応

このコミットが含まれているのは:
routersys committed 2026-06-29 08:16:51 +09:00
1 親 90fe288f66
コミット 3ba77aab18
9ファイル変更
+96 -16

検索条件に一致するファイルはありません

+8
ファイルの表示
@@ -124,6 +124,14 @@ namespace LuaScript
_pixelBufferLoaded = true;
}
internal void SetResolvedBuffer(byte[] buffer, int width, int height)
{
_pixelBuffer = buffer;
_pixelBufferLoaded = true;
ImageWidth = width;
ImageHeight = height;
}
internal byte[]? GetPixelBuffer() => _pixelBuffer;
internal void MarkPixelsDirty() => _isPixelsDirty = true;
+22 -2
ファイルの表示
@@ -50,6 +50,7 @@ namespace LuaScript.Engine
Func<string, int, SceneObjectInfo?> resolveObject,
Func<string, int, double, double, double, (byte[] buffer, int w, int h)> loadFigure,
Action<string, IReadOnlyList<KeyValuePair<string, object>>> addEffect,
Action<DrawCommand> addDraw,
out bool pixelsDirty,
out bool bufferReplaced,
out byte[]? newPixels,
@@ -103,7 +104,7 @@ namespace LuaScript.Engine
if (status != NativeProtocol.StatusCallback)
break;
DispatchCallback(view, resolveObject, loadFigure, addEffect);
DispatchCallback(view, resolveObject, loadFigure, addEffect, addDraw);
_workEvent.Set();
}
@@ -147,7 +148,8 @@ namespace LuaScript.Engine
MemoryMappedViewAccessor view,
Func<string, int, SceneObjectInfo?> resolveObject,
Func<string, int, double, double, double, (byte[] buffer, int w, int h)> loadFigure,
Action<string, IReadOnlyList<KeyValuePair<string, object>>> addEffect)
Action<string, IReadOnlyList<KeyValuePair<string, object>>> addEffect,
Action<DrawCommand> addDraw)
{
int kind = view.ReadInt32(NativeProtocol.OffCallbackKind);
switch (kind)
@@ -161,9 +163,27 @@ namespace LuaScript.Engine
case NativeProtocol.CbKindEffect:
ResolveEffectCallback(view, addEffect);
break;
case NativeProtocol.CbKindDraw:
ResolveDrawCallback(view, addDraw);
break;
}
}
private static void ResolveDrawCallback(MemoryMappedViewAccessor view, Action<DrawCommand> addDraw)
{
long rOff = NativeProtocol.CallbackResultOffset;
double ox = view.ReadDouble(rOff + 0 * 8);
double oy = view.ReadDouble(rOff + 1 * 8);
double oz = view.ReadDouble(rOff + 2 * 8);
double zoom = view.ReadDouble(rOff + 3 * 8);
double alpha = view.ReadDouble(rOff + 4 * 8);
double aspect = view.ReadDouble(rOff + 5 * 8);
try { addDraw(new DrawCommand(ox, oy, oz, zoom, alpha, aspect)); }
catch { }
view.Write(NativeProtocol.OffCallbackFound, 1);
}
private void ResolveGetObjectCallback(MemoryMappedViewAccessor view, Func<string, int, SceneObjectInfo?> resolveObject)
{
int frame = view.ReadInt32(NativeProtocol.OffCallbackFrame);
+1
ファイルの表示
@@ -46,6 +46,7 @@ namespace LuaScript.Engine
public const int CbKindGetObject = 0;
public const int CbKindLoadFigure = 1;
public const int CbKindEffect = 2;
public const int CbKindDraw = 3;
public const int CbExist = 0;
public const int CbX = 1;
-1
ファイルの表示
@@ -21,7 +21,6 @@ namespace LuaScript.Engine
public static bool UsesDrawingApi(string? script) =>
script is not null && (
script.Contains("obj.draw", StringComparison.Ordinal) ||
script.Contains("obj.setoption", StringComparison.Ordinal) ||
script.Contains("obj.copybuffer", StringComparison.Ordinal));
+15
ファイルの表示
@@ -447,6 +447,7 @@ namespace LuaScript
(tag, frame) => ctx.ResolveObject(tag, frame, out var info) ? info : null,
NativeLoadFigure,
(name, args) => ctx.AddEffect(new AviUtlEffectRequest(name, args)),
ctx.AddDraw,
out bool dirty, out bool bufferReplaced, out byte[]? newPixels,
out int resultW, out int resultH, out string? error);
@@ -459,6 +460,8 @@ namespace LuaScript
NativeFieldMap.FromFields(_nativeFields, ctx);
bool hasDraws = ctx.DrawCommands.Count > 0;
if (dirty)
{
int outW = bufferReplaced ? resultW : imgW;
@@ -471,6 +474,12 @@ namespace LuaScript
ctx.ReplaceBuffer(outPixels, outW, outH);
}
if (hasDraws)
{
ctx.SetResolvedBuffer(outPixels, outW, outH);
return true;
}
_pixelManager!.WritePixelsToOutput(outPixels, outW, outH);
if (bufferReplaced)
effectOutput = _pixelManager.GetTransformOutput(-outW / 2f, -outH / 2f);
@@ -479,6 +488,12 @@ namespace LuaScript
return true;
}
if (hasDraws)
{
ctx.SetResolvedBuffer(buffer, imgW, imgH);
return false;
}
effectOutput = null;
return false;
}