NodeVar.hx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package hrt.shgraph;
  2. using hxsl.Ast;
  3. class NodeVar {
  4. public var node : ShaderNode;
  5. public var keyOutput : String;
  6. public function new ( n : ShaderNode, key : String ) {
  7. node = n;
  8. keyOutput = key;
  9. }
  10. public function getKey() : String {
  11. return keyOutput;
  12. }
  13. public function getTVar() {
  14. return null;//node.getOutput(keyOutput);
  15. }
  16. public function getType() : Type {
  17. return TVoid;//node.getOutputType(keyOutput);
  18. }
  19. public function isEmpty() {
  20. return true;//node.getOutputTExpr(keyOutput) == null;
  21. }
  22. public function getVar(?type: Type) : TExpr {
  23. var currentType = getType();
  24. if (type == null || currentType == type) {
  25. return null;//node.getOutputTExpr(keyOutput);
  26. }
  27. return null;
  28. }
  29. public function getExpr() : Array<TExpr> {
  30. if (node.outputCompiled.get(keyOutput) != null)
  31. return [];
  32. node.outputCompiled.set(keyOutput, true);
  33. var res = [];
  34. var nodeBuild = node.build(keyOutput);
  35. var tvar = getTVar();
  36. if (tvar != null && tvar.kind == Local && ShaderInput.availableInputs.indexOf(tvar) < 0)
  37. res.push({ e : TVarDecl(getTVar()), t : getType(), p : null });
  38. if (nodeBuild != null)
  39. res.push(nodeBuild);
  40. return res;
  41. }
  42. }