mirror of
https://github.com/Relintai/props.git
synced 2024-11-12 10:15:25 +01:00
Removed PropDataProcessor, moved it's functionality into PropDataEntry.
This commit is contained in:
parent
b34a8f3996
commit
85670797de
2
SCsub
2
SCsub
@ -21,8 +21,6 @@ sources = [
|
||||
"props/prop_data_prop.cpp",
|
||||
"props/prop_data_entity.cpp",
|
||||
|
||||
"processor/prop_data_processor.cpp",
|
||||
|
||||
"clutter/ground_clutter.cpp",
|
||||
"clutter/ground_clutter_foliage.cpp",
|
||||
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
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 "prop_data_processor.h"
|
||||
|
||||
#include "scene/3d/spatial.h"
|
||||
|
||||
bool PropDataProcessor::handles(Node *node) {
|
||||
return call("_handles", node);
|
||||
}
|
||||
void PropDataProcessor::process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
|
||||
call("_process", prop_data, node, transform);
|
||||
}
|
||||
Node *PropDataProcessor::get_node_for(const Ref<PropData> &prop_data) {
|
||||
return call("_get_node_for", prop_data);
|
||||
}
|
||||
|
||||
bool PropDataProcessor::_handles(Node *node) {
|
||||
return false;
|
||||
}
|
||||
void PropDataProcessor::_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
|
||||
}
|
||||
Node *PropDataProcessor::_get_node_for(const Ref<PropData> &prop_data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PropDataProcessor::PropDataProcessor() {
|
||||
}
|
||||
PropDataProcessor::~PropDataProcessor() {
|
||||
}
|
||||
|
||||
void PropDataProcessor::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "handles"), "_handles"));
|
||||
BIND_VMETHOD(MethodInfo("_process",
|
||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"),
|
||||
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"),
|
||||
PropertyInfo(Variant::TRANSFORM, "transform")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "_get_node_for",
|
||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("handles", "node"), &PropDataProcessor::handles);
|
||||
ClassDB::bind_method(D_METHOD("process", "prop_data", "node", "transform"), &PropDataProcessor::process);
|
||||
ClassDB::bind_method(D_METHOD("get_node_for", "prop_data"), &PropDataProcessor::get_node_for);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_handles", "node"), &PropDataProcessor::_handles);
|
||||
ClassDB::bind_method(D_METHOD("_process", "prop_data", "node", "transform"), &PropDataProcessor::_process);
|
||||
ClassDB::bind_method(D_METHOD("_get_node_for", "prop_data"), &PropDataProcessor::_get_node_for);
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2019-2020 Péter Magyar
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef PROP_DATA_PROCESSOR_H
|
||||
#define PROP_DATA_PROCESSOR_H
|
||||
|
||||
#include "core/math/transform.h"
|
||||
#include "core/math/vector3.h"
|
||||
#include "core/reference.h"
|
||||
|
||||
#include "../props/prop_data.h"
|
||||
|
||||
class Spatial;
|
||||
|
||||
class PropDataProcessor : public Reference {
|
||||
GDCLASS(PropDataProcessor, Reference);
|
||||
|
||||
public:
|
||||
bool handles(Node *node);
|
||||
void process(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||
Node *get_node_for(const Ref<PropData> &prop_data);
|
||||
|
||||
virtual bool _handles(Node *node);
|
||||
virtual void _process(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||
virtual Node *_get_node_for(const Ref<PropData> &prop_data);
|
||||
|
||||
PropDataProcessor();
|
||||
~PropDataProcessor();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
};
|
||||
|
||||
#endif
|
@ -26,8 +26,6 @@ SOFTWARE.
|
||||
#include "prop_data_light.h"
|
||||
#include "prop_data_prop.h"
|
||||
|
||||
#include "../../voxelman/world/voxel_chunk.h"
|
||||
|
||||
int PropData::get_id() const {
|
||||
return _id;
|
||||
}
|
||||
|
@ -40,9 +40,6 @@ SOFTWARE.
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
#endif
|
||||
|
||||
class Spatial;
|
||||
class VoxelChunk;
|
||||
|
||||
class PropData : public Resource {
|
||||
GDCLASS(PropData, Resource);
|
||||
|
||||
|
@ -22,6 +22,9 @@ SOFTWARE.
|
||||
|
||||
#include "prop_data_entry.h"
|
||||
|
||||
#include "prop_data.h"
|
||||
#include "scene/3d/spatial.h"
|
||||
|
||||
Transform PropDataEntry::get_transform() const {
|
||||
return _transform;
|
||||
}
|
||||
@ -36,6 +39,25 @@ void PropDataEntry::add_textures_into(Ref<TexturePacker> texture_packer) {
|
||||
}
|
||||
#endif
|
||||
|
||||
bool PropDataEntry::processor_handles(Node *node) {
|
||||
return call("_processor_handles", node);
|
||||
}
|
||||
void PropDataEntry::processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
|
||||
call("_processor_process", prop_data, node, transform);
|
||||
}
|
||||
Node *PropDataEntry::processor_get_node_for(const Ref<PropData> &prop_data) {
|
||||
return call("_processor_get_node_for", prop_data);
|
||||
}
|
||||
|
||||
bool PropDataEntry::_processor_handles(Node *node) {
|
||||
return false;
|
||||
}
|
||||
void PropDataEntry::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
|
||||
}
|
||||
Node *PropDataEntry::_processor_get_node_for(const Ref<PropData> &prop_data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PropDataEntry::PropDataEntry() {
|
||||
}
|
||||
PropDataEntry::~PropDataEntry() {
|
||||
@ -51,4 +73,21 @@ void PropDataEntry::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_textures_into", "texture_packer"), &PropDataEntry::add_textures_into);
|
||||
#endif
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "handles"), "_processor_handles"));
|
||||
BIND_VMETHOD(MethodInfo("_processor_process",
|
||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"),
|
||||
PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"),
|
||||
PropertyInfo(Variant::TRANSFORM, "transform")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "_processor_get_node_for",
|
||||
PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("processor_handles", "node"), &PropDataEntry::processor_handles);
|
||||
ClassDB::bind_method(D_METHOD("processor_process", "prop_data", "node", "transform"), &PropDataEntry::processor_process);
|
||||
ClassDB::bind_method(D_METHOD("processor_get_node_for", "prop_data"), &PropDataEntry::processor_get_node_for);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_processor_handles", "node"), &PropDataEntry::_processor_handles);
|
||||
ClassDB::bind_method(D_METHOD("_processor_process", "prop_data", "node", "transform"), &PropDataEntry::_processor_process);
|
||||
ClassDB::bind_method(D_METHOD("_processor_get_node_for", "prop_data"), &PropDataEntry::_processor_get_node_for);
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ SOFTWARE.
|
||||
#include "../../texture_packer/texture_packer.h"
|
||||
#endif
|
||||
|
||||
class PropData;
|
||||
|
||||
class PropDataEntry : public Resource {
|
||||
GDCLASS(PropDataEntry, Resource);
|
||||
|
||||
@ -41,6 +43,14 @@ public:
|
||||
void add_textures_into(Ref<TexturePacker> texture_packer);
|
||||
#endif
|
||||
|
||||
bool processor_handles(Node *node);
|
||||
void processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||
Node *processor_get_node_for(const Ref<PropData> &prop_data);
|
||||
|
||||
virtual bool _processor_handles(Node *node);
|
||||
virtual void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||
virtual Node *_processor_get_node_for(const Ref<PropData> &prop_data);
|
||||
|
||||
PropDataEntry();
|
||||
~PropDataEntry();
|
||||
|
||||
|
@ -42,8 +42,6 @@ SOFTWARE.
|
||||
|
||||
#include "./editor/prop_editor_plugin.h"
|
||||
|
||||
#include "processor/prop_data_processor.h"
|
||||
|
||||
static PropUtils *prop_utils = NULL;
|
||||
|
||||
void register_props_types() {
|
||||
@ -54,8 +52,6 @@ void register_props_types() {
|
||||
ClassDB::register_class<PropDataProp>();
|
||||
ClassDB::register_class<PropDataEntity>();
|
||||
|
||||
ClassDB::register_class<PropDataProcessor>();
|
||||
|
||||
ClassDB::register_class<GroundClutter>();
|
||||
ClassDB::register_class<GroundClutterFoliage>();
|
||||
|
||||
|
@ -22,11 +22,11 @@ SOFTWARE.
|
||||
|
||||
#include "prop_utils.h"
|
||||
|
||||
#include "../processor/prop_data_processor.h"
|
||||
#include "../props/prop_data.h"
|
||||
#include "../props/prop_data_entry.h"
|
||||
|
||||
PropUtils *PropUtils::_instance;
|
||||
Vector<Ref<PropDataProcessor> > PropUtils::_processors;
|
||||
Vector<Ref<PropDataEntry> > PropUtils::_processors;
|
||||
|
||||
PropUtils *PropUtils::get_singleton() {
|
||||
return _instance;
|
||||
@ -48,12 +48,12 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(node));
|
||||
|
||||
for (int i = 0; i < PropUtils::_processors.size(); ++i) {
|
||||
Ref<PropDataProcessor> proc = PropUtils::_processors.get(i);
|
||||
Ref<PropDataEntry> proc = PropUtils::_processors.get(i);
|
||||
|
||||
ERR_CONTINUE(!proc.is_valid());
|
||||
|
||||
if (proc->handles(node)) {
|
||||
proc->process(prop_data, node, transform);
|
||||
if (proc->processor_handles(node)) {
|
||||
proc->processor_process(prop_data, node, transform);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -74,15 +74,15 @@ void PropUtils::_convert_tree(Ref<PropData> prop_data, Node *node, const Transfo
|
||||
}
|
||||
}
|
||||
|
||||
int PropUtils::add_processor(const Ref<PropDataProcessor> &processor) {
|
||||
int PropUtils::add_processor(const Ref<PropDataEntry> &processor) {
|
||||
ERR_FAIL_COND_V(!processor.is_valid(), 0);
|
||||
|
||||
PropUtils::_processors.push_back(processor);
|
||||
|
||||
return PropUtils::_processors.size() - 1;
|
||||
}
|
||||
Ref<PropDataProcessor> PropUtils::get_processor(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, PropUtils::_processors.size(), Ref<PropDataProcessor>());
|
||||
Ref<PropDataEntry> PropUtils::get_processor(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, PropUtils::_processors.size(), Ref<PropDataEntry>());
|
||||
|
||||
return PropUtils::_processors[index];
|
||||
}
|
||||
@ -90,7 +90,7 @@ void PropUtils::swap_processors(const int index1, const int index2) {
|
||||
ERR_FAIL_INDEX(index1, PropUtils::_processors.size());
|
||||
ERR_FAIL_INDEX(index2, PropUtils::_processors.size());
|
||||
|
||||
Ref<PropDataProcessor> a = PropUtils::_processors.get(index1);
|
||||
Ref<PropDataEntry> a = PropUtils::_processors.get(index1);
|
||||
PropUtils::_processors.set(index1, PropUtils::_processors.get(index2));
|
||||
PropUtils::_processors.set(index2, a);
|
||||
}
|
||||
@ -123,10 +123,10 @@ void PropUtils::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_processor_count"), &PropUtils::_get_processor_count_bind);
|
||||
}
|
||||
|
||||
int PropUtils::_add_processor_bind(const Ref<PropDataProcessor> &processor) {
|
||||
int PropUtils::_add_processor_bind(const Ref<PropDataEntry> &processor) {
|
||||
return PropUtils::add_processor(processor);
|
||||
}
|
||||
Ref<PropDataProcessor> PropUtils::_get_processor_bind(const int index) {
|
||||
Ref<PropDataEntry> PropUtils::_get_processor_bind(const int index) {
|
||||
return PropUtils::get_processor(index);
|
||||
}
|
||||
void PropUtils::_swap_processors_bind(const int index1, const int index2) {
|
||||
|
@ -29,8 +29,8 @@ SOFTWARE.
|
||||
|
||||
#include "core/reference.h"
|
||||
|
||||
class PropDataProcessor;
|
||||
class PropData;
|
||||
class PropDataEntry;
|
||||
|
||||
class PropUtils : public Object {
|
||||
GDCLASS(PropUtils, Object);
|
||||
@ -41,8 +41,8 @@ public:
|
||||
Ref<PropData> convert_tree(Node *root);
|
||||
void _convert_tree(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||
|
||||
static int add_processor(const Ref<PropDataProcessor> &processor);
|
||||
static Ref<PropDataProcessor> get_processor(const int index);
|
||||
static int add_processor(const Ref<PropDataEntry> &processor);
|
||||
static Ref<PropDataEntry> get_processor(const int index);
|
||||
static void swap_processors(const int index1, const int index2);
|
||||
static void remove_processor(const int index);
|
||||
static int get_processor_count();
|
||||
@ -54,13 +54,13 @@ protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _add_processor_bind(const Ref<PropDataProcessor> &processor);
|
||||
Ref<PropDataProcessor> _get_processor_bind(const int index);
|
||||
int _add_processor_bind(const Ref<PropDataEntry> &processor);
|
||||
Ref<PropDataEntry> _get_processor_bind(const int index);
|
||||
void _swap_processors_bind(const int index1, const int index2);
|
||||
void _remove_processor_bind(const int index);
|
||||
int _get_processor_count_bind();
|
||||
|
||||
static Vector<Ref<PropDataProcessor> > _processors;
|
||||
static Vector<Ref<PropDataEntry> > _processors;
|
||||
static PropUtils *_instance;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user