From ff153b25eb3fcd7dc04b332dc574ba383b14ed19 Mon Sep 17 00:00:00 2001 From: ryanontheinstide Date: Wed, 28 Aug 2024 17:00:40 -0400 Subject: [PATCH] added emission radius --- node_configs.py | 2 ++ nodes/masks/mask_base.py | 16 +++++++++++++++- nodes/masks/particle_system_masks.py | 6 ++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/node_configs.py b/node_configs.py index 11644e8..0a913ec 100644 --- a/node_configs.py +++ b/node_configs.py @@ -287,6 +287,7 @@ add_node_config("ParticleModulationBase", { - `effect_duration`: Duration of the modulation effect in frames (0 to 1000) - `temporal_easing`: Easing function for the modulation effect ("ease_in_out", "linear", "bounce", "elastic", "none") - `palindrome`: Whether to reverse the modulation effect after completion (True/False) +- `random`: Selects a random value between 0 and the chosen target value and applies it per particle """ }) @@ -560,6 +561,7 @@ add_node_config("ParticleEmitter", { - `initial_plume`: Initial burst of particles (0.0 to 1.0) - `start_frame`: Frame to start the emission (0 to 10000) - `end_frame`: Frame to end the emission (0 to 10000) +- `emission_radius`: Defaulting to 0 (a point), this value changes the radius of the area from which the particles are emitted. The open 'mouth' of the emitter. Optional inputs: - `emitter_movement`: Movement settings for the emitter (EMITTER_MOVEMENT type) diff --git a/nodes/masks/mask_base.py b/nodes/masks/mask_base.py index b210f0b..07ea674 100644 --- a/nodes/masks/mask_base.py +++ b/nodes/masks/mask_base.py @@ -701,11 +701,25 @@ class ParticleSystemMaskBase(MaskBase, ABC): return ccw(p1,p3,p4) != ccw(p2,p3,p4) and ccw(p1,p2,p3) != ccw(p1,p2,p4) def emit_particle(self, emitter, height, width, emitter_index, frame_index): - emitter_pos = (float(emitter['emitter_x']) * width, float(emitter['emitter_y']) * height) + emitter_x = float(emitter['emitter_x']) * width + emitter_y = float(emitter['emitter_y']) * height particle_direction = math.radians(float(emitter['particle_direction'])) particle_spread = math.radians(float(emitter['particle_spread'])) particle_speed = float(emitter['particle_speed']) particle_size = float(emitter['particle_size']) + + emission_radius = float(emitter.get('emission_radius', 0)) # Default to 0 if not specified + + # Generate a random point within the circular emission area + if emission_radius > 0: + r = random.uniform(0, emission_radius) + theta = random.uniform(0, 2 * math.pi) + emitter_pos = ( + emitter_x + r * math.cos(theta), + emitter_y + r * math.sin(theta) + ) + else: + emitter_pos = (emitter_x, emitter_y) angle = random.uniform(particle_direction - particle_spread/2, particle_direction + particle_spread/2) diff --git a/nodes/masks/particle_system_masks.py b/nodes/masks/particle_system_masks.py index 019ad8f..431da84 100644 --- a/nodes/masks/particle_system_masks.py +++ b/nodes/masks/particle_system_masks.py @@ -156,6 +156,7 @@ class ParticleEmitter(ParticleSystemModulatorBase): "initial_plume": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01}), "start_frame": ("INT", {"default": 0, "min": 0, "max": 10000, "step": 1}), "end_frame": ("INT", {"default": 0, "min": 0, "max": 10000, "step": 1}), + "emission_radius": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 100.0, "step": 0.1}), }, "optional": { "previous_emitter": ("PARTICLE_EMITTER",), @@ -170,8 +171,8 @@ class ParticleEmitter(ParticleSystemModulatorBase): def create_emitter(self, emitter_x, emitter_y, particle_direction, particle_spread, particle_size, particle_speed, emission_rate, color, initial_plume, - start_frame, end_frame, previous_emitter=None, emitter_movement=None, - spring_joint_setting=None, particle_modulation=None): + start_frame, end_frame, emission_radius, previous_emitter=None, + emitter_movement=None, spring_joint_setting=None, particle_modulation=None): emitter = { "emitter_x": emitter_x, "emitter_y": emitter_y, @@ -184,6 +185,7 @@ class ParticleEmitter(ParticleSystemModulatorBase): "initial_plume": initial_plume, "start_frame": start_frame, "end_frame": end_frame, + "emission_radius": emission_radius, } if emitter_movement: