Skip to content

Commit

Permalink
updated docs and readme
Browse files Browse the repository at this point in the history
fixed viewport texture saving
  • Loading branch information
DmitriySalnikov committed Apr 1, 2024
1 parent 1753226 commit f5f24e2
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 30 deletions.
5 changes: 3 additions & 2 deletions addons/debug_draw_3d/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ Precompiled for:
* Linux (built on Ubuntu 20.04)
* macOS (10.14+)
* Android (5.0+)
* iOS
* Web (Firefox not supported)

This addon also supports working with several World3D and different Viewports.

## [Interactive Web Demo](https://dd3d.dmitriysalnikov.ru/demo/)

[![screenshot_web](/images/screenshot_web.png)](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))

> [!WARNING]
>
> * Firefox most likely can't run this demo
Expand Down
12 changes: 4 additions & 8 deletions examples_dd3d/DebugDrawDemoScene.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=36 format=3 uid="uid://c3sccy6x0ht5j"]
[gd_scene load_steps=35 format=3 uid="uid://c3sccy6x0ht5j"]

[ext_resource type="Script" path="res://examples_dd3d/DebugDrawDemoScene.gd" id="1"]
[ext_resource type="FontFile" uid="uid://erdgllynwqkw" path="res://examples_dd3d/Roboto-Bold.ttf" id="2_aedbq"]
Expand Down Expand Up @@ -130,22 +130,18 @@ _data = {

[sub_resource type="Shader" id="Shader_621vv"]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_back,diffuse_burley,unshaded,ambient_light_disabled,fog_disabled;
render_mode unshaded;

uniform sampler2D albedo_texture : source_color,filter_linear_mipmap,repeat_enable;
uniform sampler2D albedo_texture;

void fragment() {
ALBEDO = texture(albedo_texture,UV).rgb;
}
"

[sub_resource type="ViewportTexture" id="ViewportTexture_xp3xe"]
viewport_path = NodePath("OtherWorld/SubViewport")

[sub_resource type="ShaderMaterial" id="ShaderMaterial_ho0aq"]
render_priority = 0
shader = SubResource("Shader_621vv")
shader_parameter/albedo_texture = SubResource("ViewportTexture_xp3xe")

[sub_resource type="PlaneMesh" id="PlaneMesh_c6mie"]
material = SubResource("ShaderMaterial_ho0aq")
Expand All @@ -157,7 +153,7 @@ length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:mesh:material:albedo_texture")
tracks/0/path = NodePath(".:mesh:material:shader_parameter/albedo_texture")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
Expand Down
3 changes: 3 additions & 0 deletions src/3d/config_scope_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ class DebugDraw3DScopeConfig : public RefCounted {
* If the World3D of this Viewport has not been used before,
* then the owner of this World3D will be found in the current branch of the tree,
* and special observer nodes will be added to it.
*
* @note
* Objects created for a specific Viewport will use only one camera related to that Viewport for culling.
*/
Ref<DebugDraw3DScopeConfig> set_viewport(Viewport *_value);
Viewport *get_viewport() const;
Expand Down
7 changes: 6 additions & 1 deletion src/3d/debug_draw_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class _DD3D_WorldWatcher : public Node3D {
static void _bind_methods(){};

public:
virtual void _process(double p_delta);
virtual void _process(double p_delta) override;
virtual void _notification(int p_what);

_DD3D_WorldWatcher() :
Expand Down Expand Up @@ -92,6 +92,11 @@ class _DD3D_WorldWatcher : public Node3D {
* physics_tick_processed = true
* # some DD3D logic
* ```
*
* ---
* @note
* Due to the way Godot registers this addon, it is not possible to use the `draw_` methods
* in the first few frames immediately after the project is launched.
*/
class DebugDraw3D : public Object, public IScopeStorage<DebugDraw3DScopeConfig, DebugDraw3DScopeConfig::Data> {
GDCLASS(DebugDraw3D, Object)
Expand Down
3 changes: 1 addition & 2 deletions src/3d/debug_geometry_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ void DebugGeometryContainer::update_geometry(double p_delta) {
SphereBounds(center, radius),
&Colors::empty_color);

// TODO test bounds
geometry_pool.add_or_update_instance(
cfg,
InstanceType::SPHERE,
Expand All @@ -385,7 +384,7 @@ void DebugGeometryContainer::update_geometry(double p_delta) {
ProcessType::PROCESS,
std::move(l),
s,
Colors::orange_red);
Colors::red);
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/3d/render_instances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ void GeometryPool::fill_lines_data(Ref<ArrayMesh> p_ig, std::unordered_map<Viewp

GODOT_STOPWATCH(&time_spent_to_fill_buffers_of_lines);

// Avoiding a large number of resizes increased the speed from 1.9-2.0ms to 1.4-1.5ms
size_t used_vertexes = 0;

PackedVector3Array vertexes;
Expand Down
10 changes: 0 additions & 10 deletions src/editor/generate_csharp_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ void GenerateCSharpBindingsPlugin::generate() {
}
}

// TODO remove in the next minor update
if (DirAccess::dir_exists_absolute(old_output_directory)) {
PRINT_WARNING(FMT_STR("Found an old folder for C# bindings \"{0}\".\nThis folder will be deleted as it will no longer be used.", old_output_directory));
auto files = DirAccess::get_files_at(old_output_directory);
for (String f : files) {
DirAccess::remove_absolute(old_output_directory.path_join(f));
}
DirAccess::remove_absolute(old_output_directory);
}

// First, delete the old file to check for locks
if (FileAccess::file_exists(out_path)) {
PRINT("Attempt to delete an old file: " + out_path);
Expand Down
2 changes: 0 additions & 2 deletions src/editor/generate_csharp_bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ class GenerateCSharpBindingsPlugin {
};

String output_directory = "res://addons/debug_draw_3d/gen/csharp";
// TODO remove in the next minor update
String old_output_directory = "res://addons/debug_draw_3d/csharp";
String api_file_name = "DebugDrawGeneratedAPI.cs";
String log_file_name = "log.txt";
String indent_template = " ";
Expand Down
4 changes: 2 additions & 2 deletions src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ constexpr size_t INSTANCE_DATA_FLOAT_COUNT = ((sizeof(godot::Transform3D) + size
} \
}

// TODO: temp constants.
// HACK temp constants.

#define VEC3_ONE(comp) Vector3(comp, comp, comp)
const extern godot::Vector3 Vector3_ZERO;
Expand Down Expand Up @@ -282,7 +282,7 @@ class Utils {
return p;
}

// TODO: need to use make from API when it becomes possible
// TODO need to use make from API when it becomes possible
#pragma region HACK_FOR_DICTIONARIES
template <class... Args>
static godot::Dictionary make_dict(Args... args) {
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#define DD3D_MAJOR 1
#define DD3D_MINOR 3
#define DD3D_PATCH 1
#define DD3D_MINOR 4
#define DD3D_PATCH 0
#define DD3D_VERSION ((DD3D_MAJOR << (8 * 3)) + (DD3D_MINOR << (8 * 2)) + (DD3D_PATCH << (8 * 1)))

#define _DD3D_VERSION_STR_TEXT(text) #text
Expand Down

0 comments on commit f5f24e2

Please sign in to comment.