Skip to content

Commit

Permalink
Added the no_depth_test mode
Browse files Browse the repository at this point in the history
added cpp.hint
  • Loading branch information
DmitriySalnikov committed Apr 13, 2024
1 parent 54c1e12 commit da6f672
Show file tree
Hide file tree
Showing 21 changed files with 518 additions and 211 deletions.
16 changes: 14 additions & 2 deletions docs/image_generator/preview_generator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum PreviewCase {
SphereDensity,
IcoSphere,
PlaneSize,
NoDepthTest,

Line,
Arrow,
Expand Down Expand Up @@ -55,6 +56,7 @@ var case_maps = {
PreviewCase.SphereDensity : CaseData.new(),
PreviewCase.IcoSphere : CaseData.new(),
PreviewCase.PlaneSize : CaseData.new(),
PreviewCase.NoDepthTest : CaseData.new("NoDepthTest"),

PreviewCase.Line : CaseData.new(),
PreviewCase.Arrow : CaseData.new("DrawMethods360Lines"),
Expand Down Expand Up @@ -102,6 +104,10 @@ var changed_by_code := false
changed_by_code = true
$Control.size = val
$GridRender.size = val * 2

if not Engine.is_editor_hint():
$Control.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
get_tree().root.size = viewport_size
changed_by_code = false

@export var anim_value_1: float = 0
Expand Down Expand Up @@ -156,7 +162,10 @@ func _set_anim():
%AnimationPlayer.seek(0)

if not Engine.is_editor_hint():
%AnimationPlayer.callback_mode_process = AnimationMixer.ANIMATION_CALLBACK_MODE_PROCESS_MANUAL
if Engine.get_version_info()["minor"] > 1:
%AnimationPlayer.callback_mode_process = 2
else:
%AnimationPlayer.playback_process_mode = 2

if not Engine.is_editor_hint() and OS.has_feature("movie"):
var anim: Animation = %AnimationPlayer.get_animation(%AnimationPlayer.current_animation)
Expand Down Expand Up @@ -257,7 +266,7 @@ func _process(delta):
%AnimationPlayer.advance(delta)

# Default 3D
var _s_def = DebugDraw3D.new_scoped_config().set_thickness(0.05)
var _s_def = DebugDraw3D.new_scoped_config().set_thickness(0.05).set_viewport($GridRender)

# Default 2D
DebugDraw2D.custom_canvas = $Control/PanelContainer
Expand Down Expand Up @@ -305,6 +314,9 @@ func _process(delta):
PreviewCase.PlaneSize:
var _s = DebugDraw3D.new_scoped_config().set_plane_size(anim_value_1)
DebugDraw3D.draw_plane(plane, Color.SEA_GREEN * Color(1,1,1,0.6), pxf.origin)
PreviewCase.NoDepthTest:
var _s = DebugDraw3D.new_scoped_config().set_no_depth_test(anim_value_1 > 0.5)
DebugDraw3D.draw_box(%OriginInstances.global_position, %OriginInstances.quaternion, Vector3.ONE * Vector3(0.6, 0.3, 0.3), Color.DEEP_PINK, true)

PreviewCase.Line:
var _s = DebugDraw3D.new_scoped_config().set_center_brightness(0.7).set_thickness(0.2)
Expand Down
190 changes: 186 additions & 4 deletions docs/image_generator/preview_generator.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=31 format=3 uid="uid://davayb2hh6h3u"]
[gd_scene load_steps=35 format=3 uid="uid://davayb2hh6h3u"]

[ext_resource type="Script" path="res://image_generator/preview_generator.gd" id="1_1iqys"]

Expand Down Expand Up @@ -2131,6 +2131,154 @@ tracks/9/keys = {
"times": PackedFloat32Array(0, 0.6, 0.75, 1.35)
}

[sub_resource type="Animation" id="Animation_hhbl7"]
resource_name = "NoDepthTest"
length = 2.0
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:viewport_size")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [Vector2i(256, 128)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:single_image")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath(".:lossless")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("GridRender/CameraOrigin/Camera3D:position")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, -0.150017, 1.72116)]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("GridRender/CameraOrigin/Camera3D:rotation")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0.296706, 0, 0)]
}
tracks/5/type = "value"
tracks/5/imported = false
tracks/5/enabled = true
tracks/5/path = NodePath("GridRender/CameraOrigin:rotation")
tracks/5/interp = 1
tracks/5/loop_wrap = true
tracks/5/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(-0.698132, 0, 0)]
}
tracks/6/type = "value"
tracks/6/imported = false
tracks/6/enabled = true
tracks/6/path = NodePath("OriginInstances:position")
tracks/6/interp = 1
tracks/6/loop_wrap = true
tracks/6/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0.44, 0)]
}
tracks/7/type = "value"
tracks/7/imported = false
tracks/7/enabled = true
tracks/7/path = NodePath("OriginInstances:rotation")
tracks/7/interp = 1
tracks/7/loop_wrap = true
tracks/7/keys = {
"times": PackedFloat32Array(0, 2),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, 0), Vector3(0, -6.28319, 0)]
}
tracks/8/type = "value"
tracks/8/imported = false
tracks/8/enabled = true
tracks/8/path = NodePath("OriginInstances:scale")
tracks/8/interp = 1
tracks/8/loop_wrap = true
tracks/8/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0.65, 0.65, 0.65)]
}
tracks/9/type = "value"
tracks/9/imported = false
tracks/9/enabled = true
tracks/9/path = NodePath("OriginUpVector:rotation")
tracks/9/interp = 1
tracks/9/loop_wrap = true
tracks/9/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0.261799, 0, 0)]
}
tracks/10/type = "value"
tracks/10/imported = false
tracks/10/enabled = true
tracks/10/path = NodePath("NoDepthTestBox:visible")
tracks/10/interp = 1
tracks/10/loop_wrap = true
tracks/10/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/11/type = "bezier"
tracks/11/imported = false
tracks/11/enabled = true
tracks/11/path = NodePath(".:anim_value_1")
tracks/11/interp = 1
tracks/11/loop_wrap = true
tracks/11/keys = {
"handle_modes": PackedInt32Array(0, 0, 0),
"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0, 0, -0.25, 0, 0.25, 0),
"times": PackedFloat32Array(0, 1, 2)
}

[sub_resource type="Animation" id="Animation_a5v07"]
resource_name = "PlaneSize"
loop_mode = 1
Expand Down Expand Up @@ -2459,6 +2607,18 @@ tracks/16/keys = {
"update": 0,
"values": [Vector3(0.308753, 0.314478, -0.54646)]
}
tracks/17/type = "value"
tracks/17/imported = false
tracks/17/enabled = true
tracks/17/path = NodePath("NoDepthTestBox:visible")
tracks/17/interp = 1
tracks/17/loop_wrap = true
tracks/17/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [false]
}

[sub_resource type="Animation" id="Animation_2pssc"]
resource_name = "SphereDensity"
Expand Down Expand Up @@ -2628,11 +2788,28 @@ _data = {
"LineBevel": SubResource("Animation_1l2uk"),
"LineCenterBrightness": SubResource("Animation_dj0n6"),
"LineThickness": SubResource("Animation_4yn7h"),
"NoDepthTest": SubResource("Animation_hhbl7"),
"PlaneSize": SubResource("Animation_a5v07"),
"RESET": SubResource("Animation_hchms"),
"SphereDensity": SubResource("Animation_2pssc")
}

[sub_resource type="Shader" id="Shader_t34go"]
code = "shader_type spatial;
render_mode unshaded;

void fragment() {
ALBEDO = vec3(0);
}
"

[sub_resource type="ShaderMaterial" id="ShaderMaterial_aonqq"]
render_priority = 0
shader = SubResource("Shader_t34go")

[sub_resource type="BoxMesh" id="BoxMesh_bwerf"]
material = SubResource("ShaderMaterial_aonqq")

[node name="PreviewGenerator" type="Control"]
layout_mode = 3
anchors_preset = 15
Expand All @@ -2641,7 +2818,7 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_1iqys")
preview_case = 5
preview_case = 6
anim_value_1 = 0.1
metadata/movie_file = "C:/My/Projects/GE/Addons/godot_debug_draw_3d/docs/images/classes/temp/_.png"

Expand Down Expand Up @@ -2695,7 +2872,6 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_qjyty")

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
callback_mode_method = 1
libraries = {
"": SubResource("AnimationLibrary_ce374")
}
Expand All @@ -2704,6 +2880,12 @@ libraries = {
unique_name_in_owner = true
transform = Transform3D(3.72127, 0, 3.72127, 0.0105216, 5.26265, -0.0105216, -3.72126, 0.0148798, 3.72126, 0, 0, 0)

[node name="NoDepthTestBox" type="MeshInstance3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(0.382746, 0, 0, 0, 0.666283, 0, 0, 0, 0.382746, 0, 0.440512, 0)
visible = false
mesh = SubResource("BoxMesh_bwerf")

[node name="OriginLine" type="Node3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(0.591832, 0.579682, -0.560092, -0.568178, 0.792886, 0.220241, 0.571759, 0.187886, 0.798618, 0, 0.46, 0)
Expand Down Expand Up @@ -2743,7 +2925,7 @@ transform = Transform3D(1, 6.25849e-07, 1.19209e-07, 2.98023e-08, 1, -3.72529e-0
transform = Transform3D(1, 3.12924e-07, 1.19209e-07, 2.98023e-08, 1, -3.72529e-07, 2.98023e-08, 2.98023e-07, 1, 0.308753, 0.314478, -0.54646)

[node name="OriginCameraFrustum" type="Node3D" parent="."]
transform = Transform3D(-0.619366, 0, 0.197195, 0, 0.65, 0, -0.197195, 0, -0.619366, 0, 0.44, 0)
transform = Transform3D(0.65, 0, 0, 0, 0.65, 0, 0, 0, 0.65, 0, 0.44, 0)

[node name="Camera3D" type="Camera3D" parent="OriginCameraFrustum"]
transform = Transform3D(-6.72483e-08, 0, 1.53846, 0, 1.53846, 0, -1.53846, 0, -6.72483e-08, 1.71191, 0, 0)
Expand Down
Binary file added docs/images/classes/NoDepthTest.webp
Binary file not shown.
6 changes: 4 additions & 2 deletions examples_dd3d/DebugDrawDemoScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func _physics_process(delta: float) -> void:

## Additional drawing in the Viewport
if true:
var _w1 = DebugDraw3D.new_scoped_config().set_viewport(%OtherWorldBox.get_viewport()).set_thickness(0.01).set_center_brightness(1)
var _w1 = DebugDraw3D.new_scoped_config().set_viewport(%OtherWorldBox.get_viewport()).set_thickness(0.01).set_center_brightness(1).set_no_depth_test(true)
DebugDraw3D.draw_box_xf(Transform3D(Basis()
.scaled(Vector3.ONE*0.3)
.rotated(Vector3(0,0,1), PI/4)
Expand Down Expand Up @@ -265,7 +265,7 @@ func main_update(delta: float) -> void:
DebugDraw3D.draw_gizmo($Misc/GizmoTransform.global_transform, DebugDraw3D.empty_color, true)
DebugDraw3D.draw_gizmo($Misc/GizmoOneColor.global_transform, Color.BROWN, true)
if true:
var _s123 = DebugDraw3D.new_scoped_config().set_center_brightness(0.5)
var _s123 = DebugDraw3D.new_scoped_config().set_center_brightness(0.5).set_no_depth_test(true)
DebugDraw3D.draw_gizmo($Misc/GizmoNormal.global_transform.orthonormalized(), DebugDraw3D.empty_color, false)

var tg : Transform3D = $Grids/Grid.global_transform
Expand Down Expand Up @@ -442,13 +442,15 @@ func _draw_array_of_boxes():
cubes_max_time = 60

if timer_cubes < 0:
var start_time = Time.get_ticks_usec()
for x in x_size:
for y in y_size:
for z in z_size:
var size = Vector3.ONE
cfg.set_thickness(randf_range(0, 0.1))
#var size = Vector3(randf_range(0.1, 100),randf_range(0.1, 100),randf_range(0.1, 100))
DebugDraw3D.draw_box(Vector3(x * mul, (-4-z) * mul, y * mul), Quaternion.IDENTITY, size, DebugDraw3D.empty_color, false, cubes_max_time)
#print("Draw Cubes: %fms" % ((Time.get_ticks_usec() - start_time) / 1000.0))
timer_cubes = cubes_max_time


Expand Down
16 changes: 12 additions & 4 deletions examples_dd3d/DebugDrawDemoScene.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=3 uid="uid://c3sccy6x0ht5j"]
[gd_scene load_steps=36 format=3 uid="uid://c3sccy6x0ht5j"]

[ext_resource type="Script" path="res://examples_dd3d/DebugDrawDemoScene.gd" id="1"]
[ext_resource type="FontFile" uid="uid://erdgllynwqkw" path="res://examples_dd3d/Roboto-Bold.ttf" id="2_aedbq"]
Expand Down Expand Up @@ -169,6 +169,10 @@ _data = {
}

[sub_resource type="CapsuleMesh" id="CapsuleMesh_tigpa"]
radius = 0.395
height = 1.825

[sub_resource type="BoxMesh" id="BoxMesh_b14rm"]

[sub_resource type="SphereShape3D" id="4"]
radius = 1.0
Expand Down Expand Up @@ -514,7 +518,7 @@ current = true
far = 5.0

[node name="MeshInstance3D" type="MeshInstance3D" parent="OtherWorld/SubViewport"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.57063, 0.6, 4.85623)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 6.57063, 0.6, 5.72253)
mesh = SubResource("CapsuleMesh_tigpa")

[node name="OtherWorldBox" type="Node3D" parent="OtherWorld/SubViewport"]
Expand All @@ -531,10 +535,14 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.403353, -0.331599, 2.22542)
transform = Transform3D(0.802141, -0.286294, -0.524028, -0.539546, 0.0285125, -0.841473, 0.25585, 0.957718, -0.131597, -0.475607, -0.670307, 2.30581)

[node name="Position" type="Node3D" parent="Misc"]
transform = Transform3D(1.51514, 0.589536, 1.00858, -1.34875, 0.662262, 1.133, 0, -0.462445, 2.90833, 0.853743, -0.331599, -1.73676)
transform = Transform3D(1.51514, 0.589536, 1.00858, -1.34875, 0.662262, 1.133, 0, -0.462445, 2.90833, 0.853743, 0.0843356, -1.73676)

[node name="GizmoNormal" type="Node3D" parent="Misc"]
transform = Transform3D(1.95938, 0, -0.848962, 0, 0.999999, 0, 0.525014, 0, 3.16837, 0.890203, -0.306246, 0.356159)
transform = Transform3D(0.965926, 0, -0.258819, 0, 1, 0, 0.258819, 0, 0.965926, 0.890203, -0.306246, 0.356159)

[node name="MeshInstance3D" type="MeshInstance3D" parent="Misc/GizmoNormal"]
transform = Transform3D(0.591801, 0, 4.47035e-08, 0, 0.591801, 0, -4.47035e-08, 0, 0.591801, 0, 0, 0)
mesh = SubResource("BoxMesh_b14rm")

[node name="GizmoTransform" type="Node3D" parent="Misc"]
transform = Transform3D(0.879881, 0.248446, -0.405072, -0.346604, 0.918688, -0.189411, 0.325077, 0.307059, 0.894449, -0.838587, -0.458, -0.176491)
Expand Down
Loading

0 comments on commit da6f672

Please sign in to comment.