Skip to content

Commit

Permalink
Update for 4.3
Browse files Browse the repository at this point in the history
- Update DebugDraw
  • Loading branch information
Mickeon committed Aug 29, 2024
1 parent feacc92 commit 85fe980
Show file tree
Hide file tree
Showing 45 changed files with 243 additions and 156 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Team Fortress Jumper
A small demo built in Godot 4.1 that attempts to recreate how it feels to rocket-jump around in **Team Fortress 2**.
A small demo built in Godot 4.1+ that attempts to recreate how it feels to rocket-jump around in **Team Fortress 2**.
As it stands, it's pretty close. Collisions are almost entirely broken. Things like bunny-hopping may also be intentionally turned on (they're pretty fun to mess around with).

<img width="45%" alt="Team Fortress Jumper Harvest preview" src="https://github.com/Mickeon/team-fortress-jumper/assets/66727710/2b6b756d-82e6-4af9-9e2f-8cf5a100eed8">
Expand All @@ -10,7 +10,7 @@ As it stands, it's pretty close. Collisions are almost entirely broken. Things l
This repository has not been originally designed to be visible by the public, but I'm putting it out there. It could be useful as a general point of reference.
Full support for this demo, as well as additional features _(such as multiplayer)_ should **not** be taken for granted.

You can try a **considerably** stripped out version of this project on a Chromium web browser by [clicking here](https://mickeon.netlify.app/team-fortress-jumper/).
You can try a **considerably** stripped out version of this project on a Chromium web browser by [clicking here](https://mickeon.itch.io/team-fortress-jumper).
Alternatively, download a build from [the releases](https://github.com/Mickeon/team-fortress-jumper/releases/tag/Demo).

## Controls
Expand Down
2 changes: 1 addition & 1 deletion addons/debug_draw_3d/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 DmitriySalnikov
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
Expand Down
139 changes: 47 additions & 92 deletions addons/debug_draw_3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ 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/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.

[<img src="https://upload.wikimedia.org/wikipedia/commons/8/8f/QIWI_logo.svg" alt="qiwi" width=90px/>](https://qiwi.com/n/DMITRIYSALNIKOV)
<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/>

[<img src="https://static.boosty.to/assets/images/boostyDomainLogo.5Vlxt.svg" alt="Boosty" width=120px/>](https://boosty.to/dmitriysalnikov/donate)
<b>USDT-TRC20 TEw934PrsffHsAn5M63SoHYRuZo984EF6v</b>

## Features

Expand All @@ -30,6 +34,7 @@ Your support adds motivation to develop my public projects.
* Line
* Line Path
* Line with Arrow
* Plane
* Points
* Position 3D (3 crossing axes)
* Sphere
Expand All @@ -47,38 +52,33 @@ Overlay:
Precompiled for:

* Windows
* Linux
* macOS
* Android
* Web (WebAssembly)
* Linux (built on Ubuntu 20.04)
* macOS (10.14+)
* Android (5.0+)
* iOS
* Web (Firefox not supported)

## [Interactive Web Demo](https://dmitriysalnikov.github.io/godot_debug_draw_3d/)
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](/images/screenshot_web.png)](https://dmitriysalnikov.github.io/godot_debug_draw_3d/)
## [Interactive Web Demo](https://dd3d.dmitriysalnikov.ru/demo/)

Thanks to Nick Maltbie ([nicholas-maltbie](https://github.com/nicholas-maltbie)) ([#24](https://github.com/DmitriySalnikov/godot_debug_draw_3d/pull/24))
[![screenshot_web](/images/screenshot_web.png)](https://dd3d.dmitriysalnikov.ru/demo/)

> **Warning**
> [!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

To download, use the [Godot Asset Library](https://godotengine.org/asset-library/asset/1766) 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
### Installation

* Close editor
* 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,104 +100,59 @@ 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`.
An example of using scoped configs:

```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)
@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)
```

But unfortunately at the moment `GDExtension` does not support adding documentation.
![screenshot_5](/images/screenshot_5.png)

## Exporting a project
> [!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!
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.
## API

![export_features](/images/export_features.png)
This project has a separate [documentation](https://dd3d.dmitriysalnikov.ru/docs/) page.

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.
Also, a list of all functions is available in the documentation inside the editor (see `DebugDraw3D` and `DebugDraw2D`).

![csharp_compilation_symbols](/images/csharp_compilation_symbols.png)
![screenshot_4](/images/screenshot_4.png)

## Known issues and limitations

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

[OpenGL: The last instance of MultiMesh incorrectly sets the color](https://github.com/godotengine/godot/issues/71897)

**The version for Godot 4.0 requires explicitly specifying the exact data types, otherwise errors may occur.**

## More screenshots

`DebugDrawDemoScene.tscn` in editor
![screenshot_2](/images/screenshot_2.png)

`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 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
```

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
# build for the android. ANDROID_NDK_ROOT is required in your environment variables.
scons platform=android target=template_release arch=arm64v8
```

### 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)
58 changes: 41 additions & 17 deletions addons/debug_draw_3d/debug_draw_3d.gdextension
Original file line number Diff line number Diff line change
@@ -1,79 +1,103 @@
[configuration]

entry_symbol = "debug_draw_3d_library_init"
compatibility_minimum = "4.1.3"
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
; 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 = { }

# release no debug draw
ios = {}

; -------------------------------------
; release no debug draw

macos.template_release = { }
windows.template_release.x86_64 = { }
linux.template_release.x86_64 = { }

web.template_release.wasm32 = {}
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 = { }

# release forced debug draw
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.forced_dd3d = {}
web.template_release.wasm32.nothreads.forced_dd3d = { }
web.template_release.wasm32.forced_dd3d = { }

ios.template_release.forced_dd3d = {}

[libraries]

# debug
; -------------------------------------
; debug

macos = "libs/libdd3d.macos.editor.universal.dylib"
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 = "libs/libdd3d.web.template_debug.wasm32.wasm"
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"

# release no debug draw
ios = "libs/libdd3d.ios.template_debug.universal.dylib"

macos.template_release = "libs/libdd3d.macos.template_release.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 = "libs/libdd3d.web.template_release.wasm32.wasm"
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"

# release forced debug draw
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.dylib"
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.forced_dd3d = "libs/libdd3d.web.template_release.wasm32.enabled.wasm"
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"
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified addons/debug_draw_3d/libs/libdd3d.linux.editor.x86_64.so
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>libdd3d.macos.editor.universal.dylib</string>
<key>CFBundleName</key>
<string>Debug Draw 3D</string>
<key>CFBundleDisplayName</key>
<string>Debug Draw 3D</string>
<key>CFBundleIdentifier</key>
<string>ru.dmitriysalnikov.dd3d</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright (c) Dmitriy Salnikov.</string>
<key>CFBundleVersion</key>
<string>1.4.4</string>
<key>CFBundleShortVersionString</key>
<string>1.4.4</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>DTPlatformName</key>
<string>macosx</string>
<key>LSMinimumSystemVersion</key>
<string>10.14</string>
</dict>
</plist>

Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 85fe980

Please sign in to comment.