mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-14 14:41:15 +01:00
Added Material and merger support for PropDataMergeGroup.
This commit is contained in:
parent
5ae8d147f0
commit
e63a88836c
@ -7,7 +7,35 @@
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="material_add">
|
||||
<return type="void" />
|
||||
<argument index="0" name="value" type="Material" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="material_get">
|
||||
<return type="Material" />
|
||||
<argument index="0" name="index" type="int" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="material_get_num" qualifiers="const">
|
||||
<return type="int" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="materials_clear">
|
||||
<return type="void" />
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="is_merger" type="bool" setter="set_is_merger" getter="get_is_merger" default="false">
|
||||
</member>
|
||||
<member name="materials" type="Array" setter="materials_set" getter="materials_get" default="[ ]">
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
||||
|
@ -31,10 +31,72 @@
|
||||
|
||||
#include "prop_merge_group.h"
|
||||
|
||||
#include "scene/resources/material/material.h"
|
||||
|
||||
//Materials
|
||||
Ref<Material> PropMergeGroup::material_get(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _materials.size(), Ref<Material>(NULL));
|
||||
|
||||
return _materials[index];
|
||||
}
|
||||
|
||||
void PropMergeGroup::material_add(const Ref<Material> &value) {
|
||||
ERR_FAIL_COND(!value.is_valid());
|
||||
|
||||
_materials.push_back(value);
|
||||
}
|
||||
|
||||
int PropMergeGroup::material_get_num() const {
|
||||
return _materials.size();
|
||||
}
|
||||
|
||||
void PropMergeGroup::materials_clear() {
|
||||
_materials.clear();
|
||||
}
|
||||
|
||||
Vector<Variant> PropMergeGroup::materials_get() {
|
||||
Vector<Variant> r;
|
||||
for (int i = 0; i < _materials.size(); i++) {
|
||||
r.push_back(_materials[i].get_ref_ptr());
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void PropMergeGroup::materials_set(const Vector<Variant> &materials) {
|
||||
_materials.clear();
|
||||
|
||||
for (int i = 0; i < materials.size(); i++) {
|
||||
Ref<Material> material = Ref<Material>(materials[i]);
|
||||
|
||||
_materials.push_back(material);
|
||||
}
|
||||
}
|
||||
|
||||
bool PropMergeGroup::get_is_merger() {
|
||||
return _is_merger;
|
||||
}
|
||||
void PropMergeGroup::set_is_merger(bool value) {
|
||||
_is_merger = value;
|
||||
}
|
||||
|
||||
PropMergeGroup::PropMergeGroup() {
|
||||
_is_merger = false;
|
||||
}
|
||||
PropMergeGroup::~PropMergeGroup() {
|
||||
}
|
||||
|
||||
void PropMergeGroup::_bind_methods() {
|
||||
///Materials
|
||||
ClassDB::bind_method(D_METHOD("material_get", "index"), &PropMergeGroup::material_get);
|
||||
ClassDB::bind_method(D_METHOD("material_add", "value"), &PropMergeGroup::material_add);
|
||||
ClassDB::bind_method(D_METHOD("material_get_num"), &PropMergeGroup::material_get_num);
|
||||
ClassDB::bind_method(D_METHOD("materials_clear"), &PropMergeGroup::materials_clear);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("materials_get"), &PropMergeGroup::materials_get);
|
||||
ClassDB::bind_method(D_METHOD("materials_set"), &PropMergeGroup::materials_set);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "23/20:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_is_merger"), &PropMergeGroup::get_is_merger);
|
||||
ClassDB::bind_method(D_METHOD("set_is_merger", "value"), &PropMergeGroup::set_is_merger);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_merger"), "set_is_merger", "get_is_merger");
|
||||
}
|
||||
|
@ -39,15 +39,32 @@
|
||||
#include "props/prop_data.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
class Material;
|
||||
|
||||
class PropMergeGroup : public Spatial {
|
||||
GDCLASS(PropMergeGroup, Spatial);
|
||||
|
||||
public:
|
||||
///Materials
|
||||
Ref<Material> material_get(const int index);
|
||||
void material_add(const Ref<Material> &value);
|
||||
int material_get_num() const;
|
||||
void materials_clear();
|
||||
|
||||
Vector<Variant> materials_get();
|
||||
void materials_set(const Vector<Variant> &materials);
|
||||
|
||||
bool get_is_merger();
|
||||
void set_is_merger(bool value);
|
||||
|
||||
PropMergeGroup();
|
||||
~PropMergeGroup();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
bool _is_merger;
|
||||
Vector<Ref<Material>> _materials;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -59,6 +59,9 @@ void PropDataMergeGroup::_processor_process(Ref<PropData> prop_data, Node *node,
|
||||
l.instance();
|
||||
l->set_prop(d);
|
||||
l->set_transform(transform * g->get_transform());
|
||||
l->materials_set(g->materials_get());
|
||||
l->set_is_merger(g->get_is_merger());
|
||||
|
||||
prop_data->add_prop(l);
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
bool _processor_handles(Node *node);
|
||||
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||
bool _processor_evaluate_children();
|
||||
|
||||
|
||||
PropDataMergeGroup();
|
||||
~PropDataMergeGroup();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user