Skip to content

[Bug] Bug in terminal on first particle spawn #494

Description

@ShroomySquid

Hey, new to Godot Rapier.

My project gets a set of error on the terminal whenever I spawn particles for the first time. I'm using a Fluid2D node with surface tension and viscosity. The bug trigger as soon as I click the "Spawn" btn which triggers the add_points_and_velocities(points_new, velocities_new) for the first time.

The bug is solely on the terminal. It doesn't impact the game in any ways.

Godot 4.6.1. Bug is present both on Ubuntu 22 and Windows 11.

The errors go like this:

ERROR: [panic /home/runner/.cargo/git/checkouts/salva-c88c9745d16e1d12/3c0a04b/build/salva2d/../../src/solver/surface_tension/wcsph_surface_tension.rs:75] index out of bounds: the len is 0 but the index is 0
at: godot_core::private::set_gdext_hook::{{closure}} (/home/runner/.cargo/git/checkouts/gdext-0d37dbac4138f9c2/3ae4d55/godot-core/src/private.rs:343)
ERROR: [panic /home/runner/.cargo/git/checkouts/salva-c88c9745d16e1d12/3c0a04b/build/salva2d/../../src/solver/surface_tension/wcsph_surface_tension.rs:75] index out of bounds: the len is 0 but the index is 0
ERROR: [panic /home/runner/.cargo/git/checkouts/salva-c88c9745d16e1d12/3c0a04b/build/salva2d/../../src/solver/surface_tension/wcsph_surface_tension.rs:75] index out of bounds: the len is 0 but the index is 0
at: godot_core::private::set_gdext_hook::{{closure}} (/home/runner/.cargo/git/checkouts/gdext-0d37dbac4138f9c2/3ae4d55/godot-core/src/private.rs:343)
at: godot_core::private::set_gdext_hook::{{closure}} (/home/runner/.cargo/git/checkouts/gdext-0d37dbac4138f9c2/3ae4d55/godot-core/src/private.rs:343)

Here's the script of my Fluid2D node:

extends Fluid2D

@export var interval := 0.06
@export var max_particles: int = 1000
@export var width: int = 1
https://github.com/onready var bouton := %BeerButton
var time_last_spawn := 0.0

var points_new: PackedVector2Array
var velocities_new: PackedVector2Array

func _ready():
points_new = create_circle_points(width)
velocities_new.resize(points_new.size())
var gravity_value = ProjectSettings.get("physics/2d/default_gravity")
var gravity_dir = ProjectSettings.get("physics/2d/default_gravity_vector")
var dir = global_transform.basis_xform(gravity_dir * gravity_value * 0)
velocities_new.fill(dir)

func _process(delta):
time_last_spawn += delta
if interval > time_last_spawn:
return
time_last_spawn = 0
if len(points) > max_particles or !bouton.is_hovered():
return
add_points_and_velocities(points_new, velocities_new)

Can anyone help with this issue?

barman-simulator.zip

Example project(zip)

Please attach a zip with project where issue occurs. Remove the addons folder so that the size is less than 25 mb.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions