add wind_slider and change wind_amount particles base on wind_stranght #1
@@ -48,6 +48,7 @@ var thereare_fireflies: bool = false
|
||||
var current_wind_speed: float = 0.0
|
||||
var current_wind_strength: float = 0.0
|
||||
var current_wind_fade: float = 0.0
|
||||
var max_wind_amount: int = 0
|
||||
|
||||
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
|
||||
@@ -65,6 +66,7 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
environment_shadows = envshadows
|
||||
environment = theenvironment
|
||||
environment_config = environmentconfig
|
||||
max_wind_amount = environment_config.wind_amount if environment_config != null else 0
|
||||
camera = thecamera
|
||||
camera_pivot = thecamerapivot
|
||||
thunder_sounds = thundersounds
|
||||
@@ -308,6 +310,7 @@ func toggle_wind(value: bool):
|
||||
|
||||
#disable wind and set default values and materials
|
||||
func init_wind():
|
||||
_update_wind_amount_from_strength(environment_config.wind_strength)
|
||||
if particles_wind:
|
||||
particles_wind.visible = true
|
||||
particles_wind.emitting = false
|
||||
@@ -388,8 +391,24 @@ func change_wind_strength(value: float) -> void:
|
||||
return
|
||||
|
||||
environment_config.wind_strength = value
|
||||
_update_wind_amount_from_strength(value)
|
||||
if is_windy or current_wind_fade > 0.0:
|
||||
_set_current_wind_strength(value)
|
||||
if particles_wind:
|
||||
particles_wind.amount = environment_config.wind_amount
|
||||
|
||||
func _update_wind_amount_from_strength(value: float) -> void:
|
||||
if environment_config == null:
|
||||
return
|
||||
if max_wind_amount <= 0:
|
||||
max_wind_amount = max(environment_config.wind_amount, 1)
|
||||
|
||||
var normalized_strength: float = clamp(value, 0.0, 1.0)
|
||||
var amount_ratio: float = normalized_strength
|
||||
if normalized_strength > 0.0 and normalized_strength < 0.3:
|
||||
amount_ratio = lerp(0.08, 0.25, normalized_strength / 0.3)
|
||||
|
||||
environment_config.wind_amount = roundi(max_wind_amount * amount_ratio)
|
||||
|
||||
func _apply_cloud_config() -> void:
|
||||
var dir = environment_config.wind_direction
|
||||
|
||||
Reference in New Issue
Block a user