diff --git a/SCsub b/SCsub index 3f40a79..252994a 100644 --- a/SCsub +++ b/SCsub @@ -30,7 +30,6 @@ sources = [ "prop_instance.cpp", "prop_ess_entity.cpp", - "prop_mesh_data_instance.cpp", "prop_instance_job.cpp", ] diff --git a/config.py b/config.py index 1647ae4..8424c8c 100644 --- a/config.py +++ b/config.py @@ -23,7 +23,6 @@ def get_doc_classes(): "PropESSEntity", "PropInstance", - "PropMeshDataInstance", "PropMeshUtils", ] diff --git a/prop_instance.cpp b/prop_instance.cpp index 6e6e337..8a4ff9e 100644 --- a/prop_instance.cpp +++ b/prop_instance.cpp @@ -1,6 +1,6 @@ #include "prop_instance.h" -#include "prop_mesh_data_instance.h" +#include "../mesh_data_resource/nodes/mesh_data_instance.h" #include "../thread_pool/thread_pool.h" @@ -25,7 +25,7 @@ void PropInstance::set_snap_axis(const Vector3 &value) { _snap_axis = value; } -void PropInstance::register_prop_mesh_data_instance(PropMeshDataInstance *instance) { +void PropInstance::register_prop_mesh_data_instance(MeshDataInstance *instance) { ERR_FAIL_COND(!ObjectDB::instance_validate(instance)); _mesh_data_instances.push_back(instance); @@ -34,7 +34,7 @@ void PropInstance::register_prop_mesh_data_instance(PropMeshDataInstance *instan queue_bake(); } -void PropInstance::unregister_prop_mesh_data_instance(PropMeshDataInstance *instance) { +void PropInstance::unregister_prop_mesh_data_instance(MeshDataInstance *instance) { ERR_FAIL_COND(!ObjectDB::instance_validate(instance)); _mesh_data_instances.erase(instance); @@ -50,7 +50,7 @@ void PropInstance::bake() { _job->clear(); for (int i = 0; i < _mesh_data_instances.size(); ++i) { - PropMeshDataInstance *md = _mesh_data_instances.get(i); + MeshDataInstance *md = _mesh_data_instances.get(i); ERR_CONTINUE(!ObjectDB::instance_validate(md)); diff --git a/prop_instance.h b/prop_instance.h index 81c1264..5d67170 100644 --- a/prop_instance.h +++ b/prop_instance.h @@ -37,7 +37,7 @@ SOFTWARE. #include "prop_instance_job.h" -class PropMeshDataInstance; +class MeshDataInstance; class PropInstance : public Spatial { GDCLASS(PropInstance, Spatial); @@ -53,8 +53,8 @@ public: Vector3 get_snap_axis() const; void set_snap_axis(const Vector3 &value); - void register_prop_mesh_data_instance(PropMeshDataInstance *instance); - void unregister_prop_mesh_data_instance(PropMeshDataInstance *instance); + void register_prop_mesh_data_instance(MeshDataInstance *instance); + void unregister_prop_mesh_data_instance(MeshDataInstance *instance); void bake(); void queue_bake(); @@ -72,7 +72,7 @@ private: bool _baking; bool _snap_to_mesh; Vector3 _snap_axis; - Vector _mesh_data_instances; + Vector _mesh_data_instances; Ref _job; }; diff --git a/prop_mesh_data_instance.cpp b/prop_mesh_data_instance.cpp deleted file mode 100644 index 734b3c7..0000000 --- a/prop_mesh_data_instance.cpp +++ /dev/null @@ -1,92 +0,0 @@ -#include "prop_mesh_data_instance.h" - -#include "prop_instance.h" - -bool PropMeshDataInstance::get_snap_to_mesh() const { - return _snap_to_mesh; -} -void PropMeshDataInstance::set_snap_to_mesh(const bool value) { - _snap_to_mesh = value; -} - -Vector3 PropMeshDataInstance::get_snap_axis() const { - return _snap_axis; -} -void PropMeshDataInstance::set_snap_axis(const Vector3 &value) { - _snap_axis = value; -} - -Ref PropMeshDataInstance::get_mesh() { - return _mesh; -} -void PropMeshDataInstance::set_mesh(const Ref &mesh) { - _mesh = mesh; -} - -Ref PropMeshDataInstance::get_texture() { - return _texture; -} -void PropMeshDataInstance::set_texture(const Ref &texture) { - _texture = texture; -} - -PropMeshDataInstance::PropMeshDataInstance() { - _snap_to_mesh = false; - _snap_axis = Vector3(0, -1, 0); -} -PropMeshDataInstance::~PropMeshDataInstance() { - _mesh.unref(); - _texture.unref(); -} - -void PropMeshDataInstance::notification(int p_what) { - switch (p_what) { - case NOTIFICATION_READY: { - if (get_parent() == NULL) - return; - } - //fallthrough - case NOTIFICATION_PARENTED: { - Node *n = this; - - while (n) { - - PropInstance *pi = Object::cast_to(n); - - if (pi) { - _owner = pi; - pi->register_prop_mesh_data_instance(this); - return; - } - - n = n->get_parent(); - } - - } break; - case NOTIFICATION_EXIT_TREE: - case NOTIFICATION_UNPARENTED: { - if (_owner) { - _owner->unregister_prop_mesh_data_instance(this); - } - break; - } - } -} - -void PropMeshDataInstance::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropMeshDataInstance::get_snap_to_mesh); - ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropMeshDataInstance::set_snap_to_mesh); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh"); - - ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropMeshDataInstance::get_snap_axis); - ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropMeshDataInstance::set_snap_axis); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); - - ClassDB::bind_method(D_METHOD("get_mesh"), &PropMeshDataInstance::get_mesh); - ClassDB::bind_method(D_METHOD("set_mesh", "value"), &PropMeshDataInstance::set_mesh); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh"); - - ClassDB::bind_method(D_METHOD("get_texture"), &PropMeshDataInstance::get_texture); - ClassDB::bind_method(D_METHOD("set_texture", "value"), &PropMeshDataInstance::set_texture); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture"); -} diff --git a/prop_mesh_data_instance.h b/prop_mesh_data_instance.h deleted file mode 100644 index 55e4497..0000000 --- a/prop_mesh_data_instance.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -Copyright (c) 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_MESH_DATA_INSTANCE_H -#define PROP_MESH_DATA_INSTANCE_H - -#include "core/version.h" -#include "scene/resources/texture.h" - -#if VERSION_MAJOR < 4 -#include "scene/3d/spatial.h" -#else -#include "scene/3d/node_3d.h" - -#define Spatial Node3D -#define Texture Texture2D -#endif - -#include "core/math/vector3.h" - -#if MESH_DATA_RESOURCE_PRESENT -#include "../mesh_data_resource/mesh_data_resource.h" -#else -#define MeshDataResource ArrayMesh -#endif - -class PropInstance; - -class PropMeshDataInstance : public Spatial { - GDCLASS(PropMeshDataInstance, Spatial); - OBJ_CATEGORY("Props"); - -public: - bool get_snap_to_mesh() const; - void set_snap_to_mesh(const bool value); - - Vector3 get_snap_axis() const; - void set_snap_axis(const Vector3 &value); - - Ref get_mesh(); - void set_mesh(const Ref &mesh); - - Ref get_texture(); - void set_texture(const Ref &texture); - - PropMeshDataInstance(); - ~PropMeshDataInstance(); - -protected: - void notification(int p_what); - static void _bind_methods(); - -private: - bool _snap_to_mesh; - Vector3 _snap_axis; - Ref _mesh; - Ref _texture; - PropInstance *_owner; -}; - -#endif diff --git a/register_types.cpp b/register_types.cpp index 95d4d85..a81fb83 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -37,7 +37,6 @@ SOFTWARE. #include "prop_ess_entity.h" #include "prop_instance.h" -#include "prop_mesh_data_instance.h" #include "prop_instance_job.h" @@ -58,7 +57,6 @@ void register_props_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); }