mirror of
https://github.com/Relintai/props.git
synced 2024-11-12 10:15:25 +01:00
Implement processing PropDatalights.
This commit is contained in:
parent
27b9ec75c0
commit
c76a6c7282
@ -22,6 +22,9 @@ SOFTWARE.
|
||||
|
||||
#include "prop_data_light.h"
|
||||
|
||||
#include "prop_data.h"
|
||||
#include "scene/3d/light.h"
|
||||
|
||||
Color PropDataLight::get_light_color() const {
|
||||
return _light_color;
|
||||
}
|
||||
@ -36,8 +39,37 @@ void PropDataLight::set_light_size(const int 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() {
|
||||
_light_size = 5;
|
||||
_light_size = 0;
|
||||
}
|
||||
PropDataLight::~PropDataLight() {
|
||||
}
|
||||
|
@ -37,6 +37,10 @@ public:
|
||||
int get_light_size() const;
|
||||
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();
|
||||
|
||||
|
@ -65,6 +65,9 @@ void register_props_types() {
|
||||
ClassDB::register_class<PropUtils>();
|
||||
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
|
||||
EditorPlugins::add_by_type<PropEditorPlugin>();
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user