Compare commits
No commits in common. "main" and "v0.1.1" have entirely different histories.
@ -9,10 +9,10 @@ it can handle about 2000 boids in a single flock at 11ms physics process tick on
|
|||||||
|
|
||||||
## usage
|
## 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.
|
or clone the repository (git lfs is needed) and copy over the `addons` folder into your project root.
|
||||||
(requires [cross](https://github.com/cross-rs/cross))
|
check the examples for more info.
|
||||||
|
|
||||||
## development
|
## development
|
||||||
|
|
||||||
|
1
rust/.gitignore
vendored
1
rust/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/.vscode
|
|
@ -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
|
|
@ -1,15 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -x
|
|
||||||
|
|
||||||
cross build --release --target x86_64-unknown-linux-gnu
|
cross build --release --target x86_64-unknown-linux-gnu
|
||||||
cross build --release --target x86_64-pc-windows-gnu
|
cross build --release --target x86_64-pc-windows-gnu
|
||||||
cross +nightly build -Zbuild-std --release --target wasm32-unknown-emscripten
|
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
|
zip -r ../../boids-release.zip ../addons ../examples ../README.md ../LICENSE.txt
|
||||||
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
|
|
||||||
|
@ -83,9 +83,9 @@ impl Boid for Boid2D {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn apply_force(&mut self, force: Vec3) {
|
fn apply_force(&mut self, force: Vec3) {
|
||||||
self.vel += force.xy();
|
self.vel += force.xy();
|
||||||
self.vel = self.vel.clamp_length_max(self.props.max_speed);
|
let new_vel = self.vel.clamp_length_max(self.props.max_speed);
|
||||||
let force_to_apply = Vector2::new(self.vel.x, self.vel.y);
|
self.vel = new_vel;
|
||||||
self.base_mut().translate(force_to_apply);
|
self.base_mut().translate(Vector2::new(new_vel.x, new_vel.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -82,9 +82,10 @@ impl Boid for Boid3D {
|
|||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn apply_force(&mut self, force: Vec3) {
|
fn apply_force(&mut self, force: Vec3) {
|
||||||
self.vel += force;
|
self.vel += force;
|
||||||
self.vel = self.vel.clamp_length_max(self.props.max_speed);
|
let new_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.vel = new_vel;
|
||||||
self.base_mut().translate(force_to_apply);
|
self.base_mut()
|
||||||
|
.translate(Vector3::new(new_vel.x, new_vel.y, new_vel.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
Loading…
Reference in New Issue
Block a user