ln-cleanups

This commit is contained in:
Henrique 2020-10-01 16:05:47 -03:00
parent da1cf33930
commit a47dafe9ed
30 changed files with 167 additions and 212 deletions

View file

@ -8,15 +8,20 @@ class ArrayGetNode extends LogicNode {
override function get(from: Int): Dynamic {
var ar: Array<Dynamic> = inputs[0].get();
if (ar == null) return null;
var i: Int = inputs[1].get();
if (i < 0) i = ar.length + i;
if (i < 0 || i > ar.length - 1) {
var className = Type.getClassName(Type.getClass(tree));
var traitName = className.substring(className.lastIndexOf(".") + 1);
var objectName = tree.object.name;
trace('Logic error (object: $objectName, trait: $traitName): Array Get - index out of range');
return null;
}
return ar[i];

View file

@ -7,14 +7,11 @@ class BloomGetNode extends LogicNode {
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.bloom_uniforms[0];
} else if (from == 1) {
return armory.renderpath.Postprocess.bloom_uniforms[1];
} else if (from == 2) {
return armory.renderpath.Postprocess.bloom_uniforms[2];
} else {
return 0.0;
}
}
return switch (from) {
case 0: armory.renderpath.Postprocess.bloom_uniforms[0];
case 1: armory.renderpath.Postprocess.bloom_uniforms[1];
case 2: armory.renderpath.Postprocess.bloom_uniforms[2];
default: null;
}
}
}

View file

@ -7,26 +7,17 @@ class CameraGetNode extends LogicNode {
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.camera_uniforms[0];
} else if (from == 1) {
return armory.renderpath.Postprocess.camera_uniforms[1];
} else if (from == 2) {
return armory.renderpath.Postprocess.camera_uniforms[2];
} else if (from == 3) {
return armory.renderpath.Postprocess.camera_uniforms[3];
} else if (from == 4) {
return armory.renderpath.Postprocess.camera_uniforms[4];
} else if (from == 5) {
return armory.renderpath.Postprocess.camera_uniforms[5];
} else if (from == 6) {
return armory.renderpath.Postprocess.camera_uniforms[6];
} else if (from == 7) {
return armory.renderpath.Postprocess.camera_uniforms[7];
} else if (from == 8) {
return armory.renderpath.Postprocess.camera_uniforms[8];
} else {
return 0.0;
}
}
return switch (from) {
case 0: armory.renderpath.Postprocess.camera_uniforms[0];
case 1: armory.renderpath.Postprocess.camera_uniforms[1];
case 2: armory.renderpath.Postprocess.camera_uniforms[2];
case 3: armory.renderpath.Postprocess.camera_uniforms[3];
case 4: armory.renderpath.Postprocess.camera_uniforms[4];
case 5: armory.renderpath.Postprocess.camera_uniforms[5];
case 6: armory.renderpath.Postprocess.camera_uniforms[6];
case 7: armory.renderpath.Postprocess.camera_uniforms[7];
case 8: armory.renderpath.Postprocess.camera_uniforms[8];
default: null;
}
}
}

View file

@ -14,6 +14,7 @@ class CanvasGetVisibleNode extends LogicNode {
#if arm_ui
override function get(from: Int): Dynamic { // Null<Bool>
var element: String = inputs[0].get();
if (canvas == null) canvas = Scene.active.getTrait(CanvasScript);
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
if (canvas == null || !canvas.ready) return null;

View file

@ -7,12 +7,10 @@ class ChromaticAberrationGetNode extends LogicNode {
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.chromatic_aberration_uniforms[0];
} else if (from == 1) {
return armory.renderpath.Postprocess.chromatic_aberration_uniforms[1];
} else {
return 0.0;
}
}
return switch (from) {
case 0: armory.renderpath.Postprocess.chromatic_aberration_uniforms[0];
case 1: armory.renderpath.Postprocess.chromatic_aberration_uniforms[1];
default: null;
}
}
}

View file

@ -6,24 +6,15 @@ class ColorgradingGetGlobalNode extends LogicNode {
super(tree);
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.colorgrading_global_uniforms[0][0];
} else if (from == 1) {
return armory.renderpath.Postprocess.colorgrading_global_uniforms[1];
} else if (from == 2) {
return armory.renderpath.Postprocess.colorgrading_global_uniforms[2];
} else if (from == 3) {
return armory.renderpath.Postprocess.colorgrading_global_uniforms[3];
} else if (from == 4) {
return armory.renderpath.Postprocess.colorgrading_global_uniforms[4];
} else if (from == 5) {
return armory.renderpath.Postprocess.colorgrading_global_uniforms[5];
} else if (from == 6) {
return armory.renderpath.Postprocess.colorgrading_global_uniforms[6];
} else {
return 0.0;
}
}
override function get(from:Int):Dynamic {
return switch (from) {
case 0: armory.renderpath.Postprocess.colorgrading_global_uniforms[0][0];
case 1: armory.renderpath.Postprocess.colorgrading_global_uniforms[1];
case 2: armory.renderpath.Postprocess.colorgrading_global_uniforms[2];
case 3: armory.renderpath.Postprocess.colorgrading_global_uniforms[3];
case 4: armory.renderpath.Postprocess.colorgrading_global_uniforms[4];
case 5: armory.renderpath.Postprocess.colorgrading_global_uniforms[5];
case 6: armory.renderpath.Postprocess.colorgrading_global_uniforms[6];
}
}
}

View file

@ -6,24 +6,16 @@ class ColorgradingGetHighlightNode extends LogicNode {
super(tree);
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.colorgrading_highlight_uniforms[0][2];
} else if (from == 1) {
return armory.renderpath.Postprocess.colorgrading_highlight_uniforms[0];
} else if (from == 2) {
return armory.renderpath.Postprocess.colorgrading_highlight_uniforms[1];
} else if (from == 3) {
return armory.renderpath.Postprocess.colorgrading_highlight_uniforms[2];
} else if (from == 4) {
return armory.renderpath.Postprocess.colorgrading_highlight_uniforms[3];
} else if (from == 5) {
return armory.renderpath.Postprocess.colorgrading_highlight_uniforms[4];
} else if (from == 6) {
return armory.renderpath.Postprocess.colorgrading_highlight_uniforms[5];
} else {
return 0.0;
}
}
override function get(from:Int):Dynamic {
return switch (from) {
case 0: armory.renderpath.Postprocess.colorgrading_highlight_uniforms[0];
case 1: armory.renderpath.Postprocess.colorgrading_highlight_uniforms[1];
case 2: armory.renderpath.Postprocess.colorgrading_highlight_uniforms[2];
case 3: armory.renderpath.Postprocess.colorgrading_highlight_uniforms[3];
case 4: armory.renderpath.Postprocess.colorgrading_highlight_uniforms[4];
case 5: armory.renderpath.Postprocess.colorgrading_highlight_uniforms[5];
default: null;
}
}
}

View file

@ -6,22 +6,16 @@ class ColorgradingGetMidtoneNode extends LogicNode {
super(tree);
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.colorgrading_midtone_uniforms[0];
} else if (from == 1) {
return armory.renderpath.Postprocess.colorgrading_midtone_uniforms[1];
} else if (from == 2) {
return armory.renderpath.Postprocess.colorgrading_midtone_uniforms[2];
} else if (from == 3) {
return armory.renderpath.Postprocess.colorgrading_midtone_uniforms[3];
} else if (from == 4) {
return armory.renderpath.Postprocess.colorgrading_midtone_uniforms[4];
} else if (from == 5) {
return armory.renderpath.Postprocess.colorgrading_midtone_uniforms[5];
} else {
return 0.0;
}
}
override function get(from:Int):Dynamic {
return switch (from) {
case 0: armory.renderpath.Postprocess.colorgrading_midtone_uniforms[0];
case 1: armory.renderpath.Postprocess.colorgrading_midtone_uniforms[1];
case 2: armory.renderpath.Postprocess.colorgrading_midtone_uniforms[2];
case 3: armory.renderpath.Postprocess.colorgrading_midtone_uniforms[3];
case 4: armory.renderpath.Postprocess.colorgrading_midtone_uniforms[4];
case 5: armory.renderpath.Postprocess.colorgrading_midtone_uniforms[5];
default: null;
}
}
}

View file

@ -6,24 +6,15 @@ class ColorgradingGetShadowNode extends LogicNode {
super(tree);
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.colorgrading_shadow_uniforms[0][1];
} else if (from == 1) {
return armory.renderpath.Postprocess.colorgrading_shadow_uniforms[0];
} else if (from == 2) {
return armory.renderpath.Postprocess.colorgrading_shadow_uniforms[1];
} else if (from == 3) {
return armory.renderpath.Postprocess.colorgrading_shadow_uniforms[2];
} else if (from == 4) {
return armory.renderpath.Postprocess.colorgrading_shadow_uniforms[3];
} else if (from == 5) {
return armory.renderpath.Postprocess.colorgrading_shadow_uniforms[4];
} else if (from == 6) {
return armory.renderpath.Postprocess.colorgrading_shadow_uniforms[5];
} else {
return 0.0;
}
}
override function get(from:Int):Dynamic {
return switch (from) {
case 0: armory.renderpath.Postprocess.colorgrading_shadow_uniforms[0];
case 1: armory.renderpath.Postprocess.colorgrading_shadow_uniforms[1];
case 2: armory.renderpath.Postprocess.colorgrading_shadow_uniforms[2];
case 3: armory.renderpath.Postprocess.colorgrading_shadow_uniforms[3];
case 4: armory.renderpath.Postprocess.colorgrading_shadow_uniforms[4];
case 5: armory.renderpath.Postprocess.colorgrading_shadow_uniforms[5];
default: null;
}
}
}

View file

@ -11,7 +11,7 @@ class GetCameraFovNode extends LogicNode {
override function get(from: Int): Dynamic {
var camera: CameraObject = inputs[0].get();
if (camera == null) return 0.0;
if (camera == null) return null;
return camera.data.raw.fov;
}

View file

@ -11,15 +11,18 @@ class GetContactsNode extends LogicNode {
override function get(from: Int): Dynamic {
var object: Object = inputs[0].get();
if (object == null) return null;
#if arm_physics
var physics = armory.trait.physics.PhysicsWorld.active;
var rbs = physics.getContacts(object.getTrait(RigidBody));
var obs = [];
if (rbs != null) for (rb in rbs) if (rb != null) obs.push(rb.object);
return obs;
#end
return null;
}
}

View file

@ -18,7 +18,7 @@ class GetCursorLocationNode extends LogicNode {
case 1: mouse.y;
case 2: mouse.x * -1;
case 3: mouse.y * -1;
default: null;
default: null;
}
}
}

View file

@ -12,13 +12,13 @@ class GetCursorStateNode extends LogicNode {
var mouse = iron.system.Input.getMouse();
return switch (from) {
case 0:
if (mouse.hidden == true && mouse.locked == true) return true;
return false;
case 0:
if (mouse.hidden == true && mouse.locked == true) return true;
return false;
case 1: mouse.hidden;
case 2: mouse.locked;
default: null;
}
case 1: mouse.hidden;
case 2: mouse.locked;
default: null;
}
}
}

View file

@ -16,8 +16,10 @@ class GetFirstContactNode extends LogicNode {
#if arm_physics
var physics = armory.trait.physics.PhysicsWorld.active;
var rbs = physics.getContacts(object.getTrait(RigidBody));
if (rbs != null && rbs.length > 0) return rbs[0].object;
#end
return null;
}
}

View file

@ -9,7 +9,7 @@ class GetGravityNode extends LogicNode {
override function get(from: Int): Dynamic {
#if arm_physics
var physics = armory.trait.physics.PhysicsWorld.active;
var physics = armory.trait.physics.PhysicsWorld.active;
return physics.getGravity();
#end

View file

@ -23,7 +23,7 @@ class GetMouseMovementNode extends LogicNode {
case 3: mouse.movementX * multX;
case 4: mouse.movementY * multY;
case 5: mouse.wheelDelta * multDelta;
default: null;
default: null;
}
}
}

View file

@ -12,6 +12,7 @@ class GetMouseVisibleNode extends LogicNode {
var mouse = iron.system.Input.getMouse();
if (mouse.hidden == false) return true;
return false;
}
}

View file

@ -17,7 +17,7 @@ class GetObjectOffscreenNode extends LogicNode {
case 0: object.culled;
case 1: object.culledMesh;
case 2: object.culledShadow;
default: null;
default: null;
}
}

View file

@ -14,29 +14,30 @@ class GetRigidBodyDataNode extends LogicNode {
if (object == null) return null;
#if arm_physics
var rigidBody = object.getTrait(RigidBody);
#if arm_physics
var rb = object.getTrait(RigidBody);
return switch (from) {
case 0:
if (rigidBody == null) return false;
if (rb == null) return false;
return true;
case 1: rigidBody.group;
case 2: rigidBody.mask;
case 3: rigidBody.animated;
case 4: rigidBody.staticObj;
case 5: rigidBody.angularDamping;
case 6: rigidBody.linearDamping;
case 7: rigidBody.friction;
case 8: rigidBody.mass;
case 1: rb.group;
case 2: rb.mask;
case 3: rb.animated;
case 4: rb.staticObj;
case 5: rb.angularDamping;
case 6: rb.linearDamping;
case 7: rb.friction;
case 8: rb.mass;
//case 9: ; // collision shape
//case 10: ; // activation state
//case 11: ; // is gravity enabled
//case 12: ; // angular factor
//case 13: ; // linear factor
default: null;
default: null;
}
#end
}
}

View file

@ -11,11 +11,13 @@ class GetRotationNode extends LogicNode {
override function get(from: Int): Dynamic {
var object: Object = inputs[0].get();
if (object == null) {
return null;
}
var rot = object.transform.rot;
switch (from) {
case 0:
// euler angles

View file

@ -1,25 +1,25 @@
package armory.logicnode;
class GetSystemName extends LogicNode {
// New (constructor)
public function new(tree: LogicTree) {
super(tree);
}
public static function equalsCI(a : String, b : String) return a.toLowerCase() == b.toLowerCase();
// Get - out
public static function equalsCI(a : String, b : String) return a.toLowerCase() == b.toLowerCase();
override function get(from: Int): Dynamic {
switch (from) {
// Out value - Value (string)
case 0: return kha.System.systemId;
case 1: return equalsCI(kha.System.systemId, 'Windows');
case 2: return equalsCI(kha.System.systemId, 'Linux');
case 3: return equalsCI(kha.System.systemId, 'Mac');
case 4: return equalsCI(kha.System.systemId, 'HTML5');
case 5: return equalsCI(kha.System.systemId, 'Android');
var systemName: String = kha.System.systemId;
return switch (from) {
case 0: systemName;
case 1: equalsCI(systemName, 'Windows');
case 2: equalsCI(systemName, 'Linux');
case 3: equalsCI(systemName, 'Mac');
case 4: equalsCI(systemName, 'HTML5');
case 5: equalsCI(systemName, 'Android');
default: null;
}
return null;
}
}
}

View file

@ -18,7 +18,7 @@ class GetTouchLocationNode extends LogicNode {
case 1: touch.y;
case 2: touch.x * -1;
case 3: touch.y * -1;
default: null;
default: null;
}
}
}

View file

@ -20,7 +20,7 @@ class GetTouchMovementNode extends LogicNode {
case 1: touch.movementY;
case 2: touch.movementX * multX;
case 3: touch.movementY * multY;
default: null;
default: null;
}
}
}

View file

@ -15,9 +15,9 @@ class GetTraitNode extends LogicNode {
var name: String = inputs[1].get();
if (object == null) return null;
if (cname == null) cname = cast Type.resolveClass(Main.projectPackage + "." + name);
if (cname == null) cname = cast Type.resolveClass(Main.projectPackage + ".node." + name);
return object.getTrait(cname);
}
}

View file

@ -16,11 +16,12 @@ class GetVelocityNode extends LogicNode {
#if arm_physics
var rb: RigidBody = object.getTrait(RigidBody);
if (rb != null) {
if (from == 0) return rb.getLinearVelocity();
else if (from == 1) return rb.getAngularVelocity();
return switch (from) {
case 0: rb.getLinearVelocity();
case 1: rb.getAngularVelocity();
default: null;
}
#end
return null;
}
}

View file

@ -17,7 +17,7 @@ class GetVisibleNode extends LogicNode {
case 0: object.visible;
case 1: object.visibleMesh;
case 2: object.visibleShadow;
default: null;
default: null;
}
}

View file

@ -13,18 +13,14 @@ class GetWorldNode extends LogicNode {
override function get(from: Int): Dynamic {
var object: Object = inputs[0].get();
if (object == null) {
return null;
}
switch (property0) {
case "Right":
return object.transform.world.right();
case "Look":
return object.transform.world.look();
case "Up":
return object.transform.world.up();
if (object == null) return null;
return switch (property0) {
case "Right": object.transform.world.right();
case "Look": return object.transform.world.look();
case "Up": return object.transform.world.up();
default: null;
}
return null;
}
}

View file

@ -7,18 +7,13 @@ class LenstextureGetNode extends LogicNode {
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.lenstexture_uniforms[0];
} else if (from == 1) {
return armory.renderpath.Postprocess.lenstexture_uniforms[1];
} else if (from == 2) {
return armory.renderpath.Postprocess.lenstexture_uniforms[2];
} else if (from == 3) {
return armory.renderpath.Postprocess.lenstexture_uniforms[3];
} else if (from == 4) {
return armory.renderpath.Postprocess.lenstexture_uniforms[4];
} else {
return 0.0;
}
}
return switch (from) {
case 0: armory.renderpath.Postprocess.lenstexture_uniforms[0];
case 1: armory.renderpath.Postprocess.lenstexture_uniforms[1];
case 2: armory.renderpath.Postprocess.lenstexture_uniforms[2];
case 3: armory.renderpath.Postprocess.lenstexture_uniforms[3];
case 4: armory.renderpath.Postprocess.lenstexture_uniforms[4];
default: null;
}
}
}

View file

@ -7,14 +7,12 @@ class SSAOGetNode extends LogicNode {
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.ssao_uniforms[0];
} else if (from == 1) {
return armory.renderpath.Postprocess.ssao_uniforms[1];
} else if (from == 2) {
return armory.renderpath.Postprocess.ssao_uniforms[2];
} else {
return 0.0;
}
}
return switch (from) {
case 0: armory.renderpath.Postprocess.ssao_uniforms[0];
case 1: armory.renderpath.Postprocess.ssao_uniforms[1];
case 2: armory.renderpath.Postprocess.ssao_uniforms[2];
default: null;
}
}
}

View file

@ -7,18 +7,14 @@ class SSRGetNode extends LogicNode {
}
override function get(from:Int):Dynamic {
if(from == 0) {
return armory.renderpath.Postprocess.ssr_uniforms[0];
} else if (from == 1) {
return armory.renderpath.Postprocess.ssr_uniforms[1];
} else if (from == 2) {
return armory.renderpath.Postprocess.ssr_uniforms[2];
} else if (from == 3) {
return armory.renderpath.Postprocess.ssr_uniforms[3];
} else if (from == 4) {
return armory.renderpath.Postprocess.ssr_uniforms[4];
} else {
return 0.0;
}
}
return switch (from) {
case 0: armory.renderpath.Postprocess.ssr_uniforms[0];
case 1: armory.renderpath.Postprocess.ssr_uniforms[1];
case 2: armory.renderpath.Postprocess.ssr_uniforms[2];
case 3: armory.renderpath.Postprocess.ssr_uniforms[3];
case 4: armory.renderpath.Postprocess.ssr_uniforms[4];
default: null;
}
}
}