Added debugd_draw_3d addon.

main
Martin Felis 2024-12-31 16:18:03 +01:00
parent 67b87bc603
commit 6c2670a281
15 changed files with 2372 additions and 33 deletions

9
.gitignore vendored
View File

@ -1,8 +1,17 @@
# Godot 4+ specific ignores # Godot 4+ specific ignores
.godot/ .godot/
# symlink to app_userdata
app_userdata
# Addon ignores # Addon ignores
addons/.gdunit_update/ addons/.gdunit_update/
addons/debug_draw_3d/libs/*android*
addons/debug_draw_3d/libs/*ios*
addons/debug_draw_3d/libs/*macos*
addons/debug_draw_3d/libs/*web*
demo/
examples_dd3d/
# Godot-specific ignores # Godot-specific ignores
.import/ .import/

View File

@ -1,10 +0,0 @@
<component name="libraryTable">
<library name="GdSdk Master" type="GdScript">
<properties path="$USER_HOME$/.cache/JetBrains/Rider2024.3/projects/tinyadventure.5da21fa0/sdk/GdSdk Master" version="Master" date="2024-06-01T15:14:16.000+02:00" />
<CLASSES />
<JAVADOC />
<SOURCES>
<root url="file://$USER_HOME$/.cache/JetBrains/Rider2024.3/projects/tinyadventure.5da21fa0/sdk/GdSdk Master" />
</SOURCES>
</library>
</component>

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 DmitriySalnikov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the Software), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, andor sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,162 @@
![icon](/images/icon_3d_128.png)
# Debug drawing utility for Godot
This is an add-on for debug drawing in 3D and for some 2D overlays, which is written in `C++` and can be used with `GDScript` or `C#`.
Based on my previous addon, which was developed [only for C#](https://github.com/DmitriySalnikov/godot_debug_draw_cs), and which was inspired by [Zylann's GDScript addon](https://github.com/Zylann/godot_debug_draw)
## [Documentation](https://dd3d.dmitriysalnikov.ru/docs/)
## [Godot 3 version](https://github.com/DmitriySalnikov/godot_debug_draw_3d/tree/godot_3)
## Support me
Your support adds motivation to develop my public projects.
<a href="https://boosty.to/dmitriysalnikov/donate"><img src="/docs/images/boosty.png" alt="Boosty" width=150px/></a>
<img src="/docs/images/USDT-TRC20.png" alt="USDT-TRC20" width=150px/>
<b>USDT-TRC20 TEw934PrsffHsAn5M63SoHYRuZo984EF6v</b>
## Features
3D:
* Arrow
* Billboard opaque square
* Box
* Camera Frustum
* Cylinder
* Gizmo
* Grid
* Line
* Line Path
* Line with Arrow
* Plane
* Points
* Position 3D (3 crossing axes)
* Sphere
2D:
* **[Work in progress]**
Overlay:
* Text (with grouping and coloring)
* FPS Graph
* Custom Graphs
Precompiled for:
* Windows
* Linux (built on Ubuntu 20.04)
* macOS (10.14+)
* Android (5.0+)
* iOS
* Web (Firefox not supported)
This addon supports working with several World3D and different Viewports.
There is also a no depth test mode and other settings that can be changed for each instance.
This library supports double-precision builds, for more information, [see the documentation](https://dd3d.dmitriysalnikov.ru/docs/1.4.5/md_docs_2DoublePrecision.html).
## [Interactive Web Demo](https://dd3d.dmitriysalnikov.ru/demo/)
[![screenshot_web](/images/screenshot_web.png)](https://dd3d.dmitriysalnikov.ru/demo/)
> [!WARNING]
>
> * Firefox most likely can't run this demo
## Download
To download, use the [Godot Asset Library](https://godotengine.org/asset-library/asset/1766) or use one of the stable versions from the [GitHub Releases](https://github.com/DmitriySalnikov/godot_debug_draw_3d/releases) page.
For versions prior to `1.4.5`, just download one of the `source codes` in the assets. For newer versions, download `debug-draw-3d_[version].zip`.
### Installation
* Close editor
* Copy `addons/debug_draw_3d` to your `addons` folder, create it if the folder doesn't exist
* Launch editor
## Examples
More examples can be found in the `examples_dd3d/` folder.
Simple test:
```gdscript
func _process(delta: float) -> void:
var _time = Time.get_ticks_msec() / 1000.0
var box_pos = Vector3(0, sin(_time * 4), 0)
var line_begin = Vector3(-1, sin(_time * 4), 0)
var line_end = Vector3(1, cos(_time * 4), 0)
DebugDraw3D.draw_box(box_pos, Vector3(1, 2, 1), Color(0, 1, 0))
DebugDraw3D.draw_line(line_begin, line_end, Color(1, 1, 0))
DebugDraw2D.set_text("Time", _time)
DebugDraw2D.set_text("Frames drawn", Engine.get_frames_drawn())
DebugDraw2D.set_text("FPS", Engine.get_frames_per_second())
DebugDraw2D.set_text("delta", delta)
```
![screenshot_1](/images/screenshot_1.png)
An example of using scoped configs:
```gdscript
@tool
extends Node3D
func _ready():
# Set the base scoped_config.
# Each frame will be reset to these scoped values.
DebugDraw3D.scoped_config().set_thickness(0.1).set_center_brightness(0.6)
func _process(delta):
# Draw using the base scoped config.
DebugDraw3D.draw_box(Vector3.ZERO, Quaternion.IDENTITY, Vector3.ONE * 2, Color.CORNFLOWER_BLUE)
if true:
# Create a scoped config that will exist until exiting this if.
var _s = DebugDraw3D.new_scoped_config().set_thickness(0).set_center_brightness(0.1)
# Draw with a thickness of 0
DebugDraw3D.draw_box(Vector3.ZERO, Quaternion.IDENTITY, Vector3.ONE, Color.RED)
# If necessary, the values inside this scope can be changed
# even before each call to draw_*.
_s.set_thickness(0.05)
DebugDraw3D.draw_box(Vector3(1,0,1), Quaternion.IDENTITY, Vector3.ONE * 1, Color.BLUE_VIOLET)
```
![screenshot_5](/images/screenshot_5.png)
> [!TIP]
>
> If you want to use a non-standard Viewport for rendering a 3d scene, then do not forget to specify it in the scoped config!
## API
This project has a separate [documentation](https://dd3d.dmitriysalnikov.ru/docs/) page.
Also, a list of all functions is available in the documentation inside the editor (see `DebugDraw3D` and `DebugDraw2D`).
![screenshot_4](/images/screenshot_4.png)
## Known issues and limitations
The text in the keys and values of a text group cannot contain multi-line strings.
The entire text overlay can only be placed in one corner, unlike `DataGraphs`.
[Frustum of Camera3D does not take into account the window size from ProjectSettings](https://github.com/godotengine/godot/issues/70362).
## More screenshots
`DebugDrawDemoScene.tscn` in editor
![screenshot_2](/images/screenshot_2.png)
`DebugDrawDemoScene.tscn` in play mode
![screenshot_3](/images/screenshot_3.png)

View File

@ -0,0 +1,153 @@
[configuration]
entry_symbol = "debug_draw_3d_library_init"
compatibility_minimum = "4.1.4"
reloadable = false
[dependencies]
; example.x86_64 = { "relative or absolute path to the dependency" : "the path relative to the exported project", }
; -------------------------------------
; debug
macos = { }
windows.x86_64 = { }
linux.x86_64 = { }
; by default godot is using threads
web.wasm32.nothreads = {}
web.wasm32 = {}
android.arm32 = { }
android.arm64 = { }
android.x86_32 = { }
android.x86_64 = { }
ios = {}
; -------------------------------------
; release no debug draw
macos.template_release = { }
windows.template_release.x86_64 = { }
linux.template_release.x86_64 = { }
web.template_release.wasm32.nothreads = { }
web.template_release.wasm32 = { }
android.template_release.arm32 = { }
android.template_release.arm64 = { }
android.template_release.x86_32 = { }
android.template_release.x86_64 = { }
ios.template_release = {}
; -------------------------------------
; release forced debug draw
macos.template_release.forced_dd3d = { }
windows.template_release.x86_64.forced_dd3d = { }
linux.template_release.x86_64.forced_dd3d = { }
web.template_release.wasm32.nothreads.forced_dd3d = { }
web.template_release.wasm32.forced_dd3d = { }
ios.template_release.forced_dd3d = {}
[libraries]
; -------------------------------------
; debug
macos = "libs/libdd3d.macos.editor.universal.framework"
windows.x86_64 = "libs/libdd3d.windows.editor.x86_64.dll"
linux.x86_64 = "libs/libdd3d.linux.editor.x86_64.so"
web.wasm32.nothreads = "libs/libdd3d.web.template_debug.wasm32.wasm"
web.wasm32 = "libs/libdd3d.web.template_debug.wasm32.threads.wasm"
android.arm32 = "libs/libdd3d.android.template_debug.arm32.so"
android.arm64 = "libs/libdd3d.android.template_debug.arm64.so"
android.x86_32 = "libs/libdd3d.android.template_debug.x86_32.so"
android.x86_64 = "libs/libdd3d.android.template_debug.x86_64.so"
ios = "libs/libdd3d.ios.template_debug.universal.dylib"
; -------------------------------------
; release no debug draw
macos.template_release = "libs/libdd3d.macos.template_release.universal.framework"
windows.template_release.x86_64 = "libs/libdd3d.windows.template_release.x86_64.dll"
linux.template_release.x86_64 = "libs/libdd3d.linux.template_release.x86_64.so"
web.template_release.wasm32.nothreads = "libs/libdd3d.web.template_release.wasm32.wasm"
web.template_release.wasm32 = "libs/libdd3d.web.template_release.wasm32.threads.wasm"
android.template_release.arm32 = "libs/libdd3d.android.template_release.arm32.so"
android.template_release.arm64 = "libs/libdd3d.android.template_release.arm64.so"
android.template_release.x86_32 = "libs/libdd3d.android.template_release.x86_32.so"
android.template_release.x86_64 = "libs/libdd3d.android.template_release.x86_64.so"
ios.template_release = "libs/libdd3d.ios.template_release.universal.dylib"
; -------------------------------------
; release forced debug draw
macos.template_release.forced_dd3d = "libs/libdd3d.macos.template_release.universal.enabled.framework"
windows.template_release.x86_64.forced_dd3d = "libs/libdd3d.windows.template_release.x86_64.enabled.dll"
linux.template_release.x86_64.forced_dd3d = "libs/libdd3d.linux.template_release.x86_64.enabled.so"
web.template_release.wasm32.nothreads.forced_dd3d = "libs/libdd3d.web.template_release.wasm32.enabled.wasm"
web.template_release.wasm32.forced_dd3d = "libs/libdd3d.web.template_release.wasm32.threads.enabled.wasm"
ios.template_release.forced_dd3d = "libs/libdd3d.ios.template_release.universal.enabled.dylib"
; -------------------------------------
; DOUBLE PRECISION
; -------------------------------------
; -------------------------------------
; debug
macos.double = "libs/libdd3d.macos.editor.universal.double.framework"
windows.x86_64.double = "libs/libdd3d.windows.editor.x86_64.double.dll"
linux.x86_64.double = "libs/libdd3d.linux.editor.x86_64.double.so"
web.wasm32.nothreads.double = "libs/libdd3d.web.template_debug.wasm32.double.wasm"
web.wasm32.double = "libs/libdd3d.web.template_debug.wasm32.threads.double.wasm"
android.arm32.double = "libs/libdd3d.android.template_debug.arm32.double.so"
android.arm64.double = "libs/libdd3d.android.template_debug.arm64.double.so"
android.x86_32.double = "libs/libdd3d.android.template_debug.x86_32.double.so"
android.x86_64.double = "libs/libdd3d.android.template_debug.x86_64.double.so"
ios.double = "libs/libdd3d.ios.template_debug.universal.dylib"
; -------------------------------------
; release no debug draw
macos.template_release.double = "libs/libdd3d.macos.template_release.universal.double.framework"
windows.template_release.x86_64.double = "libs/libdd3d.windows.template_release.x86_64.double.dll"
linux.template_release.x86_64.double = "libs/libdd3d.linux.template_release.x86_64.double.so"
web.template_release.wasm32.nothreads.double = "libs/libdd3d.web.template_release.wasm32.double.wasm"
web.template_release.wasm32.double = "libs/libdd3d.web.template_release.wasm32.threads.double.wasm"
android.template_release.arm32.double = "libs/libdd3d.android.template_release.arm32.double.so"
android.template_release.arm64.double = "libs/libdd3d.android.template_release.arm64.double.so"
android.template_release.x86_32.double = "libs/libdd3d.android.template_release.x86_32.double.so"
android.template_release.x86_64.double = "libs/libdd3d.android.template_release.x86_64.double.so"
ios.template_release.double = "libs/libdd3d.ios.template_release.universal.double.dylib"
; -------------------------------------
; release forced debug draw
macos.template_release.forced_dd3d.double = "libs/libdd3d.macos.template_release.universal.enabled.double.framework"
windows.template_release.x86_64.forced_dd3d.double = "libs/libdd3d.windows.template_release.x86_64.enabled.double.dll"
linux.template_release.x86_64.forced_dd3d.double = "libs/libdd3d.linux.template_release.x86_64.enabled.double.so"
web.template_release.wasm32.nothreads.forced_dd3d.double = "libs/libdd3d.web.template_release.wasm32.enabled.double.wasm"
web.template_release.wasm32.forced_dd3d.double = "libs/libdd3d.web.template_release.wasm32.threads.enabled.double.wasm"
ios.template_release.forced_dd3d.double = "libs/libdd3d.ios.template_release.universal.enabled.double.dylib"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,238 @@
Generation of bindings started, output file: res://addons/debug_draw_3d/gen/csharp/DebugDrawGeneratedAPI.generated.cs
Log file: res://addons/debug_draw_3d/gen/csharp/log.txt
Hold Shift to print information on the Output panel when manually starting generation via the 'Project - Tools - Debug Draw' menu
Class: DebugDraw2D
Wrapper...
Constants...
Enums...
Methods...
clear_all
begin_text_group
end_text_group
set_text
clear_texts
create_graph
create_fps_graph
graph_update_data
remove_graph
clear_graphs
get_graph
get_graph_names
get_render_stats
Properties...
empty_color
debug_enabled
config
custom_canvas
Class: DebugDraw2DStats
Wrapper...
Constants...
Enums...
Methods...
Properties...
overlay_text_groups
overlay_text_lines
overlay_graphs_enabled
overlay_graphs_total
Class: DebugDraw2DConfig
Wrapper...
Constants...
Enums...
BlockPosition
Methods...
Properties...
graphs_base_offset
text_block_position
text_block_offset
text_padding
text_default_duration
text_default_size
text_foreground_color
text_background_color
text_custom_font
Class: DebugDraw2DGraph
Wrapper...
Constants...
Enums...
GraphPosition
GraphSide
TextFlags
Methods...
get_title
set_parent
Properties...
enabled
upside_down
show_title
show_text_flags
size
buffer_size
offset
corner
line_width
line_color
background_color
border_color
text_suffix
custom_font
title_size
text_size
title_color
text_color
text_precision
parent_graph
parent_graph_side
data_getter
Class: DebugDraw2DFPSGraph
Wrapper...
Constants...
Enums...
Methods...
Properties...
frame_time_mode
Class: DebugDraw3D
Wrapper...
Constants...
Enums...
PointType
Methods...
regenerate_geometry_meshes
clear_all
draw_sphere
color will be remapped to arg_2
draw_sphere_xf
color will be remapped to arg_2
draw_cylinder
color will be remapped to arg_2
draw_cylinder_ab
color will be remapped to arg_2
draw_box
color will be remapped to arg_2
draw_box_ab
color will be remapped to arg_2
draw_box_xf
color will be remapped to arg_2
draw_aabb
color will be remapped to arg_2
draw_aabb_ab
color will be remapped to arg_2
draw_line_hit
hit_color will be remapped to arg_2
after_hit_color will be remapped to arg_2
draw_line_hit_offset
hit_color will be remapped to arg_2
after_hit_color will be remapped to arg_2
draw_line
color will be remapped to arg_2
draw_lines
color will be remapped to arg_2
draw_ray
color will be remapped to arg_2
draw_line_path
color will be remapped to arg_2
draw_arrowhead
color will be remapped to arg_2
draw_arrow
color will be remapped to arg_2
draw_arrow_ray
color will be remapped to arg_2
draw_arrow_path
color will be remapped to arg_2
draw_point_path
points_color will be remapped to arg_2
lines_color will be remapped to arg_2
draw_square
color will be remapped to arg_2
draw_plane
color will be remapped to arg_2
draw_points
color will be remapped to arg_2
draw_camera_frustum
color will be remapped to arg_2
draw_camera_frustum_planes
color will be remapped to arg_2
draw_position
color will be remapped to arg_2
draw_gizmo
color will be remapped to arg_2
draw_grid
color will be remapped to arg_2
draw_grid_xf
color will be remapped to arg_2
get_render_stats
get_render_stats_for_world
new_scoped_config
scoped_config
Properties...
empty_color
debug_enabled
config
Class: DebugDraw3DStats
Wrapper...
Constants...
Enums...
Methods...
Properties...
instances
lines
instances_physics
lines_physics
total_geometry
visible_instances
visible_lines
total_visible
time_filling_buffers_instances_usec
time_filling_buffers_lines_usec
time_filling_buffers_instances_physics_usec
time_filling_buffers_lines_physics_usec
total_time_filling_buffers_usec
time_culling_instances_usec
time_culling_lines_usec
total_time_culling_usec
total_time_spent_usec
created_scoped_configs
orphan_scoped_configs
Class: DebugDraw3DConfig
Wrapper...
Constants...
Enums...
Methods...
Properties...
freeze_3d_render
visible_instance_bounds
use_frustum_culling
frustum_length_scale
force_use_camera_from_scene
geometry_render_layers
line_hit_color
line_after_hit_color
Class: DebugDraw3DScopeConfig
Wrapper...
Constants...
Enums...
Methods...
set_thickness
get_thickness
set_center_brightness
get_center_brightness
set_hd_sphere
is_hd_sphere
set_plane_size
get_plane_size
set_viewport
get_viewport
set_no_depth_test
is_no_depth_test
Properties...
Class: DebugDrawManager
Wrapper...
Constants...
Enums...
Methods...
clear_all
Properties...
debug_enabled
DebugDraw utilities:
Arguments remap...
Class factory...
The generation process is completed!

View File

View File

@ -1,23 +0,0 @@
extends Panel
var build_system:BuildSystem = null
@onready var build_system_active_label: Label = %BuildSystemActiveLabel
@onready var build_system_hover_object: Label = %BuildSystemHoverObject
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
if build_system == null:
build_system_active_label.text = "Not found"
build_system_hover_object.text = ""
return
if build_system.is_active:
build_system_active_label.text = "true"
else:
build_system_active_label.text = "false"
if build_system.hovered_existing_structure and not build_system.hovered_existing_structure.is_queued_for_deletion():
build_system_hover_object.text = build_system.hovered_existing_structure.get_path()
else:
build_system_hover_object.text = ""