From 08dbd8681b5c5928111156c733ff27f0555d8f8f Mon Sep 17 00:00:00 2001 From: Josef Date: Sun, 20 Jul 2025 13:22:12 +0200 Subject: [PATCH] Jam Updates --- Runtime/Actions/Node3D/OnCollision.cs | 32 +++++++++++++- Runtime/Actions/RemoveNode.cs | 21 +++++++++ Runtime/Actions/RemoveNode.cs.uid | 1 + Runtime/App/App.cs | 9 +++- Runtime/Godot/NodeState.cs | 13 ++++++ Runtime/Interactions/Interactor.cs | 3 ++ Runtime/Interactions/Pointer.cs | 8 ++++ .../Assets/Grass/Windy Grass Shader.gdshader | 44 +++++++++---------- .../Assets/Foliage/MeshInstanceFoliageData.cs | 3 ++ 9 files changed, 108 insertions(+), 26 deletions(-) create mode 100644 Runtime/Actions/RemoveNode.cs create mode 100644 Runtime/Actions/RemoveNode.cs.uid diff --git a/Runtime/Actions/Node3D/OnCollision.cs b/Runtime/Actions/Node3D/OnCollision.cs index 9a7047b..43a69ac 100644 --- a/Runtime/Actions/Node3D/OnCollision.cs +++ b/Runtime/Actions/Node3D/OnCollision.cs @@ -7,7 +7,7 @@ namespace Rokojori { [Tool] [GlobalClass, Icon("res://addons/rokojori_action_library/Icons/OnEvent.svg") ] - public partial class OnCollision:Node + public partial class OnCollision:Node,iNodeState { [Export] public Area3D area; @@ -28,6 +28,24 @@ namespace Rokojori Dictionary _inside = new Dictionary(); + List _nodes = new List(); + + public List GetNodesInside() + { + _nodes = _nodes.Filter( n => n != null && IsInstanceValid( n ) ); + + return _nodes; + } + + public void OnNodeStateChanged( bool processEnabled, bool inputEnabled, bool physicsEnabled, bool signalsEnabled, + Node.ProcessModeEnum processMode, bool visible ) + { + if ( ! processEnabled || ! physicsEnabled || Node.ProcessModeEnum.Disabled == processMode ) + { + this.LogInfo( "Clearing nodes" ); + _nodes.Clear(); + } + } public override void _Ready() { @@ -56,9 +74,15 @@ namespace Rokojori return; } + if ( ! _nodes.Contains( n ) ) + { + _nodes.Add( n ); + } - this.LogInfo( "Selecting Enter", area.GlobalPosition, HierarchyName.Of( n ), ( (Node3D)n ).GlobalPosition ); + + + // this.LogInfo( "Selecting Enter", area.GlobalPosition, HierarchyName.Of( n ), ( (Node3D)n ).GlobalPosition ); Action.Trigger( onEntered ); if ( onInside == null ) @@ -81,6 +105,8 @@ namespace Rokojori void TriggerOnExited( Node n ) { + _nodes.Remove( n ); + if ( ! Selector.IsSelecting( selector, n ) ) { return; @@ -88,6 +114,8 @@ namespace Rokojori Action.Trigger( onExit ); + + if ( ! _inside.ContainsKey( n ) ) { return; diff --git a/Runtime/Actions/RemoveNode.cs b/Runtime/Actions/RemoveNode.cs new file mode 100644 index 0000000..acd0fc6 --- /dev/null +++ b/Runtime/Actions/RemoveNode.cs @@ -0,0 +1,21 @@ + +using Godot; +using System.Collections.Generic; + +namespace Rokojori +{ + [Tool][GlobalClass] + public partial class RemoveNode : Action + { + [Export] + public Node target; + + protected override void _OnTrigger() + { + if ( target != null ) + { + target.SelfDestroy(); + } + } + } +} \ No newline at end of file diff --git a/Runtime/Actions/RemoveNode.cs.uid b/Runtime/Actions/RemoveNode.cs.uid new file mode 100644 index 0000000..e87f12f --- /dev/null +++ b/Runtime/Actions/RemoveNode.cs.uid @@ -0,0 +1 @@ +uid://dq5kae8x62gre diff --git a/Runtime/App/App.cs b/Runtime/App/App.cs index 33745f3..3351b1c 100644 --- a/Runtime/App/App.cs +++ b/Runtime/App/App.cs @@ -50,8 +50,13 @@ namespace Rokojori - // [ExportToolButton( "Initialize")] - // public Callable InitializeButton => Callable.From( Initialize ); + [ExportToolButton( "Initialize")] + public Callable InitializeButton => Callable.From( Initialize ); + + public override void _Process( double delta ) + { + Engine.MaxFps = _fps; + } public void Initialize() { diff --git a/Runtime/Godot/NodeState.cs b/Runtime/Godot/NodeState.cs index d42999f..590335e 100644 --- a/Runtime/Godot/NodeState.cs +++ b/Runtime/Godot/NodeState.cs @@ -5,6 +5,13 @@ using System; namespace Rokojori { + public interface iNodeState + { + public void OnNodeStateChanged( bool processEnabled, bool inputEnabled, bool physicsEnabled, bool signalsEnabled, + Node.ProcessModeEnum processMode, bool visible ); + + } + public static class NodeState { public static void Configure( Node n, bool processEnabled, bool inputEnabled, bool physicsEnabled, bool signalsEnabled, @@ -22,6 +29,12 @@ namespace Rokojori n.ProcessMode = processMode; + if ( n is iNodeState ins ) + { + ins.OnNodeStateChanged( processEnabled, inputEnabled, physicsEnabled, signalsEnabled, + processMode, visible ); + } + if ( n is Node3D ) { diff --git a/Runtime/Interactions/Interactor.cs b/Runtime/Interactions/Interactor.cs index fe3684a..5efa639 100644 --- a/Runtime/Interactions/Interactor.cs +++ b/Runtime/Interactions/Interactor.cs @@ -15,6 +15,9 @@ namespace Rokojori [Export] public Sensor button; + [Export] + public Action onInteract; + public override void _Ready() { SensorManager.Register( this, button ); diff --git a/Runtime/Interactions/Pointer.cs b/Runtime/Interactions/Pointer.cs index 7b3274e..1a679f7 100644 --- a/Runtime/Interactions/Pointer.cs +++ b/Runtime/Interactions/Pointer.cs @@ -19,6 +19,9 @@ namespace Rokojori [Export] public Pointable pointable; + [Export] + public bool printPointables = false; + public override void _Process( double delta ) { if ( caster == null ) @@ -52,6 +55,11 @@ namespace Rokojori pointable.UpdatePointerState( this, true ); Highlight( HighlightActionType.Start, pointable ); } + + if ( printPointables ) + { + this.LogInfo( pointable ); + } } void Highlight( HighlightActionType type, Pointable p ) diff --git a/Runtime/Procedural/Assets/Grass/Windy Grass Shader.gdshader b/Runtime/Procedural/Assets/Grass/Windy Grass Shader.gdshader index da18f86..ec0c79e 100644 --- a/Runtime/Procedural/Assets/Grass/Windy Grass Shader.gdshader +++ b/Runtime/Procedural/Assets/Grass/Windy Grass Shader.gdshader @@ -91,30 +91,30 @@ vec3 limitDeform( vec3 originalWorldPosition, vec3 deformedWorldPosition ) return outputPosition; } -void vertex() +void vertex() { UV = UV * uv1_scale.xy + uv1_offset.xy; - + vec3 worldVertex = localToWorld( VERTEX, MODEL_MATRIX ).xyz; vec2 worldUV = worldVertex.xz * hslVariationUVScale; - + float hslAmountValue = ( 2.0 * texture( windNoise, mod( worldUV, vec2( 1,1 ) ) ).r - 1.0 ); - + vec3 albedoHSL = RGBtoHSL( albedo.rgb ) + hslAmountValue * hslVariation.xyz; //albedoHSL = RGBtoHSL( albedo.rgb ); //albedoHSL.y *= 1.0; - albedoHSL.x = mod( albedoHSL.x, 1 ); + albedoHSL.x = mod( albedoHSL.x, 1 ); albedoHSL = clamp( albedoHSL, vec3( 0,0,0 ), vec3( 1,1,1 ) ); - albedoColor = mix( albedo.rgb, HSLtoRGB( albedoHSL ), hslVariation.w ); - + albedoColor = mix( albedo.rgb, HSLtoRGB( albedoHSL ), hslVariation.w ); + + + - - if ( windEnabled ) - { + { float windAmount = normalizeToRange01( VERTEX.y, windStart, windEnd ); float rawWindAmount = windAmount; - windAmount = mix( windAmount, windAmount * windAmount, windWeightCurve ); + windAmount = mix( windAmount, windAmount * windAmount, windWeightCurve ); vec2 windUV = TIME * windSpeed + worldVertex.xz * windScale; float angle = texture( windNoise, windUV + windNoiseAngleOffset).r * PI * 2.0; float strength = texture( windNoise, windUV + windNoiseStrengthOffset ).r * windStrength; @@ -127,10 +127,10 @@ void vertex() if ( obstaclesEnabeld ) { - worldVertex = deform( worldVertex, obstacle1 ); - worldVertex = deform( worldVertex, obstacle2 ); - worldVertex = deform( worldVertex, obstacle3 ); - worldVertex = deform( worldVertex, obstacle4 ); + worldVertex = deform( worldVertex, obstacle1 ); + worldVertex = deform( worldVertex, obstacle2 ); + worldVertex = deform( worldVertex, obstacle3 ); + worldVertex = deform( worldVertex, obstacle4 ); worldVertex = limitDeform( originalWorldVertex, worldVertex ); } @@ -138,31 +138,31 @@ void vertex() VERTEX = worldToLocal( worldVertex, MODEL_MATRIX ); float minY = min( VERTEX.y, 0 ); // VERTEX.y = mix( VERTEX.y, max( 0, VERTEX.y - strength * windAmount), windHeightCompensation * 2.0f ); VERTEX.y = mix( VERTEX.y, max( minY, VERTEX.y - strength * windAmount), windHeightCompensation * 4.0f ); - + } - + } -void fragment() +void fragment() { vec2 base_uv = UV; vec4 albedo_tex = texture(texture_albedo, base_uv); ALBEDO = albedoColor * albedo_tex.rgb; BACKLIGHT = ALBEDO * albedoToBacklight + backlight; - - + + float metallic_tex = dot(texture(texture_metallic, base_uv), metallic_texture_channel); METALLIC = metallic_tex * metallic; SPECULAR = specular; - + vec4 roughness_texture_channel = vec4(1.0, 0.0, 0.0, 0.0); float roughness_tex = dot(texture(texture_roughness, base_uv), roughness_texture_channel); ROUGHNESS = roughness_tex * roughness; NORMAL_MAP = texture(texture_normal, base_uv).rgb; NORMAL_MAP_DEPTH = normal_scale; - + AO = dot(texture(texture_ambient_occlusion, base_uv), ao_texture_channel); AO_LIGHT_AFFECT = ao_light_affect; diff --git a/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs b/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs index d3eb17a..fc118be 100644 --- a/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs +++ b/Runtime/Rendering/Assets/Foliage/MeshInstanceFoliageData.cs @@ -47,6 +47,7 @@ namespace Rokojori particles.FractDelta = false; particles.CustomAabb = Box3.WithSize( 10000 ); + processMaterial.positionVariance.Set( renderLayer.renderer.noise ); processMaterial.rotationVariance.Set( renderLayer.renderer.noise ); @@ -60,6 +61,8 @@ namespace Rokojori particles.DrawPasses = 1; particles.DrawPass1 = meshInstance.Mesh; + particles.CastShadow = GeometryInstance3D.ShadowCastingSetting.Off; + } } } \ No newline at end of file