[update] Implemented getting matrix values as a variable.

This commit is contained in:
falsycat 2019-10-09 00:00:00 +00:00
parent 7f2ada6982
commit ab889c2e1c
2 changed files with 22 additions and 1 deletions

View File

@ -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) {

View File

@ -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);
///