diff --git a/modules/props/SCsub b/modules/props/SCsub index d25ced7e7..2afa62f4d 100644 --- a/modules/props/SCsub +++ b/modules/props/SCsub @@ -23,6 +23,7 @@ sources = [ "props/prop_data_tiled_wall.cpp", "props/prop_data_collision_object.cpp", "props/prop_data_static_body.cpp", + "props/prop_data_merge_group.cpp", "clutter/ground_clutter.cpp", "clutter/ground_clutter_foliage.cpp", @@ -32,6 +33,7 @@ sources = [ "prop_ess_entity.cpp", "prop_instance_job.cpp", "prop_instance_prop_job.cpp", + "prop_merge_group.cpp", "prop_scene_instance.cpp", diff --git a/modules/props/config.py b/modules/props/config.py index 4d62fe4b2..ecc3cd48c 100644 --- a/modules/props/config.py +++ b/modules/props/config.py @@ -19,6 +19,7 @@ def get_doc_classes(): "PropData", "PropDataCollisionObject", "PropDataStaticBody", + "PropDataMergeGroup", "TiledWall", "TiledWallData", @@ -33,6 +34,7 @@ def get_doc_classes(): "PropMeshUtils", "PropSceneInstance", + "PropMergeGroup", "PropUtils", diff --git a/modules/props/prop_merge_group.cpp b/modules/props/prop_merge_group.cpp new file mode 100644 index 000000000..4c89679ea --- /dev/null +++ b/modules/props/prop_merge_group.cpp @@ -0,0 +1,40 @@ +/*************************************************************************/ +/* prop_merge_group.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://github.com/Relintai/pandemonium_engine */ +/*************************************************************************/ +/* Copyright (c) 2022-present Péter Magyar. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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_merge_group.h" + +PropMergeGroup::PropMergeGroup() { +} +PropMergeGroup::~PropMergeGroup() { +} + +void PropMergeGroup::_bind_methods() { +} diff --git a/modules/props/prop_merge_group.h b/modules/props/prop_merge_group.h new file mode 100644 index 000000000..1e6be0c85 --- /dev/null +++ b/modules/props/prop_merge_group.h @@ -0,0 +1,53 @@ +#ifndef PROP_MERGE_GROUP_H +#define PROP_MERGE_GROUP_H + +/*************************************************************************/ +/* prop_merge_group.h */ +/*************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://github.com/Relintai/pandemonium_engine */ +/*************************************************************************/ +/* Copyright (c) 2022-present Péter Magyar. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 "scene/main/spatial.h" + +#include "core/math/vector3.h" + +#include "props/prop_data.h" +#include "scene/resources/packed_scene.h" + +class PropMergeGroup : public Spatial { + GDCLASS(PropMergeGroup, Spatial); + +public: + PropMergeGroup(); + ~PropMergeGroup(); + +protected: + static void _bind_methods(); +}; + +#endif diff --git a/modules/props/props/prop_data_merge_group.cpp b/modules/props/props/prop_data_merge_group.cpp new file mode 100644 index 000000000..2ac82f882 --- /dev/null +++ b/modules/props/props/prop_data_merge_group.cpp @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* prop_data_merge_group.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://github.com/Relintai/pandemonium_engine */ +/*************************************************************************/ +/* Copyright (c) 2022-present Péter Magyar. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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_merge_group.h" + +#include "../prop_instance.h" +#include "../prop_merge_group.h" +#include "../singleton/prop_utils.h" +#include "prop_data.h" + +#include "modules/modules_enabled.gen.h" + +bool PropDataMergeGroup::_processor_handles(Node *node) { + PropMergeGroup *g = Object::cast_to(node); + + return g; +} + +void PropDataMergeGroup::_processor_process(Ref prop_data, Node *node, const Transform &transform) { + PropMergeGroup *g = Object::cast_to(node); + + if (g) { + Ref d; + d.instance(); + + for (int i = 0; i < g->get_child_count(); ++i) { + PropUtils::get_singleton()->_convert_tree(d, g->get_child(i), Transform()); + } + + Ref l; + l.instance(); + l->set_prop(d); + l->set_transform(transform * g->get_transform()); + prop_data->add_prop(l); + } +} + +bool PropDataMergeGroup::_processor_evaluate_children() { + return false; +} + +PropDataMergeGroup::PropDataMergeGroup() { +} + +PropDataMergeGroup::~PropDataMergeGroup() { +} + +void PropDataMergeGroup::_bind_methods() { +} diff --git a/modules/props/props/prop_data_merge_group.h b/modules/props/props/prop_data_merge_group.h new file mode 100644 index 000000000..1bc39548a --- /dev/null +++ b/modules/props/props/prop_data_merge_group.h @@ -0,0 +1,61 @@ +#ifndef PROP_DATA_MERGE_GROUP_H +#define PROP_DATA_MERGE_GROUP_H + +/*************************************************************************/ +/* prop_data_merge_group.h */ +/*************************************************************************/ +/* This file is part of: */ +/* PANDEMONIUM ENGINE */ +/* https://github.com/Relintai/pandemonium_engine */ +/*************************************************************************/ +/* Copyright (c) 2022-present Péter Magyar. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* */ +/* 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 "core/math/vector3.h" +#include "prop_data_entry.h" + +#include "prop_data_prop.h" + +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_TEXTURE_PACKER_ENABLED +#include "../../texture_packer/texture_packer.h" +#endif + +class PropDataMergeGroup : public PropDataProp { + GDCLASS(PropDataMergeGroup, PropDataProp); + +public: + bool _processor_handles(Node *node); + void _processor_process(Ref prop_data, Node *node, const Transform &transform); + bool _processor_evaluate_children(); + + PropDataMergeGroup(); + ~PropDataMergeGroup(); + +protected: + static void _bind_methods(); +}; + +#endif diff --git a/modules/props/props/prop_data_prop.cpp b/modules/props/props/prop_data_prop.cpp index 71ed27c76..179471fc2 100644 --- a/modules/props/props/prop_data_prop.cpp +++ b/modules/props/props/prop_data_prop.cpp @@ -74,13 +74,15 @@ bool PropDataProp::_processor_handles(Node *node) { void PropDataProp::_processor_process(Ref prop_data, Node *node, const Transform &transform) { PropInstance *i = Object::cast_to(node); - ERR_FAIL_COND(!i); + if (i) { + Ref l; + l.instance(); + l->set_prop(i->get_prop_data()); + l->set_transform(transform * i->get_transform()); + prop_data->add_prop(l); - Ref l; - l.instance(); - l->set_prop(i->get_prop_data()); - l->set_transform(transform * i->get_transform()); - prop_data->add_prop(l); + return; + } } Node *PropDataProp::_processor_get_node_for(const Transform &transform) { @@ -96,6 +98,7 @@ PropDataProp::PropDataProp() { _snap_to_mesh = false; _snap_axis = Vector3(0, 1, 0); } + PropDataProp::~PropDataProp() { if (_prop.is_valid()) _prop.unref(); diff --git a/modules/props/props/prop_data_static_body.h b/modules/props/props/prop_data_static_body.h index 7d4693c3d..1ff48a071 100644 --- a/modules/props/props/prop_data_static_body.h +++ b/modules/props/props/prop_data_static_body.h @@ -32,28 +32,6 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -/* -Copyright (c) 2023-present 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_collision_object.h" class PhysicsMaterial; diff --git a/modules/props/register_types.cpp b/modules/props/register_types.cpp index a8dbd87e8..96af2d4fb 100644 --- a/modules/props/register_types.cpp +++ b/modules/props/register_types.cpp @@ -40,6 +40,7 @@ #include "props/prop_data_collision_object.h" #include "props/prop_data_entry.h" #include "props/prop_data_light.h" +#include "props/prop_data_merge_group.h" #include "props/prop_data_prop.h" #include "props/prop_data_scene.h" #include "props/prop_data_static_body.h" @@ -53,6 +54,7 @@ #include "prop_ess_entity.h" #include "prop_instance.h" #include "prop_instance_merger.h" +#include "prop_merge_group.h" #include "prop_instance_job.h" #include "prop_instance_prop_job.h" @@ -107,6 +109,7 @@ void register_props_types(ModuleRegistrationLevel p_level) { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); @@ -127,6 +130,7 @@ void register_props_types(ModuleRegistrationLevel p_level) { ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); @@ -151,6 +155,9 @@ void register_props_types(ModuleRegistrationLevel p_level) { Ref static_body_processor = Ref(memnew(PropDataStaticBody)); PropUtils::add_processor(static_body_processor); + + Ref merge_group_processor = Ref(memnew(PropDataMergeGroup)); + PropUtils::add_processor(merge_group_processor); } #ifdef TOOLS_ENABLED