Compare commits

..

6 Commits
v0.1.1 ... main

8 changed files with 30 additions and 16 deletions

View File

@ -9,10 +9,10 @@ it can handle about 2000 boids in a single flock at 11ms physics process tick on
## usage
download it from the asset library.
download it from the [asset library](https://godotengine.org/asset-library/asset/3284).
or clone the repository (git lfs is needed) and copy over the `addons` folder into your project root.
check the examples for more info.
or clone the repository, and run `rust/package-release.sh` to build the libraries for all supported targets.
(requires [cross](https://github.com/cross-rs/cross))
## development

1
rust/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.vscode

10
rust/build-debug.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/sh
set -x
cargo build
cd ..
cp -f rust/target/debug/libboids.so addons/boids/lib/boids.x86.so
cp -f rust/target/debug/boids.dll addons/boids/lib/boids.x86.dll

View File

@ -1,11 +1,15 @@
#!/bin/sh
set -x
cross build --release --target x86_64-unknown-linux-gnu
cross build --release --target x86_64-pc-windows-gnu
cross +nightly build -Zbuild-std --release --target wasm32-unknown-emscripten
cp -f target/x86_64-unknown-linux-gnu/release/libboids.so ../addons/boids/lib/boids.x86.so
cp -f target/x86_64-pc-windows-gnu/release/boids.dll ../addons/boids/lib/boids.x86.dll
cp -f target/wasm32-unknown-emscripten/release/boids.wasm ../addons/boids/lib/boids.wasm
cd ..
zip -r ../../boids-release.zip ../addons ../examples ../README.md ../LICENSE.txt
cp -f rust/target/x86_64-unknown-linux-gnu/release/libboids.so addons/boids/lib/boids.x86.so
cp -f rust/target/x86_64-pc-windows-gnu/release/boids.dll addons/boids/lib/boids.x86.dll
cp -f rust/target/wasm32-unknown-emscripten/release/boids.wasm addons/boids/lib/boids.wasm
zip -r ../boids-release.zip addons examples README.md LICENSE.txt

View File

@ -83,9 +83,9 @@ impl Boid for Boid2D {
#[inline(always)]
fn apply_force(&mut self, force: Vec3) {
self.vel += force.xy();
let new_vel = self.vel.clamp_length_max(self.props.max_speed);
self.vel = new_vel;
self.base_mut().translate(Vector2::new(new_vel.x, new_vel.y));
self.vel = self.vel.clamp_length_max(self.props.max_speed);
let force_to_apply = Vector2::new(self.vel.x, self.vel.y);
self.base_mut().translate(force_to_apply);
}
#[inline(always)]

View File

@ -82,10 +82,9 @@ impl Boid for Boid3D {
#[inline(always)]
fn apply_force(&mut self, force: Vec3) {
self.vel += force;
let new_vel = self.vel.clamp_length_max(self.props.max_speed);
self.vel = new_vel;
self.base_mut()
.translate(Vector3::new(new_vel.x, new_vel.y, new_vel.z));
self.vel = self.vel.clamp_length_max(self.props.max_speed);
let force_to_apply = Vector3::new(self.vel.x, self.vel.y, self.vel.z);
self.base_mut().translate(force_to_apply);
}
#[inline(always)]

View File

@ -28,4 +28,4 @@ pub struct BoidProperties {
#[init(val = 0.8)]
/// How much to follow a flock target (if there is one).
pub targeting: f32,
}
}

View File

@ -16,4 +16,4 @@ pub struct FlockProperties {
#[init(val = 2500.0)]
/// Distance (squared) to apply cohesion force between boids in a flock.
pub goal_cohesion: f32,
}
}