Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Mar 26, 2023
1 parent 14113b2 commit 179ad80
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 24 deletions.
63 changes: 39 additions & 24 deletions addons/debug_draw_3d/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Version 4.x is not working correctly at the moment. Very early version! Use the Godot 3.x version!

![icon](/images/icon.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#.
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

## [Godot 3 version](https://github.com/DmitriySalnikov/godot_debug_draw_3d/tree/godot_3)

## Donations
## Support me

Your support adds motivation to develop my public projects.

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I53VZ2D)

Expand Down Expand Up @@ -51,28 +51,31 @@ Precompiled for:

## Download

To download, use the [Godot Asset Library](https://godotengine.org/asset-library/asset/1451) 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](https://github.com/DmitriySalnikov/godot_debug_draw_3d/releases) page (just download one of the "Source Codes" in assets).
To download, use the [Godot Asset Library](https://godotengine.org/asset-library/asset/NO_LINK_FOR_GODOT_4) 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](https://github.com/DmitriySalnikov/godot_debug_draw_3d/releases) page (just download one of the "Source Codes" in assets).

## Usage

1. Copy `addons/debug_draw_3d` to your `addons` folder, create it if the folder doesn't exist
1. Restart the editor
<!--
1. Rebuild the project if you use C#
1. Add `addons/debug_draw_3d/debug_draw.gd` or/and `addons/debug_draw_3d/DebugDrawCS.cs` to your project as autoload singleton
1. (Optionally) Enable the `Debug Draw 3D for Editor` plugin to enable debug drawing support inside the editor
2. (Optionally) Enable the `Debug Draw 3D for Editor` plugin to enable debug drawing support inside the editor
-->

## Examples

More examples can be found in the `debug_draw_examples/` folder.
More examples can be found in the `examples_dd3d/` folder.

Simple test:

```gdscript
func _process(delta: float) -> void:
var _time = OS.get_ticks_msec() / 1000.0
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)
DebugDraw.draw_box(box_pos, Vector3(1, 2, 1), Color(0, 1, 0))
DebugDraw.draw_line(line_begin, line_end, Color(1, 1, 0))
DebugDraw.set_text("Time", _time)
Expand All @@ -81,7 +84,7 @@ func _process(delta: float) -> void:
DebugDraw.set_text("delta", delta)
```

```csharp
<!-- ```csharp
public override void _Process(float delta)
{
var _time = OS.GetTicksMsec() / 1000f;
Expand All @@ -96,31 +99,41 @@ public override void _Process(float delta)
DebugDrawCS.SetText("FPS", Engine.GetFramesPerSecond());
DebugDrawCS.SetText("delta", delta);
}
```
``` -->

![screenshot_1](/images/screenshot_1.png)

## API

Information about all functions and properties is provided inside wrapper scripts `debug_draw.gd` and `DebugDrawCS.cs` in `addons/debug_draw_3d/`.
A list of all functions is available in the documentation inside the editor.
![screenshot_4](/images/screenshot_4.png)

Besides `DebugDraw`, you can also use `Dbg3`.

```gdscript
DebugDraw.draw_box_xf(Transform3D(), Color.GREEN)
Dbg3.draw_box_xf(Transform3D(), Color.GREEN)
```

But unfortunately at the moment `GDExtension` does not support adding documentation.

## Exporting a project
<!-- ## Exporting a project
Most likely, when exporting the release version of the game, you will not want to export the debugging library with it. So you will need to make additional configuration of the project.
Most likely, when exporting the release version of the game, you will not want to export the debugging library with it. So you will need to make additional configuration of the project. -->

### For GDScript
<!-- ### For GDScript
I made a dummy wrapper to remove unnecessary checks and calls in GDScript after exporting the release version of the game. It contains only definitions of functions and parameters, but does not execute any code.
To use it, you need to replace the original autoload with the dummy version (`res://addons/debug_draw_3d/debug_draw_dummy.gd`) before exporting.
*note:* I previously suggested overriding autoloads via project settings, but this approach did not work correctly and was removed in godot 3.5.
*note:* I previously suggested overriding autoloads via project settings, but this approach did not work correctly and was removed in godot 3.5. -->

### For C\#
<!-- ### For C\#
Just switch to the `release` build and all calls to this library will be removed.
Just switch to the `release` build and all calls to this library will be removed. -->

### For Native Libraries
<!-- ### For Native Libraries
In order to not export native libraries in the release build, you need to specify an exclusion filter.
Expand All @@ -130,24 +143,26 @@ To do this, select the profile in the `Export` menu, go to the `Resources` tab a
There are also additional parameters in the project settings to disable debug rendering in certain conditions.
![proj settings](/images/additional_proj_settings.png)
![proj settings](/images/additional_proj_settings.png) -->

### Remark
<!-- ### Remark
It will not be possible to completely get rid of this library in the release build in this way. Since empty functions can still be called, which can slow down code execution very slightly. To avoid this, you need to get rid of the calls of these functions in your code.
In `GDScript`, for example, you can use `if`'s before calling debugging functions so that they are not called in the release build. And in `C#`, conditional compilation (`#if DEBUG`) can be used so that calls to debugging functions occur only in the debug assembly.
In `GDScript`, for example, you can use `if`'s before calling debugging functions so that they are not called in the release build. And in `C#`, conditional compilation (`#if DEBUG`) can be used so that calls to debugging functions occur only in the debug assembly. -->

## Known issues and limitations

If you see `ERROR: _gl_debug_print: GL ERROR: Source: OpenGL Type: Error ID: 1281 Severity: High Message: GL_INVALID_VALUE error generated. Invalid offset and/or size.`, try increasing the value of `rendering/limits/buffers/immediate_buffer_size_kb`.

Enabling occlusion culing can lower fps instead of increasing it. At the moment I do not know how to speed up the calculation of the visibility of objects.

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).

**The C# binding is not ready yet.**

## More screenshots

`DebugDrawDemoScene.tscn` in editor
Expand Down
Binary file modified images/screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/screenshot_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 179ad80

Please sign in to comment.