diff --git a/SCsub b/SCsub index 622d246..7480615 100644 --- a/SCsub +++ b/SCsub @@ -11,7 +11,7 @@ module_env = env.Clone() sources = [ "register_types.cpp", - + "mesh_utils.cpp", "fast_quadratic_mesh_simplifier.cpp", ] diff --git a/mesh_utils.cpp b/mesh_utils.cpp new file mode 100644 index 0000000..de44320 --- /dev/null +++ b/mesh_utils.cpp @@ -0,0 +1,40 @@ +/* +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, EXPRMeshUtils OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNMeshUtils 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 "mesh_utils.h" + +MeshUtils *MeshUtils::_instance; + +MeshUtils *MeshUtils::get_singleton() { + return _instance; +} + +MeshUtils::MeshUtils() { + _instance = this; +} + +MeshUtils::~MeshUtils() { + _instance = NULL; +} + +void MeshUtils::_bind_methods() { +} diff --git a/mesh_utils.h b/mesh_utils.h new file mode 100644 index 0000000..d0800d9 --- /dev/null +++ b/mesh_utils.h @@ -0,0 +1,44 @@ +/* +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 MESH_UTILS_H +#define MESH_UTILS_H + +#include "core/object.h" + +class MeshUtils : public Object { + GDCLASS(MeshUtils, Object); + +public: + static MeshUtils *get_singleton(); + + MeshUtils(); + ~MeshUtils(); + +protected: + static void _bind_methods(); + +private: + static MeshUtils *_instance; +}; + +#endif diff --git a/register_types.cpp b/register_types.cpp index 4ae2dc1..c9d3031 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -1,7 +1,3 @@ -#include "register_types.h" - -#include "fast_quadratic_mesh_simplifier.h" - /* Copyright (c) 2020 Péter Magyar @@ -26,9 +22,24 @@ SOFTWARE. */ +#include "register_types.h" + +#include "core/engine.h" +#include "fast_quadratic_mesh_simplifier.h" +#include "mesh_utils.h" + +static MeshUtils *mesh_utils = NULL; + void register_mesh_utils_types() { ClassDB::register_class(); + + mesh_utils = memnew(MeshUtils); + ClassDB::register_class(); + Engine::get_singleton()->add_singleton(Engine::Singleton("MeshUtils", MeshUtils::get_singleton())); } void unregister_mesh_utils_types() { + if (mesh_utils) { + memdelete(mesh_utils); + } }