Skip to content

Commit f33c4aa

Browse files
authored
Merge pull request #12 from mphe/endpoint_fixation
Various new features, examples and fixes
2 parents b530c1b + 0391a9b commit f33c4aa

49 files changed

Lines changed: 5603 additions & 358 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Checks:
2+
- bugprone-*
3+
- -bugprone-easily-swappable-parameters
4+
- cert-*
5+
- clang-analyzer-*
6+
- concurrency-*
7+
- cppcoreguidelines-*
8+
- -cppcoreguidelines-init-variables # Produces false positves when initialization happens later
9+
- -cppcoreguidelines-avoid-magic-numbers # This also triggers with literals like 3.1415
10+
- -cppcoreguidelines-avoid-non-const-global-variables
11+
- misc-*
12+
- -misc-non-private-member-variables-in-classes
13+
- -misc-use-anonymous-namespace
14+
- -misc-include-cleaner
15+
- performance-*
16+
- portability-*
17+
- readability-*
18+
- -readability-braces-around-statements
19+
- -readability-uppercase-literal-suffix
20+
- -readability-magic-numbers # This also triggers with literals like 3.1415
21+
- -readability-redundant-access-specifiers
22+
- -readability-implicit-bool-conversion

.clangd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CompileFlags:
2+
Remove:
3+
- -fno-gnu-unique
4+
Add:
5+
- -Wall
6+
- -Wextra

.github/workflows/build.yml

Lines changed: 60 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,87 @@
11
# Adapted from https://github.com/nathanfranke/gdextension/blob/main/.github/workflows/build.yml
22
name: Builds
33
on:
4-
push:
5-
branches: [ "master" ]
6-
pull_request:
7-
branches: [ "master" ]
4+
workflow_dispatch:
5+
inputs:
6+
git-ref:
7+
description: A commit, branch or tag to build.
8+
type: string
9+
required: true
10+
workflow_call:
11+
inputs:
12+
git-ref:
13+
description: A commit, branch or tag to build.
14+
type: string
15+
required: true
816

917
jobs:
1018
build:
1119
runs-on: ${{ matrix.runner }}
12-
name: ${{ matrix.name }}
20+
name: ${{ matrix.platform }} ${{ matrix.target }} ${{ matrix.arch }} ${{ matrix.optimize }}
1321
strategy:
1422
fail-fast: false
1523
matrix:
24+
target: [ template_debug, template_release ]
25+
identifier: [ windows, linux, macos, android, android_arm64 ]
26+
1627
include:
17-
# Linux
18-
- identifier: linux-debug
19-
name: Linux Debug
20-
runner: ubuntu-20.04
21-
target: template_debug
22-
platform: linux
23-
arch: x86_64
28+
# Defaults
29+
- runner: ubuntu-latest
30+
- optimize: speed
31+
- arch: x86_64
2432

25-
- identifier: linux-release
26-
name: Linux Release
27-
runner: ubuntu-20.04
28-
target: template_release
29-
platform: linux
30-
arch: x86_64
33+
# Debug build settings
34+
- target: template_debug
35+
optimize: speed_trace
3136

32-
# Windows
33-
- identifier: windows-debug
34-
name: Windows Debug
35-
runner: ubuntu-20.04
36-
target: template_debug
37+
# Map identifiers to platforms + special settings
38+
- identifier: windows
3739
platform: windows
38-
arch: x86_64
3940

40-
- identifier: windows-release
41-
name: Windows Release
42-
runner: ubuntu-20.04
43-
target: template_release
44-
platform: windows
45-
arch: x86_64
46-
47-
# Android Arm64
48-
- identifier: android-release
49-
name: Android Release Arm64
50-
runner: ubuntu-20.04
51-
target: template_release
52-
platform: android
53-
arch: arm64
41+
- identifier: macos
42+
platform: macos
43+
runner: macos-latest
44+
arch: universal
5445

55-
- identifier: android-debug
56-
name: Android Debug Arm64
57-
runner: ubuntu-20.04
58-
target: template_debug
59-
platform: android
60-
arch: arm64
46+
- identifier: linux
47+
platform: linux
6148

62-
# Android x86_64
63-
- identifier: android-release
64-
name: Android Release x86_64
65-
runner: ubuntu-20.04
66-
target: template_release
49+
- identifier: android
6750
platform: android
68-
arch: x86_64
6951

70-
- identifier: android-debug
71-
name: Android Debug x86_64
72-
runner: ubuntu-20.04
73-
target: template_debug
52+
- identifier: android_arm64
7453
platform: android
75-
arch: x86_64
76-
77-
# Mac
78-
- identifier: macos-debug
79-
name: macOS (universal) Debug
80-
runner: macos-latest
81-
target: template_debug
82-
platform: macos
83-
arch: universal
84-
85-
- identifier: macos-release
86-
name: macOS (universal) Release
87-
runner: macos-latest
88-
target: template_release
89-
platform: macos
90-
arch: universal
54+
arch: arm64
9155

9256
steps:
57+
- name: Check settings
58+
if: ${{ matrix.platform == '' || matrix.target == '' || matrix.runner == '' || matrix.optimize == '' || matrix.arch == ''}}
59+
run: |
60+
echo "One of the matrix values is not set."
61+
exit 1
62+
9363
- name: (Windows) Install mingw64
94-
if: ${{ startsWith(matrix.identifier, 'windows-') }}
64+
if: ${{ matrix.platform == 'windows' }}
9565
shell: sh
9666
run: |
9767
sudo apt-get install mingw-w64
9868
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
9969
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
10070
10171
- name: (Android) Install JDK 17
102-
if: ${{ startsWith(matrix.identifier, 'android-') }}
72+
if: ${{ matrix.platform == 'android' }}
10373
uses: actions/setup-java@v3
10474
with:
10575
java-version: 17
10676
distribution: temurin
10777

10878
- name: (Android) Install Android SDK
109-
if: ${{ startsWith(matrix.identifier, 'android-') }}
79+
if: ${{ matrix.platform == 'android' }}
11080
uses: android-actions/setup-android@v3
11181

11282
# From Godot docs, might not be necessary.
11383
#- name: (Android) Install Android Tools
114-
# if: ${{ startsWith(matrix.identifier, 'android-') }}
84+
# if: ${{ matrix.platform == 'android' }}
11585
# shell: sh
11686
# run: |
11787
# "$ANDROID_SDK_ROOT"/cmdline-tools/latest/bin/sdkmanager --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "build-tools;30.0.3" "platforms;android-29" "cmdline-tools;latest" "cmake;3.10.2.4988404"
@@ -124,19 +94,22 @@ jobs:
12494
link-to-sdk: true
12595

12696
- name: Set up Python
127-
uses: actions/setup-python@v2
97+
uses: actions/setup-python@v5
98+
with:
99+
python-version: '3.10'
128100

129101
- name: Set up SCons
130102
shell: bash
131103
run: |
132104
python -c "import sys; print(sys.version)"
133-
python -m pip install scons
105+
python -m pip install scons==4.7.0
134106
scons --version
135107
136108
- name: Checkout project
137-
uses: actions/checkout@v2
109+
uses: actions/checkout@v4
138110
with:
139111
submodules: recursive
112+
ref: ${{ inputs.git-ref }}
140113

141114
# TODO: Cache doesn't work yet. SCons rebuilds the objects even if they already exist. Could be caused by modification dates or extension_api.json.
142115
# fetch-depth: 0 May be needed for cache. See: <https://github.com/actions/checkout/issues/468>.
@@ -147,30 +120,30 @@ jobs:
147120
# ${{ github.workspace }}/.scons-cache/
148121
# ${{ github.workspace }}/**/.sconsign.dblite
149122
# ${{ github.workspace }}/godot-cpp/gen/
150-
# key: ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }}
123+
# key: ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }}
151124
# restore-keys: |
152-
# ${{ matrix.identifier }}-${{ github.ref }}-${{ github.sha }}
153-
# ${{ matrix.identifier }}-${{ github.ref }}
154-
# ${{ matrix.identifier }}
125+
# ${{ matrix.platform }}-${{ github.ref }}-${{ github.sha }}
126+
# ${{ matrix.platform }}-${{ github.ref }}
127+
# ${{ matrix.platform }}
155128

156129
- name: Compile extension
157130
shell: sh
158131
# env:
159132
# SCONS_CACHE: '${{ github.workspace }}/.scons-cache/'
160133
# SCONS_CACHE_LIMIT: 8192
161134
run: |
162-
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' -j2
135+
scons target='${{ matrix.target }}' platform='${{ matrix.platform }}' arch='${{ matrix.arch }}' optimize=${{ matrix.optimize }} -j2
163136
ls -l demo/addons/*/bin/
164137
165-
- name: Copy extra files to addon
138+
- name: Prepare files for publish
166139
shell: sh
167140
run: |
168-
for addon in ${{ github.workspace }}/demo/addons/*/; do
169-
cp -n '${{ github.workspace }}/README.md' '${{ github.workspace }}/LICENSE' "$addon"
170-
done
141+
cp -n '${{ github.workspace }}/README.md' '${{ github.workspace }}/LICENSE' '${{ github.workspace }}/demo/addons/ropesim/'
142+
rm -rf '${{ github.workspace }}/demo/addons/diagnosticlist'
143+
rm '${{ github.workspace }}/demo/project.godot'
171144
172145
- name: Upload artifact
173-
uses: actions/upload-artifact@v2
146+
uses: actions/upload-artifact@v3
174147
with:
175148
name: ${{ github.event.repository.name }}
176149
path: |

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: CI
2+
on:
3+
push:
4+
# branches: [ master ]
5+
pull_request:
6+
# branches: [ master ]
7+
8+
jobs:
9+
ci:
10+
name: "CI"
11+
uses: ./.github/workflows/build.yml
12+
with:
13+
git-ref: ${{ github.ref }}
14+

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<img src="https://github.com/mphe/GDNative-Ropesim/assets/7116001/272f4f65-cb79-4798-97ba-f0d43589caef" width=128px align="right"/>
44

5-
A 2D verlet integration based rope simulation for Godot 4.2.
5+
A 2D verlet integration based rope simulation for Godot 4.2+.
66

77
The computation-heavy simulation part is written in C++ using GDExtension, the rest in GDScript. This allows for fast processing and easy extendability, while keeping the code readable.
88

@@ -15,9 +15,9 @@ The last Godot 3.x version can be found on the [3.x branch](https://github.com/m
1515
* [Download](https://github.com/mphe/GDNative-Ropesim/releases/latest) the latest release from the release page, or
1616
* [Download](https://github.com/mphe/GDNative-Ropesim/actions) it from the latest GitHub Actions run, or
1717
* [Compile](#building) it yourself.
18-
3. Copy or symlink `addons/ropesim` to your project's `addons/` directory
19-
4. Enable the addon in the project settings
20-
5. Restart Godot
18+
2. Copy or symlink `addons/ropesim` to your project's `addons/` directory
19+
3. Enable the addon in the project settings
20+
4. Restart Godot
2121

2222
# Building
2323

@@ -29,7 +29,7 @@ To compile for Linux, run the following commands.
2929
Compiling for other platforms works analogously.
3030

3131
```sh
32-
$ scons target=template_release platform=linux arch=x86_64 -j8
32+
$ scons target=template_release platform=linux optimize=speed arch=x86_64 -j8
3333
$ scons target=template_debug platform=linux arch=x86_64 -j8
3434
```
3535

@@ -43,15 +43,17 @@ Following nodes exist:
4343
* `RopeHandle`: A handle that can be used to control, animate, or fixate parts of the rope.
4444
* `RopeRendererLine2D`: Renders a target rope using `Line2D`.
4545
* `RopeCollisionShapeGenerator`: Can be used e.g. in an `Area2D` to detect collisions with the target rope.
46-
47-
See inline comments for further information and documentation of node properties.
48-
49-
The included demo project and the showcase video below provide some usage examples.
46+
* `RopeInteraction`: Handles mutual interaction of a target node with a rope. Useful for rope grabbing or pulling mechanics where an object should be able to affect the rope and vice-versa.
5047

5148
When one of these nodes is selected, a "Ropesim" menu appears in the editor toolbar that can be used to toggle live preview in the editor on and off.
5249

5350
All rope related tools, automatically pause themselves when their target rope is paused to save performance.
5451

52+
Use the in-engine help to view the full documentation for each node.
53+
54+
The project also includes various example scenes that demonstrate the features of this plugin.
55+
See also the [showcase video](#showcase) for a basic usage example.
56+
5557
# Showcase
5658

5759
A quick overview of how to use each node.

SConstruct

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ opts.Update(env)
2626
# - CPPDEFINES are for pre-processor defines
2727
# - LINKFLAGS are for linking flags
2828

29+
env.Append(CCFLAGS="-fdiagnostics-color")
30+
2931

3032
# Sources
3133
env.Append(CPPPATH=["src/"])

compile_debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
scons compiledb=yes optimize=debug
3+
scons compiledb=yes optimize=debug use_llvm=yes

compile_release.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
scons optimize=speed target=template_release

demo/addons/diagnosticlist/.diagnostic_ignore

Whitespace-only changes.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
extends RefCounted
2+
class_name DiagnosticList_Diagnostic
3+
4+
5+
class Pack extends RefCounted:
6+
var res_uri: StringName
7+
var diagnostics: Array[DiagnosticList_Diagnostic]
8+
9+
10+
enum Severity {
11+
Error,
12+
Warning,
13+
Info,
14+
Hint,
15+
}
16+
17+
18+
## Represents the file path as res:// path
19+
@export var res_uri: StringName
20+
@export var line_start: int # zero-based
21+
@export var column_start: int # zero-based
22+
@export var severity: Severity
23+
@export var message: String
24+
25+
var _filename: StringName
26+
27+
28+
## Returns the filename, i.e. the last component of the path including the extension.
29+
func get_filename() -> StringName:
30+
if _filename.is_empty():
31+
_filename = StringName(res_uri.get_file())
32+
return _filename
33+
34+

0 commit comments

Comments
 (0)