Implement and upgrade set material value parameter node

This commit is contained in:
QuantumCoderQC 2021-06-05 15:11:06 +02:00
parent 8e4d8785d1
commit 3add69d7d4

View file

@ -6,7 +6,7 @@ import iron.object.Object;
class SetMaterialValueParamNode extends LogicNode {
static var registered = false;
static var map = new Map<MaterialData, Map<String, Null<kha.FastFloat>>>();
static var map = new Map<Object, Map<MaterialData, Map<String, Null<kha.FastFloat>>>>();
public function new(tree: LogicTree) {
super(tree);
@ -17,21 +17,36 @@ class SetMaterialValueParamNode extends LogicNode {
}
override function run(from: Int) {
var mat = inputs[1].get();
if (mat == null) return;
var entry = map.get(mat);
var obj = inputs[1].get();
var mat = inputs[2].get();
if(obj == null) return;
var matMap = map.get(obj);
if (matMap == null) {
matMap = new Map();
map.set(obj, matMap);
}
var entry = matMap.get(mat);
if (entry == null) {
entry = new Map();
map.set(mat, entry);
matMap.set(mat, entry);
}
entry.set(inputs[2].get(), inputs[3].get()); // Node name, value
entry.set(inputs[3].get(), inputs[4].get()); // Node name, value
runOutput(0);
}
static function floatLink(object: Object, mat: MaterialData, link: String): Null<kha.FastFloat> {
if(object == null) return null;
if (mat == null) return null;
var entry = map.get(mat);
var material = map.get(object);
if (material == null) return null;
var entry = material.get(mat);
if (entry == null) return null;
return entry.get(link);
}
}