Compare commits
2 Commits
0f67d318df
...
29ddd128c6
Author | SHA1 | Date | |
---|---|---|---|
29ddd128c6 | |||
514e80c1a0 |
@ -2,7 +2,7 @@ extends Node2D
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
for flock in get_children():
|
for flock in get_children():
|
||||||
for i in 100: spawnBoid(flock)
|
for i in 1000: spawnBoid(flock)
|
||||||
|
|
||||||
func spawnBoid(flock: Flock2D) -> void:
|
func spawnBoid(flock: Flock2D) -> void:
|
||||||
var boid: Boid2D = preload("../example_boid.tscn").instantiate()
|
var boid: Boid2D = preload("../example_boid.tscn").instantiate()
|
||||||
|
16
rust/Cargo.lock
generated
16
rust/Cargo.lock
generated
@ -164,6 +164,7 @@ version = "0.1.3"
|
|||||||
source = "git+https://github.com/godot-rust/gdext?branch=master#7634fe769d1fcb66209586f0b6c06aac40978253"
|
source = "git+https://github.com/godot-rust/gdext?branch=master#7634fe769d1fcb66209586f0b6c06aac40978253"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"godot-bindings",
|
"godot-bindings",
|
||||||
|
"markdown",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"venial",
|
"venial",
|
||||||
@ -197,6 +198,15 @@ version = "0.2.158"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "markdown"
|
||||||
|
version = "1.0.0-alpha.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "911a8325e6fb87b89890cd4529a2ab34c2669c026279e61c26b7140a3d821ccb"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-id",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.4"
|
version = "2.7.4"
|
||||||
@ -308,6 +318,12 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-id"
|
||||||
|
version = "0.3.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.12"
|
version = "1.0.12"
|
||||||
|
@ -10,7 +10,7 @@ crate-type = ["cdylib"]
|
|||||||
stats = []
|
stats = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
godot = { git = "https://github.com/godot-rust/gdext", branch = "master", features = ["api-4-3", "experimental-threads"] }
|
godot = { git = "https://github.com/godot-rust/gdext", branch = "master", features = ["api-4-3", "experimental-threads", "register-docs"] }
|
||||||
glam = { version = "0.28", features = ["fast-math"] }
|
glam = { version = "0.28", features = ["fast-math"] }
|
||||||
rayon = { version = "1.10" }
|
rayon = { version = "1.10" }
|
||||||
rustc-hash = "2"
|
rustc-hash = "2"
|
||||||
|
@ -5,6 +5,8 @@ use crate::{BoidProperties, Flock2D};
|
|||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(init, base=Node2D)]
|
#[class(init, base=Node2D)]
|
||||||
|
/// A 2D boid.
|
||||||
|
/// Doesn't do anything on it's own, must be a child of a `Flock2D`.
|
||||||
pub struct Boid2D {
|
pub struct Boid2D {
|
||||||
#[export]
|
#[export]
|
||||||
/// The properties of this boid.
|
/// The properties of this boid.
|
||||||
|
@ -5,6 +5,8 @@ use crate::{to_glam_vec, BoidProperties, Flock3D};
|
|||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(init, base=Node3D)]
|
#[class(init, base=Node3D)]
|
||||||
|
/// A 3D boid.
|
||||||
|
/// Doesn't do anything on it's own, must be a child of a `Flock3D`.
|
||||||
pub struct Boid3D {
|
pub struct Boid3D {
|
||||||
#[export]
|
#[export]
|
||||||
/// The properties of this boid.
|
/// The properties of this boid.
|
||||||
|
@ -2,6 +2,7 @@ use godot::prelude::*;
|
|||||||
|
|
||||||
#[derive(Default, Clone, Debug, GodotClass)]
|
#[derive(Default, Clone, Debug, GodotClass)]
|
||||||
#[class(tool, init, base=Resource)]
|
#[class(tool, init, base=Resource)]
|
||||||
|
/// Properties for a 2D/3D boid.
|
||||||
pub struct BoidProperties {
|
pub struct BoidProperties {
|
||||||
#[export]
|
#[export]
|
||||||
#[init(val = 4.0)]
|
#[init(val = 4.0)]
|
||||||
|
@ -7,6 +7,8 @@ use super::Flock;
|
|||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(init, base=Node2D)]
|
#[class(init, base=Node2D)]
|
||||||
|
/// A flock that holds 2D boids.
|
||||||
|
/// Adding `Boid2D` as a child of this node will register the boid.
|
||||||
pub struct Flock2D {
|
pub struct Flock2D {
|
||||||
#[export]
|
#[export]
|
||||||
/// Properties of this flock.
|
/// Properties of this flock.
|
||||||
@ -58,6 +60,7 @@ impl INode2D for Flock2D {
|
|||||||
impl Flock2D {
|
impl Flock2D {
|
||||||
#[func]
|
#[func]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
/// Retrieve the ID of this flock.
|
||||||
pub fn get_id(&self) -> i64 {
|
pub fn get_id(&self) -> i64 {
|
||||||
self.base().instance_id().to_i64()
|
self.base().instance_id().to_i64()
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ use super::Flock;
|
|||||||
|
|
||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(init, base=Node3D)]
|
#[class(init, base=Node3D)]
|
||||||
|
/// A flock that holds 3D boids.
|
||||||
|
/// Adding `Boid3D` as a child of this node will register the boid.
|
||||||
pub struct Flock3D {
|
pub struct Flock3D {
|
||||||
#[export]
|
#[export]
|
||||||
/// Properties of this flock.
|
/// Properties of this flock.
|
||||||
@ -60,6 +62,7 @@ impl INode3D for Flock3D {
|
|||||||
impl Flock3D {
|
impl Flock3D {
|
||||||
#[func]
|
#[func]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
/// Retrieve the ID of this flock.
|
||||||
pub fn get_id(&self) -> i64 {
|
pub fn get_id(&self) -> i64 {
|
||||||
self.base().instance_id().to_i64()
|
self.base().instance_id().to_i64()
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ use godot::prelude::*;
|
|||||||
|
|
||||||
#[derive(Default, Clone, Debug, GodotClass)]
|
#[derive(Default, Clone, Debug, GodotClass)]
|
||||||
#[class(tool, init, base=Resource)]
|
#[class(tool, init, base=Resource)]
|
||||||
|
/// Properties for a 2D/3D flock.
|
||||||
pub struct FlockProperties {
|
pub struct FlockProperties {
|
||||||
#[export]
|
#[export]
|
||||||
#[init(val = 625.0)]
|
#[init(val = 625.0)]
|
||||||
|
@ -74,7 +74,7 @@ unsafe impl ExtensionLibrary for BoidsExtension {
|
|||||||
#[derive(GodotClass)]
|
#[derive(GodotClass)]
|
||||||
#[class(init, base=Node)]
|
#[class(init, base=Node)]
|
||||||
/// Node that will make calls automatically to process 2D/3D boids, providing some configuration options.
|
/// Node that will make calls automatically to process 2D/3D boids, providing some configuration options.
|
||||||
/// It's best to use this as an autoload singleton.
|
/// It's best to use this as an autoload singleton. The plugin will register an autoload by default so you don't have to set this up yourself.
|
||||||
pub struct BoidsProcess {
|
pub struct BoidsProcess {
|
||||||
#[export]
|
#[export]
|
||||||
#[init(val = true)]
|
#[init(val = true)]
|
||||||
|
Loading…
Reference in New Issue
Block a user