From 99c1248d9c10f9eb7456f34c4c40f790bcb463cc Mon Sep 17 00:00:00 2001 From: dusk Date: Fri, 6 Dec 2024 22:29:26 +0300 Subject: [PATCH] feat: add default properties for 2d and 3d --- README.md | 7 ++++++- addons/boids/defaults/2d_boid_properties.tres | 5 +++++ addons/boids/defaults/2d_flock_properties.tres | 3 +++ addons/boids/defaults/3d_boid_properties.tres | 5 +++++ addons/boids/defaults/3d_flock_properties.tres | 6 ++++++ examples/boids/2d/simple/example.tscn | 5 ++--- examples/boids/3d/simple/example.tscn | 8 ++------ 7 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 addons/boids/defaults/2d_boid_properties.tres create mode 100644 addons/boids/defaults/2d_flock_properties.tres create mode 100644 addons/boids/defaults/3d_boid_properties.tres create mode 100644 addons/boids/defaults/3d_flock_properties.tres diff --git a/README.md b/README.md index 6d0ae66..26cfe9e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ addon for Godot that adds 2D / 3D boids (flocking). it can handle about 2000 boids in a single flock at 11ms physics process tick on my PC (Ryzen 5600). (keep in mind this is without any partitioning of sorts, so it's bound to get better) -## usage +## install download it from the [asset library](https://godotengine.org/asset-library/asset/3284). @@ -16,6 +16,11 @@ or clone the repository, and run `just all` to build the libraries (in release m currently, linux, windows and web (wasm) is supported. +## usage + +take a look at the [examples](./examples/boids/). +the addon folder also contains [a set of default properties extracted from the examples](./addons/boids/defaults/). + ## development it's just a standard rust project under `rust`, so make sure you have `rustup` installed (or the toolchain specified under `rust-toolchain.toml`.) diff --git a/addons/boids/defaults/2d_boid_properties.tres b/addons/boids/defaults/2d_boid_properties.tres new file mode 100644 index 0000000..f6affa0 --- /dev/null +++ b/addons/boids/defaults/2d_boid_properties.tres @@ -0,0 +1,5 @@ +[gd_resource type="BoidProperties" format=3 uid="uid://be12p6dxpuvg5"] + +[resource] +alignment = 1.0 +cohesion = 0.8 diff --git a/addons/boids/defaults/2d_flock_properties.tres b/addons/boids/defaults/2d_flock_properties.tres new file mode 100644 index 0000000..0fa4837 --- /dev/null +++ b/addons/boids/defaults/2d_flock_properties.tres @@ -0,0 +1,3 @@ +[gd_resource type="FlockProperties" format=3 uid="uid://6iwscl4up3tg"] + +[resource] diff --git a/addons/boids/defaults/3d_boid_properties.tres b/addons/boids/defaults/3d_boid_properties.tres new file mode 100644 index 0000000..6438d7d --- /dev/null +++ b/addons/boids/defaults/3d_boid_properties.tres @@ -0,0 +1,5 @@ +[gd_resource type="BoidProperties" format=3 uid="uid://bnlws4wqnydj0"] + +[resource] +max_speed = 0.2 +max_force = 0.04 diff --git a/addons/boids/defaults/3d_flock_properties.tres b/addons/boids/defaults/3d_flock_properties.tres new file mode 100644 index 0000000..c8476e2 --- /dev/null +++ b/addons/boids/defaults/3d_flock_properties.tres @@ -0,0 +1,6 @@ +[gd_resource type="FlockProperties" format=3 uid="uid://cr1ysckawaeow"] + +[resource] +goal_seperation = 4.0 +goal_alignment = 16.0 +goal_cohesion = 16.0 diff --git a/examples/boids/2d/simple/example.tscn b/examples/boids/2d/simple/example.tscn index 7ded31d..18648af 100644 --- a/examples/boids/2d/simple/example.tscn +++ b/examples/boids/2d/simple/example.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://op0qicvpbjt6"] [ext_resource type="Script" path="res://examples/boids/2d/simple/example.gd" id="1_3gcrf"] +[ext_resource type="FlockProperties" uid="uid://6iwscl4up3tg" path="res://addons/boids/defaults/2d_flock_properties.tres" id="2_2xgek"] [sub_resource type="Environment" id="Environment_jxsqf"] background_mode = 3 @@ -8,8 +9,6 @@ glow_enabled = true glow_bloom = 0.2 glow_blend_mode = 1 -[sub_resource type="FlockProperties" id="FlockProperties_cvyp0"] - [node name="Example" type="Node2D"] script = ExtResource("1_3gcrf") @@ -17,7 +16,7 @@ script = ExtResource("1_3gcrf") environment = SubResource("Environment_jxsqf") [node name="Flock" type="Flock2D" parent="."] -properties = SubResource("FlockProperties_cvyp0") +properties = ExtResource("2_2xgek") [node name="Camera2D" type="Camera2D" parent="."] position = Vector2(576, 324) diff --git a/examples/boids/3d/simple/example.tscn b/examples/boids/3d/simple/example.tscn index 1fb73d7..c6b15f1 100644 --- a/examples/boids/3d/simple/example.tscn +++ b/examples/boids/3d/simple/example.tscn @@ -1,6 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://dmjob0jc7a2qr"] [ext_resource type="Script" path="res://examples/boids/3d/simple/example.gd" id="1_um23s"] +[ext_resource type="FlockProperties" uid="uid://cr1ysckawaeow" path="res://addons/boids/defaults/3d_flock_properties.tres" id="2_fviqq"] [sub_resource type="Environment" id="Environment_aypca"] ambient_light_source = 2 @@ -9,11 +10,6 @@ glow_enabled = true glow_bloom = 0.1 glow_blend_mode = 1 -[sub_resource type="FlockProperties" id="FlockProperties_1d3ec"] -goal_seperation = 4.0 -goal_alignment = 16.0 -goal_cohesion = 16.0 - [node name="Example" type="Node3D"] script = ExtResource("1_um23s") @@ -21,7 +17,7 @@ script = ExtResource("1_um23s") environment = SubResource("Environment_aypca") [node name="Flock3D" type="Flock3D" parent="." node_paths=PackedStringArray("target")] -properties = SubResource("FlockProperties_1d3ec") +properties = ExtResource("2_fviqq") target = NodePath("../Marker3D") [node name="Camera3D" type="Camera3D" parent="."]