Implement processing PropDatalights.

This commit is contained in:
Relintai 2020-07-06 20:46:00 +02:00
parent 27b9ec75c0
commit c76a6c7282
3 changed files with 40 additions and 1 deletions

View File

@ -22,6 +22,9 @@ SOFTWARE.
#include "prop_data_light.h" #include "prop_data_light.h"
#include "prop_data.h"
#include "scene/3d/light.h"
Color PropDataLight::get_light_color() const { Color PropDataLight::get_light_color() const {
return _light_color; return _light_color;
} }
@ -36,8 +39,37 @@ void PropDataLight::set_light_size(const int value) {
_light_size = value; _light_size = value;
} }
bool PropDataLight::_processor_handles(Node *node) {
OmniLight *i = Object::cast_to<OmniLight>(node);
return i;
}
void PropDataLight::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
OmniLight *i = Object::cast_to<OmniLight>(node);
ERR_FAIL_COND(!i);
Ref<PropDataLight> l;
l.instance();
l->set_light_color(i->get_color());
l->set_light_size(i->get_param(Light::PARAM_RANGE));
l->set_transform(transform * i->get_transform());
prop_data->add_prop(l);
}
Node *PropDataLight::_processor_get_node_for(const Transform &transform) {
OmniLight *i = memnew(OmniLight);
i->set_color(get_light_color());
i->set_param(Light::PARAM_RANGE, get_light_size());
i->set_transform(get_transform());
return i;
}
PropDataLight::PropDataLight() { PropDataLight::PropDataLight() {
_light_size = 5; _light_size = 0;
} }
PropDataLight::~PropDataLight() { PropDataLight::~PropDataLight() {
} }

View File

@ -37,6 +37,10 @@ public:
int get_light_size() const; int get_light_size() const;
void set_light_size(const int value); void set_light_size(const int value);
bool _processor_handles(Node *node);
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
Node *_processor_get_node_for(const Transform &transform);
PropDataLight(); PropDataLight();
~PropDataLight(); ~PropDataLight();

View File

@ -65,6 +65,9 @@ void register_props_types() {
ClassDB::register_class<PropUtils>(); ClassDB::register_class<PropUtils>();
Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("PropUtils", PropUtils::get_singleton()));
Ref<PropDataLight> light_processor = Ref<PropDataLight>(memnew(PropDataLight));
PropUtils::add_processor(light_processor);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<PropEditorPlugin>(); EditorPlugins::add_by_type<PropEditorPlugin>();
#endif #endif