diff --git a/.github/actions/compile_gdextension/action.yml b/.github/actions/compile_gdextension/action.yml index 2bf012e9..e7c53856 100644 --- a/.github/actions/compile_gdextension/action.yml +++ b/.github/actions/compile_gdextension/action.yml @@ -12,6 +12,16 @@ inputs: description: Arch (universal|x86_32|x86_64|arm32|arm64|rv64|ppc32|ppc64|wasm32) required: true default: "" + artifact: + description: Artifact name. This name will be used for caching. + required: true + default: "bin" + additional: + description: Any additional arguments + default: "" + additional_enabled_dd3d: + description: Use force_enabled_dd3d if possible + default: "true" output_libs_path: description: Path to compiled libraries required: true @@ -19,15 +29,8 @@ inputs: use_cache: description: Use cache default: "true" - artifact: - description: Artifact name - required: true - default: "bin" - additional: - description: Any additional arguments - default: "" runs: - using: "composite" + using: composite steps: - name: Get godot-cpp SHA shell: bash @@ -40,10 +43,10 @@ runs: uses: actions/cache/restore@v3 with: path: ${{env.SCONS_CACHE}} - key: ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} + key: ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} restore-keys: | - ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}} - ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}} + ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}} + ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}} continue-on-error: true - name: Set up Python 3.x @@ -64,11 +67,11 @@ runs: - name: Linux dependencies shell: bash - if: runner.os == 'Linux' + if: (runner.os == 'Linux') && (inputs.platform == 'linux') run: | - sudo apt-get update + sudo apt update if [[ "${{inputs.arch}}" == *"32" ]];then - sudo apt-get install gcc-multilib g++-multilib + sudo apt install gcc-multilib g++-multilib fi - name: Compilation @@ -81,7 +84,7 @@ runs: git apply --ignore-space-change --ignore-whitespace ../patches/unity_build.patch cd .. scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} ${{inputs.additional}} - if [ "${{inputs.target}}" == "template_release" ] && [ "${{inputs.platform}}" != "android" ]; then + if [ "${{inputs.target}}" == "template_release" ] && [ "${{inputs.additional_enabled_dd3d}}" == "true" ]; then scons platform=${{inputs.platform}} arch=${{inputs.arch}} target=${{inputs.target}} addon_output_dir=${{inputs.output_libs_path}} force_enabled_dd3d=yes ${{inputs.additional}} fi echo "::endgroup::" @@ -103,7 +106,7 @@ runs: Remove-Item ${{inputs.output_libs_path}}/* -Recurse -Include *.exp,*.lib,*.pdb -Force - name: Upload Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{inputs.artifact}} retention-days: 7 @@ -114,5 +117,5 @@ runs: uses: actions/cache/save@v3 with: path: ${{env.SCONS_CACHE}} - key: ${{github.job}}-${{inputs.arch}}_${{inputs.target}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} + key: ${{github.job}}-${{inputs.artifact}}-${{steps.get_godot_cpp_sha.outputs.sha}}-${{github.ref}}-${{github.sha}} continue-on-error: true diff --git a/.github/actions/delete_artifact/action.yml b/.github/actions/delete_artifact/action.yml new file mode 100644 index 00000000..6c5cabee --- /dev/null +++ b/.github/actions/delete_artifact/action.yml @@ -0,0 +1,31 @@ +name: Delete the artifact if it exists +description: Delete an artifact by its name if it exists. 'actions/upload-artifact@v4' usually removes artifacts itself when restarting jobs. +inputs: + artifact: + description: Any name of artifact + required: true +runs: + using: composite + steps: + - name: Delete `${{inputs.artifact}}` + shell: bash + continue-on-error: true + run: | + res=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/actions/runs/${{github.run_id}}/artifacts?name="${{inputs.artifact}}") + + artifact_id=$(echo "$res" | jq -r 'if .total_count > 0 then .artifacts[0].id else 0 end') + + if [ "$artifact_id" == "0" ]; then + echo "No artifact to remove was found." + else + echo "Found the artifact ID $artifact_id for the ${{inputs.artifact}}." + gh api \ + --method DELETE \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/actions/artifacts/$artifact_id + echo "The artifact with the ID $artifact_id has been removed." + fi diff --git a/.github/workflows/gdextension_build.yml b/.github/workflows/gdextension_build.yml index 2a69e115..00fd99d4 100644 --- a/.github/workflows/gdextension_build.yml +++ b/.github/workflows/gdextension_build.yml @@ -10,22 +10,26 @@ on: description: Use Cache default: true type: boolean - repository_dispatch: # Stop the same workflow actions concurrency: - group: ${{github.workflow}}-${{github.event.pull_request.number || github.run_id}} + group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}} cancel-in-progress: true +permissions: + actions: write + env: SCONS_CACHE: ${{github.workspace}}/.scons-cache/ + USE_CACHE: ${{!format('{0}', inputs.use_cache) && 'true' || format('{0}', inputs.use_cache)}} # Default true OUTPUT_LIBS_PATH: bin FORCE_DISABLE_UNITY: yes + GH_TOKEN: ${{ github.token }} jobs: windows-gdextension: name: 🏁 Windows - runs-on: "windows-latest" + runs-on: windows-latest strategy: fail-fast: false @@ -35,7 +39,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -46,16 +50,16 @@ jobs: platform: windows target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} # Cast to string - artifact: windows + artifact: windows.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ linux-gdextension: name: 🐧 Linux - runs-on: "ubuntu-20.04" + runs-on: ubuntu-20.04 strategy: fail-fast: false @@ -65,7 +69,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -76,16 +80,16 @@ jobs: platform: linux target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: linux + artifact: linux.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ macos-gdextension: name: 🍏 MacOS - runs-on: "macos-latest" + runs-on: macos-latest strategy: fail-fast: false @@ -95,7 +99,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -106,16 +110,16 @@ jobs: platform: macos target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: macos + artifact: macos.${{matrix.target}}.${{matrix.arch}} additional: lto=yes macos_deployment_target=10.14 + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ android-gdextension: name: 🤖 Android - runs-on: "ubuntu-latest" + runs-on: ubuntu-latest strategy: fail-fast: false @@ -125,7 +129,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive @@ -156,16 +160,17 @@ jobs: platform: android target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: android + artifact: android.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + additional_enabled_dd3d: false + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ web-gdextension: name: 🕸 Web - runs-on: "ubuntu-latest" + runs-on: ubuntu-latest strategy: fail-fast: false @@ -178,14 +183,19 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true submodules: recursive - - uses: mymindstorm/setup-emsdk@v12 + - name: Download Emscripten + uses: mymindstorm/setup-emsdk@v12 + # Continue if failed to cache + # https://github.com/mymindstorm/setup-emsdk/issues/20 + continue-on-error: true with: version: ${{env.EM_VERSION}} + actions-cache-folder: obj/emsdk_cache - name: Compile GDExtension uses: ./.github/actions/compile_gdextension @@ -193,10 +203,10 @@ jobs: platform: web target: ${{matrix.target}} arch: ${{matrix.arch}} - output_libs_path: ${{env.OUTPUT_LIBS_PATH}} - use_cache: ${{format('{0}', inputs.use_cache)}} - artifact: web + artifact: web.${{matrix.target}}.${{matrix.arch}} additional: lto=yes + output_libs_path: ${{env.OUTPUT_LIBS_PATH}} + use_cache: ${{env.USE_CACHE}} # ============================================ @@ -213,15 +223,15 @@ jobs: runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v4 + + # https://github.com/actions/download-artifact/issues/249 - name: Download Binaries - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: extracted_files - - name: Remove `gdextension_libs` if the action was restarted - run: | - rm -rf extracted_files/gdextension_libs/ - - name: Store all libraries in one directory run: | ls -R extracted_files/ @@ -229,9 +239,14 @@ jobs: rm -rf extracted_files/**/ touch extracted_files/.gdignore + - name: Output file information + run: | + cd extracted_files + echo "Total size: $(du -ch -b | grep total | cut -f1 | awk '{printf "%.2f", $1/1048576}') MB, Total number of files: $(find . -type f | wc -l)" >> $GITHUB_STEP_SUMMARY + - name: Upload GDExtension - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: gdextension_libs + name: .gdextension_libs retention-days: 7 path: extracted_files/* diff --git a/.github/workflows/github_pages_build.yml b/.github/workflows/github_pages_build.yml deleted file mode 100644 index 506c9dce..00000000 --- a/.github/workflows/github_pages_build.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: 🚀 Deploy Github Pages Demo -on: - workflow_dispatch: - repository_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Stop the same workflow actions -concurrency: - group: ${{github.workflow}}-${{github.event.pull_request.number || github.run_id}} - cancel-in-progress: true - -# Environment variables for the job -env: - GODOT_VERSION: 4.1.1 - PROJECT_PATH: dd3d_web_build - -jobs: - build: - name: 🌐 Build Project - runs-on: ubuntu-20.04 - container: - image: barichello/godot-ci:4.1.1 - steps: - - name: Check out code - uses: actions/checkout@v3 - with: - lfs: true - - - name: Setup - run: | - mkdir -v -p ~/.local/share/godot/export_templates - mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable - - - name: Prepare Web Build - run: | - cp -r addons ${PROJECT_PATH}/addons - cp -r examples_dd3d ${PROJECT_PATH}/examples_dd3d - - - name: Import Assets - run: godot -v -e --headless --path ${PROJECT_PATH} --quit || true - - - name: Web Build - run: | - mkdir ${GITHUB_WORKSPACE}/_site - cp ${PROJECT_PATH}/coi-serviceworker.min.js ${GITHUB_WORKSPACE}/_site/coi-serviceworker.min.js - godot -v --headless --path ${PROJECT_PATH} --export-release web ${GITHUB_WORKSPACE}/_site/index.html - - - name: Fix Permissions - run: | - chmod -c -R +rX "_site/" | while read line; do - echo "::warning title=Invalid file permissions automatically fixed::$line" - done - - - name: Upload Site Artifact - uses: actions/upload-pages-artifact@v1 - with: - name: github-pages - - deploy: - name: 🚀 Deploy Site - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 diff --git a/.github/workflows/util_cleanup_cache.yml b/.github/workflows/util_cleanup_cache.yml index 0d53c4b4..79f628b3 100644 --- a/.github/workflows/util_cleanup_cache.yml +++ b/.github/workflows/util_cleanup_cache.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cleanup run: | diff --git a/.github/workflows/util_update_libs.yml b/.github/workflows/util_update_libs.yml index 955f85f2..d66c1189 100644 --- a/.github/workflows/util_update_libs.yml +++ b/.github/workflows/util_update_libs.yml @@ -15,7 +15,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true @@ -24,22 +24,26 @@ jobs: with: workflow: gdextension_build.yml branch: ${{github.ref_name}} - name: gdextension_libs + name: .gdextension_libs path: extracted_files/ - name: Replace with new files + shell: bash run: | ls -R extracted_files rm -rf ${{env.ADDON_LIBS_PATH}}/ mv -f extracted_files ${{env.ADDON_LIBS_PATH}} - - name: Commit report + - name: Commit and report + shell: bash run: | - git config --global user.name 'Auto Updater' - git config --global user.email 'auto-updater@users.noreply.github.com' + git config --global user.name 'github-actions-auto-updater[bot]' + git config --global user.email 'github-actions-auto-updater[bot]@users.noreply.github.com' git diff - echo "# Changed files:" >> $GITHUB_STEP_SUMMARY - git diff --name-only >> $GITHUB_STEP_SUMMARY git add -A - git commit -am "[CI] ↗️ Updated Binaries" - git push \ No newline at end of file + git commit --allow-empty -am "[CI] ↗️ Updated Binaries: ${{github.sha}}" + git push + + echo "## Changed files:" >> $GITHUB_STEP_SUMMARY + codeblock_tmp=$'```\nSTATS\n```' + echo "${codeblock_tmp//STATS/$(git diff --stat HEAD~)}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/web_deploy.yml b/.github/workflows/web_deploy.yml new file mode 100644 index 00000000..8486f5a4 --- /dev/null +++ b/.github/workflows/web_deploy.yml @@ -0,0 +1,616 @@ +name: 🚀 Deploy content to Github Pages +on: + push: + branches-ignore: gh-pages + paths: [docs/**, images/**, dd3d_web_build/**, examples_dd3d/**, Doxyfile, src/**, .github/**, "!.github/**/util_*", "patches/**", lib_utils.py, SConstruct] + workflow_dispatch: + inputs: + dev_deploy: + description: Dev deploy + default: true + type: boolean + +# docs/ for documentation +# demo/ for demo project +# dev/ for development version +# dev/BRANCH/docs and dev/BRANCH/demo for dev docs/ and demo/ + +# Permissions to update the PAGES_BRANCH branch +permissions: + contents: write + pages: write + id-token: write + actions: write + +# Stop the same workflow actions +concurrency: + group: ${{github.workflow}}-${{github.event.pull_request.number || github.ref}} + cancel-in-progress: true + +env: + PAGES_BRANCH: gh-pages + DEV_DEPLOY: ${{!format('{0}', inputs.dev_deploy) && 'true' || format('{0}', inputs.dev_deploy)}} # Default true + GH_TOKEN: ${{github.token}} + +jobs: + data_preparation: + name: ⛏ Data preparation + runs-on: ubuntu-latest + outputs: + head_sha: ${{steps.get_sha.outputs.head_sha}} + lib_version: ${{steps.get_lib_version.outputs.version}} + domain: ${{steps.get_domain.outputs.domain}} + + steps: + - name: Is development version + shell: bash + run: | + echo "Is a development build: \`${{env.DEV_DEPLOY}}\`" >> $GITHUB_STEP_SUMMARY + + - name: Get HEAD + shell: bash + id: get_sha + run: | + sha=$(gh api \ + -H "Accept: application/vnd.github.sha" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/commits/${{env.PAGES_BRANCH}}) + + if [ $? -ne 0 ]; then + echo "Curl failed with error: $?" + exit $? + fi + echo "head_sha=$sha" >> $GITHUB_OUTPUT + echo "\`$sha\` will be used as a restore point." >> $GITHUB_STEP_SUMMARY + + - name: Checkout version.h + uses: actions/checkout@v4 + with: + path: current + sparse-checkout: | + src/version.h + + - name: Get library version + id: get_lib_version + shell: bash + run: | + # Get DD3D version + source_file="current/src/version.h" + + major=$(grep -oP '(?<=#define DD3D_MAJOR )\d+' "$source_file") + minor=$(grep -oP '(?<=#define DD3D_MINOR )\d+' "$source_file") + patch=$(grep -oP '(?<=#define DD3D_PATCH )\d+' "$source_file") + + version_string="$major.$minor.$patch" + + echo "version=$version_string" >> $GITHUB_OUTPUT + echo "Version found in file \`version.h\`: \`$version_string\`" >> $GITHUB_STEP_SUMMARY + + - name: Checkout CNAME + uses: actions/checkout@v4 + continue-on-error: true + id: checkout_cname + with: + ref: ${{env.PAGES_BRANCH}} + path: pages + sparse-checkout: | + CNAME + + - name: Get CNAME or domain + id: get_domain + run: | + if [ "${{steps.checkout_cname.conclusion}}" == "success" ]; then + cname=$(cat pages/CNAME) + echo "domain=$cname" >> $GITHUB_OUTPUT + echo "Found CNAME record: \`$cname\`" >> $GITHUB_STEP_SUMMARY + else + domain="${{github.repository_owner}}.github.io/${{github.event.repository.name}}" + echo "domain=$domain" >> $GITHUB_OUTPUT + echo "CNAME not found, presumably domain of gh-pages: \`$domain\`" >> $GITHUB_STEP_SUMMARY + fi + + + web-gdextension: + name: 🕸 Build a Web library + needs: data_preparation + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + env: + EM_VERSION: 3.1.39 + # Faster build, but bigger library size (726KB vs 680KB) + FORCE_DISABLE_UNITY: no + SCONS_CACHE: ${{github.workspace}}/.scons-cache/ + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + submodules: recursive + + - name: Download Emscripten + uses: mymindstorm/setup-emsdk@v12 + # Continue if failed to cache + # https://github.com/mymindstorm/setup-emsdk/issues/20 + continue-on-error: true + with: + version: ${{env.EM_VERSION}} + actions-cache-folder: obj/emsdk_cache + + - name: Compile GDExtension + uses: ./.github/actions/compile_gdextension + with: + platform: web + target: template_release + arch: wasm32 + artifact: web.demo_build + additional: lto=yes force_enabled_dd3d=yes + additional_enabled_dd3d: false + output_libs_path: bin + use_cache: true + + + generate_docs: + name: 📚 Generate Docs + needs: data_preparation + runs-on: ubuntu-latest + + env: + DOXYGEN_VERSION: 1.9.8 + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + submodules: recursive + + - name: Install Doxygen + shell: bash + run: | + mkdir obj + cd obj + wget -nv https://www.doxygen.nl/files/doxygen-${{env.DOXYGEN_VERSION}}.linux.bin.tar.gz + tar -xf doxygen-${{env.DOXYGEN_VERSION}}.linux.bin.tar.gz + + - name: Run Doxygen + shell: bash + run: | + ( cat Doxyfile ; echo "PROJECT_NUMBER=${{needs.data_preparation.outputs.lib_version}}" ) | ./obj/doxygen-${{env.DOXYGEN_VERSION}}/bin/doxygen - + + - name: Get destination_dir + id: get_ref + shell: bash + env: + REF: ${{github.ref_name}} + content_dir: docs + # dev folder name must be synced with :fix_ref_names + run: | + fixed_ref_name=$(echo "$REF" | tr -c [:alnum:]+[:cntrl:] [_*]) + new_ref_name="" + if [ "${{env.DEV_DEPLOY}}" == "true" ]; then + new_ref_name="dev/$fixed_ref_name/$content_dir" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + else + new_ref_name="$content_dir/${{needs.data_preparation.outputs.lib_version}}" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + fi + echo "Target URL: https://${{needs.data_preparation.outputs.domain}}/$new_ref_name" >> $GITHUB_STEP_SUMMARY + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + publish_dir: obj/doxygen/html + destination_dir: ${{steps.get_ref.outputs.new_ref_name}} + publish_branch: ${{env.PAGES_BRANCH}} + 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' + + + export_demo_project: + name: 🌐📦 Export Demo Project + runs-on: ubuntu-20.04 + needs: [data_preparation, generate_docs, web-gdextension] + container: + image: barichello/godot-ci:4.2.1 + + env: + # Sync with container: image: + GODOT_VERSION: 4.2.1 + PROJECT_PATH: dd3d_web_build + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + lfs: true + + - name: Setup + run: | + mkdir -v -p ~/.local/share/godot/export_templates + mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable + + - name: Download Binaries + uses: actions/download-artifact@v4 + with: + path: addons/debug_draw_3d/libs + name: web.demo_build + + - name: Prepare Web Build + run: | + ls addons/debug_draw_3d/libs + ls ${GITHUB_WORKSPACE}/addons/debug_draw_3d/libs + cp -r addons ${PROJECT_PATH}/addons + cp -r examples_dd3d ${PROJECT_PATH}/examples_dd3d + + - name: Import Assets + run: godot -v -e --headless --path ${PROJECT_PATH} --quit || true + + - name: Web Build + run: | + mkdir ${GITHUB_WORKSPACE}/demo + cp ${PROJECT_PATH}/coi-serviceworker.min.js ${GITHUB_WORKSPACE}/demo/coi-serviceworker.min.js + godot -v --headless --path ${PROJECT_PATH} --export-release web ${GITHUB_WORKSPACE}/demo/index.html + + - name: Fix Permissions + run: | + chmod -c -R +rX "demo/" | while read line; do + echo "::warning title=Invalid file permissions automatically fixed::$line" + done + + - name: Get destination_dir + id: get_ref + shell: bash + env: + REF: ${{github.ref_name}} + content_dir: demo + # dev folder name must be synced with :fix_ref_names + run: | + fixed_ref_name=$(echo "$REF" | tr -c [:alnum:]+[:cntrl:] [_*]) + new_ref_name="" + if [ "${{env.DEV_DEPLOY}}" == "true" ]; then + new_ref_name="dev/$fixed_ref_name/$content_dir" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + else + new_ref_name="$content_dir/${{needs.data_preparation.outputs.lib_version}}" + echo "new_ref_name=$new_ref_name" >> $GITHUB_OUTPUT + fi + echo "Target URL: https://${{needs.data_preparation.outputs.domain}}/$new_ref_name" >> $GITHUB_STEP_SUMMARY + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{secrets.GITHUB_TOKEN}} + publish_dir: demo + destination_dir: ${{steps.get_ref.outputs.new_ref_name}} + publish_branch: ${{env.PAGES_BRANCH}} + 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' + + + finalization: + name: 🏁 Finalization + needs: [data_preparation, export_demo_project] + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{env.PAGES_BRANCH}} + # MUST BE A SUFFICIENT VALUE TO BE ABLE TO RESET TO THE INITIAL COMMIT + fetch-depth: 4 + lfs: true + + - name: Clean unused folders + if: env.DEV_DEPLOY == 'false' + continue-on-error: true + # 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: | + # Get branches + response=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{github.repository}}/branches) + + # Can't compare existing folders with no branches + if [ $? -ne 0 ]; then + echo "Error: Could not load the list of branches. Exiting." + exit 1 + fi + + git_branches=$(echo "$response" | jq -r '.[].name') + # Fix ref names + # :fix_ref_names + for ((i=0; i<${#git_branches[@]}; i++)); do + git_branches[$i]=$(echo "${git_branches[$i]}" | tr -c [:alnum:]+[:cntrl:] [_*]) + done + echo "Found branches:" + echo "${git_branches[@]}" + + cd dev + # 'cd' must run successfully to avoid accidentally deleting anything unnecessary + if [ $? -ne 0 ]; then + echo "Error: Could not change folder to 'dev'. Exiting." + exit 1 + fi + + # Get directories + folders=$(find . -mindepth 1 -maxdepth 1 -type d) + echo "Existing folders:" + echo ${folders[@]} + + for folder in $folders; do + folder_name=$(basename "$folder") + + # Check if the branch exists + if ! echo "$git_branches" | grep -q "^$folder_name$"; then + echo "Removing the folder: $folder_name" + rm -r "$folder_name" + fi + done + + - name: Add a dev index.html + shell: bash --noprofile --norc -o pipefail {0} + run: | + html_template=' + + + + Development versions + + + + + + + +

Links to versions in development

+ + + + + ' + + cd dev + # 'cd' must run successfully + if [ $? -ne 0 ]; then + echo "The 'dev' folder does not exist." + exit 1 + fi + echo "$html_template" > index.html + echo "Updated navigation in 'dev' folder" + + - name: Generate a list of available versions + shell: bash --noprofile --norc -o pipefail {0} + run: | + generate_json() { + # Go to + pushd "$1" > /dev/null + if [ $? -ne 0 ]; then + echo "Error: Could not change folder to '$1'. Exiting." + return 1 + fi + + # Find all folders, sort, remove './' + folders=$(find . -mindepth 1 -maxdepth 1 -type d | sort -r | sed 's|^\./||') + if [ -z "$folders" ]; then + json="[]" + else + # Folders to JSON array + json=$(echo "$folders" | jq -R -s 'split("\n")[:-1]') + fi + + # Go back to the root + popd > /dev/null + echo "$json" > $2 + echo "Saved folder list for '$1' to '$2'." + } + + if [ "${{env.DEV_DEPLOY}}" = "false" ]; then + # Only on release + generate_json "docs" "docs_versions.json" + generate_json "demo" "demo_versions.json" + fi + generate_json "dev" "dev_versions.json" + + - name: Generate redirects + if: env.DEV_DEPLOY == 'false' + shell: bash --noprofile --norc -o pipefail {0} + run: | + # Redirect template + html_template=' + + + + + Redirecting to REDIRECT_TO_FOLDER/ + + + + + + Redirecting to REDIRECT_TO_FOLDER/... + + + ' + + generate_redirect() { + # Go to + pushd "$1" > /dev/null + if [ $? -ne 0 ]; then + echo "Error: Could not change folder to '$1'. Exiting." + return 1 + fi + + # Find all the folders, sort, remove './' and get only the first one, most likely the newest version + first_folder=$(find . -mindepth 1 -maxdepth 1 -type d | sort -r | sed 's|^\./||' | head -n 1) + + if [ -n "$first_folder" ]; then + echo "${html_template//REDIRECT_TO_FOLDER/$first_folder}" > index.html + echo "Created a redirect from '$1' to '$first_folder'" + else + echo "The '$1' folder is empty. Exiting." + fi + + # Go back to the root + popd > /dev/null + } + + generate_redirect "docs" + generate_redirect "demo" + + # Root to docs/ redirect + echo "${html_template//REDIRECT_TO_FOLDER/docs}" > index.html + echo "Added redirection to docs/" + + - name: Commit changes + shell: bash + run: | + git config --global user.name 'github-actions-auto-updater[bot]' + git config --global user.email 'github-actions-auto-updater[bot]@users.noreply.github.com' + git diff + git add -A + git commit --allow-empty -am "Folder structure updated" + + - name: Squash and push + shell: bash + run: | + git reset --soft ${{needs.data_preparation.outputs.head_sha}} + msg=$'Pages have been updated: ${{github.sha}}\n' + git commit -am "${msg}$(git log --format=%B --reverse HEAD..HEAD@{1})" + git push -f + + echo "## Changed files:" >> $GITHUB_STEP_SUMMARY + codeblock_tmp=$'```\nSTATS\n```' + echo "${codeblock_tmp//STATS/$(git diff --stat HEAD~)}" >> $GITHUB_STEP_SUMMARY + + + deploy: + name: 🌐 Deploy + needs: [finalization] + runs-on: ubuntu-latest + + environment: + name: github-pages + url: ${{steps.deployment.outputs.page_url}} + + steps: + - name: Checkout Action + uses: actions/checkout@v4 + with: + path: temp_repo + sparse-checkout: .github/actions/delete_artifact + + - name: Remove `github-pages` if the action was restarted + uses: ./temp_repo/.github/actions/delete_artifact + with: + artifact: github-pages + + - name: Remove Action + run: rm -rf temp_repo/ + + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{env.PAGES_BRANCH}} + lfs: true + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + 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] + if: failure() || cancelled() + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{env.PAGES_BRANCH}} + # MUST BE A SUFFICIENT VALUE TO BE ABLE TO RESET TO THE INITIAL COMMIT + fetch-depth: 4 + lfs: true + + - name: Reset and push + shell: bash + continue-on-error: true + run: | + if [ -n "${{needs.data_preparation.outputs.head_sha}}" ]; then + git reset --hard ${{needs.data_preparation.outputs.head_sha}} + git push -f + echo "The branch has been reset to \`${{needs.data_preparation.outputs.head_sha}}\`" >> $GITHUB_STEP_SUMMARY + fi diff --git a/Doxyfile b/Doxyfile index 1cf4104a..02bab440 100644 --- a/Doxyfile +++ b/Doxyfile @@ -98,6 +98,82 @@ IMAGE_PATH = docs/images \ docs/images/classes \ images +# The HTML_HEADER tag can be used to specify a user-defined HTML header file for +# each generated HTML page. If the tag is left blank doxygen will generate a +# standard header. +# +# To get valid HTML the header file that includes any scripts and style sheets +# that doxygen needs, which is dependent on the configuration options used (e.g. +# the setting GENERATE_TREEVIEW). It is highly recommended to start with a +# default header using +# doxygen -w html new_header.html new_footer.html new_stylesheet.css +# YourConfigFile +# and then modify the file new_header.html. See also section "Doxygen usage" +# for information on how to generate the default header that doxygen normally +# uses. +# Note: The header is subject to change so you typically have to regenerate the +# default header when upgrading to a newer version of doxygen. For a description +# of the possible markers and block names see the documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_HEADER = docs/doxygen_resources/header.html + +# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each +# generated HTML page. If the tag is left blank doxygen will generate a standard +# footer. See HTML_HEADER for more information on how to generate a default +# footer and what special commands can be used inside the footer. See also +# section "Doxygen usage" for information on how to generate the default footer +# that doxygen normally uses. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FOOTER = docs/doxygen_resources/footer.html + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style +# sheet that is used by each HTML page. It can be used to fine-tune the look of +# the HTML output. If left blank doxygen will generate a default style sheet. +# See also section "Doxygen usage" for information on how to generate the style +# sheet that doxygen normally uses. +# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as +# it is more robust and this tag (HTML_STYLESHEET) will in the future become +# obsolete. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_STYLESHEET = + +# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined +# cascading style sheets that are included after the standard style sheets +# created by doxygen. Using this option one can overrule certain style aspects. +# This is preferred over using HTML_STYLESHEET since it does not replace the +# standard style sheet and is therefore more robust against future updates. +# Doxygen will copy the style sheet files to the output directory. +# Note: The order of the extra style sheet files is of importance (e.g. the last +# style sheet in the list overrules the setting of the previous ones in the +# list). +# Note: Since the styling of scrollbars can currently not be overruled in +# Webkit/Chromium, the styling will be left out of the default doxygen.css if +# one or more extra stylesheets have been specified. So if scrollbar +# customization is desired it has to be added explicitly. For an example see the +# documentation. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_STYLESHEET = docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome.css \ + docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-sidebar-only.css \ + docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-sidebar-only-darkmode-toggle.css \ + docs/doxygen_resources/custom.css + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that the +# files will be copied as-is; there are no commands or markers available. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_EXTRA_FILES = docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js \ + docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-paragraph-link.js \ + docs/doxygen_resources/doc_version_select.js \ + images/icon_3d_32.png \ + # If the CREATE_SUBDIRS tag is set to YES then doxygen will create up to 4096 # sub-directories (in 2 levels) under the output directory of each output format # and will distribute the generated files over these directories. Enabling this @@ -1349,81 +1425,6 @@ HTML_OUTPUT = html HTML_FILE_EXTENSION = .html -# The HTML_HEADER tag can be used to specify a user-defined HTML header file for -# each generated HTML page. If the tag is left blank doxygen will generate a -# standard header. -# -# To get valid HTML the header file that includes any scripts and style sheets -# that doxygen needs, which is dependent on the configuration options used (e.g. -# the setting GENERATE_TREEVIEW). It is highly recommended to start with a -# default header using -# doxygen -w html new_header.html new_footer.html new_stylesheet.css -# YourConfigFile -# and then modify the file new_header.html. See also section "Doxygen usage" -# for information on how to generate the default header that doxygen normally -# uses. -# Note: The header is subject to change so you typically have to regenerate the -# default header when upgrading to a newer version of doxygen. For a description -# of the possible markers and block names see the documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_HEADER = docs/doxygen_resources/header.html - -# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each -# generated HTML page. If the tag is left blank doxygen will generate a standard -# footer. See HTML_HEADER for more information on how to generate a default -# footer and what special commands can be used inside the footer. See also -# section "Doxygen usage" for information on how to generate the default footer -# that doxygen normally uses. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style -# sheet that is used by each HTML page. It can be used to fine-tune the look of -# the HTML output. If left blank doxygen will generate a default style sheet. -# See also section "Doxygen usage" for information on how to generate the style -# sheet that doxygen normally uses. -# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as -# it is more robust and this tag (HTML_STYLESHEET) will in the future become -# obsolete. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_STYLESHEET = - -# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined -# cascading style sheets that are included after the standard style sheets -# created by doxygen. Using this option one can overrule certain style aspects. -# This is preferred over using HTML_STYLESHEET since it does not replace the -# standard style sheet and is therefore more robust against future updates. -# Doxygen will copy the style sheet files to the output directory. -# Note: The order of the extra style sheet files is of importance (e.g. the last -# style sheet in the list overrules the setting of the previous ones in the -# list). -# Note: Since the styling of scrollbars can currently not be overruled in -# Webkit/Chromium, the styling will be left out of the default doxygen.css if -# one or more extra stylesheets have been specified. So if scrollbar -# customization is desired it has to be added explicitly. For an example see the -# documentation. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_STYLESHEET = docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome.css \ - docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-sidebar-only.css \ - docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-sidebar-only-darkmode-toggle.css \ - docs/doxygen_resources/custom.css - -# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or -# other source files which should be copied to the HTML output directory. Note -# that these files will be copied to the base HTML output directory. Use the -# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these -# files. In the HTML_STYLESHEET file, use the file name only. Also note that the -# files will be copied as-is; there are no commands or markers available. -# This tag requires that the tag GENERATE_HTML is set to YES. - -HTML_EXTRA_FILES = docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-darkmode-toggle.js \ - docs/doxygen_resources/doxygen-awesome-css/doxygen-awesome-paragraph-link.js \ - images/icon_3d_32.png \ - # The HTML_COLORSTYLE tag can be used to specify if the generated HTML output # should be rendered with a dark or light theme. # Possible values are: LIGHT always generate light mode output, DARK always diff --git a/addons/debug_draw_3d/README.md b/addons/debug_draw_3d/README.md index 2cc1a185..0b12110e 100644 --- a/addons/debug_draw_3d/README.md +++ b/addons/debug_draw_3d/README.md @@ -6,7 +6,7 @@ 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/) +## [Documentation](https://dd3d.dmitriysalnikov.ru/docs/) ## [Godot 3 version](https://github.com/DmitriySalnikov/godot_debug_draw_3d/tree/godot_3) @@ -14,7 +14,7 @@ Based on my previous addon, which was developed [only for C#](https://github.com Your support adds motivation to develop my public projects. -Boosty +Boosty qiwi @@ -54,9 +54,9 @@ Precompiled for: * Android * Web (WebAssembly) -## [Interactive Web Demo](https://dd3d.dmitriysalnikov.ru/) +## [Interactive Web Demo](https://dd3d.dmitriysalnikov.ru/demo/) -[![screenshot_web](/images/screenshot_web.png)](https://dd3d.dmitriysalnikov.ru/) +[![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)) @@ -68,7 +68,7 @@ Thanks to Nick Maltbie ([nicholas-maltbie](https://github.com/nicholas-maltbie)) 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 @@ -99,11 +99,11 @@ func _process(delta: float) -> void: ## API -A list of all functions is available in the documentation inside the editor. +This project has a separate [documentation](https://dd3d.dmitriysalnikov.ru/docs/) page. -![screenshot_4](/images/screenshot_4.png) +Also, a list of all functions is available in the documentation inside the editor (see `DebugDraw3D` and `DebugDraw2D`). -But also this project has a separate [documentation](https://dd3d.dmitriysalnikov.ru/) page. +![screenshot_4](/images/screenshot_4.png) ## Known issues and limitations diff --git a/dd3d_web_build/export_presets.cfg b/dd3d_web_build/export_presets.cfg index 2b8ebde5..86460946 100644 --- a/dd3d_web_build/export_presets.cfg +++ b/dd3d_web_build/export_presets.cfg @@ -51,6 +51,61 @@ function loadData() { } }); } + +" html/canvas_resize_policy=2 html/focus_canvas_on_start=true diff --git a/dd3d_web_build/project.godot b/dd3d_web_build/project.godot index 0e59422c..7f51ecd9 100644 --- a/dd3d_web_build/project.godot +++ b/dd3d_web_build/project.godot @@ -24,6 +24,10 @@ buses/default_bus_layout="res://examples_dd3d/VisualizerAudioBus.tres" project/assembly_name="Debug Drawing Utility for Godot" +[gui] + +timers/tooltip_delay_sec=0.2 + [physics] common/physics_ticks_per_second=15 diff --git a/docs/Build.md b/docs/Build.md index 89e1d30a..966bc064 100644 --- a/docs/Build.md +++ b/docs/Build.md @@ -31,7 +31,7 @@ scons platform=web target=template_debug 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)! +If you too want to add an [Interactive Demo](https://dd3d.dmitriysalnikov.ru/demo/) 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 \ 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). diff --git a/docs/Introduction.md b/docs/Introduction.md index 73005a59..8a732028 100644 --- a/docs/Introduction.md +++ b/docs/Introduction.md @@ -1,3 +1,4 @@ +@mainpage # Introduction 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#`. @@ -48,7 +49,7 @@ Precompiled for: ## Download -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). +To download, use the [Godot Asset Library](https://godotengine.org/asset-library/asset/1766) or download the archive from the [GitHub](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 @@ -60,7 +61,11 @@ To download, use the [Godot Asset Library](https://godotengine.org/asset-library Your support adds motivation to develop my public projects. -Boosty +[![](images/boosty.png){html: width=192px}](https://boosty.to/dmitriysalnikov/donate) + +

Interactive Web Demo

+ +[![](/images/screenshot_web.png)](https://dd3d.dmitriysalnikov.ru/demo/) ## Next steps diff --git a/docs/doxygen_resources/custom.css b/docs/doxygen_resources/custom.css index 506f8c33..47d8df1d 100644 --- a/docs/doxygen_resources/custom.css +++ b/docs/doxygen_resources/custom.css @@ -1,19 +1,28 @@ html { - --top-nav-height: 150px + --top-height: 120px; + --side-nav_offset: 20px; } @media screen and (min-width: 768px) { #top { - height: var(--top-nav-height); + height: calc(var(--top-height) + var(--side-nav_offset)); } #nav-tree, #side-nav { - height: calc(100vh - var(--top-nav-height)) !important; + height: calc(100vh - var(--top-height) - var(--side-nav_offset)) !important; } #side-nav { - top: var(--top-nav-height); + top: calc(var(--top-height) + var(--side-nav_offset)); + } + + #doc-content { + position: absolute; + top: 0px; + bottom: 0px; + right: 0px; + left: 0px; } } @@ -74,4 +83,60 @@ span.mlabel { border-radius: 5px; color: rgb(20, 20, 20); font-weight: 800; -} \ No newline at end of file +} + +select#dd3d_version_select { + color: var(--primary-color); + font-weight: 600; + background-color: var(--code-background); + border-color: var(--separator-color); + border-radius: var(--border-radius-small); +} + +select#dd3d_version_select option { + color: var(--page-foreground-color); +} + +/* Octocat corner */ + +a.github-corner:hover .octo-arm { + animation: octocat-wave 560ms ease-in-out +} + +@keyframes octocat-wave { + + 0%, + 100% { + transform: rotate(0) + } + + 20%, + 60% { + transform: rotate(-25deg) + } + + 40%, + 80% { + transform: rotate(10deg) + } +} + +@media (max-width:500px) { + a.github-corner:hover .octo-arm { + animation: none + } + + a.github-corner .octo-arm { + animation: octocat-wave 560ms ease-in-out + } +} + +a.github-corner { + position: absolute; + top: 0; + border: 0; + right: 0; + z-index: 1; +} + +/* !Octocat corner */ \ No newline at end of file diff --git a/docs/doxygen_resources/doc_version_select.js b/docs/doxygen_resources/doc_version_select.js new file mode 100644 index 00000000..fbd3992b --- /dev/null +++ b/docs/doxygen_resources/doc_version_select.js @@ -0,0 +1,55 @@ +document.addEventListener("DOMContentLoaded", function () { + address_split = window.location.pathname.split("/", 2).filter(Boolean);; + fetch_address = ""; + link_template = ""; + re_template = ""; + if (address_split.length == 1) { + if (address_split[0] == "docs") { + fetch_address = "/docs_versions.json"; + link_template = "/docs/[version]/"; + re_template = /\/docs\/([^\/]+)/; + } else if (address_split[0] == "dev") { + fetch_address = "/dev_versions.json"; + link_template = "/dev/[version]/docs"; + re_template = /\/dev\/([^\/]+)\/docs/; + } + } + + const versionSelectBlock = document.getElementById("dd3d_version_block"); + if (versionSelectBlock) { + versionSelectBlock.hidden = true; + } + + if (fetch_address) { + fetch(fetch_address) + .then(response => response.json()) + .then(versions => { + // Get docs/ version + const currentVersionMatch = window.location.pathname.match(re_template); + const currentVersion = currentVersionMatch ? currentVersionMatch[1] : null; + + const versionSelect = document.getElementById("dd3d_version_select"); + versionSelect.innerHTML = ""; + + versions.forEach(version => { + const option = document.createElement("option"); + option.value = version; + option.text = version; + + if (version === currentVersion) { + option.selected = true; + } + versionSelect.appendChild(option); + }); + + versionSelectBlock.hidden = false; + versionSelect.addEventListener("change", function () { + const selectedVersion = versionSelect.value; + window.location.href = link_template.replace("[version]", selectedVersion); + }); + }) + .catch(error => { + console.error("Error loading JSON file:", error); + }); + } +}); \ No newline at end of file diff --git a/docs/doxygen_resources/footer.html b/docs/doxygen_resources/footer.html new file mode 100644 index 00000000..ac59f02e --- /dev/null +++ b/docs/doxygen_resources/footer.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/doxygen_resources/header.html b/docs/doxygen_resources/header.html index b2c19819..c9105388 100644 --- a/docs/doxygen_resources/header.html +++ b/docs/doxygen_resources/header.html @@ -1,87 +1,110 @@ - + + - - - - - -$projectname: $title -$title - - + + + + + + + + + $projectname: $title + + $title + + - + - - - -$treeview -$search -$mathjax -$darkmode - -$extrastylesheet - - - + + + + $treeview + $search + $mathjax + $darkmode + + $extrastylesheet + + + - + + + + - - + + - + -
- - +
+ + -
+
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
$projectname $projectnumber -
-
$projectbrief
-
-
$projectbrief
-
$searchbox
$searchbox
-
- - + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
$projectname $projectnumber +
+ +
$projectbrief
+
+
$projectbrief
+
$searchbox
$searchbox
+
+ + \ No newline at end of file diff --git a/docs/image_generator/preview_generator.gd b/docs/image_generator/preview_generator.gd index 3952f3b2..123646a6 100644 --- a/docs/image_generator/preview_generator.gd +++ b/docs/image_generator/preview_generator.gd @@ -1,5 +1,5 @@ ## Please define "editor/movie_writer/base_folder" with output path -## Also specify movie FPS "editor/movie_writer/fps" (default 48) +## Also specify movie FPS "editor/movie_writer/fps" (default 30) ## It is advisable to override this setting for .movie: "rendering/viewport/transparent_background" ## Override "rendering/anti_aliasing/quality/msaa_2d" for better quality ## Override "display/window/size/transparent" to display transparency @@ -117,7 +117,7 @@ var movie_temp_path: String = movie_base_path.path_join("temp") var movie_input_template: String = "_%08d.png" var movie_output_ext: String = ".webp" var movie_name: String = "output" -var movie_FPS: int = 48 +var movie_FPS: int = 30 var movie_compression: int = 4 # 0-6 var movie_quality: int = 90 # 0-100 diff --git a/docs/image_generator/preview_generator.tscn b/docs/image_generator/preview_generator.tscn index 0c69288e..04a3f5a9 100644 --- a/docs/image_generator/preview_generator.tscn +++ b/docs/image_generator/preview_generator.tscn @@ -2404,7 +2404,7 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_1iqys") -preview_case = 4 +preview_case = 24 anim_value_1 = 0.1 metadata/movie_file = "C:/My/Projects/GE/Addons/godot_debug_draw_3d/docs/images/classes/temp/_.png" diff --git a/docs/images/boosty.png b/docs/images/boosty.png new file mode 100644 index 00000000..5b0b559d Binary files /dev/null and b/docs/images/boosty.png differ diff --git a/docs/images/classes/Arrow.webp b/docs/images/classes/Arrow.webp index 4c95553e..aede2d1c 100644 Binary files a/docs/images/classes/Arrow.webp and b/docs/images/classes/Arrow.webp differ diff --git a/docs/images/classes/DrawArrowPath.webp b/docs/images/classes/DrawArrowPath.webp index b03a3733..7588ae7f 100644 Binary files a/docs/images/classes/DrawArrowPath.webp and b/docs/images/classes/DrawArrowPath.webp differ diff --git a/docs/images/classes/DrawBoxAb.webp b/docs/images/classes/DrawBoxAb.webp index e256d9b2..68883658 100644 Binary files a/docs/images/classes/DrawBoxAb.webp and b/docs/images/classes/DrawBoxAb.webp differ diff --git a/docs/images/classes/DrawBoxAbEdge.webp b/docs/images/classes/DrawBoxAbEdge.webp index 03111ff0..5b2f9378 100644 Binary files a/docs/images/classes/DrawBoxAbEdge.webp and b/docs/images/classes/DrawBoxAbEdge.webp differ diff --git a/docs/images/classes/DrawBoxXf.webp b/docs/images/classes/DrawBoxXf.webp index ebb7e4f6..687137e4 100644 Binary files a/docs/images/classes/DrawBoxXf.webp and b/docs/images/classes/DrawBoxXf.webp differ diff --git a/docs/images/classes/DrawBoxXfCorner.webp b/docs/images/classes/DrawBoxXfCorner.webp index d86c27ca..da55668b 100644 Binary files a/docs/images/classes/DrawBoxXfCorner.webp and b/docs/images/classes/DrawBoxXfCorner.webp differ diff --git a/docs/images/classes/DrawCylinder.webp b/docs/images/classes/DrawCylinder.webp index 474be91f..da6051f0 100644 Binary files a/docs/images/classes/DrawCylinder.webp and b/docs/images/classes/DrawCylinder.webp differ diff --git a/docs/images/classes/DrawCylinderAb.webp b/docs/images/classes/DrawCylinderAb.webp index d73ac43f..b005e0e7 100644 Binary files a/docs/images/classes/DrawCylinderAb.webp and b/docs/images/classes/DrawCylinderAb.webp differ diff --git a/docs/images/classes/DrawFrustum.webp b/docs/images/classes/DrawFrustum.webp index 008fa2f8..7bcb09de 100644 Binary files a/docs/images/classes/DrawFrustum.webp and b/docs/images/classes/DrawFrustum.webp differ diff --git a/docs/images/classes/DrawGizmo.webp b/docs/images/classes/DrawGizmo.webp index 15f342a2..de254ea0 100644 Binary files a/docs/images/classes/DrawGizmo.webp and b/docs/images/classes/DrawGizmo.webp differ diff --git a/docs/images/classes/DrawGizmoCentered.webp b/docs/images/classes/DrawGizmoCentered.webp index c20bf6b0..367bc864 100644 Binary files a/docs/images/classes/DrawGizmoCentered.webp and b/docs/images/classes/DrawGizmoCentered.webp differ diff --git a/docs/images/classes/DrawGrid.webp b/docs/images/classes/DrawGrid.webp index 3cfd9ee2..156ac94b 100644 Binary files a/docs/images/classes/DrawGrid.webp and b/docs/images/classes/DrawGrid.webp differ diff --git a/docs/images/classes/DrawLineHit.webp b/docs/images/classes/DrawLineHit.webp index 3f9d0abe..4d077daa 100644 Binary files a/docs/images/classes/DrawLineHit.webp and b/docs/images/classes/DrawLineHit.webp differ diff --git a/docs/images/classes/DrawLines.webp b/docs/images/classes/DrawLines.webp index d0109465..74248483 100644 Binary files a/docs/images/classes/DrawLines.webp and b/docs/images/classes/DrawLines.webp differ diff --git a/docs/images/classes/DrawPoints.webp b/docs/images/classes/DrawPoints.webp index 355fe373..48b83e1f 100644 Binary files a/docs/images/classes/DrawPoints.webp and b/docs/images/classes/DrawPoints.webp differ diff --git a/docs/images/classes/DrawPointsPath.webp b/docs/images/classes/DrawPointsPath.webp index e30a3966..66e9865e 100644 Binary files a/docs/images/classes/DrawPointsPath.webp and b/docs/images/classes/DrawPointsPath.webp differ diff --git a/docs/images/classes/DrawPointsPathSpheres.webp b/docs/images/classes/DrawPointsPathSpheres.webp index 2df5af27..060b894a 100644 Binary files a/docs/images/classes/DrawPointsPathSpheres.webp and b/docs/images/classes/DrawPointsPathSpheres.webp differ diff --git a/docs/images/classes/DrawPosition.webp b/docs/images/classes/DrawPosition.webp index faf4d8ce..bdd6ac77 100644 Binary files a/docs/images/classes/DrawPosition.webp and b/docs/images/classes/DrawPosition.webp differ diff --git a/docs/images/classes/DrawSphere.webp b/docs/images/classes/DrawSphere.webp index b7802bbd..8332ac68 100644 Binary files a/docs/images/classes/DrawSphere.webp and b/docs/images/classes/DrawSphere.webp differ diff --git a/docs/images/classes/DrawSphereXf.webp b/docs/images/classes/DrawSphereXf.webp index 32c3603e..0658885f 100644 Binary files a/docs/images/classes/DrawSphereXf.webp and b/docs/images/classes/DrawSphereXf.webp differ diff --git a/docs/images/classes/IcoSphere.webp b/docs/images/classes/IcoSphere.webp index bf143035..969de9e2 100644 Binary files a/docs/images/classes/IcoSphere.webp and b/docs/images/classes/IcoSphere.webp differ diff --git a/docs/images/classes/Line.webp b/docs/images/classes/Line.webp index e30eb11c..bcff0422 100644 Binary files a/docs/images/classes/Line.webp and b/docs/images/classes/Line.webp differ diff --git a/docs/images/classes/LineBevel.webp b/docs/images/classes/LineBevel.webp index 630b129e..92b3f0cb 100644 Binary files a/docs/images/classes/LineBevel.webp and b/docs/images/classes/LineBevel.webp differ diff --git a/docs/images/classes/LineCenterBrightness.webp b/docs/images/classes/LineCenterBrightness.webp index 7ce6eb6f..d176a42c 100644 Binary files a/docs/images/classes/LineCenterBrightness.webp and b/docs/images/classes/LineCenterBrightness.webp differ diff --git a/docs/images/classes/LineThickness.webp b/docs/images/classes/LineThickness.webp index 6d128462..d29cb46d 100644 Binary files a/docs/images/classes/LineThickness.webp and b/docs/images/classes/LineThickness.webp differ diff --git a/docs/images/classes/SphereDensity.webp b/docs/images/classes/SphereDensity.webp index be39966b..e30198ec 100644 Binary files a/docs/images/classes/SphereDensity.webp and b/docs/images/classes/SphereDensity.webp differ diff --git a/examples_dd3d/DebugDrawDemoScene.gd b/examples_dd3d/DebugDrawDemoScene.gd index 9c74cad6..953b5446 100644 --- a/examples_dd3d/DebugDrawDemoScene.gd +++ b/examples_dd3d/DebugDrawDemoScene.gd @@ -41,47 +41,6 @@ var timer_2 := 0.0 var timer_3 := 0.0 var timer_text := 0.0 -func _ready() -> void: - _update_keys_just_press() - - await get_tree().process_frame - - # this check is required for inherited scenes, because an instance of this - # script is created first, and then overridden by another - if !is_inside_tree(): - return - - -func _is_key_just_pressed(key): - if (button_presses[key] == 1): - button_presses[key] = 2 - return true - return false - - -func _update_keys_just_press(): - var set_key = func (k: Key): - if Input.is_key_pressed(k) and button_presses.has(k): - if button_presses[k] == 0: - return 1 - else: - return button_presses[k] - else: - return 0 - button_presses[KEY_LEFT] = set_key.call(KEY_LEFT) - button_presses[KEY_UP] = set_key.call(KEY_UP) - button_presses[KEY_CTRL] = set_key.call(KEY_CTRL) - button_presses[KEY_F1] = set_key.call(KEY_F1) - button_presses[KEY_1] = set_key.call(KEY_1) - button_presses[KEY_2] = set_key.call(KEY_2) - button_presses[KEY_3] = set_key.call(KEY_3) - -func _update_timers(delta : float): - timer_1 -= delta - timer_2 -= delta - timer_3 -= delta - timer_text -= delta - func _process(delta): if !update_in_physics: %RayEmitterAnimationPlayer.callback_mode_process = AnimationPlayer.ANIMATION_PROCESS_IDLE @@ -525,3 +484,47 @@ func _create_graph(title, is_fps, show_title, flags, parent := &"", parent_side graph.set_parent(parent, parent_side) return graph + + +func _ready() -> void: + _update_keys_just_press() + + await get_tree().process_frame + + # this check is required for inherited scenes, because an instance of this + # script is created first, and then overridden by another + if !is_inside_tree(): + return + + +func _is_key_just_pressed(key): + if (button_presses[key] == 1): + button_presses[key] = 2 + return true + return false + + +func _update_keys_just_press(): + var set_key = func (k: Key): + if Input.is_key_pressed(k) and button_presses.has(k): + if button_presses[k] == 0: + return 1 + else: + return button_presses[k] + else: + return 0 + button_presses[KEY_LEFT] = set_key.call(KEY_LEFT) + button_presses[KEY_UP] = set_key.call(KEY_UP) + button_presses[KEY_CTRL] = set_key.call(KEY_CTRL) + button_presses[KEY_F1] = set_key.call(KEY_F1) + button_presses[KEY_1] = set_key.call(KEY_1) + button_presses[KEY_2] = set_key.call(KEY_2) + button_presses[KEY_3] = set_key.call(KEY_3) + + +func _update_timers(delta : float): + timer_1 -= delta + timer_2 -= delta + timer_3 -= delta + timer_text -= delta + diff --git a/examples_dd3d/DebugDrawDemoScene.tscn b/examples_dd3d/DebugDrawDemoScene.tscn index 77760eac..467e9a3d 100644 --- a/examples_dd3d/DebugDrawDemoScene.tscn +++ b/examples_dd3d/DebugDrawDemoScene.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://c3sccy6x0ht5j"] +[gd_scene load_steps=23 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"] @@ -167,20 +167,21 @@ _data = { [sub_resource type="GDScript" id="GDScript_atshy"] script/source = "@tool -extends Button +extends VBoxContainer @export_range(1, 128) var bars_count := 32 var transform: Transform3D: get: return %AudioVisualizer.global_transform -@export_exp_easing(\"inout\") var motion_smoothing := 0.06 -@export_range(0, 0.5) var bar_thickness := 0.02 -@export_range(0, 10) var bars_separation := 0.1 +@export_exp_easing(\"inout\") var motion_smoothing := 0.025 +@export_range(0, 0.5) var bar_thickness := 0.065 +@export_range(0, 10) var bars_separation := 0.325 @export_exp_easing(\"inout\") var color_offset_speed := 0.4 @export var colors: Gradient = null var MusicBus := &\"MusicVisualizer\" -var MAX_HZ := 11050.0 +var MAX_HZ := 16000.0 +var MIN_HZ := 50.0 var MIN_DB := 60.0 var spectrum: AudioEffectSpectrumAnalyzerInstance = null @@ -257,11 +258,16 @@ func open_stream(file_ext: String, data: PackedByteArray): %MusicPlayer.stream = stream %MusicPlayer.bus = MusicBus %MusicPlayer.play() + + # Debugging frequencies + for ih in range(1, bars_count + 1): + var _hz: float = log_freq(ih / float(bars_count), MIN_HZ, MAX_HZ) + #print(\"%.0f hz %.2f\" % [_hz, ih / float(bars_count)]) func draw_spectrum(): - var _s1 = DebugDraw3D.scoped_config().set_thickness(bar_thickness) - var prev_hz = 0 + var _s1 = DebugDraw3D.scoped_config().set_thickness(bar_thickness).set_center_brightness(0.9) + var prev_hz = MIN_HZ smoothed_energy.resize(bars_count) var xf := transform @@ -274,8 +280,8 @@ func draw_spectrum(): for ih in range(1, bars_count + 1): var i := ih - 1 - var hz: float = ih * MAX_HZ / bars_count - var magnitude: float = spectrum.get_magnitude_for_frequency_range(prev_hz, hz).length() + var hz: float = log_freq(ih / float(bars_count), MIN_HZ, MAX_HZ) + var magnitude: float = spectrum.get_magnitude_for_frequency_range(prev_hz, hz, 0).length() var energy: float = clampf((MIN_DB + linear_to_db(magnitude)) / MIN_DB, 0, 1) var e: float = lerp(smoothed_energy[i], energy, clampf(get_process_delta_time() / motion_smoothing if motion_smoothing else 1.0, 0, 1)) smoothed_energy[i] = e @@ -298,12 +304,20 @@ func draw_spectrum(): color_offset = wrapf(color_offset + sum / smoothed_energy.size() * clampf(get_process_delta_time() / color_offset_speed if color_offset_speed else 1.0, 0, 1), 0, 1) -func _on_mute_toggled(toggled_on): - AudioServer.set_bus_mute(AudioServer.get_bus_index(&\"Master\"), toggled_on) +func log10(val: float) -> float: + return log(val) / 2.302585 + + +func log_freq(pos: float, min_hz: float, max_hz: float) -> float: + return pow(10, log10(min_hz) + (log10(max_hz) - log10(min_hz)) * pos) func _on_volume_slider_value_changed(value): AudioServer.set_bus_volume_db(AudioServer.get_bus_index(&\"Master\"), linear_to_db(value)) + + +func _on_mute_master_toggled(toggled_on): + AudioServer.set_bus_mute(AudioServer.get_bus_index(&\"Master\"), toggled_on) " [sub_resource type="Gradient" id="Gradient_tup4c"] @@ -315,7 +329,7 @@ length = 0.001 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("%MusicPlayer:stream") +tracks/0/path = NodePath("../MusicPlayer:stream") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { @@ -356,7 +370,7 @@ func _ready(): %BufferSlider.value = test.buffer_size %ThicknessSlider.value = get_parent().debug_thickness - %UpdateInPhysics.text = \"Update in physics (%d Ticks)\" % ProjectSettings.get_setting(\"physics/common/physics_ticks_per_second\") + %UpdateInPhysics.text = \"Update in physics (%d Ticks) *\" % ProjectSettings.get_setting(\"physics/common/physics_ticks_per_second\") %UpdateInPhysics.button_pressed = get_parent().update_in_physics %ShowStats.button_pressed = get_parent().text_groups_show_stats @@ -419,6 +433,51 @@ func _on_draw_boxes_toggled(toggled_on): get_parent().draw_array_of_boxes = toggled_on " +[sub_resource type="GDScript" id="GDScript_h0fpq"] +script/source = "extends HBoxContainer + +var _on_versions_loaded_callback = null +@onready var btn: OptionButton = $OptionButton + +func _enter_tree(): + hide() + + +func _ready(): + if OS.has_feature('web'): + _on_versions_loaded_callback = JavaScriptBridge.create_callback(_on_versions_loaded) + var versions_callbacks: JavaScriptObject = JavaScriptBridge.get_interface(\"versions_callbacks\") + versions_callbacks.loaded = _on_versions_loaded_callback + + JavaScriptBridge.eval(\"loadVersions()\") + + +func _on_versions_loaded(args: Array) -> void: + if (args.size() == 0): + return + + var current_version: String = args[0] + + var versions_str: String = JavaScriptBridge.eval(\"versions_callbacks.versions;\") + var version_urls_str: String = JavaScriptBridge.eval(\"versions_callbacks.version_urls;\") + var versions: PackedStringArray = versions_str.split(\";\", false) + var version_urls: PackedStringArray = version_urls_str.split(\";\", false) + + if versions: + show() + btn.clear() + btn.item_selected.connect(func(idx): + # move to another version + JavaScriptBridge.eval(\"window.location.href = \\\"%s\\\"\" % version_urls[idx]) + ) + + for i in range(versions.size()): + btn.add_item(versions[i], i) + + if versions[i] == current_version: + btn.select(i) +" + [sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_oj5gf"] content_margin_top = 5.0 content_margin_bottom = 7.0 @@ -750,18 +809,21 @@ libraries = { "": SubResource("AnimationLibrary_a7f1a") } -[node name="MusicVisualizer" type="Button" parent="."] +[node name="MusicVisualizer" type="VBoxContainer" parent="."] offset_left = 10.0 offset_top = 10.0 -offset_right = 98.0 -offset_bottom = 41.0 -text = "OPEN FILE" +offset_right = 50.0 +offset_bottom = 50.0 script = SubResource("GDScript_atshy") -bar_thickness = 0.065 -bars_separation = 0.325 colors = SubResource("Gradient_tup4c") +[node name="OpenFile" type="Button" parent="MusicVisualizer"] +layout_mode = 2 +size_flags_horizontal = 0 +text = "OPEN FILE" + [node name="RESET" type="AnimationPlayer" parent="MusicVisualizer"] +root_node = NodePath("../OpenFile") libraries = { "": SubResource("AnimationLibrary_0ity1") } @@ -772,10 +834,7 @@ autoplay = true bus = &"MusicVisualizer" [node name="VBox" type="VBoxContainer" parent="MusicVisualizer"] -layout_mode = 0 -offset_top = 35.0 -offset_right = 40.0 -offset_bottom = 75.0 +layout_mode = 2 [node name="HBoxContainer" type="HBoxContainer" parent="MusicVisualizer/VBox"] layout_mode = 2 @@ -841,7 +900,32 @@ offset_bottom = -10.0 grow_horizontal = 0 grow_vertical = 0 -[node name="Label" type="Label" parent="Settings/HBox"] +[node name="VBoxContainer" type="VBoxContainer" parent="Settings/HBox"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 8 + +[node name="VersionBlock" type="HBoxContainer" parent="Settings/HBox/VBoxContainer"] +unique_name_in_owner = true +layout_mode = 2 +script = SubResource("GDScript_h0fpq") + +[node name="Label" type="Label" parent="Settings/HBox/VBoxContainer/VersionBlock"] +layout_mode = 2 +size_flags_horizontal = 10 +theme_override_font_sizes/font_size = 13 +text = "Demo version:" + +[node name="OptionButton" type="OptionButton" parent="Settings/HBox/VBoxContainer/VersionBlock"] +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_font_sizes/font_size = 13 +item_count = 1 +selected = 0 +popup/item_0/text = "1.0.0" +popup/item_0/id = 0 + +[node name="Label" type="Label" parent="Settings/HBox/VBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 size_flags_vertical = 8 @@ -885,7 +969,10 @@ value = 0.05 [node name="UpdateInPhysics" type="CheckBox" parent="Settings/HBox/PanelContainer/VBox"] unique_name_in_owner = true layout_mode = 2 -text = "Update in physics (15 Ticks)" +tooltip_text = "Because of the low physics tick rate, +you can see how RayCast's can shake. +This is expected behavior." +text = "Update in physics (15 Ticks) *" [node name="Label2" type="Label" parent="Settings/HBox/PanelContainer/VBox"] layout_mode = 2 @@ -957,8 +1044,10 @@ unique_name_in_owner = true layout_mode = 2 text = "Switch to C#" +[connection signal="pressed" from="MusicVisualizer/OpenFile" to="MusicVisualizer" method="_pressed"] [connection signal="value_changed" from="MusicVisualizer/VBox/HBoxContainer/VolumeSlider" to="MusicVisualizer" method="_on_volume_slider_value_changed"] -[connection signal="toggled" from="MusicVisualizer/VBox/HBoxContainer/MuteMaster" to="MusicVisualizer" method="_on_mute_toggled"] +[connection signal="value_changed" from="MusicVisualizer/VBox/HBoxContainer/VolumeSlider" to="MusicVisualizer/OpenFile" method="_on_volume_slider_value_changed"] +[connection signal="toggled" from="MusicVisualizer/VBox/HBoxContainer/MuteMaster" to="MusicVisualizer" method="_on_mute_master_toggled"] [connection signal="value_changed" from="Settings/HBox/PanelContainer/VBox/HBox3/ThicknessSlider" to="Settings" method="_on_thickness_slider_value_changed"] [connection signal="toggled" from="Settings/HBox/PanelContainer/VBox/UpdateInPhysics" to="Settings" method="_on_update_in_physics_toggled"] [connection signal="toggled" from="Settings/HBox/PanelContainer/VBox/FPSEnabled" to="Settings" method="_on_CheckBox_toggled"] diff --git a/examples_dd3d/DebugDrawDemoSceneCS.tscn b/examples_dd3d/DebugDrawDemoSceneCS.tscn index 343af439..9f1b7b2f 100644 --- a/examples_dd3d/DebugDrawDemoSceneCS.tscn +++ b/examples_dd3d/DebugDrawDemoSceneCS.tscn @@ -9,8 +9,8 @@ script = ExtResource("2_ipqea") [node name="Settings" parent="." index="17"] switch_to_scene = "res://examples_dd3d/DebugDrawDemoScene.tscn" -[node name="Label" parent="Settings/HBox" index="0"] +[node name="Label" parent="Settings/HBox/VBoxContainer" index="1"] text = "C# example" -[node name="SwitchLang" parent="Settings/HBox/PanelContainer/VBox" index="8"] +[node name="SwitchLang" parent="Settings/HBox/PanelContainer/VBox" index="11"] text = "Switch to GDScript" diff --git a/src/2d/debug_draw_2d.h b/src/2d/debug_draw_2d.h index 22fc2ce9..aa5dc46e 100644 --- a/src/2d/debug_draw_2d.h +++ b/src/2d/debug_draw_2d.h @@ -83,6 +83,9 @@ class DebugDraw2D : public Object { /// @private void init(DebugDrawManager *root); + /** + * Get singleton. Not available in GDScript. + */ static DebugDraw2D *get_singleton() { return singleton; }; @@ -148,6 +151,8 @@ class DebugDraw2D : public Object { * @param group_priority Group priority based on which groups will be sorted from top to bottom. * @param group_color Main color of the group * @param show_title Whether to show the title + * @param title_size Title font size + * @param text_size Text font size */ void begin_text_group(String group_title, int group_priority = 0, Color group_color = Colors::empty_color, bool show_title = true, int title_size = 14, int text_size = 12); /** diff --git a/src/2d/graphs.h b/src/2d/graphs.h index b09036a1..c1a8967e 100644 --- a/src/2d/graphs.h +++ b/src/2d/graphs.h @@ -17,6 +17,11 @@ using namespace godot; class DataGraphManager; +/** + * Base class for drawing graphs. + * + * Must be created via DebugDraw2D.create_graph. +*/ class DebugDraw2DGraph : public RefCounted { GDCLASS(DebugDraw2DGraph, RefCounted); @@ -304,7 +309,9 @@ VARIANT_ENUM_CAST(DebugDraw2DGraph::GraphSide); VARIANT_BITFIELD_CAST(DebugDraw2DGraph::TextFlags); /** - * This version of the graphs is automatically updated and displays FPS or Frametime + * This version of the graphs is automatically updated and displays FPS or Frametime. + * + * Must be created via DebugDraw2D.create_fps_graph. */ class DebugDraw2DFPSGraph : public DebugDraw2DGraph { GDCLASS(DebugDraw2DFPSGraph, DebugDraw2DGraph); diff --git a/src/3d/debug_draw_3d.cpp b/src/3d/debug_draw_3d.cpp index 7b03dd3b..11801439 100644 --- a/src/3d/debug_draw_3d.cpp +++ b/src/3d/debug_draw_3d.cpp @@ -958,15 +958,15 @@ void DebugDraw3D::draw_grid(const Vector3 &origin, const Vector3 &x_size, const subdivision, color, is_centered, duration); } -void DebugDraw3D::draw_grid_xf(const Transform3D &transform, const Vector2i &_subdivision, const Color &color, const bool &is_centered, const real_t &duration) { +void DebugDraw3D::draw_grid_xf(const Transform3D &transform, const Vector2i &p_subdivision, const Color &color, const bool &is_centered, const real_t &duration) { ZoneScoped; CHECK_BEFORE_CALL(); #define MAX_SUBDIVISIONS 1024 * 1024 - ERR_FAIL_COND(_subdivision.x > MAX_SUBDIVISIONS); - ERR_FAIL_COND(_subdivision.y > MAX_SUBDIVISIONS); + ERR_FAIL_COND(p_subdivision.x > MAX_SUBDIVISIONS); + ERR_FAIL_COND(p_subdivision.y > MAX_SUBDIVISIONS); - Vector2i subdivision = _subdivision.abs(); + Vector2i subdivision = p_subdivision.abs(); subdivision = Vector2i(Math::clamp(subdivision.x, 1, MAX_SUBDIVISIONS), Math::clamp(subdivision.y, 1, MAX_SUBDIVISIONS)); Vector3 x_axis = transform.basis.get_column(0); Vector3 z_axis = transform.basis.get_column(2); diff --git a/src/3d/debug_draw_3d.h b/src/3d/debug_draw_3d.h index 53110b46..c996fdce 100644 --- a/src/3d/debug_draw_3d.h +++ b/src/3d/debug_draw_3d.h @@ -58,6 +58,9 @@ class DebugDraw3D : public Object, public IScopeStorage #endif public: + /** + * Appearance of points on the path + */ enum PointType : int { POINT_TYPE_SQUARE, POINT_TYPE_SPHERE, @@ -158,6 +161,9 @@ class DebugDraw3D : public Object, public IScopeStorage DebugDraw3D(); ~DebugDraw3D(); + /** + * Get singleton. Not available in GDScript. + */ static DebugDraw3D *get_singleton() { return singleton; }; @@ -455,7 +461,7 @@ class DebugDraw3D : public Object, public IScopeStorage /** * Draw the arrowhead * - * @param Transform Transform3D of the Arrowhead + * @param transform Transform3D of the Arrowhead * @param color Primary color * @param duration The duration of how long the object will be visible */ @@ -470,7 +476,7 @@ class DebugDraw3D : public Object, public IScopeStorage * @param b End point * @param color Primary color * @param arrow_size Size of the arrow - * @param absolute_size Is `arrow_size` absolute or relative to the length of the string? + * @param is_absolute_size Is `arrow_size` absolute or relative to the length of the string? * @param duration The duration of how long the object will be visible */ void draw_arrow(const Vector3 &a, const Vector3 &b, const Color &color = Colors::empty_color, const real_t &arrow_size = 0.5f, const bool &is_absolute_size = false, const real_t &duration = 0) FAKE_FUNC_IMPL; @@ -483,7 +489,7 @@ class DebugDraw3D : public Object, public IScopeStorage * @param length Length * @param color Primary color * @param arrow_size Size of the arrow - * @param absolute_size Is `arrow_size` absolute or relative to the line length? + * @param is_absolute_size Is `arrow_size` absolute or relative to the line length? * @param duration The duration of how long the object will be visible */ void draw_arrow_ray(const Vector3 &origin, const Vector3 &direction, const real_t &length, const Color &color = Colors::empty_color, const real_t &arrow_size = 0.5f, const bool &is_absolute_size = false, const real_t &duration = 0) FAKE_FUNC_IMPL; @@ -496,7 +502,7 @@ class DebugDraw3D : public Object, public IScopeStorage * @param path Sequence of points * @param color Primary color * @param arrow_size Size of the arrow - * @param absolute_size Is the `arrow_size` absolute or relative to the length of the line? + * @param is_absolute_size Is the `arrow_size` absolute or relative to the length of the line? * @param duration The duration of how long the object will be visible */ void draw_arrow_path(const PackedVector3Array &path, const Color &color = Colors::empty_color, const real_t &arrow_size = 0.75f, const bool &is_absolute_size = true, const real_t &duration = 0) FAKE_FUNC_IMPL; @@ -530,9 +536,10 @@ class DebugDraw3D : public Object, public IScopeStorage * * ![](docs/images/classes/DrawPoints.webp) * - * @param path Sequence of points - * @param color Primary color + * @param points Sequence of points + * @param type Type of points * @param size Size of squares + * @param color Primary color * @param duration The duration of how long the object will be visible */ void draw_points(const PackedVector3Array &points, const PointType type = PointType::POINT_TYPE_SQUARE, const real_t &size = 0.25f, const Color &color = Colors::empty_color, const real_t &duration = 0) FAKE_FUNC_IMPL; @@ -593,12 +600,12 @@ class DebugDraw3D : public Object, public IScopeStorage * Like DebugDraw3D.draw_grid, but instead of origin, x_size and y_size, a single transform is used. * * @param transform Transform3D of the Grid - * @param subdivision Number of cells for the X and Y axes + * @param p_subdivision Number of cells for the X and Y axes * @param color Primary color * @param is_centered Draw lines relative to origin * @param duration The duration of how long the object will be visible */ - void draw_grid_xf(const Transform3D &transform, const Vector2i &_subdivision, const Color &color = Colors::empty_color, const bool &is_centered = true, const real_t &duration = 0) FAKE_FUNC_IMPL; + void draw_grid_xf(const Transform3D &transform, const Vector2i &p_subdivision, const Color &color = Colors::empty_color, const bool &is_centered = true, const real_t &duration = 0) FAKE_FUNC_IMPL; #pragma region Camera Frustum diff --git a/src/debug_draw_manager.h b/src/debug_draw_manager.h index 7e4eda50..555b6a8a 100644 --- a/src/debug_draw_manager.h +++ b/src/debug_draw_manager.h @@ -28,27 +28,27 @@ class DD3D_PhysicsWatcher : public Node { /** * The main singleton class that handles DebugDraw2D and DebugDraw3D. - * + * * Several additional settings can be found in the project settings. - * + * * @note The following settings require a restart. - * + * * `debug_draw_3d/settings/initial_debug_state` sets the initial debugging state. - * + * * `debug_draw_3d/settings/common/DebugDrawManager_singleton_aliases` sets aliases for DebugDrawManager to be registered as additional singletons. - * + * * `debug_draw_3d/settings/common/DebugDraw2D_singleton_aliases` sets aliases for DebugDraw2D to be registered as additional singletons. - * + * * `debug_draw_3d/settings/common/DebugDraw3D_singleton_aliases` sets aliases for DebugDraw3D to be registered as additional singletons. - * + * * Using these aliases you can reference singletons with shorter words: - * + * * ```python * var _s = Dbg3.new_scope_config().set_thickness(0.025).set_center_brightness(0.7) * Dbg3.draw_grid_xf(%Grid.global_transform, Vector2i(10,10), Color.LIGHT_GRAY) * Dbg2.set_text("Frametime", delta) * ``` -*/ + */ class DebugDrawManager : public CanvasLayer { GDCLASS(DebugDrawManager, CanvasLayer) protected: @@ -127,6 +127,9 @@ class DebugDrawManager : public CanvasLayer { DebugDrawManager(); ~DebugDrawManager(); + /** + * Get singleton. Not available in GDScript. + */ static DebugDrawManager *get_singleton() { return singleton; }; @@ -134,15 +137,15 @@ class DebugDrawManager : public CanvasLayer { #pragma region Exposed Methods /** * Clear all 2D and 3D geometry - */ + */ void clear_all(); /** * Set whether to display 2D and 3D debug graphics - */ + */ void set_debug_enabled(bool value); /** * Whether debug 2D and 3D graphics are disabled - */ + */ bool is_debug_enabled() const; #pragma endregion // Exposed Methods diff --git a/src/editor/editor_menu_extensions.cpp b/src/editor/editor_menu_extensions.cpp index 37755ee2..fc922aa1 100644 --- a/src/editor/editor_menu_extensions.cpp +++ b/src/editor/editor_menu_extensions.cpp @@ -3,6 +3,7 @@ #include "editor_menu_extensions.h" #include "generate_csharp_bindings.h" #include "utils/utils.h" +#include "version.h" GODOT_WARNING_DISABLE() #include "gen/editor_resources.gen.h" @@ -60,7 +61,7 @@ void DebugDrawMenuExtensionPlugin::_on_id_pressed(MenuItemId id) { break; } case DebugDrawMenuExtensionPlugin::OPEN_DOCUMENTATION_SITE: { - OS::get_singleton()->shell_open("https://dd3d.dmitriysalnikov.ru/docs/stable"); + OS::get_singleton()->shell_open("https://dd3d.dmitriysalnikov.ru/docs/" DD3D_VERSION_STR); break; } case DebugDrawMenuExtensionPlugin::GENERATE_CSHARP_BINDING: { diff --git a/src/version.h b/src/version.h index ea776c04..fe7b641c 100644 --- a/src/version.h +++ b/src/version.h @@ -6,5 +6,5 @@ #define DD3D_VERSION ((DD3D_MAJOR << (8 * 3)) + (DD3D_MINOR << (8 * 2)) + (DD3D_PATCH << (8 * 1))) #define _DD3D_VERSION_STR_TEXT(text) #text -#define _DD3D_VERSION_STR(major, minor, patch) (_DD3D_VERSION_STR_TEXT(major) "." _DD3D_VERSION_STR_TEXT(minor) "." _DD3D_VERSION_STR_TEXT(patch)) +#define _DD3D_VERSION_STR(major, minor, patch) _DD3D_VERSION_STR_TEXT(major) "." _DD3D_VERSION_STR_TEXT(minor) "." _DD3D_VERSION_STR_TEXT(patch) #define DD3D_VERSION_STR _DD3D_VERSION_STR(DD3D_MAJOR, DD3D_MINOR, DD3D_PATCH)