mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 10:11:57 +03:00
Use switch consistently in _notification (scene folder)
This commit is contained in:
@@ -29,9 +29,9 @@
|
||||
/*************************************************************************/
|
||||
|
||||
#include "light_occluder_2d.h"
|
||||
#include "core/math/geometry_2d.h"
|
||||
|
||||
#include "core/config/engine.h"
|
||||
#include "core/math/geometry_2d.h"
|
||||
|
||||
#define LINE_GRAB_WIDTH 8
|
||||
|
||||
@@ -158,42 +158,46 @@ void LightOccluder2D::_poly_changed() {
|
||||
}
|
||||
|
||||
void LightOccluder2D::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ENTER_CANVAS) {
|
||||
RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas());
|
||||
RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
|
||||
RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
|
||||
}
|
||||
if (p_what == NOTIFICATION_TRANSFORM_CHANGED) {
|
||||
RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
|
||||
}
|
||||
if (p_what == NOTIFICATION_VISIBILITY_CHANGED) {
|
||||
RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
|
||||
}
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_CANVAS: {
|
||||
RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, get_canvas());
|
||||
RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
|
||||
RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
|
||||
} break;
|
||||
|
||||
if (p_what == NOTIFICATION_DRAW) {
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
if (occluder_polygon.is_valid()) {
|
||||
Vector<Vector2> poly = occluder_polygon->get_polygon();
|
||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||
RS::get_singleton()->canvas_light_occluder_set_transform(occluder, get_global_transform());
|
||||
} break;
|
||||
|
||||
if (poly.size()) {
|
||||
if (occluder_polygon->is_closed()) {
|
||||
Vector<Color> color;
|
||||
color.push_back(Color(0, 0, 0, 0.6));
|
||||
draw_polygon(Variant(poly), color);
|
||||
} else {
|
||||
int ps = poly.size();
|
||||
const Vector2 *r = poly.ptr();
|
||||
for (int i = 0; i < ps - 1; i++) {
|
||||
draw_line(r[i], r[i + 1], Color(0, 0, 0, 0.6), 3);
|
||||
case NOTIFICATION_VISIBILITY_CHANGED: {
|
||||
RS::get_singleton()->canvas_light_occluder_set_enabled(occluder, is_visible_in_tree());
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_DRAW: {
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
if (occluder_polygon.is_valid()) {
|
||||
Vector<Vector2> poly = occluder_polygon->get_polygon();
|
||||
|
||||
if (poly.size()) {
|
||||
if (occluder_polygon->is_closed()) {
|
||||
Vector<Color> color;
|
||||
color.push_back(Color(0, 0, 0, 0.6));
|
||||
draw_polygon(Variant(poly), color);
|
||||
} else {
|
||||
int ps = poly.size();
|
||||
const Vector2 *r = poly.ptr();
|
||||
for (int i = 0; i < ps - 1; i++) {
|
||||
draw_line(r[i], r[i + 1], Color(0, 0, 0, 0.6), 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
||||
if (p_what == NOTIFICATION_EXIT_CANVAS) {
|
||||
RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID());
|
||||
case NOTIFICATION_EXIT_CANVAS: {
|
||||
RS::get_singleton()->canvas_light_occluder_attach_to_canvas(occluder, RID());
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user