Compare commits

..

No commits in common. "main" and "v0.1.1" have entirely different histories.
main ... v0.1.1

8 changed files with 16 additions and 30 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](https://godotengine.org/asset-library/asset/3284).
download it from the asset library.
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))
or clone the repository (git lfs is needed) and copy over the `addons` folder into your project root.
check the examples for more info.
## development

1
rust/.gitignore vendored
View File

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

View File

@ -1,10 +0,0 @@
#!/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,15 +1,11 @@
#!/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
cd ..
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
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
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();
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);
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));
}
#[inline(always)]

View File

@ -82,9 +82,10 @@ impl Boid for Boid3D {
#[inline(always)]
fn apply_force(&mut self, force: Vec3) {
self.vel += force;
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);
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));
}
#[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,
}
}