/**************************************************************************/1/* light_occluder_2d.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/2d/node_2d.h"3334class OccluderPolygon2D : public Resource {35GDCLASS(OccluderPolygon2D, Resource);3637public:38enum CullMode {39CULL_DISABLED,40CULL_CLOCKWISE,41CULL_COUNTER_CLOCKWISE42};4344private:45RID occ_polygon;46Vector<Vector2> polygon;47bool closed = true;48CullMode cull = CULL_DISABLED;4950mutable Rect2 item_rect;51mutable bool rect_cache_dirty = true;5253protected:54static void _bind_methods();5556public:57#ifdef DEBUG_ENABLED58virtual Rect2 _edit_get_rect() const;59virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const;60#endif // DEBUG_ENABLED61void set_polygon(const Vector<Vector2> &p_polygon);62Vector<Vector2> get_polygon() const;6364void set_closed(bool p_closed);65bool is_closed() const;6667void set_cull_mode(CullMode p_mode);68CullMode get_cull_mode() const;6970virtual RID get_rid() const override;71OccluderPolygon2D();72~OccluderPolygon2D();73};7475VARIANT_ENUM_CAST(OccluderPolygon2D::CullMode);7677class LightOccluder2D : public Node2D {78GDCLASS(LightOccluder2D, Node2D);7980RID occluder;81int mask = 1;82Ref<OccluderPolygon2D> occluder_polygon;83bool sdf_collision = false;84void _poly_changed();8586virtual void _physics_interpolated_changed() override;8788protected:89void _notification(int p_what);90static void _bind_methods();9192public:93#ifdef DEBUG_ENABLED94virtual Rect2 _edit_get_rect() const override;95virtual bool _edit_is_selected_on_click(const Point2 &p_point, double p_tolerance) const override;96#endif // DEBUG_ENABLED9798void set_occluder_polygon(const Ref<OccluderPolygon2D> &p_polygon);99Ref<OccluderPolygon2D> get_occluder_polygon() const;100101void set_occluder_light_mask(int p_mask);102int get_occluder_light_mask() const;103104void set_as_sdf_collision(bool p_enable);105bool is_set_as_sdf_collision() const;106107PackedStringArray get_configuration_warnings() const override;108109LightOccluder2D();110~LightOccluder2D();111};112113114