diff options
Diffstat (limited to 'scene/3d/cpu_particles_3d.cpp')
-rw-r--r-- | scene/3d/cpu_particles_3d.cpp | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index 414dc6f97b..631ab4e0f7 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -36,16 +36,13 @@ #include "servers/rendering_server.h" AABB CPUParticles3D::get_aabb() const { - return AABB(); } Vector<Face3> CPUParticles3D::get_faces(uint32_t p_usage_flags) const { - return Vector<Face3>(); } void CPUParticles3D::set_emitting(bool p_emitting) { - if (emitting == p_emitting) return; @@ -60,7 +57,6 @@ void CPUParticles3D::set_emitting(bool p_emitting) { } void CPUParticles3D::set_amount(int p_amount) { - ERR_FAIL_COND_MSG(p_amount < 1, "Amount of particles must be greater than 0."); particles.resize(p_amount); @@ -79,97 +75,76 @@ void CPUParticles3D::set_amount(int p_amount) { particle_order.resize(p_amount); } void CPUParticles3D::set_lifetime(float p_lifetime) { - ERR_FAIL_COND_MSG(p_lifetime <= 0, "Particles lifetime must be greater than 0."); lifetime = p_lifetime; } void CPUParticles3D::set_one_shot(bool p_one_shot) { - one_shot = p_one_shot; } void CPUParticles3D::set_pre_process_time(float p_time) { - pre_process_time = p_time; } void CPUParticles3D::set_explosiveness_ratio(float p_ratio) { - explosiveness_ratio = p_ratio; } void CPUParticles3D::set_randomness_ratio(float p_ratio) { - randomness_ratio = p_ratio; } void CPUParticles3D::set_lifetime_randomness(float p_random) { - lifetime_randomness = p_random; } void CPUParticles3D::set_use_local_coordinates(bool p_enable) { - local_coords = p_enable; } void CPUParticles3D::set_speed_scale(float p_scale) { - speed_scale = p_scale; } bool CPUParticles3D::is_emitting() const { - return emitting; } int CPUParticles3D::get_amount() const { - return particles.size(); } float CPUParticles3D::get_lifetime() const { - return lifetime; } bool CPUParticles3D::get_one_shot() const { - return one_shot; } float CPUParticles3D::get_pre_process_time() const { - return pre_process_time; } float CPUParticles3D::get_explosiveness_ratio() const { - return explosiveness_ratio; } float CPUParticles3D::get_randomness_ratio() const { - return randomness_ratio; } float CPUParticles3D::get_lifetime_randomness() const { - return lifetime_randomness; } bool CPUParticles3D::get_use_local_coordinates() const { - return local_coords; } float CPUParticles3D::get_speed_scale() const { - return speed_scale; } void CPUParticles3D::set_draw_order(DrawOrder p_order) { - draw_order = p_order; } CPUParticles3D::DrawOrder CPUParticles3D::get_draw_order() const { - return draw_order; } void CPUParticles3D::set_mesh(const Ref<Mesh> &p_mesh) { - mesh = p_mesh; if (mesh.is_valid()) { RS::get_singleton()->multimesh_set_mesh(multimesh, mesh->get_rid()); @@ -179,7 +154,6 @@ void CPUParticles3D::set_mesh(const Ref<Mesh> &p_mesh) { } Ref<Mesh> CPUParticles3D::get_mesh() const { - return mesh; } @@ -200,7 +174,6 @@ bool CPUParticles3D::get_fractional_delta() const { } String CPUParticles3D::get_configuration_warning() const { - String warnings; bool mesh_found = false; @@ -236,7 +209,6 @@ String CPUParticles3D::get_configuration_warning() const { } void CPUParticles3D::restart() { - time = 0; inactive_time = 0; frame_remainder = 0; @@ -256,62 +228,51 @@ void CPUParticles3D::restart() { } void CPUParticles3D::set_direction(Vector3 p_direction) { - direction = p_direction; } Vector3 CPUParticles3D::get_direction() const { - return direction; } void CPUParticles3D::set_spread(float p_spread) { - spread = p_spread; } float CPUParticles3D::get_spread() const { - return spread; } void CPUParticles3D::set_flatness(float p_flatness) { - flatness = p_flatness; } float CPUParticles3D::get_flatness() const { - return flatness; } void CPUParticles3D::set_param(Parameter p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); parameters[p_param] = p_value; } float CPUParticles3D::get_param(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return parameters[p_param]; } void CPUParticles3D::set_param_randomness(Parameter p_param, float p_value) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); randomness[p_param] = p_value; } float CPUParticles3D::get_param_randomness(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, 0); return randomness[p_param]; } static void _adjust_curve_range(const Ref<Curve> &p_curve, float p_min, float p_max) { - Ref<Curve> curve = p_curve; if (!curve.is_valid()) return; @@ -320,7 +281,6 @@ static void _adjust_curve_range(const Ref<Curve> &p_curve, float p_min, float p_ } void CPUParticles3D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curve) { - ERR_FAIL_INDEX(p_param, PARAM_MAX); curve_parameters[p_param] = p_curve; @@ -351,7 +311,6 @@ void CPUParticles3D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curv _adjust_curve_range(p_curve, -360, 360); } break; case PARAM_SCALE: { - } break; case PARAM_HUE_VARIATION: { _adjust_curve_range(p_curve, -1, 1); @@ -366,29 +325,24 @@ void CPUParticles3D::set_param_curve(Parameter p_param, const Ref<Curve> &p_curv } } Ref<Curve> CPUParticles3D::get_param_curve(Parameter p_param) const { - ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Curve>()); return curve_parameters[p_param]; } void CPUParticles3D::set_color(const Color &p_color) { - color = p_color; } Color CPUParticles3D::get_color() const { - return color; } void CPUParticles3D::set_color_ramp(const Ref<Gradient> &p_ramp) { - color_ramp = p_ramp; } Ref<Gradient> CPUParticles3D::get_color_ramp() const { - return color_ramp; } @@ -411,49 +365,39 @@ void CPUParticles3D::set_emission_shape(EmissionShape p_shape) { } void CPUParticles3D::set_emission_sphere_radius(float p_radius) { - emission_sphere_radius = p_radius; } void CPUParticles3D::set_emission_box_extents(Vector3 p_extents) { - emission_box_extents = p_extents; } void CPUParticles3D::set_emission_points(const Vector<Vector3> &p_points) { - emission_points = p_points; } void CPUParticles3D::set_emission_normals(const Vector<Vector3> &p_normals) { - emission_normals = p_normals; } void CPUParticles3D::set_emission_colors(const Vector<Color> &p_colors) { - emission_colors = p_colors; } float CPUParticles3D::get_emission_sphere_radius() const { - return emission_sphere_radius; } Vector3 CPUParticles3D::get_emission_box_extents() const { - return emission_box_extents; } Vector<Vector3> CPUParticles3D::get_emission_points() const { - return emission_points; } Vector<Vector3> CPUParticles3D::get_emission_normals() const { - return emission_normals; } Vector<Color> CPUParticles3D::get_emission_colors() const { - return emission_colors; } @@ -461,17 +405,14 @@ CPUParticles3D::EmissionShape CPUParticles3D::get_emission_shape() const { return emission_shape; } void CPUParticles3D::set_gravity(const Vector3 &p_gravity) { - gravity = p_gravity; } Vector3 CPUParticles3D::get_gravity() const { - return gravity; } void CPUParticles3D::_validate_property(PropertyInfo &property) const { - if (property.name == "color" && color_ramp.is_valid()) { property.usage = 0; } @@ -498,7 +439,6 @@ void CPUParticles3D::_validate_property(PropertyInfo &property) const { } static uint32_t idhash(uint32_t x) { - x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b); x = ((x >> uint32_t(16)) ^ x) * uint32_t(0x45d9f3b); x = (x >> uint32_t(16)) ^ x; @@ -519,7 +459,6 @@ static float rand_from_seed(uint32_t &seed) { } void CPUParticles3D::_update_internal() { - if (particles.size() == 0 || !is_visible_in_tree()) { _set_redraw(false); return; @@ -547,7 +486,6 @@ void CPUParticles3D::_update_internal() { bool processed = false; if (time == 0 && pre_process_time > 0.0) { - float frame_time; if (fixed_fps > 0) frame_time = 1.0 / fixed_fps; @@ -594,7 +532,6 @@ void CPUParticles3D::_update_internal() { } void CPUParticles3D::_particles_process(float p_delta) { - p_delta *= speed_scale; int pcount = particles.size(); @@ -623,7 +560,6 @@ void CPUParticles3D::_particles_process(float p_delta) { float system_phase = time / lifetime; for (int i = 0; i < pcount; i++) { - Particle &p = parray[i]; if (!emitting && !p.active) @@ -681,7 +617,6 @@ void CPUParticles3D::_particles_process(float p_delta) { } if (restart) { - if (!emitting) { p.active = false; continue; @@ -750,7 +685,6 @@ void CPUParticles3D::_particles_process(float p_delta) { } break; case EMISSION_SHAPE_POINTS: case EMISSION_SHAPE_DIRECTED_POINTS: { - int pc = emission_points.size(); if (pc == 0) break; @@ -805,7 +739,6 @@ void CPUParticles3D::_particles_process(float p_delta) { } else if (p.time > p.lifetime) { p.active = false; } else { - uint32_t alt_seed = p.seed; p.time += local_delta; @@ -875,7 +808,6 @@ void CPUParticles3D::_particles_process(float p_delta) { force += diff.length() > 0.0 ? diff.normalized() * (parameters[PARAM_RADIAL_ACCEL] + tex_radial_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_RADIAL_ACCEL]) : Vector3(); //apply tangential acceleration; if (flags[FLAG_DISABLE_Z]) { - Vector2 yx = Vector2(diff.y, diff.x); Vector2 yx2 = (yx * Vector2(-1.0, 1.0)).normalized(); force += yx.length() > 0.0 ? Vector3(yx2.x, yx2.y, 0.0) * ((parameters[PARAM_TANGENTIAL_ACCEL] + tex_tangential_accel) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_TANGENTIAL_ACCEL])) : Vector3(); @@ -903,7 +835,6 @@ void CPUParticles3D::_particles_process(float p_delta) { p.velocity = p.velocity.normalized() * tex_linear_velocity; } if (parameters[PARAM_DAMPING] + tex_damping > 0.0) { - float v = p.velocity.length(); float damp = (parameters[PARAM_DAMPING] + tex_damping) * Math::lerp(1.0f, rand_from_seed(alt_seed), randomness[PARAM_DAMPING]); v -= damp * local_delta; @@ -960,7 +891,6 @@ void CPUParticles3D::_particles_process(float p_delta) { p.color *= p.base_color; if (flags[FLAG_DISABLE_Z]) { - if (flags[FLAG_ALIGN_Y_TO_VELOCITY]) { if (p.velocity.length() > 0.0) { p.transform.basis.set_axis(1, p.velocity.normalized()); @@ -1047,7 +977,6 @@ void CPUParticles3D::_update_particle_data_buffer() { Vector3 dir = c->get_global_transform().basis.get_axis(2); //far away to close if (local_coords) { - // will look different from Particles in editor as this is based on the camera in the scenetree // and not the editor camera dir = inv_emission_transform.xform(dir).normalized(); @@ -1064,7 +993,6 @@ void CPUParticles3D::_update_particle_data_buffer() { } for (int i = 0; i < pc; i++) { - int idx = order ? order[i] : i; Transform t = r[idx].transform; @@ -1131,7 +1059,6 @@ void CPUParticles3D::_set_redraw(bool p_redraw) { } void CPUParticles3D::_update_render_thread() { - MutexLock lock(update_mutex); if (can_update) { @@ -1141,7 +1068,6 @@ void CPUParticles3D::_update_render_thread() { } void CPUParticles3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { set_process_internal(emitting); @@ -1165,11 +1091,9 @@ void CPUParticles3D::_notification(int p_what) { } if (p_what == NOTIFICATION_TRANSFORM_CHANGED) { - inv_emission_transform = get_global_transform().affine_inverse(); if (!local_coords) { - int pc = particles.size(); float *w = particle_data.ptrw(); @@ -1177,7 +1101,6 @@ void CPUParticles3D::_notification(int p_what) { float *ptr = w; for (int i = 0; i < pc; i++) { - Transform t = inv_emission_transform * r[i].transform; if (r[i].active) { @@ -1206,7 +1129,6 @@ void CPUParticles3D::_notification(int p_what) { } void CPUParticles3D::convert_from_particles(Node *p_particles) { - GPUParticles3D *particles = Object::cast_to<GPUParticles3D>(p_particles); ERR_FAIL_COND_MSG(!particles, "Only GPUParticles3D nodes can be converted to CPUParticles3D."); @@ -1276,7 +1198,6 @@ void CPUParticles3D::convert_from_particles(Node *p_particles) { } void CPUParticles3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_emitting", "emitting"), &CPUParticles3D::set_emitting); ClassDB::bind_method(D_METHOD("set_amount", "amount"), &CPUParticles3D::set_amount); ClassDB::bind_method(D_METHOD("set_lifetime", "secs"), &CPUParticles3D::set_lifetime); @@ -1481,7 +1402,6 @@ void CPUParticles3D::_bind_methods() { } CPUParticles3D::CPUParticles3D() { - time = 0; inactive_time = 0; frame_remainder = 0; |