Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
updated c#
updated ci tests
add more safety
  • Loading branch information
DmitriySalnikov committed Apr 14, 2024
1 parent da6f672 commit 66738ff
Show file tree
Hide file tree
Showing 12 changed files with 120 additions and 58 deletions.
62 changes: 45 additions & 17 deletions .github/workflows/gdextension_build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
name: 🛠️ GDExtension Build
on:
push:
paths: [src/**, .github/**, "!.github/**/util_*", "patches/**", lib_utils.py, SConstruct]
paths:
[
src/**,
.github/**,
"!.github/**/util_*",
"patches/**",
lib_utils.py,
SConstruct,
]
pull_request:
paths: [src/**, .github/**, "!.github/**/util_*", "patches/**", lib_utils.py, SConstruct]
paths:
[
src/**,
.github/**,
"!.github/**/util_*",
"patches/**",
lib_utils.py,
SConstruct,
]
workflow_dispatch:
inputs:
production_build:
Expand Down Expand Up @@ -120,7 +136,7 @@ jobs:
use_cache: ${{env.USE_CACHE}}
token: ${{secrets.TELEMETRY_TOKEN}}

# ============================================
# ============================================

ios-gdextension:
name: 🍏 Ios
Expand Down Expand Up @@ -349,21 +365,33 @@ jobs:
download_export_templates: false
is_mono: false

# TODO: Add few attempts
- name: Import Assets
- name: macOS dependencies
shell: bash
run: ${{steps.setup_godot.outputs.godot}} -v -e --headless --path ${{env.PROJECT_PATH}} --quit || true

- name: Test Run
shell: bash
timeout-minutes: 2
if: runner.os == 'macOS'
run: |
${{steps.setup_godot.outputs.godot}} -v --headless --path ${{env.PROJECT_PATH}} res://headless_test.tscn || true
brew install coreutils
alias timeout="gtimeout"
- name: Check Results
shell: bash
- name: Test run
shell: bash --noprofile --norc -o pipefail {0}
run: |
if [ ! -f "${{env.PROJECT_PATH}}/SUCCESS" ]; then
echo "The file reporting success has not been created! Failed."
exit 1
fi
max_attempts=3
current_attempt=1
last_exit_code=0
until [ $current_attempt -gt $max_attempts ]; do
current_attempt=$((current_attempt + 1))
timeout 2m ${{steps.setup_godot.outputs.godot}} -v -e --headless --path ${{env.PROJECT_PATH}} --quit || true
timeout 2m ${{steps.setup_godot.outputs.godot}} -v --headless --path ${{env.PROJECT_PATH}} res://headless_test.tscn || true
if [ ! -f "${{env.PROJECT_PATH}}/SUCCESS" ]; then
echo "The file reporting success has not been created! Failed."
last_exit_code=1
else
echo "The file reporting success has been created! Success!"
exit 0
fi
done
echo "The maximum number of attempts has been reached. Last error code: $?"
exit $last_exit_code
63 changes: 39 additions & 24 deletions .github/workflows/web_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@ on:
push:
branches-ignore: gh-pages
# Must not overlap with conditions in `gdextension_build.yml`
paths: [docs/**, images/**, dd3d_web_build/**, examples_dd3d/**, Doxyfile,
src/**, .github/**, "!.github/**/util_*", "patches/**", lib_utils.py, SConstruct
]
paths:
[
docs/**,
images/**,
dd3d_web_build/**,
examples_dd3d/**,
Doxyfile,
src/**,
.github/**,
"!.github/**/util_*",
"patches/**",
lib_utils.py,
SConstruct,
]
workflow_call:
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -137,17 +148,17 @@ jobs:
fail-fast: false
matrix:
include:
- platform: web
target: template_release
arch: wasm32
artifact: web.demo_build
additional: lto=yes force_enabled_dd3d=yes

- platform: linux
target: editor
arch: x86_64
artifact: linux.demo_build
additional: lto=yes
- platform: web
target: template_release
arch: wasm32
artifact: web.demo_build
additional: lto=yes force_enabled_dd3d=yes

- platform: linux
target: editor
arch: x86_64
artifact: linux.demo_build
additional: lto=yes

env:
EM_VERSION: 3.1.39
Expand Down Expand Up @@ -253,9 +264,8 @@ jobs:
allow_empty_commit: true
keep_files: true
commit_message: Updated documentation
user_name: 'github-actions-deploy[bot]'
user_email: 'github-actions-deploy[bot]@users.noreply.github.com'

user_name: "github-actions-deploy[bot]"
user_email: "github-actions-deploy[bot]@users.noreply.github.com"

export_demo_project:
name: 🌐📦 Export Demo Project
Expand Down Expand Up @@ -360,9 +370,8 @@ jobs:
allow_empty_commit: true
keep_files: true
commit_message: Updated demo build
user_name: 'github-actions-deploy[bot]'
user_email: 'github-actions-deploy[bot]@users.noreply.github.com'

user_name: "github-actions-deploy[bot]"
user_email: "github-actions-deploy[bot]@users.noreply.github.com"

finalization:
name: 🏁 Finalization
Expand All @@ -380,7 +389,7 @@ jobs:
- name: Clean unused folders
if: env.DEV_DEPLOY == 'false'
continue-on-error: true
# default bash without -e (fail-fast)
# default bash without -e (fail-fast)
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
shell: bash --noprofile --norc -o pipefail {0}
run: |
Expand Down Expand Up @@ -640,15 +649,21 @@ jobs:
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
path: "."
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4


restore_on_fail:
name: 🔄 Restore gh-pages
needs: [data_preparation, generate_docs, export_demo_project, finalization, deploy]
needs:
[
data_preparation,
generate_docs,
export_demo_project,
finalization,
deploy,
]
if: failure() || cancelled()
runs-on: ubuntu-latest

Expand Down
4 changes: 2 additions & 2 deletions examples_dd3d/DebugDrawDemoScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,15 @@ func _draw_array_of_boxes():
cubes_max_time = 60

if timer_cubes < 0:
var start_time = Time.get_ticks_usec()
var _start_time = Time.get_ticks_usec()
for x in x_size:
for y in y_size:
for z in z_size:
var size = Vector3.ONE
cfg.set_thickness(randf_range(0, 0.1))
#var size = Vector3(randf_range(0.1, 100),randf_range(0.1, 100),randf_range(0.1, 100))
DebugDraw3D.draw_box(Vector3(x * mul, (-4-z) * mul, y * mul), Quaternion.IDENTITY, size, DebugDraw3D.empty_color, false, cubes_max_time)
#print("Draw Cubes: %fms" % ((Time.get_ticks_usec() - start_time) / 1000.0))
#print("Draw Cubes: %fms" % ((Time.get_ticks_usec() - _start_time) / 1000.0))
timer_cubes = cubes_max_time


Expand Down
6 changes: 4 additions & 2 deletions examples_dd3d/DebugDrawDemoSceneCS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public override void _PhysicsProcess(double delta)
}

// Additional drawing in the Viewport
using (var _w1 = DebugDraw3D.NewScopedConfig().SetViewport(dOtherWorldBox.GetViewport()).SetThickness(0.01f).SetCenterBrightness(1))
using (var _w1 = DebugDraw3D.NewScopedConfig().SetViewport(dOtherWorldBox.GetViewport()).SetThickness(0.01f).SetCenterBrightness(1).SetNoDepthTest(true))
{
DebugDraw3D.DrawBoxXf(new Transform3D(Basis.Identity
.Scaled(Vector3.One * 0.3f)
Expand Down Expand Up @@ -470,7 +470,7 @@ void MainUpdate(double delta)

DebugDraw3D.DrawGizmo(dMisc_GizmoTransform.GlobalTransform, null, true);
DebugDraw3D.DrawGizmo(dMisc_GizmoOneColor.GlobalTransform, Colors.Brown, true);
using (var s = DebugDraw3D.NewScopedConfig().SetCenterBrightness(0.5f))
using (var s = DebugDraw3D.NewScopedConfig().SetCenterBrightness(0.5f).SetNoDepthTest(true))
{
DebugDraw3D.DrawGizmo(dMisc_GizmoNormal.GlobalTransform.Orthonormalized(), null, false);
}
Expand Down Expand Up @@ -712,6 +712,7 @@ void _draw_array_of_boxes()

if (timer_cubes <= 0)
{
var start_time = Time.GetTicksUsec();
for (int x = 0; x < x_size; x++)
{
for (int y = 0; y < y_size; y++)
Expand All @@ -725,6 +726,7 @@ void _draw_array_of_boxes()
}
}
}
//GD.Print($"Draw Cubes: {((Time.GetTicksUsec() - start_time) / 1000.0):F2}ms");
timer_cubes = cubes_max_time;
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples_dd3d/DebugDrawDemoSceneCS.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ switch_to_scene = "res://examples_dd3d/DebugDrawDemoScene.tscn"
[node name="Label" parent="Settings/HBox/VBoxContainer" index="1"]
text = "C# example"

[node name="SwitchLang" parent="Settings/HBox/PanelContainer/VBox" index="12"]
[node name="SwitchLang" parent="Settings/HBox/VBox/SettingsPanel/VBox" index="12"]
text = "Switch to GDScript"
1 change: 1 addition & 0 deletions src/3d/config_scope_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using namespace godot;
* @warning
* Also, you can't use scope config between `await`s unless this object is freed before `await`.
* So, narrow the scope if you want to use `await` and DebugDraw3DScopeConfig in the same method.
* Or set the value of the variable to `null` so that the object is cleared due to lack of references.
* ```python
* # Bad example
* var _s = DebugDraw3D.new_scoped_config().set_thickness(0.3)
Expand Down
24 changes: 15 additions & 9 deletions src/3d/debug_draw_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ std::shared_ptr<DebugGeometryContainer> DebugDraw3D::create_debug_container(bool
return std::make_shared<DebugGeometryContainer>(this, p_no_depth_test);
}

std::shared_ptr<DebugGeometryContainer> DebugDraw3D::get_debug_container(const DebugDraw3DScopeConfig::DebugContainerDependent &p_dgcd) {
std::shared_ptr<DebugGeometryContainer> DebugDraw3D::get_debug_container(const DebugDraw3DScopeConfig::DebugContainerDependent &p_dgcd, const bool p_generate_new_container) {
ZoneScoped;
LOCK_GUARD(datalock);

Expand All @@ -383,17 +383,23 @@ std::shared_ptr<DebugGeometryContainer> DebugDraw3D::get_debug_container(const D
if (const auto &dgc_pair = debug_containers.find(vp_world_id);
dgc_pair != debug_containers.end() && dgc_pair->second[dgc_depth]) {

viewport_to_world_cache[p_dgcd.viewport].world_id = dgc_pair->first;
viewport_to_world_cache[p_dgcd.viewport].dgcs[dgc_depth] = dgc_pair->second[dgc_depth];
auto &cache = viewport_to_world_cache[p_dgcd.viewport];
cache.world_id = dgc_pair->first;
cache.dgcs[dgc_depth] = dgc_pair->second[dgc_depth];
return dgc_pair->second[dgc_depth];
}

if (!p_generate_new_container) {
return nullptr;
}

auto dgc = create_debug_container(p_dgcd.no_depth_test);
dgc->set_world(vp_world);
debug_containers[vp_world_id][dgc_depth] = dgc;

viewport_to_world_cache[p_dgcd.viewport].world_id = vp_world_id;
viewport_to_world_cache[p_dgcd.viewport].dgcs[dgc_depth] = dgc;
auto &cache = viewport_to_world_cache[p_dgcd.viewport];
cache.world_id = vp_world_id;
cache.dgcs[dgc_depth] = dgc;

call_deferred(NAMEOF(_register_viewport_world_deferred), _get_root_world_viewport(p_dgcd.viewport), vp_world_id);

Expand Down Expand Up @@ -590,7 +596,7 @@ Ref<DebugDraw3DStats> DebugDraw3D::get_render_stats_for_world(Viewport *viewport
stats_3d.instantiate();

for (int i = 0; i < 2; i++) {
auto dgc = get_debug_container(DebugDraw3DScopeConfig::DebugContainerDependent(viewport, !!i));
auto dgc = get_debug_container(DebugDraw3DScopeConfig::DebugContainerDependent(viewport, i > 0), false);
if (dgc) {
dgc->get_render_stats(stats_3d);
res->combine_with(stats_3d);
Expand Down Expand Up @@ -643,9 +649,9 @@ void DebugDraw3D::clear_all() {
if (NEED_LEAVE || config->is_freeze_3d_render()) return;
#endif

#define GET_SCOPED_CFG_AND_DGC() \
auto scfg = scoped_config_for_current_thread(); \
auto dgc = get_debug_container(scfg->dgcd); \
#define GET_SCOPED_CFG_AND_DGC() \
auto scfg = scoped_config_for_current_thread(); \
auto dgc = get_debug_container(scfg->dgcd, true); \
if (!dgc) return

#ifndef DISABLE_DEBUG_RENDERING
Expand Down
2 changes: 1 addition & 1 deletion src/3d/debug_draw_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class DebugDraw3D : public Object, public IScopeStorage<DebugDraw3DScopeConfig,

std::array<Ref<ArrayMesh>, 2> *get_shared_meshes();
std::shared_ptr<DebugGeometryContainer> create_debug_container(bool p_no_depth_test);
std::shared_ptr<DebugGeometryContainer> get_debug_container(const DebugDraw3DScopeConfig::DebugContainerDependent &p_dgcd);
std::shared_ptr<DebugGeometryContainer> get_debug_container(const DebugDraw3DScopeConfig::DebugContainerDependent &p_dgcd, const bool p_generate_new_container);
void _register_viewport_world_deferred(Viewport *p_vp, const uint64_t p_world_id);
Viewport *_get_root_world_viewport(Viewport *p_vp);
void _remove_debug_container(const uint64_t &p_world_id);
Expand Down
3 changes: 3 additions & 0 deletions src/3d/debug_geometry_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ using namespace godot;

DebugGeometryContainer::DebugGeometryContainer(class DebugDraw3D *p_root, bool p_no_depth_test) {
ZoneScoped;
DEV_PRINT_STD("New " NAMEOF(DebugGeometryContainer) " created: %s\n", p_no_depth_test ? "NoDepth" : "Normal");
owner = p_root;
RenderingServer *rs = RenderingServer::get_singleton();
no_depth_test = p_no_depth_test;
geometry_pool.set_no_depth_test_info(no_depth_test);

// Create wireframe mesh drawer
{
Expand Down Expand Up @@ -78,6 +80,7 @@ DebugGeometryContainer::DebugGeometryContainer(class DebugDraw3D *p_root, bool p

DebugGeometryContainer::~DebugGeometryContainer() {
ZoneScoped;
DEV_PRINT_STD(NAMEOF(DebugGeometryContainer) " destroyed: %s, World3D (%d)\n", no_depth_test ? "NoDepth" : "Normal", UtilityFunctions::is_instance_valid(base_world_viewport) ? base_world_viewport->get_instance_id() : 0);
LOCK_GUARD(owner->datalock);

geometry_pool.clear_pool();
Expand Down
1 change: 0 additions & 1 deletion src/3d/debug_geometry_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ GODOT_WARNING_RESTORE()
using namespace godot;

class DebugDraw3DStats;
enum class MeshMaterialType : char;

class DebugGeometryContainer {
friend class DebugDraw3D;
Expand Down
6 changes: 5 additions & 1 deletion src/3d/render_instances.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ bool GeometryPool::_is_viewport_empty(Viewport *vp) {
return true;
}

void GeometryPool::set_no_depth_test_info(bool p_no_depth_test) {
is_no_depth_test = p_no_depth_test;
}

std::vector<Viewport *> GeometryPool::get_and_validate_viewports() {
ZoneScoped;
std::vector<Viewport *> res;
Expand All @@ -440,7 +444,7 @@ std::vector<Viewport *> GeometryPool::get_and_validate_viewports() {
for (const auto &vp : viewport_ids) {
if (UtilityFunctions::is_instance_id_valid(vp.second)) {
if (_is_viewport_empty(vp.first)) {
DEV_PRINT_STD("Viewport (%s) did not contain any debug data, it will be deleted from the World3D's container.\n", vp.first->to_string().utf8().get_data());
DEV_PRINT_STD("%s Viewport (%s) did not contain any debug data,\n\tit will be deleted from the World3D's container.\n", is_no_depth_test ? "NoDepth" : "Normal", vp.first->to_string().utf8().get_data());
to_delete.push_back(vp.first);
} else {
res.push_back(vp.first);
Expand Down
4 changes: 4 additions & 0 deletions src/3d/render_instances.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class GeometryPool {
TIME_USED_TO_SHRINK_DELAYED = 5,
};

bool is_no_depth_test = false;

template <class TInst>
struct ObjectsPool {
std::vector<TInst> instant = {};
Expand Down Expand Up @@ -231,6 +233,8 @@ class GeometryPool {
~GeometryPool() {
}

void set_no_depth_test_info(bool p_no_depth_test);

std::vector<Viewport *> get_and_validate_viewports();

void fill_mesh_data(const std::vector<Ref<MultiMesh> *> &p_meshes, Ref<ArrayMesh> p_ig, std::unordered_map<Viewport *, std::shared_ptr<GeometryPoolCullingData> > &p_culling_data);
Expand Down

0 comments on commit 66738ff

Please sign in to comment.