You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Validate input in (CPU)Particles set_emission_shape()
Fixes #29777. Co-authored-by: Cameron Reikes <cameronreikes@gmail.com>
This commit is contained in:
@@ -367,5 +367,8 @@
|
|||||||
<constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape">
|
<constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape">
|
||||||
Particles will be emitted at a position chosen randomly among [member emission_points]. Particle velocity and rotation will be set based on [member emission_normals]. Particle color will be modulated by [member emission_colors].
|
Particles will be emitted at a position chosen randomly among [member emission_points]. Particle velocity and rotation will be set based on [member emission_normals]. Particle color will be modulated by [member emission_colors].
|
||||||
</constant>
|
</constant>
|
||||||
|
<constant name="EMISSION_SHAPE_MAX" value="5" enum="EmissionShape">
|
||||||
|
Represents the size of the [enum EmissionShape] enum.
|
||||||
|
</constant>
|
||||||
</constants>
|
</constants>
|
||||||
</class>
|
</class>
|
||||||
|
|||||||
@@ -360,5 +360,8 @@
|
|||||||
<constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape">
|
<constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape">
|
||||||
Particles will be emitted at a position chosen randomly among [member emission_points]. Particle velocity and rotation will be set based on [member emission_normals]. Particle color will be modulated by [member emission_colors].
|
Particles will be emitted at a position chosen randomly among [member emission_points]. Particle velocity and rotation will be set based on [member emission_normals]. Particle color will be modulated by [member emission_colors].
|
||||||
</constant>
|
</constant>
|
||||||
|
<constant name="EMISSION_SHAPE_MAX" value="5" enum="EmissionShape">
|
||||||
|
Represents the size of the [enum EmissionShape] enum.
|
||||||
|
</constant>
|
||||||
</constants>
|
</constants>
|
||||||
</class>
|
</class>
|
||||||
|
|||||||
@@ -321,5 +321,8 @@
|
|||||||
<constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape">
|
<constant name="EMISSION_SHAPE_DIRECTED_POINTS" value="4" enum="EmissionShape">
|
||||||
Particles will be emitted at a position determined by sampling a random point on the [member emission_point_texture]. Particle velocity and rotation will be set based on [member emission_normal_texture]. Particle color will be modulated by [member emission_color_texture].
|
Particles will be emitted at a position determined by sampling a random point on the [member emission_point_texture]. Particle velocity and rotation will be set based on [member emission_normal_texture]. Particle color will be modulated by [member emission_color_texture].
|
||||||
</constant>
|
</constant>
|
||||||
|
<constant name="EMISSION_SHAPE_MAX" value="5" enum="EmissionShape">
|
||||||
|
Represents the size of the [enum EmissionShape] enum.
|
||||||
|
</constant>
|
||||||
</constants>
|
</constants>
|
||||||
</class>
|
</class>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
</method>
|
</method>
|
||||||
</methods>
|
</methods>
|
||||||
<members>
|
<members>
|
||||||
<member name="bind_ip" type="String" setter="set_bind_ip" getter="get_bind_ip">
|
<member name="bind_ip" type="String" setter="set_bind_ip" getter="get_bind_ip" default=""*"">
|
||||||
When not set to [code]*[/code] will restrict incoming connections to the specified IP address. Setting [code]bind_ip[/code] to [code]127.0.0.1[/code] will cause the server to listen only to the local host.
|
When not set to [code]*[/code] will restrict incoming connections to the specified IP address. Setting [code]bind_ip[/code] to [code]127.0.0.1[/code] will cause the server to listen only to the local host.
|
||||||
</member>
|
</member>
|
||||||
<member name="ca_chain" type="X509Certificate" setter="set_ca_chain" getter="get_ca_chain">
|
<member name="ca_chain" type="X509Certificate" setter="set_ca_chain" getter="get_ca_chain">
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ bool CPUParticles2D::get_particle_flag(Flags p_flag) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CPUParticles2D::set_emission_shape(EmissionShape p_shape) {
|
void CPUParticles2D::set_emission_shape(EmissionShape p_shape) {
|
||||||
|
ERR_FAIL_INDEX(p_shape, EMISSION_SHAPE_MAX);
|
||||||
emission_shape = p_shape;
|
emission_shape = p_shape;
|
||||||
_change_notify();
|
_change_notify();
|
||||||
}
|
}
|
||||||
@@ -772,6 +772,9 @@ void CPUParticles2D::_particles_process(float p_delta) {
|
|||||||
p.base_color = emission_colors.get(random_idx);
|
p.base_color = emission_colors.get(random_idx);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case EMISSION_SHAPE_MAX: { // Max value for validity check.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!local_coords) {
|
if (!local_coords) {
|
||||||
@@ -1416,6 +1419,7 @@ void CPUParticles2D::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_RECTANGLE);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_RECTANGLE);
|
||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
|
||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
|
||||||
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUParticles2D::CPUParticles2D() {
|
CPUParticles2D::CPUParticles2D() {
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public:
|
|||||||
EMISSION_SHAPE_RECTANGLE,
|
EMISSION_SHAPE_RECTANGLE,
|
||||||
EMISSION_SHAPE_POINTS,
|
EMISSION_SHAPE_POINTS,
|
||||||
EMISSION_SHAPE_DIRECTED_POINTS,
|
EMISSION_SHAPE_DIRECTED_POINTS,
|
||||||
|
EMISSION_SHAPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -405,7 +405,7 @@ bool CPUParticles::get_particle_flag(Flags p_flag) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CPUParticles::set_emission_shape(EmissionShape p_shape) {
|
void CPUParticles::set_emission_shape(EmissionShape p_shape) {
|
||||||
|
ERR_FAIL_INDEX(p_shape, EMISSION_SHAPE_MAX);
|
||||||
emission_shape = p_shape;
|
emission_shape = p_shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,6 +784,9 @@ void CPUParticles::_particles_process(float p_delta) {
|
|||||||
p.base_color = emission_colors.get(random_idx);
|
p.base_color = emission_colors.get(random_idx);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case EMISSION_SHAPE_MAX: { // Max value for validity check.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!local_coords) {
|
if (!local_coords) {
|
||||||
@@ -1488,6 +1491,7 @@ void CPUParticles::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
|
||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
|
||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
|
||||||
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUParticles::CPUParticles() {
|
CPUParticles::CPUParticles() {
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public:
|
|||||||
EMISSION_SHAPE_BOX,
|
EMISSION_SHAPE_BOX,
|
||||||
EMISSION_SHAPE_POINTS,
|
EMISSION_SHAPE_POINTS,
|
||||||
EMISSION_SHAPE_DIRECTED_POINTS,
|
EMISSION_SHAPE_DIRECTED_POINTS,
|
||||||
|
EMISSION_SHAPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -198,6 +198,9 @@ void ParticlesMaterial::_update_shader() {
|
|||||||
code += "uniform sampler2D emission_texture_color : hint_white;\n";
|
code += "uniform sampler2D emission_texture_color : hint_white;\n";
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case EMISSION_SHAPE_MAX: { // Max value for validity check.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code += "uniform vec4 color_value : hint_color;\n";
|
code += "uniform vec4 color_value : hint_color;\n";
|
||||||
@@ -283,7 +286,7 @@ void ParticlesMaterial::_update_shader() {
|
|||||||
code += " float degree_to_rad = pi / 180.0;\n";
|
code += " float degree_to_rad = pi / 180.0;\n";
|
||||||
code += "\n";
|
code += "\n";
|
||||||
|
|
||||||
if (emission_shape >= EMISSION_SHAPE_POINTS) {
|
if (emission_shape == EMISSION_SHAPE_POINTS || emission_shape == EMISSION_SHAPE_DIRECTED_POINTS) {
|
||||||
code += " int point = min(emission_texture_point_count - 1, int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n";
|
code += " int point = min(emission_texture_point_count - 1, int(rand_from_seed(alt_seed) * float(emission_texture_point_count)));\n";
|
||||||
code += " ivec2 emission_tex_size = textureSize(emission_texture_points, 0);\n";
|
code += " ivec2 emission_tex_size = textureSize(emission_texture_points, 0);\n";
|
||||||
code += " ivec2 emission_tex_ofs = ivec2(point % emission_tex_size.x, point / emission_tex_size.x);\n";
|
code += " ivec2 emission_tex_ofs = ivec2(point % emission_tex_size.x, point / emission_tex_size.x);\n";
|
||||||
@@ -368,6 +371,9 @@ void ParticlesMaterial::_update_shader() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
case EMISSION_SHAPE_MAX: { // Max value for validity check.
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY, 0.0)).xyz;\n";
|
code += " VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY, 0.0)).xyz;\n";
|
||||||
code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n";
|
code += " TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;\n";
|
||||||
@@ -515,7 +521,7 @@ void ParticlesMaterial::_update_shader() {
|
|||||||
} else {
|
} else {
|
||||||
code += " COLOR = hue_rot_mat * color_value;\n";
|
code += " COLOR = hue_rot_mat * color_value;\n";
|
||||||
}
|
}
|
||||||
if (emission_color_texture.is_valid() && emission_shape >= EMISSION_SHAPE_POINTS) {
|
if (emission_color_texture.is_valid() && (emission_shape == EMISSION_SHAPE_POINTS || emission_shape == EMISSION_SHAPE_DIRECTED_POINTS)) {
|
||||||
code += " COLOR *= texelFetch(emission_texture_color, emission_tex_ofs, 0);\n";
|
code += " COLOR *= texelFetch(emission_texture_color, emission_tex_ofs, 0);\n";
|
||||||
}
|
}
|
||||||
if (trail_color_modifier.is_valid()) {
|
if (trail_color_modifier.is_valid()) {
|
||||||
@@ -894,7 +900,7 @@ bool ParticlesMaterial::get_flag(Flags p_flag) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) {
|
void ParticlesMaterial::set_emission_shape(EmissionShape p_shape) {
|
||||||
|
ERR_FAIL_INDEX(p_shape, EMISSION_SHAPE_MAX);
|
||||||
emission_shape = p_shape;
|
emission_shape = p_shape;
|
||||||
_change_notify();
|
_change_notify();
|
||||||
_queue_shader_change();
|
_queue_shader_change();
|
||||||
@@ -1242,6 +1248,7 @@ void ParticlesMaterial::_bind_methods() {
|
|||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_BOX);
|
||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_POINTS);
|
||||||
BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS);
|
||||||
|
BIND_ENUM_CONSTANT(EMISSION_SHAPE_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticlesMaterial::ParticlesMaterial() :
|
ParticlesMaterial::ParticlesMaterial() :
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
EMISSION_SHAPE_BOX,
|
EMISSION_SHAPE_BOX,
|
||||||
EMISSION_SHAPE_POINTS,
|
EMISSION_SHAPE_POINTS,
|
||||||
EMISSION_SHAPE_DIRECTED_POINTS,
|
EMISSION_SHAPE_DIRECTED_POINTS,
|
||||||
|
EMISSION_SHAPE_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user