From df9099e0edaccc247899a69c125cbcda671b9145 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 6 Jun 2022 18:44:51 +0200 Subject: [PATCH] Added the MMAlgos class (and binding) to the build. Also set up it's singleton. --- modules/material_maker/SCsub | 17 ++++++++ .../material_maker/algos/mm_algos_bind.cpp | 1 + modules/material_maker/config.py | 18 ++++++++ modules/material_maker/register_types.cpp | 43 +++++++++++++++++++ modules/material_maker/register_types.h | 24 +++++++++++ 5 files changed, 103 insertions(+) create mode 100644 modules/material_maker/SCsub create mode 100644 modules/material_maker/config.py create mode 100644 modules/material_maker/register_types.cpp create mode 100644 modules/material_maker/register_types.h diff --git a/modules/material_maker/SCsub b/modules/material_maker/SCsub new file mode 100644 index 000000000..a80fc6de8 --- /dev/null +++ b/modules/material_maker/SCsub @@ -0,0 +1,17 @@ +import os + +Import('env') + +module_env = env.Clone() + + +sources = [ + "register_types.cpp", + + "algos/mm_algos.cpp", + "algos/mm_algos_bind.cpp", +] + + +module_env.add_source_files(env.modules_sources, sources) + diff --git a/modules/material_maker/algos/mm_algos_bind.cpp b/modules/material_maker/algos/mm_algos_bind.cpp index 3d44cba86..208caae8f 100644 --- a/modules/material_maker/algos/mm_algos_bind.cpp +++ b/modules/material_maker/algos/mm_algos_bind.cpp @@ -1,6 +1,7 @@ #include "mm_algos_bind.h" +#include "core/method_bind_ext.gen.inc" #include "mm_algos.h" Vector3 _MMAlgos::clampv3(const Vector3 &v, const Vector3 &mi, const Vector3 &ma) { diff --git a/modules/material_maker/config.py b/modules/material_maker/config.py new file mode 100644 index 000000000..8a2d70293 --- /dev/null +++ b/modules/material_maker/config.py @@ -0,0 +1,18 @@ + + +def can_build(env, platform): + return True + + +def configure(env): + pass + + +def get_doc_classes(): + return [ + "MMAlgos", + ] + +def get_doc_path(): + return "doc_classes" + diff --git a/modules/material_maker/register_types.cpp b/modules/material_maker/register_types.cpp new file mode 100644 index 000000000..0ff732581 --- /dev/null +++ b/modules/material_maker/register_types.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2022 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 "register_types.h" + +#include "core/engine.h" + +#include "algos/mm_algos.h" +#include "algos/mm_algos_bind.h" + +static _MMAlgos *_mm_algos_singleton = nullptr; + +void register_material_maker_types() { + ClassDB::register_class<_MMAlgos>(); + + _mm_algos_singleton = memnew(_MMAlgos); + Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton())); +} + +void unregister_material_maker_types() { + if (_mm_algos_singleton) { + memdelete(_mm_algos_singleton); + } +} diff --git a/modules/material_maker/register_types.h b/modules/material_maker/register_types.h new file mode 100644 index 000000000..71335cf0c --- /dev/null +++ b/modules/material_maker/register_types.h @@ -0,0 +1,24 @@ +/* +Copyright (c) 2022 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. +*/ + +void register_material_maker_types(); +void unregister_material_maker_types();