Processor for PropDataProp.

This commit is contained in:
Relintai 2020-07-06 20:54:05 +02:00
parent c76a6c7282
commit 59a874bd68
3 changed files with 37 additions and 0 deletions

View File

@ -22,6 +22,9 @@ SOFTWARE.
#include "prop_data_prop.h" #include "prop_data_prop.h"
#include "../prop_instance.h"
#include "prop_data.h"
Ref<PropData> PropDataProp::get_prop() const { Ref<PropData> PropDataProp::get_prop() const {
return _prop; return _prop;
} }
@ -51,6 +54,33 @@ void PropDataProp::_add_textures_into(Ref<TexturePacker> texture_packer) {
} }
#endif #endif
bool PropDataProp::_processor_handles(Node *node) {
PropInstance *i = Object::cast_to<PropInstance>(node);
return i;
}
void PropDataProp::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
PropInstance *i = Object::cast_to<PropInstance>(node);
ERR_FAIL_COND(!i);
Ref<PropDataProp> l;
l.instance();
l->set_prop(i->get_prop_data());
l->set_transform(transform * i->get_transform());
prop_data->add_prop(l);
}
Node *PropDataProp::_processor_get_node_for(const Transform &transform) {
PropInstance *i = memnew(PropInstance);
i->set_prop_data(get_prop());
i->set_transform(get_transform());
return i;
}
PropDataProp::PropDataProp() { PropDataProp::PropDataProp() {
_snap_to_mesh = false; _snap_to_mesh = false;
_snap_axis = Vector3(0, 1, 0); _snap_axis = Vector3(0, 1, 0);

View File

@ -49,6 +49,10 @@ public:
void _add_textures_into(Ref<TexturePacker> texture_packer); void _add_textures_into(Ref<TexturePacker> texture_packer);
#endif #endif
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);
PropDataProp(); PropDataProp();
~PropDataProp(); ~PropDataProp();

View File

@ -68,6 +68,9 @@ void register_props_types() {
Ref<PropDataLight> light_processor = Ref<PropDataLight>(memnew(PropDataLight)); Ref<PropDataLight> light_processor = Ref<PropDataLight>(memnew(PropDataLight));
PropUtils::add_processor(light_processor); PropUtils::add_processor(light_processor);
Ref<PropDataProp> prop_processor = Ref<PropDataProp>(memnew(PropDataProp));
PropUtils::add_processor(prop_processor);
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<PropEditorPlugin>(); EditorPlugins::add_by_type<PropEditorPlugin>();
#endif #endif