Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Dec 21, 2023
1 parent de997c0 commit 4fc8aea
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 89 deletions.
2 changes: 2 additions & 0 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ OUTPUT_DIRECTORY = obj/doxygen

INPUT = docs/Introduction.md \
docs/Examples.md \
docs/Export.md \
docs/Build.md \
src/debug_draw_manager.h \
src/2d/debug_draw_2d.h \
src/2d/config_2d.h \
Expand Down
92 changes: 6 additions & 86 deletions addons/debug_draw_3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This is an add-on for debug drawing in 3D and for some 2D overlays, which is wri

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

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

## Support me
Expand Down Expand Up @@ -52,15 +54,14 @@ Precompiled for:
* Android
* Web (WebAssembly)

## [Interactive Web Demo](https://dmitriysalnikov.github.io/godot_debug_draw_3d/)
## [Interactive Web Demo](https://dd3d.dmitriysalnikov.ru/)

[![screenshot_web](/images/screenshot_web.png)](https://dmitriysalnikov.github.io/godot_debug_draw_3d/)
[![screenshot_web](/images/screenshot_web.png)](https://dd3d.dmitriysalnikov.ru/)

Thanks to Nick Maltbie ([nicholas-maltbie](https://github.com/nicholas-maltbie)) ([#24](https://github.com/DmitriySalnikov/godot_debug_draw_3d/pull/24))

> **Warning**
>
> * The web version uses `OpenGL`, which in `Godot 4.1` incorrectly assigns colors to the last rendered geometry instances.
> * Firefox most likely can't run this demo
## Download
Expand All @@ -73,12 +74,6 @@ To download, use the [Godot Asset Library](https://godotengine.org/asset-library
* Copy `addons/debug_draw_3d` to your `addons` folder, create it if the folder doesn't exist
* Launch editor

### C\#

When you start the engine for the first time, bindings for `C#` will be generated automatically. If this does not happen, you can manually generate them through the `Project - Tools - Debug Draw` menu.

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

## Examples

More examples can be found in the `examples_dd3d/` folder.
Expand All @@ -100,51 +95,15 @@ func _process(delta: float) -> void:
DebugDraw2D.set_text("delta", delta)
```

```csharp
public override void _Process(float delta)
{
var _time = Time.GetTicksMsec() / 1000.0f;
var box_pos = new Vector3(0, Mathf.Sin(_time * 4f), 0);
var line_begin = new Vector3(-1, Mathf.Sin(_time * 4f), 0);
var line_end = new Vector3(1, Mathf.Cos(_time * 4f), 0);

DebugDraw3D.DrawBox(box_pos, new Vector3(1, 2, 1), new Color(0, 1, 0));
DebugDraw3D.DrawLine(line_begin, line_end, new Color(1, 1, 0));
DebugDraw2D.SetText("Time", _time);
DebugDraw2D.SetText("Frames drawn", Engine.GetFramesDrawn());
DebugDraw2D.SetText("FPS", Engine.GetFramesPerSecond());
DebugDraw2D.SetText("delta", delta);
}
```

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

## API

A list of all functions is available in the documentation inside the editor.
![screenshot_4](/images/screenshot_4.png)

Besides `DebugDraw2D/3D`, you can also use `Dbg2/3`.

```gdscript
DebugDraw3D.draw_box_xf(Transform3D(), Color.GREEN)
Dbg3.draw_box_xf(Transform3D(), Color.GREEN)
DebugDraw2D.set_text("delta", delta)
Dbg2.set_text("delta", delta)
```

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

## Exporting a project

Most likely, when exporting a release version of a game, you don't want to export the debug library along with it. But since there is still no `Conditional Compilation` in `GDScript`, so I decided to create a `dummy` library that has the same API as a regular library, but has minimal impact on performance, even if calls to its methods occur. The `dummy` library is used by default in the release version. However if you need to use debug rendering in the release version, then you can add the `forced_dd3d` feature when exporting. In this case, the release library with all the functionality will be used.

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

In C#, these tags are not taken into account at compile time, so the Release build will use Runtime checks to disable draw calls. If you want to avoid this, you can manually specify the `FORCED_DD3D` symbol.
![screenshot_4](/images/screenshot_4.png)

![csharp_compilation_symbols](/images/csharp_compilation_symbols.png)
But also this project has a separate [documentation](https://dd3d.dmitriysalnikov.ru/) page.

## Known issues and limitations

Expand All @@ -165,42 +124,3 @@ The entire text overlay can only be placed in one corner, unlike `DataGraphs`.

`DebugDrawDemoScene.tscn` in play mode
![screenshot_3](/images/screenshot_3.png)

## Build

As well as for the engine itself, you will need to configure the [environment](https://docs.godotengine.org/en/4.1/contributing/development/compiling/index.html).
And also you may need to apply several patches:

```bash
cd godot-cpp
# Optional
## Build only the necessary classes
git apply --ignore-space-change --ignore-whitespace ../patches/godot_cpp_exclude_unused_classes.patch
## Faster build
git apply --ignore-space-change --ignore-whitespace ../patches/unity_build.patch
## Hide useless function exports. Can greatly reduce the size of libraries
git apply --ignore-space-change --ignore-whitespace ../patches/visibilty_hidden.patch
```

Then you can just run scons as usual:

```bash
# build for the current system.
# target=editor is used for both the editor and the debug template.
scons target=editor dev_build=yes debug_symbols=yes
# Android build. ANDROID_NDK_ROOT is required in your environment variables.
# Or ANDROID_HOME with 'ndk/23.2.8568313' installed.
scons platform=android target=template_release arch=arm64v8
# Web build. GDExtension for Web currently works best with Emscripten '3.1.39'
scons platform=web target=template_debug
```

### JavaScript/Web build

If you have problems running the Web version of your project, you can try using the scripts and tips from [this page](https://gist.github.com/DmitriySalnikov/ce12ff100df4e3352176768f5232abfa).

If you too want to add an [Interactive Demo](https://dmitriysalnikov.github.io/godot_debug_draw_3d/) to your GitHub repository, then you can see how Nick Maltbie ([nicholas-maltbie](https://github.com/nicholas-maltbie)) added this feature to this repository in PR [#24](https://github.com/DmitriySalnikov/godot_debug_draw_3d/pull/24)!

In short, you need to activate `Extension Support` when exporting and add the [gzuidhof/coi-serviceworker](https://github.com/gzuidhof/coi-serviceworker) to the \<head\> and to the export folder. Then you will need to somehow publish a demo on the GitHub pages, as for example done in [#24](https://github.com/DmitriySalnikov/godot_debug_draw_3d/pull/24/files#diff-46a620e221376649fe75b0aaf2f607fee47f0d47db1d37bc08bb4a5f11b1af98).

![export_web_for_github](images/export_web_for_github.png)
38 changes: 38 additions & 0 deletions docs/Build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Build

As well as for the engine itself, you will need to configure the [environment](https://docs.godotengine.org/en/4.1/contributing/development/compiling/index.html).
And also you may need to apply several patches:

```python
cd godot-cpp
# Optional
# #Build only the necessary classes
git apply --ignore-space-change --ignore-whitespace ../patches/godot_cpp_exclude_unused_classes.patch
# #Faster builds and larger binaries
git apply --ignore-space-change --ignore-whitespace ../patches/unity_build.patch
# #Hide useless function exports. Can greatly reduce the size of libraries
git apply --ignore-space-change --ignore-whitespace ../patches/visibilty_hidden.patch
```

Then you can just run scons as usual:

```python
# build for the current system.
# target=editor is used for both the editor and the debug template.
scons target=editor dev_build=yes debug_symbols=yes
# Android build. ANDROID_NDK_ROOT is required in your environment variables.
# Or ANDROID_HOME with 'ndk/23.2.8568313' installed.
scons platform=android target=template_release arch=arm64v8
# Web build. GDExtension for Web currently works best with Emscripten '3.1.39'
scons platform=web target=template_debug
```

## JavaScript/Web build

If you have problems running the Web version of your project, you can try using the scripts and tips from [this page](https://gist.github.com/DmitriySalnikov/ce12ff100df4e3352176768f5232abfa).

If you too want to add an [Interactive Demo](https://dmitriysalnikov.github.io/godot_debug_draw_3d/) to your GitHub repository, then you can see how Nick Maltbie ([nicholas-maltbie](https://github.com/nicholas-maltbie)) added this feature to this repository in PR [#24](https://github.com/DmitriySalnikov/godot_debug_draw_3d/pull/24)!

In short, you need to activate `Extension Support` when exporting and add the [gzuidhof/coi-serviceworker](https://github.com/gzuidhof/coi-serviceworker) to the \<head\> and to the export folder. Then you will need to somehow publish a demo on the GitHub pages, as for example done in [#24](https://github.com/DmitriySalnikov/godot_debug_draw_3d/pull/24/files#diff-46a620e221376649fe75b0aaf2f607fee47f0d47db1d37bc08bb4a5f11b1af98).

![](images/export_web_for_github.png)
2 changes: 1 addition & 1 deletion docs/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func _process(delta: float) -> void:

When you start the engine for the first time, bindings for `C#` will be generated automatically. If this does not happen, you can manually generate them through the `Project - Tools - Debug Draw` menu.

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

```csharp
public override void _Process(float delta)
Expand Down
13 changes: 13 additions & 0 deletions docs/Export.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Exporting a project

Most likely, when exporting a release version of a game, you don't want to export the debug library along with it. But since there is still no `Conditional Compilation` in `GDScript`, so I decided to create a `dummy` library that has the same API as a regular library, but has minimal impact on performance, even if calls to its methods occur. The `dummy` library is used by default in the release version. However if you need to use debug rendering in the release version, then you can add the `forced_dd3d` feature when exporting. In this case, the release library with all the functionality will be used.

![](images/export_features.png)

In C#, these tags are not taken into account at compile time, so the Release build will use Runtime checks to disable draw calls. If you want to avoid this, you can manually specify the `FORCED_DD3D` symbol.

![](images/csharp_compilation_symbols.png)

@note
Though it's still best that these calls don't happen at all.
In the future, it is possible that the dependency on the native library in the release version will be removed and replaced by dummy GDScript.
6 changes: 5 additions & 1 deletion docs/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Precompiled for:

To download, use the [Godot Asset Library](https://godotengine.org/asset-library/asset/1766) or download the archive from the [GithHub](https://github.com/DmitriySalnikov/godot_debug_draw_3d) page by clicking the button at the top of the 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).

### Installation

* Close editor
* Copy `addons/debug_draw_3d` to your `addons` folder, create it if the folder doesn't exist
* Launch editor
Expand All @@ -60,6 +62,8 @@ Your support adds motivation to develop my public projects.

<a href="https://boosty.to/dmitriysalnikov/donate"><img src="https://static.boosty.to/assets/images/boostyDomainLogo.5Vlxt.svg" alt="Boosty" width=120px/></a>

## Next step
## Next steps

[Examples](Examples.md)

[Classes](annotated.html)
1 change: 1 addition & 0 deletions docs/doxygen_resources/doxygen-awesome-css
Submodule doxygen-awesome-css added at df88fe
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
3 changes: 2 additions & 1 deletion examples_dd3d/DebugDrawDemoScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,8 @@ func _text_tests():
if text_groups_show_hints:
DebugDraw2D.begin_text_group("controls", 1024, Color.WHITE, false)
DebugDraw2D.set_text("Shift: change render layers", DebugDraw3D.config.geometry_render_layers, 1)
DebugDraw2D.set_text("Ctrl: toggle anti-aliasing", "MSAA 4x" if get_viewport().msaa_3d == Viewport.MSAA_4X else "Disabled", 2)
if not OS.has_feature("web"):
DebugDraw2D.set_text("Ctrl: toggle anti-aliasing", "MSAA 4x" if get_viewport().msaa_3d == Viewport.MSAA_4X else "Disabled", 2)
DebugDraw2D.set_text("Down: freeze render", DebugDraw3D.config.freeze_3d_render, 3)
DebugDraw2D.set_text("Up: use scene camera", DebugDraw3D.config.force_use_camera_from_scene, 4)
DebugDraw2D.set_text("1,2,3: toggle debug", "%s, %s 😐, %s 😏" % [DebugDraw3D.debug_enabled, DebugDraw2D.debug_enabled, DebugDrawManager.debug_enabled], 5)
Expand Down
Binary file modified images/screenshot_web.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 4fc8aea

Please sign in to comment.