| 
									
										
										
										
											2023-01-10 15:26:54 +01:00
										 |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*  particles_editor_plugin.cpp                                           */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /*                         This file is part of:                          */ | 
					
						
							|  |  |  | /*                             GODOT ENGINE                               */ | 
					
						
							|  |  |  | /*                        https://godotengine.org                         */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  | /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */ | 
					
						
							|  |  |  | /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                  */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* Permission is hereby granted, free of charge, to any person obtaining  */ | 
					
						
							|  |  |  | /* a copy of this software and associated documentation files (the        */ | 
					
						
							|  |  |  | /* "Software"), to deal in the Software without restriction, including    */ | 
					
						
							|  |  |  | /* without limitation the rights to use, copy, modify, merge, publish,    */ | 
					
						
							|  |  |  | /* distribute, sublicense, and/or sell copies of the Software, and to     */ | 
					
						
							|  |  |  | /* permit persons to whom the Software is furnished to do so, subject to  */ | 
					
						
							|  |  |  | /* the following conditions:                                              */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* The above copyright notice and this permission notice shall be         */ | 
					
						
							|  |  |  | /* included in all copies or substantial portions of the Software.        */ | 
					
						
							|  |  |  | /*                                                                        */ | 
					
						
							|  |  |  | /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,        */ | 
					
						
							|  |  |  | /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF     */ | 
					
						
							|  |  |  | /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | 
					
						
							|  |  |  | /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY   */ | 
					
						
							|  |  |  | /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,   */ | 
					
						
							|  |  |  | /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE      */ | 
					
						
							|  |  |  | /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                 */ | 
					
						
							|  |  |  | /**************************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-10-03 16:33:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | #include "particles_editor_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-04 11:30:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-11 18:13:45 +02:00
										 |  |  | #include "core/io/resource_loader.h"
 | 
					
						
							| 
									
										
										
										
											2017-03-05 16:44:50 +01:00
										 |  |  | #include "editor/plugins/spatial_editor_plugin.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-07 09:04:22 -03:00
										 |  |  | #include "scene/3d/cpu_particles.h"
 | 
					
						
							| 
									
										
										
										
											2018-09-04 11:30:04 +02:00
										 |  |  | #include "scene/resources/particles_material.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | bool ParticlesEditorBase::_generate(PoolVector<Vector3> &points, PoolVector<Vector3> &normals) { | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	bool use_normals = emission_fill->get_selected() == 1; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	if (emission_fill->get_selected() < 2) { | 
					
						
							|  |  |  | 		float area_accum = 0; | 
					
						
							|  |  |  | 		Map<float, int> triangle_area_map; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		for (int i = 0; i < geometry.size(); i++) { | 
					
						
							| 
									
										
										
										
											2017-01-14 18:03:38 +01:00
										 |  |  | 			float area = geometry[i].get_area(); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 			if (area < CMP_EPSILON) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				continue; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 			triangle_area_map[area_accum] = i; | 
					
						
							|  |  |  | 			area_accum += area; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		if (!triangle_area_map.size() || area_accum == 0) { | 
					
						
							| 
									
										
										
										
											2019-08-15 15:54:12 +02:00
										 |  |  | 			EditorNode::get_singleton()->show_warning(TTR("The geometry's faces don't contain any area.")); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 			return false; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		int emissor_count = emission_amount->get_value(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		for (int i = 0; i < emissor_count; i++) { | 
					
						
							|  |  |  | 			float areapos = Math::random(0.0f, area_accum); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 			Map<float, int>::Element *E = triangle_area_map.find_closest(areapos); | 
					
						
							| 
									
										
										
										
											2019-06-11 14:49:34 +02:00
										 |  |  | 			ERR_FAIL_COND_V(!E, false); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			int index = E->get(); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 			ERR_FAIL_INDEX_V(index, geometry.size(), false); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// ok FINALLY get face
 | 
					
						
							|  |  |  | 			Face3 face = geometry[index]; | 
					
						
							|  |  |  | 			//now compute some position inside the face...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Vector3 pos = face.get_random_point_inside(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 			points.push_back(pos); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			if (use_normals) { | 
					
						
							|  |  |  | 				Vector3 normal = face.get_plane().normal; | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 				normals.push_back(normal); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		int gcount = geometry.size(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		if (gcount == 0) { | 
					
						
							| 
									
										
										
										
											2019-08-15 15:54:12 +02:00
										 |  |  | 			EditorNode::get_singleton()->show_warning(TTR("The geometry doesn't contain any faces.")); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 			return false; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-07 18:25:37 -03:00
										 |  |  | 		PoolVector<Face3>::Read r = geometry.read(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-16 21:09:00 -05:00
										 |  |  | 		AABB aabb; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		for (int i = 0; i < gcount; i++) { | 
					
						
							|  |  |  | 			for (int j = 0; j < 3; j++) { | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 				if (i == 0 && j == 0) { | 
					
						
							| 
									
										
										
										
											2017-06-06 20:33:51 +02:00
										 |  |  | 					aabb.position = r[i].vertex[j]; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 					aabb.expand_to(r[i].vertex[j]); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		int emissor_count = emission_amount->get_value(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		for (int i = 0; i < emissor_count; i++) { | 
					
						
							|  |  |  | 			int attempts = 5; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 			for (int j = 0; j < attempts; j++) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				Vector3 dir; | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 				dir[Math::rand() % 3] = 1.0; | 
					
						
							| 
									
										
										
										
											2017-08-21 15:15:36 -04:00
										 |  |  | 				Vector3 ofs = (Vector3(1, 1, 1) - dir) * Vector3(Math::randf(), Math::randf(), Math::randf()) * aabb.size + aabb.position; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				Vector3 ofsv = ofs + aabb.size * dir; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				//space it a little
 | 
					
						
							|  |  |  | 				ofs -= dir; | 
					
						
							|  |  |  | 				ofsv += dir; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 				float max = -1e7, min = 1e7; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 				for (int k = 0; k < gcount; k++) { | 
					
						
							|  |  |  | 					const Face3 &f3 = r[k]; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					Vector3 res; | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 					if (f3.intersects_segment(ofs, ofsv, &res)) { | 
					
						
							|  |  |  | 						res -= ofs; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 						float d = dir.dot(res); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 						if (d < min) { | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 							min = d; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 						} | 
					
						
							|  |  |  | 						if (d > max) { | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 							max = d; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 						} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 				if (max < min) { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 					continue; //lost attempt
 | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 				float val = min + (max - min) * Math::randf(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				Vector3 point = ofs + dir * val; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 				points.push_back(point); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 	return true; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditorBase::_node_selected(const NodePath &p_path) { | 
					
						
							|  |  |  | 	Node *sel = get_node(p_path); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	if (!sel) { | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-15 15:54:12 +02:00
										 |  |  | 	if (!sel->is_class("Spatial")) { | 
					
						
							|  |  |  | 		EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Spatial."), sel->get_name())); | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 	VisualInstance *vi = Object::cast_to<VisualInstance>(sel); | 
					
						
							|  |  |  | 	if (!vi) { | 
					
						
							| 
									
										
										
										
											2019-08-15 15:54:12 +02:00
										 |  |  | 		EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain geometry."), sel->get_name())); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	geometry = vi->get_faces(VisualInstance::FACES_SOLID); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (geometry.size() == 0) { | 
					
						
							| 
									
										
										
										
											2019-08-15 15:54:12 +02:00
										 |  |  | 		EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain face geometry."), sel->get_name())); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Transform geom_xform = base_node->get_global_transform().affine_inverse() * vi->get_global_transform(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int gc = geometry.size(); | 
					
						
							|  |  |  | 	PoolVector<Face3>::Write w = geometry.write(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	for (int i = 0; i < gc; i++) { | 
					
						
							|  |  |  | 		for (int j = 0; j < 3; j++) { | 
					
						
							|  |  |  | 			w[i].vertex[j] = geom_xform.xform(w[i].vertex[j]); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-05 18:08:43 +01:00
										 |  |  | 	w.release(); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	emission_dialog->popup_centered(Size2(300, 130)); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditorBase::_bind_methods() { | 
					
						
							|  |  |  | 	ClassDB::bind_method("_node_selected", &ParticlesEditorBase::_node_selected); | 
					
						
							|  |  |  | 	ClassDB::bind_method("_generate_emission_points", &ParticlesEditorBase::_generate_emission_points); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ParticlesEditorBase::ParticlesEditorBase() { | 
					
						
							|  |  |  | 	emission_dialog = memnew(ConfirmationDialog); | 
					
						
							|  |  |  | 	emission_dialog->set_title(TTR("Create Emitter")); | 
					
						
							|  |  |  | 	add_child(emission_dialog); | 
					
						
							|  |  |  | 	VBoxContainer *emd_vb = memnew(VBoxContainer); | 
					
						
							|  |  |  | 	emission_dialog->add_child(emd_vb); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	emission_amount = memnew(SpinBox); | 
					
						
							|  |  |  | 	emission_amount->set_min(1); | 
					
						
							|  |  |  | 	emission_amount->set_max(100000); | 
					
						
							|  |  |  | 	emission_amount->set_value(512); | 
					
						
							|  |  |  | 	emd_vb->add_margin_child(TTR("Emission Points:"), emission_amount); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	emission_fill = memnew(OptionButton); | 
					
						
							|  |  |  | 	emission_fill->add_item(TTR("Surface Points")); | 
					
						
							|  |  |  | 	emission_fill->add_item(TTR("Surface Points+Normal (Directed)")); | 
					
						
							|  |  |  | 	emission_fill->add_item(TTR("Volume")); | 
					
						
							| 
									
										
										
										
											2022-06-08 11:42:51 +02:00
										 |  |  | 	emd_vb->add_margin_child(TTR("Emission Source:"), emission_fill); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	emission_dialog->get_ok()->set_text(TTR("Create")); | 
					
						
							|  |  |  | 	emission_dialog->connect("confirmed", this, "_generate_emission_points"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	emission_file_dialog = memnew(EditorFileDialog); | 
					
						
							|  |  |  | 	add_child(emission_file_dialog); | 
					
						
							|  |  |  | 	emission_file_dialog->connect("file_selected", this, "_resource_seleted"); | 
					
						
							|  |  |  | 	emission_tree_dialog = memnew(SceneTreeDialog); | 
					
						
							|  |  |  | 	add_child(emission_tree_dialog); | 
					
						
							|  |  |  | 	emission_tree_dialog->connect("selected", this, "_node_selected"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	List<String> extensions; | 
					
						
							|  |  |  | 	ResourceLoader::get_recognized_extensions_for_type("Mesh", &extensions); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	emission_file_dialog->clear_filters(); | 
					
						
							|  |  |  | 	for (int i = 0; i < extensions.size(); i++) { | 
					
						
							|  |  |  | 		emission_file_dialog->add_filter("*." + extensions[i] + " ; " + extensions[i].to_upper()); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	emission_file_dialog->set_mode(EditorFileDialog::MODE_OPEN_FILE); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditor::_node_removed(Node *p_node) { | 
					
						
							|  |  |  | 	if (p_node == node) { | 
					
						
							| 
									
										
										
										
											2021-05-04 16:00:45 +02:00
										 |  |  | 		node = nullptr; | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 		hide(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditor::_notification(int p_notification) { | 
					
						
							|  |  |  | 	if (p_notification == NOTIFICATION_ENTER_TREE) { | 
					
						
							|  |  |  | 		options->set_icon(options->get_popup()->get_icon("Particles", "EditorIcons")); | 
					
						
							| 
									
										
										
										
											2018-08-24 08:28:53 -03:00
										 |  |  | 		get_tree()->connect("node_removed", this, "_node_removed"); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditor::_menu_option(int p_option) { | 
					
						
							|  |  |  | 	switch (p_option) { | 
					
						
							|  |  |  | 		case MENU_OPTION_GENERATE_AABB: { | 
					
						
							| 
									
										
										
										
											2021-07-05 15:09:46 +02:00
										 |  |  | 			// Add one second to the default generation lifetime, since the progress is updated every second.
 | 
					
						
							|  |  |  | 			generate_seconds->set_value(MAX(1.0, trunc(node->get_lifetime()) + 1.0)); | 
					
						
							| 
									
										
										
										
											2018-08-13 17:14:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-05 15:09:46 +02:00
										 |  |  | 			if (generate_seconds->get_value() >= 11.0 + CMP_EPSILON) { | 
					
						
							|  |  |  | 				// Only pop up the time dialog if the particle's lifetime is long enough to warrant shortening it.
 | 
					
						
							|  |  |  | 				generate_aabb->popup_centered_minsize(); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2021-07-05 15:09:46 +02:00
										 |  |  | 				// Generate the visibility AABB immediately.
 | 
					
						
							|  |  |  | 				_generate_aabb(); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 		} break; | 
					
						
							|  |  |  | 		case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH: { | 
					
						
							|  |  |  | 			Ref<ParticlesMaterial> material = node->get_process_material(); | 
					
						
							|  |  |  | 			if (material.is_null()) { | 
					
						
							|  |  |  | 				EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticlesMaterial' is required.")); | 
					
						
							|  |  |  | 				return; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			emission_file_dialog->popup_centered_ratio(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} break; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		case MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE: { | 
					
						
							|  |  |  | 			Ref<ParticlesMaterial> material = node->get_process_material(); | 
					
						
							|  |  |  | 			if (material.is_null()) { | 
					
						
							|  |  |  | 				EditorNode::get_singleton()->show_warning(TTR("A processor material of type 'ParticlesMaterial' is required.")); | 
					
						
							|  |  |  | 				return; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			emission_tree_dialog->popup_centered_ratio(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2018-07-07 09:04:22 -03:00
										 |  |  | 		case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: { | 
					
						
							|  |  |  | 			CPUParticles *cpu_particles = memnew(CPUParticles); | 
					
						
							|  |  |  | 			cpu_particles->convert_from_particles(node); | 
					
						
							| 
									
										
										
										
											2018-07-23 12:28:15 -03:00
										 |  |  | 			cpu_particles->set_name(node->get_name()); | 
					
						
							|  |  |  | 			cpu_particles->set_transform(node->get_transform()); | 
					
						
							|  |  |  | 			cpu_particles->set_visible(node->is_visible()); | 
					
						
							|  |  |  | 			cpu_particles->set_pause_mode(node->get_pause_mode()); | 
					
						
							| 
									
										
										
										
											2018-07-07 09:04:22 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-30 23:08:57 +02:00
										 |  |  | 			UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); | 
					
						
							|  |  |  | 			ur->create_action(TTR("Convert to CPUParticles")); | 
					
						
							|  |  |  | 			ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, cpu_particles, true, false); | 
					
						
							| 
									
										
										
										
											2019-06-24 12:08:28 +02:00
										 |  |  | 			ur->add_do_reference(cpu_particles); | 
					
						
							| 
									
										
										
										
											2019-05-30 23:08:57 +02:00
										 |  |  | 			ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, node, false, false); | 
					
						
							| 
									
										
										
										
											2019-06-24 12:08:28 +02:00
										 |  |  | 			ur->add_undo_reference(node); | 
					
						
							| 
									
										
										
										
											2019-05-30 23:08:57 +02:00
										 |  |  | 			ur->commit_action(); | 
					
						
							| 
									
										
										
										
											2018-07-07 09:04:22 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2019-06-21 22:33:11 -07:00
										 |  |  | 		case MENU_OPTION_RESTART: { | 
					
						
							|  |  |  | 			node->restart(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		} break; | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditor::_generate_aabb() { | 
					
						
							|  |  |  | 	float time = generate_seconds->get_value(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	float running = 0.0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-05 15:09:46 +02:00
										 |  |  | 	EditorProgress ep("gen_aabb", TTR("Generating Visibility AABB (Waiting for Particle Simulation)"), int(time)); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 17:14:56 +02:00
										 |  |  | 	bool was_emitting = node->is_emitting(); | 
					
						
							|  |  |  | 	if (!was_emitting) { | 
					
						
							|  |  |  | 		node->set_emitting(true); | 
					
						
							|  |  |  | 		OS::get_singleton()->delay_usec(1000); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 	AABB rect; | 
					
						
							| 
									
										
										
										
											2018-08-13 17:14:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 	while (running < time) { | 
					
						
							|  |  |  | 		uint64_t ticks = OS::get_singleton()->get_ticks_usec(); | 
					
						
							|  |  |  | 		ep.step("Generating...", int(running), true); | 
					
						
							|  |  |  | 		OS::get_singleton()->delay_usec(1000); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		AABB capture = node->capture_aabb(); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		if (rect == AABB()) { | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 			rect = capture; | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		} else { | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 			rect.merge_with(capture); | 
					
						
							| 
									
										
										
										
											2021-05-05 12:44:11 +02:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		running += (OS::get_singleton()->get_ticks_usec() - ticks) / 1000000.0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-13 17:14:56 +02:00
										 |  |  | 	if (!was_emitting) { | 
					
						
							|  |  |  | 		node->set_emitting(false); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-24 00:54:06 +02:00
										 |  |  | 	UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo(); | 
					
						
							|  |  |  | 	ur->create_action(TTR("Generate Visibility AABB")); | 
					
						
							|  |  |  | 	ur->add_do_method(node, "set_visibility_aabb", rect); | 
					
						
							|  |  |  | 	ur->add_undo_method(node, "set_visibility_aabb", node->get_visibility_aabb()); | 
					
						
							|  |  |  | 	ur->commit_action(); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditor::edit(Particles *p_particles) { | 
					
						
							|  |  |  | 	base_node = p_particles; | 
					
						
							|  |  |  | 	node = p_particles; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditor::_generate_emission_points() { | 
					
						
							|  |  |  | 	/// hacer codigo aca
 | 
					
						
							|  |  |  | 	PoolVector<Vector3> points; | 
					
						
							|  |  |  | 	PoolVector<Vector3> normals; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!_generate(points, normals)) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int point_count = points.size(); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	int w = 2048; | 
					
						
							|  |  |  | 	int h = (point_count / 2048) + 1; | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	PoolVector<uint8_t> point_img; | 
					
						
							|  |  |  | 	point_img.resize(w * h * 3 * sizeof(float)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		PoolVector<uint8_t>::Write iw = point_img.write(); | 
					
						
							| 
									
										
										
										
											2021-04-29 12:34:11 +02:00
										 |  |  | 		memset(iw.ptr(), 0, w * h * 3 * sizeof(float)); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 		PoolVector<Vector3>::Read r = points.read(); | 
					
						
							|  |  |  | 		float *wf = (float *)iw.ptr(); | 
					
						
							|  |  |  | 		for (int i = 0; i < point_count; i++) { | 
					
						
							|  |  |  | 			wf[i * 3 + 0] = r[i].x; | 
					
						
							|  |  |  | 			wf[i * 3 + 1] = r[i].y; | 
					
						
							|  |  |  | 			wf[i * 3 + 2] = r[i].z; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 07:36:47 -03:00
										 |  |  | 	Ref<Image> image = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img)); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	Ref<ImageTexture> tex; | 
					
						
							|  |  |  | 	tex.instance(); | 
					
						
							|  |  |  | 	tex->create_from_image(image, Texture::FLAG_FILTER); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Ref<ParticlesMaterial> material = node->get_process_material(); | 
					
						
							|  |  |  | 	ERR_FAIL_COND(material.is_null()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 	if (normals.size() > 0) { | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_DIRECTED_POINTS); | 
					
						
							|  |  |  | 		material->set_emission_point_count(point_count); | 
					
						
							|  |  |  | 		material->set_emission_point_texture(tex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		PoolVector<uint8_t> point_img2; | 
					
						
							|  |  |  | 		point_img2.resize(w * h * 3 * sizeof(float)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			PoolVector<uint8_t>::Write iw = point_img2.write(); | 
					
						
							| 
									
										
										
										
											2021-04-29 12:34:11 +02:00
										 |  |  | 			memset(iw.ptr(), 0, w * h * 3 * sizeof(float)); | 
					
						
							| 
									
										
										
										
											2018-07-06 20:21:13 -03:00
										 |  |  | 			PoolVector<Vector3>::Read r = normals.read(); | 
					
						
							|  |  |  | 			float *wf = (float *)iw.ptr(); | 
					
						
							|  |  |  | 			for (int i = 0; i < point_count; i++) { | 
					
						
							|  |  |  | 				wf[i * 3 + 0] = r[i].x; | 
					
						
							|  |  |  | 				wf[i * 3 + 1] = r[i].y; | 
					
						
							|  |  |  | 				wf[i * 3 + 2] = r[i].z; | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-17 07:36:47 -03:00
										 |  |  | 		Ref<Image> image2 = memnew(Image(w, h, false, Image::FORMAT_RGBF, point_img2)); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Ref<ImageTexture> tex2; | 
					
						
							|  |  |  | 		tex2.instance(); | 
					
						
							|  |  |  | 		tex2->create_from_image(image2, Texture::FLAG_FILTER); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		material->set_emission_normal_texture(tex2); | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		material->set_emission_shape(ParticlesMaterial::EMISSION_SHAPE_POINTS); | 
					
						
							|  |  |  | 		material->set_emission_point_count(point_count); | 
					
						
							|  |  |  | 		material->set_emission_point_texture(tex); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditor::_bind_methods() { | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	ClassDB::bind_method("_menu_option", &ParticlesEditor::_menu_option); | 
					
						
							| 
									
										
										
										
											2017-04-08 22:38:11 -03:00
										 |  |  | 	ClassDB::bind_method("_generate_aabb", &ParticlesEditor::_generate_aabb); | 
					
						
							| 
									
										
										
										
											2018-08-24 08:28:53 -03:00
										 |  |  | 	ClassDB::bind_method("_node_removed", &ParticlesEditor::_node_removed); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ParticlesEditor::ParticlesEditor() { | 
					
						
							| 
									
										
										
										
											2021-05-04 16:00:45 +02:00
										 |  |  | 	node = nullptr; | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	particles_editor_hb = memnew(HBoxContainer); | 
					
						
							| 
									
										
										
										
											2014-07-10 10:55:03 +08:00
										 |  |  | 	SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	options = memnew(MenuButton); | 
					
						
							| 
									
										
										
										
											2019-04-25 10:27:33 -03:00
										 |  |  | 	options->set_switch_on_hover(true); | 
					
						
							| 
									
										
										
										
											2014-07-10 10:55:03 +08:00
										 |  |  | 	particles_editor_hb->add_child(options); | 
					
						
							|  |  |  | 	particles_editor_hb->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-23 22:25:14 +02:00
										 |  |  | 	options->set_text(TTR("Particles")); | 
					
						
							| 
									
										
										
										
											2021-01-06 19:15:03 +01:00
										 |  |  | 	options->get_popup()->add_item(TTR("Generate Visibility AABB"), MENU_OPTION_GENERATE_AABB); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	options->get_popup()->add_separator(); | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	options->get_popup()->add_item(TTR("Create Emission Points From Mesh"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_MESH); | 
					
						
							|  |  |  | 	options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE); | 
					
						
							| 
									
										
										
										
											2018-07-07 09:04:22 -03:00
										 |  |  | 	options->get_popup()->add_separator(); | 
					
						
							|  |  |  | 	options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES); | 
					
						
							| 
									
										
										
										
											2019-06-21 22:33:11 -07:00
										 |  |  | 	options->get_popup()->add_separator(); | 
					
						
							|  |  |  | 	options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART); | 
					
						
							| 
									
										
										
										
											2018-07-07 09:04:22 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	options->get_popup()->connect("id_pressed", this, "_menu_option"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-08 22:38:11 -03:00
										 |  |  | 	generate_aabb = memnew(ConfirmationDialog); | 
					
						
							|  |  |  | 	generate_aabb->set_title(TTR("Generate Visibility AABB")); | 
					
						
							|  |  |  | 	VBoxContainer *genvb = memnew(VBoxContainer); | 
					
						
							|  |  |  | 	generate_aabb->add_child(genvb); | 
					
						
							|  |  |  | 	generate_seconds = memnew(SpinBox); | 
					
						
							|  |  |  | 	genvb->add_margin_child(TTR("Generation Time (sec):"), generate_seconds); | 
					
						
							|  |  |  | 	generate_seconds->set_min(0.1); | 
					
						
							|  |  |  | 	generate_seconds->set_max(25); | 
					
						
							|  |  |  | 	generate_seconds->set_value(2); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	add_child(generate_aabb); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	generate_aabb->connect("confirmed", this, "_generate_aabb"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditorPlugin::edit(Object *p_object) { | 
					
						
							| 
									
										
										
										
											2017-08-24 22:58:51 +02:00
										 |  |  | 	particles_editor->edit(Object::cast_to<Particles>(p_object)); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool ParticlesEditorPlugin::handles(Object *p_object) const { | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	return p_object->is_class("Particles"); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ParticlesEditorPlugin::make_visible(bool p_visible) { | 
					
						
							|  |  |  | 	if (p_visible) { | 
					
						
							|  |  |  | 		particles_editor->show(); | 
					
						
							| 
									
										
										
										
											2014-07-10 10:55:03 +08:00
										 |  |  | 		particles_editor->particles_editor_hb->show(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2014-07-10 10:55:03 +08:00
										 |  |  | 		particles_editor->particles_editor_hb->hide(); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 		particles_editor->hide(); | 
					
						
							| 
									
										
										
										
											2021-05-04 16:00:45 +02:00
										 |  |  | 		particles_editor->edit(nullptr); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ParticlesEditorPlugin::ParticlesEditorPlugin(EditorNode *p_node) { | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | 	editor = p_node; | 
					
						
							|  |  |  | 	particles_editor = memnew(ParticlesEditor); | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | 	editor->get_viewport()->add_child(particles_editor); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	particles_editor->hide(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 23:36:37 -03:00
										 |  |  | ParticlesEditorPlugin::~ParticlesEditorPlugin() { | 
					
						
							| 
									
										
										
										
											2014-02-09 22:10:30 -03:00
										 |  |  | } |