You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-08 12:40:44 +00:00
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
This commit is contained in:
@@ -37,34 +37,27 @@
|
||||
#include "scene/resources/particles_material.h"
|
||||
|
||||
void Particles2DEditorPlugin::edit(Object *p_object) {
|
||||
|
||||
particles = Object::cast_to<Particles2D>(p_object);
|
||||
}
|
||||
|
||||
bool Particles2DEditorPlugin::handles(Object *p_object) const {
|
||||
|
||||
return p_object->is_class("Particles2D");
|
||||
}
|
||||
|
||||
void Particles2DEditorPlugin::make_visible(bool p_visible) {
|
||||
|
||||
if (p_visible) {
|
||||
|
||||
toolbar->show();
|
||||
} else {
|
||||
|
||||
toolbar->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void Particles2DEditorPlugin::_file_selected(const String &p_file) {
|
||||
|
||||
source_emission_file = p_file;
|
||||
emission_mask->popup_centered_minsize();
|
||||
}
|
||||
|
||||
void Particles2DEditorPlugin::_menu_callback(int p_idx) {
|
||||
|
||||
switch (p_idx) {
|
||||
case MENU_GENERATE_VISIBILITY_RECT: {
|
||||
float gen_time = particles->get_lifetime();
|
||||
@@ -75,16 +68,13 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
|
||||
generate_visibility_rect->popup_centered_minsize();
|
||||
} break;
|
||||
case MENU_LOAD_EMISSION_MASK: {
|
||||
|
||||
file->popup_centered_ratio();
|
||||
|
||||
} break;
|
||||
case MENU_CLEAR_EMISSION_MASK: {
|
||||
|
||||
emission_mask->popup_centered_minsize();
|
||||
} break;
|
||||
case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: {
|
||||
|
||||
CPUParticles2D *cpu_particles = memnew(CPUParticles2D);
|
||||
cpu_particles->convert_from_particles(particles);
|
||||
cpu_particles->set_name(particles->get_name());
|
||||
@@ -103,14 +93,12 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
|
||||
|
||||
} break;
|
||||
case MENU_RESTART: {
|
||||
|
||||
particles->restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Particles2DEditorPlugin::_generate_visibility_rect() {
|
||||
|
||||
float time = generate_seconds->get_value();
|
||||
|
||||
float running = 0.0;
|
||||
@@ -125,7 +113,6 @@ void Particles2DEditorPlugin::_generate_visibility_rect() {
|
||||
|
||||
Rect2 rect;
|
||||
while (running < time) {
|
||||
|
||||
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
|
||||
ep.step("Generating...", int(running), true);
|
||||
OS::get_singleton()->delay_usec(1000);
|
||||
@@ -150,7 +137,6 @@ void Particles2DEditorPlugin::_generate_visibility_rect() {
|
||||
}
|
||||
|
||||
void Particles2DEditorPlugin::_generate_emission_mask() {
|
||||
|
||||
Ref<ParticlesMaterial> pm = particles->get_process_material();
|
||||
if (!pm.is_valid()) {
|
||||
EditorNode::get_singleton()->show_warning(TTR("Can only set point into a ParticlesMaterial process material"));
|
||||
@@ -196,13 +182,10 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
|
||||
|
||||
for (int i = 0; i < s.width; i++) {
|
||||
for (int j = 0; j < s.height; j++) {
|
||||
|
||||
uint8_t a = r[(j * s.width + i) * 4 + 3];
|
||||
|
||||
if (a > 128) {
|
||||
|
||||
if (emode == EMISSION_MODE_SOLID) {
|
||||
|
||||
if (capture_colors) {
|
||||
valid_colors.write[vpc * 4 + 0] = r[(j * s.width + i) * 4 + 0];
|
||||
valid_colors.write[vpc * 4 + 1] = r[(j * s.width + i) * 4 + 1];
|
||||
@@ -212,11 +195,9 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
|
||||
valid_positions.write[vpc++] = Point2(i, j);
|
||||
|
||||
} else {
|
||||
|
||||
bool on_border = false;
|
||||
for (int x = i - 1; x <= i + 1; x++) {
|
||||
for (int y = j - 1; y <= j + 1; y++) {
|
||||
|
||||
if (x < 0 || y < 0 || x >= s.width || y >= s.height || r[(y * s.width + x) * 4 + 3] <= 128) {
|
||||
on_border = true;
|
||||
break;
|
||||
@@ -234,7 +215,6 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
|
||||
Vector2 normal;
|
||||
for (int x = i - 2; x <= i + 2; x++) {
|
||||
for (int y = j - 2; y <= j + 2; y++) {
|
||||
|
||||
if (x == i && y == j)
|
||||
continue;
|
||||
|
||||
@@ -281,7 +261,6 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
|
||||
PoolVector<uint8_t>::Write tw = texdata.write();
|
||||
float *twf = (float *)tw.ptr();
|
||||
for (int i = 0; i < vpc; i++) {
|
||||
|
||||
twf[i * 2 + 0] = valid_positions[i].x;
|
||||
twf[i * 2 + 1] = valid_positions[i].y;
|
||||
}
|
||||
@@ -298,14 +277,12 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
|
||||
pm->set_emission_point_count(vpc);
|
||||
|
||||
if (capture_colors) {
|
||||
|
||||
PoolVector<uint8_t> colordata;
|
||||
colordata.resize(w * h * 4); //use RG texture
|
||||
|
||||
{
|
||||
PoolVector<uint8_t>::Write tw = colordata.write();
|
||||
for (int i = 0; i < vpc * 4; i++) {
|
||||
|
||||
tw[i] = valid_colors[i];
|
||||
}
|
||||
}
|
||||
@@ -346,9 +323,7 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
|
||||
}
|
||||
|
||||
void Particles2DEditorPlugin::_notification(int p_what) {
|
||||
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
|
||||
menu->get_popup()->connect("id_pressed", this, "_menu_callback");
|
||||
menu->set_icon(menu->get_popup()->get_icon("Particles2D", "EditorIcons"));
|
||||
file->connect("file_selected", this, "_file_selected");
|
||||
@@ -356,7 +331,6 @@ void Particles2DEditorPlugin::_notification(int p_what) {
|
||||
}
|
||||
|
||||
void Particles2DEditorPlugin::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_menu_callback"), &Particles2DEditorPlugin::_menu_callback);
|
||||
ClassDB::bind_method(D_METHOD("_file_selected"), &Particles2DEditorPlugin::_file_selected);
|
||||
ClassDB::bind_method(D_METHOD("_generate_visibility_rect"), &Particles2DEditorPlugin::_generate_visibility_rect);
|
||||
@@ -364,7 +338,6 @@ void Particles2DEditorPlugin::_bind_methods() {
|
||||
}
|
||||
|
||||
Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
|
||||
|
||||
particles = NULL;
|
||||
editor = p_node;
|
||||
undo_redo = editor->get_undo_redo();
|
||||
|
||||
Reference in New Issue
Block a user