This repository has been archived on 2025-09-28. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
rectangular/addons/godot-rapier2d/fluid_2d_renderer.gd

30 lines
835 B
GDScript3
Raw Permalink Normal View History

2024-09-25 21:18:58 +02:00
@tool
class_name Fluid2DRenderer
extends MultiMeshInstance2D
@export var fluid: Fluid2D
@export var color: Color = Color(0.8, 0.8, 0.8, 0.3)
func _ready():
if multimesh == null:
multimesh = MultiMesh.new()
multimesh.mesh = load("res://addons/godot-rapier2d/circle_mesh.tres").duplicate()
multimesh.use_colors = true
if texture == null:
texture = load("res://addons/godot-rapier2d/Radial2D.svg")
func _process(_delta):
if fluid == null:
return
global_transform = fluid.global_transform
var index = 0
multimesh.instance_count = fluid.points.size()
var points = fluid.points
for i in points.size():
var point = points[i]
var new_transform: Transform2D = Transform2D(0, Vector2(5, 5), 0, point)
multimesh.set_instance_transform_2d(index, new_transform)
multimesh.set_instance_color(index, color)
index += 1