mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-31 08:07:13 +01:00
Added VertexLight2D Node.
This commit is contained in:
parent
e6fcd72b66
commit
26ca3d7235
@ -119,7 +119,7 @@
|
||||
</member>
|
||||
<member name="UserDB" type="UserDB" setter="" getter="">
|
||||
</member>
|
||||
<member name="VertexLights2D" type="VertexLights2D" setter="" getter="">
|
||||
<member name="VertexLights2DServer" type="VertexLights2DServer" setter="" getter="">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
|
@ -7,3 +7,4 @@ module_env = env.Clone()
|
||||
module_env.add_source_files(env.modules_sources,"register_types.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"vertex_lights_2d_server.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"vertex_light_data.cpp")
|
||||
module_env.add_source_files(env.modules_sources,"vertex_light_2d.cpp")
|
||||
|
@ -11,6 +11,7 @@ def configure(env):
|
||||
def get_doc_classes():
|
||||
return [
|
||||
"VertexLights2DServer",
|
||||
"VertexLight2D",
|
||||
]
|
||||
|
||||
def get_doc_path():
|
||||
|
31
modules/vertex_lights_2d/doc_classes/VertexLight2D.xml
Normal file
31
modules/vertex_lights_2d/doc_classes/VertexLight2D.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="VertexLight2D" inherits="Node2D" version="4.3">
|
||||
<brief_description>
|
||||
</brief_description>
|
||||
<description>
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )">
|
||||
</member>
|
||||
<member name="item_cull_mask" type="int" setter="set_item_cull_mask" getter="get_item_cull_mask" default="1">
|
||||
</member>
|
||||
<member name="layer_range" type="Vector2i" setter="set_layer_range" getter="get_layer_range" default="Vector2i( 0, 0 )">
|
||||
</member>
|
||||
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="VertexLight2D.VertexLight2DMode" default="0">
|
||||
</member>
|
||||
<member name="z_range" type="Vector2i" setter="set_z_range" getter="get_z_range" default="Vector2i( -1024, 1024 )">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="VERTEX_LIGHT_2D_MODE_ADD" value="0" enum="VertexLight2DMode">
|
||||
</constant>
|
||||
<constant name="VERTEX_LIGHT_2D_MODE_SUB" value="1" enum="VertexLight2DMode">
|
||||
</constant>
|
||||
<constant name="VERTEX_LIGHT_2D_MODE_MIX" value="2" enum="VertexLight2DMode">
|
||||
</constant>
|
||||
</constants>
|
||||
</class>
|
@ -48,7 +48,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="light_get_mode">
|
||||
<return type="int" enum="VertexLights2D.VertexLight2DMode" />
|
||||
<return type="int" enum="VertexLights2DServer.VertexLight2DMode" />
|
||||
<argument index="0" name="light" type="RID" />
|
||||
<description>
|
||||
</description>
|
||||
@ -96,7 +96,7 @@
|
||||
<method name="light_set_mode">
|
||||
<return type="void" />
|
||||
<argument index="0" name="light" type="RID" />
|
||||
<argument index="1" name="mode" type="int" enum="VertexLights2D.VertexLight2DMode" />
|
||||
<argument index="1" name="mode" type="int" enum="VertexLights2DServer.VertexLight2DMode" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
|
@ -34,15 +34,22 @@
|
||||
#include "core/config/engine.h"
|
||||
|
||||
#include "vertex_lights_2d_server.h"
|
||||
#include "vertex_light_2d.h"
|
||||
|
||||
VertexLights2DServer *vertex_lights_2d_server = NULL;
|
||||
|
||||
void register_vertex_lights_2d_types(ModuleRegistrationLevel p_level) {
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) {
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
|
||||
vertex_lights_2d_server = memnew(VertexLights2DServer);
|
||||
ClassDB::register_class<VertexLights2DServer>();
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("VertexLights2DServer", VertexLights2DServer::get_singleton()));
|
||||
}
|
||||
|
||||
|
||||
if (p_level == MODULE_REGISTRATION_LEVEL_SCENE) {
|
||||
ClassDB::register_class<VertexLight2D>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void unregister_vertex_lights_2d_types(ModuleRegistrationLevel p_level) {
|
||||
|
105
modules/vertex_lights_2d/vertex_light_2d.cpp
Normal file
105
modules/vertex_lights_2d/vertex_light_2d.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
/*************************************************************************/
|
||||
/* vertex_light_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. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "vertex_light_2d.h"
|
||||
|
||||
Color VertexLight2D::get_color() {
|
||||
return _color;
|
||||
}
|
||||
void VertexLight2D::set_color(const Color &p_color) {
|
||||
_color = p_color;
|
||||
}
|
||||
|
||||
VertexLight2D::VertexLight2DMode VertexLight2D::get_mode() {
|
||||
return _mode;
|
||||
}
|
||||
void VertexLight2D::set_mode(const VertexLight2D::VertexLight2DMode p_mode) {
|
||||
_mode = p_mode;
|
||||
}
|
||||
|
||||
Vector2i VertexLight2D::get_z_range() {
|
||||
return _z_range;
|
||||
}
|
||||
void VertexLight2D::set_z_range(const Vector2i &p_z_range) {
|
||||
_z_range = p_z_range;
|
||||
}
|
||||
|
||||
Vector2i VertexLight2D::get_layer_range() {
|
||||
return _layer_range;
|
||||
}
|
||||
void VertexLight2D::set_layer_range(const Vector2i &p_layer_range) {
|
||||
_layer_range = p_layer_range;
|
||||
}
|
||||
|
||||
int VertexLight2D::get_item_cull_mask() {
|
||||
return _item_cull_mask;
|
||||
}
|
||||
void VertexLight2D::set_item_cull_mask(const int p_item_cull_mask) {
|
||||
_item_cull_mask = p_item_cull_mask;
|
||||
}
|
||||
|
||||
VertexLight2D::VertexLight2D() {
|
||||
_vertex_light = RID_PRIME(VertexLights2DServer::get_singleton()->light_create());
|
||||
|
||||
_item_cull_mask = 1;
|
||||
_z_range = Vector2i(-1024, 1024);
|
||||
_mode = VERTEX_LIGHT_2D_MODE_ADD;
|
||||
}
|
||||
|
||||
VertexLight2D::~VertexLight2D() {
|
||||
VertexLights2DServer::get_singleton()->free(_vertex_light);
|
||||
}
|
||||
|
||||
void VertexLight2D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_color"), &VertexLight2D::get_color);
|
||||
ClassDB::bind_method(D_METHOD("set_color", "color"), &VertexLight2D::set_color);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_mode"), &VertexLight2D::get_mode);
|
||||
ClassDB::bind_method(D_METHOD("set_mode", "mode"), &VertexLight2D::set_mode);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Add,Sub,Mix,Mask"), "set_mode", "get_mode");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_z_range"), &VertexLight2D::get_z_range);
|
||||
ClassDB::bind_method(D_METHOD("set_z_range", "z_range"), &VertexLight2D::set_z_range);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "z_range", PROPERTY_HINT_RANGE, itos(RS::CANVAS_ITEM_Z_MIN) + "," + itos(RS::CANVAS_ITEM_Z_MAX) + ",1"), "set_z_range", "get_z_range");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_layer_range"), &VertexLight2D::get_layer_range);
|
||||
ClassDB::bind_method(D_METHOD("set_layer_range", "layer_range"), &VertexLight2D::set_layer_range);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2I, "layer_range", PROPERTY_HINT_RANGE, "-512,512,1"), "set_layer_range", "get_layer_range");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_item_cull_mask"), &VertexLight2D::get_item_cull_mask);
|
||||
ClassDB::bind_method(D_METHOD("set_item_cull_mask", "item_cull_mask"), &VertexLight2D::set_item_cull_mask);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "item_cull_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_item_cull_mask", "get_item_cull_mask");
|
||||
|
||||
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_ADD);
|
||||
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_SUB);
|
||||
BIND_ENUM_CONSTANT(VERTEX_LIGHT_2D_MODE_MIX);
|
||||
}
|
87
modules/vertex_lights_2d/vertex_light_2d.h
Normal file
87
modules/vertex_lights_2d/vertex_light_2d.h
Normal file
@ -0,0 +1,87 @@
|
||||
#ifndef VERTEX_LIGHT_2D_H
|
||||
#define VERTEX_LIGHT_2D_H
|
||||
|
||||
/*************************************************************************/
|
||||
/* vertex_2d.h */
|
||||
/*************************************************************************/
|
||||
/* 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. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "scene/main/node_2d.h"
|
||||
|
||||
#include "core/containers/hash_map.h"
|
||||
#include "core/containers/vector.h"
|
||||
#include "core/math/color.h"
|
||||
#include "core/math/vector2i.h"
|
||||
|
||||
#include "vertex_lights_2d_server.h"
|
||||
|
||||
class VertexLight2D : public Node2D {
|
||||
GDCLASS(VertexLight2D, Node2D);
|
||||
|
||||
public:
|
||||
enum VertexLight2DMode {
|
||||
VERTEX_LIGHT_2D_MODE_ADD = VertexLights2DServer::VERTEX_LIGHT_2D_MODE_ADD,
|
||||
VERTEX_LIGHT_2D_MODE_SUB = VertexLights2DServer::VERTEX_LIGHT_2D_MODE_SUB,
|
||||
VERTEX_LIGHT_2D_MODE_MIX = VertexLights2DServer::VERTEX_LIGHT_2D_MODE_MIX,
|
||||
//VERTEX_LIGHT_2D_MODE_MASK = VertexLights2DServer::VERTEX_LIGHT_2D_MODE_MASK
|
||||
};
|
||||
|
||||
Color get_color();
|
||||
void set_color(const Color &p_color);
|
||||
|
||||
VertexLight2D::VertexLight2DMode get_mode();
|
||||
void set_mode(const VertexLight2D::VertexLight2DMode p_mode);
|
||||
|
||||
Vector2i get_z_range();
|
||||
void set_z_range(const Vector2i &p_z_range);
|
||||
|
||||
Vector2i get_layer_range();
|
||||
void set_layer_range(const Vector2i &p_layer_range);
|
||||
|
||||
int get_item_cull_mask();
|
||||
void set_item_cull_mask(const int p_item_cull_mask);
|
||||
|
||||
VertexLight2D();
|
||||
~VertexLight2D();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
RID _vertex_light;
|
||||
|
||||
Color _color;
|
||||
VertexLight2DMode _mode;
|
||||
Vector2i _z_range;
|
||||
Vector2i _layer_range;
|
||||
int _item_cull_mask;
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(VertexLight2D::VertexLight2DMode);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user