Skip to content

Commit

Permalink
added header and version check
Browse files Browse the repository at this point in the history
classes now check several conditions on creation
enums now have more correct names
fixed casting of classes by adding a class factory
added support for default values of Array and Dictionary
added Variant support
added cache for default values
added auto-update of C# bindings
FMT_STR is now in utils
fixed clear_all on scene changing
  • Loading branch information
DmitriySalnikov committed Sep 13, 2023
1 parent 4063176 commit 60fad14
Show file tree
Hide file tree
Showing 16 changed files with 829 additions and 295 deletions.
26 changes: 16 additions & 10 deletions examples_dd3d/DebugDrawDemoScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extends Node3D
@export var graph_frame_time_mode := true
@export var graph_is_enabled := true

var button_presses = {}
var button_presses := {}
var time := 0.0
var time2 := 0.0
var time3 := 0.0
Expand All @@ -48,16 +48,25 @@ func _ready() -> void:


func _is_key_just_pressed(key):
return button_presses[key] != Input.is_key_pressed(key) and Input.is_key_pressed(key)
if (button_presses[key] == 1):
button_presses[key] = 2
return true
return false


func _update_keys_just_press():
button_presses[KEY_LEFT] = Input.is_key_pressed(KEY_LEFT)
button_presses[KEY_UP] = Input.is_key_pressed(KEY_UP)
button_presses[KEY_F1] = Input.is_key_pressed(KEY_F1)
var set_key = func (k: Key): return (1 if button_presses[k] == 0 else button_presses[k]) if Input.is_key_pressed(k) else 0
button_presses[KEY_LEFT] = set_key.call(KEY_LEFT)
button_presses[KEY_UP] = set_key.call(KEY_UP)
button_presses[KEY_F1] = set_key.call(KEY_F1)


func _process(delta: float) -> void:
_update_keys_just_press()

if _is_key_just_pressed(KEY_F1):
zylann_example = !zylann_example

# Zylann's example :D
if zylann_example:
DebugDraw2D.clear_graphs()
Expand Down Expand Up @@ -91,8 +100,6 @@ func _process(delta: float) -> void:
DebugDraw3D.config.visible_instance_bounds = Input.is_key_pressed(KEY_RIGHT)

# Some property toggles
if _is_key_just_pressed(KEY_F1):
zylann_example = !zylann_example
if _is_key_just_pressed(KEY_LEFT):
DebugDraw3D.config.use_frustum_culling = !DebugDraw3D.config.use_frustum_culling
if _is_key_just_pressed(KEY_UP):
Expand All @@ -102,7 +109,6 @@ func _process(delta: float) -> void:
DebugDraw3D.config.cull_by_distance = start_culling_distance if DebugDraw3D.config.force_use_camera_from_scene else 0.0
else:
DebugDraw3D.config.cull_by_distance = start_culling_distance
_update_keys_just_press()

# Zones with black borders
for z in $Zones.get_children():
Expand All @@ -128,7 +134,7 @@ func _process(delta: float) -> void:
DebugDraw3D.draw_box($Box2.global_transform.origin, Vector3.ONE, Color.REBECCA_PURPLE)
DebugDraw3D.draw_box_xf(Transform3D(Basis(Vector3.UP, PI * 0.25).scaled(Vector3.ONE * 2), $Box3.global_transform.origin), Color.ROSY_BROWN)

DebugDraw3D.draw_box_xf($BoxOutOfDistabceCulling.global_transform, Color.RED)
DebugDraw3D.draw_box_xf($BoxOutOfDistanceCulling.global_transform, Color.RED)

DebugDraw3D.draw_aabb(AABB($AABB_fixed.global_transform.origin, Vector3(2, 1, 2)), Color.AQUA)
DebugDraw3D.draw_aabb_ab($AABB.get_child(0).global_transform.origin, $AABB.get_child(1).global_transform.origin, Color.DEEP_PINK)
Expand Down Expand Up @@ -257,7 +263,7 @@ func _text_tests():
if text_groups_show_stats:
DebugDraw2D.begin_text_group("-- Stats --", 3, Color.WHEAT)

var render_stats := DebugDraw2D.get_render_stats()
var render_stats := DebugDraw3D.get_render_stats()
if render_stats:
DebugDraw2D.set_text("Total", render_stats.total_geometry)
DebugDraw2D.set_text("Instances", render_stats.instances, 1)
Expand Down
4 changes: 2 additions & 2 deletions examples_dd3d/DebugDrawDemoScene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ stretch = true
[node name="Viewport" type="SubViewport" parent="Panel/ViewportContainer"]
handle_input_locally = false
size = Vector2i(300, 300)
size = Vector2i(2, 2)
render_target_update_mode = 0
[node name="CameraLayer2_5" type="Camera3D" parent="Panel/ViewportContainer/Viewport"]
Expand Down Expand Up @@ -337,7 +337,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.4103, 0, 6.71577)
[node name="Box3" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14.0067, 0, 10.5182)
[node name="BoxOutOfDistabceCulling" type="Node3D" parent="."]
[node name="BoxOutOfDistanceCulling" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.608, 0.344, -16.314)
[node name="AABB" type="Node3D" parent="."]
Expand Down
Loading

0 comments on commit 60fad14

Please sign in to comment.