Apply checkstyle

This commit is contained in:
luboslenco 2019-12-19 23:54:08 +01:00
parent fe3fa62a97
commit db4f0cc107
300 changed files with 2055 additions and 2102 deletions

View file

@ -7,7 +7,7 @@ class Config {
public static function load(done: Void->Void) {
try {
iron.data.Data.getBlob('config.arm', function(blob:kha.Blob) {
iron.data.Data.getBlob("config.arm", function(blob: kha.Blob) {
configLoaded = true;
raw = haxe.Json.parse(blob.toString());
done();
@ -17,7 +17,7 @@ class Config {
}
public static function save() {
var path = iron.data.Data.dataPath + 'config.arm';
var path = iron.data.Data.dataPath + "config.arm";
var bytes = haxe.io.Bytes.ofString(haxe.Json.stringify(raw));
#if kha_krom
Krom.fileSaveBytes(path, bytes.getData());

View file

@ -10,6 +10,6 @@ class ArrayInArrayNode extends LogicNode {
var array: Array<Dynamic> = inputs[0].get();
var value: Dynamic = inputs[1].get();
return ! (array.indexOf(value) == -1);
return array.indexOf(value) != -1;
}
}

View file

@ -22,8 +22,9 @@ class CallFunctionNode extends LogicNode {
}
var func = Reflect.field(object, funName);
if (func != null)
if (func != null) {
result = Reflect.callMethod(object, func, args);
}
runOutput(0);
}

View file

@ -11,7 +11,7 @@ class CallHaxeStaticNode extends LogicNode {
override function run(from: Int) {
var path: String = inputs[1].get();
if (path != '') {
if (path != "") {
var dotIndex = path.lastIndexOf(".");
var classPath = path.substr(0, dotIndex);
var classType = Type.resolveClass(classPath);

View file

@ -17,12 +17,12 @@ class CanvasGetCheckboxNode extends LogicNode {
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
if (canvas == null || !canvas.ready) return null;
// This Try/Catch hacks around an issue where the handles are
// not created yet, even though canvas.ready is true.
try {
return canvas.getHandle(inputs[0].get()).selected;
} catch (e:Dynamic) {return null;}
}
catch (e: Dynamic) { return null; }
}
#end
}

View file

@ -17,12 +17,12 @@ class CanvasGetInputTextNode extends LogicNode {
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
if (canvas == null || !canvas.ready) return null;
// This Try/Catch hacks around an issue where the handles are
// not created yet, even though canvas.ready is true.
try {
return canvas.getHandle(inputs[0].get()).text;
} catch (e:Dynamic) {return null;}
}
catch (e: Dynamic) { return null; }
}
#end
}

View file

@ -17,12 +17,12 @@ class CanvasGetPositionNode extends LogicNode {
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
if (canvas == null || !canvas.ready) return null;
// This Try/Catch hacks around an issue where the handles are
// not created yet, even though canvas.ready is true.
try {
return canvas.getHandle(inputs[0].get()).position;
} catch (e:Dynamic) {return null;}
}
catch (e: Dynamic) { return null; }
}
#end
}

View file

@ -17,12 +17,12 @@ class CanvasGetSliderNode extends LogicNode {
if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript);
if (canvas == null || !canvas.ready) return null;
// This Try/Catch hacks around an issue where the handles are
// not created yet, even though canvas.ready is true.
try {
return canvas.getHandle(inputs[0].get()).value;
} catch (e:Dynamic) {return null;}
}
catch (e: Dynamic) { return null; }
}
#end
}

View file

@ -22,7 +22,8 @@ class CanvasSetSliderNode extends LogicNode {
try {
canvas.getHandle(element).value = value;
tree.removeUpdate(update);
} catch (e:Dynamic) {}
}
catch (e: Dynamic) {}
runOutput(0);
}

View file

@ -31,7 +31,8 @@ class CastPhysicsRayNode extends LogicNode {
v.set(hitPointWorld.x, hitPointWorld.y, hitPointWorld.z, 1);
return v;
}
} else { // Normal
}
else { // Normal
var hitNormalWorld: Vec4 = rb != null ? physics.hitNormalWorld : null;
if (hitNormalWorld != null) {
v.set(hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z, 0);

View file

@ -16,7 +16,7 @@ class FunctionNode extends LogicNode {
runOutput(0);
}
override function get(from:Int) {
override function get(from: Int): Dynamic {
return this.args[from - 1];
}
}

View file

@ -32,9 +32,11 @@ class GamepadCoordsNode extends LogicNode {
coords.x = gamepad.rightStick.movementX;
coords.y = gamepad.rightStick.movementY;
return coords;
} else if(from == 4) {
}
else if (from == 4) {
return gamepad.down("l2");
} else if(from == 5) {
}
else if (from == 5) {
return gamepad.down("r2");
}
return null;

View file

@ -12,7 +12,6 @@ class GateNode extends LogicNode {
}
override function run(from: Int) {
var v1: Dynamic = inputs[1].get();
var v2: Dynamic = inputs[2].get();
var cond = false;

View file

@ -1,9 +1,5 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;
class GetGravityNode extends LogicNode {
public function new(tree: LogicTree) {

View file

@ -11,7 +11,7 @@ class GetNameNode extends LogicNode {
override function get(from: Int): Dynamic {
var object: Object = inputs[0].get();
if (object == null) return '';
if (object == null) return "";
return object.name;
}

View file

@ -1,18 +1,20 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Quat;
import iron.math.Vec3;
class GetRotationNode extends LogicNode {
public function new(tree: LogicTree) {
super(tree);
}
override function get(from: Int): Dynamic {
var object: Object = inputs[0].get();
if (object == null)
if (object == null) {
return null;
}
var rot = object.transform.rot;
switch (from) {
case 0:
@ -21,8 +23,9 @@ class GetRotationNode extends LogicNode {
case 1:
// vector
var sqrtW = Math.sqrt(1 - (rot.w * rot.w));
if (sqrtW == 0)
if (sqrtW == 0) {
return new Vec3(0, 0, 1);
}
return new Vec3(rot.x / sqrtW, rot.y / sqrtW, rot.z / sqrtW);
case 2:
// angle radians

View file

@ -1,7 +1,6 @@
package armory.logicnode;
import iron.Scene;
import iron.object.Object;
class GroupNode extends LogicNode {

View file

@ -7,7 +7,6 @@ class GroupOutputNode extends LogicNode {
}
override function run(from: Int) {
runOutput(0);
}
}

View file

@ -7,7 +7,6 @@ class IsFalseNode extends LogicNode {
}
override function run(from: Int) {
var v1: Bool = inputs[1].get();
if (!v1) runOutput(0);
}

View file

@ -7,7 +7,6 @@ class IsNoneNode extends LogicNode {
}
override function run(from: Int) {
var v1: Dynamic = inputs[1].get();
if (v1 == null) runOutput(0);
}

View file

@ -7,7 +7,6 @@ class IsNotNoneNode extends LogicNode {
}
override function run(from: Int) {
var v1: Dynamic = inputs[1].get();
if (v1 != null) runOutput(0);
}

View file

@ -7,7 +7,6 @@ class IsTrueNode extends LogicNode {
}
override function run(from: Int) {
var v1: Bool = inputs[1].get();
if (v1) runOutput(0);
}

View file

@ -27,15 +27,15 @@ class LogicNode {
}
/**
* Called when this node is activated.
* @param from impulse index
*/
Called when this node is activated.
@param from impulse index
**/
function run(from: Int) {}
/**
* Call to activate node connected to the output.
* @param i output index
*/
Call to activate node connected to the output.
@param i output index
**/
function runOutput(i: Int) {
if (i >= outputs.length) return;
for (o in outputs[i]) {

View file

@ -7,8 +7,7 @@ class MaskNode extends LogicNode {
}
override function get(from: Int): Dynamic {
var ret : Int= 0;
var ret = 0;
for (v in 0...20) {
var bit: Bool = inputs[v].get();
if (bit) ret |= (1 << v);

View file

@ -1,6 +1,5 @@
package armory.logicnode;
import iron.math.Vec4;
import iron.math.Mat4;
class MatrixMathNode extends LogicNode {

View file

@ -17,7 +17,7 @@ class OnUpdateNode extends LogicNode {
#if arm_physics
case "Physics Pre-Update": PhysicsWorld.active.notifyOnPreUpdate(update);
#end
default /* Update */: tree.notifyOnUpdate(update);
default: tree.notifyOnUpdate(update); /* Update */
}
}

View file

@ -7,7 +7,6 @@ class RemoveActiveSceneNode extends LogicNode {
}
override function run(from: Int) {
iron.Scene.active.remove();
runOutput(0);
}

View file

@ -1,7 +1,5 @@
package armory.logicnode;
import iron.object.Object;
class RemoveTraitNode extends LogicNode {
public function new(tree: LogicTree) {

View file

@ -1,7 +1,6 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Mat4;
import iron.math.Quat;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;

View file

@ -21,7 +21,7 @@ class RpConfigNode extends LogicNode {
case "GI":
on ? armory.data.Config.raw.rp_gi = true : armory.data.Config.raw.rp_gi = false;
case "Motion Blur":
on ? armory.data.Config.raw.rp_motionblur = true : armory.data.Config.raw.rp_motionblur = false;// armory.renderpath.RenderPathCreator.applyConfig();
on ? armory.data.Config.raw.rp_motionblur = true : armory.data.Config.raw.rp_motionblur = false;
}
armory.renderpath.RenderPathCreator.applyConfig();
armory.data.Config.save();

View file

@ -1,7 +1,6 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Mat4;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;

View file

@ -1,7 +1,5 @@
package armory.logicnode;
import iron.Scene;
class SceneNode extends LogicNode {
public var property0: String;

View file

@ -1,7 +1,5 @@
package armory.logicnode;
import iron.Scene;
class SceneRootNode extends LogicNode {
public function new(tree: LogicTree) {

View file

@ -15,7 +15,7 @@ class SendEventNode extends LogicNode {
var name: String = inputs[1].get();
var object: Object = inputs.length > 2 ? inputs[2].get() : tree.object;
if (object == null) return null;
if (object == null) return;
var all = Event.get(name);
if (all != null) {

View file

@ -1,6 +1,5 @@
package armory.logicnode;
import iron.object.Object;
import armory.system.Event;
class SendGlobalEventNode extends LogicNode {

View file

@ -1,6 +1,5 @@
package armory.logicnode;
import iron.Scene;
import iron.object.CameraObject;
class SetCameraNode extends LogicNode {

View file

@ -6,8 +6,8 @@ import armory.trait.physics.RigidBody;
#end
/**
* Enable or disable the gravity for a specific object.
*/
Enable or disable the gravity for a specific object.
**/
class SetGravityEnabledNode extends LogicNode {
public function new(tree: LogicTree) {

View file

@ -1,8 +1,6 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;
class SetGravityNode extends LogicNode {

View file

@ -1,6 +1,5 @@
package armory.logicnode;
import iron.math.Vec4;
import iron.data.MaterialData;
import iron.object.Object;

View file

@ -1,6 +1,5 @@
package armory.logicnode;
import iron.math.Vec4;
import iron.data.MaterialData;
import iron.object.Object;

View file

@ -6,6 +6,7 @@ import iron.math.Vec3;
import armory.trait.physics.RigidBody;
class SetRotationNode extends LogicNode {
public var property0: String;
public function new(tree: LogicTree) {
@ -14,8 +15,9 @@ class SetRotationNode extends LogicNode {
override function run(from: Int) {
var object: Object = inputs[1].get();
if (object == null)
if (object == null) {
return;
}
var vec: Vec3 = inputs[2].get();
var w: Float = inputs[3].get();
switch (property0) {
@ -37,8 +39,9 @@ class SetRotationNode extends LogicNode {
object.transform.buildMatrix();
#if arm_physics
var rigidBody = object.getTrait(RigidBody);
if (rigidBody != null)
if (rigidBody != null) {
rigidBody.syncTransform();
}
#end
runOutput(0);
}

View file

@ -1,8 +1,6 @@
package armory.logicnode;
import armory.trait.navigation.Navigation;
import iron.object.Object;
import iron.math.Vec4;
class StopAgentNode extends LogicNode {

View file

@ -1,7 +1,6 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Mat4;
import iron.math.Vec4;
import armory.trait.physics.RigidBody;

View file

@ -25,7 +25,6 @@ class TranslateOnLocalAxisNode extends LogicNode {
else if (l == 2) loc.setFrom(object.transform.world.up());
else if (l == 3) loc.setFrom(object.transform.world.right());
if (ini) {
loc.x = -loc.x;
loc.y = -loc.y;

View file

@ -1,7 +1,6 @@
package armory.logicnode;
import iron.object.Object;
import iron.math.Vec4;
class VolumeTriggerNode extends LogicNode {
@ -12,7 +11,7 @@ class VolumeTriggerNode extends LogicNode {
super(tree);
}
override function get(from:Int) {
override function get(from: Int): Dynamic {
var object: Object = inputs[0].get();
var volume: Object = inputs[1].get();

View file

@ -29,11 +29,11 @@ class HosekWilkieRadianceData {
1 * Math.pow(value, 5) * spline[index + 5 * stride];
}
function clamp(n:Int, lower:Int, upper:Int) {
function clamp(n: Int, lower: Int, upper: Int): Int {
return n <= lower ? lower : n >= upper ? upper : n;
}
function clampF(n:Float, lower:Float, upper:Float) {
function clampF(n: Float, lower: Float, upper: Float): Float {
return n <= lower ? lower : n >= upper ? upper : n;
}
@ -108,6 +108,7 @@ class HosekWilkieRadianceData {
}
class HosekWilkie {
public static var data: HosekWilkieRadianceData = null;
public static function recompute(world: WorldData) {

View file

@ -370,7 +370,7 @@ class RenderPathDeferred {
t.name = "empty_white";
t.width = 1;
t.height = 1;
t.format = 'R8';
t.format = "R8";
var rt = new RenderTarget(t);
var b = haxe.io.Bytes.alloc(1);
b.set(0, 255);

View file

@ -111,7 +111,7 @@ class RenderPathForward {
t.name = "buf";
t.width = 0;
t.height = 0;
t.format = 'RGBA32';
t.format = "RGBA32";
t.displayp = Inc.getDisplayp();
t.scale = Inc.getSuperSampling();
t.depth_buffer = "main";

View file

@ -11,7 +11,6 @@ import kha.graphics5.VertexBuffer;
import kha.graphics5.IndexBuffer;
import kha.graphics5.VertexStructure;
import kha.graphics5.VertexData;
import kha.graphics5.Usage;
import kha.graphics5.TextureFormat;
import iron.RenderPath;

View file

@ -47,7 +47,7 @@ class Logic {
}
static function safesrc(s: String): String {
return StringTools.replace(s, ' ', '');
return StringTools.replace(s, " ", "");
}
static function node_name(node: TNode): String {
@ -97,7 +97,7 @@ class Logic {
// Properties
for (i in 0...5) {
for (b in node.buttons) {
if (b.name == 'property' + i) {
if (b.name == "property" + i) {
Reflect.setProperty(v, b.name, b.data[b.default_value]);
}
}
@ -121,8 +121,7 @@ class Logic {
}
}
}
// Not linked - create node with default values
else {
else { // Not linked - create node with default values
inp_node = build_default_node(inp);
inp_from = 0;
}
@ -141,8 +140,7 @@ class Logic {
outNodes.push(nodeMap.get(out_name));
}
}
// Not linked - create node with default values
else {
else { // Not linked - create node with default values
outNodes.push(build_default_node(out));
}
// Add outputs
@ -178,44 +176,44 @@ class Logic {
var v: armory.logicnode.LogicNode = null;
if (inp.type == 'OBJECT') {
v = createClassInstance('ObjectNode', [tree, inp.default_value]);
if (inp.type == "OBJECT") {
v = createClassInstance("ObjectNode", [tree, inp.default_value]);
}
else if (inp.type == 'ANIMACTION') {
v = createClassInstance('StringNode', [tree, inp.default_value]);
else if (inp.type == "ANIMACTION") {
v = createClassInstance("StringNode", [tree, inp.default_value]);
}
else if (inp.type == 'VECTOR') {
else if (inp.type == "VECTOR") {
if (inp.default_value == null) inp.default_value = [0, 0, 0]; // TODO
v = createClassInstance('VectorNode', [tree, inp.default_value[0], inp.default_value[1], inp.default_value[2]]);
v = createClassInstance("VectorNode", [tree, inp.default_value[0], inp.default_value[1], inp.default_value[2]]);
}
else if (inp.type == 'RGBA') {
else if (inp.type == "RGBA") {
if (inp.default_value == null) inp.default_value = [0, 0, 0]; // TODO
v = createClassInstance('ColorNode', [tree, inp.default_value[0], inp.default_value[1], inp.default_value[2], inp.default_value[3]]);
v = createClassInstance("ColorNode", [tree, inp.default_value[0], inp.default_value[1], inp.default_value[2], inp.default_value[3]]);
}
else if (inp.type == 'RGB') {
else if (inp.type == "RGB") {
if (inp.default_value == null) inp.default_value = [0, 0, 0]; // TODO
v = createClassInstance('ColorNode', [tree, inp.default_value[0], inp.default_value[1], inp.default_value[2]]);
v = createClassInstance("ColorNode", [tree, inp.default_value[0], inp.default_value[1], inp.default_value[2]]);
}
else if (inp.type == 'VALUE') {
v = createClassInstance('FloatNode', [tree, inp.default_value]);
else if (inp.type == "VALUE") {
v = createClassInstance("FloatNode", [tree, inp.default_value]);
}
else if (inp.type == 'INT') {
v = createClassInstance('IntegerNode', [tree, inp.default_value]);
else if (inp.type == "INT") {
v = createClassInstance("IntegerNode", [tree, inp.default_value]);
}
else if (inp.type == 'BOOLEAN') {
v = createClassInstance('BooleanNode', [tree, inp.default_value]);
else if (inp.type == "BOOLEAN") {
v = createClassInstance("BooleanNode", [tree, inp.default_value]);
}
else if (inp.type == 'STRING') {
v = createClassInstance('StringNode', [tree, inp.default_value]);
else if (inp.type == "STRING") {
v = createClassInstance("StringNode", [tree, inp.default_value]);
}
else { // ACTION, ARRAY
v = createClassInstance('NullNode', [tree]);
v = createClassInstance("NullNode", [tree]);
}
return v;
}
static function createClassInstance(className: String, args: Array<Dynamic>): Dynamic {
var cname = Type.resolveClass(packageName + '.' + className);
var cname = Type.resolveClass(packageName + "." + className);
if (cname == null) return null;
return Type.createInstance(cname, args);
}

View file

@ -116,7 +116,6 @@ class Starter {
#end
#end
#if (js && arm_navigation)
tasks++;
loadLib("recast.js");

View file

@ -1,10 +1,8 @@
package armory.trait;
import iron.object.Object;
import iron.Trait;
import iron.system.Input;
import iron.math.Vec4;
import iron.math.Quat;
class ArcBall extends Trait {

View file

@ -68,9 +68,7 @@ class Character extends Trait {
if (actionMove != null) animation.play(actionMove);
}
// Otherwise if state is walking and character is idle, play idle animation
else if (currentAction == actionMove && framesIdle > 2) {
else if (currentAction == actionMove && framesIdle > 2) { // Otherwise if state is walking and character is idle, play idle animation
currentAction = actionIdle;
if (actionIdle != null) animation.play(actionIdle);

View file

@ -2,14 +2,13 @@ package armory.trait;
import iron.Scene;
import iron.object.Object;
import iron.math.Vec4;
/*
/**
This trait is to be used with a camera mounted on a camera boom with offset.
1. Place the camera as a child to another object, for example an 'Empty'.
2. Place this trait on the 'Empty' object.
3. Set the name of the target object to be followed by the camera.
*/
**/
class FollowCamera extends iron.Trait {
@prop

View file

@ -1,10 +1,6 @@
package armory.trait;
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.ExprTools;
class Macro {
macro public static function prop() { return null; }
macro public static function prop(): haxe.macro.Expr { return null; }
}

View file

@ -40,7 +40,7 @@ class NavAgent extends Trait {
path = null;
}
function shortAngle(from:Float, to:Float) {
function shortAngle(from: Float, to: Float): Float {
if (from < 0) from += Math.PI * 2;
if (to < 0) to += Math.PI * 2;
var delta = Math.abs(from - to);

View file

@ -47,14 +47,13 @@ class NavMesh extends Trait {
recast = Navigation.active.recast;
recast.OBJDataLoader(b.toString(), function() {
var settings = [
'cellSize' => cellSize,
'cellHeight' => cellHeight,
'agentHeight' => agentHeight,
'agentRadius' => agentRadius,
'agentMaxClimb' => agentMaxClimb,
'agentMaxSlope' => agentMaxSlope,
"cellSize" => cellSize,
"cellHeight" => cellHeight,
"agentHeight" => agentHeight,
"agentRadius" => agentRadius,
"agentMaxClimb" => agentMaxClimb,
"agentMaxSlope" => agentMaxSlope,
];
recast.settings(settings);

View file

@ -12,6 +12,7 @@ import armory.trait.physics.PhysicsWorld;
#end
class PhysicsBreak extends Trait {
#if (!arm_bullet)
public function new() { super(); }
#else
@ -56,7 +57,7 @@ class PhysicsBreak extends Trait {
var radialIter = 1;
var randIter = 1;
var debris = breaker.subdivideByImpact(cast object, impactPoint, impactNormal, radialIter, randIter);
var numObjects = debris.length;
// var numObjects = debris.length;
for (o in debris) {
var ud = breaker.userDataMap.get(cast o);
var params = [0.04, 0.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.04, 0.0, 0.0, 0.0];
@ -484,7 +485,7 @@ class ConvexBreaker {
}
static var meshIndex = 0;
function makeMeshData(points:Array<Vec4>) {
function makeMeshData(points: Array<Vec4>): MeshData {
while (points.length > 50) points.pop();
var cm = new ConvexHull(points);
@ -568,6 +569,7 @@ class ConvexBreaker {
}
class UserData {
public var mass: Float;
public var friction: Float;
public var velocity: Vec4;
@ -581,12 +583,14 @@ class UserData {
}
class CutResult {
public var object1: MeshObject = null;
public var object2: MeshObject = null;
public function new() {}
}
class Line3 {
public var start: Vec4;
public var end: Vec4;
@ -595,13 +599,14 @@ class Line3 {
end = new Vec4();
}
public function delta(result:Vec4) {
public function delta(result: Vec4): Vec4 {
result.subvecs(end, start);
return result;
}
}
class Plane {
public var normal = new Vec4(1.0, 0.0, 0.0);
public var constant = 0.0;
@ -611,7 +616,7 @@ class Plane {
return normal.dot(point) + constant;
}
public function setFromCoplanarPoints(a:Vec4, b:Vec4, c:Vec4) {
public function setFromCoplanarPoints(a: Vec4, b: Vec4, c: Vec4): Plane {
var v1 = new Vec4();
var v2 = new Vec4();
var normal = v1.subvecs(c, b).cross(v2.subvecs(a, b)).normalize();
@ -625,7 +630,7 @@ class Plane {
return this;
}
public function coplanarPoint(result:Vec4) {
public function coplanarPoint(result: Vec4): Vec4 {
return result.setFrom(normal).mult(-constant);
}
@ -749,7 +754,7 @@ class ConvexHull {
}
// Whether the face is visible from the vertex
function visible(face:Array<Int>, vertex:Vec4, vertices:Array<Vec4>) {
function visible(face: Array<Int>, vertex: Vec4, vertices: Array<Vec4>): Bool {
var va = vertices[face[0]];
var vb = vertices[face[1]];
var vc = vertices[face[2]];
@ -758,7 +763,7 @@ class ConvexHull {
return n.dot(vertex) >= dist;
}
function normal(va:Vec4, vb:Vec4, vc:Vec4) {
function normal(va: Vec4, vb: Vec4, vc: Vec4): Vec4 {
var cb = new Vec4();
var ab = new Vec4();
cb.subvecs(vc, vb);
@ -768,11 +773,11 @@ class ConvexHull {
return cb;
}
function equalEdge(ea:Array<Int>, eb:Array<Int>) {
function equalEdge(ea: Array<Int>, eb: Array<Int>): Bool {
return ea[0] == eb[1] && ea[1] == eb[0];
}
function randomOffset() {
function randomOffset(): Float {
return (Math.random() - 0.5) * 2 * 1e-6;
}
}

View file

@ -218,19 +218,19 @@ class VehicleBody extends Trait {
}
#if arm_azerty
static inline var keyUp = 'z';
static inline var keyDown = 's';
static inline var keyLeft = 'q';
static inline var keyRight = 'd';
static inline var keyStrafeUp = 'e';
static inline var keyStrafeDown = 'a';
static inline var keyUp = "z";
static inline var keyDown = "s";
static inline var keyLeft = "q";
static inline var keyRight = "d";
static inline var keyStrafeUp = "e";
static inline var keyStrafeDown = "a";
#else
static inline var keyUp = 'w';
static inline var keyDown = 's';
static inline var keyLeft = 'a';
static inline var keyRight = 'd';
static inline var keyStrafeUp = 'e';
static inline var keyStrafeDown = 'q';
static inline var keyUp = "w";
static inline var keyDown = "s";
static inline var keyLeft = "a";
static inline var keyRight = "d";
static inline var keyStrafeUp = "e";
static inline var keyStrafeDown = "q";
#end
#end
}

View file

@ -125,18 +125,18 @@ class WalkNavigation extends Trait {
}
#if arm_azerty
static inline var keyUp = 'z';
static inline var keyDown = 's';
static inline var keyLeft = 'q';
static inline var keyRight = 'd';
static inline var keyStrafeUp = 'e';
static inline var keyStrafeDown = 'a';
static inline var keyUp = "z";
static inline var keyDown = "s";
static inline var keyLeft = "q";
static inline var keyRight = "d";
static inline var keyStrafeUp = "e";
static inline var keyStrafeDown = "a";
#else
static inline var keyUp = 'w';
static inline var keyDown = 's';
static inline var keyLeft = 'a';
static inline var keyRight = 'd';
static inline var keyStrafeUp = 'e';
static inline var keyStrafeDown = 'q';
static inline var keyUp = "w";
static inline var keyDown = "s";
static inline var keyLeft = "a";
static inline var keyRight = "d";
static inline var keyStrafeUp = "e";
static inline var keyStrafeDown = "q";
#end
}

View file

@ -42,19 +42,19 @@ class CameraController extends Trait {
}
#if arm_azerty
static inline var keyUp = 'z';
static inline var keyDown = 's';
static inline var keyLeft = 'q';
static inline var keyRight = 'd';
static inline var keyStrafeUp = 'e';
static inline var keyStrafeDown = 'a';
static inline var keyUp = "z";
static inline var keyDown = "s";
static inline var keyLeft = "q";
static inline var keyRight = "d";
static inline var keyStrafeUp = "e";
static inline var keyStrafeDown = "a";
#else
static inline var keyUp = 'w';
static inline var keyDown = 's';
static inline var keyLeft = 'a';
static inline var keyRight = 'd';
static inline var keyStrafeUp = 'e';
static inline var keyStrafeDown = 'q';
static inline var keyUp = "w";
static inline var keyDown = "s";
static inline var keyLeft = "a";
static inline var keyRight = "d";
static inline var keyStrafeUp = "e";
static inline var keyStrafeDown = "q";
#end
#end
}

View file

@ -19,12 +19,13 @@ class CanvasScript extends Trait {
public function new(canvasName: String, font: String = "font_default.ttf") {
super();
iron.data.Data.getBlob(canvasName + '.json', function(blob:kha.Blob) {
iron.data.Data.getBlob(canvasName + ".json", function(blob: kha.Blob) {
iron.data.Data.getBlob('_themes.json', function(tBlob:kha.Blob) {
iron.data.Data.getBlob("_themes.json", function(tBlob: kha.Blob) {
if (tBlob.get_length() != 0) {
Canvas.themes = haxe.Json.parse(tBlob.toString());
} else {
}
else {
trace("\"_themes.json\" is empty! Using default theme instead.");
}
@ -38,8 +39,7 @@ class CanvasScript extends Trait {
cui = new Zui({font: f, theme: Canvas.getTheme(c.theme)});
if (c.assets == null || c.assets.length == 0) canvas = c;
// Load canvas assets
else {
else { // Load canvas assets
var loaded = 0;
for (asset in c.assets) {
var file = asset.name;

View file

@ -59,7 +59,7 @@ class DebugConsole extends Trait {
this.scaleFactor = scaleFactor;
iron.data.Data.getFont('font_default.ttf', function(font:kha.Font) {
iron.data.Data.getFont("font_default.ttf", function(font: kha.Font) {
ui = new Zui({scaleFactor: scaleFactor, font: font});
notifyOnRender2D(render2D);
notifyOnUpdate(update);
@ -114,7 +114,7 @@ class DebugConsole extends Trait {
}
static var haxeTrace: Dynamic->haxe.PosInfos->Void = null;
static var lastTraces:Array<String> = [''];
static var lastTraces: Array<String> = [""];
static function consoleTrace(v: Dynamic, ?inf: haxe.PosInfos) {
lastTraces.unshift(Std.string(v));
if (lastTraces.length > 10) lastTraces.pop();
@ -137,16 +137,16 @@ class DebugConsole extends Trait {
ui.begin(g);
if (ui.window(hwin, wx, wy, ww, wh, true)) {
if (ui.tab(htab, '')) {}
if (ui.tab(htab, "")) {}
if (ui.tab(htab, 'Scene')) {
if (ui.tab(htab, "Scene")) {
if (ui.panel(Id.handle({selected: true}), "Outliner")) {
ui.indent();
var i = 0;
function drawList(h: zui.Zui.Handle, o: iron.object.Object) {
if (o.name.charAt(0) == '.') return; // Hidden
if (o.name.charAt(0) == ".") return; // Hidden
var b = false;
if (selectedObject == o) {
ui.g.color = 0xff205d9c;
@ -325,34 +325,34 @@ class DebugConsole extends Trait {
var fpsAvg = avg > 0 ? Math.round(1000 / avg) : 0;
if (ui.tab(htab, '$avg ms')) {
if (ui.panel(Id.handle({selected: true}), 'Performance')) {
if (ui.panel(Id.handle({selected: true}), "Performance")) {
if (graph != null) ui.image(graph);
ui.indent();
ui.row(lrow);
ui.text('Frame');
ui.text("Frame");
ui.text('$avg ms / $fpsAvg fps', Align.Right);
ui.row(lrow);
ui.text('Render-path');
ui.text("Render-path");
ui.text(Math.round(renderPathTimeAvg * 10000) / 10 + " ms", Align.Right);
ui.row(lrow);
ui.text('Script');
ui.text("Script");
ui.text(Math.round((updateTimeAvg - physTimeAvg - animTimeAvg) * 10000) / 10 + " ms", Align.Right);
ui.row(lrow);
ui.text('Animation');
ui.text("Animation");
ui.text(Math.round(animTimeAvg * 10000) / 10 + " ms", Align.Right);
ui.row(lrow);
ui.text('Physics');
ui.text("Physics");
ui.text(Math.round(physTimeAvg * 10000) / 10 + " ms", Align.Right);
ui.unindent();
}
if (ui.panel(Id.handle({selected: false}), 'Draw')) {
if (ui.panel(Id.handle({selected: false}), "Draw")) {
ui.indent();
ui.row(lrow);
@ -361,42 +361,42 @@ class DebugConsole extends Trait {
ui.text(numMeshes + "", Align.Right);
ui.row(lrow);
ui.text('Draw calls');
ui.text("Draw calls");
ui.text(iron.RenderPath.drawCalls + "", Align.Right);
ui.row(lrow);
ui.text('Tris mesh');
ui.text("Tris mesh");
ui.text(iron.RenderPath.numTrisMesh + "", Align.Right);
ui.row(lrow);
ui.text('Tris shadow');
ui.text("Tris shadow");
ui.text(iron.RenderPath.numTrisShadow + "", Align.Right);
#if arm_batch
ui.row(lrow);
ui.text('Batch calls');
ui.text("Batch calls");
ui.text(iron.RenderPath.batchCalls + "", Align.Right);
ui.row(lrow);
ui.text('Batch buckets');
ui.text("Batch buckets");
ui.text(iron.RenderPath.batchBuckets + "", Align.Right);
#end
ui.row(lrow);
ui.text('Culled'); // Assumes shadow context for all meshes
ui.text(iron.RenderPath.culled + ' / ' + numMeshes * 2, Align.Right);
ui.text("Culled"); // Assumes shadow context for all meshes
ui.text(iron.RenderPath.culled + " / " + numMeshes * 2, Align.Right);
#if arm_stream
ui.row(lrow);
var total = iron.Scene.active.sceneStream.sceneTotal();
ui.text('Streamed');
ui.text("Streamed");
ui.text('$numMeshes / $total', Align.Right);
#end
ui.unindent();
}
if (ui.panel(Id.handle({selected: false}), 'Render Targets')) {
if (ui.panel(Id.handle({selected: false}), "Render Targets")) {
ui.indent();
#if (kha_opengl || kha_webgl)
ui.imageInvertY = true;
@ -413,7 +413,7 @@ class DebugConsole extends Trait {
ui.unindent();
}
if (ui.panel(Id.handle({selected: false}), 'Cached Materials')) {
if (ui.panel(Id.handle({selected: false}), "Cached Materials")) {
ui.indent();
for (c in iron.data.Data.cachedMaterials) {
ui.text(c.name);
@ -421,7 +421,7 @@ class DebugConsole extends Trait {
ui.unindent();
}
if (ui.panel(Id.handle({selected: false}), 'Cached Shaders')) {
if (ui.panel(Id.handle({selected: false}), "Cached Shaders")) {
ui.indent();
for (c in iron.data.Data.cachedShaders) {
ui.text(c.name);
@ -437,9 +437,9 @@ class DebugConsole extends Trait {
// ui.unindent();
// }
}
if (ui.tab(htab, lastTraces[0] == '' ? 'Console' : lastTraces[0].substr(0, 20))) {
if (ui.tab(htab, lastTraces[0] == "" ? "Console" : lastTraces[0].substr(0, 20))) {
#if js
if (ui.panel(Id.handle({selected: false}), 'Script')) {
if (ui.panel(Id.handle({selected: false}), "Script")) {
ui.indent();
var t = ui.textInput(Id.handle());
if (ui.button("Run")) {
@ -449,10 +449,10 @@ class DebugConsole extends Trait {
ui.unindent();
}
#end
if (ui.panel(Id.handle({selected: true}), 'Log')) {
if (ui.panel(Id.handle({selected: true}), "Log")) {
ui.indent();
if (ui.button("Clear")) {
lastTraces[0] = '';
lastTraces[0] = "";
lastTraces.splice(1, lastTraces.length - 1);
}
for (t in lastTraces) ui.text(t);
@ -462,7 +462,7 @@ class DebugConsole extends Trait {
if (watchNodes.length > 0 && ui.tab(htab, "Watch")) {
for (n in watchNodes) {
ui.text(n.tree.object.name + '.' + n.tree.name + '.' + n.name + ' = ' + n.get(0));
ui.text(n.tree.object.name + "." + n.tree.name + "." + n.name + " = " + n.get(0));
}
}

View file

@ -14,7 +14,7 @@ class LivePatch extends iron.Trait {
function update() {
kha.Assets.loadBlobFromPath("krom.patch", function(b: kha.Blob) {
if (b.length == 0) return;
var lines = b.toString().split('\n');
var lines = b.toString().split("\n");
var id = Std.parseInt(lines[0]);
if (id > patchId) {
patchId = id;

View file

@ -8,6 +8,7 @@ import iron.system.Input;
import iron.system.Time;
class WasmScript extends iron.Trait {
var wasm: Wasm;
var objectMap: Map<Int, iron.object.Object> = new Map();

View file

@ -33,7 +33,6 @@ class PhysicsConstraint extends iron.Trait {
vec3 = new bullet.Bt.Vector3(0, 0, 0);
trans1 = new bullet.Bt.Transform();
trans2 = new bullet.Bt.Transform();
}
this.body1 = body1;
@ -90,32 +89,26 @@ class PhysicsConstraint extends iron.Trait {
if (limits[0] == 0) {
limits[1] = 1.0;
limits[2] = -1.0;
}
if (limits[3] == 0) {
limits[4] = 1.0;
limits[5] = -1.0;
}
if (limits[6] == 0) {
limits[7] = 1.0;
limits[8] = -1.0;
}
if (limits[9] == 0) {
limits[10] = 1.0;
limits[11] = -1.0;
}
if (limits[12] == 0) {
limits[13] = 1.0;
limits[14] = -1.0;
}
if (limits[15] == 0) {
limits[16] = 1.0;
limits[17] = -1.0;
}
vec1.setX(limits[1]);
vec1.setY(limits[4]);
@ -143,32 +136,26 @@ class PhysicsConstraint extends iron.Trait {
if (limits[0] == 0) {
limits[1] = 1.0;
limits[2] = -1.0;
}
if (limits[3] == 0) {
limits[4] = 1.0;
limits[5] = -1.0;
}
if (limits[6] == 0) {
limits[7] = 1.0;
limits[8] = -1.0;
}
if (limits[9] == 0) {
limits[10] = 1.0;
limits[11] = -1.0;
}
if (limits[12] == 0) {
limits[13] = 1.0;
limits[14] = -1.0;
}
if (limits[15] == 0) {
limits[16] = 1.0;
limits[17] = -1.0;
}
vec1.setX(limits[1]);
vec1.setY(limits[4]);
@ -186,51 +173,54 @@ class PhysicsConstraint extends iron.Trait {
vec1.setY(limits[14]);
vec1.setZ(limits[17]);
c.setAngularUpperLimit(vec1);
if(limits[18] != 0)
{
if (limits[18] != 0) {
c.enableSpring(0, true);
c.setStiffness(0, limits[19]);
c.setDamping(0, limits[20]);
}
else{c.enableSpring(0,false);}
if(limits[21] != 0)
{
else {
c.enableSpring(0, false);
}
if (limits[21] != 0) {
c.enableSpring(1, true);
c.setStiffness(1, limits[22]);
c.setDamping(1, limits[23]);
}
else{c.enableSpring(1,false);}
if(limits[24] != 0)
{
else {
c.enableSpring(1, false);
}
if (limits[24] != 0) {
c.enableSpring(2, true);
c.setStiffness(2, limits[25]);
c.setDamping(2, limits[26]);
}
else{c.enableSpring(2,false);}
if(limits[27] != 0)
{
else {
c.enableSpring(2, false);
}
if (limits[27] != 0) {
c.enableSpring(3, true);
c.setStiffness(3, limits[28]);
c.setDamping(3, limits[29]);
}
else{c.enableSpring(3,false);}
if(limits[30] != 0)
{
else {
c.enableSpring(3, false);
}
if (limits[30] != 0) {
c.enableSpring(4, true);
c.setStiffness(4, limits[31]);
c.setDamping(4, limits[32]);
}
else{c.enableSpring(4,false);}
if(limits[33] != 0)
{
else {
c.enableSpring(4, false);
}
if (limits[33] != 0) {
c.enableSpring(5, true);
c.setStiffness(5, limits[34]);
c.setDamping(5, limits[35]);
}
else{c.enableSpring(5,false);}
else {
c.enableSpring(5, false);
}
con = cast c;
}
@ -260,19 +250,14 @@ class PhysicsConstraint extends iron.Trait {
else if (type == "SLIDER") {
var c = new bullet.Bt.SliderConstraint(rb1.body, rb2.body, trans1, trans2, true);
if (limits[0] != 0) {
c.setLowerLinLimit(limits[1]);
c.setUpperLinLimit(limits[2]);
}
con = cast c;
}
else if (type == "PISTON") {
var c = new bullet.Bt.SliderConstraint(rb1.body, rb2.body, trans1, trans2, true);
if (limits[0] != 0) {
@ -289,8 +274,6 @@ class PhysicsConstraint extends iron.Trait {
}
con = cast c;
}
if (breakingThreshold > 0) con.setBreakingImpulseThreshold(breakingThreshold);

View file

@ -15,6 +15,7 @@ import armory.trait.physics.RigidBody;
import armory.trait.physics.PhysicsWorld;
class PhysicsHook extends Trait {
var target: Object;
var targetName: String;
var targetTransform: Transform;

View file

@ -9,6 +9,7 @@ import iron.math.RayCaster;
import iron.data.SceneFormat;
class Hit {
public var rb: RigidBody;
public var pos: Vec4;
public var normal: Vec4;
@ -20,6 +21,7 @@ class Hit {
}
class ContactPair {
public var a: Int;
public var b: Int;
public var posA: Vec4;
@ -87,8 +89,7 @@ class PhysicsWorld extends Trait {
if (active == null) {
createPhysics();
}
// Scene switch
else {
else { // Scene switch
world = active.world;
dispatcher = active.dispatcher;
gimpactRegistered = active.gimpactRegistered;
@ -189,11 +190,10 @@ class PhysicsWorld extends Trait {
// }
/**
* Used to get intersecting rigid bodies with the passed in RigidBody as reference. Often used when checking for object collisions.
*
* @param body The passed in RigidBody to be checked for intersecting rigid bodies.
* @return Array<RigidBody> or null.
*/
Used to get intersecting rigid bodies with the passed in RigidBody as reference. Often used when checking for object collisions.
@param body The passed in RigidBody to be checked for intersecting rigid bodies.
@return Array<RigidBody> or null.
**/
public function getContacts(body: RigidBody): Array<RigidBody> {
if (contacts.length == 0) return null;
var res: Array<RigidBody> = [];

View file

@ -9,10 +9,10 @@ import iron.object.MeshObject;
import iron.data.MeshData;
/**
* RigidBody is used to allow objects to interact with Physics in your game including collisions and gravity.
* RigidBody can also be used with the getContacts method to detect collisions and run appropriate code.
* The Bullet physics engine is used for these calculations.
*/
RigidBody is used to allow objects to interact with Physics in your game including collisions and gravity.
RigidBody can also be used with the getContacts method to detect collisions and run appropriate code.
The Bullet physics engine is used for these calculations.
**/
@:access(armory.trait.physics.bullet.PhysicsWorld)
class RigidBody extends iron.Trait {
@ -460,10 +460,8 @@ class RigidBody extends iron.Trait {
quat.fromMat(t.world);
quat1.setValue(quat.x, quat.y, quat.z, quat.w);
trans1.setRotation(quat1);
if(animated)
body.getMotionState().setWorldTransform(trans1);
else
body.setCenterOfMassTransform(trans1);
if (animated) body.getMotionState().setWorldTransform(trans1);
else body.setCenterOfMassTransform(trans1);
if (currentScaleX != t.scale.x || currentScaleY != t.scale.y || currentScaleZ != t.scale.z) setScale(t.scale);
activate();
}