Giter VIP home page Giter VIP logo

godot_debug_draw_3d's Introduction

icon

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#, and which was inspired by Zylann's GDScript addon

Support me

Your support adds motivation to develop my public projects.

Boosty

USDT-TRC20

USDT-TRC20 TEw934PrsffHsAn5M63SoHYRuZo984EF6v

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.

screenshot_web

Warning

  • Firefox most likely can't run this demo

Download

To download, use the Godot Asset Library or download the archive by clicking the button at the top of the main repository page: Code -> Download ZIP, then unzip it to your project folder. Or use one of the stable versions from the GitHub Releases page (just download one of the Source Codes in assets).

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:

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

API

This project has a separate documentation page.

Also, a list of all functions is available in the documentation inside the editor (see DebugDraw3D and DebugDraw2D).

screenshot_4

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.

More screenshots

DebugDrawDemoScene.tscn in editor screenshot_2

DebugDrawDemoScene.tscn in play mode screenshot_3

godot_debug_draw_3d's People

Contributors

dmitriysalnikov avatar emirthab avatar nicholas-maltbie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godot_debug_draw_3d's Issues

[Bug]: Rotation of DebugDraw3D.DrawBox() draws a warped/flattened box.

Godot version

v4.2.1.stable.mono.official [b09f793f5]

DebugDraw3D version

1.3.1

On which operating systems the error occurs

Windows

Using which renderers the error occurs

No response

Issue description

Applying rotation to DrawBox3D() results in unexpected deformation/warping of the box.

image

Video:

DrawBox3DRotationBug.mp4

Steps to reproduce

  1. Create a new Node3D and attach a new C-Sharp Script to it.
  2. Mark the script as [Tool] and add the following code:
  3.  public override void _Process(double delta)
     {
     	Vector3 size = new Vector3(8, 1, 4);
     	Quaternion rotation = Quaternion.FromEuler(new Vector3(0, 0, 45));
     	DebugDraw3D.DrawBox(Vector3.Zero, rotation, size, new Color(0x00FF00FF), true);
     }

You will see that the box is warped and no longer a rectangle.

Expected Result
The box should be rotated and still rectangular, the same way that a BoxMesh would be.

Minimal reproduction project

DrawBox3DBug.zip

  • Note: You might need to close & reopen the main.tscn for the box to render.

Add support for volumetric wireframes

By this I mean adding the ability to draw not only lines one pixel thick, but also thick, volumetric lines
.
Problem:
For example, in the ideal conditions of a test scene, everything is visible well, but in a scene with a large number of light objects, thin lines will be poorly visible.

Solution:
Draw lines using X-like shapes of the desired thickness.

The idea of implementation:
In the project settings, set the default thickness. If the thickness is greater than zero, then use volumetric lines when calling any draw_* function. And also before calling the draw_* function, you can specify the desired thickness by calling, for example, set_line_thickness. And after reset_line_thickness.

Other ways to solve this problem: increase the number of arguments of all functions, or make duplicates of all functions, but for volumetric lines.

Pros:

  • Better visibility.
  • More understanding of the volume and position in the space of the geometry.

Cons:

  • More mesh instances are needed for rendering.
  • Adding to the rendering queue is slower.

I hope to do this soon, but in the meantime I would like to see ideas and suggestions.
Or maybe there is an easier way to draw thick lines?..

[Bug]: Duration in set_text doesn't seems to work

Godot version

4.1.1

DebugDraw3D version

1.1.3

On which operating systems the error occurs

Windows

Using which renderers the error occurs

Vulkan

Issue description

I'm using this addons for almost all my visual debugging. Good job.

The only issues I've found was that the duration in DebugDraw.set_text("A","B",0,Color(),2.5) doesn't leave the message displayed for 2.5. It show it but only very few frames.

Steps to reproduce

From a fresh install

in any classes's ready function

func _ready():
  while(true):
    DebugDraw.set_text("A","B",0,Color(),2.5) # it's supposed to show A : B for 2.5 seconds
    await get_tree().create_timer(5.0,true,true).timeout # Wait 5 seconds

Minimal reproduction project

N/A

[Bug]: No way to enable the plugin

Godot version

4.0.2

DebugDraw3D version

1.1.0

On which operating systems the error occurs

Windows

Using which renderers the error occurs

Vulkan

Issue description

image
No option to enable the plugin to draw in the editor.

Steps to reproduce

.

Minimal reproduction project

.

[Bug]: Can't use `DebugDraw` in a `Viewport`-extending scripts

Godot version

4.0.3

DebugDraw3D version

1.0.0 (downloaded from the asset lib, not sure where to check for the version)

On which operating systems the error occurs

Linux

Using which renderers the error occurs

Vulkan, GLES3

Issue description

For some reason when trying to use DebugDraw in a Viewport script (or SubViewport, etc.) it refuses to work, yielding two possible errors:

  • "Cannot find member "draw_a" in base "Viewport.DebugDraw"." -- when typing, and
  • "The native enum "DebugDraw" does not behave like Dictionary and does not have methods of its own." when typed a valid member/function name.

Those errors don't show up on a Node-extending script, and the DebugDraw thing seem to work correctly in a Node script.

simplescreenrecorder-2023-05-30_15.22.29.webm

Steps to reproduce

create a script file in a project with DebugDraw installed, and put that in it:

extends Viewport

func _process(delta: float) -> void:
    DebugDraw.draw_sphere(Vector3.ZERO)

Minimal reproduction project

(contains literally a clean install of the addon from the asset lib and the above script)
DebugDrawViewportBug.zip

Add support for solid geometry

Add support for drawing transparent geometry consisting not only of wireframes, but also of triangles.

Pros:

  • Improves understanding of the volume of shapes.

The idea of implementation:
Create several new functions for drawing shapes.

I'm not sure how much people need it, so I'll just leave it here for now.

[Feature Request]: DebugDraw2D should be visible on 2D viewport too

Feature description

Currently all the functions in DebugDraw2D draw to the 3D viewport, and don't show anything in the 2D viewport. As the class is called DebugDraw2D, I had expected these functions would be useful for my 2D game, but alas this is not the case, I can see it in 3D but not in 2D.

Implementation Ideas

Functions in DebugDraw2D should draw to both the 2D and 3D viewports, so that they can be viewed in both the 2D and 3D editor tabs.

[Feature Request]: Viewport Scaling Visibility

Feature description

My project uses a 4k base resolution to make use of high resolution UI assets. as a result, the lines drawn by debug draw 3d become too thin to see often.
image

Implementation Ideas

Maybe a way to set line thickness would be helpful?

[Feature Request]: iOS Support

Feature description

We're developing games for iOS and are unfortunately unable to use this plugin on device. Adding support for iOS would be great.

Implementation Ideas

No response

C# bindings generator

Feature description

Would it be possible to have this as a separate addon that could be used with others? Or how difficult would it be to use this with another addon? Sorry I know this is off-topic a bit but I don't know another way to discuss with you

Implementation Ideas

No response

[Bug]: weird constant high gpu usage anywhere in the editor

Godot version

4.1.1 no c#

DebugDraw3D version

1.2.0

On which operating systems the error occurs

macOS

Using which renderers the error occurs

Vulkan

Issue description

so i've had a weird issue where in the editor (not an issue at all in game), there's very high gpu usage everywhere in the editor, on the previous project file i had it happen in empty 2d scenes, this time i noticed it in the script editor. but not in the game itself, the game taking focus away from the editor would reduce the gpu usage, at least when in the menu.

to test, i installed another plugin, tho it's gdscript not gdextension so maybe it's gdextension specific, but i saw no or nearly no change in gpu usage. i previously thought it was yet another plugin, which did have a bug that caused high gpu usage, and i created a fresh project to redo stuff after testing an empty project with that other plugin and not seeing the same issue, and after copying some files from before i remember it starting to a new project file, including with debug draw, and having the same issue.

i opened a nearly empty project file to test, and after installing, without even leaving the addons page, i was able to see the increase in gpu usage, and after deleting it with the integrated file browser, it went back down to baseline.

Steps to reproduce

install addon
look at gpu usage

Minimal reproduction project

N/A

[Bug]: Not working with Godot 4.1 RC1/2/3

Godot version

4.1 RC3

DebugDraw3D version

1.1.0

On which operating systems the error occurs

macOS

Using which renderers the error occurs

Vulkan

Issue description

Installing the plugin manually or using the assetlib this is the console text:

core/extension/gdextension.cpp:593 - GDExtension configuration file must contain a "configuration/compatibility_minimum" key: res://addons/debug_draw_3d/debug_draw_3d.gdextension
Failed loading resource: res://addons/debug_draw_3d/debug_draw_3d.gdextension. Make sure resources have been imported by opening the project in the editor at least once.
res://examples_dd3d/addon_icon.gd:5 - Parse Error: Identifier "DebugDraw" not declared in the current scope.
res://examples_dd3d/addon_icon.gd:6 - Parse Error: Identifier "DebugDraw" not declared in the current scope.
res://examples_dd3d/addon_icon.gd:7 - Parse Error: Identifier "DebugDraw" not declared in the current scope.
res://examples_dd3d/addon_icon.gd:7 - Parse Error: Identifier "DebugDraw" not declared in the current scope.
res://examples_dd3d/addon_icon.gd:8 - Parse Error: Identifier "DebugDraw" not declared in the current scope.

and so on...

Steps to reproduce

Install the plugin manually or via assetlib in Godot 4.1 RC 1/2/3

Minimal reproduction project

N/A

[Feature Request]: Drawing Planes

Feature description

Include a method for drawing Planes. This would be very helpful to visualize mouse interaction on 3D when using planes.

Implementation Ideas

Introduce a new method, such as draw_plane, that takes a Plane as a parameter. This method would then render a visual representation of the plane in the 3D space.

DebugDraw3D.draw_plane(plane, color, duration)

[Bug]: Error when running empty scene?

Godot version

v4.0.2 stable.mono.official 7a0977ce2

DebugDraw3D version

v1.0.0

On which operating systems the error occurs

Windows

Using which renderers the error occurs

Vulkan

Issue description

scenes without a camera produce errors

Steps to reproduce

I'm not sure which renderer I'm using but I assume it's Vulkan. I've never changed any settings for the renderer. I'm using Forward+

If I start a blank project, install debugdraw3d
then new empty scene based on Node3D - but do not add camera to scene
hit play
the console spits out errors

E 0:00:00:0764 DebugGeometryContainer::update_geometry: No camera found to perform frustum culling for DebugDraw
<C++ Source> src\debug_geometry_container.cpp:212 @ DebugGeometryContainer::update_geometry()

Minimal reproduction project

n/a

[Bug]: DebugDrawDefaultCanvas Control Node filters mouse input

Godot version

4.3.dev4.mono

DebugDraw3D version

1.3.0

On which operating systems the error occurs

Linux

Using which renderers the error occurs

Vulkan

Issue description

image

DebugDraw generates a Control node on top of the scene with the "Pass" mouse filter flag, which takes priority on every other node on the Scene.

Steps to reproduce

N/A

Minimal reproduction project

N/A

[Feature Request]: Provide an option to always draw debug geometry on top of everything else

Feature description

Hey there!

First of all, thanks for the great plugin. Having convenient debug drawing capabilities in godot with your plugin really makes life easier.

I have a question/feature request: Is it possible to draw the debug geometry always on top of everything else. So e.g. if I would draw a line visuallizing a raycast, would it be possible to still see the line once it enters a mesh? I would also find this convenient e.g. when I am calculating some positions in a mesh and want to make sure I actually calculated the position correctly by displaying them with debug draws. Hope this makes sense.

Maybe this is already possible, but if not it would be great to have this option as well.

Cheers,
Florentin

Solution approach

Provide an option to always draw debug geometry on top of everything else.

[Bug]: DrawCylinder radius results in cylinders that are 2x as wide as they should be.

Godot version

v4.2.1.stable.mono.official [b09f793f5]

DebugDraw3D version

1.3.1

On which operating systems the error occurs

Windows

Using which renderers the error occurs

No response

Issue description

Hi again.

Looks like the radius field in DrawCylinderAb and DrawCylinder ends up drawing the cylinder 2x as wide as it should.

This CylinderMesh and the DrawCylinder both have a radius of 0.5, but the debug cylinder is twice as wide.
image

Also viewed from the top, you can see the debug cylinder has a diameter of 2 even though it's radius should be 0.5:
image

Steps to reproduce

  1. Create a Node3D.
  2. Add Attach a script to it and add the following code:
public override void _Process(double delta)
{
    float radius = 0.5f;
    float height = 2.0f;
    
    DebugDraw3D.DrawCylinderAb(
        Vector3.Up * height / 2,
        -(Vector3.Up * height / 2),
        radius,
        Colors.Green
    );
}

You'll see that the radius is 2x what it should be. You can compare to a CylinderMesh or CylinderShape3D.

Minimal reproduction project

N/A

[Bug]: Can't Draw In Viewports that use thier own worlds

Godot version

v4.2.1.stable.official [b09f793f5]

DebugDraw3D version

1.3.1

On which operating systems the error occurs

Windows

Using which renderers the error occurs

Vulkan mobile

Issue description

Debug Draw 3D Can't be use in Viewport that have thier on worlds.

Steps to reproduce

Run the project with the "Own World 3D" variable on and off on the SubViewport

Minimal reproduction project

SubViewportBug.zip

[Bug]: No bindings for C#

Godot version

4.x

DebugDraw3D version

179ad80

On which operating systems the error occurs

No response

Using which renderers the error occurs

No response

Issue description

Due to differences in the work of GDExtension and the new versions of .NET in Godot, C# support was temporarily removed during porting.
To solve this, I need to either write a new API generator, or someone needs to extend the generator in the engine itself.

Steps to reproduce

N/A

Minimal reproduction project

N/A

[Bug]: DebugDraw.draw_grid generates an error on Godot 4.0

Godot version

4.0.3.stable.mono

DebugDraw3D version

current

On which operating systems the error occurs

Windows

Using which renderers the error occurs

Vulkan

Issue description

Getting this:

E 0:00:03:0013 root.gd:11 @ draw_gizmos(): Condition "_subdivision.x > 1024 * 1024" is true.
<C++ Source> src\debug_geometry_container.cpp:602 @ DebugGeometryContainer::draw_grid_xf()
root.gd:11 @ draw_gizmos()
root.gd:23 @ _process()

Steps to reproduce

func draw_gizmos():
	var size = 100
	var sub_divisions = 10
	# DebugDraw.draw_grid(Vector3.ZERO, Vector3.RIGHT* size, Vector3.BACK * size, Vector2(sub_divisions, sub_divisions), Color.AQUAMARINE)
	# DebugDraw.draw_grid(Vector3.ZERO, Vector3.UP * size, Vector3.BACK * size, Vector2(sub_divisions, sub_divisions), Color.aquamarine)
	DebugDraw.draw_grid(Vector3.ZERO, Vector3.RIGHT* size, Vector3.BACK * size, Vector2(sub_divisions, sub_divisions), Color.AQUAMARINE)

Minimal reproduction project

https://github.com/skooter500/miniature-rotary-phone

[Bug]: Macos Arm64 Support

Godot version

4.2.1 stable

DebugDraw3D version

1.3.0

On which operating systems the error occurs

macOS

Using which renderers the error occurs

No response

Issue description

Maybe I'm missing something, but adding the debug_draw_3d.gdextension in the addons folder yields this error message when restarting godot:

core/extension/gdextension.cpp:911 - No GDExtension library found for current OS and architecture (macos.arm64) in configuration file: res://addons/debug_draw_3d/debug_draw_3d.gdextension

Failed loading resource: res://addons/debug_draw_3d/debug_draw_3d.gdextension. Make sure resources have been imported by opening the project in the editor at least once.

This two month old reddit post seems to indicate this addons isn't compatible with mac M1/2/3 ? I have a Macbook Air M2.

Steps to reproduce

N/A

Minimal reproduction project

N/A

[Feature Request]: Web/WASM Support

Feature description

Any chance to get support for web builds? I'm not sure if this also isn't a bug since the readme says the library is disabled in release, but I'm still getting

index.js:14111 USER ERROR: No GDExtension library found for current OS and architecture (web.wasm32) in configuration file: res://addons/debug_draw_3d/debug_draw_3d.gdextension
onPrintError @ index.js:14111
index.js:14111    at: load (core/extension/gdextension.cpp:628)
onPrintError @ index.js:14111
index.js:14111 USER ERROR: Failed loading resource: res://addons/debug_draw_3d/debug_draw_3d.gdextension. Make sure resources have been imported by opening the project in the editor at least once.

and then a bunch of errors with DebugDraw not being found.

Implementation Ideas

No response

[Bug]:

Godot version

4.2

DebugDraw3D version

49df6b8

On which operating systems the error occurs

No response

Using which renderers the error occurs

No response

Issue description

hey I love this plugin and use it in every project and for teaching every day

If I build to Android right now. the game crashes. Deleting the plugin and the game builds fine.

Godot 4.2

Steps to reproduce

Build for Pixel 6a and the game crashes back to home screen straight away

Minimal reproduction project

https://github.com/skooter500/GP-2023

[Question]: Unable to draw lines in 2D

Godot version

v3.5.2.stable.mono.official [170ba337a]

DebugDraw3D version

1.0.2

On which operating systems the error occurs

Windows

Using which renderers the error occurs

GLES3

Issue description

Hello, I'm quite interested to try this plugin for my project as it seems really cool.

In earlier messages you asked to confirm the plugin is installed by searching the help for DebugDraw I believe. In my project and my test repro for this issue, I can't see that in the help.

image

image

I'm also kind of unclear about how to use this for 2D, is it possible? The arguments are Vector3, but not sure if these will display in a 2D view. I would ideally like to draw lines with with global position /world space position of 2D nodes and have them display over everything.

Steps to reproduce

Open this zip project and run the main scene

The text is showing but the lines are not drawing

		public override void _Process(float delta)
		{
        DebugDrawCS.Freeze3dRender = true;
        DebugDrawCS.ForceUseCameraFromScene = true;
        DebugDrawCS.DebugEnabled = true;
        DebugDrawCS.VisibleInstanceBounds = true;
        DebugDrawCS.DrawLine(new Vector3(0, 0, 0), new Vector3(200,200,0), Colors.Red, 1f);
        DebugDrawCS.DrawLine(new Vector3(0, 0, 3), new Vector3(1,1,3), Colors.Green, 1f);
        DebugDrawCS.DrawLine(new Vector3(0, 0, 8), new Vector3(8,8,8), Colors.Blue, 1f);
        DebugDrawCS.SetText("Test", "4");
        DebugDrawCS.SetText("Test2", "444");
        DebugDrawCS.GeometryRenderLayers = 6;
		}

Minimal reproduction project

DebugDrawTest.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.