2024-03-24 17:11:10 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* vertex_lights_2d.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* PANDEMONIUM ENGINE */
|
|
|
|
/* https://github.com/Relintai/pandemonium_engine */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* Copyright (c) 2022-present Péter Magyar. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
|
|
|
/* Copyright (c) 2007-2022 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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
#include "vertex_lights_2d_server.h"
|
2024-03-24 17:11:10 +01:00
|
|
|
|
2024-03-24 18:02:13 +01:00
|
|
|
#include "core/config/project_settings.h"
|
|
|
|
|
2024-03-26 12:11:00 +01:00
|
|
|
#include "scene/main/scene_tree.h"
|
|
|
|
|
2024-03-24 20:57:35 +01:00
|
|
|
// Defaults
|
2024-03-24 21:19:33 +01:00
|
|
|
Vector2i VertexLights2DServer::get_default_quadrant_size() const {
|
2024-03-24 20:57:35 +01:00
|
|
|
return _default_quadrant_size;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::set_default_quadrant_size(const Vector2i &p_size) {
|
2024-03-24 20:57:35 +01:00
|
|
|
_default_quadrant_size = p_size;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 20:57:35 +01:00
|
|
|
// Maps
|
2024-03-24 21:19:33 +01:00
|
|
|
RID VertexLights2DServer::map_create() {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightMap2D *map = memnew(VertexLightMap2D);
|
|
|
|
RID rid = map_owner.make_rid(map);
|
|
|
|
map->self = rid;
|
2024-03-26 13:24:46 +01:00
|
|
|
map->quadrant_size = _default_quadrant_size;
|
2024-03-24 20:57:35 +01:00
|
|
|
return rid;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
Vector2i VertexLights2DServer::map_get_quadrant_size(RID p_map) const {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightMap2D *map = map_owner.getornull(p_map);
|
|
|
|
ERR_FAIL_COND_V(map == NULL, Vector2i());
|
|
|
|
|
|
|
|
return map->quadrant_size;
|
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::map_set_quadrant_size(RID p_map, const Vector2i &p_size) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightMap2D *map = map_owner.getornull(p_map);
|
|
|
|
ERR_FAIL_COND(map == NULL);
|
|
|
|
|
|
|
|
map->quadrant_size = p_size;
|
|
|
|
map->recreate_quadrants();
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_map_changed(map);
|
2024-03-24 20:57:35 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
Array VertexLights2DServer::map_get_lights(RID p_map) const {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightMap2D *map = map_owner.getornull(p_map);
|
|
|
|
ERR_FAIL_COND_V(map == NULL, Array());
|
|
|
|
|
|
|
|
List<VertexLightData2D *> lights;
|
|
|
|
map->get_lights(&lights);
|
|
|
|
|
|
|
|
Array arr;
|
|
|
|
|
|
|
|
arr.resize(lights.size());
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (List<VertexLightData2D *>::Element *E = lights.front(); E; E = E->next()) {
|
|
|
|
arr[i++] = E->get()->self;
|
|
|
|
}
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::map_clear(RID p_map) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightMap2D *map = map_owner.getornull(p_map);
|
|
|
|
ERR_FAIL_COND(map == NULL);
|
|
|
|
|
|
|
|
map->clear();
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_map_changed(map);
|
2024-03-24 20:57:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Lights
|
2024-03-24 21:19:33 +01:00
|
|
|
RID VertexLights2DServer::light_create() {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = memnew(VertexLightData2D);
|
|
|
|
RID rid = light_owner.make_rid(light);
|
|
|
|
light->self = rid;
|
|
|
|
return rid;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
RID VertexLights2DServer::light_get_map(RID p_light) {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, RID());
|
|
|
|
|
|
|
|
if (!light->map) {
|
|
|
|
return RID();
|
|
|
|
}
|
|
|
|
|
|
|
|
return light->map->self;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::light_set_map(RID p_light, RID p_map) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
VertexLightMap2D *map = map_owner.getornull(p_map);
|
|
|
|
|
|
|
|
if (light->map) {
|
2024-03-26 12:11:00 +01:00
|
|
|
_light_changed(light);
|
2024-03-24 20:57:35 +01:00
|
|
|
light->map->remove_light(light);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map) {
|
|
|
|
map->add_light(light);
|
2024-03-26 12:11:00 +01:00
|
|
|
_light_changed(light);
|
2024-03-24 20:57:35 +01:00
|
|
|
}
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 22:05:00 +01:00
|
|
|
bool VertexLights2DServer::light_get_is_enabled(RID p_light) {
|
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, false);
|
|
|
|
|
|
|
|
return light->enabled;
|
|
|
|
}
|
|
|
|
void VertexLights2DServer::light_set_enabled(RID p_light, const bool p_enabled) {
|
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
2024-03-26 12:14:45 +01:00
|
|
|
|
|
|
|
if (light->enabled == p_enabled) {
|
|
|
|
return;
|
|
|
|
}
|
2024-03-24 22:05:00 +01:00
|
|
|
|
|
|
|
light->enabled = p_enabled;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-24 22:05:00 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
Vector2 VertexLights2DServer::light_get_position(RID p_light) {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, Vector2());
|
|
|
|
|
|
|
|
return light->position;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::light_set_position(RID p_light, const Vector2 &p_position) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
if (light->map) {
|
|
|
|
// This ensure the light gets moved to the proper quadrant
|
|
|
|
light->map->set_light_position(light, p_position);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
light->position = p_position;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-25 21:55:27 +01:00
|
|
|
Vector2i VertexLights2DServer::light_get_range(RID p_light) {
|
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, Vector2i());
|
|
|
|
|
|
|
|
return light->range;
|
|
|
|
}
|
|
|
|
void VertexLights2DServer::light_set_range(RID p_light, const Vector2i &p_range) {
|
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
light->range = p_range;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-25 21:55:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
real_t VertexLights2DServer::light_get_attenuation(RID p_light) {
|
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, 0);
|
|
|
|
|
|
|
|
return light->attenuation;
|
|
|
|
}
|
|
|
|
void VertexLights2DServer::light_set_attenuation(RID p_light, const real_t p_attenuation) {
|
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
light->attenuation = p_attenuation;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-25 21:55:27 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
Color VertexLights2DServer::light_get_color(RID p_light) {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, Color());
|
|
|
|
|
|
|
|
return light->color;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::light_set_color(RID p_light, const Color &p_color) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
light->color = p_color;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
VertexLights2DServer::VertexLight2DMode VertexLights2DServer::light_get_mode(RID p_light) {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
2024-03-24 21:19:33 +01:00
|
|
|
ERR_FAIL_COND_V(light == NULL, VertexLights2DServer::VERTEX_LIGHT_2D_MODE_ADD);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
|
|
|
return light->mode;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::light_set_mode(RID p_light, const VertexLights2DServer::VertexLight2DMode p_mode) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
light->mode = p_mode;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
Vector2i VertexLights2DServer::light_get_z_range(RID p_light) {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, Vector2i());
|
|
|
|
|
|
|
|
return light->z_range;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::light_set_z_range(RID p_light, const Vector2i &p_z_range) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
light->z_range = p_z_range;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
Vector2i VertexLights2DServer::light_get_layer_range(RID p_light) {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, Vector2i());
|
|
|
|
|
|
|
|
return light->layer_range;
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::light_set_layer_range(RID p_light, const Vector2i &p_layer_range) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
light->layer_range = p_layer_range;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-24 20:57:35 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
int VertexLights2DServer::light_get_item_cull_mask(RID p_light) {
|
2024-03-24 20:57:35 +01:00
|
|
|
const VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND_V(light == NULL, 0);
|
|
|
|
|
|
|
|
return light->item_cull_mask;
|
|
|
|
}
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::light_set_item_cull_mask(RID p_light, const int p_item_cull_mask) {
|
2024-03-24 20:57:35 +01:00
|
|
|
VertexLightData2D *light = light_owner.getornull(p_light);
|
|
|
|
ERR_FAIL_COND(light == NULL);
|
|
|
|
|
|
|
|
light->item_cull_mask = p_item_cull_mask;
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_light_changed(light);
|
2024-03-24 20:57:35 +01:00
|
|
|
}
|
|
|
|
|
2024-03-26 06:47:28 +01:00
|
|
|
// Sampling
|
|
|
|
|
|
|
|
Color VertexLights2DServer::sample_light(RID p_map, const Vector2 &p_position, const int p_item_cull_mask, const int p_layer) {
|
|
|
|
VertexLightMap2D *map = map_owner.getornull(p_map);
|
|
|
|
ERR_FAIL_COND_V(map == NULL, Color());
|
2024-03-26 12:11:00 +01:00
|
|
|
|
2024-03-26 06:47:28 +01:00
|
|
|
return map->sample_light(p_position, p_item_cull_mask, p_layer);
|
|
|
|
}
|
|
|
|
|
2024-03-24 20:57:35 +01:00
|
|
|
// Rest
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::free(RID p_rid) {
|
2024-03-24 20:57:35 +01:00
|
|
|
if (!p_rid.is_valid()) {
|
|
|
|
ERR_FAIL_MSG("Invalid RID.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (map_owner.owns(p_rid)) {
|
|
|
|
VertexLightMap2D *map = map_owner.get(p_rid);
|
|
|
|
|
|
|
|
map->clear();
|
|
|
|
map->self = RID();
|
|
|
|
|
|
|
|
map_owner.free(p_rid);
|
|
|
|
memdelete(map);
|
|
|
|
} else if (light_owner.owns(p_rid)) {
|
|
|
|
VertexLightData2D *light = light_owner.get(p_rid);
|
|
|
|
|
|
|
|
if (light->map) {
|
2024-03-26 12:11:00 +01:00
|
|
|
_light_changed(light);
|
2024-03-24 20:57:35 +01:00
|
|
|
light->map->remove_light(light);
|
|
|
|
}
|
2024-03-24 22:05:00 +01:00
|
|
|
|
2024-03-24 20:57:35 +01:00
|
|
|
light->self = RID();
|
|
|
|
|
|
|
|
light_owner.free(p_rid);
|
|
|
|
memdelete(light);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
ERR_FAIL_MSG("Invalid RID.");
|
|
|
|
}
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-26 12:11:00 +01:00
|
|
|
void VertexLights2DServer::init() {
|
|
|
|
if (SceneTree::get_singleton()) {
|
|
|
|
SceneTree::get_singleton()->add_idle_callback(VertexLights2DServer::_scene_tree_idle_callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexLights2DServer::finalize() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void VertexLights2DServer::flush_notifications() {
|
|
|
|
for (HashSet<RID>::Iterator iter = _changed_maps.begin(); iter; ++iter) {
|
|
|
|
emit_signal(_map_changed_name, iter.key());
|
|
|
|
}
|
|
|
|
|
|
|
|
_changed_maps.clear();
|
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
VertexLights2DServer::VertexLights2DServer() {
|
2024-03-24 17:11:10 +01:00
|
|
|
ERR_FAIL_COND(_self);
|
|
|
|
|
|
|
|
_self = this;
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 18:02:13 +01:00
|
|
|
GLOBAL_DEF("vertex_lights_2d/default_quadrant_size", Vector2i(256, 256));
|
|
|
|
_default_quadrant_size = GLOBAL_GET("vertex_lights_2d/default_quadrant_size");
|
2024-03-26 12:11:00 +01:00
|
|
|
|
|
|
|
_map_changed_name = "map_changed";
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
VertexLights2DServer::~VertexLights2DServer() {
|
2024-03-24 17:11:10 +01:00
|
|
|
_self = NULL;
|
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
void VertexLights2DServer::_bind_methods() {
|
2024-03-26 12:11:00 +01:00
|
|
|
ADD_SIGNAL(MethodInfo("map_changed", PropertyInfo(Variant::RID, "map")));
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("get_default_quadrant_size"), &VertexLights2DServer::get_default_quadrant_size);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_default_quadrant_size", "size"), &VertexLights2DServer::set_default_quadrant_size);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("map_create"), &VertexLights2DServer::map_create);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("map_get_quadrant_size", "map"), &VertexLights2DServer::map_get_quadrant_size);
|
|
|
|
ClassDB::bind_method(D_METHOD("map_set_quadrant_size", "map", "size"), &VertexLights2DServer::map_set_quadrant_size);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("map_get_lights", "map"), &VertexLights2DServer::map_get_lights);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("map_clear", "map"), &VertexLights2DServer::map_clear);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
|
|
|
// Lights
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_create"), &VertexLights2DServer::light_create);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_map", "light"), &VertexLights2DServer::light_get_map);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_map", "light", "map"), &VertexLights2DServer::light_set_map);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 22:05:00 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_is_enabled", "light"), &VertexLights2DServer::light_get_is_enabled);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_enabled", "light", "enabled"), &VertexLights2DServer::light_set_enabled);
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_position", "light"), &VertexLights2DServer::light_get_position);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_position", "light", "position"), &VertexLights2DServer::light_set_position);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-25 21:55:27 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_range", "light"), &VertexLights2DServer::light_get_range);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_range", "light", "range"), &VertexLights2DServer::light_set_range);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("light_get_attenuation", "light"), &VertexLights2DServer::light_get_attenuation);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_attenuation", "light", "attenuation"), &VertexLights2DServer::light_set_attenuation);
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_color", "light"), &VertexLights2DServer::light_get_color);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &VertexLights2DServer::light_set_color);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_mode", "light"), &VertexLights2DServer::light_get_mode);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_mode", "light", "mode"), &VertexLights2DServer::light_set_mode);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_z_range", "light"), &VertexLights2DServer::light_get_z_range);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_z_range", "light", "z_range"), &VertexLights2DServer::light_set_z_range);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_layer_range", "light"), &VertexLights2DServer::light_get_layer_range);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_layer_range", "light", "layer_range"), &VertexLights2DServer::light_set_layer_range);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("light_get_item_cull_mask", "light"), &VertexLights2DServer::light_get_item_cull_mask);
|
|
|
|
ClassDB::bind_method(D_METHOD("light_set_item_cull_mask", "light", "item_cull_mask"), &VertexLights2DServer::light_set_item_cull_mask);
|
2024-03-26 12:11:00 +01:00
|
|
|
|
2024-03-26 06:47:28 +01:00
|
|
|
// Sampling
|
2024-03-26 12:11:00 +01:00
|
|
|
|
2024-03-26 06:47:28 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("sample_light", "map", "position", "item_cull_mask", "layer"), &VertexLights2DServer::sample_light, DEFVAL(1), DEFVAL(0));
|
2024-03-24 20:57:35 +01:00
|
|
|
|
|
|
|
// Rest
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("free", "rid"), &VertexLights2DServer::free);
|
2024-03-24 20:57:35 +01:00
|
|
|
|
2024-03-26 12:11:00 +01:00
|
|
|
ClassDB::bind_method(D_METHOD("flush_notifications"), &VertexLights2DServer::flush_notifications);
|
|
|
|
|
2024-03-24 20:57:35 +01:00
|
|
|
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_ADD);
|
|
|
|
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_SUB);
|
|
|
|
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_MIX);
|
2024-03-24 17:11:10 +01:00
|
|
|
}
|
|
|
|
|
2024-03-24 21:19:33 +01:00
|
|
|
VertexLights2DServer *VertexLights2DServer::_self = NULL;
|