-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
444 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class_name Fluid2DRenderer | ||
extends MultiMeshInstance2D | ||
|
||
@onready var fluid :Fluid2D = get_parent() | ||
|
||
func _process(delta): | ||
var index = 0 | ||
multimesh.instance_count = fluid.points.size() | ||
for point in fluid.points: | ||
var new_transform: Transform2D = Transform2D() | ||
new_transform.origin = point - position | ||
multimesh.set_instance_transform_2d(index, new_transform) | ||
index += 1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[remap] | ||
|
||
importer="texture" | ||
type="CompressedTexture2D" | ||
uid="uid://bjnvmmcdjgbu6" | ||
path="res://.godot/imported/Node2D.svg-839688c6fcfc535aaba08e1eeebc9ec8.ctex" | ||
metadata={ | ||
"vram_texture": false | ||
} | ||
|
||
[deps] | ||
|
||
source_file="res://addons/godot-rapier2d/Node2D.svg" | ||
dest_files=["res://.godot/imported/Node2D.svg-839688c6fcfc535aaba08e1eeebc9ec8.ctex"] | ||
|
||
[params] | ||
|
||
compress/mode=0 | ||
compress/high_quality=false | ||
compress/lossy_quality=0.7 | ||
compress/hdr_compression=1 | ||
compress/normal_map=0 | ||
compress/channel_pack=0 | ||
mipmaps/generate=false | ||
mipmaps/limit=-1 | ||
roughness/mode=0 | ||
roughness/src_normal="" | ||
process/fix_alpha_border=true | ||
process/premult_alpha=false | ||
process/normal_map_invert_y=false | ||
process/hdr_as_srgb=false | ||
process/hdr_clamp_exposure=false | ||
process/size_limit=0 | ||
detect_3d/compress_to=1 | ||
svg/scale=1.0 | ||
editor/scale_with_editor_scale=false | ||
editor/convert_colors_with_editor_theme=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[gd_resource type="MultiMesh" load_steps=2 format=3 uid="uid://d0bhettx43xt1"] | ||
|
||
[sub_resource type="ArrayMesh" id="ArrayMesh_gi4ki"] | ||
_surfaces = [{ | ||
"2d": true, | ||
"aabb": AABB(-16, -16, 0, 32, 32, 0), | ||
"attribute_data": PackedByteArray(0, 0, 128, 63, 154, 153, 129, 62, 0, 0, 128, 63, 0, 0, 112, 63, 102, 102, 118, 63, 0, 0, 112, 63, 205, 204, 76, 63, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 168, 62, 0, 0, 0, 61, 102, 102, 166, 61, 0, 0, 0, 61, 0, 0, 0, 0, 51, 51, 59, 63, 0, 0, 0, 0), | ||
"format": 34393296913, | ||
"index_count": 21, | ||
"index_data": PackedByteArray(8, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 4, 0, 5, 0, 6, 0, 6, 0, 7, 0, 8, 0, 8, 0, 1, 0, 2, 0, 2, 0, 4, 0, 6, 0, 6, 0, 8, 0, 2, 0), | ||
"primitive": 3, | ||
"uv_scale": Vector4(0, 0, 0, 0), | ||
"vertex_count": 9, | ||
"vertex_data": PackedByteArray(0, 0, 128, 65, 204, 204, 252, 192, 0, 0, 128, 65, 0, 0, 96, 65, 204, 204, 108, 65, 0, 0, 96, 65, 154, 153, 25, 65, 0, 0, 128, 65, 0, 0, 128, 193, 0, 0, 128, 65, 0, 0, 128, 193, 0, 0, 176, 192, 0, 0, 112, 193, 102, 102, 86, 193, 0, 0, 112, 193, 0, 0, 128, 193, 204, 204, 236, 64, 0, 0, 128, 193) | ||
}] | ||
|
||
[resource] | ||
mesh = SubResource("ArrayMesh_gi4ki") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
; Engine configuration file. | ||
; It's best edited using the editor UI and not directly, | ||
; since the parameters that go here are not all obvious. | ||
; | ||
; Format: | ||
; [section] ; section goes between [] | ||
; param=value ; assign values to parameters | ||
|
||
config_version=5 | ||
|
||
[application] | ||
|
||
config/name="Godot Physics Tests" | ||
config/features=PackedStringArray("4.2", "Forward Plus") | ||
|
||
[display] | ||
|
||
window/size/viewport_width=1920 | ||
window/size/viewport_height=1080 | ||
|
||
[physics] | ||
|
||
2d/physics_engine="Rapier2D" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Normalize EOL for all files that Git considers text files. | ||
* text=auto eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Godot 4+ specific ignores | ||
.godot/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
extends Node2D | ||
|
||
@export var fluid :Fluid2D | ||
|
||
var points: PackedVector2Array | ||
var velocities: PackedVector2Array | ||
|
||
func _ready(): | ||
points = fluid.points | ||
velocities.resize(points.size()) | ||
velocities.fill(Vector2(0, 980)) | ||
|
||
func _on_timer_timeout(): | ||
if len(fluid.points) > 2000: | ||
return | ||
fluid.set_points_and_velocities(fluid.points+points, fluid.velocities+velocities) | ||
print(len(fluid.points)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
[gd_scene load_steps=18 format=3 uid="uid://dudno1v5vtvh"] | ||
|
||
[ext_resource type="Script" path="res://samples/godot-rapier2d/Faucet.gd" id="1_omq0c"] | ||
[ext_resource type="Script" path="res://addons/godot-rapier2d/Fluid2DRectangle.gd" id="2_x6a0h"] | ||
[ext_resource type="MultiMesh" uid="uid://d0bhettx43xt1" path="res://addons/godot-rapier2d/fluid_multi_mesh.tres" id="3_880wm"] | ||
[ext_resource type="Texture2D" uid="uid://bjnvmmcdjgbu6" path="res://addons/godot-rapier2d/Node2D.svg" id="4_xdgjh"] | ||
[ext_resource type="Script" path="res://addons/godot-rapier2d/Fluid2DRenderer.gd" id="5_2rahx"] | ||
|
||
[sub_resource type="FluidEffect2DViscosityXSPH" id="FluidEffect2DViscosityXSPH_y3smb"] | ||
fluid_viscosity_coefficient = 0.3 | ||
|
||
[sub_resource type="FluidEffect2DSurfaceTensionAKINCI" id="FluidEffect2DSurfaceTensionAKINCI_amypy"] | ||
fluid_tension_coefficient = 10.0 | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8y86f"] | ||
size = Vector2(2676, 1041) | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xuw7n"] | ||
size = Vector2(1749, 1004) | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c23gn"] | ||
size = Vector2(1177, 182.5) | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_sd5wa"] | ||
size = Vector2(521.5, 914.5) | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_os3ki"] | ||
size = Vector2(1521, 2437.5) | ||
|
||
[sub_resource type="CircleShape2D" id="CircleShape2D_mdcyi"] | ||
radius = 72.06 | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_4bdhm"] | ||
size = Vector2(286, 678) | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_vhhvt"] | ||
size = Vector2(858, 333) | ||
|
||
[sub_resource type="CircleShape2D" id="CircleShape2D_k12t3"] | ||
|
||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_q8nq7"] | ||
size = Vector2(44, 303) | ||
|
||
[node name="Node2D" type="Node2D"] | ||
|
||
[node name="Faucet" type="Node2D" parent="." node_paths=PackedStringArray("fluid")] | ||
position = Vector2(1468, 993) | ||
script = ExtResource("1_omq0c") | ||
fluid = NodePath("../Fluid2D") | ||
|
||
[node name="Timer" type="Timer" parent="Faucet"] | ||
process_callback = 0 | ||
wait_time = 0.05 | ||
autostart = true | ||
|
||
[node name="Fluid2D" type="Fluid2D" parent="."] | ||
accelerations = PackedVector2Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | ||
velocities = PackedVector2Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) | ||
points = PackedVector2Array(0, 0, 40, 0, 80, 0, 120, 0, 160, 0, 0, 40, 40, 40, 80, 40, 120, 40, 160, 40) | ||
density = 200.0 | ||
effects = Array[FluidEffect2D]([SubResource("FluidEffect2DViscosityXSPH_y3smb"), SubResource("FluidEffect2DSurfaceTensionAKINCI_amypy")]) | ||
debug_draw = false | ||
modulate = Color(0.654902, 0.768627, 1, 1) | ||
position = Vector2(1480, 680) | ||
script = ExtResource("2_x6a0h") | ||
height = 2 | ||
width = 5 | ||
|
||
[node name="Fluid2DRenderer" type="MultiMeshInstance2D" parent="Fluid2D"] | ||
modulate = Color(0.380392, 0.576471, 1, 1) | ||
position = Vector2(-220, -59) | ||
multimesh = ExtResource("3_880wm") | ||
texture = ExtResource("4_xdgjh") | ||
script = ExtResource("5_2rahx") | ||
|
||
[node name="StaticBody2D" type="StaticBody2D" parent="."] | ||
position = Vector2(126, 282) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(-3554, 1698) | ||
shape = SubResource("RectangleShape2D_8y86f") | ||
|
||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(-1170, 2352) | ||
shape = SubResource("RectangleShape2D_8y86f") | ||
|
||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(-245, 2430) | ||
shape = SubResource("RectangleShape2D_xuw7n") | ||
|
||
[node name="CollisionShape2D8" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(-1114, 1509) | ||
shape = SubResource("RectangleShape2D_xuw7n") | ||
|
||
[node name="CollisionShape2D9" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(282, 1097.75) | ||
shape = SubResource("RectangleShape2D_c23gn") | ||
|
||
[node name="CollisionShape2D10" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(282, 1411) | ||
shape = SubResource("RectangleShape2D_c23gn") | ||
|
||
[node name="CollisionShape2D11" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(869, 2149) | ||
rotation = 0.563727 | ||
shape = SubResource("RectangleShape2D_c23gn") | ||
|
||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(1824, 2579) | ||
shape = SubResource("RectangleShape2D_8y86f") | ||
|
||
[node name="CollisionShape2D5" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(2171.25, 1708.25) | ||
shape = SubResource("RectangleShape2D_sd5wa") | ||
|
||
[node name="CollisionShape2D7" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(3748.5, 1752.75) | ||
shape = SubResource("RectangleShape2D_os3ki") | ||
|
||
[node name="CollisionShape2D6" type="CollisionShape2D" parent="StaticBody2D"] | ||
position = Vector2(1405, 1225) | ||
shape = SubResource("CircleShape2D_mdcyi") | ||
|
||
[node name="Camera2D" type="Camera2D" parent="."] | ||
position = Vector2(1586, 1637) | ||
zoom = Vector2(0.5, 0.5) | ||
|
||
[node name="StaticBody2D2" type="StaticBody2D" parent="."] | ||
position = Vector2(1574, 643) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D2"] | ||
position = Vector2(-333, -38) | ||
shape = SubResource("RectangleShape2D_4bdhm") | ||
|
||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="StaticBody2D2"] | ||
position = Vector2(-45, -277) | ||
shape = SubResource("RectangleShape2D_vhhvt") | ||
|
||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="StaticBody2D2"] | ||
position = Vector2(225, -65) | ||
shape = SubResource("RectangleShape2D_4bdhm") | ||
|
||
[node name="Label" type="Label" parent="."] | ||
offset_left = 1316.0 | ||
offset_top = 987.0 | ||
offset_right = 1903.0 | ||
offset_bottom = 1042.0 | ||
theme_override_font_sizes/font_size = 80 | ||
text = "Rapier2D Fluid using Salva2D" | ||
|
||
[node name="StaticBody2D3" type="StaticBody2D" parent="."] | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D3"] | ||
position = Vector2(1380, 1879) | ||
shape = SubResource("CircleShape2D_k12t3") | ||
|
||
[node name="PinJoint2D" type="PinJoint2D" parent="."] | ||
position = Vector2(1384, 1875) | ||
node_a = NodePath("../StaticBody2D3") | ||
node_b = NodePath("../RigidBody2D") | ||
motor_enabled = true | ||
motor_target_velocity = 872.665 | ||
|
||
[node name="RigidBody2D" type="RigidBody2D" parent="."] | ||
position = Vector2(1363, 1874) | ||
mass = 200.0 | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"] | ||
position = Vector2(12, 141.5) | ||
shape = SubResource("RectangleShape2D_q8nq7") | ||
|
||
[connection signal="timeout" from="Faucet/Timer" to="Faucet" method="_on_timer_timeout"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.