From ab889c2e1c89c4a6d7a151977c2f94e524582ed1 Mon Sep 17 00:00:00 2001 From: falsycat Date: Wed, 9 Oct 2019 00:00:00 +0000 Subject: [PATCH] [update] Implemented getting matrix values as a variable. --- sjplayer/src/sjplayer/ScheduledController.d | 7 ++++++- sjplayer/src/sjplayer/util/MatrixFactory.d | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sjplayer/src/sjplayer/ScheduledController.d b/sjplayer/src/sjplayer/ScheduledController.d index 9b9cd49..808723d 100644 --- a/sjplayer/src/sjplayer/ScheduledController.d +++ b/sjplayer/src/sjplayer/ScheduledController.d @@ -70,8 +70,13 @@ class ScheduledController( case map_name: return mixin("target_."~code); } - default: return super.GetVariable(name); + default: } + static if (MatrixModificationAvailable) { + const value = matrix_factory_.GetValueByName(name); + if (!value.isNull) return value.get; + } + return super.GetVariable(name); } override void SetParameter(ref in Parameter param, ref in VarStore vars) { switch (param.name) { diff --git a/sjplayer/src/sjplayer/util/MatrixFactory.d b/sjplayer/src/sjplayer/util/MatrixFactory.d index 11a99eb..7c3c40e 100644 --- a/sjplayer/src/sjplayer/util/MatrixFactory.d +++ b/sjplayer/src/sjplayer/util/MatrixFactory.d @@ -1,6 +1,8 @@ /// License: MIT module sjplayer.util.MatrixFactory; +import std.typecons; + import gl4d; /// @@ -17,6 +19,20 @@ struct MatrixFactory { return m; } + /// + Nullable!float GetValueByName(string name) const { + switch (name) { + case "scale_x": return Nullable!float(scale.x); + case "scale_y": return Nullable!float(scale.y); + case "rotation_x": return Nullable!float(rotation.x); + case "rotation_y": return Nullable!float(rotation.y); + case "rotation_z": return Nullable!float(rotation.z); + case "translation_x": return Nullable!float(translation.x); + case "translation_y": return Nullable!float(translation.y); + default: return Nullable!float.init; + } + } + /// vec3 scale = vec3(1, 1, 1); ///