From db4f0cc107cf987eb9cee6b23ac960c8da2433b2 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Thu, 19 Dec 2019 23:54:08 +0100 Subject: [PATCH] Apply checkstyle --- Sources/armory/data/Config.hx | 48 ++--- Sources/armory/logicnode/ActiveCameraNode.hx | 4 +- Sources/armory/logicnode/ActiveSceneNode.hx | 4 +- Sources/armory/logicnode/AddGroupNode.hx | 8 +- Sources/armory/logicnode/AddTraitNode.hx | 10 +- Sources/armory/logicnode/AlternateNode.hx | 4 +- Sources/armory/logicnode/AnimActionNode.hx | 8 +- .../armory/logicnode/AnimationStateNode.hx | 6 +- .../armory/logicnode/AppendTransformNode.hx | 8 +- .../logicnode/ApplyForceAtLocationNode.hx | 16 +- Sources/armory/logicnode/ApplyForceNode.hx | 14 +- .../logicnode/ApplyImpulseAtLocationNode.hx | 16 +- Sources/armory/logicnode/ApplyImpulseNode.hx | 14 +- .../logicnode/ApplyTorqueImpulseNode.hx | 12 +- Sources/armory/logicnode/ApplyTorqueNode.hx | 12 +- Sources/armory/logicnode/ArrayAddNode.hx | 8 +- .../armory/logicnode/ArrayAddUniqueNode.hx | 10 +- Sources/armory/logicnode/ArrayBooleanNode.hx | 10 +- Sources/armory/logicnode/ArrayColorNode.hx | 10 +- Sources/armory/logicnode/ArrayFloatNode.hx | 10 +- Sources/armory/logicnode/ArrayGetNode.hx | 10 +- Sources/armory/logicnode/ArrayInArrayNode.hx | 10 +- Sources/armory/logicnode/ArrayIntegerNode.hx | 10 +- Sources/armory/logicnode/ArrayLengthNode.hx | 6 +- Sources/armory/logicnode/ArrayLoopNode.hx | 10 +- Sources/armory/logicnode/ArrayNode.hx | 10 +- Sources/armory/logicnode/ArrayObjectNode.hx | 10 +- Sources/armory/logicnode/ArrayPopNode.hx | 8 +- Sources/armory/logicnode/ArrayRemoveNode.hx | 12 +- .../armory/logicnode/ArrayRemoveValueNode.hx | 12 +- Sources/armory/logicnode/ArraySetNode.hx | 10 +- Sources/armory/logicnode/ArrayShiftNode.hx | 6 +- Sources/armory/logicnode/ArraySliceNode.hx | 12 +- Sources/armory/logicnode/ArraySpliceNode.hx | 6 +- Sources/armory/logicnode/ArrayStringNode.hx | 10 +- Sources/armory/logicnode/ArrayVectorNode.hx | 10 +- Sources/armory/logicnode/BlendActionNode.hx | 14 +- Sources/armory/logicnode/BoneFKNode.hx | 18 +- Sources/armory/logicnode/BoneIKNode.hx | 14 +- Sources/armory/logicnode/BooleanNode.hx | 8 +- Sources/armory/logicnode/BranchNode.hx | 6 +- Sources/armory/logicnode/CallFunctionNode.hx | 21 +- Sources/armory/logicnode/CallGroupNode.hx | 8 +- .../armory/logicnode/CallHaxeStaticNode.hx | 14 +- .../armory/logicnode/CanvasGetCheckboxNode.hx | 10 +- .../logicnode/CanvasGetInputTextNode.hx | 10 +- .../armory/logicnode/CanvasGetLocationNode.hx | 14 +- Sources/armory/logicnode/CanvasGetPBNode.hx | 14 +- .../armory/logicnode/CanvasGetPositionNode.hx | 10 +- .../armory/logicnode/CanvasGetRotationNode.hx | 12 +- .../armory/logicnode/CanvasGetScaleNode.hx | 14 +- .../armory/logicnode/CanvasGetSliderNode.hx | 10 +- .../armory/logicnode/CanvasSetAssetNode.hx | 10 +- .../armory/logicnode/CanvasSetLocationNode.hx | 12 +- Sources/armory/logicnode/CanvasSetPBNode.hx | 12 +- .../armory/logicnode/CanvasSetRotationNode.hx | 10 +- .../armory/logicnode/CanvasSetScaleNode.hx | 12 +- .../armory/logicnode/CanvasSetSliderNode.hx | 13 +- .../logicnode/CanvasSetTextColorNode.hx | 18 +- Sources/armory/logicnode/CanvasSetTextNode.hx | 10 +- .../armory/logicnode/CanvasSetVisibleNode.hx | 10 +- Sources/armory/logicnode/CaseStringNode.hx | 8 +- .../armory/logicnode/CastPhysicsRayNode.hx | 17 +- Sources/armory/logicnode/ClearParentNode.hx | 10 +- Sources/armory/logicnode/ColorNode.hx | 6 +- Sources/armory/logicnode/CompareNode.hx | 12 +- .../armory/logicnode/ConcatenateStringNode.hx | 6 +- .../armory/logicnode/ContainsStringNode.hx | 10 +- Sources/armory/logicnode/DegToRadNode.hx | 6 +- Sources/armory/logicnode/DisplayInfoNode.hx | 4 +- Sources/armory/logicnode/DynamicNode.hx | 8 +- Sources/armory/logicnode/ExpressionNode.hx | 10 +- Sources/armory/logicnode/FloatNode.hx | 8 +- Sources/armory/logicnode/FunctionNode.hx | 10 +- .../armory/logicnode/FunctionOutputNode.hx | 6 +- Sources/armory/logicnode/GamepadCoordsNode.hx | 12 +- Sources/armory/logicnode/GateNode.hx | 13 +- Sources/armory/logicnode/GetCameraFovNode.hx | 6 +- Sources/armory/logicnode/GetChildNode.hx | 16 +- Sources/armory/logicnode/GetChildrenNode.hx | 6 +- Sources/armory/logicnode/GetContactsNode.hx | 6 +- Sources/armory/logicnode/GetDistanceNode.hx | 8 +- .../armory/logicnode/GetFirstContactNode.hx | 6 +- Sources/armory/logicnode/GetGravityNode.hx | 10 +- Sources/armory/logicnode/GetGroupNode.hx | 6 +- .../armory/logicnode/GetHaxePropertyNode.hx | 8 +- Sources/armory/logicnode/GetLocationNode.hx | 6 +- Sources/armory/logicnode/GetMaterialNode.hx | 6 +- Sources/armory/logicnode/GetMeshNode.hx | 6 +- Sources/armory/logicnode/GetNameNode.hx | 8 +- Sources/armory/logicnode/GetObjectNode.hx | 6 +- Sources/armory/logicnode/GetParentNode.hx | 6 +- Sources/armory/logicnode/GetPropertyNode.hx | 8 +- Sources/armory/logicnode/GetRotationNode.hx | 15 +- Sources/armory/logicnode/GetScaleNode.hx | 6 +- Sources/armory/logicnode/GetTraitNode.hx | 10 +- Sources/armory/logicnode/GetTransformNode.hx | 6 +- Sources/armory/logicnode/GetVelocityNode.hx | 8 +- Sources/armory/logicnode/GetVisibleNode.hx | 6 +- Sources/armory/logicnode/GlobalObjectNode.hx | 4 +- Sources/armory/logicnode/GoToLocationNode.hx | 14 +- Sources/armory/logicnode/GroupNode.hx | 7 +- Sources/armory/logicnode/GroupOutputNode.hx | 5 +- Sources/armory/logicnode/HasContactNode.hx | 8 +- Sources/armory/logicnode/IntegerNode.hx | 8 +- Sources/armory/logicnode/InverseNode.hx | 4 +- Sources/armory/logicnode/IsFalseNode.hx | 7 +- Sources/armory/logicnode/IsNoneNode.hx | 7 +- Sources/armory/logicnode/IsNotNoneNode.hx | 7 +- Sources/armory/logicnode/IsTrueNode.hx | 7 +- Sources/armory/logicnode/LengthStringNode.hx | 6 +- Sources/armory/logicnode/LoadUrlNode.hx | 4 +- Sources/armory/logicnode/LogicNode.hx | 44 ++-- Sources/armory/logicnode/LookAtNode.hx | 10 +- Sources/armory/logicnode/LoopBreakNode.hx | 4 +- Sources/armory/logicnode/LoopNode.hx | 12 +- Sources/armory/logicnode/MaskNode.hx | 13 +- Sources/armory/logicnode/MaterialNode.hx | 12 +- Sources/armory/logicnode/MathNode.hx | 12 +- Sources/armory/logicnode/MatrixMathNode.hx | 11 +- Sources/armory/logicnode/MergeNode.hx | 4 +- Sources/armory/logicnode/MergedGamepadNode.hx | 12 +- .../armory/logicnode/MergedKeyboardNode.hx | 14 +- Sources/armory/logicnode/MergedMouseNode.hx | 14 +- Sources/armory/logicnode/MergedSurfaceNode.hx | 6 +- .../logicnode/MergedVirtualButtonNode.hx | 8 +- Sources/armory/logicnode/MeshNode.hx | 12 +- Sources/armory/logicnode/MixNode.hx | 20 +- Sources/armory/logicnode/MouseCoordsNode.hx | 4 +- .../armory/logicnode/NavigableLocationNode.hx | 8 +- Sources/armory/logicnode/NoneNode.hx | 4 +- Sources/armory/logicnode/NotNode.hx | 8 +- Sources/armory/logicnode/NullNode.hx | 4 +- Sources/armory/logicnode/ObjectNode.hx | 10 +- .../armory/logicnode/OnActionMarkerNode.hx | 10 +- .../armory/logicnode/OnContactArrayNode.hx | 8 +- Sources/armory/logicnode/OnContactNode.hx | 8 +- Sources/armory/logicnode/OnEventNode.hx | 12 +- Sources/armory/logicnode/OnGamepadNode.hx | 8 +- Sources/armory/logicnode/OnInitNode.hx | 2 +- Sources/armory/logicnode/OnKeyboardNode.hx | 6 +- Sources/armory/logicnode/OnMouseNode.hx | 6 +- Sources/armory/logicnode/OnSurfaceNode.hx | 4 +- Sources/armory/logicnode/OnTimerNode.hx | 2 +- Sources/armory/logicnode/OnUpdateNode.hx | 6 +- .../armory/logicnode/OnVirtualButtonNode.hx | 6 +- .../armory/logicnode/OnVolumeTriggerNode.hx | 8 +- Sources/armory/logicnode/ParseFloatNode.hx | 6 +- Sources/armory/logicnode/PauseActionNode.hx | 8 +- Sources/armory/logicnode/PauseSoundNode.hx | 6 +- .../armory/logicnode/PauseTilesheetNode.hx | 8 +- Sources/armory/logicnode/PauseTraitNode.hx | 6 +- Sources/armory/logicnode/PickLocationNode.hx | 10 +- Sources/armory/logicnode/PickObjectNode.hx | 6 +- Sources/armory/logicnode/PlayActionNode.hx | 12 +- Sources/armory/logicnode/PlaySoundNode.hx | 6 +- Sources/armory/logicnode/PlaySoundRawNode.hx | 8 +- Sources/armory/logicnode/PlayTilesheetNode.hx | 10 +- Sources/armory/logicnode/PrintNode.hx | 8 +- Sources/armory/logicnode/QuaternionNode.hx | 6 +- Sources/armory/logicnode/RadToDegNode.hx | 6 +- Sources/armory/logicnode/RandomBooleanNode.hx | 4 +- Sources/armory/logicnode/RandomColorNode.hx | 4 +- Sources/armory/logicnode/RandomFloatNode.hx | 8 +- Sources/armory/logicnode/RandomIntegerNode.hx | 8 +- Sources/armory/logicnode/RandomVectorNode.hx | 8 +- Sources/armory/logicnode/ReadFileNode.hx | 18 +- Sources/armory/logicnode/ReadJsonNode.hx | 20 +- Sources/armory/logicnode/ReadStorageNode.hx | 16 +- .../armory/logicnode/RemoveActiveSceneNode.hx | 5 +- Sources/armory/logicnode/RemoveGroupNode.hx | 6 +- Sources/armory/logicnode/RemoveObjectNode.hx | 8 +- Sources/armory/logicnode/RemoveTraitNode.hx | 8 +- Sources/armory/logicnode/ResumeActionNode.hx | 8 +- .../armory/logicnode/ResumeTilesheetNode.hx | 8 +- Sources/armory/logicnode/ResumeTraitNode.hx | 6 +- .../logicnode/RotateObjectAroundAxisNode.hx | 10 +- Sources/armory/logicnode/RotateObjectNode.hx | 9 +- Sources/armory/logicnode/RpConfigNode.hx | 12 +- Sources/armory/logicnode/RpMSAANode.hx | 8 +- .../armory/logicnode/RpShadowQualityNode.hx | 10 +- Sources/armory/logicnode/RpSuperSampleNode.hx | 8 +- Sources/armory/logicnode/ScaleObjectNode.hx | 9 +- Sources/armory/logicnode/SceneNode.hx | 10 +- Sources/armory/logicnode/SceneRootNode.hx | 6 +- .../logicnode/ScreenToWorldSpaceNode.hx | 8 +- Sources/armory/logicnode/ScriptNode.hx | 18 +- Sources/armory/logicnode/SelfNode.hx | 4 +- Sources/armory/logicnode/SelfTraitNode.hx | 4 +- Sources/armory/logicnode/SendEventNode.hx | 14 +- .../armory/logicnode/SendGlobalEventNode.hx | 11 +- Sources/armory/logicnode/SensorCoordsNode.hx | 4 +- Sources/armory/logicnode/SeparateColorNode.hx | 6 +- .../armory/logicnode/SeparateTransformNode.hx | 6 +- .../armory/logicnode/SeparateVectorNode.hx | 6 +- Sources/armory/logicnode/SequenceNode.hx | 4 +- .../armory/logicnode/SetActionSpeedNode.hx | 10 +- Sources/armory/logicnode/SetCameraFovNode.hx | 10 +- Sources/armory/logicnode/SetCameraNode.hx | 7 +- .../armory/logicnode/SetGravityEnabledNode.hx | 12 +- Sources/armory/logicnode/SetGravityNode.hx | 10 +- .../armory/logicnode/SetHaxePropertyNode.hx | 12 +- Sources/armory/logicnode/SetLightColorNode.hx | 10 +- .../armory/logicnode/SetLightStrengthNode.hx | 10 +- Sources/armory/logicnode/SetLocationNode.hx | 8 +- .../logicnode/SetMaterialImageParamNode.hx | 9 +- Sources/armory/logicnode/SetMaterialNode.hx | 10 +- .../logicnode/SetMaterialRgbParamNode.hx | 6 +- .../armory/logicnode/SetMaterialSlotNode.hx | 12 +- .../logicnode/SetMaterialValueParamNode.hx | 7 +- Sources/armory/logicnode/SetMeshNode.hx | 10 +- Sources/armory/logicnode/SetMouseLockNode.hx | 6 +- Sources/armory/logicnode/SetNameNode.hx | 10 +- Sources/armory/logicnode/SetParentBoneNode.hx | 12 +- Sources/armory/logicnode/SetParentNode.hx | 10 +- .../armory/logicnode/SetParticleSpeedNode.hx | 10 +- Sources/armory/logicnode/SetPropertyNode.hx | 12 +- Sources/armory/logicnode/SetRotationNode.hx | 21 +- Sources/armory/logicnode/SetScaleNode.hx | 8 +- Sources/armory/logicnode/SetSceneNode.hx | 12 +- Sources/armory/logicnode/SetTimeScaleNode.hx | 6 +- Sources/armory/logicnode/SetTransformNode.hx | 8 +- Sources/armory/logicnode/SetVariableNode.hx | 6 +- Sources/armory/logicnode/SetVelocityNode.hx | 18 +- Sources/armory/logicnode/SetVisibleNode.hx | 10 +- Sources/armory/logicnode/ShowMouseNode.hx | 6 +- Sources/armory/logicnode/ShutdownNode.hx | 4 +- Sources/armory/logicnode/SleepNode.hx | 6 +- Sources/armory/logicnode/SpawnObjectNode.hx | 16 +- Sources/armory/logicnode/SpawnSceneNode.hx | 14 +- Sources/armory/logicnode/SplitStringNode.hx | 8 +- Sources/armory/logicnode/StopAgentNode.hx | 12 +- Sources/armory/logicnode/StopSoundNode.hx | 6 +- Sources/armory/logicnode/StringNode.hx | 8 +- Sources/armory/logicnode/SubStringNode.hx | 10 +- Sources/armory/logicnode/SurfaceCoordsNode.hx | 4 +- Sources/armory/logicnode/SwitchNode.hx | 8 +- Sources/armory/logicnode/TimeNode.hx | 4 +- Sources/armory/logicnode/TimerNode.hx | 8 +- Sources/armory/logicnode/ToBoolNode.hx | 8 +- Sources/armory/logicnode/TraitNode.hx | 12 +- Sources/armory/logicnode/TransformMathNode.hx | 12 +- Sources/armory/logicnode/TransformNode.hx | 14 +- .../armory/logicnode/TranslateObjectNode.hx | 15 +- .../logicnode/TranslateOnLocalAxisNode.hx | 21 +- .../armory/logicnode/VectorClampToSizeNode.hx | 10 +- .../logicnode/VectorFromTransformNode.hx | 8 +- Sources/armory/logicnode/VectorMathNode.hx | 10 +- Sources/armory/logicnode/VectorMixNode.hx | 20 +- Sources/armory/logicnode/VectorNode.hx | 6 +- Sources/armory/logicnode/VolumeTriggerNode.hx | 11 +- Sources/armory/logicnode/WhileNode.hx | 6 +- Sources/armory/logicnode/WindowInfoNode.hx | 4 +- .../logicnode/WorldToScreenSpaceNode.hx | 8 +- Sources/armory/logicnode/WriteFileNode.hx | 8 +- Sources/armory/logicnode/WriteJsonNode.hx | 8 +- Sources/armory/logicnode/WriteStorageNode.hx | 8 +- Sources/armory/object/Uniforms.hx | 10 +- .../renderpath/DynamicResolutionScale.hx | 12 +- Sources/armory/renderpath/HosekWilkie.hx | 69 +++--- Sources/armory/renderpath/Inc.hx | 34 +-- .../armory/renderpath/RenderPathCreator.hx | 24 +-- .../armory/renderpath/RenderPathDeferred.hx | 22 +- .../armory/renderpath/RenderPathForward.hx | 12 +- .../armory/renderpath/RenderPathRaytracer.hx | 19 +- Sources/armory/system/Event.hx | 18 +- Sources/armory/system/Logic.hx | 92 ++++---- Sources/armory/system/Starter.hx | 25 ++- Sources/armory/trait/ArcBall.hx | 2 - Sources/armory/trait/Character.hx | 20 +- Sources/armory/trait/FirstPersonController.hx | 12 +- Sources/armory/trait/FollowCamera.hx | 21 +- Sources/armory/trait/Macro.hx | 6 +- Sources/armory/trait/NavAgent.hx | 14 +- Sources/armory/trait/NavMesh.hx | 39 ++-- Sources/armory/trait/PhysicsBreak.hx | 151 +++++++------- Sources/armory/trait/PhysicsDrag.hx | 12 +- Sources/armory/trait/SimpleMoveObject.hx | 8 +- Sources/armory/trait/SimpleRotateObject.hx | 8 +- Sources/armory/trait/SimpleScaleObject.hx | 10 +- Sources/armory/trait/ThirdPersonController.hx | 20 +- Sources/armory/trait/VehicleBody.hx | 78 +++---- Sources/armory/trait/VirtualGamepad.hx | 6 +- Sources/armory/trait/WalkNavigation.hx | 36 ++-- Sources/armory/trait/internal/Bridge.hx | 2 +- .../armory/trait/internal/CameraController.hx | 30 +-- Sources/armory/trait/internal/CanvasScript.hx | 40 ++-- Sources/armory/trait/internal/DebugConsole.hx | 90 ++++---- Sources/armory/trait/internal/DebugDraw.hx | 44 ++-- Sources/armory/trait/internal/LivePatch.hx | 4 +- .../armory/trait/internal/LoadingScreen.hx | 2 +- Sources/armory/trait/internal/MovieTexture.hx | 24 +-- Sources/armory/trait/internal/WasmScript.hx | 53 ++--- Sources/armory/trait/navigation/Navigation.hx | 8 +- .../bullet/KinematicCharacterController.hx | 88 ++++---- .../trait/physics/bullet/PhysicsConstraint.hx | 197 ++++++++---------- .../trait/physics/bullet/PhysicsHook.hx | 27 +-- .../trait/physics/bullet/PhysicsWorld.hx | 130 ++++++------ .../armory/trait/physics/bullet/RigidBody.hx | 186 ++++++++--------- .../armory/trait/physics/bullet/SoftBody.hx | 26 +-- 300 files changed, 2055 insertions(+), 2102 deletions(-) diff --git a/Sources/armory/data/Config.hx b/Sources/armory/data/Config.hx index df52e141..ec08c946 100644 --- a/Sources/armory/data/Config.hx +++ b/Sources/armory/data/Config.hx @@ -2,22 +2,22 @@ package armory.data; class Config { - public static var raw:TConfig = null; + public static var raw: TConfig = null; public static var configLoaded = false; - public static function load(done:Void->Void) { + 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(); }); } - catch(e:Dynamic) { done(); } + catch (e: Dynamic) { done(); } } 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()); @@ -30,23 +30,23 @@ class Config { } typedef TConfig = { - @:optional var debug_console:Null; - @:optional var window_mode:Null; // window, fullscreen - @:optional var window_w:Null; - @:optional var window_h:Null; - @:optional var window_resizable:Null; - @:optional var window_maximizable:Null; - @:optional var window_minimizable:Null; - @:optional var window_vsync:Null; - @:optional var window_msaa:Null; - @:optional var window_scale:Null; - @:optional var rp_supersample:Null; - @:optional var rp_shadowmap_cube:Null; // size - @:optional var rp_shadowmap_cascade:Null; // size for single cascade - @:optional var rp_ssgi:Null; - @:optional var rp_ssr:Null; - @:optional var rp_bloom:Null; - @:optional var rp_motionblur:Null; - @:optional var rp_gi:Null; // voxelao - @:optional var rp_dynres:Null; // dynamic resolution scaling + @:optional var debug_console: Null; + @:optional var window_mode: Null; // window, fullscreen + @:optional var window_w: Null; + @:optional var window_h: Null; + @:optional var window_resizable: Null; + @:optional var window_maximizable: Null; + @:optional var window_minimizable: Null; + @:optional var window_vsync: Null; + @:optional var window_msaa: Null; + @:optional var window_scale: Null; + @:optional var rp_supersample: Null; + @:optional var rp_shadowmap_cube: Null; // size + @:optional var rp_shadowmap_cascade: Null; // size for single cascade + @:optional var rp_ssgi: Null; + @:optional var rp_ssr: Null; + @:optional var rp_bloom: Null; + @:optional var rp_motionblur: Null; + @:optional var rp_gi: Null; // voxelao + @:optional var rp_dynres: Null; // dynamic resolution scaling } diff --git a/Sources/armory/logicnode/ActiveCameraNode.hx b/Sources/armory/logicnode/ActiveCameraNode.hx index 78482435..0af87d53 100644 --- a/Sources/armory/logicnode/ActiveCameraNode.hx +++ b/Sources/armory/logicnode/ActiveCameraNode.hx @@ -2,9 +2,9 @@ package armory.logicnode; class ActiveCameraNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { return iron.Scene.active.camera; } + override function get(from: Int): Dynamic { return iron.Scene.active.camera; } } diff --git a/Sources/armory/logicnode/ActiveSceneNode.hx b/Sources/armory/logicnode/ActiveSceneNode.hx index 6820a4f1..b183f853 100644 --- a/Sources/armory/logicnode/ActiveSceneNode.hx +++ b/Sources/armory/logicnode/ActiveSceneNode.hx @@ -2,9 +2,9 @@ package armory.logicnode; class ActiveSceneNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { return iron.Scene.active.raw.name; } + override function get(from: Int): Dynamic { return iron.Scene.active.raw.name; } } diff --git a/Sources/armory/logicnode/AddGroupNode.hx b/Sources/armory/logicnode/AddGroupNode.hx index 8b72b155..a887faee 100644 --- a/Sources/armory/logicnode/AddGroupNode.hx +++ b/Sources/armory/logicnode/AddGroupNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class AddGroupNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var groupName:String = inputs[1].get(); + override function run(from: Int) { + var groupName: String = inputs[1].get(); var raw = iron.Scene.active.raw; - + // Already exists for (g in raw.groups) { if (g.name == groupName) { diff --git a/Sources/armory/logicnode/AddTraitNode.hx b/Sources/armory/logicnode/AddTraitNode.hx index 05a74747..d6139fb1 100644 --- a/Sources/armory/logicnode/AddTraitNode.hx +++ b/Sources/armory/logicnode/AddTraitNode.hx @@ -4,14 +4,14 @@ import iron.object.Object; class AddTraitNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var trait:Dynamic = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var trait: Dynamic = inputs[2].get(); + if (object == null || trait == null) return; object.addTrait(trait); diff --git a/Sources/armory/logicnode/AlternateNode.hx b/Sources/armory/logicnode/AlternateNode.hx index e19395cf..c5628ed5 100644 --- a/Sources/armory/logicnode/AlternateNode.hx +++ b/Sources/armory/logicnode/AlternateNode.hx @@ -4,11 +4,11 @@ class AlternateNode extends LogicNode { var b = true; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { b ? runOutput(0) : runOutput(1); b = !b; } diff --git a/Sources/armory/logicnode/AnimActionNode.hx b/Sources/armory/logicnode/AnimActionNode.hx index f1bd9a01..46c692bf 100644 --- a/Sources/armory/logicnode/AnimActionNode.hx +++ b/Sources/armory/logicnode/AnimActionNode.hx @@ -2,19 +2,19 @@ package armory.logicnode; class AnimActionNode extends LogicNode { - public var value:String; + public var value: String; - public function new(tree:LogicTree, value = "") { + public function new(tree: LogicTree, value = "") { super(tree); this.value = value; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (inputs.length > 0) return inputs[0].get(); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { if (inputs.length > 0) inputs[0].set(value); else this.value = value; } diff --git a/Sources/armory/logicnode/AnimationStateNode.hx b/Sources/armory/logicnode/AnimationStateNode.hx index dea898f5..75b8e9ab 100644 --- a/Sources/armory/logicnode/AnimationStateNode.hx +++ b/Sources/armory/logicnode/AnimationStateNode.hx @@ -4,12 +4,12 @@ import iron.object.Object; class AnimationStateNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; var animation = object.animation; diff --git a/Sources/armory/logicnode/AppendTransformNode.hx b/Sources/armory/logicnode/AppendTransformNode.hx index 1149f2f2..2f573efb 100644 --- a/Sources/armory/logicnode/AppendTransformNode.hx +++ b/Sources/armory/logicnode/AppendTransformNode.hx @@ -8,13 +8,13 @@ import armory.trait.physics.RigidBody; class AppendTransformNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var matrix:Mat4 = inputs[2].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var matrix: Mat4 = inputs[2].get(); if (object == null || matrix == null) return; diff --git a/Sources/armory/logicnode/ApplyForceAtLocationNode.hx b/Sources/armory/logicnode/ApplyForceAtLocationNode.hx index 8bb0202b..d7ba973c 100644 --- a/Sources/armory/logicnode/ApplyForceAtLocationNode.hx +++ b/Sources/armory/logicnode/ApplyForceAtLocationNode.hx @@ -6,20 +6,20 @@ import armory.trait.physics.RigidBody; class ApplyForceAtLocationNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var force:Vec4 = inputs[2].get(); - var location:Vec4 = inputs[3].get(); - var local:Bool = inputs.length > 3 ? inputs[3].get() : false; - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var force: Vec4 = inputs[2].get(); + var location: Vec4 = inputs[3].get(); + var local: Bool = inputs.length > 3 ? inputs[3].get() : false; + if (object == null || force == null || location == null) return; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); if (!local) { rb.applyForce(force, location); } diff --git a/Sources/armory/logicnode/ApplyForceNode.hx b/Sources/armory/logicnode/ApplyForceNode.hx index 3a6db995..67601233 100644 --- a/Sources/armory/logicnode/ApplyForceNode.hx +++ b/Sources/armory/logicnode/ApplyForceNode.hx @@ -6,19 +6,19 @@ import armory.trait.physics.RigidBody; class ApplyForceNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var force:Vec4 = inputs[2].get(); - var local:Bool = inputs.length > 3 ? inputs[3].get() : false; - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var force: Vec4 = inputs[2].get(); + var local: Bool = inputs.length > 3 ? inputs[3].get() : false; + if (object == null || force == null) return; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); if (!local) { rb.applyForce(force); } diff --git a/Sources/armory/logicnode/ApplyImpulseAtLocationNode.hx b/Sources/armory/logicnode/ApplyImpulseAtLocationNode.hx index 7f500f95..170d9eb5 100644 --- a/Sources/armory/logicnode/ApplyImpulseAtLocationNode.hx +++ b/Sources/armory/logicnode/ApplyImpulseAtLocationNode.hx @@ -6,20 +6,20 @@ import armory.trait.physics.RigidBody; class ApplyImpulseAtLocationNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var impulse:Vec4 = inputs[2].get(); - var location:Vec4 = inputs[3].get(); - var local:Bool = inputs.length > 3 ? inputs[3].get() : false; - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var impulse: Vec4 = inputs[2].get(); + var location: Vec4 = inputs[3].get(); + var local: Bool = inputs.length > 3 ? inputs[3].get() : false; + if (object == null || impulse == null || location == null) return; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); if (!local) { rb.applyImpulse(impulse, location); } else { diff --git a/Sources/armory/logicnode/ApplyImpulseNode.hx b/Sources/armory/logicnode/ApplyImpulseNode.hx index cd55297e..7b65aa03 100644 --- a/Sources/armory/logicnode/ApplyImpulseNode.hx +++ b/Sources/armory/logicnode/ApplyImpulseNode.hx @@ -6,19 +6,19 @@ import armory.trait.physics.RigidBody; class ApplyImpulseNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var impulse:Vec4 = inputs[2].get(); - var local:Bool = inputs.length > 3 ? inputs[3].get() : false; - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var impulse: Vec4 = inputs[2].get(); + var local: Bool = inputs.length > 3 ? inputs[3].get() : false; + if (object == null || impulse == null) return; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); if (!local) { rb.applyImpulse(impulse); } diff --git a/Sources/armory/logicnode/ApplyTorqueImpulseNode.hx b/Sources/armory/logicnode/ApplyTorqueImpulseNode.hx index fad505cf..10c30c39 100644 --- a/Sources/armory/logicnode/ApplyTorqueImpulseNode.hx +++ b/Sources/armory/logicnode/ApplyTorqueImpulseNode.hx @@ -6,18 +6,18 @@ import armory.trait.physics.RigidBody; class ApplyTorqueImpulseNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var torque:Vec4 = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var torque: Vec4 = inputs[2].get(); + if (object == null || torque == null) return; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); rb.applyTorqueImpulse(torque); #end diff --git a/Sources/armory/logicnode/ApplyTorqueNode.hx b/Sources/armory/logicnode/ApplyTorqueNode.hx index bf49852f..d48f6fd5 100644 --- a/Sources/armory/logicnode/ApplyTorqueNode.hx +++ b/Sources/armory/logicnode/ApplyTorqueNode.hx @@ -6,18 +6,18 @@ import armory.trait.physics.RigidBody; class ApplyTorqueNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var torque:Vec4 = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var torque: Vec4 = inputs[2].get(); + if (object == null || torque == null) return; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); rb.applyTorque(torque); #end diff --git a/Sources/armory/logicnode/ArrayAddNode.hx b/Sources/armory/logicnode/ArrayAddNode.hx index 67079746..fb4787ec 100644 --- a/Sources/armory/logicnode/ArrayAddNode.hx +++ b/Sources/armory/logicnode/ArrayAddNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class ArrayAddNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var ar:Array = inputs[1].get(); + override function run(from: Int) { + var ar: Array = inputs[1].get(); if (ar == null) return; if (inputs.length > 2) { for (i in 2...inputs.length) { - var value:Dynamic = inputs[i].get(); + var value: Dynamic = inputs[i].get(); ar.push(value); } } diff --git a/Sources/armory/logicnode/ArrayAddUniqueNode.hx b/Sources/armory/logicnode/ArrayAddUniqueNode.hx index f9e24b78..fafde3d6 100644 --- a/Sources/armory/logicnode/ArrayAddUniqueNode.hx +++ b/Sources/armory/logicnode/ArrayAddUniqueNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class ArrayAddUniqueNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var ar:Array = inputs[1].get(); + override function run(from: Int) { + var ar: Array = inputs[1].get(); if (ar == null) return; - + if (inputs.length > 2) { for (i in 2...inputs.length) { - var value:Dynamic = inputs[i].get(); + var value: Dynamic = inputs[i].get(); if (ar.indexOf(value) == -1) ar.push(value); } } diff --git a/Sources/armory/logicnode/ArrayBooleanNode.hx b/Sources/armory/logicnode/ArrayBooleanNode.hx index c3fb06e2..8eea5d51 100644 --- a/Sources/armory/logicnode/ArrayBooleanNode.hx +++ b/Sources/armory/logicnode/ArrayBooleanNode.hx @@ -2,18 +2,18 @@ package armory.logicnode; class ArrayBooleanNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:Bool = inp.get(); + var val: Bool = inp.get(); value.push(val); } } @@ -21,7 +21,7 @@ class ArrayBooleanNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ArrayColorNode.hx b/Sources/armory/logicnode/ArrayColorNode.hx index d4bc55f6..20f7a17c 100644 --- a/Sources/armory/logicnode/ArrayColorNode.hx +++ b/Sources/armory/logicnode/ArrayColorNode.hx @@ -4,18 +4,18 @@ import iron.math.Vec4; class ArrayColorNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:Vec4 = inp.get(); + var val: Vec4 = inp.get(); value.push(val); } } @@ -23,7 +23,7 @@ class ArrayColorNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ArrayFloatNode.hx b/Sources/armory/logicnode/ArrayFloatNode.hx index 9bb19e27..8d5bcf98 100644 --- a/Sources/armory/logicnode/ArrayFloatNode.hx +++ b/Sources/armory/logicnode/ArrayFloatNode.hx @@ -2,18 +2,18 @@ package armory.logicnode; class ArrayFloatNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:Float = inp.get(); + var val: Float = inp.get(); value.push(val); } } @@ -21,7 +21,7 @@ class ArrayFloatNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ArrayGetNode.hx b/Sources/armory/logicnode/ArrayGetNode.hx index caaad707..e445a78c 100644 --- a/Sources/armory/logicnode/ArrayGetNode.hx +++ b/Sources/armory/logicnode/ArrayGetNode.hx @@ -2,15 +2,15 @@ package armory.logicnode; class ArrayGetNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var ar:Array = inputs[0].get(); + override function get(from: Int): Dynamic { + var ar: Array = inputs[0].get(); if (ar == null) return null; - - var i:Int = inputs[1].get(); + + 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)); diff --git a/Sources/armory/logicnode/ArrayInArrayNode.hx b/Sources/armory/logicnode/ArrayInArrayNode.hx index 2b5b10d4..9e561002 100644 --- a/Sources/armory/logicnode/ArrayInArrayNode.hx +++ b/Sources/armory/logicnode/ArrayInArrayNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class ArrayInArrayNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var array:Array = inputs[0].get(); - var value:Dynamic = inputs[1].get(); + override function get(from: Int): Dynamic { + var array: Array = inputs[0].get(); + var value: Dynamic = inputs[1].get(); - return ! (array.indexOf(value) == -1); + return array.indexOf(value) != -1; } } diff --git a/Sources/armory/logicnode/ArrayIntegerNode.hx b/Sources/armory/logicnode/ArrayIntegerNode.hx index 3e2e8a44..2a0c5dda 100644 --- a/Sources/armory/logicnode/ArrayIntegerNode.hx +++ b/Sources/armory/logicnode/ArrayIntegerNode.hx @@ -2,18 +2,18 @@ package armory.logicnode; class ArrayIntegerNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:Int = inp.get(); + var val: Int = inp.get(); value.push(val); } } @@ -21,7 +21,7 @@ class ArrayIntegerNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ArrayLengthNode.hx b/Sources/armory/logicnode/ArrayLengthNode.hx index bddec582..b0a3dc1f 100644 --- a/Sources/armory/logicnode/ArrayLengthNode.hx +++ b/Sources/armory/logicnode/ArrayLengthNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class ArrayLengthNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var ar:Array = inputs[0].get(); + override function get(from: Int): Dynamic { + var ar: Array = inputs[0].get(); return ar != null ? ar.length : 0; } } diff --git a/Sources/armory/logicnode/ArrayLoopNode.hx b/Sources/armory/logicnode/ArrayLoopNode.hx index c7de8460..eb993e90 100644 --- a/Sources/armory/logicnode/ArrayLoopNode.hx +++ b/Sources/armory/logicnode/ArrayLoopNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class ArrayLoopNode extends LogicNode { - var value:Dynamic; + var value: Dynamic; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var ar:Array = inputs[1].get(); + override function run(from: Int) { + var ar: Array = inputs[1].get(); if (ar == null) return; for (val in ar) { @@ -24,7 +24,7 @@ class ArrayLoopNode extends LogicNode { runOutput(2); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return value; } } diff --git a/Sources/armory/logicnode/ArrayNode.hx b/Sources/armory/logicnode/ArrayNode.hx index ebdfdf8b..cfb751ca 100644 --- a/Sources/armory/logicnode/ArrayNode.hx +++ b/Sources/armory/logicnode/ArrayNode.hx @@ -2,18 +2,18 @@ package armory.logicnode; class ArrayNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:Dynamic = inp.get(); + var val: Dynamic = inp.get(); value.push(val); } } @@ -21,7 +21,7 @@ class ArrayNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ArrayObjectNode.hx b/Sources/armory/logicnode/ArrayObjectNode.hx index 753c8d8a..681b8e77 100644 --- a/Sources/armory/logicnode/ArrayObjectNode.hx +++ b/Sources/armory/logicnode/ArrayObjectNode.hx @@ -4,18 +4,18 @@ import iron.object.Object; class ArrayObjectNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:Object = inp.get(); + var val: Object = inp.get(); value.push(val); } } @@ -23,7 +23,7 @@ class ArrayObjectNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ArrayPopNode.hx b/Sources/armory/logicnode/ArrayPopNode.hx index c3eb7e94..94b5b302 100644 --- a/Sources/armory/logicnode/ArrayPopNode.hx +++ b/Sources/armory/logicnode/ArrayPopNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class ArrayPopNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var ar:Array = inputs[0].get(); + override function get(from: Int): Dynamic { + var ar: Array = inputs[0].get(); if (ar == null) return null; - + return ar.pop(); } } diff --git a/Sources/armory/logicnode/ArrayRemoveNode.hx b/Sources/armory/logicnode/ArrayRemoveNode.hx index 42807c0e..31e64508 100644 --- a/Sources/armory/logicnode/ArrayRemoveNode.hx +++ b/Sources/armory/logicnode/ArrayRemoveNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class ArrayRemoveNode extends LogicNode { - var removedValue:Dynamic = null; + var removedValue: Dynamic = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var ar:Array = inputs[1].get(); + override function run(from: Int) { + var ar: Array = inputs[1].get(); if (ar == null) return; - var i:Int = inputs[2].get(); + var i: Int = inputs[2].get(); if (i < 0) i = ar.length + i; removedValue = ar[i]; @@ -21,7 +21,7 @@ class ArrayRemoveNode extends LogicNode { runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return removedValue; } } diff --git a/Sources/armory/logicnode/ArrayRemoveValueNode.hx b/Sources/armory/logicnode/ArrayRemoveValueNode.hx index 0dda13e6..b1bf34a3 100644 --- a/Sources/armory/logicnode/ArrayRemoveValueNode.hx +++ b/Sources/armory/logicnode/ArrayRemoveValueNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class ArrayRemoveValueNode extends LogicNode { - var removedValue:Dynamic = null; + var removedValue: Dynamic = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var ar:Array = inputs[1].get(); + override function run(from: Int) { + var ar: Array = inputs[1].get(); if (ar == null) return; - var val:Dynamic = inputs[2].get(); + var val: Dynamic = inputs[2].get(); removedValue = val; ar.remove(val); @@ -20,7 +20,7 @@ class ArrayRemoveValueNode extends LogicNode { runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return removedValue; } } diff --git a/Sources/armory/logicnode/ArraySetNode.hx b/Sources/armory/logicnode/ArraySetNode.hx index 96bc0193..9a113dc2 100644 --- a/Sources/armory/logicnode/ArraySetNode.hx +++ b/Sources/armory/logicnode/ArraySetNode.hx @@ -2,16 +2,16 @@ package armory.logicnode; class ArraySetNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var ar:Array = inputs[1].get(); + override function run(from: Int) { + var ar: Array = inputs[1].get(); if (ar == null) return; - var i:Int = inputs[2].get(); - var value:Dynamic = inputs[3].get(); + var i: Int = inputs[2].get(); + var value: Dynamic = inputs[3].get(); if (i < 0) ar[ar.length + i] = value; else ar[i] = value; diff --git a/Sources/armory/logicnode/ArrayShiftNode.hx b/Sources/armory/logicnode/ArrayShiftNode.hx index d53544ff..5a49f7bf 100644 --- a/Sources/armory/logicnode/ArrayShiftNode.hx +++ b/Sources/armory/logicnode/ArrayShiftNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class ArrayShiftNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var ar:Array = inputs[0].get(); + override function get(from: Int): Dynamic { + var ar: Array = inputs[0].get(); if (ar == null) return null; return ar.shift(); diff --git a/Sources/armory/logicnode/ArraySliceNode.hx b/Sources/armory/logicnode/ArraySliceNode.hx index 89e338e1..cbdc1bb2 100644 --- a/Sources/armory/logicnode/ArraySliceNode.hx +++ b/Sources/armory/logicnode/ArraySliceNode.hx @@ -2,16 +2,16 @@ package armory.logicnode; class ArraySliceNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var ar:Array = inputs[0].get(); + override function get(from: Int): Dynamic { + var ar: Array = inputs[0].get(); if (ar == null) return null; - - var i:Int = inputs[1].get(); - var end:Int = inputs[2].get(); + + var i: Int = inputs[1].get(); + var end: Int = inputs[2].get(); if (i < 0) i = ar.length + i; if (i < 0 || i > ar.length - 1) { diff --git a/Sources/armory/logicnode/ArraySpliceNode.hx b/Sources/armory/logicnode/ArraySpliceNode.hx index 99026068..237fb8d0 100644 --- a/Sources/armory/logicnode/ArraySpliceNode.hx +++ b/Sources/armory/logicnode/ArraySpliceNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class ArraySpliceNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var ar:Array = inputs[1].get(); + override function run(from: Int) { + var ar: Array = inputs[1].get(); if (ar == null) return; var i = inputs[2].get(); diff --git a/Sources/armory/logicnode/ArrayStringNode.hx b/Sources/armory/logicnode/ArrayStringNode.hx index f194a233..cb47eef6 100644 --- a/Sources/armory/logicnode/ArrayStringNode.hx +++ b/Sources/armory/logicnode/ArrayStringNode.hx @@ -2,18 +2,18 @@ package armory.logicnode; class ArrayStringNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:String = inp.get(); + var val: String = inp.get(); value.push(val); } } @@ -21,7 +21,7 @@ class ArrayStringNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ArrayVectorNode.hx b/Sources/armory/logicnode/ArrayVectorNode.hx index 8bceff0d..fa138543 100644 --- a/Sources/armory/logicnode/ArrayVectorNode.hx +++ b/Sources/armory/logicnode/ArrayVectorNode.hx @@ -4,18 +4,18 @@ import iron.math.Vec4; class ArrayVectorNode extends LogicNode { - public var value:Array = []; + public var value: Array = []; var initialized = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (!initialized) { initialized = true; for (inp in inputs) { - var val:Vec4 = inp.get(); + var val: Vec4 = inp.get(); value.push(val); } } @@ -23,7 +23,7 @@ class ArrayVectorNode extends LogicNode { return from == 0 ? value : value.length; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/BlendActionNode.hx b/Sources/armory/logicnode/BlendActionNode.hx index 37585bc3..39bc9372 100644 --- a/Sources/armory/logicnode/BlendActionNode.hx +++ b/Sources/armory/logicnode/BlendActionNode.hx @@ -4,16 +4,16 @@ import iron.object.Object; class BlendActionNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var action1:String = inputs[2].get(); - var action2:String = inputs[3].get(); - var blendFactor:Float = inputs[4].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var action1: String = inputs[2].get(); + var action2: String = inputs[3].get(); + var blendFactor: Float = inputs[4].get(); + if (object == null) return; var animation = object.animation; if (animation == null) animation = object.getParentArmature(object.name); diff --git a/Sources/armory/logicnode/BoneFKNode.hx b/Sources/armory/logicnode/BoneFKNode.hx index 7b54cf38..8d8cabb1 100644 --- a/Sources/armory/logicnode/BoneFKNode.hx +++ b/Sources/armory/logicnode/BoneFKNode.hx @@ -7,21 +7,21 @@ import iron.math.Mat4; class BoneFKNode extends LogicNode { var notified = false; - var m:Mat4 = null; - var w:Mat4 = null; + var m: Mat4 = null; + var w: Mat4 = null; var iw = Mat4.identity(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { #if arm_skin - var object:Object = inputs[1].get(); - var boneName:String = inputs[2].get(); - var transform:Mat4 = inputs[3].get(); - + var object: Object = inputs[1].get(); + var boneName: String = inputs[2].get(); + var transform: Mat4 = inputs[3].get(); + if (object == null) return; var anim = object.animation != null ? cast(object.animation, BoneAnimation) : null; if (anim == null) anim = object.getParentArmature(object.name); @@ -30,7 +30,7 @@ class BoneFKNode extends LogicNode { var bone = anim.getBone(boneName); m = anim.getBoneMat(bone); w = anim.getAbsMat(bone); - + function moveBone() { m.setFrom(w); m.multmat(transform); diff --git a/Sources/armory/logicnode/BoneIKNode.hx b/Sources/armory/logicnode/BoneIKNode.hx index ae6c5dfe..de187f0a 100644 --- a/Sources/armory/logicnode/BoneIKNode.hx +++ b/Sources/armory/logicnode/BoneIKNode.hx @@ -6,26 +6,26 @@ import iron.math.Vec4; class BoneIKNode extends LogicNode { - var goal:Vec4; + var goal: Vec4; var notified = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { #if arm_skin - var object:Object = inputs[1].get(); - var boneName:String = inputs[2].get(); + var object: Object = inputs[1].get(); + var boneName: String = inputs[2].get(); goal = inputs[3].get(); - + if (object == null || goal == null) return; var anim = object.animation != null ? cast(object.animation, BoneAnimation) : null; if (anim == null) anim = object.getParentArmature(object.name); var bone = anim.getBone(boneName); - + function solveBone() { anim.solveIK(bone, goal); diff --git a/Sources/armory/logicnode/BooleanNode.hx b/Sources/armory/logicnode/BooleanNode.hx index 1cc06fb5..88317f7f 100644 --- a/Sources/armory/logicnode/BooleanNode.hx +++ b/Sources/armory/logicnode/BooleanNode.hx @@ -2,19 +2,19 @@ package armory.logicnode; class BooleanNode extends LogicNode { - public var value:Bool; + public var value: Bool; - public function new(tree:LogicTree, value = false) { + public function new(tree: LogicTree, value = false) { super(tree); this.value = value; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (inputs.length > 0) return inputs[0].get(); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { if (inputs.length > 0) inputs[0].set(value); else this.value = value; } diff --git a/Sources/armory/logicnode/BranchNode.hx b/Sources/armory/logicnode/BranchNode.hx index e344190a..f35f40d5 100644 --- a/Sources/armory/logicnode/BranchNode.hx +++ b/Sources/armory/logicnode/BranchNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class BranchNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var b:Bool = inputs[1].get(); + override function run(from: Int) { + var b: Bool = inputs[1].get(); b ? runOutput(0) : runOutput(1); } } diff --git a/Sources/armory/logicnode/CallFunctionNode.hx b/Sources/armory/logicnode/CallFunctionNode.hx index 350507e3..33798363 100644 --- a/Sources/armory/logicnode/CallFunctionNode.hx +++ b/Sources/armory/logicnode/CallFunctionNode.hx @@ -4,31 +4,32 @@ import iron.object.Object; class CallFunctionNode extends LogicNode { - var result:Dynamic; + var result: Dynamic; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); if (object == null) return; - - var funName:String = inputs[2].get(); - var args:Array = []; + + var funName: String = inputs[2].get(); + var args: Array = []; for (i in 3...inputs.length) { args.push(inputs[i].get()); } - + var func = Reflect.field(object, funName); - if (func != null) + if (func != null) { result = Reflect.callMethod(object, func, args); + } runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return result; } } diff --git a/Sources/armory/logicnode/CallGroupNode.hx b/Sources/armory/logicnode/CallGroupNode.hx index 2160356d..e02368a5 100644 --- a/Sources/armory/logicnode/CallGroupNode.hx +++ b/Sources/armory/logicnode/CallGroupNode.hx @@ -2,15 +2,15 @@ package armory.logicnode; class CallGroupNode extends LogicNode { - public var property0:String; - var callTree:LogicTree = null; + public var property0: String; + var callTree: LogicTree = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @:access(iron.Trait) - override function run(from:Int) { + override function run(from: Int) { if (callTree == null) { var classType = Type.resolveClass(property0); diff --git a/Sources/armory/logicnode/CallHaxeStaticNode.hx b/Sources/armory/logicnode/CallHaxeStaticNode.hx index 0d409b39..d4ad4e77 100644 --- a/Sources/armory/logicnode/CallHaxeStaticNode.hx +++ b/Sources/armory/logicnode/CallHaxeStaticNode.hx @@ -2,16 +2,16 @@ package armory.logicnode; class CallHaxeStaticNode extends LogicNode { - var result:Dynamic; + var result: Dynamic; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - - var path:String = inputs[1].get(); - if (path != '') { + override function run(from: Int) { + + var path: String = inputs[1].get(); + if (path != "") { var dotIndex = path.lastIndexOf("."); var classPath = path.substr(0, dotIndex); var classType = Type.resolveClass(classPath); @@ -22,7 +22,7 @@ class CallHaxeStaticNode extends LogicNode { runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return result; } } diff --git a/Sources/armory/logicnode/CanvasGetCheckboxNode.hx b/Sources/armory/logicnode/CanvasGetCheckboxNode.hx index 96999fbd..6bb2f4d8 100644 --- a/Sources/armory/logicnode/CanvasGetCheckboxNode.hx +++ b/Sources/armory/logicnode/CanvasGetCheckboxNode.hx @@ -5,24 +5,24 @@ import armory.trait.internal.CanvasScript; class CanvasGetCheckboxNode extends LogicNode { - var canvas:CanvasScript; + var canvas: CanvasScript; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } #if arm_ui - override function get(from:Int) { + override function get(from: Int) { if (canvas == null) canvas = Scene.active.getTrait(CanvasScript); 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 } diff --git a/Sources/armory/logicnode/CanvasGetInputTextNode.hx b/Sources/armory/logicnode/CanvasGetInputTextNode.hx index 0d21820a..4163de59 100644 --- a/Sources/armory/logicnode/CanvasGetInputTextNode.hx +++ b/Sources/armory/logicnode/CanvasGetInputTextNode.hx @@ -5,24 +5,24 @@ import armory.trait.internal.CanvasScript; class CanvasGetInputTextNode extends LogicNode { - var canvas:CanvasScript; + var canvas: CanvasScript; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } #if arm_ui - override function get(from:Int) { + override function get(from: Int) { if (canvas == null) canvas = Scene.active.getTrait(CanvasScript); 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 } diff --git a/Sources/armory/logicnode/CanvasGetLocationNode.hx b/Sources/armory/logicnode/CanvasGetLocationNode.hx index 3ecf8c6d..16317842 100644 --- a/Sources/armory/logicnode/CanvasGetLocationNode.hx +++ b/Sources/armory/logicnode/CanvasGetLocationNode.hx @@ -5,12 +5,12 @@ import armory.trait.internal.CanvasScript; class CanvasGetLocationNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var x:Float; - var y:Float; + var canvas: CanvasScript; + var element: String; + var x: Float; + var y: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -24,7 +24,7 @@ class CanvasGetLocationNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); canvas = Scene.active.getTrait(CanvasScript); if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript); @@ -33,7 +33,7 @@ class CanvasGetLocationNode extends LogicNode { tree.notifyOnUpdate(update); update(); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 1) return x; else if (from == 2) return y; else return 0; diff --git a/Sources/armory/logicnode/CanvasGetPBNode.hx b/Sources/armory/logicnode/CanvasGetPBNode.hx index 68f5edc1..823bb756 100644 --- a/Sources/armory/logicnode/CanvasGetPBNode.hx +++ b/Sources/armory/logicnode/CanvasGetPBNode.hx @@ -5,12 +5,12 @@ import armory.trait.internal.CanvasScript; class CanvasGetPBNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var at:Int; - var max:Int; + var canvas: CanvasScript; + var element: String; + var at: Int; + var max: Int; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -24,7 +24,7 @@ class CanvasGetPBNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); canvas = Scene.active.getTrait(CanvasScript); if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript); @@ -33,7 +33,7 @@ class CanvasGetPBNode extends LogicNode { tree.notifyOnUpdate(update); update(); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 1) return at; else if (from == 2) return max; else return 0; diff --git a/Sources/armory/logicnode/CanvasGetPositionNode.hx b/Sources/armory/logicnode/CanvasGetPositionNode.hx index 7fafcf6c..4fa41a61 100644 --- a/Sources/armory/logicnode/CanvasGetPositionNode.hx +++ b/Sources/armory/logicnode/CanvasGetPositionNode.hx @@ -5,24 +5,24 @@ import armory.trait.internal.CanvasScript; class CanvasGetPositionNode extends LogicNode { - var canvas:CanvasScript; + var canvas: CanvasScript; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } #if arm_ui - override function get(from:Int) { + override function get(from: Int) { if (canvas == null) canvas = Scene.active.getTrait(CanvasScript); 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 } diff --git a/Sources/armory/logicnode/CanvasGetRotationNode.hx b/Sources/armory/logicnode/CanvasGetRotationNode.hx index 80e103f4..6a4131cb 100644 --- a/Sources/armory/logicnode/CanvasGetRotationNode.hx +++ b/Sources/armory/logicnode/CanvasGetRotationNode.hx @@ -5,11 +5,11 @@ import armory.trait.internal.CanvasScript; class CanvasGetRotationNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var rad:Float; + var canvas: CanvasScript; + var element: String; + var rad: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -23,7 +23,7 @@ class CanvasGetRotationNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); canvas = Scene.active.getTrait(CanvasScript); if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript); @@ -32,7 +32,7 @@ class CanvasGetRotationNode extends LogicNode { tree.notifyOnUpdate(update); update(); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 1) return rad; else return 0; } diff --git a/Sources/armory/logicnode/CanvasGetScaleNode.hx b/Sources/armory/logicnode/CanvasGetScaleNode.hx index 030db474..a99b2693 100644 --- a/Sources/armory/logicnode/CanvasGetScaleNode.hx +++ b/Sources/armory/logicnode/CanvasGetScaleNode.hx @@ -5,12 +5,12 @@ import armory.trait.internal.CanvasScript; class CanvasGetScaleNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var width:Int; - var height:Int; + var canvas: CanvasScript; + var element: String; + var width: Int; + var height: Int; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -24,7 +24,7 @@ class CanvasGetScaleNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); canvas = Scene.active.getTrait(CanvasScript); if (canvas == null) canvas = Scene.active.camera.getTrait(CanvasScript); @@ -33,7 +33,7 @@ class CanvasGetScaleNode extends LogicNode { tree.notifyOnUpdate(update); update(); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 1) return height; else if (from == 2) return width; else return 0; diff --git a/Sources/armory/logicnode/CanvasGetSliderNode.hx b/Sources/armory/logicnode/CanvasGetSliderNode.hx index 82b942c0..e8da408d 100644 --- a/Sources/armory/logicnode/CanvasGetSliderNode.hx +++ b/Sources/armory/logicnode/CanvasGetSliderNode.hx @@ -5,24 +5,24 @@ import armory.trait.internal.CanvasScript; class CanvasGetSliderNode extends LogicNode { - var canvas:CanvasScript; + var canvas: CanvasScript; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } #if arm_ui - override function get(from:Int) { + override function get(from: Int) { if (canvas == null) canvas = Scene.active.getTrait(CanvasScript); 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 } diff --git a/Sources/armory/logicnode/CanvasSetAssetNode.hx b/Sources/armory/logicnode/CanvasSetAssetNode.hx index c7916cf5..0c46215a 100644 --- a/Sources/armory/logicnode/CanvasSetAssetNode.hx +++ b/Sources/armory/logicnode/CanvasSetAssetNode.hx @@ -5,11 +5,11 @@ import armory.trait.internal.CanvasScript; class CanvasSetAssetNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var asset:String; + var canvas: CanvasScript; + var element: String; + var asset: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -22,7 +22,7 @@ class CanvasSetAssetNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); asset = Std.string(inputs[2].get()); canvas = Scene.active.getTrait(CanvasScript); diff --git a/Sources/armory/logicnode/CanvasSetLocationNode.hx b/Sources/armory/logicnode/CanvasSetLocationNode.hx index e1d84f4a..afe73972 100644 --- a/Sources/armory/logicnode/CanvasSetLocationNode.hx +++ b/Sources/armory/logicnode/CanvasSetLocationNode.hx @@ -5,12 +5,12 @@ import armory.trait.internal.CanvasScript; class CanvasSetLocationNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var newX:Float; - var newY:Float; + var canvas: CanvasScript; + var element: String; + var newX: Float; + var newY: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -24,7 +24,7 @@ class CanvasSetLocationNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); newX = inputs[2].get(); newY = inputs[3].get(); diff --git a/Sources/armory/logicnode/CanvasSetPBNode.hx b/Sources/armory/logicnode/CanvasSetPBNode.hx index edca4623..73e3f67d 100644 --- a/Sources/armory/logicnode/CanvasSetPBNode.hx +++ b/Sources/armory/logicnode/CanvasSetPBNode.hx @@ -5,12 +5,12 @@ import armory.trait.internal.CanvasScript; class CanvasSetPBNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var newAt:Int; - var newMax:Int; + var canvas: CanvasScript; + var element: String; + var newAt: Int; + var newMax: Int; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -25,7 +25,7 @@ class CanvasSetPBNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); newAt = inputs[2].get(); newMax = inputs[3].get(); diff --git a/Sources/armory/logicnode/CanvasSetRotationNode.hx b/Sources/armory/logicnode/CanvasSetRotationNode.hx index 8f6d872d..32decf53 100644 --- a/Sources/armory/logicnode/CanvasSetRotationNode.hx +++ b/Sources/armory/logicnode/CanvasSetRotationNode.hx @@ -5,11 +5,11 @@ import armory.trait.internal.CanvasScript; class CanvasSetRotationNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var rad:Float; + var canvas: CanvasScript; + var element: String; + var rad: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -22,7 +22,7 @@ class CanvasSetRotationNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); rad = inputs[2].get(); canvas = Scene.active.getTrait(CanvasScript); diff --git a/Sources/armory/logicnode/CanvasSetScaleNode.hx b/Sources/armory/logicnode/CanvasSetScaleNode.hx index d773b0bc..d36f2075 100644 --- a/Sources/armory/logicnode/CanvasSetScaleNode.hx +++ b/Sources/armory/logicnode/CanvasSetScaleNode.hx @@ -5,12 +5,12 @@ import armory.trait.internal.CanvasScript; class CanvasSetScaleNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var height:Int; - var width:Int; + var canvas: CanvasScript; + var element: String; + var height: Int; + var width: Int; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -24,7 +24,7 @@ class CanvasSetScaleNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); height = inputs[2].get(); width = inputs[3].get(); diff --git a/Sources/armory/logicnode/CanvasSetSliderNode.hx b/Sources/armory/logicnode/CanvasSetSliderNode.hx index 59beba23..9a9d8c82 100644 --- a/Sources/armory/logicnode/CanvasSetSliderNode.hx +++ b/Sources/armory/logicnode/CanvasSetSliderNode.hx @@ -5,11 +5,11 @@ import armory.trait.internal.CanvasScript; class CanvasSetSliderNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var value:Float; + var canvas: CanvasScript; + var element: String; + var value: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -22,12 +22,13 @@ class CanvasSetSliderNode extends LogicNode { try { canvas.getHandle(element).value = value; tree.removeUpdate(update); - } catch (e:Dynamic) {} + } + catch (e: Dynamic) {} runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); value = inputs[2].get(); canvas = Scene.active.getTrait(CanvasScript); diff --git a/Sources/armory/logicnode/CanvasSetTextColorNode.hx b/Sources/armory/logicnode/CanvasSetTextColorNode.hx index 5b2326d9..5f4f57da 100644 --- a/Sources/armory/logicnode/CanvasSetTextColorNode.hx +++ b/Sources/armory/logicnode/CanvasSetTextColorNode.hx @@ -6,14 +6,14 @@ import kha.Color; class CanvasSetTextColorNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var r:Float; - var g:Float; - var b:Float; - var a:Float; + var canvas: CanvasScript; + var element: String; + var r: Float; + var g: Float; + var b: Float; + var a: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -22,11 +22,11 @@ class CanvasSetTextColorNode extends LogicNode { if (!canvas.ready) return; tree.removeUpdate(update); - canvas.getElement(element).color_text = Color.fromFloats(r,g,b,a); + canvas.getElement(element).color_text = Color.fromFloats(r, g, b, a); runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); r = inputs[2].get(); g = inputs[3].get(); diff --git a/Sources/armory/logicnode/CanvasSetTextNode.hx b/Sources/armory/logicnode/CanvasSetTextNode.hx index 6c46c903..f76d9b21 100644 --- a/Sources/armory/logicnode/CanvasSetTextNode.hx +++ b/Sources/armory/logicnode/CanvasSetTextNode.hx @@ -5,11 +5,11 @@ import armory.trait.internal.CanvasScript; class CanvasSetTextNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var text:String; + var canvas: CanvasScript; + var element: String; + var text: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -22,7 +22,7 @@ class CanvasSetTextNode extends LogicNode { runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); text = Std.string(inputs[2].get()); canvas = Scene.active.getTrait(CanvasScript); diff --git a/Sources/armory/logicnode/CanvasSetVisibleNode.hx b/Sources/armory/logicnode/CanvasSetVisibleNode.hx index 3904ba18..7743bb0c 100644 --- a/Sources/armory/logicnode/CanvasSetVisibleNode.hx +++ b/Sources/armory/logicnode/CanvasSetVisibleNode.hx @@ -5,11 +5,11 @@ import armory.trait.internal.CanvasScript; class CanvasSetVisibleNode extends LogicNode { - var canvas:CanvasScript; - var element:String; - var visible:Bool; + var canvas: CanvasScript; + var element: String; + var visible: Bool; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -22,7 +22,7 @@ class CanvasSetVisibleNode extends LogicNode { else canvas.getElement(element).visible = false; runOutput(0); } - override function run(from:Int) { + override function run(from: Int) { element = inputs[1].get(); visible = inputs[2].get(); canvas = Scene.active.getTrait(CanvasScript); diff --git a/Sources/armory/logicnode/CaseStringNode.hx b/Sources/armory/logicnode/CaseStringNode.hx index 2c8e233f..a2b696c5 100644 --- a/Sources/armory/logicnode/CaseStringNode.hx +++ b/Sources/armory/logicnode/CaseStringNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class CaseStringNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var s:String = inputs[0].get(); + override function get(from: Int): Dynamic { + var s: String = inputs[0].get(); if (s == null) return null; switch (property0) { diff --git a/Sources/armory/logicnode/CastPhysicsRayNode.hx b/Sources/armory/logicnode/CastPhysicsRayNode.hx index e26c38d0..b70a0beb 100644 --- a/Sources/armory/logicnode/CastPhysicsRayNode.hx +++ b/Sources/armory/logicnode/CastPhysicsRayNode.hx @@ -6,14 +6,14 @@ class CastPhysicsRayNode extends LogicNode { var v = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var vfrom:Vec4 = inputs[0].get(); - var vto:Vec4 = inputs[1].get(); - var mask:Int = inputs[2].get(); + override function get(from: Int): Dynamic { + var vfrom: Vec4 = inputs[0].get(); + var vto: Vec4 = inputs[1].get(); + var mask: Int = inputs[2].get(); if (vfrom == null || vto == null) return null; @@ -26,13 +26,14 @@ class CastPhysicsRayNode extends LogicNode { if (rb != null) return rb.object; } else if (from == 1) { // Hit - var hitPointWorld:Vec4 = rb != null ? physics.hitPointWorld : null; + var hitPointWorld: Vec4 = rb != null ? physics.hitPointWorld : null; if (hitPointWorld != null) { v.set(hitPointWorld.x, hitPointWorld.y, hitPointWorld.z, 1); return v; } - } else { // Normal - var hitNormalWorld:Vec4 = rb != null ? physics.hitNormalWorld : null; + } + else { // Normal + var hitNormalWorld: Vec4 = rb != null ? physics.hitNormalWorld : null; if (hitNormalWorld != null) { v.set(hitNormalWorld.x, hitNormalWorld.y, hitNormalWorld.z, 0); return v; diff --git a/Sources/armory/logicnode/ClearParentNode.hx b/Sources/armory/logicnode/ClearParentNode.hx index 4f845a41..982d98c3 100644 --- a/Sources/armory/logicnode/ClearParentNode.hx +++ b/Sources/armory/logicnode/ClearParentNode.hx @@ -4,14 +4,14 @@ import iron.object.Object; class ClearParentNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var keepTransform:Bool = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var keepTransform: Bool = inputs[2].get(); + if (object == null || object.parent == null) return; object.parent.removeChild(object, keepTransform); diff --git a/Sources/armory/logicnode/ColorNode.hx b/Sources/armory/logicnode/ColorNode.hx index b8b8b125..4d2b0c52 100644 --- a/Sources/armory/logicnode/ColorNode.hx +++ b/Sources/armory/logicnode/ColorNode.hx @@ -6,18 +6,18 @@ class ColorNode extends LogicNode { var value = new Vec4(); - public function new(tree:LogicTree, r = 0.8, g = 0.8, b = 0.8, a = 1.0) { + public function new(tree: LogicTree, r = 0.8, g = 0.8, b = 0.8, a = 1.0) { super(tree); value.set(r, g, b, a); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (inputs.length > 0) return inputs[0].get(); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { if (inputs.length > 0) inputs[0].set(value); else this.value = value; } diff --git a/Sources/armory/logicnode/CompareNode.hx b/Sources/armory/logicnode/CompareNode.hx index 0d30777f..88dc97be 100644 --- a/Sources/armory/logicnode/CompareNode.hx +++ b/Sources/armory/logicnode/CompareNode.hx @@ -4,17 +4,17 @@ import iron.math.Vec4; class CompareNode extends LogicNode { - public var property0:String; - public var property1:Float; + public var property0: String; + public var property1: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Bool { + override function get(from: Int): Bool { - var v1:Dynamic = inputs[0].get(); - var v2:Dynamic = inputs[1].get(); + var v1: Dynamic = inputs[0].get(); + var v2: Dynamic = inputs[1].get(); var cond = false; switch (property0) { diff --git a/Sources/armory/logicnode/ConcatenateStringNode.hx b/Sources/armory/logicnode/ConcatenateStringNode.hx index 67affcab..8153fe64 100644 --- a/Sources/armory/logicnode/ConcatenateStringNode.hx +++ b/Sources/armory/logicnode/ConcatenateStringNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class ConcatenateStringNode extends LogicNode { - public var value:String; + public var value: String; - public function new(tree:LogicTree, value = "") { + public function new(tree: LogicTree, value = "") { super(tree); this.value = value; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { value = ""; for (inp in inputs) value += inp.get(); return value; diff --git a/Sources/armory/logicnode/ContainsStringNode.hx b/Sources/armory/logicnode/ContainsStringNode.hx index 9643985b..6bc19e5e 100644 --- a/Sources/armory/logicnode/ContainsStringNode.hx +++ b/Sources/armory/logicnode/ContainsStringNode.hx @@ -2,15 +2,15 @@ package armory.logicnode; class ContainsStringNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var s1:String = inputs[0].get(); - var s2:String = inputs[1].get(); + override function get(from: Int): Dynamic { + var s1: String = inputs[0].get(); + var s2: String = inputs[1].get(); if (s1 == null || s2 == null) return null; switch (property0) { diff --git a/Sources/armory/logicnode/DegToRadNode.hx b/Sources/armory/logicnode/DegToRadNode.hx index f8d8ab4c..a6c107c7 100644 --- a/Sources/armory/logicnode/DegToRadNode.hx +++ b/Sources/armory/logicnode/DegToRadNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class DegToRadNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var deg:Float = inputs[0].get(); + override function get(from: Int): Dynamic { + var deg: Float = inputs[0].get(); return deg * 0.0174532924; } } diff --git a/Sources/armory/logicnode/DisplayInfoNode.hx b/Sources/armory/logicnode/DisplayInfoNode.hx index db3a5264..264ce436 100644 --- a/Sources/armory/logicnode/DisplayInfoNode.hx +++ b/Sources/armory/logicnode/DisplayInfoNode.hx @@ -4,11 +4,11 @@ class DisplayInfoNode extends LogicNode { static inline var displayIndex = 0; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 0) return kha.Display.all[displayIndex].width; else return kha.Display.all[displayIndex].height; } diff --git a/Sources/armory/logicnode/DynamicNode.hx b/Sources/armory/logicnode/DynamicNode.hx index 3ac8686a..715b8e1b 100644 --- a/Sources/armory/logicnode/DynamicNode.hx +++ b/Sources/armory/logicnode/DynamicNode.hx @@ -2,18 +2,18 @@ package armory.logicnode; class DynamicNode extends LogicNode { - public var value:Dynamic; + public var value: Dynamic; - public function new(tree:LogicTree, value:Dynamic = null) { + public function new(tree: LogicTree, value: Dynamic = null) { super(tree); this.value = value == null ? {} : value; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/ExpressionNode.hx b/Sources/armory/logicnode/ExpressionNode.hx index 5ec7542e..d27fb08f 100644 --- a/Sources/armory/logicnode/ExpressionNode.hx +++ b/Sources/armory/logicnode/ExpressionNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class ExpressionNode extends LogicNode { - public var property0:String; - var result:Dynamic; + public var property0: String; + var result: Dynamic; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { #if hscript var expr = property0; @@ -22,7 +22,7 @@ class ExpressionNode extends LogicNode { runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return result; } } diff --git a/Sources/armory/logicnode/FloatNode.hx b/Sources/armory/logicnode/FloatNode.hx index b341a1c9..6df907a9 100644 --- a/Sources/armory/logicnode/FloatNode.hx +++ b/Sources/armory/logicnode/FloatNode.hx @@ -2,19 +2,19 @@ package armory.logicnode; class FloatNode extends LogicNode { - public var value:Float; + public var value: Float; - public function new(tree:LogicTree, value = 0.0) { + public function new(tree: LogicTree, value = 0.0) { super(tree); this.value = value; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (inputs.length > 0) return inputs[0].get(); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { if (inputs.length > 0) inputs[0].set(value); else this.value = value; } diff --git a/Sources/armory/logicnode/FunctionNode.hx b/Sources/armory/logicnode/FunctionNode.hx index 65950224..7f2f67b9 100644 --- a/Sources/armory/logicnode/FunctionNode.hx +++ b/Sources/armory/logicnode/FunctionNode.hx @@ -3,20 +3,20 @@ package armory.logicnode; class FunctionNode extends LogicNode { @:allow(armory.logicnode.LogicTree) - var args:Array = []; + var args: Array = []; @:allow(armory.logicnode.LogicTree) - var result:Dynamic; + var result: Dynamic; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @:allow(armory.logicnode.LogicTree) - override function run(from:Int) { + override function run(from: Int) { runOutput(0); } - override function get(from:Int) { + override function get(from: Int): Dynamic { return this.args[from - 1]; } } diff --git a/Sources/armory/logicnode/FunctionOutputNode.hx b/Sources/armory/logicnode/FunctionOutputNode.hx index 1a10722c..87b95c0a 100644 --- a/Sources/armory/logicnode/FunctionOutputNode.hx +++ b/Sources/armory/logicnode/FunctionOutputNode.hx @@ -3,13 +3,13 @@ package armory.logicnode; class FunctionOutputNode extends LogicNode { @:allow(armory.logicnode.LogicTree) - var result:Dynamic; + var result: Dynamic; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { this.result = inputs[1].get(); runOutput(0); } diff --git a/Sources/armory/logicnode/GamepadCoordsNode.hx b/Sources/armory/logicnode/GamepadCoordsNode.hx index 01394156..a1a8660c 100644 --- a/Sources/armory/logicnode/GamepadCoordsNode.hx +++ b/Sources/armory/logicnode/GamepadCoordsNode.hx @@ -6,12 +6,12 @@ class GamepadCoordsNode extends LogicNode { var coords = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var num:Int = inputs[0].get(); + override function get(from: Int): Dynamic { + var num: Int = inputs[0].get(); var gamepad = iron.system.Input.getGamepad(num); if (from == 0) { coords.x = gamepad.leftStick.x; @@ -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; diff --git a/Sources/armory/logicnode/GateNode.hx b/Sources/armory/logicnode/GateNode.hx index ac2c2496..ca310419 100644 --- a/Sources/armory/logicnode/GateNode.hx +++ b/Sources/armory/logicnode/GateNode.hx @@ -4,17 +4,16 @@ import iron.math.Vec4; class GateNode extends LogicNode { - public var property0:String; - public var property1:Float; + public var property0: String; + public var property1: Float; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - - var v1:Dynamic = inputs[1].get(); - var v2:Dynamic = inputs[2].get(); + override function run(from: Int) { + var v1: Dynamic = inputs[1].get(); + var v2: Dynamic = inputs[2].get(); var cond = false; switch (property0) { diff --git a/Sources/armory/logicnode/GetCameraFovNode.hx b/Sources/armory/logicnode/GetCameraFovNode.hx index 5625aad3..5c8e9b96 100644 --- a/Sources/armory/logicnode/GetCameraFovNode.hx +++ b/Sources/armory/logicnode/GetCameraFovNode.hx @@ -4,12 +4,12 @@ import iron.object.CameraObject; class GetCameraFovNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var camera:CameraObject = inputs[0].get(); + override function get(from: Int): Dynamic { + var camera: CameraObject = inputs[0].get(); if (camera == null) return 0.0; diff --git a/Sources/armory/logicnode/GetChildNode.hx b/Sources/armory/logicnode/GetChildNode.hx index 050ef05f..b177f9ea 100644 --- a/Sources/armory/logicnode/GetChildNode.hx +++ b/Sources/armory/logicnode/GetChildNode.hx @@ -4,15 +4,15 @@ import iron.object.Object; class GetChildNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); - var childName:String = inputs[1].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); + var childName: String = inputs[1].get(); if (object == null || childName == null) return null; @@ -30,7 +30,7 @@ class GetChildNode extends LogicNode { return null; } - function contains(o:Object, name:String):Object { + function contains(o: Object, name: String): Object { if (o.name.indexOf(name) >= 0) return o; else { for (c in o.children) { @@ -41,7 +41,7 @@ class GetChildNode extends LogicNode { return null; } - function startsWith(o:Object, name:String):Object { + function startsWith(o: Object, name: String): Object { if (StringTools.startsWith(o.name, name)) return o; else { for (c in o.children) { @@ -52,7 +52,7 @@ class GetChildNode extends LogicNode { return null; } - function endsWith(o:Object, name:String):Object { + function endsWith(o: Object, name: String): Object { if (StringTools.endsWith(o.name, name)) return o; else { for (c in o.children) { diff --git a/Sources/armory/logicnode/GetChildrenNode.hx b/Sources/armory/logicnode/GetChildrenNode.hx index c83c9134..8e6230e6 100644 --- a/Sources/armory/logicnode/GetChildrenNode.hx +++ b/Sources/armory/logicnode/GetChildrenNode.hx @@ -4,12 +4,12 @@ import iron.object.Object; class GetChildrenNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetContactsNode.hx b/Sources/armory/logicnode/GetContactsNode.hx index c13cbafa..277922df 100644 --- a/Sources/armory/logicnode/GetContactsNode.hx +++ b/Sources/armory/logicnode/GetContactsNode.hx @@ -5,12 +5,12 @@ import armory.trait.physics.RigidBody; class GetContactsNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; #if arm_physics diff --git a/Sources/armory/logicnode/GetDistanceNode.hx b/Sources/armory/logicnode/GetDistanceNode.hx index 356b9da3..00370871 100644 --- a/Sources/armory/logicnode/GetDistanceNode.hx +++ b/Sources/armory/logicnode/GetDistanceNode.hx @@ -4,13 +4,13 @@ import iron.object.Object; class GetDistanceNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object1:Object = inputs[0].get(); - var object2:Object = inputs[1].get(); + override function get(from: Int): Dynamic { + var object1: Object = inputs[0].get(); + var object2: Object = inputs[1].get(); if (object1 == null || object2 == null) return 0; diff --git a/Sources/armory/logicnode/GetFirstContactNode.hx b/Sources/armory/logicnode/GetFirstContactNode.hx index 4b51a2e9..10989add 100644 --- a/Sources/armory/logicnode/GetFirstContactNode.hx +++ b/Sources/armory/logicnode/GetFirstContactNode.hx @@ -5,12 +5,12 @@ import armory.trait.physics.RigidBody; class GetFirstContactNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; #if arm_physics diff --git a/Sources/armory/logicnode/GetGravityNode.hx b/Sources/armory/logicnode/GetGravityNode.hx index 7b02ce72..85a04784 100644 --- a/Sources/armory/logicnode/GetGravityNode.hx +++ b/Sources/armory/logicnode/GetGravityNode.hx @@ -1,17 +1,13 @@ 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) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - + override function get(from: Int): Dynamic { + #if arm_physics var physics = armory.trait.physics.PhysicsWorld.active; return physics.world.getGravity(); diff --git a/Sources/armory/logicnode/GetGroupNode.hx b/Sources/armory/logicnode/GetGroupNode.hx index dad06371..5edd8685 100644 --- a/Sources/armory/logicnode/GetGroupNode.hx +++ b/Sources/armory/logicnode/GetGroupNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class GetGroupNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var groupName:String = inputs[0].get(); + override function get(from: Int): Dynamic { + var groupName: String = inputs[0].get(); return iron.Scene.active.getGroup(groupName); } } diff --git a/Sources/armory/logicnode/GetHaxePropertyNode.hx b/Sources/armory/logicnode/GetHaxePropertyNode.hx index 4c777d9e..f2aa65a1 100644 --- a/Sources/armory/logicnode/GetHaxePropertyNode.hx +++ b/Sources/armory/logicnode/GetHaxePropertyNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class GetHaxePropertyNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Dynamic = inputs[0].get(); - var property:String = inputs[1].get(); + override function get(from: Int): Dynamic { + var object: Dynamic = inputs[0].get(); + var property: String = inputs[1].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetLocationNode.hx b/Sources/armory/logicnode/GetLocationNode.hx index 9decbfc4..961f8280 100644 --- a/Sources/armory/logicnode/GetLocationNode.hx +++ b/Sources/armory/logicnode/GetLocationNode.hx @@ -4,12 +4,12 @@ import iron.object.Object; class GetLocationNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetMaterialNode.hx b/Sources/armory/logicnode/GetMaterialNode.hx index e3fcb6e2..d1a33e87 100644 --- a/Sources/armory/logicnode/GetMaterialNode.hx +++ b/Sources/armory/logicnode/GetMaterialNode.hx @@ -4,12 +4,12 @@ import iron.object.MeshObject; class GetMaterialNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:MeshObject = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: MeshObject = inputs[0].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetMeshNode.hx b/Sources/armory/logicnode/GetMeshNode.hx index 48fe13e4..0c4a576e 100644 --- a/Sources/armory/logicnode/GetMeshNode.hx +++ b/Sources/armory/logicnode/GetMeshNode.hx @@ -4,12 +4,12 @@ import iron.object.MeshObject; class GetMeshNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:MeshObject = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: MeshObject = inputs[0].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetNameNode.hx b/Sources/armory/logicnode/GetNameNode.hx index 979f9f8e..dc49cf8d 100644 --- a/Sources/armory/logicnode/GetNameNode.hx +++ b/Sources/armory/logicnode/GetNameNode.hx @@ -4,14 +4,14 @@ import iron.object.Object; class GetNameNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); - if (object == null) return ''; + if (object == null) return ""; return object.name; } diff --git a/Sources/armory/logicnode/GetObjectNode.hx b/Sources/armory/logicnode/GetObjectNode.hx index dfe5ed19..aeae1782 100644 --- a/Sources/armory/logicnode/GetObjectNode.hx +++ b/Sources/armory/logicnode/GetObjectNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class GetObjectNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var objectName:String = inputs[0].get(); + override function get(from: Int): Dynamic { + var objectName: String = inputs[0].get(); return iron.Scene.active.getChild(objectName); } diff --git a/Sources/armory/logicnode/GetParentNode.hx b/Sources/armory/logicnode/GetParentNode.hx index 9d2403c0..8c9c7ace 100644 --- a/Sources/armory/logicnode/GetParentNode.hx +++ b/Sources/armory/logicnode/GetParentNode.hx @@ -4,12 +4,12 @@ import iron.object.Object; class GetParentNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetPropertyNode.hx b/Sources/armory/logicnode/GetPropertyNode.hx index 7b45f61a..0d3c7a7e 100644 --- a/Sources/armory/logicnode/GetPropertyNode.hx +++ b/Sources/armory/logicnode/GetPropertyNode.hx @@ -4,13 +4,13 @@ import iron.object.Object; class GetPropertyNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); - var property:String = inputs[1].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); + var property: String = inputs[1].get(); if (from == 0) { if (object == null || object.properties == null) return null; diff --git a/Sources/armory/logicnode/GetRotationNode.hx b/Sources/armory/logicnode/GetRotationNode.hx index df91eb02..b2755f16 100644 --- a/Sources/armory/logicnode/GetRotationNode.hx +++ b/Sources/armory/logicnode/GetRotationNode.hx @@ -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) { + + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); - if (object == null) + 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: @@ -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 diff --git a/Sources/armory/logicnode/GetScaleNode.hx b/Sources/armory/logicnode/GetScaleNode.hx index b92ad31b..ecaed09d 100644 --- a/Sources/armory/logicnode/GetScaleNode.hx +++ b/Sources/armory/logicnode/GetScaleNode.hx @@ -4,12 +4,12 @@ import iron.object.Object; class GetScaleNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetTraitNode.hx b/Sources/armory/logicnode/GetTraitNode.hx index 6a4e4dd1..000c96ec 100644 --- a/Sources/armory/logicnode/GetTraitNode.hx +++ b/Sources/armory/logicnode/GetTraitNode.hx @@ -4,15 +4,15 @@ import iron.object.Object; class GetTraitNode extends LogicNode { - var cname:Class = null; + var cname: Class = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); - var name:String = inputs[1].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); + var name: String = inputs[1].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetTransformNode.hx b/Sources/armory/logicnode/GetTransformNode.hx index 1731d893..379df0ae 100644 --- a/Sources/armory/logicnode/GetTransformNode.hx +++ b/Sources/armory/logicnode/GetTransformNode.hx @@ -4,12 +4,12 @@ import iron.object.Object; class GetTransformNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; diff --git a/Sources/armory/logicnode/GetVelocityNode.hx b/Sources/armory/logicnode/GetVelocityNode.hx index 7c7f9a34..d7f81350 100644 --- a/Sources/armory/logicnode/GetVelocityNode.hx +++ b/Sources/armory/logicnode/GetVelocityNode.hx @@ -5,16 +5,16 @@ import armory.trait.physics.RigidBody; class GetVelocityNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) return null; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); if (rb != null) { if (from == 0) return rb.getLinearVelocity(); diff --git a/Sources/armory/logicnode/GetVisibleNode.hx b/Sources/armory/logicnode/GetVisibleNode.hx index 54f5e9fd..0fe4db1f 100644 --- a/Sources/armory/logicnode/GetVisibleNode.hx +++ b/Sources/armory/logicnode/GetVisibleNode.hx @@ -4,12 +4,12 @@ import iron.object.Object; class GetVisibleNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); if (object == null) false; diff --git a/Sources/armory/logicnode/GlobalObjectNode.hx b/Sources/armory/logicnode/GlobalObjectNode.hx index def965c1..c227079a 100644 --- a/Sources/armory/logicnode/GlobalObjectNode.hx +++ b/Sources/armory/logicnode/GlobalObjectNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class GlobalObjectNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return iron.Scene.global; } } diff --git a/Sources/armory/logicnode/GoToLocationNode.hx b/Sources/armory/logicnode/GoToLocationNode.hx index b6f36f45..31fb6cd5 100644 --- a/Sources/armory/logicnode/GoToLocationNode.hx +++ b/Sources/armory/logicnode/GoToLocationNode.hx @@ -6,22 +6,22 @@ import iron.math.Vec4; class GoToLocationNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var location:Vec4 = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var location: Vec4 = inputs[2].get(); + if (object == null || location == null) return; #if arm_navigation // Assume navmesh exists.. var from = object.transform.world.getLoc(); var to = location; - Navigation.active.navMeshes[0].findPath(from, to, function(path:Array) { - var agent:armory.trait.NavAgent = object.getTrait(armory.trait.NavAgent); + Navigation.active.navMeshes[0].findPath(from, to, function(path: Array) { + var agent: armory.trait.NavAgent = object.getTrait(armory.trait.NavAgent); agent.setPath(path); }); #end diff --git a/Sources/armory/logicnode/GroupNode.hx b/Sources/armory/logicnode/GroupNode.hx index a46f2be1..3f8184c0 100644 --- a/Sources/armory/logicnode/GroupNode.hx +++ b/Sources/armory/logicnode/GroupNode.hx @@ -1,17 +1,16 @@ package armory.logicnode; import iron.Scene; -import iron.object.Object; class GroupNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return Scene.active.getGroup(property0); } } diff --git a/Sources/armory/logicnode/GroupOutputNode.hx b/Sources/armory/logicnode/GroupOutputNode.hx index 2ff82b97..8ccc424f 100644 --- a/Sources/armory/logicnode/GroupOutputNode.hx +++ b/Sources/armory/logicnode/GroupOutputNode.hx @@ -2,12 +2,11 @@ package armory.logicnode; class GroupOutputNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - + override function run(from: Int) { runOutput(0); } } diff --git a/Sources/armory/logicnode/HasContactNode.hx b/Sources/armory/logicnode/HasContactNode.hx index d12b3b20..ab10941c 100644 --- a/Sources/armory/logicnode/HasContactNode.hx +++ b/Sources/armory/logicnode/HasContactNode.hx @@ -5,13 +5,13 @@ import armory.trait.physics.RigidBody; class HasContactNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object1:Object = inputs[0].get(); - var object2:Object = inputs[1].get(); + override function get(from: Int): Dynamic { + var object1: Object = inputs[0].get(); + var object2: Object = inputs[1].get(); if (object1 == null || object2 == null) return false; diff --git a/Sources/armory/logicnode/IntegerNode.hx b/Sources/armory/logicnode/IntegerNode.hx index eac2343c..9cd704bb 100644 --- a/Sources/armory/logicnode/IntegerNode.hx +++ b/Sources/armory/logicnode/IntegerNode.hx @@ -2,19 +2,19 @@ package armory.logicnode; class IntegerNode extends LogicNode { - public var value:Int; + public var value: Int; - public function new(tree:LogicTree, value = 0) { + public function new(tree: LogicTree, value = 0) { super(tree); this.value = value; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (inputs.length > 0) return inputs[0].get(); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { if (inputs.length > 0) inputs[0].set(value); else this.value = value; } diff --git a/Sources/armory/logicnode/InverseNode.hx b/Sources/armory/logicnode/InverseNode.hx index 56d97798..d4627e6d 100644 --- a/Sources/armory/logicnode/InverseNode.hx +++ b/Sources/armory/logicnode/InverseNode.hx @@ -4,12 +4,12 @@ class InverseNode extends LogicNode { var c = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); } - override function run(from:Int) { + override function run(from: Int) { c = true; } diff --git a/Sources/armory/logicnode/IsFalseNode.hx b/Sources/armory/logicnode/IsFalseNode.hx index ccc0557c..b8d7b1f2 100644 --- a/Sources/armory/logicnode/IsFalseNode.hx +++ b/Sources/armory/logicnode/IsFalseNode.hx @@ -2,13 +2,12 @@ package armory.logicnode; class IsFalseNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - - var v1:Bool = inputs[1].get(); + override function run(from: Int) { + var v1: Bool = inputs[1].get(); if (!v1) runOutput(0); } } diff --git a/Sources/armory/logicnode/IsNoneNode.hx b/Sources/armory/logicnode/IsNoneNode.hx index 1823b1da..7eafe4b0 100644 --- a/Sources/armory/logicnode/IsNoneNode.hx +++ b/Sources/armory/logicnode/IsNoneNode.hx @@ -2,13 +2,12 @@ package armory.logicnode; class IsNoneNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - - var v1:Dynamic = inputs[1].get(); + override function run(from: Int) { + var v1: Dynamic = inputs[1].get(); if (v1 == null) runOutput(0); } } diff --git a/Sources/armory/logicnode/IsNotNoneNode.hx b/Sources/armory/logicnode/IsNotNoneNode.hx index 1e0e401e..2fc51a43 100644 --- a/Sources/armory/logicnode/IsNotNoneNode.hx +++ b/Sources/armory/logicnode/IsNotNoneNode.hx @@ -2,13 +2,12 @@ package armory.logicnode; class IsNotNoneNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - - var v1:Dynamic = inputs[1].get(); + override function run(from: Int) { + var v1: Dynamic = inputs[1].get(); if (v1 != null) runOutput(0); } } diff --git a/Sources/armory/logicnode/IsTrueNode.hx b/Sources/armory/logicnode/IsTrueNode.hx index 1704b596..a2a0b73c 100644 --- a/Sources/armory/logicnode/IsTrueNode.hx +++ b/Sources/armory/logicnode/IsTrueNode.hx @@ -2,13 +2,12 @@ package armory.logicnode; class IsTrueNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - - var v1:Bool = inputs[1].get(); + override function run(from: Int) { + var v1: Bool = inputs[1].get(); if (v1) runOutput(0); } } diff --git a/Sources/armory/logicnode/LengthStringNode.hx b/Sources/armory/logicnode/LengthStringNode.hx index aff79328..f6128366 100644 --- a/Sources/armory/logicnode/LengthStringNode.hx +++ b/Sources/armory/logicnode/LengthStringNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class LengthStringNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var s:String = inputs[0].get(); + override function get(from: Int): Dynamic { + var s: String = inputs[0].get(); if (s == null) return null; return s.length; diff --git a/Sources/armory/logicnode/LoadUrlNode.hx b/Sources/armory/logicnode/LoadUrlNode.hx index e178c3c2..7bf88549 100644 --- a/Sources/armory/logicnode/LoadUrlNode.hx +++ b/Sources/armory/logicnode/LoadUrlNode.hx @@ -6,11 +6,11 @@ import kha.System; class LoadUrlNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { System.loadUrl(inputs[1].get()); } } diff --git a/Sources/armory/logicnode/LogicNode.hx b/Sources/armory/logicnode/LogicNode.hx index 7e9c0309..9e5e367c 100644 --- a/Sources/armory/logicnode/LogicNode.hx +++ b/Sources/armory/logicnode/LogicNode.hx @@ -2,41 +2,41 @@ package armory.logicnode; class LogicNode { - var tree:LogicTree; - var inputs:Array = []; - var outputs:Array> = []; + var tree: LogicTree; + var inputs: Array = []; + var outputs: Array> = []; #if arm_debug public var name = ""; - public function watch(b:Bool) { // Watch in debug console + public function watch(b: Bool) { // Watch in debug console var nodes = armory.trait.internal.DebugConsole.watchNodes; b ? nodes.push(this) : nodes.remove(this); } #end - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { this.tree = tree; } - public function addInput(node:LogicNode, from:Int) { + public function addInput(node: LogicNode, from: Int) { inputs.push(new LogicNodeInput(node, from)); } - public function addOutputs(nodes:Array) { + public function addOutputs(nodes: Array) { outputs.push(nodes); } /** - * Called when this node is activated. - * @param from impulse index - */ - function run(from:Int) {} + 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 - */ - function runOutput(i:Int) { + 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]) { // Check which input activated the node @@ -50,30 +50,30 @@ class LogicNode { } @:allow(armory.logicnode.LogicNodeInput) - function get(from:Int):Dynamic { return this; } + function get(from: Int): Dynamic { return this; } @:allow(armory.logicnode.LogicNodeInput) - function set(value:Dynamic) { } + function set(value: Dynamic) {} } class LogicNodeInput { @:allow(armory.logicnode.LogicNode) - var node:LogicNode; - var from:Int; // Socket index + var node: LogicNode; + var from: Int; // Socket index - public function new(node:LogicNode, from:Int) { + public function new(node: LogicNode, from: Int) { this.node = node; this.from = from; } @:allow(armory.logicnode.LogicNode) - function get():Dynamic { + function get(): Dynamic { return node.get(from); } @:allow(armory.logicnode.LogicNode) - function set(value:Dynamic) { + function set(value: Dynamic) { node.set(value); } } diff --git a/Sources/armory/logicnode/LookAtNode.hx b/Sources/armory/logicnode/LookAtNode.hx index 8b7591ea..25e37ee7 100644 --- a/Sources/armory/logicnode/LookAtNode.hx +++ b/Sources/armory/logicnode/LookAtNode.hx @@ -5,18 +5,18 @@ import iron.math.Quat; class LookAtNode extends LogicNode { - public var property0:String; + public var property0: String; var v1 = new Vec4(); var v2 = new Vec4(); var q = new Quat(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var vfrom:Vec4 = inputs[0].get(); - var vto:Vec4 = inputs[1].get(); + override function get(from: Int): Dynamic { + var vfrom: Vec4 = inputs[0].get(); + var vto: Vec4 = inputs[1].get(); if (vfrom == null || vto == null) return null; diff --git a/Sources/armory/logicnode/LoopBreakNode.hx b/Sources/armory/logicnode/LoopBreakNode.hx index 22223250..d2cccd8e 100644 --- a/Sources/armory/logicnode/LoopBreakNode.hx +++ b/Sources/armory/logicnode/LoopBreakNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class LoopBreakNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { tree.loopBreak = true; } } diff --git a/Sources/armory/logicnode/LoopNode.hx b/Sources/armory/logicnode/LoopNode.hx index 4637260a..8111948f 100644 --- a/Sources/armory/logicnode/LoopNode.hx +++ b/Sources/armory/logicnode/LoopNode.hx @@ -2,16 +2,16 @@ package armory.logicnode; class LoopNode extends LogicNode { - var index:Int; + var index: Int; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { index = 0; - var from:Int = inputs[1].get(); - var to:Int = inputs[2].get(); + var from: Int = inputs[1].get(); + var to: Int = inputs[2].get(); for (i in from...to) { index = i; runOutput(0); @@ -24,7 +24,7 @@ class LoopNode extends LogicNode { runOutput(2); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return index; } } diff --git a/Sources/armory/logicnode/MaskNode.hx b/Sources/armory/logicnode/MaskNode.hx index 45055aa1..b581c368 100644 --- a/Sources/armory/logicnode/MaskNode.hx +++ b/Sources/armory/logicnode/MaskNode.hx @@ -2,16 +2,15 @@ package armory.logicnode; class MaskNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - - var ret : Int= 0; - for(v in 0...20){ - var bit:Bool = inputs[v].get(); - if(bit) ret |= (1 << v); + override function get(from: Int): Dynamic { + var ret = 0; + for (v in 0...20) { + var bit: Bool = inputs[v].get(); + if (bit) ret |= (1 << v); } return ret; } diff --git a/Sources/armory/logicnode/MaterialNode.hx b/Sources/armory/logicnode/MaterialNode.hx index 7c548a21..b8914112 100644 --- a/Sources/armory/logicnode/MaterialNode.hx +++ b/Sources/armory/logicnode/MaterialNode.hx @@ -4,10 +4,10 @@ import iron.data.MaterialData; class MaterialNode extends LogicNode { - public var property0:String; - public var value:MaterialData = null; + public var property0: String; + public var value: MaterialData = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); iron.Scene.active.notifyOnInit(function() { @@ -15,9 +15,9 @@ class MaterialNode extends LogicNode { }); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (property0 != null) { - iron.data.Data.getMaterial(iron.Scene.active.raw.name, property0, function(mat:MaterialData) { + iron.data.Data.getMaterial(iron.Scene.active.raw.name, property0, function(mat: MaterialData) { value = mat; }); } @@ -25,7 +25,7 @@ class MaterialNode extends LogicNode { return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/MathNode.hx b/Sources/armory/logicnode/MathNode.hx index 3a0552f8..56549307 100644 --- a/Sources/armory/logicnode/MathNode.hx +++ b/Sources/armory/logicnode/MathNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class MathNode extends LogicNode { - public var property0:String; - public var property1:String; // Clamp + public var property0: String; + public var property1: String; // Clamp - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { - var v1:Float = inputs[0].get(); - var v2:Float = inputs[1].get(); + var v1: Float = inputs[0].get(); + var v2: Float = inputs[1].get(); var f = 0.0; switch (property0) { case "Add": diff --git a/Sources/armory/logicnode/MatrixMathNode.hx b/Sources/armory/logicnode/MatrixMathNode.hx index cd612495..d7f504f8 100644 --- a/Sources/armory/logicnode/MatrixMathNode.hx +++ b/Sources/armory/logicnode/MatrixMathNode.hx @@ -1,20 +1,19 @@ package armory.logicnode; -import iron.math.Vec4; import iron.math.Mat4; class MatrixMathNode extends LogicNode { - public var property0:String; + public var property0: String; var m = Mat4.identity(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var m1:Mat4 = inputs[0].get(); - var m2:Mat4 = inputs[1].get(); + override function get(from: Int): Dynamic { + var m1: Mat4 = inputs[0].get(); + var m2: Mat4 = inputs[1].get(); if (m1 == null || m2 == null) return null; diff --git a/Sources/armory/logicnode/MergeNode.hx b/Sources/armory/logicnode/MergeNode.hx index ba22a6ab..60eb6ca8 100644 --- a/Sources/armory/logicnode/MergeNode.hx +++ b/Sources/armory/logicnode/MergeNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class MergeNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { runOutput(0); } } diff --git a/Sources/armory/logicnode/MergedGamepadNode.hx b/Sources/armory/logicnode/MergedGamepadNode.hx index 921d9110..6c3afc76 100644 --- a/Sources/armory/logicnode/MergedGamepadNode.hx +++ b/Sources/armory/logicnode/MergedGamepadNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class MergedGamepadNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); } function update() { - var num:Int = inputs[0].get(); + var num: Int = inputs[0].get(); var gamepad = iron.system.Input.getGamepad(num); if (gamepad == null) return; var b = false; @@ -31,8 +31,8 @@ class MergedGamepadNode extends LogicNode { if (b) runOutput(0); } - override function get(from:Int):Dynamic { - var num:Int = inputs[0].get(); + override function get(from: Int): Dynamic { + var num: Int = inputs[0].get(); var gamepad = iron.system.Input.getGamepad(num); switch (property0) { case "Down": diff --git a/Sources/armory/logicnode/MergedKeyboardNode.hx b/Sources/armory/logicnode/MergedKeyboardNode.hx index c165e9c3..72e44b98 100644 --- a/Sources/armory/logicnode/MergedKeyboardNode.hx +++ b/Sources/armory/logicnode/MergedKeyboardNode.hx @@ -2,15 +2,15 @@ package armory.logicnode; class MergedKeyboardNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); - + tree.notifyOnUpdate(update); } - + function update() { var keyboard = iron.system.Input.getKeyboard(); var b = false; @@ -24,8 +24,8 @@ class MergedKeyboardNode extends LogicNode { } if (b) runOutput(0); } - - override function get(from:Int):Dynamic { + + override function get(from: Int): Dynamic { var keyboard = iron.system.Input.getKeyboard(); switch (property0) { case "Down": diff --git a/Sources/armory/logicnode/MergedMouseNode.hx b/Sources/armory/logicnode/MergedMouseNode.hx index 338ed065..833f9aaf 100644 --- a/Sources/armory/logicnode/MergedMouseNode.hx +++ b/Sources/armory/logicnode/MergedMouseNode.hx @@ -2,15 +2,15 @@ package armory.logicnode; class MergedMouseNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); - + tree.notifyOnUpdate(update); } - + function update() { var mouse = iron.system.Input.getMouse(); var b = false; @@ -26,8 +26,8 @@ class MergedMouseNode extends LogicNode { } if (b) runOutput(0); } - - override function get(from:Int):Dynamic { + + override function get(from: Int): Dynamic { var mouse = iron.system.Input.getMouse(); switch (property0) { case "Down": diff --git a/Sources/armory/logicnode/MergedSurfaceNode.hx b/Sources/armory/logicnode/MergedSurfaceNode.hx index 741c8760..0399580c 100644 --- a/Sources/armory/logicnode/MergedSurfaceNode.hx +++ b/Sources/armory/logicnode/MergedSurfaceNode.hx @@ -2,9 +2,9 @@ package armory.logicnode; class MergedSurfaceNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); @@ -26,7 +26,7 @@ class MergedSurfaceNode extends LogicNode { if (b) runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { var surface = iron.system.Input.getSurface(); switch (property0) { case "Touched": diff --git a/Sources/armory/logicnode/MergedVirtualButtonNode.hx b/Sources/armory/logicnode/MergedVirtualButtonNode.hx index 3cced332..0cadc6ea 100644 --- a/Sources/armory/logicnode/MergedVirtualButtonNode.hx +++ b/Sources/armory/logicnode/MergedVirtualButtonNode.hx @@ -2,10 +2,10 @@ package armory.logicnode; class MergedVirtualButtonNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); @@ -26,7 +26,7 @@ class MergedVirtualButtonNode extends LogicNode { if (b) runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { var vb = iron.system.Input.getVirtualButton(property1); if (vb == null) return false; switch (property0) { diff --git a/Sources/armory/logicnode/MeshNode.hx b/Sources/armory/logicnode/MeshNode.hx index e2c04e1b..40112049 100644 --- a/Sources/armory/logicnode/MeshNode.hx +++ b/Sources/armory/logicnode/MeshNode.hx @@ -4,10 +4,10 @@ import iron.data.MeshData; class MeshNode extends LogicNode { - public var property0:String; - public var value:MeshData = null; + public var property0: String; + public var value: MeshData = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); iron.Scene.active.notifyOnInit(function() { @@ -15,15 +15,15 @@ class MeshNode extends LogicNode { }); } - override function get(from:Int):Dynamic { - iron.data.Data.getMesh("mesh_" + property0, property0, function(mesh:MeshData) { + override function get(from: Int): Dynamic { + iron.data.Data.getMesh("mesh_" + property0, property0, function(mesh: MeshData) { value = mesh; }); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/MixNode.hx b/Sources/armory/logicnode/MixNode.hx index 8fdd5fa6..9a3a3a79 100644 --- a/Sources/armory/logicnode/MixNode.hx +++ b/Sources/armory/logicnode/MixNode.hx @@ -4,13 +4,13 @@ import iron.system.Tween; class MixNode extends LogicNode { - public var property0:String; // Type - public var property1:String; // Ease - public var property2:String; // Clamp + public var property0: String; // Type + public var property1: String; // Ease + public var property2: String; // Clamp - var ease:Float->Float = null; + var ease: Float->Float = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -39,13 +39,13 @@ class MixNode extends LogicNode { } } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (ease == null) init(); - var k:Float = inputs[0].get(); //Factor - var v1:Float = inputs[1].get(); - var v2:Float = inputs[2].get(); + var k: Float = inputs[0].get(); //Factor + var v1: Float = inputs[1].get(); + var v2: Float = inputs[2].get(); var f = v1 + (v2 - v1) * ease(k); - + if (property2 == "true") f = f < 0 ? 0 : f > 1 ? 1 : f; return f; } diff --git a/Sources/armory/logicnode/MouseCoordsNode.hx b/Sources/armory/logicnode/MouseCoordsNode.hx index 69fa9626..39df55d1 100644 --- a/Sources/armory/logicnode/MouseCoordsNode.hx +++ b/Sources/armory/logicnode/MouseCoordsNode.hx @@ -6,11 +6,11 @@ class MouseCoordsNode extends LogicNode { var coords = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { var mouse = iron.system.Input.getMouse(); if (from == 0) { coords.x = mouse.x; diff --git a/Sources/armory/logicnode/NavigableLocationNode.hx b/Sources/armory/logicnode/NavigableLocationNode.hx index 79ad5765..68a96bb7 100644 --- a/Sources/armory/logicnode/NavigableLocationNode.hx +++ b/Sources/armory/logicnode/NavigableLocationNode.hx @@ -5,9 +5,9 @@ import armory.trait.navigation.Navigation; class NavigableLocationNode extends LogicNode { - var loc:Vec4; + var loc: Vec4; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); iron.Scene.active.notifyOnInit(function() { @@ -15,10 +15,10 @@ class NavigableLocationNode extends LogicNode { }); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { #if arm_navigation // Assume navmesh exists.. - Navigation.active.navMeshes[0].getRandomPoint(function(p:Vec4) { + Navigation.active.navMeshes[0].getRandomPoint(function(p: Vec4) { loc = p; }); #end diff --git a/Sources/armory/logicnode/NoneNode.hx b/Sources/armory/logicnode/NoneNode.hx index cc0a7146..0dd28ce5 100644 --- a/Sources/armory/logicnode/NoneNode.hx +++ b/Sources/armory/logicnode/NoneNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class NoneNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return null; } } diff --git a/Sources/armory/logicnode/NotNode.hx b/Sources/armory/logicnode/NotNode.hx index 5f9391c8..d771521c 100644 --- a/Sources/armory/logicnode/NotNode.hx +++ b/Sources/armory/logicnode/NotNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class NotNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var v1:Bool = inputs[0].get(); + override function get(from: Int): Dynamic { + var v1: Bool = inputs[0].get(); return !v1; } } diff --git a/Sources/armory/logicnode/NullNode.hx b/Sources/armory/logicnode/NullNode.hx index 00ac226c..88d1f13f 100644 --- a/Sources/armory/logicnode/NullNode.hx +++ b/Sources/armory/logicnode/NullNode.hx @@ -2,9 +2,9 @@ package armory.logicnode; class NullNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { return null; } + override function get(from: Int): Dynamic { return null; } } diff --git a/Sources/armory/logicnode/ObjectNode.hx b/Sources/armory/logicnode/ObjectNode.hx index 33894e3e..1506fdd2 100644 --- a/Sources/armory/logicnode/ObjectNode.hx +++ b/Sources/armory/logicnode/ObjectNode.hx @@ -4,21 +4,21 @@ import iron.object.Object; class ObjectNode extends LogicNode { - public var objectName:String; - public var value:Object = null; + public var objectName: String; + public var value: Object = null; - public function new(tree:LogicTree, objectName:String = "") { + public function new(tree: LogicTree, objectName: String = "") { this.objectName = objectName; super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (inputs.length > 0) return inputs[0].get(); if (value == null) value = objectName != "" ? iron.Scene.active.getChild(objectName) : tree.object; return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { if (inputs.length > 0) inputs[0].set(value); else { objectName = value.name; diff --git a/Sources/armory/logicnode/OnActionMarkerNode.hx b/Sources/armory/logicnode/OnActionMarkerNode.hx index 35a7c076..80c2b95f 100644 --- a/Sources/armory/logicnode/OnActionMarkerNode.hx +++ b/Sources/armory/logicnode/OnActionMarkerNode.hx @@ -4,20 +4,20 @@ import iron.object.Object; class OnActionMarkerNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnInit(init); } function init() { - var object:Object = inputs[0].get(); - var marker:String = inputs[1].get(); - + var object: Object = inputs[0].get(); + var marker: String = inputs[1].get(); + if (object == null) return; var animation = object.animation; if (animation == null) animation = object.getParentArmature(object.name); - + animation.notifyOnMarker(marker, function() { runOutput(0); }); } } diff --git a/Sources/armory/logicnode/OnContactArrayNode.hx b/Sources/armory/logicnode/OnContactArrayNode.hx index 33084a3d..043c761b 100644 --- a/Sources/armory/logicnode/OnContactArrayNode.hx +++ b/Sources/armory/logicnode/OnContactArrayNode.hx @@ -5,18 +5,18 @@ import armory.trait.physics.RigidBody; class OnContactArrayNode extends LogicNode { - public var property0:String; + public var property0: String; var lastContact = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); } function update() { - var object1:Object = inputs[0].get(); - var objects:Array = inputs[1].get(); + var object1: Object = inputs[0].get(); + var objects: Array = inputs[1].get(); if (object1 == null) object1 = tree.object; if (objects == null)return; diff --git a/Sources/armory/logicnode/OnContactNode.hx b/Sources/armory/logicnode/OnContactNode.hx index f944b61a..81762590 100644 --- a/Sources/armory/logicnode/OnContactNode.hx +++ b/Sources/armory/logicnode/OnContactNode.hx @@ -5,18 +5,18 @@ import armory.trait.physics.RigidBody; class OnContactNode extends LogicNode { - public var property0:String; + public var property0: String; var lastContact = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); } function update() { - var object1:Object = inputs[0].get(); - var object2:Object = inputs[1].get(); + var object1: Object = inputs[0].get(); + var object2: Object = inputs[1].get(); if (object1 == null) object1 = tree.object; if (object2 == null) object2 = tree.object; diff --git a/Sources/armory/logicnode/OnEventNode.hx b/Sources/armory/logicnode/OnEventNode.hx index fb39bd35..b905833f 100644 --- a/Sources/armory/logicnode/OnEventNode.hx +++ b/Sources/armory/logicnode/OnEventNode.hx @@ -4,20 +4,20 @@ import armory.system.Event; class OnEventNode extends LogicNode { - var _property0:String; - public var property0(get, set):String; - var listener:TEvent = null; + var _property0: String; + public var property0(get, set): String; + var listener: TEvent = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnRemove(onRemove); } - function get_property0():String { + function get_property0(): String { return _property0; } - function set_property0(s:String):String { + function set_property0(s: String): String { listener = Event.add(s, onEvent, tree.object.uid); return _property0 = s; } diff --git a/Sources/armory/logicnode/OnGamepadNode.hx b/Sources/armory/logicnode/OnGamepadNode.hx index edba6a67..6e54b8da 100644 --- a/Sources/armory/logicnode/OnGamepadNode.hx +++ b/Sources/armory/logicnode/OnGamepadNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class OnGamepadNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); } function update() { - var num:Int = inputs[0].get(); + var num: Int = inputs[0].get(); var gamepad = iron.system.Input.getGamepad(num); if (gamepad == null) return; var b = false; diff --git a/Sources/armory/logicnode/OnInitNode.hx b/Sources/armory/logicnode/OnInitNode.hx index 171e5042..ea825cd1 100644 --- a/Sources/armory/logicnode/OnInitNode.hx +++ b/Sources/armory/logicnode/OnInitNode.hx @@ -5,7 +5,7 @@ import armory.trait.physics.PhysicsWorld; @:access(iron.Trait) class OnInitNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnInit(init); } diff --git a/Sources/armory/logicnode/OnKeyboardNode.hx b/Sources/armory/logicnode/OnKeyboardNode.hx index 8f5ed6f2..188a477f 100644 --- a/Sources/armory/logicnode/OnKeyboardNode.hx +++ b/Sources/armory/logicnode/OnKeyboardNode.hx @@ -2,10 +2,10 @@ package armory.logicnode; class OnKeyboardNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); diff --git a/Sources/armory/logicnode/OnMouseNode.hx b/Sources/armory/logicnode/OnMouseNode.hx index 42f2e878..6bb1845f 100644 --- a/Sources/armory/logicnode/OnMouseNode.hx +++ b/Sources/armory/logicnode/OnMouseNode.hx @@ -2,10 +2,10 @@ package armory.logicnode; class OnMouseNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); diff --git a/Sources/armory/logicnode/OnSurfaceNode.hx b/Sources/armory/logicnode/OnSurfaceNode.hx index 97e19d23..c097aeb9 100644 --- a/Sources/armory/logicnode/OnSurfaceNode.hx +++ b/Sources/armory/logicnode/OnSurfaceNode.hx @@ -2,9 +2,9 @@ package armory.logicnode; class OnSurfaceNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); diff --git a/Sources/armory/logicnode/OnTimerNode.hx b/Sources/armory/logicnode/OnTimerNode.hx index 28b71b21..5328bddb 100644 --- a/Sources/armory/logicnode/OnTimerNode.hx +++ b/Sources/armory/logicnode/OnTimerNode.hx @@ -5,7 +5,7 @@ class OnTimerNode extends LogicNode { var duration = 0.0; var repeat = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); diff --git a/Sources/armory/logicnode/OnUpdateNode.hx b/Sources/armory/logicnode/OnUpdateNode.hx index 6e74a0d5..a445c3e3 100644 --- a/Sources/armory/logicnode/OnUpdateNode.hx +++ b/Sources/armory/logicnode/OnUpdateNode.hx @@ -4,9 +4,9 @@ import armory.trait.physics.PhysicsWorld; class OnUpdateNode extends LogicNode { - public var property0:String; // Update, Late Update, Physics Pre-Update + public var property0: String; // Update, Late Update, Physics Pre-Update - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnInit(init); } @@ -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 */ } } diff --git a/Sources/armory/logicnode/OnVirtualButtonNode.hx b/Sources/armory/logicnode/OnVirtualButtonNode.hx index d092c7f7..954845c9 100644 --- a/Sources/armory/logicnode/OnVirtualButtonNode.hx +++ b/Sources/armory/logicnode/OnVirtualButtonNode.hx @@ -2,10 +2,10 @@ package armory.logicnode; class OnVirtualButtonNode extends LogicNode { - public var property0:String; - public var property1:String; + public var property0: String; + public var property1: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); diff --git a/Sources/armory/logicnode/OnVolumeTriggerNode.hx b/Sources/armory/logicnode/OnVolumeTriggerNode.hx index 2fc26be7..7fa0d9a1 100644 --- a/Sources/armory/logicnode/OnVolumeTriggerNode.hx +++ b/Sources/armory/logicnode/OnVolumeTriggerNode.hx @@ -5,21 +5,21 @@ import iron.math.Vec4; class OnVolumeTriggerNode extends LogicNode { - public var property0:String; + public var property0: String; var lastOverlap = false; var l1 = new Vec4(); var l2 = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); tree.notifyOnUpdate(update); } function update() { - var object:Object = inputs[0].get(); - var volume:Object = inputs[1].get(); + var object: Object = inputs[0].get(); + var volume: Object = inputs[1].get(); if (object == null) return; if (volume == null) volume = tree.object; diff --git a/Sources/armory/logicnode/ParseFloatNode.hx b/Sources/armory/logicnode/ParseFloatNode.hx index 07b5d977..6fe0bb4a 100644 --- a/Sources/armory/logicnode/ParseFloatNode.hx +++ b/Sources/armory/logicnode/ParseFloatNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class ParseFloatNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var s:String = inputs[0].get(); + override function get(from: Int): Dynamic { + var s: String = inputs[0].get(); if (s == null) return null; return Std.parseFloat(s); diff --git a/Sources/armory/logicnode/PauseActionNode.hx b/Sources/armory/logicnode/PauseActionNode.hx index 6ab0813e..5bd76f38 100644 --- a/Sources/armory/logicnode/PauseActionNode.hx +++ b/Sources/armory/logicnode/PauseActionNode.hx @@ -4,13 +4,13 @@ import iron.object.Object; class PauseActionNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + if (object == null) return; var animation = object.animation; if (animation == null) animation = object.getParentArmature(object.name); diff --git a/Sources/armory/logicnode/PauseSoundNode.hx b/Sources/armory/logicnode/PauseSoundNode.hx index 42ac4131..9c712df9 100644 --- a/Sources/armory/logicnode/PauseSoundNode.hx +++ b/Sources/armory/logicnode/PauseSoundNode.hx @@ -4,12 +4,12 @@ import iron.object.SpeakerObject; class PauseSoundNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:SpeakerObject = cast(inputs[1].get(), SpeakerObject); + override function run(from: Int) { + var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject); if (object == null) return; object.pause(); runOutput(0); diff --git a/Sources/armory/logicnode/PauseTilesheetNode.hx b/Sources/armory/logicnode/PauseTilesheetNode.hx index 418dc9ed..55566edb 100644 --- a/Sources/armory/logicnode/PauseTilesheetNode.hx +++ b/Sources/armory/logicnode/PauseTilesheetNode.hx @@ -4,13 +4,13 @@ import iron.object.MeshObject; class PauseTilesheetNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:MeshObject = inputs[1].get(); - + override function run(from: Int) { + var object: MeshObject = inputs[1].get(); + if (object == null) return; object.tilesheet.pause(); diff --git a/Sources/armory/logicnode/PauseTraitNode.hx b/Sources/armory/logicnode/PauseTraitNode.hx index 093379a1..a040f5d1 100644 --- a/Sources/armory/logicnode/PauseTraitNode.hx +++ b/Sources/armory/logicnode/PauseTraitNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class PauseTraitNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var trait:Dynamic = inputs[1].get(); + override function run(from: Int) { + var trait: Dynamic = inputs[1].get(); if (trait == null || !Std.is(trait, LogicTree)) return; cast(trait, LogicTree).pause(); diff --git a/Sources/armory/logicnode/PickLocationNode.hx b/Sources/armory/logicnode/PickLocationNode.hx index f6d96b23..4c258b76 100644 --- a/Sources/armory/logicnode/PickLocationNode.hx +++ b/Sources/armory/logicnode/PickLocationNode.hx @@ -7,14 +7,14 @@ class PickLocationNode extends LogicNode { var loc = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var object:Object = inputs[0].get(); - var coords:Vec4 = inputs[1].get(); - + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); + var coords: Vec4 = inputs[1].get(); + if (object == null || coords == null) null; #if arm_physics diff --git a/Sources/armory/logicnode/PickObjectNode.hx b/Sources/armory/logicnode/PickObjectNode.hx index df561292..a135f245 100644 --- a/Sources/armory/logicnode/PickObjectNode.hx +++ b/Sources/armory/logicnode/PickObjectNode.hx @@ -6,12 +6,12 @@ class PickObjectNode extends LogicNode { var v = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var coords:Vec4 = inputs[0].get(); + override function get(from: Int): Dynamic { + var coords: Vec4 = inputs[0].get(); if (coords == null) return null; diff --git a/Sources/armory/logicnode/PlayActionNode.hx b/Sources/armory/logicnode/PlayActionNode.hx index faee7588..61afa794 100644 --- a/Sources/armory/logicnode/PlayActionNode.hx +++ b/Sources/armory/logicnode/PlayActionNode.hx @@ -4,15 +4,15 @@ import iron.object.Object; class PlayActionNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var action:String = inputs[2].get(); - var blendTime:Float = inputs[3].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var action: String = inputs[2].get(); + var blendTime: Float = inputs[3].get(); + if (object == null) return; var animation = object.animation; if (animation == null) animation = object.getParentArmature(object.name); diff --git a/Sources/armory/logicnode/PlaySoundNode.hx b/Sources/armory/logicnode/PlaySoundNode.hx index 91c8a3cf..9b321742 100644 --- a/Sources/armory/logicnode/PlaySoundNode.hx +++ b/Sources/armory/logicnode/PlaySoundNode.hx @@ -4,12 +4,12 @@ import iron.object.SpeakerObject; class PlaySoundNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:SpeakerObject = cast(inputs[1].get(), SpeakerObject); + override function run(from: Int) { + var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject); if (object == null) return; object.play(); runOutput(0); diff --git a/Sources/armory/logicnode/PlaySoundRawNode.hx b/Sources/armory/logicnode/PlaySoundRawNode.hx index ab57f0cb..da877eef 100644 --- a/Sources/armory/logicnode/PlaySoundRawNode.hx +++ b/Sources/armory/logicnode/PlaySoundRawNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class PlaySoundRawNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - iron.data.Data.getSound(property0, function(sound:kha.Sound) { + override function run(from: Int) { + iron.data.Data.getSound(property0, function(sound: kha.Sound) { iron.system.Audio.play(sound, false); }); runOutput(0); diff --git a/Sources/armory/logicnode/PlayTilesheetNode.hx b/Sources/armory/logicnode/PlayTilesheetNode.hx index 24d53143..6c06b94c 100644 --- a/Sources/armory/logicnode/PlayTilesheetNode.hx +++ b/Sources/armory/logicnode/PlayTilesheetNode.hx @@ -4,14 +4,14 @@ import iron.object.MeshObject; class PlayTilesheetNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:MeshObject = inputs[1].get(); - var action:String = inputs[2].get(); - + override function run(from: Int) { + var object: MeshObject = inputs[1].get(); + var action: String = inputs[2].get(); + if (object == null) return; object.tilesheet.play(action, function() { diff --git a/Sources/armory/logicnode/PrintNode.hx b/Sources/armory/logicnode/PrintNode.hx index 0092aaee..f4e89f62 100644 --- a/Sources/armory/logicnode/PrintNode.hx +++ b/Sources/armory/logicnode/PrintNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class PrintNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var value:Dynamic = inputs[1].get(); - + override function run(from: Int) { + var value: Dynamic = inputs[1].get(); + #if (arm_debug) trace(tree.name + ": " + value); #else diff --git a/Sources/armory/logicnode/QuaternionNode.hx b/Sources/armory/logicnode/QuaternionNode.hx index 807c34b2..d92c4bfe 100644 --- a/Sources/armory/logicnode/QuaternionNode.hx +++ b/Sources/armory/logicnode/QuaternionNode.hx @@ -6,7 +6,7 @@ class QuaternionNode extends LogicNode { var value = new Quat(); - public function new(tree:LogicTree, x:Null = null, y:Null = null, z:Null = null, w:Null = null) { + public function new(tree: LogicTree, x: Null = null, y: Null = null, z: Null = null, w: Null = null) { super(tree); if (x != null) { @@ -17,7 +17,7 @@ class QuaternionNode extends LogicNode { } } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { value.x = inputs[0].get(); value.y = inputs[1].get(); value.z = inputs[2].get(); @@ -25,7 +25,7 @@ class QuaternionNode extends LogicNode { return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/RadToDegNode.hx b/Sources/armory/logicnode/RadToDegNode.hx index b1a35295..7e746e69 100644 --- a/Sources/armory/logicnode/RadToDegNode.hx +++ b/Sources/armory/logicnode/RadToDegNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class RadToDegNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var rad:Float = inputs[0].get(); + override function get(from: Int): Dynamic { + var rad: Float = inputs[0].get(); return rad * 57.29578; } } diff --git a/Sources/armory/logicnode/RandomBooleanNode.hx b/Sources/armory/logicnode/RandomBooleanNode.hx index bf50f24e..0c2927a9 100644 --- a/Sources/armory/logicnode/RandomBooleanNode.hx +++ b/Sources/armory/logicnode/RandomBooleanNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class RandomBooleanNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return Std.random(2) == 0; } } diff --git a/Sources/armory/logicnode/RandomColorNode.hx b/Sources/armory/logicnode/RandomColorNode.hx index f8eb37fd..a8145be2 100644 --- a/Sources/armory/logicnode/RandomColorNode.hx +++ b/Sources/armory/logicnode/RandomColorNode.hx @@ -6,11 +6,11 @@ class RandomColorNode extends LogicNode { var v = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { var r = Math.random(); var g = Math.random(); var b = Math.random(); diff --git a/Sources/armory/logicnode/RandomFloatNode.hx b/Sources/armory/logicnode/RandomFloatNode.hx index 008fd358..f7669955 100644 --- a/Sources/armory/logicnode/RandomFloatNode.hx +++ b/Sources/armory/logicnode/RandomFloatNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class RandomFloatNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var min:Float = inputs[0].get(); - var max:Float = inputs[1].get(); + override function get(from: Int): Dynamic { + var min: Float = inputs[0].get(); + var max: Float = inputs[1].get(); return min + (Math.random() * (max - min)); } } diff --git a/Sources/armory/logicnode/RandomIntegerNode.hx b/Sources/armory/logicnode/RandomIntegerNode.hx index dc2f1409..6bf81e4a 100644 --- a/Sources/armory/logicnode/RandomIntegerNode.hx +++ b/Sources/armory/logicnode/RandomIntegerNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class RandomIntegerNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var min:Int = inputs[0].get(); - var max:Int = inputs[1].get(); + override function get(from: Int): Dynamic { + var min: Int = inputs[0].get(); + var max: Int = inputs[1].get(); return min + Std.random(max - min); } } diff --git a/Sources/armory/logicnode/RandomVectorNode.hx b/Sources/armory/logicnode/RandomVectorNode.hx index 12385db9..6a1d014a 100644 --- a/Sources/armory/logicnode/RandomVectorNode.hx +++ b/Sources/armory/logicnode/RandomVectorNode.hx @@ -6,13 +6,13 @@ class RandomVectorNode extends LogicNode { var v = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var min:Vec4 = inputs[0].get(); - var max:Vec4 = inputs[1].get(); + override function get(from: Int): Dynamic { + var min: Vec4 = inputs[0].get(); + var max: Vec4 = inputs[1].get(); var x = min.x + (Math.random() * (max.x - min.x)); var y = min.y + (Math.random() * (max.y - min.y)); var z = min.z + (Math.random() * (max.z - min.z)); diff --git a/Sources/armory/logicnode/ReadFileNode.hx b/Sources/armory/logicnode/ReadFileNode.hx index acc34d37..e8d4f963 100644 --- a/Sources/armory/logicnode/ReadFileNode.hx +++ b/Sources/armory/logicnode/ReadFileNode.hx @@ -2,29 +2,29 @@ package armory.logicnode; class ReadFileNode extends LogicNode { - var data:String; + var data: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { // Relative or absolute path to file - var file:String = inputs[1].get(); + var file: String = inputs[1].get(); // Whether to use the cache - var useCache:Bool = inputs[2].get(); + var useCache: Bool = inputs[2].get(); // Load the file asynchronously - if(!useCache && iron.data.Data.cachedBlobs.get(file) != null) iron.data.Data.cachedBlobs.remove(file); - iron.data.Data.getBlob(file, function(b:kha.Blob) { + if (!useCache && iron.data.Data.cachedBlobs.get(file) != null) iron.data.Data.cachedBlobs.remove(file); + iron.data.Data.getBlob(file, function(b: kha.Blob) { data = b.toString(); - if(!useCache) iron.data.Data.cachedBlobs.remove(file); + if (!useCache) iron.data.Data.cachedBlobs.remove(file); runOutput(0); }); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return data; } } diff --git a/Sources/armory/logicnode/ReadJsonNode.hx b/Sources/armory/logicnode/ReadJsonNode.hx index 2b1c8bb0..1c7c06de 100644 --- a/Sources/armory/logicnode/ReadJsonNode.hx +++ b/Sources/armory/logicnode/ReadJsonNode.hx @@ -2,29 +2,29 @@ package armory.logicnode; class ReadJsonNode extends LogicNode { - var data:Dynamic; + var data: Dynamic; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { // Relative or absolute path to file - var file:String = inputs[1].get(); + var file: String = inputs[1].get(); // Whether to use the cache - var useCache:Bool = inputs[2].get(); - + var useCache: Bool = inputs[2].get(); + // Load the file asynchronously - if(!useCache && iron.data.Data.cachedBlobs.get(file) != null) iron.data.Data.cachedBlobs.remove(file); - iron.data.Data.getBlob(file, function(b:kha.Blob) { + if (!useCache && iron.data.Data.cachedBlobs.get(file) != null) iron.data.Data.cachedBlobs.remove(file); + iron.data.Data.getBlob(file, function(b: kha.Blob) { data = haxe.Json.parse(b.toString()); - if(!useCache) iron.data.Data.cachedBlobs.remove(file); + if (!useCache) iron.data.Data.cachedBlobs.remove(file); runOutput(0); }); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return data; } } diff --git a/Sources/armory/logicnode/ReadStorageNode.hx b/Sources/armory/logicnode/ReadStorageNode.hx index d3050306..40f60a49 100644 --- a/Sources/armory/logicnode/ReadStorageNode.hx +++ b/Sources/armory/logicnode/ReadStorageNode.hx @@ -2,17 +2,17 @@ package armory.logicnode; class ReadStorageNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var key:String = inputs[0].get(); + override function get(from: Int): Dynamic { + var key: String = inputs[0].get(); - var data:Dynamic = iron.system.Storage.data; + var data: Dynamic = iron.system.Storage.data; if (data == null) return null; - - var value:Dynamic = Reflect.field(data, key); + + var value: Dynamic = Reflect.field(data, key); if (value == null) { value = parseArg(inputs[1].get()); @@ -21,7 +21,7 @@ class ReadStorageNode extends LogicNode { return value; } - static function parseArg(str:String):Dynamic { + static function parseArg(str: String): Dynamic { if (str == "true") return true; else if (str == "false") return false; else if (str.charAt(0) == "'") return StringTools.replace(str, "'", ""); @@ -31,7 +31,7 @@ class ReadStorageNode extends LogicNode { str = StringTools.replace(str, "[", ""); str = StringTools.replace(str, "]", ""); str = StringTools.replace(str, " ", ""); - var ar:Dynamic = []; + var ar: Dynamic = []; var s = str.split(","); for (childStr in s) { ar.push(parseArg(childStr)); diff --git a/Sources/armory/logicnode/RemoveActiveSceneNode.hx b/Sources/armory/logicnode/RemoveActiveSceneNode.hx index 971a1333..2a24e01c 100644 --- a/Sources/armory/logicnode/RemoveActiveSceneNode.hx +++ b/Sources/armory/logicnode/RemoveActiveSceneNode.hx @@ -2,12 +2,11 @@ package armory.logicnode; class RemoveActiveSceneNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - + override function run(from: Int) { iron.Scene.active.remove(); runOutput(0); } diff --git a/Sources/armory/logicnode/RemoveGroupNode.hx b/Sources/armory/logicnode/RemoveGroupNode.hx index 1f30eb29..78d2b00a 100644 --- a/Sources/armory/logicnode/RemoveGroupNode.hx +++ b/Sources/armory/logicnode/RemoveGroupNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class RemoveGroupNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var groupName:String = inputs[1].get(); + override function run(from: Int) { + var groupName: String = inputs[1].get(); var raw = iron.Scene.active.raw; for (g in raw.groups) { diff --git a/Sources/armory/logicnode/RemoveObjectNode.hx b/Sources/armory/logicnode/RemoveObjectNode.hx index 1209586e..835e5d3e 100644 --- a/Sources/armory/logicnode/RemoveObjectNode.hx +++ b/Sources/armory/logicnode/RemoveObjectNode.hx @@ -4,13 +4,13 @@ import iron.object.Object; class RemoveObjectNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + if (object == null) return; object.remove(); diff --git a/Sources/armory/logicnode/RemoveTraitNode.hx b/Sources/armory/logicnode/RemoveTraitNode.hx index 1ffeb7d7..b70ee56e 100644 --- a/Sources/armory/logicnode/RemoveTraitNode.hx +++ b/Sources/armory/logicnode/RemoveTraitNode.hx @@ -1,15 +1,13 @@ package armory.logicnode; -import iron.object.Object; - class RemoveTraitNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var trait:Dynamic = inputs[1].get(); + override function run(from: Int) { + var trait: Dynamic = inputs[1].get(); if (trait == null) return; trait.remove(); diff --git a/Sources/armory/logicnode/ResumeActionNode.hx b/Sources/armory/logicnode/ResumeActionNode.hx index b3c49d8a..3cc291ac 100644 --- a/Sources/armory/logicnode/ResumeActionNode.hx +++ b/Sources/armory/logicnode/ResumeActionNode.hx @@ -4,13 +4,13 @@ import iron.object.Object; class ResumeActionNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + if (object == null) return; var animation = object.animation; if (animation == null) animation = object.getParentArmature(object.name); diff --git a/Sources/armory/logicnode/ResumeTilesheetNode.hx b/Sources/armory/logicnode/ResumeTilesheetNode.hx index 0fb78595..fbb7b8cb 100644 --- a/Sources/armory/logicnode/ResumeTilesheetNode.hx +++ b/Sources/armory/logicnode/ResumeTilesheetNode.hx @@ -4,13 +4,13 @@ import iron.object.MeshObject; class ResumeTilesheetNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:MeshObject = inputs[1].get(); - + override function run(from: Int) { + var object: MeshObject = inputs[1].get(); + if (object == null) return; object.tilesheet.resume(); diff --git a/Sources/armory/logicnode/ResumeTraitNode.hx b/Sources/armory/logicnode/ResumeTraitNode.hx index 246655e4..c3c8b26b 100644 --- a/Sources/armory/logicnode/ResumeTraitNode.hx +++ b/Sources/armory/logicnode/ResumeTraitNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class ResumeTraitNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var trait:Dynamic = inputs[1].get(); + override function run(from: Int) { + var trait: Dynamic = inputs[1].get(); if (trait == null || !Std.is(trait, LogicTree)) return; cast(trait, LogicTree).resume(); diff --git a/Sources/armory/logicnode/RotateObjectAroundAxisNode.hx b/Sources/armory/logicnode/RotateObjectAroundAxisNode.hx index 2af1021b..dd44d32c 100644 --- a/Sources/armory/logicnode/RotateObjectAroundAxisNode.hx +++ b/Sources/armory/logicnode/RotateObjectAroundAxisNode.hx @@ -6,14 +6,14 @@ import armory.trait.physics.RigidBody; class RotateObjectAroundAxisNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var axis:Vec4 = inputs[2].get(); - var angle:Float = inputs[3].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var axis: Vec4 = inputs[2].get(); + var angle: Float = inputs[3].get(); if (object == null || axis == null) return; diff --git a/Sources/armory/logicnode/RotateObjectNode.hx b/Sources/armory/logicnode/RotateObjectNode.hx index 6eb3a99e..8525ac0c 100644 --- a/Sources/armory/logicnode/RotateObjectNode.hx +++ b/Sources/armory/logicnode/RotateObjectNode.hx @@ -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; @@ -10,13 +9,13 @@ class RotateObjectNode extends LogicNode { var q = new Quat(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var vec:Vec4 = inputs[2].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var vec: Vec4 = inputs[2].get(); if (object == null || vec == null) return; diff --git a/Sources/armory/logicnode/RpConfigNode.hx b/Sources/armory/logicnode/RpConfigNode.hx index 7f16136e..f5075e20 100644 --- a/Sources/armory/logicnode/RpConfigNode.hx +++ b/Sources/armory/logicnode/RpConfigNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class RpConfigNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int){ - var on:Bool = inputs[1].get(); + override function run(from: Int){ + var on: Bool = inputs[1].get(); switch (property0) { case "SSGI": @@ -21,10 +21,10 @@ 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(); runOutput(0); } -} \ No newline at end of file +} diff --git a/Sources/armory/logicnode/RpMSAANode.hx b/Sources/armory/logicnode/RpMSAANode.hx index bf604624..827e936a 100644 --- a/Sources/armory/logicnode/RpMSAANode.hx +++ b/Sources/armory/logicnode/RpMSAANode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class RpMSAANode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int){ + override function run(from: Int){ switch (property0) { case "1": @@ -26,4 +26,4 @@ class RpMSAANode extends LogicNode { armory.data.Config.save(); runOutput(0); } -} \ No newline at end of file +} diff --git a/Sources/armory/logicnode/RpShadowQualityNode.hx b/Sources/armory/logicnode/RpShadowQualityNode.hx index 6ae60325..f31f84f3 100644 --- a/Sources/armory/logicnode/RpShadowQualityNode.hx +++ b/Sources/armory/logicnode/RpShadowQualityNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class RpShadowQualityNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int){ + override function run(from: Int){ switch (property0) { case "High": @@ -18,9 +18,9 @@ class RpShadowQualityNode extends LogicNode { case "Low": armory.data.Config.raw.rp_shadowmap_cascade = 1024; } - + armory.renderpath.RenderPathCreator.applyConfig(); armory.data.Config.save(); runOutput(0); } -} \ No newline at end of file +} diff --git a/Sources/armory/logicnode/RpSuperSampleNode.hx b/Sources/armory/logicnode/RpSuperSampleNode.hx index a77dd45f..26f5d60e 100644 --- a/Sources/armory/logicnode/RpSuperSampleNode.hx +++ b/Sources/armory/logicnode/RpSuperSampleNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class RpSuperSampleNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int){ + override function run(from: Int){ switch (property0) { case "1": @@ -24,4 +24,4 @@ class RpSuperSampleNode extends LogicNode { armory.data.Config.save(); runOutput(0); } -} \ No newline at end of file +} diff --git a/Sources/armory/logicnode/ScaleObjectNode.hx b/Sources/armory/logicnode/ScaleObjectNode.hx index 4bb9bf90..16c54ac8 100644 --- a/Sources/armory/logicnode/ScaleObjectNode.hx +++ b/Sources/armory/logicnode/ScaleObjectNode.hx @@ -1,19 +1,18 @@ package armory.logicnode; import iron.object.Object; -import iron.math.Mat4; import iron.math.Vec4; import armory.trait.physics.RigidBody; class ScaleObjectNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var vec:Vec4 = inputs[2].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var vec: Vec4 = inputs[2].get(); if (object == null || vec == null) return; diff --git a/Sources/armory/logicnode/SceneNode.hx b/Sources/armory/logicnode/SceneNode.hx index 8a626106..5dc7d9bd 100644 --- a/Sources/armory/logicnode/SceneNode.hx +++ b/Sources/armory/logicnode/SceneNode.hx @@ -1,20 +1,18 @@ package armory.logicnode; -import iron.Scene; - class SceneNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return property0; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.property0 = value; } } diff --git a/Sources/armory/logicnode/SceneRootNode.hx b/Sources/armory/logicnode/SceneRootNode.hx index f0adbf2e..263e7597 100644 --- a/Sources/armory/logicnode/SceneRootNode.hx +++ b/Sources/armory/logicnode/SceneRootNode.hx @@ -1,14 +1,12 @@ package armory.logicnode; -import iron.Scene; - class SceneRootNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return iron.Scene.active.root; } } diff --git a/Sources/armory/logicnode/ScreenToWorldSpaceNode.hx b/Sources/armory/logicnode/ScreenToWorldSpaceNode.hx index e57f0fb2..a5339f08 100644 --- a/Sources/armory/logicnode/ScreenToWorldSpaceNode.hx +++ b/Sources/armory/logicnode/ScreenToWorldSpaceNode.hx @@ -5,16 +5,16 @@ import iron.math.Mat4; class ScreenToWorldSpaceNode extends LogicNode { - public var property0:String; + public var property0: String; var v = new Vec4(); var m = Mat4.identity(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var v1:Vec4 = inputs[0].get(); + override function get(from: Int): Dynamic { + var v1: Vec4 = inputs[0].get(); if (v1 == null) return null; diff --git a/Sources/armory/logicnode/ScriptNode.hx b/Sources/armory/logicnode/ScriptNode.hx index bdb919a9..1a50f4b3 100644 --- a/Sources/armory/logicnode/ScriptNode.hx +++ b/Sources/armory/logicnode/ScriptNode.hx @@ -2,22 +2,22 @@ package armory.logicnode; class ScriptNode extends LogicNode { - public var property0:String; - var result:Dynamic; + public var property0: String; + var result: Dynamic; #if hscript - var parser:hscript.Parser = null; - var interp:hscript.Interp = null; - var ast:hscript.Expr = null; + var parser: hscript.Parser = null; + var interp: hscript.Interp = null; + var ast: hscript.Expr = null; #end - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { - var v:Dynamic = inputs[1].get(); + var v: Dynamic = inputs[1].get(); #if hscript if (parser == null) { @@ -36,7 +36,7 @@ class ScriptNode extends LogicNode { runOutput(0); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return result; } } diff --git a/Sources/armory/logicnode/SelfNode.hx b/Sources/armory/logicnode/SelfNode.hx index bd645323..f8db60a4 100755 --- a/Sources/armory/logicnode/SelfNode.hx +++ b/Sources/armory/logicnode/SelfNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class SelfNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return tree.object; } } diff --git a/Sources/armory/logicnode/SelfTraitNode.hx b/Sources/armory/logicnode/SelfTraitNode.hx index 6d992a25..f6de93cb 100644 --- a/Sources/armory/logicnode/SelfTraitNode.hx +++ b/Sources/armory/logicnode/SelfTraitNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class SelfTraitNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return tree; } } diff --git a/Sources/armory/logicnode/SendEventNode.hx b/Sources/armory/logicnode/SendEventNode.hx index 94179ad5..2fff9bea 100644 --- a/Sources/armory/logicnode/SendEventNode.hx +++ b/Sources/armory/logicnode/SendEventNode.hx @@ -5,18 +5,18 @@ import armory.system.Event; class SendEventNode extends LogicNode { - var entries:Array = null; + var entries: Array = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var name:String = inputs[1].get(); - var object:Object = inputs.length > 2 ? inputs[2].get() : tree.object; + override function run(from: Int) { + var name: String = inputs[1].get(); + var object: Object = inputs.length > 2 ? inputs[2].get() : tree.object; + + if (object == null) return; - if (object == null) return null; - var all = Event.get(name); if (all != null) { entries = []; diff --git a/Sources/armory/logicnode/SendGlobalEventNode.hx b/Sources/armory/logicnode/SendGlobalEventNode.hx index fde291e0..798847f6 100644 --- a/Sources/armory/logicnode/SendGlobalEventNode.hx +++ b/Sources/armory/logicnode/SendGlobalEventNode.hx @@ -1,19 +1,18 @@ package armory.logicnode; -import iron.object.Object; import armory.system.Event; class SendGlobalEventNode extends LogicNode { - var entries:Array = null; + var entries: Array = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var name:String = inputs[1].get(); - + override function run(from: Int) { + var name: String = inputs[1].get(); + entries = Event.get(name); if (entries == null) return; // Event does not exist for (e in entries) e.onEvent(); diff --git a/Sources/armory/logicnode/SensorCoordsNode.hx b/Sources/armory/logicnode/SensorCoordsNode.hx index 07dd00e2..618b6ce1 100644 --- a/Sources/armory/logicnode/SensorCoordsNode.hx +++ b/Sources/armory/logicnode/SensorCoordsNode.hx @@ -6,11 +6,11 @@ class SensorCoordsNode extends LogicNode { var coords = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { var sensor = iron.system.Input.getSensor(); coords.x = sensor.x; coords.y = sensor.y; diff --git a/Sources/armory/logicnode/SeparateColorNode.hx b/Sources/armory/logicnode/SeparateColorNode.hx index 4a240b7d..b9f94bd9 100644 --- a/Sources/armory/logicnode/SeparateColorNode.hx +++ b/Sources/armory/logicnode/SeparateColorNode.hx @@ -4,12 +4,12 @@ import iron.math.Vec4; class SeparateColorNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var vector:Vec4 = inputs[0].get(); + override function get(from: Int): Dynamic { + var vector: Vec4 = inputs[0].get(); if (vector == null) return 0.0; if (from == 0) return vector.x; diff --git a/Sources/armory/logicnode/SeparateTransformNode.hx b/Sources/armory/logicnode/SeparateTransformNode.hx index a32c6532..da0c43d4 100644 --- a/Sources/armory/logicnode/SeparateTransformNode.hx +++ b/Sources/armory/logicnode/SeparateTransformNode.hx @@ -6,12 +6,12 @@ import iron.math.Quat; class SeparateTransformNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var matrix:Mat4 = inputs[0].get(); + override function get(from: Int): Dynamic { + var matrix: Mat4 = inputs[0].get(); if (matrix == null) return null; var loc = new Vec4(); diff --git a/Sources/armory/logicnode/SeparateVectorNode.hx b/Sources/armory/logicnode/SeparateVectorNode.hx index bf7ec2ed..72276fc6 100644 --- a/Sources/armory/logicnode/SeparateVectorNode.hx +++ b/Sources/armory/logicnode/SeparateVectorNode.hx @@ -4,12 +4,12 @@ import iron.math.Vec4; class SeparateVectorNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var vector:Vec4 = inputs[0].get(); + override function get(from: Int): Dynamic { + var vector: Vec4 = inputs[0].get(); if (vector == null) return 0.0; if (from == 0) return vector.x; diff --git a/Sources/armory/logicnode/SequenceNode.hx b/Sources/armory/logicnode/SequenceNode.hx index 1e31b03b..3513f2ff 100644 --- a/Sources/armory/logicnode/SequenceNode.hx +++ b/Sources/armory/logicnode/SequenceNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class SequenceNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { for (i in 0...outputs.length) runOutput(i); } } diff --git a/Sources/armory/logicnode/SetActionSpeedNode.hx b/Sources/armory/logicnode/SetActionSpeedNode.hx index da4cb526..af34a661 100644 --- a/Sources/armory/logicnode/SetActionSpeedNode.hx +++ b/Sources/armory/logicnode/SetActionSpeedNode.hx @@ -4,14 +4,14 @@ import iron.object.Object; class SetActionSpeedNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var speed:Float = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var speed: Float = inputs[2].get(); + if (object == null) return; var animation = object.animation; if (animation == null) animation = object.getParentArmature(object.name); diff --git a/Sources/armory/logicnode/SetCameraFovNode.hx b/Sources/armory/logicnode/SetCameraFovNode.hx index 8c70c23d..0e416865 100644 --- a/Sources/armory/logicnode/SetCameraFovNode.hx +++ b/Sources/armory/logicnode/SetCameraFovNode.hx @@ -4,14 +4,14 @@ import iron.object.CameraObject; class SetCameraFovNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var camera:CameraObject = inputs[1].get(); - var fov:Float = inputs[2].get(); - + override function run(from: Int) { + var camera: CameraObject = inputs[1].get(); + var fov: Float = inputs[2].get(); + if (camera == null) return; camera.data.raw.fov = fov; diff --git a/Sources/armory/logicnode/SetCameraNode.hx b/Sources/armory/logicnode/SetCameraNode.hx index 84bc1acb..f2a183f4 100644 --- a/Sources/armory/logicnode/SetCameraNode.hx +++ b/Sources/armory/logicnode/SetCameraNode.hx @@ -1,16 +1,15 @@ package armory.logicnode; -import iron.Scene; import iron.object.CameraObject; class SetCameraNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var camera:CameraObject = inputs[1].get(); + override function run(from: Int) { + var camera: CameraObject = inputs[1].get(); if (camera == null) return; camera.buildProjection(); diff --git a/Sources/armory/logicnode/SetGravityEnabledNode.hx b/Sources/armory/logicnode/SetGravityEnabledNode.hx index b868ccf1..49a09be5 100644 --- a/Sources/armory/logicnode/SetGravityEnabledNode.hx +++ b/Sources/armory/logicnode/SetGravityEnabledNode.hx @@ -6,17 +6,17 @@ 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) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var gravityEnabled:Bool = inputs[2].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var gravityEnabled: Bool = inputs[2].get(); if (object == null) return; #if arm_physics diff --git a/Sources/armory/logicnode/SetGravityNode.hx b/Sources/armory/logicnode/SetGravityNode.hx index 66b68b2a..0b390cd8 100644 --- a/Sources/armory/logicnode/SetGravityNode.hx +++ b/Sources/armory/logicnode/SetGravityNode.hx @@ -1,20 +1,18 @@ package armory.logicnode; -import iron.object.Object; import iron.math.Vec4; -import armory.trait.physics.RigidBody; class SetGravityNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var gravity:Vec4 = inputs[1].get(); + override function run(from: Int) { + var gravity: Vec4 = inputs[1].get(); if (gravity == null) return; - + #if arm_physics var physics = armory.trait.physics.PhysicsWorld.active; physics.setGravity(gravity); diff --git a/Sources/armory/logicnode/SetHaxePropertyNode.hx b/Sources/armory/logicnode/SetHaxePropertyNode.hx index ff64c255..d8749924 100644 --- a/Sources/armory/logicnode/SetHaxePropertyNode.hx +++ b/Sources/armory/logicnode/SetHaxePropertyNode.hx @@ -2,15 +2,15 @@ package armory.logicnode; class SetHaxePropertyNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Dynamic = inputs[1].get(); - var property:String = inputs[2].get(); - var value:Dynamic = inputs[3].get(); - + override function run(from: Int) { + var object: Dynamic = inputs[1].get(); + var property: String = inputs[2].get(); + var value: Dynamic = inputs[3].get(); + if (object == null) return; Reflect.setProperty(object, property, value); diff --git a/Sources/armory/logicnode/SetLightColorNode.hx b/Sources/armory/logicnode/SetLightColorNode.hx index 1bcccaa4..220ca5f6 100644 --- a/Sources/armory/logicnode/SetLightColorNode.hx +++ b/Sources/armory/logicnode/SetLightColorNode.hx @@ -4,14 +4,14 @@ import iron.object.LightObject; class SetLightColorNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var light:LightObject = inputs[1].get(); - var color:iron.math.Vec4 = inputs[2].get(); - + override function run(from: Int) { + var light: LightObject = inputs[1].get(); + var color: iron.math.Vec4 = inputs[2].get(); + if (light == null) return; light.data.raw.color[0] = color.x; diff --git a/Sources/armory/logicnode/SetLightStrengthNode.hx b/Sources/armory/logicnode/SetLightStrengthNode.hx index ffcd6b1c..dceebf96 100644 --- a/Sources/armory/logicnode/SetLightStrengthNode.hx +++ b/Sources/armory/logicnode/SetLightStrengthNode.hx @@ -4,14 +4,14 @@ import iron.object.LightObject; class SetLightStrengthNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var light:LightObject = inputs[1].get(); - var strength:Float = inputs[2].get(); - + override function run(from: Int) { + var light: LightObject = inputs[1].get(); + var strength: Float = inputs[2].get(); + if (light == null) return; light.data.raw.strength = light.data.raw.type == "sun" ? strength * 0.325 : strength * 0.026; diff --git a/Sources/armory/logicnode/SetLocationNode.hx b/Sources/armory/logicnode/SetLocationNode.hx index 933f157a..709e457b 100644 --- a/Sources/armory/logicnode/SetLocationNode.hx +++ b/Sources/armory/logicnode/SetLocationNode.hx @@ -6,13 +6,13 @@ import armory.trait.physics.RigidBody; class SetLocationNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var vec:Vec4 = inputs[2].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var vec: Vec4 = inputs[2].get(); if (object == null || vec == null) return; diff --git a/Sources/armory/logicnode/SetMaterialImageParamNode.hx b/Sources/armory/logicnode/SetMaterialImageParamNode.hx index babc0324..abee9941 100644 --- a/Sources/armory/logicnode/SetMaterialImageParamNode.hx +++ b/Sources/armory/logicnode/SetMaterialImageParamNode.hx @@ -1,6 +1,5 @@ package armory.logicnode; -import iron.math.Vec4; import iron.data.MaterialData; import iron.object.Object; @@ -9,7 +8,7 @@ class SetMaterialImageParamNode extends LogicNode { static var registered = false; static var map = new Map>(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); if (!registered) { registered = true; @@ -17,7 +16,7 @@ class SetMaterialImageParamNode extends LogicNode { } } - override function run(from:Int) { + override function run(from: Int) { var mat = inputs[1].get(); if (mat == null) return; var entry = map.get(mat); @@ -26,13 +25,13 @@ class SetMaterialImageParamNode extends LogicNode { map.set(mat, entry); } - iron.data.Data.getImage(inputs[3].get(), function(image:kha.Image) { + iron.data.Data.getImage(inputs[3].get(), function(image: kha.Image) { entry.set(inputs[2].get(), image); // Node name, value }); runOutput(0); } - static function textureLink(object:Object, mat:MaterialData, link:String):kha.Image { + static function textureLink(object: Object, mat: MaterialData, link: String): kha.Image { if (mat == null) return null; var entry = map.get(mat); if (entry == null) return null; diff --git a/Sources/armory/logicnode/SetMaterialNode.hx b/Sources/armory/logicnode/SetMaterialNode.hx index 20e1e96b..09f89960 100644 --- a/Sources/armory/logicnode/SetMaterialNode.hx +++ b/Sources/armory/logicnode/SetMaterialNode.hx @@ -5,14 +5,14 @@ import iron.data.MaterialData; class SetMaterialNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:MeshObject = inputs[1].get(); - var mat:MaterialData = inputs[2].get(); - + override function run(from: Int) { + var object: MeshObject = inputs[1].get(); + var mat: MaterialData = inputs[2].get(); + if (object == null) return; for (i in 0...object.materials.length) { diff --git a/Sources/armory/logicnode/SetMaterialRgbParamNode.hx b/Sources/armory/logicnode/SetMaterialRgbParamNode.hx index 0e875b6f..2db7bbc9 100644 --- a/Sources/armory/logicnode/SetMaterialRgbParamNode.hx +++ b/Sources/armory/logicnode/SetMaterialRgbParamNode.hx @@ -9,7 +9,7 @@ class SetMaterialRgbParamNode extends LogicNode { static var registered = false; static var map = new Map>(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); if (!registered) { registered = true; @@ -17,7 +17,7 @@ class SetMaterialRgbParamNode extends LogicNode { } } - override function run(from:Int) { + override function run(from: Int) { var mat = inputs[1].get(); if (mat == null) return; var entry = map.get(mat); @@ -29,7 +29,7 @@ class SetMaterialRgbParamNode extends LogicNode { runOutput(0); } - static function vec3Link(object:Object, mat:MaterialData, link:String):iron.math.Vec4 { + static function vec3Link(object: Object, mat: MaterialData, link: String): iron.math.Vec4 { if (mat == null) return null; var entry = map.get(mat); if (entry == null) return null; diff --git a/Sources/armory/logicnode/SetMaterialSlotNode.hx b/Sources/armory/logicnode/SetMaterialSlotNode.hx index ab8ab086..336389d5 100644 --- a/Sources/armory/logicnode/SetMaterialSlotNode.hx +++ b/Sources/armory/logicnode/SetMaterialSlotNode.hx @@ -5,15 +5,15 @@ import iron.data.MaterialData; class SetMaterialSlotNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:MeshObject = inputs[1].get(); - var mat:MaterialData = inputs[2].get(); - var slot:Int = inputs[3].get(); - + override function run(from: Int) { + var object: MeshObject = inputs[1].get(); + var mat: MaterialData = inputs[2].get(); + var slot: Int = inputs[3].get(); + if (object == null) return; if (slot >= object.materials.length) return; diff --git a/Sources/armory/logicnode/SetMaterialValueParamNode.hx b/Sources/armory/logicnode/SetMaterialValueParamNode.hx index e3518da0..40729a64 100644 --- a/Sources/armory/logicnode/SetMaterialValueParamNode.hx +++ b/Sources/armory/logicnode/SetMaterialValueParamNode.hx @@ -1,6 +1,5 @@ package armory.logicnode; -import iron.math.Vec4; import iron.data.MaterialData; import iron.object.Object; @@ -9,7 +8,7 @@ class SetMaterialValueParamNode extends LogicNode { static var registered = false; static var map = new Map>>(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); if (!registered) { registered = true; @@ -17,7 +16,7 @@ class SetMaterialValueParamNode extends LogicNode { } } - override function run(from:Int) { + override function run(from: Int) { var mat = inputs[1].get(); if (mat == null) return; var entry = map.get(mat); @@ -29,7 +28,7 @@ class SetMaterialValueParamNode extends LogicNode { runOutput(0); } - static function floatLink(object:Object, mat:MaterialData, link:String):Null { + static function floatLink(object: Object, mat: MaterialData, link: String): Null { if (mat == null) return null; var entry = map.get(mat); if (entry == null) return null; diff --git a/Sources/armory/logicnode/SetMeshNode.hx b/Sources/armory/logicnode/SetMeshNode.hx index bdc61510..71a70d6e 100644 --- a/Sources/armory/logicnode/SetMeshNode.hx +++ b/Sources/armory/logicnode/SetMeshNode.hx @@ -5,14 +5,14 @@ import iron.data.MeshData; class SetMeshNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:MeshObject = inputs[1].get(); - var mesh:MeshData = inputs[2].get(); - + override function run(from: Int) { + var object: MeshObject = inputs[1].get(); + var mesh: MeshData = inputs[2].get(); + if (object == null) return; object.data = mesh; diff --git a/Sources/armory/logicnode/SetMouseLockNode.hx b/Sources/armory/logicnode/SetMouseLockNode.hx index 5466d6b3..cc999a2b 100644 --- a/Sources/armory/logicnode/SetMouseLockNode.hx +++ b/Sources/armory/logicnode/SetMouseLockNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class SetMouseLockNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var lock:Bool = inputs[1].get(); + override function run(from: Int) { + var lock: Bool = inputs[1].get(); var mouse = iron.system.Input.getMouse(); lock ? mouse.lock() : mouse.unlock(); runOutput(0); diff --git a/Sources/armory/logicnode/SetNameNode.hx b/Sources/armory/logicnode/SetNameNode.hx index 09fa85b5..630baa7a 100644 --- a/Sources/armory/logicnode/SetNameNode.hx +++ b/Sources/armory/logicnode/SetNameNode.hx @@ -4,14 +4,14 @@ import iron.object.Object; class SetNameNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var name:String = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var name: String = inputs[2].get(); + if (object == null) return; object.name = name; diff --git a/Sources/armory/logicnode/SetParentBoneNode.hx b/Sources/armory/logicnode/SetParentBoneNode.hx index 6a05f962..200fade0 100644 --- a/Sources/armory/logicnode/SetParentBoneNode.hx +++ b/Sources/armory/logicnode/SetParentBoneNode.hx @@ -4,17 +4,17 @@ import iron.object.Object; class SetParentBoneNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { #if arm_skin - var object:Object = inputs[1].get(); - var parent:Object = inputs[2].get(); - var bone:String = inputs[3].get(); - + var object: Object = inputs[1].get(); + var parent: Object = inputs[2].get(); + var bone: String = inputs[3].get(); + if (object == null || parent == null) return; if (object.parent != parent) { diff --git a/Sources/armory/logicnode/SetParentNode.hx b/Sources/armory/logicnode/SetParentNode.hx index 8170a8f5..1a229088 100644 --- a/Sources/armory/logicnode/SetParentNode.hx +++ b/Sources/armory/logicnode/SetParentNode.hx @@ -4,14 +4,14 @@ import iron.object.Object; class SetParentNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); - var parent:Object; + var parent: Object; var isUnparent = false; if (Std.is(inputs[2].node, ObjectNode)) { var parentNode = cast(inputs[2].node, ObjectNode); @@ -19,7 +19,7 @@ class SetParentNode extends LogicNode { } if (isUnparent) parent = iron.Scene.active.root; else parent = inputs[2].get(); - + if (object == null || parent == null || object.parent == parent) return; object.parent.removeChild(object, isUnparent); // keepTransform diff --git a/Sources/armory/logicnode/SetParticleSpeedNode.hx b/Sources/armory/logicnode/SetParticleSpeedNode.hx index f1f3eca7..7a9238b5 100644 --- a/Sources/armory/logicnode/SetParticleSpeedNode.hx +++ b/Sources/armory/logicnode/SetParticleSpeedNode.hx @@ -4,15 +4,15 @@ import iron.object.Object; class SetParticleSpeedNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { #if arm_particles - var object:Object = inputs[1].get(); - var speed:Float = inputs[2].get(); - + var object: Object = inputs[1].get(); + var speed: Float = inputs[2].get(); + if (object == null) return; var mo = cast(object, iron.object.MeshObject); diff --git a/Sources/armory/logicnode/SetPropertyNode.hx b/Sources/armory/logicnode/SetPropertyNode.hx index 380e2f12..0ab25e19 100644 --- a/Sources/armory/logicnode/SetPropertyNode.hx +++ b/Sources/armory/logicnode/SetPropertyNode.hx @@ -4,15 +4,15 @@ import iron.object.Object; class SetPropertyNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var property:String = inputs[2].get(); - var value:Dynamic = inputs[3].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var property: String = inputs[2].get(); + var value: Dynamic = inputs[3].get(); + if (object == null) return; if (object.properties == null) object.properties = new Map(); object.properties.set(property, value); diff --git a/Sources/armory/logicnode/SetRotationNode.hx b/Sources/armory/logicnode/SetRotationNode.hx index 4d94916e..dbc1eeee 100644 --- a/Sources/armory/logicnode/SetRotationNode.hx +++ b/Sources/armory/logicnode/SetRotationNode.hx @@ -6,23 +6,25 @@ import iron.math.Vec3; import armory.trait.physics.RigidBody; class SetRotationNode extends LogicNode { - public var property0:String; - public function new(tree:LogicTree) { + public var property0: String; + + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - if (object == null) + override function run(from: Int) { + var object: Object = inputs[1].get(); + if (object == null) { return; - var vec:Vec3 = inputs[2].get(); - var w:Float = inputs[3].get(); + } + var vec: Vec3 = inputs[2].get(); + var w: Float = inputs[3].get(); switch (property0) { case "Euler Angles": object.transform.rot.fromEuler(vec.x, vec.y, vec.z); case "Angle Axies (Degrees)" | "Angle Axies (Radians)": - var angle:Float = w; + var angle: Float = w; if (property0 == "Angle Axies (Degrees)") { angle = angle * (Math.PI / 180); } @@ -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); } diff --git a/Sources/armory/logicnode/SetScaleNode.hx b/Sources/armory/logicnode/SetScaleNode.hx index c29f0559..48f8bc6e 100644 --- a/Sources/armory/logicnode/SetScaleNode.hx +++ b/Sources/armory/logicnode/SetScaleNode.hx @@ -6,13 +6,13 @@ import armory.trait.physics.RigidBody; class SetScaleNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var vec:Vec4 = inputs[2].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var vec: Vec4 = inputs[2].get(); if (object == null || vec == null) return; diff --git a/Sources/armory/logicnode/SetSceneNode.hx b/Sources/armory/logicnode/SetSceneNode.hx index f4a10823..3c9a3d27 100644 --- a/Sources/armory/logicnode/SetSceneNode.hx +++ b/Sources/armory/logicnode/SetSceneNode.hx @@ -4,22 +4,22 @@ import iron.object.Object; class SetSceneNode extends LogicNode { - var root:Object; + var root: Object; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var sceneName:String = inputs[1].get(); + override function run(from: Int) { + var sceneName: String = inputs[1].get(); - iron.Scene.setActive(sceneName, function(o:iron.object.Object) { + iron.Scene.setActive(sceneName, function(o: iron.object.Object) { root = o; runOutput(0); }); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return root; } } diff --git a/Sources/armory/logicnode/SetTimeScaleNode.hx b/Sources/armory/logicnode/SetTimeScaleNode.hx index 73f94cee..f9ef4943 100644 --- a/Sources/armory/logicnode/SetTimeScaleNode.hx +++ b/Sources/armory/logicnode/SetTimeScaleNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class SetTimeScaleNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var f:Float = inputs[1].get(); + override function run(from: Int) { + var f: Float = inputs[1].get(); iron.system.Time.scale = f; runOutput(0); } diff --git a/Sources/armory/logicnode/SetTransformNode.hx b/Sources/armory/logicnode/SetTransformNode.hx index c77c0fde..38646693 100755 --- a/Sources/armory/logicnode/SetTransformNode.hx +++ b/Sources/armory/logicnode/SetTransformNode.hx @@ -6,13 +6,13 @@ import armory.trait.physics.RigidBody; class SetTransformNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var matrix:Mat4 = inputs[2].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var matrix: Mat4 = inputs[2].get(); if (object == null || matrix == null) return; diff --git a/Sources/armory/logicnode/SetVariableNode.hx b/Sources/armory/logicnode/SetVariableNode.hx index 2c648872..8a315d5e 100644 --- a/Sources/armory/logicnode/SetVariableNode.hx +++ b/Sources/armory/logicnode/SetVariableNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class SetVariableNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { var variable = inputs[1]; - var value:Dynamic = inputs[2].get(); + var value: Dynamic = inputs[2].get(); variable.set(value); diff --git a/Sources/armory/logicnode/SetVelocityNode.hx b/Sources/armory/logicnode/SetVelocityNode.hx index f27bbeb0..d4ebf60a 100644 --- a/Sources/armory/logicnode/SetVelocityNode.hx +++ b/Sources/armory/logicnode/SetVelocityNode.hx @@ -6,21 +6,21 @@ import armory.trait.physics.RigidBody; class SetVelocityNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var linear:Vec4 = inputs[2].get(); - var linearFactor:Vec4 = inputs[3].get(); - var angular:Vec4 = inputs[4].get(); - var angularFactor:Vec4 = inputs[5].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var linear: Vec4 = inputs[2].get(); + var linearFactor: Vec4 = inputs[3].get(); + var angular: Vec4 = inputs[4].get(); + var angularFactor: Vec4 = inputs[5].get(); + if (object == null || linear == null || linearFactor == null || angular == null || angularFactor == null) return; #if arm_physics - var rb:RigidBody = object.getTrait(RigidBody); + var rb: RigidBody = object.getTrait(RigidBody); rb.activate(); rb.setLinearVelocity(linear.x, linear.y, linear.z); rb.setLinearFactor(linearFactor.x, linearFactor.y, linearFactor.z); diff --git a/Sources/armory/logicnode/SetVisibleNode.hx b/Sources/armory/logicnode/SetVisibleNode.hx index 9b6bb5be..5b861af0 100755 --- a/Sources/armory/logicnode/SetVisibleNode.hx +++ b/Sources/armory/logicnode/SetVisibleNode.hx @@ -4,14 +4,14 @@ import iron.object.Object; class SetVisibleNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var visible:Bool = inputs[2].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + var visible: Bool = inputs[2].get(); + if (object == null) return; object.visible = visible; diff --git a/Sources/armory/logicnode/ShowMouseNode.hx b/Sources/armory/logicnode/ShowMouseNode.hx index 7acc6135..be6727a1 100644 --- a/Sources/armory/logicnode/ShowMouseNode.hx +++ b/Sources/armory/logicnode/ShowMouseNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class ShowMouseNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var show:Bool = inputs[1].get(); + override function run(from: Int) { + var show: Bool = inputs[1].get(); var mouse = iron.system.Input.getMouse(); show ? mouse.show() : mouse.hide(); runOutput(0); diff --git a/Sources/armory/logicnode/ShutdownNode.hx b/Sources/armory/logicnode/ShutdownNode.hx index f7d37c84..4f6f0e3a 100644 --- a/Sources/armory/logicnode/ShutdownNode.hx +++ b/Sources/armory/logicnode/ShutdownNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class ShutdownNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { kha.System.stop(); } } diff --git a/Sources/armory/logicnode/SleepNode.hx b/Sources/armory/logicnode/SleepNode.hx index 0ae330a3..2c451236 100644 --- a/Sources/armory/logicnode/SleepNode.hx +++ b/Sources/armory/logicnode/SleepNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class SleepNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var time:Float = inputs[1].get(); + override function run(from: Int) { + var time: Float = inputs[1].get(); iron.system.Tween.timer(time, done); } diff --git a/Sources/armory/logicnode/SpawnObjectNode.hx b/Sources/armory/logicnode/SpawnObjectNode.hx index 59af5441..d4798152 100644 --- a/Sources/armory/logicnode/SpawnObjectNode.hx +++ b/Sources/armory/logicnode/SpawnObjectNode.hx @@ -6,25 +6,25 @@ import armory.trait.physics.RigidBody; class SpawnObjectNode extends LogicNode { - var object:Object; - var matrices:Array = []; + var object: Object; + var matrices: Array = []; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { var objectName = ""; var objectInput = inputs[1].get(); if (objectInput == null) objectName = cast(inputs[1].node, ObjectNode).objectName; else objectName = objectInput.name; if (objectName == "") objectName = tree.object.name; - var m:Mat4 = inputs[2].get(); + var m: Mat4 = inputs[2].get(); matrices.push(m != null ? m.clone() : null); - var spawnChildren:Bool = inputs.length > 3 ? inputs[3].get() : true; // TODO + var spawnChildren: Bool = inputs.length > 3 ? inputs[3].get() : true; // TODO - iron.Scene.active.spawnObject(objectName, null, function(o:Object) { + iron.Scene.active.spawnObject(objectName, null, function(o: Object) { object = o; var matrix = matrices.pop(); // Async spawn in a loop, order is non-stable if (matrix != null) { @@ -42,7 +42,7 @@ class SpawnObjectNode extends LogicNode { }, spawnChildren); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return object; } } diff --git a/Sources/armory/logicnode/SpawnSceneNode.hx b/Sources/armory/logicnode/SpawnSceneNode.hx index 30bd1947..3f158c92 100644 --- a/Sources/armory/logicnode/SpawnSceneNode.hx +++ b/Sources/armory/logicnode/SpawnSceneNode.hx @@ -5,16 +5,16 @@ import iron.math.Mat4; class SpawnSceneNode extends LogicNode { - var root:Object; + var root: Object; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { - var sceneName:String = inputs[1].get(); - var matrix:Mat4 = inputs[2].get(); + var sceneName: String = inputs[1].get(); + var matrix: Mat4 = inputs[2].get(); root = iron.Scene.active.addObject(); root.name = sceneName; @@ -23,12 +23,12 @@ class SpawnSceneNode extends LogicNode { root.transform.buildMatrix(); } - iron.Scene.active.addScene(sceneName, root, function(o:Object) { + iron.Scene.active.addScene(sceneName, root, function(o: Object) { runOutput(0); }); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { return root; } } diff --git a/Sources/armory/logicnode/SplitStringNode.hx b/Sources/armory/logicnode/SplitStringNode.hx index 65a78178..5d56cf85 100644 --- a/Sources/armory/logicnode/SplitStringNode.hx +++ b/Sources/armory/logicnode/SplitStringNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class SplitStringNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var s1:String = inputs[0].get(); - var s2:String = inputs[1].get(); + override function get(from: Int): Dynamic { + var s1: String = inputs[0].get(); + var s2: String = inputs[1].get(); if (s1 == null || s2 == null) return null; return s1.split(s2); diff --git a/Sources/armory/logicnode/StopAgentNode.hx b/Sources/armory/logicnode/StopAgentNode.hx index a145d564..5c319e60 100644 --- a/Sources/armory/logicnode/StopAgentNode.hx +++ b/Sources/armory/logicnode/StopAgentNode.hx @@ -1,22 +1,20 @@ package armory.logicnode; -import armory.trait.navigation.Navigation; import iron.object.Object; -import iron.math.Vec4; class StopAgentNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - + override function run(from: Int) { + var object: Object = inputs[1].get(); + if (object == null) return; #if arm_navigation - var agent:armory.trait.NavAgent = object.getTrait(armory.trait.NavAgent); + var agent: armory.trait.NavAgent = object.getTrait(armory.trait.NavAgent); agent.stop(); #end diff --git a/Sources/armory/logicnode/StopSoundNode.hx b/Sources/armory/logicnode/StopSoundNode.hx index 899edfc5..bfbfafdb 100644 --- a/Sources/armory/logicnode/StopSoundNode.hx +++ b/Sources/armory/logicnode/StopSoundNode.hx @@ -4,12 +4,12 @@ import iron.object.SpeakerObject; class StopSoundNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:SpeakerObject = cast(inputs[1].get(), SpeakerObject); + override function run(from: Int) { + var object: SpeakerObject = cast(inputs[1].get(), SpeakerObject); if (object == null) return; object.stop(); runOutput(0); diff --git a/Sources/armory/logicnode/StringNode.hx b/Sources/armory/logicnode/StringNode.hx index 35dba232..eaa8493c 100644 --- a/Sources/armory/logicnode/StringNode.hx +++ b/Sources/armory/logicnode/StringNode.hx @@ -2,19 +2,19 @@ package armory.logicnode; class StringNode extends LogicNode { - public var value:String; + public var value: String; - public function new(tree:LogicTree, value = "") { + public function new(tree: LogicTree, value = "") { super(tree); this.value = value; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (inputs.length > 0) return inputs[0].get(); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { if (inputs.length > 0) inputs[0].set(value); else this.value = value; } diff --git a/Sources/armory/logicnode/SubStringNode.hx b/Sources/armory/logicnode/SubStringNode.hx index 75e29106..84172426 100644 --- a/Sources/armory/logicnode/SubStringNode.hx +++ b/Sources/armory/logicnode/SubStringNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class SubStringNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var string:String = inputs[0].get(); - var start:Int = inputs[1].get(); - var end:Int = inputs[2].get(); + override function get(from: Int): Dynamic { + var string: String = inputs[0].get(); + var start: Int = inputs[1].get(); + var end: Int = inputs[2].get(); if (start == null || end == null || string == null) return null; return string.substring(start, end); diff --git a/Sources/armory/logicnode/SurfaceCoordsNode.hx b/Sources/armory/logicnode/SurfaceCoordsNode.hx index 25c22a7a..d3c53d62 100644 --- a/Sources/armory/logicnode/SurfaceCoordsNode.hx +++ b/Sources/armory/logicnode/SurfaceCoordsNode.hx @@ -6,11 +6,11 @@ class SurfaceCoordsNode extends LogicNode { var coords = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { var surface = iron.system.Input.getSurface(); if (from == 0) { coords.x = surface.x; diff --git a/Sources/armory/logicnode/SwitchNode.hx b/Sources/armory/logicnode/SwitchNode.hx index ff1850ed..5cad169e 100644 --- a/Sources/armory/logicnode/SwitchNode.hx +++ b/Sources/armory/logicnode/SwitchNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class SwitchNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var v1:Dynamic = inputs[1].get(); + override function run(from: Int) { + var v1: Dynamic = inputs[1].get(); if (inputs.length > 2) { - for(i in 2...inputs.length) { + for (i in 2...inputs.length) { if (inputs[i].get() == v1) { runOutput(i - 1); return; diff --git a/Sources/armory/logicnode/TimeNode.hx b/Sources/armory/logicnode/TimeNode.hx index da74493a..f5fec03d 100755 --- a/Sources/armory/logicnode/TimeNode.hx +++ b/Sources/armory/logicnode/TimeNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class TimeNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 0) return iron.system.Time.time(); else return iron.system.Time.delta; } diff --git a/Sources/armory/logicnode/TimerNode.hx b/Sources/armory/logicnode/TimerNode.hx index 08f612d8..779f6ecf 100644 --- a/Sources/armory/logicnode/TimerNode.hx +++ b/Sources/armory/logicnode/TimerNode.hx @@ -8,7 +8,7 @@ class TimerNode extends LogicNode { var running = false; var repetitions = 0; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -29,8 +29,8 @@ class TimerNode extends LogicNode { } } } - - override function run(from:Int) { + + override function run(from: Int) { if (from == 0) { // Start duration = inputs[3].get(); repeat = inputs[4].get(); @@ -56,7 +56,7 @@ class TimerNode extends LogicNode { } } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 2) return running; else if (from == 3) return time; else if (from == 4) return duration - time; diff --git a/Sources/armory/logicnode/ToBoolNode.hx b/Sources/armory/logicnode/ToBoolNode.hx index 7a07309a..d156ed95 100644 --- a/Sources/armory/logicnode/ToBoolNode.hx +++ b/Sources/armory/logicnode/ToBoolNode.hx @@ -2,18 +2,18 @@ package armory.logicnode; class ToBoolNode extends LogicNode { - var value:Bool; + var value: Bool; var b = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { b = true; } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { value = b; b = false; return value; diff --git a/Sources/armory/logicnode/TraitNode.hx b/Sources/armory/logicnode/TraitNode.hx index 038f4f2c..f5b29a63 100644 --- a/Sources/armory/logicnode/TraitNode.hx +++ b/Sources/armory/logicnode/TraitNode.hx @@ -2,23 +2,23 @@ package armory.logicnode; class TraitNode extends LogicNode { - public var property0:String; - public var value:Dynamic = null; + public var property0: String; + public var value: Dynamic = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (value != null) return value; - + var cname = Type.resolveClass(Main.projectPackage + "." + property0); if (cname == null) cname = Type.resolveClass(Main.projectPackage + ".node." + property0); value = Type.createInstance(cname, []); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { this.value = value; } } diff --git a/Sources/armory/logicnode/TransformMathNode.hx b/Sources/armory/logicnode/TransformMathNode.hx index 1ee084f8..4f727cf5 100644 --- a/Sources/armory/logicnode/TransformMathNode.hx +++ b/Sources/armory/logicnode/TransformMathNode.hx @@ -4,16 +4,16 @@ import iron.math.Mat4; class TransformMathNode extends LogicNode { - public var property0:String; + public var property0: String; var m = Mat4.identity(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var m1:Mat4 = inputs[0].get(); - var m2:Mat4 = inputs[1].get(); + override function get(from: Int): Dynamic { + var m1: Mat4 = inputs[0].get(); + var m2: Mat4 = inputs[1].get(); if (m1 == null || m2 == null) return null; @@ -23,7 +23,7 @@ class TransformMathNode extends LogicNode { return m; } - public static function transformMath(m1:Mat4, m2:Mat4) { + public static function transformMath(m1: Mat4, m2: Mat4) { var a00 = m1._00; var a01 = m1._01; var a02 = m1._02; var a10 = m1._10; var a11 = m1._11; var a12 = m1._12; var a20 = m1._20; var a21 = m1._21; var a22 = m1._22; diff --git a/Sources/armory/logicnode/TransformNode.hx b/Sources/armory/logicnode/TransformNode.hx index b01f258c..148309b2 100644 --- a/Sources/armory/logicnode/TransformNode.hx +++ b/Sources/armory/logicnode/TransformNode.hx @@ -6,26 +6,26 @@ import iron.math.Quat; class TransformNode extends LogicNode { - var value:Mat4 = Mat4.identity(); + var value: Mat4 = Mat4.identity(); static var q = new Quat(); static var v1 = new Vec4(); static var v2 = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var loc:Vec4 = inputs[0].get(); - var rot:Vec4 = inputs[1].get(); - var scale:Vec4 = inputs[2].get(); + override function get(from: Int): Dynamic { + var loc: Vec4 = inputs[0].get(); + var rot: Vec4 = inputs[1].get(); + var scale: Vec4 = inputs[2].get(); if (loc == null || rot == null || scale == null) return null; q.fromEuler(rot.x, rot.y, rot.z); value.compose(loc, q, scale); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { cast(value, Mat4).decompose(v1, q, v2); inputs[0].set(v1); inputs[1].set(q.getEuler()); diff --git a/Sources/armory/logicnode/TranslateObjectNode.hx b/Sources/armory/logicnode/TranslateObjectNode.hx index dce3af73..d5d8c576 100644 --- a/Sources/armory/logicnode/TranslateObjectNode.hx +++ b/Sources/armory/logicnode/TranslateObjectNode.hx @@ -1,24 +1,23 @@ package armory.logicnode; import iron.object.Object; -import iron.math.Mat4; import iron.math.Vec4; import armory.trait.physics.RigidBody; class TranslateObjectNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var vec:Vec4 = inputs[2].get(); - var local:Bool = inputs.length > 3 ? inputs[3].get() : false; + override function run(from: Int) { + var object: Object = inputs[1].get(); + var vec: Vec4 = inputs[2].get(); + var local: Bool = inputs.length > 3 ? inputs[3].get() : false; if (object == null || vec == null) return; - if(!local) { + if (!local) { object.transform.loc.add(vec); object.transform.buildMatrix(); } @@ -31,7 +30,7 @@ class TranslateObjectNode extends LogicNode { object.transform.loc.add(up); object.transform.buildMatrix(); } - + #if arm_physics var rigidBody = object.getTrait(RigidBody); if (rigidBody != null) rigidBody.syncTransform(); diff --git a/Sources/armory/logicnode/TranslateOnLocalAxisNode.hx b/Sources/armory/logicnode/TranslateOnLocalAxisNode.hx index 5e4469a6..2182affb 100644 --- a/Sources/armory/logicnode/TranslateOnLocalAxisNode.hx +++ b/Sources/armory/logicnode/TranslateOnLocalAxisNode.hx @@ -9,36 +9,35 @@ class TranslateOnLocalAxisNode extends LogicNode { var loc = new Vec4(); var vec = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var object:Object = inputs[1].get(); - var sp:Float = inputs[2].get(); - var l:Int = inputs[3].get(); - var ini:Bool = inputs[4].get(); + override function run(from: Int) { + var object: Object = inputs[1].get(); + var sp: Float = inputs[2].get(); + var l: Int = inputs[3].get(); + var ini: Bool = inputs[4].get(); if (object == null) return; if (l == 1) loc.setFrom(object.transform.world.look()); 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; loc.z = -loc.z; } - + vec.x = loc.x * sp; vec.y = loc.y * sp; vec.z = loc.z * sp; - + object.transform.loc.add(vec); object.transform.buildMatrix(); - + #if arm_physics var rigidBody = object.getTrait(RigidBody); if (rigidBody != null) rigidBody.syncTransform(); diff --git a/Sources/armory/logicnode/VectorClampToSizeNode.hx b/Sources/armory/logicnode/VectorClampToSizeNode.hx index 23b3e1a9..31a8f63d 100644 --- a/Sources/armory/logicnode/VectorClampToSizeNode.hx +++ b/Sources/armory/logicnode/VectorClampToSizeNode.hx @@ -6,17 +6,17 @@ class VectorClampToSizeNode extends LogicNode { var v = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { v = inputs[0].get(); - var fmin:kha.FastFloat = inputs[1].get(); - var fmax:kha.FastFloat = inputs[2].get(); + var fmin: kha.FastFloat = inputs[1].get(); + var fmax: kha.FastFloat = inputs[2].get(); v.clamp(fmin, fmax); - + return v; } } diff --git a/Sources/armory/logicnode/VectorFromTransformNode.hx b/Sources/armory/logicnode/VectorFromTransformNode.hx index c77b5838..939f05af 100644 --- a/Sources/armory/logicnode/VectorFromTransformNode.hx +++ b/Sources/armory/logicnode/VectorFromTransformNode.hx @@ -5,14 +5,14 @@ import iron.math.Mat4; class VectorFromTransformNode extends LogicNode { - public var property0:String; + public var property0: String; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var m:Mat4 = inputs[0].get(); + override function get(from: Int): Dynamic { + var m: Mat4 = inputs[0].get(); if (m == null) return null; diff --git a/Sources/armory/logicnode/VectorMathNode.hx b/Sources/armory/logicnode/VectorMathNode.hx index 61b2566e..c19880a7 100644 --- a/Sources/armory/logicnode/VectorMathNode.hx +++ b/Sources/armory/logicnode/VectorMathNode.hx @@ -4,16 +4,16 @@ import iron.math.Vec4; class VectorMathNode extends LogicNode { - public var property0:String; + public var property0: String; var v = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var v1:Vec4 = inputs[0].get(); - var v2:Vec4 = inputs[1].get(); + override function get(from: Int): Dynamic { + var v1: Vec4 = inputs[0].get(); + var v2: Vec4 = inputs[1].get(); if (v1 == null || v2 == null) return null; v.setFrom(v1); var f = 0.0; diff --git a/Sources/armory/logicnode/VectorMixNode.hx b/Sources/armory/logicnode/VectorMixNode.hx index 66fc1d37..a7d6f73c 100644 --- a/Sources/armory/logicnode/VectorMixNode.hx +++ b/Sources/armory/logicnode/VectorMixNode.hx @@ -5,15 +5,15 @@ import iron.math.Vec4; class VectorMixNode extends LogicNode { - public var property0:String; // Type - public var property1:String; // Ease - public var property2:String; // Clamp + public var property0: String; // Type + public var property1: String; // Ease + public var property2: String; // Clamp var v = new Vec4(); - var ease:Float->Float = null; + var ease: Float->Float = null; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } @@ -42,18 +42,18 @@ class VectorMixNode extends LogicNode { } } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (ease == null) init(); - var k:Float = inputs[0].get(); //Factor - var v1:Vec4 = inputs[1].get(); - var v2:Vec4 = inputs[2].get(); + var k: Float = inputs[0].get(); //Factor + var v1: Vec4 = inputs[1].get(); + var v2: Vec4 = inputs[2].get(); if (v1 == null || v2 == null) return null; var f = ease(k); v.x = v1.x + (v2.x - v1.x) * f; v.y = v1.y + (v2.y - v1.y) * f; v.z = v1.z + (v2.z - v1.z) * f; - if (property2 == "true") v.clamp(0,1); + if (property2 == "true") v.clamp(0, 1); return v; } } diff --git a/Sources/armory/logicnode/VectorNode.hx b/Sources/armory/logicnode/VectorNode.hx index 2b2b178a..7e0c11ab 100644 --- a/Sources/armory/logicnode/VectorNode.hx +++ b/Sources/armory/logicnode/VectorNode.hx @@ -6,7 +6,7 @@ class VectorNode extends LogicNode { var value = new Vec4(); - public function new(tree:LogicTree, x:Null = null, y:Null = null, z:Null = null) { + public function new(tree: LogicTree, x: Null = null, y: Null = null, z: Null = null) { super(tree); if (x != null) { @@ -16,14 +16,14 @@ class VectorNode extends LogicNode { } } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { value.x = inputs[0].get(); value.y = inputs[1].get(); value.z = inputs[2].get(); return value; } - override function set(value:Dynamic) { + override function set(value: Dynamic) { inputs[0].set(value.x); inputs[1].set(value.y); inputs[2].set(value.z); diff --git a/Sources/armory/logicnode/VolumeTriggerNode.hx b/Sources/armory/logicnode/VolumeTriggerNode.hx index 750d2d1b..83d74055 100644 --- a/Sources/armory/logicnode/VolumeTriggerNode.hx +++ b/Sources/armory/logicnode/VolumeTriggerNode.hx @@ -1,20 +1,19 @@ package armory.logicnode; import iron.object.Object; -import iron.math.Vec4; class VolumeTriggerNode extends LogicNode { - public var property0:String; + public var property0: String; var lastOverlap = false; - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int) { - var object:Object = inputs[0].get(); - var volume:Object = inputs[1].get(); + override function get(from: Int): Dynamic { + var object: Object = inputs[0].get(); + var volume: Object = inputs[1].get(); if (object == null) return false; if (volume == null) volume = tree.object; diff --git a/Sources/armory/logicnode/WhileNode.hx b/Sources/armory/logicnode/WhileNode.hx index 9dab2ead..0d348960 100644 --- a/Sources/armory/logicnode/WhileNode.hx +++ b/Sources/armory/logicnode/WhileNode.hx @@ -2,12 +2,12 @@ package armory.logicnode; class WhileNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var b:Bool = inputs[1].get(); + override function run(from: Int) { + var b: Bool = inputs[1].get(); while (b) { runOutput(0); b = inputs[1].get(); diff --git a/Sources/armory/logicnode/WindowInfoNode.hx b/Sources/armory/logicnode/WindowInfoNode.hx index b480e669..661efead 100644 --- a/Sources/armory/logicnode/WindowInfoNode.hx +++ b/Sources/armory/logicnode/WindowInfoNode.hx @@ -2,11 +2,11 @@ package armory.logicnode; class WindowInfoNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { + override function get(from: Int): Dynamic { if (from == 0) return kha.System.windowWidth(); else return kha.System.windowHeight(); } diff --git a/Sources/armory/logicnode/WorldToScreenSpaceNode.hx b/Sources/armory/logicnode/WorldToScreenSpaceNode.hx index b58f3942..54df6a2f 100644 --- a/Sources/armory/logicnode/WorldToScreenSpaceNode.hx +++ b/Sources/armory/logicnode/WorldToScreenSpaceNode.hx @@ -4,15 +4,15 @@ import iron.math.Vec4; class WorldToScreenSpaceNode extends LogicNode { - public var property0:String; + public var property0: String; var v = new Vec4(); - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function get(from:Int):Dynamic { - var v1:Vec4 = inputs[0].get(); + override function get(from: Int): Dynamic { + var v1: Vec4 = inputs[0].get(); if (v1 == null) return null; var cam = iron.Scene.active.camera; diff --git a/Sources/armory/logicnode/WriteFileNode.hx b/Sources/armory/logicnode/WriteFileNode.hx index 1866685c..2fe87a16 100644 --- a/Sources/armory/logicnode/WriteFileNode.hx +++ b/Sources/armory/logicnode/WriteFileNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class WriteFileNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { // Relative or absolute path to file - var file:String = inputs[1].get(); - var data:String = inputs[2].get(); + var file: String = inputs[1].get(); + var data: String = inputs[2].get(); #if kha_krom var path = Krom.getFilesLocation() + "/" + file; diff --git a/Sources/armory/logicnode/WriteJsonNode.hx b/Sources/armory/logicnode/WriteJsonNode.hx index b122d070..8bd70c66 100644 --- a/Sources/armory/logicnode/WriteJsonNode.hx +++ b/Sources/armory/logicnode/WriteJsonNode.hx @@ -2,14 +2,14 @@ package armory.logicnode; class WriteJsonNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { + override function run(from: Int) { // Relative or absolute path to file - var file:String = inputs[1].get(); - var data:Dynamic = inputs[2].get(); + var file: String = inputs[1].get(); + var data: Dynamic = inputs[2].get(); var s = haxe.Json.stringify(data); trace(s); diff --git a/Sources/armory/logicnode/WriteStorageNode.hx b/Sources/armory/logicnode/WriteStorageNode.hx index 08e0ddd2..dccaa435 100644 --- a/Sources/armory/logicnode/WriteStorageNode.hx +++ b/Sources/armory/logicnode/WriteStorageNode.hx @@ -2,13 +2,13 @@ package armory.logicnode; class WriteStorageNode extends LogicNode { - public function new(tree:LogicTree) { + public function new(tree: LogicTree) { super(tree); } - override function run(from:Int) { - var key:String = inputs[1].get(); - var value:Dynamic = inputs[2].get(); + override function run(from: Int) { + var key: String = inputs[1].get(); + var value: Dynamic = inputs[2].get(); var data = iron.system.Storage.data; if (data == null) return; diff --git a/Sources/armory/object/Uniforms.hx b/Sources/armory/object/Uniforms.hx index 70a3857b..6c4b9e07 100644 --- a/Sources/armory/object/Uniforms.hx +++ b/Sources/armory/object/Uniforms.hx @@ -14,7 +14,7 @@ class Uniforms { iron.object.Uniforms.externalFloatLinks = [floatLink]; } - public static function textureLink(object:Object, mat:MaterialData, link:String):kha.Image { + public static function textureLink(object: Object, mat: MaterialData, link: String): kha.Image { #if arm_ltc if (link == "_ltcMat") { if (armory.data.ConstData.ltcMatTex == null) armory.data.ConstData.initLTC(); @@ -28,8 +28,8 @@ class Uniforms { return null; } - public static function vec3Link(object:Object, mat:MaterialData, link:String):iron.math.Vec4 { - var v:Vec4 = null; + public static function vec3Link(object: Object, mat: MaterialData, link: String): iron.math.Vec4 { + var v: Vec4 = null; #if arm_hosek if (link == "_hosekA") { if (armory.renderpath.HosekWilkie.data == null) { @@ -155,11 +155,11 @@ class Uniforms { v.set(Math.floor(v.x / f) * f, Math.floor(v.y / f) * f, Math.floor(v.z / f) * f); } #end - + return v; } - public static function floatLink(object:Object, mat:MaterialData, link:String):Null { + public static function floatLink(object: Object, mat: MaterialData, link: String): Null { #if rp_dynres if (link == "_dynamicScale") { return armory.renderpath.DynamicResolutionScale.dynamicScale; diff --git a/Sources/armory/renderpath/DynamicResolutionScale.hx b/Sources/armory/renderpath/DynamicResolutionScale.hx index d0dc5dd7..98259b4c 100644 --- a/Sources/armory/renderpath/DynamicResolutionScale.hx +++ b/Sources/armory/renderpath/DynamicResolutionScale.hx @@ -11,7 +11,7 @@ class DynamicResolutionScale { static inline var scaleRangeMs = 10; static inline var maxScale = 0.6; - public static function run(path:RenderPath) { + public static function run(path: RenderPath) { if (firstFrame) { iron.App.notifyOnRender(render); firstFrame = false; @@ -31,13 +31,13 @@ class DynamicResolutionScale { else dynamicScale = 1.0; } - static var frameTime:Float; - static var lastTime:Float = 0; - static var totalTime:Float = 0; + static var frameTime: Float; + static var lastTime: Float = 0; + static var totalTime: Float = 0; static var frames = 0; static var frameTimeAvg = 0.0; - - public static function render(g:kha.graphics4.Graphics) { + + public static function render(g: kha.graphics4.Graphics) { frameTime = kha.Scheduler.realTime() - lastTime; lastTime = kha.Scheduler.realTime(); totalTime += frameTime; diff --git a/Sources/armory/renderpath/HosekWilkie.hx b/Sources/armory/renderpath/HosekWilkie.hx index a2a9b2ba..0babf591 100644 --- a/Sources/armory/renderpath/HosekWilkie.hx +++ b/Sources/armory/renderpath/HosekWilkie.hx @@ -7,7 +7,7 @@ import kha.math.FastVector3; import iron.data.WorldData; class HosekWilkieRadianceData { - + public var A = new FastVector3(); public var B = new FastVector3(); public var C = new FastVector3(); @@ -19,7 +19,7 @@ class HosekWilkieRadianceData { public var I = new FastVector3(); public var Z = new FastVector3(); - function evaluateSpline(spline:Array, index:Int, stride:Int, value:Float):Float { + function evaluateSpline(spline: Array, index: Int, stride: Int, value: Float): Float { return 1 * Math.pow(1 - value, 5) * spline[index ] + 5 * Math.pow(1 - value, 4) * Math.pow(value, 1) * spline[index + 1 * stride] + @@ -28,55 +28,55 @@ class HosekWilkieRadianceData { 5 * Math.pow(1 - value, 1) * Math.pow(value, 4) * spline[index + 4 * stride] + 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; } - - function evaluate(dataset:Array, index:Int, stride:Int, turbidity:Float, albedo:Float, sunTheta:Float):Float { + + function evaluate(dataset: Array, index: Int, stride: Int, turbidity: Float, albedo: Float, sunTheta: Float): Float { // Splines are functions of elevation^1/3 - var elevationK:Float = Math.pow(Math.max(0.0, 1.0 - sunTheta / (Math.PI / 2.0)), 1.0 / 3.0); - + var elevationK: Float = Math.pow(Math.max(0.0, 1.0 - sunTheta / (Math.PI / 2.0)), 1.0 / 3.0); + // Table has values for turbidity 1..10 - var turbidity0:Int = clamp(Std.int(turbidity), 1, 10); - var turbidity1:Int = Std.int(Math.min(turbidity0 + 1, 10)); - var turbidityK:Float = clampF(turbidity - turbidity0, 0.0, 1.0); - + var turbidity0: Int = clamp(Std.int(turbidity), 1, 10); + var turbidity1: Int = Std.int(Math.min(turbidity0 + 1, 10)); + var turbidityK: Float = clampF(turbidity - turbidity0, 0.0, 1.0); + var datasetA0Index = index; var datasetA1Index = index + stride * 6 * 10; - - var a0t0:Float = evaluateSpline(dataset, datasetA0Index + stride * 6 * (turbidity0 - 1), stride, elevationK); - var a1t0:Float = evaluateSpline(dataset, datasetA1Index + stride * 6 * (turbidity0 - 1), stride, elevationK); - var a0t1:Float = evaluateSpline(dataset, datasetA0Index + stride * 6 * (turbidity1 - 1), stride, elevationK); - var a1t1:Float = evaluateSpline(dataset, datasetA1Index + stride * 6 * (turbidity1 - 1), stride, elevationK); - + + var a0t0: Float = evaluateSpline(dataset, datasetA0Index + stride * 6 * (turbidity0 - 1), stride, elevationK); + var a1t0: Float = evaluateSpline(dataset, datasetA1Index + stride * 6 * (turbidity0 - 1), stride, elevationK); + var a0t1: Float = evaluateSpline(dataset, datasetA0Index + stride * 6 * (turbidity1 - 1), stride, elevationK); + var a1t1: Float = evaluateSpline(dataset, datasetA1Index + stride * 6 * (turbidity1 - 1), stride, elevationK); + return a0t0 * (1 - albedo) * (1 - turbidityK) + a1t0 * albedo * (1 - turbidityK) + a0t1 * (1 - albedo) * turbidityK + a1t1 * albedo * turbidityK; } - - function hosek_wilkie(cos_theta:Float, gamma:Float, cos_gamma:Float, A:FastVector3, B:FastVector3, C:FastVector3, D:FastVector3, E:FastVector3, F:FastVector3, G:FastVector3, H:FastVector3, I:FastVector3):FastVector3 { + + function hosek_wilkie(cos_theta: Float, gamma: Float, cos_gamma: Float, A: FastVector3, B: FastVector3, C: FastVector3, D: FastVector3, E: FastVector3, F: FastVector3, G: FastVector3, H: FastVector3, I: FastVector3): FastVector3 { var val = (1.0 + cos_gamma * cos_gamma); var chix = val / Math.pow(1.0 + H.x * H.x - 2.0 * cos_gamma * H.x, 1.5); var chiy = val / Math.pow(1.0 + H.y * H.y - 2.0 * cos_gamma * H.y, 1.5); var chiz = val / Math.pow(1.0 + H.z * H.z - 2.0 * cos_gamma * H.z, 1.5); var chi = new FastVector3(chix, chiy, chiz); - + var vx = (1.0 + A.x * Math.exp(B.x / (cos_theta + 0.01))) * (C.x + D.x * Math.exp(E.x * gamma) + F.x * (cos_gamma * cos_gamma) + G.x * chi.x + I.x * Math.sqrt(Math.max(0.0, cos_theta))); var vy = (1.0 + A.y * Math.exp(B.y / (cos_theta + 0.01))) * (C.y + D.y * Math.exp(E.y * gamma) + F.y * (cos_gamma * cos_gamma) + G.y * chi.y + I.y * Math.sqrt(Math.max(0.0, cos_theta))); var vz = (1.0 + A.z * Math.exp(B.z / (cos_theta + 0.01))) * (C.z + D.z * Math.exp(E.z * gamma) + F.z * (cos_gamma * cos_gamma) + G.z * chi.z + I.z * Math.sqrt(Math.max(0.0, cos_theta))); return new FastVector3(vx, vy, vz); } - - function setVector(v:FastVector3, index:Int, f:Float) { + + function setVector(v: FastVector3, index: Int, f: Float) { index == 0 ? v.x = f : index == 1 ? v.y = f : v.z = f; } - + public function new() {} - public function recompute(sunTheta:Float, turbidity:kha.FastFloat, albedo:kha.FastFloat, normalizedSunY:Float) { + public function recompute(sunTheta: Float, turbidity: kha.FastFloat, albedo: kha.FastFloat, normalizedSunY: Float) { for (i in 0...3) { setVector(A, i, evaluate(HosekWilkieData.datasetsRGB[i], 0, 9, turbidity, albedo, sunTheta)); setVector(B, i, evaluate(HosekWilkieData.datasetsRGB[i], 1, 9, turbidity, albedo, sunTheta)); @@ -85,16 +85,16 @@ class HosekWilkieRadianceData { setVector(E, i, evaluate(HosekWilkieData.datasetsRGB[i], 4, 9, turbidity, albedo, sunTheta)); setVector(F, i, evaluate(HosekWilkieData.datasetsRGB[i], 5, 9, turbidity, albedo, sunTheta)); setVector(G, i, evaluate(HosekWilkieData.datasetsRGB[i], 6, 9, turbidity, albedo, sunTheta)); - + // Swapped in the dataset setVector(H, i, evaluate(HosekWilkieData.datasetsRGB[i], 8, 9, turbidity, albedo, sunTheta)); setVector(I, i, evaluate(HosekWilkieData.datasetsRGB[i], 7, 9, turbidity, albedo, sunTheta)); - + setVector(Z, i, evaluate(HosekWilkieData.datasetsRGBRad[i], 0, 1, turbidity, albedo, sunTheta)); } - + if (normalizedSunY != 0.0) { - var S:FastVector3 = hosek_wilkie(Math.cos(sunTheta), 0, 1.0, A, B, C, D, E, F, G, H, I); + var S: FastVector3 = hosek_wilkie(Math.cos(sunTheta), 0, 1.0, A, B, C, D, E, F, G, H, I); S.x *= Z.x; S.y *= Z.y; S.z *= Z.z; @@ -108,15 +108,16 @@ class HosekWilkieRadianceData { } class HosekWilkie { - public static var data:HosekWilkieRadianceData = null; - public static function recompute(world:WorldData) { + public static var data: HosekWilkieRadianceData = null; + + public static function recompute(world: WorldData) { if (world == null || world.raw.sun_direction == null) return; if (data == null) data = new HosekWilkieRadianceData(); // Clamp Z for night cycle var sunZ = world.raw.sun_direction[2] > 0 ? world.raw.sun_direction[2] : 0; var sunPositionX = Math.acos(sunZ); - var normalizedSunY:kha.FastFloat = 1.15; + var normalizedSunY: kha.FastFloat = 1.15; data.recompute(sunPositionX, world.raw.turbidity, world.raw.ground_albedo, normalizedSunY); } } diff --git a/Sources/armory/renderpath/Inc.hx b/Sources/armory/renderpath/Inc.hx index b3815dff..731edd3e 100644 --- a/Sources/armory/renderpath/Inc.hx +++ b/Sources/armory/renderpath/Inc.hx @@ -4,7 +4,7 @@ import iron.RenderPath; class Inc { - static var path:RenderPath; + static var path: RenderPath; public static var superSample = 1.0; static var pointIndex = 0; @@ -15,7 +15,7 @@ class Inc { static var voxelsCreated = false; #end - public static function init(_path:RenderPath) { + public static function init(_path: RenderPath) { path = _path; #if arm_config @@ -27,7 +27,7 @@ class Inc { } superSample = config.rp_supersample; #else - + #if (rp_supersampling == 1.5) superSample = 1.5; #elseif (rp_supersampling == 2) @@ -35,7 +35,7 @@ class Inc { #elseif (rp_supersampling == 4) superSample = 4.0; #end - + #end } @@ -56,13 +56,13 @@ class Inc { } } - static function shadowMapName(l:iron.object.LightObject):String { + static function shadowMapName(l: iron.object.LightObject): String { if (l.data.raw.type == "sun") return "shadowMap"; if (l.data.raw.type == "point") return "shadowMapPoint[" + pointIndex + "]"; - else return "shadowMapSpot[" + spotIndex + "]"; + else return "shadowMapSpot[" + spotIndex + "]"; } - static function getShadowMap(l:iron.object.LightObject):String { + static function getShadowMap(l: iron.object.LightObject): String { var target = shadowMapName(l); var rt = path.renderTargets.get(target); // Create shadowmap on the fly @@ -124,10 +124,10 @@ class Inc { if (l.data.raw.type == "point") pointIndex++; else if (l.data.raw.type == "spot" || l.data.raw.type == "area") spotIndex++; } - + #end // rp_shadowmap } - + public static function applyConfig() { #if arm_config var config = armory.data.Config.raw; @@ -192,7 +192,7 @@ class Inc { path.loadShader("shader_datas/translucent_resolve/translucent_resolve"); } - public static function drawTranslucency(target:String) { + public static function drawTranslucency(target: String) { path.setTarget("accum"); path.clearTarget(0xff000000); path.setTarget("revealage"); @@ -255,7 +255,7 @@ class Inc { } #end - public static inline function getCubeSize():Int { + public static inline function getCubeSize(): Int { #if (rp_shadowmap_cube == 256) return 256; #elseif (rp_shadowmap_cube == 512) @@ -271,7 +271,7 @@ class Inc { #end } - public static inline function getCascadeSize():Int { + public static inline function getCascadeSize(): Int { #if (rp_shadowmap_cascade == 256) return 256; #elseif (rp_shadowmap_cascade == 512) @@ -291,7 +291,7 @@ class Inc { #end } - public static inline function getVoxelRes():Int { + public static inline function getVoxelRes(): Int { #if (rp_voxelgi_resolution == 512) return 512; #elseif (rp_voxelgi_resolution == 256) @@ -307,7 +307,7 @@ class Inc { #end } - public static inline function getVoxelResZ():Float { + public static inline function getVoxelResZ(): Float { #if (rp_voxelgi_resolution_z == 1.0) return 1.0; #elseif (rp_voxelgi_resolution_z == 0.5) @@ -319,11 +319,11 @@ class Inc { #end } - public static inline function getSuperSampling():Float { + public static inline function getSuperSampling(): Float { return superSample; } - public static inline function getHdrFormat():String { + public static inline function getHdrFormat(): String { #if rp_hdr return "RGBA64"; #else @@ -331,7 +331,7 @@ class Inc { #end } - public static inline function getDisplayp():Null { + public static inline function getDisplayp(): Null { #if rp_resolution_filter // Custom resolution set return Main.resolutionSize; #else diff --git a/Sources/armory/renderpath/RenderPathCreator.hx b/Sources/armory/renderpath/RenderPathCreator.hx index 651f42c9..021445c1 100644 --- a/Sources/armory/renderpath/RenderPathCreator.hx +++ b/Sources/armory/renderpath/RenderPathCreator.hx @@ -5,23 +5,23 @@ import iron.RenderPath; class RenderPathCreator { - public static var path:RenderPath; + public static var path: RenderPath; #if (rp_renderer == "Forward") - public static var setTargetMeshes:Void->Void = RenderPathForward.setTargetMeshes; - public static var drawMeshes:Void->Void = RenderPathForward.drawMeshes; - public static var applyConfig:Void->Void = RenderPathForward.applyConfig; + public static var setTargetMeshes: Void->Void = RenderPathForward.setTargetMeshes; + public static var drawMeshes: Void->Void = RenderPathForward.drawMeshes; + public static var applyConfig: Void->Void = RenderPathForward.applyConfig; #elseif (rp_renderer == "Deferred") - public static var setTargetMeshes:Void->Void = RenderPathDeferred.setTargetMeshes; - public static var drawMeshes:Void->Void = RenderPathDeferred.drawMeshes; - public static var applyConfig:Void->Void = RenderPathDeferred.applyConfig; + public static var setTargetMeshes: Void->Void = RenderPathDeferred.setTargetMeshes; + public static var drawMeshes: Void->Void = RenderPathDeferred.drawMeshes; + public static var applyConfig: Void->Void = RenderPathDeferred.applyConfig; #else - public static var setTargetMeshes:Void->Void = function() {}; - public static var drawMeshes:Void->Void = function() {}; - public static var applyConfig:Void->Void = function() {}; + public static var setTargetMeshes: Void->Void = function() {}; + public static var drawMeshes: Void->Void = function() {}; + public static var applyConfig: Void->Void = function() {}; #end - public static function get():RenderPath { + public static function get(): RenderPath { path = new RenderPath(); Inc.init(path); #if (rp_renderer == "Forward") @@ -43,5 +43,5 @@ class RenderPathCreator { #end // Last target before drawing to framebuffer - public static var finalTarget:RenderTarget = null; + public static var finalTarget: RenderTarget = null; } diff --git a/Sources/armory/renderpath/RenderPathDeferred.hx b/Sources/armory/renderpath/RenderPathDeferred.hx index e115c76b..87665920 100644 --- a/Sources/armory/renderpath/RenderPathDeferred.hx +++ b/Sources/armory/renderpath/RenderPathDeferred.hx @@ -6,7 +6,7 @@ class RenderPathDeferred { #if (rp_renderer == "Deferred") - static var path:RenderPath; + static var path: RenderPath; #if rp_voxelao static var voxels = "voxels"; @@ -33,7 +33,7 @@ class RenderPathDeferred { Inc.applyConfig(); } - public static function init(_path:RenderPath) { + public static function init(_path: RenderPath) { path = _path; @@ -326,7 +326,7 @@ class RenderPathDeferred { path.loadShader("shader_datas/ssr_pass/ssr_pass"); path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x"); path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend"); - + #if rp_ssr_half { var t = new RenderTargetRaw(); @@ -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); @@ -439,7 +439,7 @@ class RenderPathDeferred { path.setTarget("gbuffer0", ["gbuffer1"]); path.bindTarget("_main", "gbufferD"); path.drawDecals("decal"); - + #if (!kha_opengl) path.setDepthFrom("gbuffer0", "tex"); // Re-bind depth path.depthToRenderTarget.set("main", path.renderTargets.get("gbuffer0")); @@ -475,7 +475,7 @@ class RenderPathDeferred { path.bindTarget("gbuffer0", "gbuffer0"); path.drawShader("shader_datas/blur_edge_pass/blur_edge_pass_y"); } - } + } #elseif (rp_ssgi == "SSAO") { if (armory.data.Config.raw.rp_ssgi != false) { @@ -571,7 +571,7 @@ class RenderPathDeferred { Inc.bindShadowMap(); } #end - + #if rp_material_solid path.drawShader("shader_datas/deferred_light_solid/deferred_light"); #elseif rp_material_mobile @@ -765,7 +765,7 @@ class RenderPathDeferred { { path.bindTarget("_main", "gbufferD"); path.drawShader("shader_datas/motion_blur_pass/motion_blur_pass"); - + #if (!kha_opengl) path.setDepthFrom("tex", "gbuffer0"); // Re-bind depth #end @@ -786,7 +786,7 @@ class RenderPathDeferred { #if rp_chromatic_aberration { path.setTarget("buf"); - path.bindTarget("tex","tex"); + path.bindTarget("tex", "tex"); path.drawShader("shader_datas/chromatic_aberration_pass/chromatic_aberration_pass"); path.setTarget("tex"); path.bindTarget("buf", "tex"); @@ -820,7 +820,7 @@ class RenderPathDeferred { #end RenderPathCreator.finalTarget = path.currentTarget; - + var target = ""; #if ((rp_antialiasing == "Off") || (rp_antialiasing == "FXAA") || (!rp_render_to_texture)) { @@ -832,7 +832,7 @@ class RenderPathDeferred { } #end path.setTarget(target); - + path.bindTarget("tex", "tex"); #if rp_compositordepth { diff --git a/Sources/armory/renderpath/RenderPathForward.hx b/Sources/armory/renderpath/RenderPathForward.hx index 44d6ca6e..7c69f134 100644 --- a/Sources/armory/renderpath/RenderPathForward.hx +++ b/Sources/armory/renderpath/RenderPathForward.hx @@ -6,7 +6,7 @@ class RenderPathForward { #if (rp_renderer == "Forward") - static var path:RenderPath; + static var path: RenderPath; #if rp_voxelao static var voxels = "voxels"; @@ -58,10 +58,10 @@ class RenderPathForward { Inc.applyConfig(); } - public static function init(_path:RenderPath) { + public static function init(_path: RenderPath) { path = _path; - + #if (rp_background == "World") { path.loadShader("shader_datas/world_pass/world_pass"); @@ -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"; @@ -258,7 +258,7 @@ class RenderPathForward { path.loadShader("shader_datas/ssr_pass/ssr_pass"); path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_x"); path.loadShader("shader_datas/blur_adaptive_pass/blur_adaptive_pass_y3_blend"); - + #if rp_ssr_half { var t = new RenderTargetRaw(); @@ -406,7 +406,7 @@ class RenderPathForward { } } #end - + #if rp_bloom { if (armory.data.Config.raw.rp_bloom != false) { diff --git a/Sources/armory/renderpath/RenderPathRaytracer.hx b/Sources/armory/renderpath/RenderPathRaytracer.hx index 7ca90043..fe8812c8 100644 --- a/Sources/armory/renderpath/RenderPathRaytracer.hx +++ b/Sources/armory/renderpath/RenderPathRaytracer.hx @@ -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; @@ -20,7 +19,7 @@ class RenderPathRaytracer { #if (rp_renderer == "Raytracer") - static var path:RenderPath; + static var path: RenderPath; static var ready = false; static inline var bufferCount = 2; @@ -34,12 +33,12 @@ class RenderPathRaytracer { static var frame = 0.0; @:access(iron.data.Geometry) - public static function init(_path:RenderPath) { + public static function init(_path: RenderPath) { path = _path; - kha.Assets.loadBlobFromPath("raytrace.cso", function(rayTraceShader:kha.Blob) { + kha.Assets.loadBlobFromPath("raytrace.cso", function(rayTraceShader: kha.Blob) { ready = true; - + // Command list commandList = new CommandList(); for (i in 0...bufferCount) { @@ -106,7 +105,7 @@ class RenderPathRaytracer { constantBuffer.setFloat(4, ct.worldy()); constantBuffer.setFloat(8, ct.worldz()); constantBuffer.setFloat(12, 1); - + constantBuffer.setFloat(16, helpMat._00); constantBuffer.setFloat(20, helpMat._01); constantBuffer.setFloat(24, helpMat._02); @@ -123,7 +122,7 @@ class RenderPathRaytracer { constantBuffer.setFloat(68, helpMat._31); constantBuffer.setFloat(72, helpMat._32); constantBuffer.setFloat(76, helpMat._33); - + constantBuffer.setFloat(80, frame); frame += 1.0; constantBuffer.unlock(); @@ -131,15 +130,15 @@ class RenderPathRaytracer { g.begin(framebuffers[currentBuffer]); commandList.begin(); - + g.setAccelerationStructure(accel); g.setRayTracePipeline(pipeline); g.setRayTraceTarget(target); - + g.dispatchRays(commandList); g.copyRayTraceTarget(commandList, framebuffers[currentBuffer], target); commandList.end(); - + g.end(); // g.swapBuffers(); diff --git a/Sources/armory/system/Event.hx b/Sources/armory/system/Event.hx index f12077a1..fa9d14d4 100644 --- a/Sources/armory/system/Event.hx +++ b/Sources/armory/system/Event.hx @@ -4,35 +4,35 @@ class Event { static var events = new Map>(); - public static function send(name:String, mask = -1) { + public static function send(name: String, mask = -1) { var entries = get(name); if (entries != null) for (e in entries) if (mask == -1 || mask == e.mask ) e.onEvent(); } - public static function get(name:String):Array { + public static function get(name: String): Array { return events.get(name); } - public static function add(name:String, onEvent:Void->Void, mask = -1):TEvent { - var e:TEvent = { name: name, onEvent: onEvent, mask: mask }; + public static function add(name: String, onEvent: Void->Void, mask = -1): TEvent { + var e: TEvent = { name: name, onEvent: onEvent, mask: mask }; var entries = events.get(name); if (entries != null) entries.push(e); else events.set(name, [e]); return e; } - public static function remove(name:String) { + public static function remove(name: String) { events.remove(name); } - public static function removeListener(event:TEvent) { + public static function removeListener(event: TEvent) { var entries = events.get(event.name); if (entries != null) entries.remove(event); } } typedef TEvent = { - var name:String; - var onEvent:Void->Void; - var mask:Int; + var name: String; + var onEvent: Void->Void; + var mask: Int; } diff --git a/Sources/armory/system/Logic.hx b/Sources/armory/system/Logic.hx index 69684ba6..f7e4c442 100644 --- a/Sources/armory/system/Logic.hx +++ b/Sources/armory/system/Logic.hx @@ -4,12 +4,12 @@ import armory.logicnode.*; class Logic { - static var nodes:Array; - static var links:Array; + static var nodes: Array; + static var links: Array; - static var parsed_nodes:Array = null; - static var parsed_labels:Map = null; - static var nodeMap:Map; + static var parsed_nodes: Array = null; + static var parsed_labels: Map = null; + static var nodeMap: Map; public static var packageName = "armory.logicnode"; @@ -46,17 +46,17 @@ class Logic { return res; } - static function safesrc(s:String):String { - return StringTools.replace(s, ' ', ''); + static function safesrc(s: String): String { + return StringTools.replace(s, " ", ""); } - static function node_name(node:TNode):String { + static function node_name(node: TNode): String { var s = safesrc(node.name) + node.id; return s; } - static var tree:armory.logicnode.LogicTree; - public static function parse(canvas:TNodeCanvas, onAdd = true):armory.logicnode.LogicTree { + static var tree: armory.logicnode.LogicTree; + public static function parse(canvas: TNodeCanvas, onAdd = true): armory.logicnode.LogicTree { nodes = canvas.nodes; links = canvas.links; @@ -78,7 +78,7 @@ class Logic { return tree; } - static function build_node(node:TNode):String { + static function build_node(node: TNode): String { // Get node name var name = node_name(node); @@ -97,14 +97,14 @@ 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]); } } } - + // Create inputs - var inp_node:armory.logicnode.LogicNode = null; + var inp_node: armory.logicnode.LogicNode = null; var inp_from = 0; for (i in 0...node.inputs.length) { var inp = node.inputs[i]; @@ -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; } @@ -132,7 +131,7 @@ class Logic { // Create outputs for (out in node.outputs) { - var outNodes:Array = []; + var outNodes: Array = []; var ls = getOutputLinks(out); if (ls != null && ls.length > 0) { for (l in ls) { @@ -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 @@ -151,9 +149,9 @@ class Logic { return name; } - - static function get_root_nodes(node_group:TNodeCanvas):Array { - var roots:Array = []; + + static function get_root_nodes(node_group: TNodeCanvas): Array { + var roots: Array = []; for (node in node_group.nodes) { // if (node.bl_idname == 'NodeUndefined') { // arm.log.warn('Undefined logic nodes in ' + node_group.name) @@ -174,48 +172,48 @@ class Logic { return roots; } - static function build_default_node(inp:TNodeSocket):armory.logicnode.LogicNode { - - var v:armory.logicnode.LogicNode = null; - - if (inp.type == 'OBJECT') { - v = createClassInstance('ObjectNode', [tree, inp.default_value]); + static function build_default_node(inp: TNodeSocket): armory.logicnode.LogicNode { + + var v: armory.logicnode.LogicNode = null; + + 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 { - var cname = Type.resolveClass(packageName + '.' + className); + static function createClassInstance(className: String, args: Array): Dynamic { + var cname = Type.resolveClass(packageName + "." + className); if (cname == null) return null; return Type.createInstance(cname, args); } diff --git a/Sources/armory/system/Starter.hx b/Sources/armory/system/Starter.hx index ca02eda1..5661615f 100644 --- a/Sources/armory/system/Starter.hx +++ b/Sources/armory/system/Starter.hx @@ -4,14 +4,14 @@ import kha.WindowOptions; class Starter { - static var tasks:Int; + static var tasks: Int; #if arm_loadscreen - public static var drawLoading:kha.graphics2.Graphics->Int->Int->Void = null; - public static var numAssets:Int; + public static var drawLoading: kha.graphics2.Graphics->Int->Int->Void = null; + public static var numAssets: Int; #end - public static function main(scene:String, mode:Int, resize:Bool, min:Bool, max:Bool, w:Int, h:Int, msaa:Int, vsync:Bool, getRenderPath:Void->iron.RenderPath) { + public static function main(scene: String, mode: Int, resize: Bool, min: Bool, max: Bool, w: Int, h: Int, msaa: Int, vsync: Bool, getRenderPath: Void->iron.RenderPath) { function start() { if (tasks > 0) return; @@ -41,17 +41,17 @@ class Starter { try { #end - kha.System.start({title: Main.projectName, width: c.window_w, height: c.window_h, window: {mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window:kha.Window) { + kha.System.start({title: Main.projectName, width: c.window_w, height: c.window_h, window: {mode: windowMode, windowFeatures: windowFeatures}, framebuffer: {samplesPerPixel: c.window_msaa, verticalSync: c.window_vsync}}, function(window: kha.Window) { iron.App.init(function() { #if arm_loadscreen - function load(g:kha.graphics2.Graphics) { + function load(g: kha.graphics2.Graphics) { if (iron.Scene.active != null && iron.Scene.active.ready) iron.App.removeRender2D(load); else drawLoading(g, iron.data.Data.assetsLoaded, numAssets); } iron.App.notifyOnRender2D(load); #end - iron.Scene.setActive(scene, function(object:iron.object.Object) { + iron.Scene.setActive(scene, function(object: iron.object.Object) { iron.RenderPath.setActive(getRenderPath()); #if arm_patch iron.Scene.getRenderPath = getRenderPath; @@ -65,7 +65,7 @@ class Starter { #if (kha_webgl && (!arm_legacy) && (!kha_node)) } - catch (e:Dynamic) { + catch (e: Dynamic) { if (!kha.SystemImpl.gl2) { trace("This project was not compiled with legacy shaders flag - please use WebGL 2 capable browser."); } @@ -74,8 +74,8 @@ class Starter { } #if (js && arm_bullet) - function loadLibAmmo(name:String) { - kha.Assets.loadBlobFromPath(name, function(b:kha.Blob) { + function loadLibAmmo(name: String) { + kha.Assets.loadBlobFromPath(name, function(b: kha.Blob) { var print = function(s:String) { trace(s); }; var loaded = function() { tasks--; start(); }; untyped __js__("(1, eval)({0})", b.toString()); @@ -96,8 +96,8 @@ class Starter { #end #if (js && arm_navigation) - function loadLib(name:String) { - kha.Assets.loadBlobFromPath(name, function(b:kha.Blob) { + function loadLib(name: String) { + kha.Assets.loadBlobFromPath(name, function(b: kha.Blob) { untyped __js__("(1, eval)({0})", b.toString()); tasks--; start(); @@ -116,7 +116,6 @@ class Starter { #end #end - #if (js && arm_navigation) tasks++; loadLib("recast.js"); diff --git a/Sources/armory/trait/ArcBall.hx b/Sources/armory/trait/ArcBall.hx index 2e735766..ddf800f7 100644 --- a/Sources/armory/trait/ArcBall.hx +++ b/Sources/armory/trait/ArcBall.hx @@ -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 { diff --git a/Sources/armory/trait/Character.hx b/Sources/armory/trait/Character.hx index 7c93a584..6ad08fb0 100644 --- a/Sources/armory/trait/Character.hx +++ b/Sources/armory/trait/Character.hx @@ -9,24 +9,24 @@ import iron.math.Quat; class Character extends Trait { - var currentAction:String; - var animation:Animation; + var currentAction: String; + var animation: Animation; var speed = 0.0; - var loc:Vec4 = new Vec4(); - var lastLoc:Vec4 = null; + var loc: Vec4 = new Vec4(); + var lastLoc: Vec4 = null; var framesIdle = 0; // Number of frames character did not move @:prop - var actionIdle:String = "idle"; + var actionIdle: String = "idle"; @:prop - var actionMove:String = "run"; + var actionMove: String = "run"; public function new() { super(); - currentAction = actionIdle; + currentAction = actionIdle; notifyOnInit(init); } @@ -35,7 +35,7 @@ class Character extends Trait { // Try first child if we are running from armature if (animation == null) { - if(object.children.length > 0) { + if (object.children.length > 0) { animation = object.children[0].animation; } } @@ -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); diff --git a/Sources/armory/trait/FirstPersonController.hx b/Sources/armory/trait/FirstPersonController.hx index 51767936..a8a4e940 100755 --- a/Sources/armory/trait/FirstPersonController.hx +++ b/Sources/armory/trait/FirstPersonController.hx @@ -13,15 +13,15 @@ class FirstPersonController extends CameraController { public function new() { super(); } #else - var head:Object; - static inline var rotationSpeed = 2.0; + var head: Object; + static inline var rotationSpeed = 2.0; public function new() { super(); iron.Scene.active.notifyOnInit(init); } - + function init() { head = object.getChildOfType(CameraObject); @@ -34,13 +34,13 @@ class FirstPersonController extends CameraController { var zVec = Vec4.zAxis(); function preUpdate() { if (Input.occupied || !body.ready) return; - + var mouse = Input.getMouse(); var kb = Input.getKeyboard(); if (mouse.started() && !mouse.locked) mouse.lock(); else if (kb.started("escape") && mouse.locked) mouse.unlock(); - + if (mouse.locked || mouse.down()) { head.transform.rotate(xVec, -mouse.movementY / 250 * rotationSpeed); transform.rotate(zVec, -mouse.movementX / 250 * rotationSpeed); @@ -72,7 +72,7 @@ class FirstPersonController extends CameraController { var btvec = body.getLinearVelocity(); body.setLinearVelocity(0.0, 0.0, btvec.z - 1.0); - if (moveForward || moveBackward || moveLeft || moveRight) { + if (moveForward || moveBackward || moveLeft || moveRight) { dir.mult(6); body.activate(); body.setLinearVelocity(dir.x, dir.y, btvec.z - 1.0); diff --git a/Sources/armory/trait/FollowCamera.hx b/Sources/armory/trait/FollowCamera.hx index 958c8dcb..6cfdf84e 100644 --- a/Sources/armory/trait/FollowCamera.hx +++ b/Sources/armory/trait/FollowCamera.hx @@ -2,26 +2,25 @@ 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. -*/ +/** + 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 - var target:String; + var target: String; @prop - var lerp:Bool = true; + var lerp: Bool = true; @prop - var lerpSpeed:Float = 0.1; + var lerpSpeed: Float = 0.1; - var targetObj:Object; + var targetObj: Object; var disabled = false; public function new() { diff --git a/Sources/armory/trait/Macro.hx b/Sources/armory/trait/Macro.hx index 3a047792..22207bac 100755 --- a/Sources/armory/trait/Macro.hx +++ b/Sources/armory/trait/Macro.hx @@ -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; } } diff --git a/Sources/armory/trait/NavAgent.hx b/Sources/armory/trait/NavAgent.hx index 8aa7b4be..20fa87ac 100644 --- a/Sources/armory/trait/NavAgent.hx +++ b/Sources/armory/trait/NavAgent.hx @@ -8,19 +8,19 @@ import iron.system.Tween; class NavAgent extends Trait { @prop - var speed:Float = 5; + var speed: Float = 5; - var path:Array = null; + var path: Array = null; var index = 0; - var rotAnim:TAnim = null; - var locAnim:TAnim = null; + var rotAnim: TAnim = null; + var locAnim: TAnim = null; public function new() { super(); } - public function setPath(path:Array) { + public function setPath(path: Array) { stopTween(); this.path = path; @@ -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); @@ -57,7 +57,7 @@ class NavAgent extends Trait { orient.subvecs(p, object.transform.loc).normalize; var targetAngle = Math.atan2(orient.y, orient.x) + Math.PI / 2; - locAnim = Tween.to({ target: object.transform.loc, props: { x: p.x, y: p.y , z: p.z }, duration: dist / speed, done: function() { + locAnim = Tween.to({ target: object.transform.loc, props: { x: p.x, y: p.y, z: p.z }, duration: dist / speed, done: function() { index++; if (index < path.length) go(); else removeUpdate(update); diff --git a/Sources/armory/trait/NavMesh.hx b/Sources/armory/trait/NavMesh.hx index 96c5a667..fec35ede 100755 --- a/Sources/armory/trait/NavMesh.hx +++ b/Sources/armory/trait/NavMesh.hx @@ -17,19 +17,19 @@ class NavMesh extends Trait { // recast config: @prop - public var cellSize:Float = 0.3; // voxelization cell size + public var cellSize: Float = 0.3; // voxelization cell size @prop - public var cellHeight:Float = 0.2; // voxelization cell height + public var cellHeight: Float = 0.2; // voxelization cell height @prop - public var agentHeight:Float = 2.0; // agent capsule height + public var agentHeight: Float = 2.0; // agent capsule height @prop - public var agentRadius:Float = 0.4; // agent capsule radius + public var agentRadius: Float = 0.4; // agent capsule radius @prop - public var agentMaxClimb:Float = 0.9; // how high steps agents can climb, in voxels + public var agentMaxClimb: Float = 0.9; // how high steps agents can climb, in voxels @prop - public var agentMaxSlope:Float = 45.0; // maximum slope angle, in degrees + public var agentMaxSlope: Float = 45.0; // maximum slope angle, in degrees - var recast:Recast = null; + var recast: Recast = null; var ready = false; public function new() { @@ -43,18 +43,17 @@ class NavMesh extends Trait { // Load navmesh var name = "nav_" + cast(object, iron.object.MeshObject).data.name + ".arm"; - Data.getBlob(name, function(b:kha.Blob) { + Data.getBlob(name, function(b: kha.Blob) { 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); @@ -64,18 +63,18 @@ class NavMesh extends Trait { }); } - public function findPath(from:Vec4, to:Vec4, done:Array->Void) { + public function findPath(from: Vec4, to: Vec4, done: Array->Void) { if (!ready) return; - recast.findPath(from.x, from.z, from.y, to.x, to.z, to.y, 200, function(path:Array) { - var ar:Array = []; + recast.findPath(from.x, from.z, from.y, to.x, to.z, to.y, 200, function(path: Array) { + var ar: Array = []; for (p in path) ar.push(new Vec4(p.x, p.z, p.y)); done(ar); }); } - public function getRandomPoint(done:Vec4->Void) { + public function getRandomPoint(done: Vec4->Void) { if (!ready) return; - recast.getRandomPoint(function(x:Float, y:Float, z:Float) { + recast.getRandomPoint(function(x: Float, y: Float, z: Float) { done(new Vec4(x, z, -y)); }); } diff --git a/Sources/armory/trait/PhysicsBreak.hx b/Sources/armory/trait/PhysicsBreak.hx index 0146fd4a..665ecf21 100644 --- a/Sources/armory/trait/PhysicsBreak.hx +++ b/Sources/armory/trait/PhysicsBreak.hx @@ -12,14 +12,15 @@ import armory.trait.physics.PhysicsWorld; #end class PhysicsBreak extends Trait { + #if (!arm_bullet) public function new() { super(); } #else - static var physics:PhysicsWorld = null; - static var breaker:ConvexBreaker = null; + static var physics: PhysicsWorld = null; + static var breaker: ConvexBreaker = null; - var body:RigidBody; + var body: RigidBody; public function new() { super(); @@ -41,8 +42,8 @@ class PhysicsBreak extends Trait { var ar = physics.getContactPairs(body); if (ar != null) { var maxImpulse = 0.0; - var impactPoint:Vec4 = null; - var impactNormal:Vec4 = null; + var impactPoint: Vec4 = null; + var impactNormal: Vec4 = null; for (p in ar) { if (maxImpulse < p.impulse) { maxImpulse = p.impulse; @@ -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]; @@ -77,21 +78,21 @@ class PhysicsBreak extends Trait { // This class can be used to subdivide a convex geometry object into pieces class ConvexBreaker { - var minSizeForBreak:Float; - var smallDelta:Float; + var minSizeForBreak: Float; + var smallDelta: Float; - var tempLine:Line3; - var tempPlane:Plane; - var tempPlane2:Plane; - var tempCM1:Vec4; - var tempCM2:Vec4; - var tempVec4:Vec4; - var tempVec42:Vec4; - var tempVec43:Vec4; - var tempCutResult:CutResult; - var segments:Array; + var tempLine: Line3; + var tempPlane: Plane; + var tempPlane2: Plane; + var tempCM1: Vec4; + var tempCM2: Vec4; + var tempVec4: Vec4; + var tempVec42: Vec4; + var tempVec43: Vec4; + var tempCutResult: CutResult; + var segments: Array; - public var userDataMap:Map; + public var userDataMap: Map; // minSizeForBreak Min size a debris can have to break // smallDelta Max distance to consider that a point belongs to a plane @@ -113,7 +114,7 @@ class ConvexBreaker { userDataMap = new Map(); } - public function initBreakableObject(object:MeshObject, mass:Float, friction:Float, velocity:Vec4, angularVelocity:Vec4, breakable:Bool) { + public function initBreakableObject(object: MeshObject, mass: Float, friction: Float, velocity: Vec4, angularVelocity: Vec4, breakable: Bool) { var ar = object.data.geom.positions; var scalePos = object.data.scalePos; // Create vertices mark @@ -153,7 +154,7 @@ class ConvexBreaker { var verts = new Array(); var map = new Map(); var i = 0; - function orderVert(fi:Int):Int { + function orderVert(fi: Int): Int { var val = map.get(fi); if (val == null) { verts.push(vertices[fi]); @@ -182,8 +183,8 @@ class ConvexBreaker { // maxRadialIterations Iterations for radial cuts // maxRandomIterations Max random iterations for not-radial cuts - public function subdivideByImpact(object:MeshObject, pointOfImpact:Vec4, normal:Vec4, maxRadialIterations:Int, maxRandomIterations:Int):Array { - var debris:Array = []; + public function subdivideByImpact(object: MeshObject, pointOfImpact: Vec4, normal: Vec4, maxRadialIterations: Int, maxRandomIterations: Int): Array { + var debris: Array = []; tempVec4.addvecs(pointOfImpact, normal); tempPlane.setFromCoplanarPoints(pointOfImpact, object.transform.loc, tempVec4); @@ -191,13 +192,13 @@ class ConvexBreaker { var maxTotalIterations = maxRandomIterations + maxRadialIterations; var scope = this; - function subdivideRadial(subObject:MeshObject, startAngle:Float, endAngle:Float, numIterations:Int) { + function subdivideRadial(subObject: MeshObject, startAngle: Float, endAngle: Float, numIterations: Int) { if (Math.random() < numIterations * 0.05 || numIterations > maxTotalIterations) { debris.push(subObject); return; } - + var angle = Math.PI; if (numIterations == 0) { tempPlane2.normal.setFrom(tempPlane.normal); @@ -237,7 +238,7 @@ class ConvexBreaker { return debris; } - function transformFreeVector(v:Vec4, m:Mat4):Vec4 { + function transformFreeVector(v: Vec4, m: Mat4): Vec4 { // Vector interpreted as a free vector // Mat4 orthogonal matrix (matrix without scale) var x = v.x, y = v.y, z = v.z; @@ -247,7 +248,7 @@ class ConvexBreaker { return v; } - function transformFreeVectorInverse(v:Vec4, m:Mat4):Vec4 { + function transformFreeVectorInverse(v: Vec4, m: Mat4): Vec4 { // Vector interpreted as a free vector // Mat4 orthogonal matrix (matrix without scale) var x = v.x, y = v.y, z = v.z; @@ -257,7 +258,7 @@ class ConvexBreaker { return v; } - function transformTiedVectorInverse(v:Vec4, m:Mat4):Vec4 { + function transformTiedVectorInverse(v: Vec4, m: Mat4): Vec4 { // Vector interpreted as a tied (ordinary) vector // Mat4 orthogonal matrix (matrix without scale) var x = v.x, y = v.y, z = v.z; @@ -267,7 +268,7 @@ class ConvexBreaker { return v; }; - function transformPlaneToLocalSpace(plane:Plane, m:Mat4, resultPlane:Plane) { + function transformPlaneToLocalSpace(plane: Plane, m: Mat4, resultPlane: Plane) { resultPlane.normal.setFrom(plane.normal); resultPlane.constant = plane.constant; @@ -283,10 +284,10 @@ class ConvexBreaker { // object2 can be null if the plane doesn't cut the object // object1 can be null only in case of error // Returned value is number of pieces, 0 for error - function cutByPlane(object:MeshObject, plane:Plane, output:CutResult):Int { + function cutByPlane(object: MeshObject, plane: Plane, output: CutResult): Int { var userData = userDataMap.get(object); - var points:Array = userData.vertices; - var faces:Array = userData.faces; + var points: Array = userData.vertices; + var faces: Array = userData.faces; var numPoints = points.length; var points1 = []; @@ -484,7 +485,7 @@ class ConvexBreaker { } static var meshIndex = 0; - function makeMeshData(points:Array) { + function makeMeshData(points: Array): MeshData { while (points.length > 50) points.pop(); var cm = new ConvexHull(points); @@ -507,9 +508,9 @@ class ConvexBreaker { if (az > maxdim) maxdim = az; } maxdim *= 2; - + var ind = new Array(); - function addFlatNormal(normal:Vec4, fi:Int) { + function addFlatNormal(normal: Vec4, fi: Int) { if (na[fi * 3] != 0.0 || na[fi * 3 + 1] != 0.0 || na[fi * 3 + 2] != 0.0) { pa.push(pa[fi * 3 ]); pa.push(pa[fi * 3 + 1]); @@ -548,12 +549,12 @@ class ConvexBreaker { } var inda = new kha.arrays.Uint32Array(ind.length); for (i in 0...ind.length) inda.set(i, ind[i]); - - var pos:TVertexArray = { attrib: "pos", values: paa }; - var nor:TVertexArray = { attrib: "nor", values: naa }; - var indices:TIndexArray = { material: 0, values: inda }; - var rawmesh:TMeshData = { + var pos: TVertexArray = { attrib: "pos", values: paa }; + var nor: TVertexArray = { attrib: "nor", values: naa }; + var indices: TIndexArray = { material: 0, values: inda }; + + var rawmesh: TMeshData = { name: "TempMesh" + (meshIndex++), vertex_arrays: [pos, nor], index_arrays: [indices], @@ -561,57 +562,61 @@ class ConvexBreaker { }; // Synchronous on Krom - var md = new MeshData(rawmesh, function(d:MeshData) {}); + var md = new MeshData(rawmesh, function(d: MeshData) {}); md.geom.calculateAABB(); return md; } } class UserData { - public var mass:Float; - public var friction:Float; - public var velocity:Vec4; - public var angularVelocity:Vec4; - public var breakable:Bool; - public var vertices:Array; - public var faces:Array; + public var mass: Float; + public var friction: Float; + public var velocity: Vec4; + public var angularVelocity: Vec4; + public var breakable: Bool; - public function new() { } + public var vertices: Array; + public var faces: Array; + + public function new() {} } class CutResult { - public var object1:MeshObject = null; - public var object2:MeshObject = null; - public function new() { } + + public var object1: MeshObject = null; + public var object2: MeshObject = null; + public function new() {} } class Line3 { - public var start:Vec4; - public var end:Vec4; + + public var start: Vec4; + public var end: Vec4; public function new() { start = new Vec4(); 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; - public function new() { } + public function new() {} - public function distanceToPoint(point:Vec4):Float { + public function distanceToPoint(point: Vec4): Float { 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(); @@ -619,17 +624,17 @@ class Plane { return this; } - public function set(normal:Vec4, point:Vec4):Plane { + public function set(normal: Vec4, point: Vec4): Plane { this.normal.setFrom(normal); constant = -point.dot(this.normal); return this; } - public function coplanarPoint(result:Vec4) { + public function coplanarPoint(result: Vec4): Vec4 { return result.setFrom(normal).mult(-constant); } - public function intersectLine(line:Line3):Vec4 { + public function intersectLine(line: Line3): Vec4 { var v1 = new Vec4(); var result = new Vec4(); var direction = line.delta(v1); @@ -658,7 +663,7 @@ class ConvexHull { public var face3s = new Array(); public var vertices = new Array(); - public function new(vertices:Array) { + public function new(vertices: Array) { for (i in 3...vertices.length) addPoint(i, vertices); @@ -702,7 +707,7 @@ class ConvexHull { } } - function addPoint(vertexId:Int, vertices:Array) { + function addPoint(vertexId: Int, vertices: Array) { var vertex = vertices[vertexId].clone(); var mag = vertex.length(); @@ -710,7 +715,7 @@ class ConvexHull { vertex.y += mag * randomOffset(); vertex.z += mag * randomOffset(); - var hole:Array> = []; + var hole: Array> = []; var f = 0; while (f < faces.length) { var face = faces[f]; @@ -749,7 +754,7 @@ class ConvexHull { } // Whether the face is visible from the vertex - function visible(face:Array, vertex:Vec4, vertices:Array) { + function visible(face: Array, vertex: Vec4, vertices: Array): 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,23 +773,23 @@ class ConvexHull { return cb; } - function equalEdge(ea:Array, eb:Array) { + function equalEdge(ea: Array, eb: Array): Bool { return ea[0] == eb[1] && ea[1] == eb[0]; } - function randomOffset() { + function randomOffset(): Float { return (Math.random() - 0.5) * 2 * 1e-6; } } class Face3 { - public var a:Int; - public var b:Int; - public var c:Int; - public var normal:Vec4; + public var a: Int; + public var b: Int; + public var c: Int; + public var normal: Vec4; - public function new(a:Int, b:Int, c:Int) { + public function new(a: Int, b: Int, c: Int) { this.a = a; this.b = b; this.c = c; diff --git a/Sources/armory/trait/PhysicsDrag.hx b/Sources/armory/trait/PhysicsDrag.hx index c809c0ed..4c9d58b6 100755 --- a/Sources/armory/trait/PhysicsDrag.hx +++ b/Sources/armory/trait/PhysicsDrag.hx @@ -14,12 +14,12 @@ class PhysicsDrag extends Trait { public function new() { super(); } #else - var pickConstraint:bullet.Bt.Generic6DofConstraint = null; - var pickDist:Float; - var pickedBody:RigidBody = null; + var pickConstraint: bullet.Bt.Generic6DofConstraint = null; + var pickDist: Float; + var pickedBody: RigidBody = null; - var rayFrom:bullet.Bt.Vector3; - var rayTo:bullet.Bt.Vector3; + var rayFrom: bullet.Bt.Vector3; + var rayTo: bullet.Bt.Vector3; static var v = new Vec4(); static var m = Mat4.identity(); @@ -39,7 +39,7 @@ class PhysicsDrag extends Trait { var mouse = Input.getMouse(); if (mouse.started()) { - + var b = physics.pickClosest(mouse.x, mouse.y); if (b != null && b.mass > 0 && !b.body.isKinematicObject() && b.object.getTrait(PhysicsDrag) != null) { diff --git a/Sources/armory/trait/SimpleMoveObject.hx b/Sources/armory/trait/SimpleMoveObject.hx index 0b228cc3..2479cb03 100644 --- a/Sources/armory/trait/SimpleMoveObject.hx +++ b/Sources/armory/trait/SimpleMoveObject.hx @@ -11,10 +11,10 @@ import armory.trait.physics.RigidBody; class SimpleMoveObject extends iron.Trait { @prop - var speed:Float = 0.1; + var speed: Float = 0.1; - var keyboard:Keyboard; - var rb:RigidBody; + var keyboard: Keyboard; + var rb: RigidBody; public function new() { super(); @@ -57,7 +57,7 @@ class SimpleMoveObject extends iron.Trait { }); } - function moveObject(vec:Vec4){ + function moveObject(vec: Vec4){ if (rb != null) { #if arm_physics rb.setLinearVelocity(0, 0, 0); diff --git a/Sources/armory/trait/SimpleRotateObject.hx b/Sources/armory/trait/SimpleRotateObject.hx index 1050360f..dd223821 100644 --- a/Sources/armory/trait/SimpleRotateObject.hx +++ b/Sources/armory/trait/SimpleRotateObject.hx @@ -11,10 +11,10 @@ import armory.trait.physics.RigidBody; class SimpleRotateObject extends iron.Trait { @prop - var speed:Float = 0.01; + var speed: Float = 0.01; - var keyboard:Keyboard; - var rb:RigidBody; + var keyboard: Keyboard; + var rb: RigidBody; public function new() { super(); @@ -57,7 +57,7 @@ class SimpleRotateObject extends iron.Trait { }); } - function rotateObject(vec:Vec4){ + function rotateObject(vec: Vec4){ if (rb != null) { #if arm_physics rb.setAngularVelocity(0, 0, 0); diff --git a/Sources/armory/trait/SimpleScaleObject.hx b/Sources/armory/trait/SimpleScaleObject.hx index 7f69cd1d..646beb22 100644 --- a/Sources/armory/trait/SimpleScaleObject.hx +++ b/Sources/armory/trait/SimpleScaleObject.hx @@ -14,11 +14,11 @@ import armory.trait.physics.KinematicCharacterController; class SimpleScaleObject extends iron.Trait { @prop - var speed:Float = 0.1; + var speed: Float = 0.1; - var keyboard:Keyboard; - var rb:RigidBody; - var character:KinematicCharacterController; + var keyboard: Keyboard; + var rb: RigidBody; + var character: KinematicCharacterController; public function new() { super(); @@ -70,7 +70,7 @@ class SimpleScaleObject extends iron.Trait { }); } - function scaleObject(vec:Vec4){ + function scaleObject(vec: Vec4){ var s = object.transform.scale; if (rb != null) { #if arm_physics diff --git a/Sources/armory/trait/ThirdPersonController.hx b/Sources/armory/trait/ThirdPersonController.hx index 6ae25ba2..c834f786 100755 --- a/Sources/armory/trait/ThirdPersonController.hx +++ b/Sources/armory/trait/ThirdPersonController.hx @@ -12,13 +12,13 @@ class ThirdPersonController extends CameraController { public function new() { super(); } #else - static inline var rotationSpeed = 1.0; + static inline var rotationSpeed = 1.0; - var animObject:String; - var idleAction:String; - var runAction:String; - var currentAction:String; - var arm:Object; + var animObject: String; + var idleAction: String; + var runAction: String; + var currentAction: String; + var arm: Object; public function new(animObject = "", idle = "idle", run = "run") { super(); @@ -31,7 +31,7 @@ class ThirdPersonController extends CameraController { iron.Scene.active.notifyOnInit(init); } - function findAnimation(o:Object):Object { + function findAnimation(o: Object): Object { if (o.animation != null) return o; for (c in o.children) { var co = findAnimation(c); @@ -39,7 +39,7 @@ class ThirdPersonController extends CameraController { } return null; } - + function init() { if (animObject == "") arm = findAnimation(object); else arm = object.getChild(animObject); @@ -53,7 +53,7 @@ class ThirdPersonController extends CameraController { var zVec = Vec4.zAxis(); function preUpdate() { if (Input.occupied || !body.ready) return; - + var mouse = Input.getMouse(); if (mouse.down()) { camera.transform.rotate(xVec, mouse.movementY / 250 * rotationSpeed); @@ -87,7 +87,7 @@ class ThirdPersonController extends CameraController { if (moveForward || moveBackward || moveLeft || moveRight) { if (currentAction != runAction) { arm.animation.play(runAction, null, 0.2); - currentAction = runAction; + currentAction = runAction; } dir.mult(-4 * 0.7); body.activate(); diff --git a/Sources/armory/trait/VehicleBody.hx b/Sources/armory/trait/VehicleBody.hx index 2413fce8..2bed4dc9 100755 --- a/Sources/armory/trait/VehicleBody.hx +++ b/Sources/armory/trait/VehicleBody.hx @@ -13,18 +13,18 @@ class VehicleBody extends Trait { public function new() { super(); } #else - @prop var wheel0Name:String = "Wheel0"; - @prop var wheel1Name:String = "Wheel1"; - @prop var wheel2Name:String = "Wheel2"; - @prop var wheel3Name:String = "Wheel3"; + @prop var wheel0Name: String = "Wheel0"; + @prop var wheel1Name: String = "Wheel1"; + @prop var wheel2Name: String = "Wheel2"; + @prop var wheel3Name: String = "Wheel3"; - var physics:PhysicsWorld; - var transform:Transform; - var camera:CameraObject; + var physics: PhysicsWorld; + var transform: Transform; + var camera: CameraObject; - var wheels:Array = []; - var vehicle:bullet.Bt.RaycastVehicle = null; - var carChassis:bullet.Bt.RigidBody; + var wheels: Array = []; + var vehicle: bullet.Bt.RaycastVehicle = null; + var carChassis: bullet.Bt.RigidBody; var chassis_mass = 600.0; var wheelFriction = 1000; @@ -64,7 +64,7 @@ class VehicleBody extends Trait { transform.dim.z / 2)); var compound = new bullet.Bt.CompoundShape(); - + var localTrans = new bullet.Bt.Transform(); localTrans.setIdentity(); localTrans.setOrigin(new bullet.Bt.Vector3(0, 0, 1)); @@ -82,8 +82,8 @@ class VehicleBody extends Trait { carChassis.setActivationState(bullet.Bt.CollisionObject.DISABLE_DEACTIVATION); // Choose coordinate system - var rightIndex = 0; - var upIndex = 2; + var rightIndex = 0; + var upIndex = 2; var forwardIndex = 1; vehicle.setCoordinateSystem(rightIndex, upIndex, forwardIndex); @@ -161,7 +161,7 @@ class VehicleBody extends Trait { for (i in 0...vehicle.getNumWheels()) { // Synchronize the wheels with the chassis worldtransform vehicle.updateWheelTransform(i, true); - + // Update wheels transforms var trans = vehicle.getWheelTransformWS(i); var p = trans.getOrigin(); @@ -186,14 +186,14 @@ class VehicleBody extends Trait { camera.buildMatrix(); } - function createRigidBody(mass:Float, shape:bullet.Bt.CompoundShape):bullet.Bt.RigidBody { - + function createRigidBody(mass: Float, shape: bullet.Bt.CompoundShape): bullet.Bt.RigidBody { + var localInertia = new bullet.Bt.Vector3(0, 0, 0); shape.calculateLocalInertia(mass, localInertia); var centerOfMassOffset = new bullet.Bt.Transform(); centerOfMassOffset.setIdentity(); - + var startTransform = new bullet.Bt.Transform(); startTransform.setIdentity(); startTransform.setOrigin(new bullet.Bt.Vector3( @@ -208,7 +208,7 @@ class VehicleBody extends Trait { var myMotionState = new bullet.Bt.DefaultMotionState(startTransform, centerOfMassOffset); var cInfo = new bullet.Bt.RigidBodyConstructionInfo(mass, myMotionState, shape, localInertia); - + var body = new bullet.Bt.RigidBody(cInfo); body.setLinearVelocity(new bullet.Bt.Vector3(0, 0, 0)); body.setAngularVelocity(new bullet.Bt.Vector3(0, 0, 0)); @@ -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 } @@ -238,18 +238,18 @@ class VehicleBody extends Trait { class VehicleWheel { #if (!arm_bullet) - public function new() { } + public function new() {} #else - public var isFrontWheel:Bool; - public var wheelRadius:Float; - public var wheelWidth:Float; + public var isFrontWheel: Bool; + public var wheelRadius: Float; + public var wheelWidth: Float; - var locX:Float; - var locY:Float; - var locZ:Float; + var locX: Float; + var locY: Float; + var locZ: Float; - public function new(id:Int, transform:Transform, vehicleTransform:Transform) { + public function new(id: Int, transform: Transform, vehicleTransform: Transform) { wheelRadius = transform.dim.z / 2; wheelWidth = transform.dim.x > transform.dim.y ? transform.dim.y : transform.dim.x; @@ -258,7 +258,7 @@ class VehicleWheel { locZ = vehicleTransform.dim.z / 2 + transform.loc.z; } - public function getConnectionPoint():bullet.Bt.Vector3 { + public function getConnectionPoint(): bullet.Bt.Vector3 { return new bullet.Bt.Vector3(locX, locY, locZ); } #end diff --git a/Sources/armory/trait/VirtualGamepad.hx b/Sources/armory/trait/VirtualGamepad.hx index d6297657..2ab44b5a 100644 --- a/Sources/armory/trait/VirtualGamepad.hx +++ b/Sources/armory/trait/VirtualGamepad.hx @@ -8,7 +8,7 @@ import iron.math.Vec2; @:access(iron.system.Gamepad) class VirtualGamepad extends Trait { - var gamepad:Gamepad; + var gamepad: Gamepad; var leftPadX = 0; var leftPadY = 0; @@ -121,9 +121,9 @@ class VirtualGamepad extends Trait { rightStickYLast = rightStickY; } - function render2D(g:kha.graphics2.Graphics) { + function render2D(g: kha.graphics2.Graphics) { var r = radius; - + g.color = 0xffaaaaaa; kha.graphics2.GraphicsExtension.fillCircle(g, leftPadX, leftPadY, r); diff --git a/Sources/armory/trait/WalkNavigation.hx b/Sources/armory/trait/WalkNavigation.hx index 7cec18a6..8dd4a2f3 100755 --- a/Sources/armory/trait/WalkNavigation.hx +++ b/Sources/armory/trait/WalkNavigation.hx @@ -15,11 +15,11 @@ class WalkNavigation extends Trait { var yvec = new Vec4(); var ease = 1.0; - var camera:CameraObject; + var camera: CameraObject; - var keyboard:Keyboard; - var gamepad:Gamepad; - var mouse:Mouse; + var keyboard: Keyboard; + var gamepad: Gamepad; + var mouse: Mouse; public function new() { super(); @@ -34,7 +34,7 @@ class WalkNavigation extends Trait { try { camera = cast(object, CameraObject); } - catch(msg:String) { + catch (msg: String) { trace("Error occurred: " + msg + "\nWalkNavigation trait should be used with a camera object."); } @@ -89,7 +89,7 @@ class WalkNavigation extends Trait { } } } - + if (moveForward || moveBackward || strafeRight || strafeLeft || strafeUp || strafeDown) { ease += Time.delta * 15; if (ease > 1.0) ease = 1.0; @@ -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 } diff --git a/Sources/armory/trait/internal/Bridge.hx b/Sources/armory/trait/internal/Bridge.hx index 3c782906..1ce35562 100644 --- a/Sources/armory/trait/internal/Bridge.hx +++ b/Sources/armory/trait/internal/Bridge.hx @@ -11,7 +11,7 @@ class Bridge { public static var Input = iron.system.Input; public static var Object = iron.object.Object; public static var Data = iron.data.Data; - public static function log(s:String) { trace(s); }; + public static function log(s: String) { trace(s); }; } #end diff --git a/Sources/armory/trait/internal/CameraController.hx b/Sources/armory/trait/internal/CameraController.hx index dfa0d264..995d79df 100755 --- a/Sources/armory/trait/internal/CameraController.hx +++ b/Sources/armory/trait/internal/CameraController.hx @@ -12,9 +12,9 @@ class CameraController extends Trait { public function new() { super(); } #else - var transform:Transform; - var body:RigidBody; - var camera:CameraObject; + var transform: Transform; + var body: RigidBody; + var camera: CameraObject; var moveForward = false; var moveBackward = false; @@ -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 } diff --git a/Sources/armory/trait/internal/CanvasScript.hx b/Sources/armory/trait/internal/CanvasScript.hx index 4abcfd79..4b3b97d0 100644 --- a/Sources/armory/trait/internal/CanvasScript.hx +++ b/Sources/armory/trait/internal/CanvasScript.hx @@ -11,20 +11,21 @@ class CanvasScript extends Trait { #if arm_ui var cui: Zui; - var canvas:TCanvas = null; + var canvas: TCanvas = null; - public var ready(get, null):Bool; - function get_ready():Bool { return canvas != null; } + public var ready(get, null): Bool; + function get_ready(): Bool { return canvas != null; } - public function new(canvasName:String, font:String = "font_default.ttf") { + 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."); } @@ -32,18 +33,17 @@ class CanvasScript extends Trait { Canvas.themes.push(zui.Themes.light); } - iron.data.Data.getFont(font, function(f:kha.Font) { - var c:TCanvas = haxe.Json.parse(blob.toString()); + iron.data.Data.getFont(font, function(f: kha.Font) { + var c: TCanvas = haxe.Json.parse(blob.toString()); if (c.theme == null) c.theme = Canvas.themes[0].NAME; 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; - iron.data.Data.getImage(file, function(image:kha.Image) { + iron.data.Data.getImage(file, function(image: kha.Image) { Canvas.assetMap.set(asset.id, image); if (++loaded >= c.assets.length) canvas = c; }); @@ -53,7 +53,7 @@ class CanvasScript extends Trait { }); }); - notifyOnRender2D(function(g:kha.graphics2.Graphics) { + notifyOnRender2D(function(g: kha.graphics2.Graphics) { if (canvas == null) return; var events = Canvas.draw(cui, canvas, g); @@ -67,37 +67,37 @@ class CanvasScript extends Trait { }); } - var onReady:Void->Void = null; - public function notifyOnReady(f:Void->Void) { + var onReady: Void->Void = null; + public function notifyOnReady(f: Void->Void) { onReady = f; } // Defines layout - public function getElement(name:String):TElement { + public function getElement(name: String): TElement { for (e in canvas.elements) if (e.name == name) return e; return null; } // Returns canvas array of elements - public function getElements():Array { + public function getElements(): Array { return canvas.elements; } // Set visibility of all elements of canvas public function setCanvasVisibility(bool: Bool){ - for(e in canvas.elements) e.visible = bool; + for (e in canvas.elements) e.visible = bool; } // Contains data @:access(zui.Canvas) @:access(zui.Handle) - public function getHandle(name:String):Handle { + public function getHandle(name: String): Handle { // Consider this a temporary solution return Canvas.h.children[getElement(name).id]; } #else - public function new(canvasName:String) { super(); } + public function new(canvasName: String) { super(); } #end } diff --git a/Sources/armory/trait/internal/DebugConsole.hx b/Sources/armory/trait/internal/DebugConsole.hx index a5563153..fad0b199 100755 --- a/Sources/armory/trait/internal/DebugConsole.hx +++ b/Sources/armory/trait/internal/DebugConsole.hx @@ -20,7 +20,7 @@ class DebugConsole extends Trait { #else public var visible = true; - var ui:Zui; + var ui: Zui; var scaleFactor = 1.0; var lastTime = 0.0; @@ -39,27 +39,27 @@ class DebugConsole extends Trait { var animTimeAvg = 0.0; var physTime = 0.0; var physTimeAvg = 0.0; - var graph:kha.Image = null; - var graphA:kha.Image = null; - var graphB:kha.Image = null; + var graph: kha.Image = null; + var graphA: kha.Image = null; + var graphB: kha.Image = null; var benchmark = false; var benchFrames = 0; var benchTime = 0.0; - var selectedObject:iron.object.Object; + var selectedObject: iron.object.Object; var selectedType = ""; - static var lrow = [1/2, 1/2]; - static var row4 = [1/4, 1/4, 1/4, 1/4]; + static var lrow = [1 / 2, 1 / 2]; + static var row4 = [1 / 4, 1 / 4, 1 / 4, 1 / 4]; public static var debugFloat = 1.0; - public static var watchNodes:Array = []; + public static var watchNodes: Array = []; public function new(scaleFactor = 1.0) { super(); 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); @@ -78,12 +78,12 @@ class DebugConsole extends Trait { var debugDrawSet = false; - function selectObject(o:iron.object.Object) { + function selectObject(o: iron.object.Object) { selectedObject = o; if (!debugDrawSet) { debugDrawSet = true; - armory.trait.internal.DebugDraw.notifyOnRender(function(draw:armory.trait.internal.DebugDraw) { + armory.trait.internal.DebugDraw.notifyOnRender(function(draw: armory.trait.internal.DebugDraw) { if (selectedObject != null) draw.bounds(selectedObject.transform); }); } @@ -113,15 +113,15 @@ class DebugConsole extends Trait { graph.g2.end(); } - static var haxeTrace:Dynamic->haxe.PosInfos->Void = null; - static var lastTraces:Array = ['']; - static function consoleTrace(v:Dynamic, ?inf:haxe.PosInfos) { + static var haxeTrace: Dynamic->haxe.PosInfos->Void = null; + static var lastTraces: Array = [""]; + static function consoleTrace(v: Dynamic, ?inf: haxe.PosInfos) { lastTraces.unshift(Std.string(v)); if (lastTraces.length > 10) lastTraces.pop(); haxeTrace(v, inf); } - function render2D(g:kha.graphics2.Graphics) { + function render2D(g: kha.graphics2.Graphics) { if (!visible) return; var hwin = Id.handle(); var htab = Id.handle({position: 0}); @@ -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 + function drawList(h: zui.Zui.Handle, o: iron.object.Object) { + if (o.name.charAt(0) == ".") return; // Hidden var b = false; if (selectedObject == o) { ui.g.color = 0xff205d9c; @@ -154,7 +154,7 @@ class DebugConsole extends Trait { ui.g.color = 0xffffffff; } if (o.children.length > 0) { - ui.row([1/13, 12/13]); + ui.row([1 / 13, 12 / 13]); b = ui.panel(h.nest(i, {selected: true}), "", true); ui.text(o.name); } @@ -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,22 +437,22 @@ 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")) { try { trace("> " + t); js.Lib.eval(t); } - catch(e:Dynamic) { trace(e); } + catch (e: Dynamic) { trace(e); } } 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)); } } @@ -523,7 +523,7 @@ class DebugConsole extends Trait { #end } - static function roundfp(f:Float, precision = 2):Float { + static function roundfp(f: Float, precision = 2): Float { f *= Math.pow(10, precision); return Math.round(f) / Math.pow(10, precision); } diff --git a/Sources/armory/trait/internal/DebugDraw.hx b/Sources/armory/trait/internal/DebugDraw.hx index 7913d093..34510dd7 100644 --- a/Sources/armory/trait/internal/DebugDraw.hx +++ b/Sources/armory/trait/internal/DebugDraw.hx @@ -16,20 +16,20 @@ import iron.math.Mat4; class DebugDraw { - static var inst:DebugDraw = null; + static var inst: DebugDraw = null; - public var color:kha.Color = 0xffff0000; + public var color: kha.Color = 0xffff0000; public var strength = 0.02; - var vertexBuffer:VertexBuffer; - var indexBuffer:IndexBuffer; - var pipeline:PipelineState; + var vertexBuffer: VertexBuffer; + var indexBuffer: IndexBuffer; + var pipeline: PipelineState; - var vp:Mat4; - var vpID:ConstantLocation; + var vp: Mat4; + var vpID: ConstantLocation; - var vbData:kha.arrays.Float32Array; - var ibData:kha.arrays.Uint32Array; + var vbData: kha.arrays.Float32Array; + var ibData: kha.arrays.Uint32Array; static inline var maxLines = 300; static inline var maxVertices = maxLines * 4; @@ -38,7 +38,7 @@ class DebugDraw { function new() { inst = this; - + var structure = new VertexStructure(); structure.add("pos", VertexData.Float3); structure.add("col", VertexData.Float3); @@ -61,11 +61,11 @@ class DebugDraw { indexBuffer = new IndexBuffer(maxIndices, Usage.DynamicUsage); } - static var g:kha.graphics4.Graphics; + static var g: kha.graphics4.Graphics; - public static function notifyOnRender(f:DebugDraw->Void) { + public static function notifyOnRender(f: DebugDraw->Void) { if (inst == null) inst = new DebugDraw(); - iron.RenderPath.notifyOnContext("mesh", function(g4:kha.graphics4.Graphics, i:Int, len:Int) { + iron.RenderPath.notifyOnContext("mesh", function(g4: kha.graphics4.Graphics, i: Int, len: Int) { g = g4; if (i == 0) inst.begin(); f(inst); @@ -73,16 +73,16 @@ class DebugDraw { }); } - static var v:Vec4; + static var v: Vec4; static var vx = new Vec4(); static var vy = new Vec4(); static var vz = new Vec4(); - public function bounds(t:iron.object.Transform) { + public function bounds(t: iron.object.Transform) { v = t.world.getLoc(); var dx = t.dim.x / 2; var dy = t.dim.y / 2; var dz = t.dim.z / 2; - + var up = t.world.up(); var look = t.world.look(); var right = t.world.right(); @@ -96,7 +96,7 @@ class DebugDraw { vy.mult(dy); vz.setFrom(up); vz.mult(dz); - + lineb(-1, -1, -1, 1, -1, -1); lineb(-1, 1, -1, 1, 1, -1); lineb(-1, -1, 1, 1, -1, 1); @@ -116,7 +116,7 @@ class DebugDraw { static var v1 = new Vec4(); static var v2 = new Vec4(); static var t = new Vec4(); - function lineb(a:Int, b:Int, c:Int, d:Int, e:Int, f:Int) { + function lineb(a: Int, b: Int, c: Int, d: Int, e: Int, f: Int) { v1.setFrom(v); t.setFrom(vx); t.mult(a); v1.add(t); t.setFrom(vy); t.mult(b); v1.add(t); @@ -130,12 +130,12 @@ class DebugDraw { linev(v1, v2); } - public inline function linev(v1:Vec4, v2:Vec4) { + public inline function linev(v1: Vec4, v2: Vec4) { line(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z); } - public function line(x1:Float, y1:Float, z1:Float, x2:Float, y2:Float, z2:Float) { - + public function line(x1: Float, y1: Float, z1: Float, x2: Float, y2: Float, z2: Float) { + if (lines >= maxLines) { end(); begin(); } var camera = iron.Scene.active.camera; @@ -191,7 +191,7 @@ class DebugDraw { function end() { vertexBuffer.unlock(); indexBuffer.unlock(); - + g.setVertexBuffer(vertexBuffer); g.setIndexBuffer(indexBuffer); g.setPipeline(pipeline); diff --git a/Sources/armory/trait/internal/LivePatch.hx b/Sources/armory/trait/internal/LivePatch.hx index 70a2a4b2..220d42ba 100644 --- a/Sources/armory/trait/internal/LivePatch.hx +++ b/Sources/armory/trait/internal/LivePatch.hx @@ -12,9 +12,9 @@ class LivePatch extends iron.Trait { } function update() { - kha.Assets.loadBlobFromPath("krom.patch", function(b:kha.Blob) { + 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; diff --git a/Sources/armory/trait/internal/LoadingScreen.hx b/Sources/armory/trait/internal/LoadingScreen.hx index 98b849ae..953897e4 100644 --- a/Sources/armory/trait/internal/LoadingScreen.hx +++ b/Sources/armory/trait/internal/LoadingScreen.hx @@ -4,7 +4,7 @@ package armory.trait.internal; class LoadingScreen { - public static function render(g:kha.graphics2.Graphics, assetsLoaded:Int, assetsTotal:Int) { + public static function render(g: kha.graphics2.Graphics, assetsLoaded: Int, assetsTotal: Int) { g.color = 0xffcf2b43; g.fillRect(0, iron.App.h() - 6, iron.App.w() / assetsTotal * assetsLoaded, 6); } diff --git a/Sources/armory/trait/internal/MovieTexture.hx b/Sources/armory/trait/internal/MovieTexture.hx index 210fe209..1a3dc03a 100644 --- a/Sources/armory/trait/internal/MovieTexture.hx +++ b/Sources/armory/trait/internal/MovieTexture.hx @@ -7,11 +7,11 @@ import iron.object.MeshObject; class MovieTexture extends Trait { - var video:Video; - public static var image:Image; + var video: Video; + public static var image: Image; public static var created = false; - - var videoName:String; + + var videoName: String; function pow(pow: Int): Int { var ret = 1; @@ -21,16 +21,16 @@ class MovieTexture extends Trait { function getPower2(i: Int): Int { var power = 0; - while(true) { + while (true) { var res = pow(power); if (res >= i) return res; power++; } } - public function new(videoName:String) { + public function new(videoName: String) { super(); - + this.videoName = videoName; if (!created) { @@ -40,7 +40,7 @@ class MovieTexture extends Trait { } function init() { - iron.data.Data.getVideo(videoName, function(vid:kha.Video) { + iron.data.Data.getVideo(videoName, function(vid: kha.Video) { video = vid; video.play(true); @@ -51,16 +51,16 @@ class MovieTexture extends Trait { notifyOnRender2D(render); }); } - - function render(g:kha.graphics2.Graphics) { + + function render(g: kha.graphics2.Graphics) { g.end(); - + var g2 = image.g2; g2.begin(true, 0xff000000); g2.color = 0xffffffff; g2.drawVideo(video, 0, 0, image.width, image.height); g2.end(); - + g.begin(false); } } diff --git a/Sources/armory/trait/internal/WasmScript.hx b/Sources/armory/trait/internal/WasmScript.hx index f0d856ee..2e1f0a0f 100644 --- a/Sources/armory/trait/internal/WasmScript.hx +++ b/Sources/armory/trait/internal/WasmScript.hx @@ -8,31 +8,32 @@ import iron.system.Input; import iron.system.Time; class WasmScript extends iron.Trait { - var wasm:Wasm; - var objectMap:Map = new Map(); + var wasm: Wasm; - public function new(handle:String) { + var objectMap: Map = new Map(); + + public function new(handle: String) { super(); // Armory API exposed to WebAssembly // TODO: static /*static*/ var imports = { env: { - trace: function(i:Int) { trace(wasm.getString(i)); }, - tracef: function(f:Float) { trace(f); }, - tracei: function(i:Int) { trace(i); }, - - notify_on_update: function(i:Int) { notifyOnUpdate(wasm.exports.update); }, - remove_update: function(i:Int) { removeUpdate(wasm.exports.update); }, - get_object: function(name:Int) { + trace: function(i: Int) { trace(wasm.getString(i)); }, + tracef: function(f: Float) { trace(f); }, + tracei: function(i: Int) { trace(i); }, + + notify_on_update: function(i: Int) { notifyOnUpdate(wasm.exports.update); }, + remove_update: function(i: Int) { removeUpdate(wasm.exports.update); }, + get_object: function(name: Int) { var s = wasm.getString(name); var o = iron.Scene.active.getChild(s); if (o == null) return -1; objectMap.set(o.uid, o); return o.uid; }, - set_transform: function(object:Int, x:Float, y:Float, z:Float, rx:Float, ry:Float, rz:Float, sx:Float, sy:Float, sz:Float) { + set_transform: function(object: Int, x: Float, y: Float, z: Float, rx: Float, ry: Float, rz: Float, sx: Float, sy: Float, sz: Float) { var o = objectMap.get(object); if (o == null) return; var t = o.transform; @@ -40,19 +41,19 @@ class WasmScript extends iron.Trait { t.scale.set(sx, sy, sz); t.setRotation(rx, ry, rz); }, - set_location: function(object:Int, x:Float, y:Float, z:Float) { + set_location: function(object: Int, x: Float, y: Float, z: Float) { var o = objectMap.get(object); if (o == null) return; var t = o.transform; t.loc.set(x, y, z); }, - set_scale: function(object:Int, x:Float, y:Float, z:Float) { + set_scale: function(object: Int, x: Float, y: Float, z: Float) { var o = objectMap.get(object); if (o == null) return; var t = o.transform; t.scale.set(x, y, z); }, - set_rotation: function(object:Int, x:Float, y:Float, z:Float) { + set_rotation: function(object: Int, x: Float, y: Float, z: Float) { var o = objectMap.get(object); if (o == null) return; var t = o.transform; @@ -61,24 +62,24 @@ class WasmScript extends iron.Trait { mouse_x: function() { return Input.getMouse().x; }, mouse_y: function() { return Input.getMouse().y; }, - mouse_started: function(button:Int) { return Input.getMouse().started(); }, - mouse_down: function(button:Int) { return Input.getMouse().down(); }, - mouse_released: function(button:Int) { return Input.getMouse().released(); }, - key_started: function(key:Int) { return Input.getKeyboard().started(Keyboard.keyCode(cast key)); }, - key_down: function(key:Int) { return Input.getKeyboard().down(Keyboard.keyCode(cast key)); }, - key_released: function(key:Int) { return Input.getKeyboard().released(Keyboard.keyCode(cast key)); }, - + mouse_started: function(button: Int) { return Input.getMouse().started(); }, + mouse_down: function(button: Int) { return Input.getMouse().down(); }, + mouse_released: function(button: Int) { return Input.getMouse().released(); }, + key_started: function(key: Int) { return Input.getKeyboard().started(Keyboard.keyCode(cast key)); }, + key_down: function(key: Int) { return Input.getKeyboard().down(Keyboard.keyCode(cast key)); }, + key_released: function(key: Int) { return Input.getKeyboard().released(Keyboard.keyCode(cast key)); }, + time_real: function() { return Time.time(); }, time_delta: function() { return Time.delta; }, - - js_eval: function(fn:Int) { js.Lib.eval(wasm.getString(fn)); }, - js_call_object: function(object:Int, fn:Int) { Reflect.callMethod(objectMap.get(object), Reflect.field(objectMap.get(object), wasm.getString(fn)), null); }, - js_call_static: function(path:Int, fn:Int) { var cpath = wasm.getString(path); var ctype = Type.resolveClass(cpath); Reflect.callMethod(ctype, Reflect.field(ctype, wasm.getString(fn)), []); }, + + js_eval: function(fn: Int) { js.Lib.eval(wasm.getString(fn)); }, + js_call_object: function(object: Int, fn: Int) { Reflect.callMethod(objectMap.get(object), Reflect.field(objectMap.get(object), wasm.getString(fn)), null); }, + js_call_static: function(path: Int, fn: Int) { var cpath = wasm.getString(path); var ctype = Type.resolveClass(cpath); Reflect.callMethod(ctype, Reflect.field(ctype, wasm.getString(fn)), []); }, }, }; - Data.getBlob(handle + ".wasm", function(b:kha.Blob) { + Data.getBlob(handle + ".wasm", function(b: kha.Blob) { wasm = Wasm.instance(b, imports); wasm.exports.main(); }); diff --git a/Sources/armory/trait/navigation/Navigation.hx b/Sources/armory/trait/navigation/Navigation.hx index b8e7d0bc..99ab5f6a 100644 --- a/Sources/armory/trait/navigation/Navigation.hx +++ b/Sources/armory/trait/navigation/Navigation.hx @@ -11,10 +11,10 @@ class Navigation extends iron.Trait { public function new() { super(); } #else - public static var active:Navigation = null; - - public var navMeshes:Array = []; - public var recast:Recast; + public static var active: Navigation = null; + + public var navMeshes: Array = []; + public var recast: Recast; public function new() { super(); diff --git a/Sources/armory/trait/physics/bullet/KinematicCharacterController.hx b/Sources/armory/trait/physics/bullet/KinematicCharacterController.hx index 40ccfccc..520f3a2f 100644 --- a/Sources/armory/trait/physics/bullet/KinematicCharacterController.hx +++ b/Sources/armory/trait/physics/bullet/KinematicCharacterController.hx @@ -10,38 +10,38 @@ import iron.object.MeshObject; class KinematicCharacterController extends Trait { - var shape:ControllerShape; - var shapeConvex:bullet.Bt.ConvexShape; - var shapeConvexHull:bullet.Bt.ConvexHullShape; + var shape: ControllerShape; + var shapeConvex: bullet.Bt.ConvexShape; + var shapeConvexHull: bullet.Bt.ConvexHullShape; var isConvexHull = false; - public var physics:PhysicsWorld; - public var transform:Transform = null; - public var mass:Float; - public var friction:Float; - public var restitution:Float; - public var collisionMargin:Float; - public var animated:Bool; + public var physics: PhysicsWorld; + public var transform: Transform = null; + public var mass: Float; + public var friction: Float; + public var restitution: Float; + public var collisionMargin: Float; + public var animated: Bool; public var group = 1; - var bodyScaleX:Float; // Transform scale at creation time - var bodyScaleY:Float; - var bodyScaleZ:Float; - var currentScaleX:Float; - var currentScaleY:Float; - var currentScaleZ:Float; - var jumpSpeed:Float; + var bodyScaleX: Float; // Transform scale at creation time + var bodyScaleY: Float; + var bodyScaleZ: Float; + var currentScaleX: Float; + var currentScaleY: Float; + var currentScaleZ: Float; + var jumpSpeed: Float; - public var body:bullet.Bt.PairCachingGhostObject = null; - public var character:bullet.Bt.KinematicCharacterController = null; + public var body: bullet.Bt.PairCachingGhostObject = null; + public var character: bullet.Bt.KinematicCharacterController = null; public var ready = false; static var nextId = 0; public var id = 0; - public var onReady:Void->Void = null; + public var onReady: Void->Void = null; static var nullvec = true; - static var vec1:bullet.Bt.Vector3; - static var quat1:bullet.Bt.Quaternion; - static var trans1:bullet.Bt.Transform; + static var vec1: bullet.Bt.Vector3; + static var quat1: bullet.Bt.Quaternion; + static var trans1: bullet.Bt.Transform; static var quat = new Quat(); static inline var CF_CHARACTER_OBJECT = 16; @@ -71,11 +71,11 @@ class KinematicCharacterController extends Trait { notifyOnRemove(removeFromWorld); } - inline function withMargin(f:Float):Float { + inline function withMargin(f: Float): Float { return f - f * collisionMargin; } - public function notifyOnReady(f:Void->Void) { + public function notifyOnReady(f: Void->Void) { onReady = f; if (ready) onReady(); } @@ -99,8 +99,8 @@ class KinematicCharacterController extends Trait { } else if (shape == ControllerShape.Sphere) { var width = transform.dim.x; - if(transform.dim.y > width) width = transform.dim.y; - if(transform.dim.z > width) width = transform.dim.z; + if (transform.dim.y > width) width = transform.dim.y; + if (transform.dim.z > width) width = transform.dim.z; shapeConvex = new bullet.Bt.SphereShape(withMargin(width / 2)); } else if (shape == ControllerShape.ConvexHull && mass > 0) { @@ -195,51 +195,51 @@ class KinematicCharacterController extends Trait { } } - public function canJump():Bool { + public function canJump(): Bool { return character.canJump(); } - public function onGround():Bool { + public function onGround(): Bool { return character.onGround(); } - public function setJumpSpeed(jumpSpeed:Float) { + public function setJumpSpeed(jumpSpeed: Float) { character.setJumpSpeed(jumpSpeed); } - public function setFallSpeed(fallSpeed:Float) { + public function setFallSpeed(fallSpeed: Float) { character.setFallSpeed(fallSpeed); } - public function setMaxSlope(slopeRadians:Float) { + public function setMaxSlope(slopeRadians: Float) { return character.setMaxSlope(slopeRadians); } - public function getMaxSlope():Float { + public function getMaxSlope(): Float { return character.getMaxSlope(); } - public function setMaxJumpHeight(maxJumpHeight:Float) { + public function setMaxJumpHeight(maxJumpHeight: Float) { character.setMaxJumpHeight(maxJumpHeight); } - public function setWalkDirection(walkDirection:Vec4) { + public function setWalkDirection(walkDirection: Vec4) { vec1.setX(walkDirection.x); vec1.setY(walkDirection.y); vec1.setZ(walkDirection.z); character.setWalkDirection(vec1); } - public function setUpInterpolate(value:Bool) { + public function setUpInterpolate(value: Bool) { character.setUpInterpolate(value); } #if js - public function jump():Void{ + public function jump(): Void{ character.jump(); } #elseif cpp - public function jump(v:Vec4):Void{ + public function jump(v: Vec4): Void{ vec1.setX(v.x); vec1.setY(v.y); vec1.setZ(v.z); @@ -278,11 +278,11 @@ class KinematicCharacterController extends Trait { } #if js - public function setGravity(f:Float) { + public function setGravity(f: Float) { character.setGravity(f); } #elseif cpp - public function setGravity(v:Vec4) { + public function setGravity(v: Vec4) { vec1.setX(v.x); vec1.setY(v.y); vec1.setZ(v.z); @@ -290,11 +290,11 @@ class KinematicCharacterController extends Trait { } #end - public function setActivationState(newState:Int) { + public function setActivationState(newState: Int) { body.setActivationState(newState); } - public function setFriction(f:Float) { + public function setFriction(f: Float) { body.setFriction(f); body.setRollingFriction(f); this.friction = f; @@ -318,7 +318,7 @@ class KinematicCharacterController extends Trait { activate(); } - function setScale(v:Vec4) { + function setScale(v: Vec4) { currentScaleX = v.x; currentScaleY = v.y; currentScaleZ = v.z; @@ -330,7 +330,7 @@ class KinematicCharacterController extends Trait { physics.world.updateSingleAabb(body); } - function addPointsToConvexHull(shape:bullet.Bt.ConvexHullShape, scale:Vec4, margin:Float) { + function addPointsToConvexHull(shape: bullet.Bt.ConvexHullShape, scale: Vec4, margin: Float) { var positions = cast(object, MeshObject).data.geom.positions; var sx = scale.x * (1.0 - margin); diff --git a/Sources/armory/trait/physics/bullet/PhysicsConstraint.hx b/Sources/armory/trait/physics/bullet/PhysicsConstraint.hx index 58d65c4c..10ebb224 100644 --- a/Sources/armory/trait/physics/bullet/PhysicsConstraint.hx +++ b/Sources/armory/trait/physics/bullet/PhysicsConstraint.hx @@ -7,23 +7,23 @@ import armory.trait.physics.RigidBody; import armory.trait.physics.PhysicsWorld; class PhysicsConstraint extends iron.Trait { - var body1:String; - var body2:String; - var type:String; - var disableCollisions:Bool; - var breakingThreshold:Float; - var limits:Array; - var con:bullet.Bt.TypedConstraint = null; + var body1: String; + var body2: String; + var type: String; + var disableCollisions: Bool; + var breakingThreshold: Float; + var limits: Array; + var con: bullet.Bt.TypedConstraint = null; static var nullvec = true; - static var vec1:bullet.Bt.Vector3; - static var vec2:bullet.Bt.Vector3; - static var vec3:bullet.Bt.Vector3; - static var trans1:bullet.Bt.Transform; - static var trans2:bullet.Bt.Transform; - static var transt:bullet.Bt.Transform; + static var vec1: bullet.Bt.Vector3; + static var vec2: bullet.Bt.Vector3; + static var vec3: bullet.Bt.Vector3; + static var trans1: bullet.Bt.Transform; + static var trans2: bullet.Bt.Transform; + static var transt: bullet.Bt.Transform; - public function new(body1:String, body2:String, type:String, disableCollisions:Bool, breakingThreshold:Float, limits:Array = null) { + public function new(body1: String, body2: String, type: String, disableCollisions: Bool, breakingThreshold: Float, limits: Array = null) { super(); if (nullvec) { @@ -33,9 +33,8 @@ 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; this.body2 = body2; this.type = type; @@ -51,8 +50,8 @@ class PhysicsConstraint extends iron.Trait { var target2 = iron.Scene.active.getChild(body2); if (target1 == null || target2 == null) return; - var rb1:RigidBody = target1.getTrait(RigidBody); - var rb2:RigidBody = target2.getTrait(RigidBody); + var rb1: RigidBody = target1.getTrait(RigidBody); + var rb2: RigidBody = target2.getTrait(RigidBody); if (rb1 != null && rb1.ready && rb2 != null && rb2.ready) { @@ -73,7 +72,7 @@ class PhysicsConstraint extends iron.Trait { //trans2.setRotation(new bullet.Bt.Quaternion(t2.rot.x, t2.rot.y, t2.rot.z, t2.rot.w)); trans1.setRotation(new bullet.Bt.Quaternion(t.rot.x, t.rot.y, t.rot.z, t.rot.w)); trans2.setRotation(new bullet.Bt.Quaternion(t.rot.x, t.rot.y, t.rot.z, t.rot.w)); - + if (type == "GENERIC" || type == "FIXED") { var c = bullet.Bt.Generic6DofConstraint.new2(rb1.body, rb2.body, trans1, trans2, false); if (type == "FIXED") { @@ -85,37 +84,31 @@ class PhysicsConstraint extends iron.Trait { c.setAngularLowerLimit(vec1); c.setAngularUpperLimit(vec1); } - - else if(type == "GENERIC") { - if(limits[0] == 0){ + + else if (type == "GENERIC") { + if (limits[0] == 0) { limits[1] = 1.0; limits[2] = -1.0; - } - if(limits[3] == 0){ + if (limits[3] == 0) { limits[4] = 1.0; limits[5] = -1.0; - } - if(limits[6] == 0){ + if (limits[6] == 0) { limits[7] = 1.0; limits[8] = -1.0; - } - if(limits[9] == 0){ + if (limits[9] == 0) { limits[10] = 1.0; limits[11] = -1.0; - } - if(limits[12] == 0){ + if (limits[12] == 0) { limits[13] = 1.0; limits[14] = -1.0; - } - if(limits[15] == 0){ + if (limits[15] == 0) { limits[16] = 1.0; limits[17] = -1.0; - } vec1.setX(limits[1]); vec1.setY(limits[4]); @@ -137,38 +130,32 @@ class PhysicsConstraint extends iron.Trait { con = cast c; } - else if( type == "GENERIC_SPRING"){ + else if (type == "GENERIC_SPRING"){ var c = new bullet.Bt.Generic6DofSpringConstraint(rb1.body, rb2.body, trans1, trans2, false); - if(limits[0] == 0){ + if (limits[0] == 0) { limits[1] = 1.0; limits[2] = -1.0; - } - if(limits[3] == 0){ + if (limits[3] == 0) { limits[4] = 1.0; limits[5] = -1.0; - } - if(limits[6] == 0){ + if (limits[6] == 0) { limits[7] = 1.0; limits[8] = -1.0; - } - if(limits[9] == 0){ + if (limits[9] == 0) { limits[10] = 1.0; limits[11] = -1.0; - } - if(limits[12] == 0){ + if (limits[12] == 0) { limits[13] = 1.0; limits[14] = -1.0; - } - if(limits[15] == 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) - { - c.enableSpring(0,true); - c.setStiffness(0,limits[19]); - c.setDamping(0,limits[20]); - + 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) - { - c.enableSpring(1,true); - c.setStiffness(1,limits[22]); - c.setDamping(1,limits[23]); - + else { + c.enableSpring(0, false); } - else{c.enableSpring(1,false);} - if(limits[24] != 0) - { - c.enableSpring(2,true); - c.setStiffness(2,limits[25]); - c.setDamping(2,limits[26]); - + if (limits[21] != 0) { + c.enableSpring(1, true); + c.setStiffness(1, limits[22]); + c.setDamping(1, limits[23]); } - 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(1, false); } - else{c.enableSpring(3,false);} - if(limits[30] != 0) - { - c.enableSpring(4,true); - c.setStiffness(4,limits[31]); - c.setDamping(4,limits[32]); + if (limits[24] != 0) { + c.enableSpring(2, true); + c.setStiffness(2, limits[25]); + c.setDamping(2, limits[26]); } - 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(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) { + c.enableSpring(4, true); + c.setStiffness(4, limits[31]); + c.setDamping(4, limits[32]); + } + 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; } @@ -238,59 +228,52 @@ class PhysicsConstraint extends iron.Trait { var c = new bullet.Bt.Point2PointConstraint(rb1.body, rb2.body, vec1, vec2); con = cast c; } - + else if (type == "HINGE") { var axis = vec3; - var _softness:Float = 0.9; - var _biasFactor:Float = 0.3; - var _relaxationFactor:Float = 1.0; + var _softness: Float = 0.9; + var _biasFactor: Float = 0.3; + var _relaxationFactor: Float = 1.0; axis.setX(t.up().x); axis.setY(t.up().y); axis.setZ(t.up().z); - + var c = new bullet.Bt.HingeConstraint(rb1.body, rb2.body, vec1, vec2, axis, axis); - if(limits[0] != 0){ - c.setLimit(limits[1],limits[2],_softness ,_biasFactor ,_relaxationFactor ); + if (limits[0] != 0) { + c.setLimit(limits[1], limits[2], _softness, _biasFactor, _relaxationFactor); } - + con = cast c; } else if (type == "SLIDER") { var c = new bullet.Bt.SliderConstraint(rb1.body, rb2.body, trans1, trans2, true); - - - - if(limits[0] != 0){ + + 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){ + + if (limits[0] != 0) { c.setLowerLinLimit(limits[1]); c.setUpperLinLimit(limits[2]); } - if(limits[3] != 0){ + if (limits[3] != 0) { c.setLowerAngLimit(limits[4]); c.setUpperAngLimit(limits[5]); } - else{ + else { c.setLowerAngLimit(1); c.setUpperAngLimit(-1); } con = cast c; - - } if (breakingThreshold > 0) con.setBreakingImpulseThreshold(breakingThreshold); diff --git a/Sources/armory/trait/physics/bullet/PhysicsHook.hx b/Sources/armory/trait/physics/bullet/PhysicsHook.hx index ffc7b19b..15e5b896 100644 --- a/Sources/armory/trait/physics/bullet/PhysicsHook.hx +++ b/Sources/armory/trait/physics/bullet/PhysicsHook.hx @@ -15,25 +15,26 @@ import armory.trait.physics.RigidBody; import armory.trait.physics.PhysicsWorld; class PhysicsHook extends Trait { - var target:Object; - var targetName:String; - var targetTransform:Transform; - var verts:Array; - var constraint:bullet.Bt.Generic6DofConstraint = null; + var target: Object; + var targetName: String; + var targetTransform: Transform; + var verts: Array; + + var constraint: bullet.Bt.Generic6DofConstraint = null; #if arm_physics_soft - var hookRB:bullet.Bt.RigidBody = null; + var hookRB: bullet.Bt.RigidBody = null; #end static var nullvec = true; - static var vec1:bullet.Bt.Vector3; - static var quat1:bullet.Bt.Quaternion; - static var trans1:bullet.Bt.Transform; - static var trans2:bullet.Bt.Transform; + static var vec1: bullet.Bt.Vector3; + static var quat1: bullet.Bt.Quaternion; + static var trans1: bullet.Bt.Transform; + static var trans2: bullet.Bt.Transform; static var quat = new Quat(); - public function new(targetName:String, verts:Array) { + public function new(targetName: String, verts: Array) { super(); if (nullvec) { @@ -62,7 +63,7 @@ class PhysicsHook extends Trait { // Soft body hook #if arm_physics_soft - var sb:SoftBody = object.getTrait(SoftBody); + var sb: SoftBody = object.getTrait(SoftBody); if (sb != null && sb.ready) { // Place static rigid body at target location @@ -123,7 +124,7 @@ class PhysicsHook extends Trait { #end // Rigid body hook - var rb1:RigidBody = object.getTrait(RigidBody); + var rb1: RigidBody = object.getTrait(RigidBody); if (rb1 != null && rb1.ready) { trans1.setIdentity(); vec1.setX(targetTransform.worldx() - object.transform.worldx()); diff --git a/Sources/armory/trait/physics/bullet/PhysicsWorld.hx b/Sources/armory/trait/physics/bullet/PhysicsWorld.hx index 8ecd7e9f..d130f79e 100644 --- a/Sources/armory/trait/physics/bullet/PhysicsWorld.hx +++ b/Sources/armory/trait/physics/bullet/PhysicsWorld.hx @@ -9,10 +9,11 @@ import iron.math.RayCaster; import iron.data.SceneFormat; class Hit { - public var rb:RigidBody; - public var pos:Vec4; - public var normal:Vec4; - public function new(rb:RigidBody, pos:Vec4, normal:Vec4){ + + public var rb: RigidBody; + public var pos: Vec4; + public var normal: Vec4; + public function new(rb: RigidBody, pos: Vec4, normal: Vec4){ this.rb = rb; this.pos = pos; this.normal = normal; @@ -20,14 +21,15 @@ class Hit { } class ContactPair { - public var a:Int; - public var b:Int; - public var posA:Vec4; - public var posB:Vec4; - public var normOnB:Vec4; - public var impulse:Float; - public var distance:Float; - public function new(a:Int, b:Int) { + + public var a: Int; + public var b: Int; + public var posA: Vec4; + public var posB: Vec4; + public var normOnB: Vec4; + public var impulse: Float; + public var distance: Float; + public function new(a: Int, b: Int) { this.a = a; this.b = b; } @@ -35,31 +37,31 @@ class ContactPair { class PhysicsWorld extends Trait { - public static var active:PhysicsWorld = null; + public static var active: PhysicsWorld = null; static var sceneRemoved = false; #if arm_physics_soft - public var world:bullet.Bt.SoftRigidDynamicsWorld; + public var world: bullet.Bt.SoftRigidDynamicsWorld; #else - public var world:bullet.Bt.DiscreteDynamicsWorld; + public var world: bullet.Bt.DiscreteDynamicsWorld; #end - var dispatcher:bullet.Bt.CollisionDispatcher; + var dispatcher: bullet.Bt.CollisionDispatcher; var gimpactRegistered = false; - var contacts:Array; - var preUpdates:ArrayVoid> = null; - public var rbMap:Map; + var contacts: Array; + var preUpdates: ArrayVoid> = null; + public var rbMap: Map; public var timeScale = 1.0; var timeStep = 1 / 60; var maxSteps = 1; public var solverIterations = 10; public var hitPointWorld = new Vec4(); public var hitNormalWorld = new Vec4(); - var pairCache:Bool = false; + var pairCache: Bool = false; static var nullvec = true; - static var vec1:bullet.Bt.Vector3 = null; - static var vec2:bullet.Bt.Vector3 = null; + static var vec1: bullet.Bt.Vector3 = null; + static var vec2: bullet.Bt.Vector3 = null; #if arm_debug public static var physTime = 0.0; @@ -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; @@ -101,7 +102,7 @@ class PhysicsWorld extends Trait { // Ensure physics are updated first in the lateUpdate list _lateUpdate = [lateUpdate]; @:privateAccess iron.App.traitLateUpdates.insert(0, lateUpdate); - + iron.Scene.active.notifyOnRemove(function() { sceneRemoved = true; }); @@ -119,7 +120,7 @@ class PhysicsWorld extends Trait { #else var collisionConfiguration = new bullet.Bt.DefaultCollisionConfiguration(); #end - + dispatcher = new bullet.Bt.CollisionDispatcher(collisionConfiguration); var solver = new bullet.Bt.SequentialImpulseConstraintSolver(); @@ -144,12 +145,12 @@ class PhysicsWorld extends Trait { setGravity(gravity); } - public function setGravity(v:Vec4) { + public function setGravity(v: Vec4) { vec1.setValue(v.x, v.y, v.z); world.setGravity(vec1); } - public function addRigidBody(body:RigidBody) { + public function addRigidBody(body: RigidBody) { #if js world.addRigidBodyToGroup(body.body, body.group, body.mask); #else @@ -158,7 +159,7 @@ class PhysicsWorld extends Trait { rbMap.set(body.id, body); } - public function removeRigidBody(body:RigidBody) { + public function removeRigidBody(body: RigidBody) { if (body.destroyed) return; body.destroyed = true; if (world != null) world.removeRigidBody(body.body); @@ -189,14 +190,13 @@ 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 or null. - */ - public function getContacts(body:RigidBody):Array { + 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 or null. + **/ + public function getContacts(body: RigidBody): Array { if (contacts.length == 0) return null; - var res:Array = []; + var res: Array = []; for (i in 0...contacts.length) { var c = contacts[i]; var rb = null; @@ -206,7 +206,7 @@ class PhysicsWorld extends Trait { else if (c.b == untyped body.body.userIndex) rb = rbMap.get(c.a); #else - var ob:bullet.Bt.CollisionObject = body.body; + var ob: bullet.Bt.CollisionObject = body.body; if (c.a == ob.getUserIndex()) rb = rbMap.get(c.b); else if (c.b == ob.getUserIndex()) rb = rbMap.get(c.a); #end @@ -216,28 +216,28 @@ class PhysicsWorld extends Trait { return res; } - public function getContactPairs(body:RigidBody):Array { + public function getContactPairs(body: RigidBody): Array { if (contacts.length == 0) return null; - var res:Array = []; + var res: Array = []; for (i in 0...contacts.length) { var c = contacts[i]; #if js - + if (c.a == untyped body.body.userIndex) res.push(c); else if (c.b == untyped body.body.userIndex) res.push(c); - + #else - - var ob:bullet.Bt.CollisionObject = body.body; + + var ob: bullet.Bt.CollisionObject = body.body; if (c.a == ob.getUserIndex()) res.push(c); else if (c.b == ob.getUserIndex()) res.push(c); - + #end } return res; } - - public function findBody(id:Int):RigidBody{ + + public function findBody(id: Int): RigidBody{ var rb = rbMap.get(id); return rb; } @@ -265,7 +265,7 @@ class PhysicsWorld extends Trait { function updateContacts() { contacts = []; - var disp:bullet.Bt.Dispatcher = dispatcher; + var disp: bullet.Bt.Dispatcher = dispatcher; var numManifolds = disp.getNumManifolds(); for (i in 0...numManifolds) { @@ -274,16 +274,16 @@ class PhysicsWorld extends Trait { var body0 = untyped bullet.Bt.Ammo.btRigidBody.prototype.upcast(contactManifold.getBody0()); var body1 = untyped bullet.Bt.Ammo.btRigidBody.prototype.upcast(contactManifold.getBody1()); #else - var body0:bullet.Bt.CollisionObject = contactManifold.getBody0(); - var body1:bullet.Bt.CollisionObject = contactManifold.getBody1(); + var body0: bullet.Bt.CollisionObject = contactManifold.getBody0(); + var body1: bullet.Bt.CollisionObject = contactManifold.getBody1(); #end var numContacts = contactManifold.getNumContacts(); - var pt:bullet.Bt.ManifoldPoint = null; - var posA:bullet.Bt.Vector3 = null; - var posB:bullet.Bt.Vector3 = null; - var nor:bullet.Bt.Vector3 = null; - var cp:ContactPair = null; + var pt: bullet.Bt.ManifoldPoint = null; + var posA: bullet.Bt.Vector3 = null; + var posB: bullet.Bt.Vector3 = null; + var nor: bullet.Bt.Vector3 = null; + var cp: ContactPair = null; for (j in 0...numContacts) { pt = contactManifold.getContactPoint(j); #if js @@ -307,7 +307,7 @@ class PhysicsWorld extends Trait { } } - public function pickClosest(inputX:Float, inputY:Float):RigidBody { + public function pickClosest(inputX: Float, inputY: Float): RigidBody { var camera = iron.Scene.active.camera; var start = new Vec4(); var end = new Vec4(); @@ -317,7 +317,7 @@ class PhysicsWorld extends Trait { return rb; } - public function rayCast(from:Vec4, to:Vec4, group:Int=0x00000001,mask=0xFFFFFFFF):Hit { + public function rayCast(from: Vec4, to: Vec4, group: Int = 0x00000001, mask = 0xFFFFFFFF): Hit { var rayFrom = vec1; var rayTo = vec2; rayFrom.setValue(from.x, from.y, from.z); @@ -331,13 +331,13 @@ class PhysicsWorld extends Trait { rayCallback.m_collisionFilterGroup = group; rayCallback.m_collisionFilterMask = mask; #end - var worldDyn:bullet.Bt.DynamicsWorld = world; - var worldCol:bullet.Bt.CollisionWorld = worldDyn; + var worldDyn: bullet.Bt.DynamicsWorld = world; + var worldCol: bullet.Bt.CollisionWorld = worldDyn; worldCol.rayTest(rayFrom, rayTo, rayCallback); - var rb:RigidBody = null; - var hitInfo:Hit = null; + var rb: RigidBody = null; + var hitInfo: Hit = null; - var rc:bullet.Bt.RayResultCallback = rayCallback; + var rc: bullet.Bt.RayResultCallback = rayCallback; if (rc.hasHit()) { #if js var co = rayCallback.get_m_collisionObject(); @@ -347,14 +347,14 @@ class PhysicsWorld extends Trait { var norm = rayCallback.get_m_hitNormalWorld(); hitNormalWorld.set(norm.x(), norm.y(), norm.z()); rb = rbMap.get(untyped body.userIndex); - hitInfo = new Hit(rb,hitPointWorld,hitNormalWorld); + hitInfo = new Hit(rb, hitPointWorld, hitNormalWorld); #elseif cpp var hit = rayCallback.m_hitPointWorld; hitPointWorld.set(hit.x(), hit.y(), hit.z()); var norm = rayCallback.m_hitNormalWorld; hitNormalWorld.set(norm.x(), norm.y(), norm.z()); rb = rbMap.get(rayCallback.m_collisionObject.getUserIndex()); - hitInfo = new Hit(rb,hitPointWorld,hitNormalWorld); + hitInfo = new Hit(rb, hitPointWorld, hitNormalWorld); #end } @@ -367,12 +367,12 @@ class PhysicsWorld extends Trait { return hitInfo; } - public function notifyOnPreUpdate(f:Void->Void) { + public function notifyOnPreUpdate(f: Void->Void) { if (preUpdates == null) preUpdates = []; preUpdates.push(f); } - public function removePreUpdate(f:Void->Void) { + public function removePreUpdate(f: Void->Void) { preUpdates.remove(f); } } diff --git a/Sources/armory/trait/physics/bullet/RigidBody.hx b/Sources/armory/trait/physics/bullet/RigidBody.hx index 5cb157ae..e5180a2f 100644 --- a/Sources/armory/trait/physics/bullet/RigidBody.hx +++ b/Sources/armory/trait/physics/bullet/RigidBody.hx @@ -9,63 +9,63 @@ 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 { - var shape:Shape; - public var physics:PhysicsWorld; - public var transform:Transform = null; - public var mass:Float; - public var friction:Float; - public var restitution:Float; - public var collisionMargin:Float; - public var linearDamping:Float; - public var angularDamping:Float; - public var animated:Bool; - public var staticObj:Bool; + var shape: Shape; + public var physics: PhysicsWorld; + public var transform: Transform = null; + public var mass: Float; + public var friction: Float; + public var restitution: Float; + public var collisionMargin: Float; + public var linearDamping: Float; + public var angularDamping: Float; + public var animated: Bool; + public var staticObj: Bool; public var destroyed = false; - var linearFactors:Array; - var angularFactors:Array; - var deactivationParams:Array; + var linearFactors: Array; + var angularFactors: Array; + var deactivationParams: Array; var ccd = false; // Continuous collision detection public var group = 1; public var mask = 1; var trigger = false; - var bodyScaleX:Float; // Transform scale at creation time - var bodyScaleY:Float; - var bodyScaleZ:Float; - var currentScaleX:Float; - var currentScaleY:Float; - var currentScaleZ:Float; + var bodyScaleX: Float; // Transform scale at creation time + var bodyScaleY: Float; + var bodyScaleZ: Float; + var currentScaleX: Float; + var currentScaleY: Float; + var currentScaleZ: Float; - public var body:bullet.Bt.RigidBody = null; - public var motionState:bullet.Bt.MotionState; - public var btshape:bullet.Bt.CollisionShape; + public var body: bullet.Bt.RigidBody = null; + public var motionState: bullet.Bt.MotionState; + public var btshape: bullet.Bt.CollisionShape; public var ready = false; static var nextId = 0; public var id = 0; - public var onReady:Void->Void = null; - public var onContact:ArrayVoid> = null; - public var heightData:haxe.io.Bytes = null; + public var onReady: Void->Void = null; + public var onContact: ArrayVoid> = null; + public var heightData: haxe.io.Bytes = null; #if js - static var ammoArray:Int = -1; + static var ammoArray: Int = -1; #end static var nullvec = true; - static var vec1:bullet.Bt.Vector3; - static var vec2:bullet.Bt.Vector3; - static var vec3:bullet.Bt.Vector3; - static var quat1:bullet.Bt.Quaternion; - static var trans1:bullet.Bt.Transform; - static var trans2:bullet.Bt.Transform; + static var vec1: bullet.Bt.Vector3; + static var vec2: bullet.Bt.Vector3; + static var vec3: bullet.Bt.Vector3; + static var quat1: bullet.Bt.Quaternion; + static var trans1: bullet.Bt.Transform; + static var trans2: bullet.Bt.Transform; static var quat = new Quat(); - static var CF_STATIC_OBJECT= 1; - static var CF_KINEMATIC_OBJECT= 2; + static var CF_STATIC_OBJECT = 1; + static var CF_KINEMATIC_OBJECT = 2; static var CF_NO_CONTACT_RESPONSE = 4; static var CF_CHARACTER_OBJECT = 16; @@ -73,8 +73,8 @@ class RigidBody extends iron.Trait { static var triangleMeshCache = new Map(); static var usersCache = new Map(); - public function new(shape = Shape.Box, mass = 1.0, friction = 0.5, restitution = 0.0, group = 1, mask=1, - params:Array = null, flags:Array = null) { + public function new(shape = Shape.Box, mass = 1.0, friction = 0.5, restitution = 0.0, group = 1, mask = 1, + params: Array = null, flags: Array = null) { super(); if (nullvec) { @@ -85,7 +85,7 @@ class RigidBody extends iron.Trait { quat1 = new bullet.Bt.Quaternion(0, 0, 0, 0); trans1 = new bullet.Bt.Transform(); trans2 = new bullet.Bt.Transform(); - } + } this.shape = shape; this.mass = mass; @@ -111,11 +111,11 @@ class RigidBody extends iron.Trait { notifyOnAdd(init); } - inline function withMargin(f:Float) { + inline function withMargin(f: Float) { return f - f * collisionMargin; } - public function notifyOnReady(f:Void->Void) { + public function notifyOnReady(f: Void->Void) { onReady = f; if (ready) onReady(); } @@ -146,7 +146,7 @@ class RigidBody extends iron.Trait { var coneZ = new bullet.Bt.ConeShapeZ( withMargin(transform.dim.x / 2), // Radius withMargin(transform.dim.z)); // Height - var cone:bullet.Bt.ConeShape = coneZ; + var cone: bullet.Bt.ConeShape = coneZ; btshape = cone; } else if (shape == Shape.Cylinder) { @@ -154,7 +154,7 @@ class RigidBody extends iron.Trait { vec1.setY(withMargin(transform.dim.y / 2)); vec1.setZ(withMargin(transform.dim.z / 2)); var cylZ = new bullet.Bt.CylinderShapeZ(vec1); - var cyl:bullet.Bt.CylinderShape = cylZ; + var cyl: bullet.Bt.CylinderShape = cylZ; btshape = cyl; } else if (shape == Shape.Capsule) { @@ -162,7 +162,7 @@ class RigidBody extends iron.Trait { var capsZ = new bullet.Bt.CapsuleShapeZ( withMargin(r), // Radius withMargin(transform.dim.z - r * 2)); // Height between 2 sphere centers - var caps:bullet.Bt.CapsuleShape = capsZ; + var caps: bullet.Bt.CapsuleShape = capsZ; btshape = caps; } else if (shape == Shape.Mesh) { @@ -170,7 +170,7 @@ class RigidBody extends iron.Trait { if (mass > 0) { var shapeGImpact = new bullet.Bt.GImpactMeshShape(meshInterface); shapeGImpact.updateBound(); - var shapeConcave:bullet.Bt.ConcaveShape = shapeGImpact; + var shapeConcave: bullet.Bt.ConcaveShape = shapeGImpact; btshape = shapeConcave; if (!physics.gimpactRegistered) { #if js @@ -183,8 +183,8 @@ class RigidBody extends iron.Trait { } else { var shapeBvh = new bullet.Bt.BvhTriangleMeshShape(meshInterface, true, true); - var shapeTri:bullet.Bt.TriangleMeshShape = shapeBvh; - var shapeConcave:bullet.Bt.ConcaveShape = shapeTri; + var shapeTri: bullet.Bt.TriangleMeshShape = shapeBvh; + var shapeConcave: bullet.Bt.ConcaveShape = shapeTri; btshape = shapeConcave; } } @@ -227,12 +227,12 @@ class RigidBody extends iron.Trait { vec1.setZ(0); var inertia = vec1; - if(staticObj || animated) mass = 0; + if (staticObj || animated) mass = 0; if (mass > 0) btshape.calculateLocalInertia(mass, inertia); var bodyCI = new bullet.Bt.RigidBodyConstructionInfo(mass, motionState, btshape, inertia); body = new bullet.Bt.RigidBody(bodyCI); - - var bodyColl:bullet.Bt.CollisionObject = body; + + var bodyColl: bullet.Bt.CollisionObject = body; bodyColl.setFriction(friction); // body.setRollingFriction(friction); // This causes bodies to get stuck, apply angular damping instead if (shape == Shape.Sphere || shape == Shape.Cylinder || shape == Shape.Cone || shape == Shape.Capsule) { @@ -260,7 +260,7 @@ class RigidBody extends iron.Trait { } if (trigger) bodyColl.setCollisionFlags(bodyColl.getCollisionFlags() | CF_NO_CONTACT_RESPONSE); - if (animated){ + if (animated) { bodyColl.setCollisionFlags(bodyColl.getCollisionFlags() | CF_KINEMATIC_OBJECT); bodyColl.setCollisionFlags(bodyColl.getCollisionFlags() & ~CF_STATIC_OBJECT); } @@ -300,12 +300,12 @@ class RigidBody extends iron.Trait { syncTransform(); } else { - var bodyColl:bullet.Bt.CollisionObject = body; + var bodyColl: bullet.Bt.CollisionObject = body; var trans = bodyColl.getWorldTransform(); var p = trans.getOrigin(); var q = trans.getRotation(); - var qw:bullet.Bt.QuadWord = q; + var qw: bullet.Bt.QuadWord = q; transform.loc.set(p.x(), p.y(), p.z()); transform.rot.set(qw.x(), qw.y(), qw.z(), qw.w()); @@ -329,7 +329,7 @@ class RigidBody extends iron.Trait { } public function activate() { - var bodyColl:bullet.Bt.CollisionObject = body; + var bodyColl: bullet.Bt.CollisionObject = body; bodyColl.activate(false); } @@ -342,22 +342,22 @@ class RigidBody extends iron.Trait { body.setGravity(physics.world.getGravity()); } - public function setGravity(v:Vec4) { + public function setGravity(v: Vec4) { vec1.setValue(v.x, v.y, v.z); body.setGravity(vec1); } - public function setActivationState(newState:Int) { - var bodyColl:bullet.Bt.CollisionObject = body; + public function setActivationState(newState: Int) { + var bodyColl: bullet.Bt.CollisionObject = body; bodyColl.setActivationState(newState); } - public function setDeactivationParams(linearThreshold:Float, angularThreshold:Float, time:Float) { + public function setDeactivationParams(linearThreshold: Float, angularThreshold: Float, time: Float) { body.setSleepingThresholds(linearThreshold, angularThreshold); // body.setDeactivationTime(time); // not available in ammo } - public function applyForce(force:Vec4, loc:Vec4 = null) { + public function applyForce(force: Vec4, loc: Vec4 = null) { activate(); vec1.setValue(force.x, force.y, force.z); if (loc == null) { @@ -369,7 +369,7 @@ class RigidBody extends iron.Trait { } } - public function applyImpulse(impulse:Vec4, loc:Vec4 = null) { + public function applyImpulse(impulse: Vec4, loc: Vec4 = null) { activate(); vec1.setValue(impulse.x, impulse.y, impulse.z); if (loc == null) { @@ -381,65 +381,65 @@ class RigidBody extends iron.Trait { } } - public function applyTorque(torque:Vec4) { + public function applyTorque(torque: Vec4) { activate(); vec1.setValue(torque.x, torque.y, torque.z); body.applyTorque(vec1); } - public function applyTorqueImpulse(torque:Vec4) { + public function applyTorqueImpulse(torque: Vec4) { activate(); vec1.setValue(torque.x, torque.y, torque.z); body.applyTorqueImpulse(vec1); } - public function setLinearFactor(x:Float, y:Float, z:Float) { + public function setLinearFactor(x: Float, y: Float, z: Float) { vec1.setValue(x, y, z); body.setLinearFactor(vec1); } - public function setAngularFactor(x:Float, y:Float, z:Float) { + public function setAngularFactor(x: Float, y: Float, z: Float) { vec1.setValue(x, y, z); body.setAngularFactor(vec1); } - public function getLinearVelocity():Vec4 { + public function getLinearVelocity(): Vec4 { var v = body.getLinearVelocity(); return new Vec4(v.x(), v.y(), v.z()); } - public function setLinearVelocity(x:Float, y:Float, z:Float) { + public function setLinearVelocity(x: Float, y: Float, z: Float) { vec1.setValue(x, y, z); body.setLinearVelocity(vec1); } - public function getAngularVelocity():Vec4 { + public function getAngularVelocity(): Vec4 { var v = body.getAngularVelocity(); return new Vec4(v.x(), v.y(), v.z()); } - public function setAngularVelocity(x:Float, y:Float, z:Float) { + public function setAngularVelocity(x: Float, y: Float, z: Float) { vec1.setValue(x, y, z); body.setAngularVelocity(vec1); } - public function setFriction(f:Float) { - var bodyColl:bullet.Bt.CollisionObject = body; + public function setFriction(f: Float) { + var bodyColl: bullet.Bt.CollisionObject = body; bodyColl.setFriction(f); // bodyColl.setRollingFriction(f); this.friction = f; } - public function notifyOnContact(f:RigidBody->Void) { + public function notifyOnContact(f: RigidBody->Void) { if (onContact == null) onContact = []; onContact.push(f); } - public function removeContact(f:RigidBody->Void) { + public function removeContact(f: RigidBody->Void) { onContact.remove(f); } - function setScale(v:Vec4) { + function setScale(v: Vec4) { currentScaleX = v.x; currentScaleY = v.y; currentScaleZ = v.z; @@ -447,8 +447,8 @@ class RigidBody extends iron.Trait { vec1.setY(v.y / bodyScaleY); vec1.setZ(v.z / bodyScaleZ); btshape.setLocalScaling(vec1); - var worldDyn:bullet.Bt.DynamicsWorld = physics.world; - var worldCol:bullet.Bt.CollisionWorld = worldDyn; + var worldDyn: bullet.Bt.DynamicsWorld = physics.world; + var worldCol: bullet.Bt.CollisionWorld = worldDyn; worldCol.updateSingleAabb(body); } @@ -460,22 +460,20 @@ 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(); } // Continuous collision detection - public function setCcd(sphereRadius:Float, motionThreshold = 1e-7) { - var bodyColl:bullet.Bt.CollisionObject = body; + public function setCcd(sphereRadius: Float, motionThreshold = 1e-7) { + var bodyColl: bullet.Bt.CollisionObject = body; bodyColl.setCcdSweptSphereRadius(sphereRadius); bodyColl.setCcdMotionThreshold(motionThreshold); } - function fillConvexHull(scale:Vec4, margin:kha.FastFloat):bullet.Bt.ConvexHullShape { + function fillConvexHull(scale: Vec4, margin: kha.FastFloat): bullet.Bt.ConvexHullShape { // Check whether shape already exists var data = cast(object, MeshObject).data; var shape = convexHullCache.get(data); @@ -483,16 +481,16 @@ class RigidBody extends iron.Trait { usersCache.set(data, usersCache.get(data) + 1); return shape; } - + shape = new bullet.Bt.ConvexHullShape(); convexHullCache.set(data, shape); usersCache.set(data, 1); var positions = data.geom.positions; - var sx:kha.FastFloat = scale.x * (1.0 - margin) * (1 / 32767); - var sy:kha.FastFloat = scale.y * (1.0 - margin) * (1 / 32767); - var sz:kha.FastFloat = scale.z * (1.0 - margin) * (1 / 32767); + var sx: kha.FastFloat = scale.x * (1.0 - margin) * (1 / 32767); + var sy: kha.FastFloat = scale.y * (1.0 - margin) * (1 / 32767); + var sz: kha.FastFloat = scale.z * (1.0 - margin) * (1 / 32767); if (data.raw.scale_pos != null) { sx *= data.raw.scale_pos; @@ -509,7 +507,7 @@ class RigidBody extends iron.Trait { return shape; } - function fillTriangleMesh(scale:Vec4):bullet.Bt.TriangleMesh { + function fillTriangleMesh(scale: Vec4): bullet.Bt.TriangleMesh { // Check whether shape already exists var data = cast(object, MeshObject).data; var triangleMesh = triangleMeshCache.get(data); @@ -517,7 +515,7 @@ class RigidBody extends iron.Trait { usersCache.set(data, usersCache.get(data) + 1); return triangleMesh; } - + triangleMesh = new bullet.Bt.TriangleMesh(true, true); triangleMeshCache.set(data, triangleMesh); usersCache.set(data, 1); @@ -525,9 +523,9 @@ class RigidBody extends iron.Trait { var positions = data.geom.positions; var indices = data.geom.indices; - var sx:kha.FastFloat = scale.x * (1 / 32767); - var sy:kha.FastFloat = scale.y * (1 / 32767); - var sz:kha.FastFloat = scale.z * (1 / 32767); + var sx: kha.FastFloat = scale.x * (1 / 32767); + var sy: kha.FastFloat = scale.y * (1 / 32767); + var sz: kha.FastFloat = scale.z * (1 / 32767); if (data.raw.scale_pos != null) { sx *= data.raw.scale_pos; diff --git a/Sources/armory/trait/physics/bullet/SoftBody.hx b/Sources/armory/trait/physics/bullet/SoftBody.hx index 2a10c28f..3fba63c9 100644 --- a/Sources/armory/trait/physics/bullet/SoftBody.hx +++ b/Sources/armory/trait/physics/bullet/SoftBody.hx @@ -18,23 +18,23 @@ class SoftBody extends Trait { public function new() { super(); } #else - static var physics:PhysicsWorld = null; + static var physics: PhysicsWorld = null; public var ready = false; - var shape:SoftShape; - var bend:Float; - var mass:Float; - var margin:Float; + var shape: SoftShape; + var bend: Float; + var mass: Float; + var margin: Float; public var vertOffsetX = 0.0; public var vertOffsetY = 0.0; public var vertOffsetZ = 0.0; - public var body:bullet.Bt.SoftBody; + public var body: bullet.Bt.SoftBody; - static var helpers:bullet.Bt.SoftBodyHelpers; + static var helpers: bullet.Bt.SoftBodyHelpers; static var helpersCreated = false; - static var worldInfo:bullet.Bt.SoftBodyWorldInfo; + static var worldInfo: bullet.Bt.SoftBodyWorldInfo; public function new(shape = SoftShape.Cloth, bend = 0.5, mass = 1.0, margin = 0.04) { super(); @@ -48,7 +48,7 @@ class SoftBody extends Trait { }); } - function fromI16(ar:kha.arrays.Int16Array, scalePos:Float):kha.arrays.Float32Array { + function fromI16(ar: kha.arrays.Int16Array, scalePos: Float): kha.arrays.Float32Array { var vals = new kha.arrays.Float32Array(Std.int(ar.length / 4) * 3); for (i in 0...Std.int(vals.length / 3)) { vals[i * 3 ] = (ar[i * 4 ] / 32767) * scalePos; @@ -58,7 +58,7 @@ class SoftBody extends Trait { return vals; } - function fromU32(ars:Array):kha.arrays.Uint32Array { + function fromU32(ars: Array): kha.arrays.Uint32Array { var len = 0; for (ar in ars) len += ar.length; var vals = new kha.arrays.Uint32Array(len); @@ -130,7 +130,7 @@ class SoftBody extends Trait { #end // body.generateClusters(4); - + #if js var cfg = body.get_m_cfg(); cfg.set_viterations(physics.solverIterations); @@ -142,7 +142,7 @@ class SoftBody extends Trait { cfg.set_kDP(0.01); cfg.set_kPR(bend); } - + #elseif cpp body.m_cfg.viterations = physics.solverIterations; body.m_cfg.piterations = physics.solverIterations; @@ -171,7 +171,7 @@ class SoftBody extends Trait { function update() { var mo = cast(object, MeshObject); var geom = mo.data.geom; - + #if arm_deinterleaved var v = geom.vertexBuffers[0].lockInt16(); var n = geom.vertexBuffers[1].lockInt16();