From a4a7949bc8ecf136c497825202f671a8e72ce246 Mon Sep 17 00:00:00 2001
From: Relintai <relintai@gmail.com>
Date: Sun, 5 Jul 2020 14:54:15 +0200
Subject: [PATCH] Moved PropDataMesh to the mesh data resource module.

---
 SCsub                     |  1 -
 config.py                 |  1 -
 props/prop_data.cpp       |  6 ++-
 props/prop_data.h         |  1 -
 props/prop_data_entry.cpp |  2 +-
 props/prop_data_entry.h   |  2 +-
 props/prop_data_mesh.cpp  | 78 ---------------------------------------
 props/prop_data_mesh.h    | 62 -------------------------------
 register_types.cpp        |  2 -
 9 files changed, 6 insertions(+), 149 deletions(-)
 delete mode 100644 props/prop_data_mesh.cpp
 delete mode 100644 props/prop_data_mesh.h

diff --git a/SCsub b/SCsub
index febb494..924b89f 100644
--- a/SCsub
+++ b/SCsub
@@ -17,7 +17,6 @@ sources = [
     "props/prop_data.cpp",
     "props/prop_data_entry.cpp",
     "props/prop_data_scene.cpp",
-    "props/prop_data_mesh.cpp",
     "props/prop_data_light.cpp",
     "props/prop_data_prop.cpp",
     "props/prop_data_entity.cpp",
diff --git a/config.py b/config.py
index 4e1a1b6..d4d3c60 100644
--- a/config.py
+++ b/config.py
@@ -13,7 +13,6 @@ def get_doc_classes():
         "PropDataEntity",
         "PropDataEntry",
         "PropDataLight",
-        "PropDataMesh",
         "PropDataProp",
         "PropDataScene",
         "PropData",
diff --git a/props/prop_data.cpp b/props/prop_data.cpp
index b2dff28..111df1b 100644
--- a/props/prop_data.cpp
+++ b/props/prop_data.cpp
@@ -93,13 +93,13 @@ void PropData::add_textures_into(Ref<TexturePacker> texture_packer) {
 
 	for (int i = 0; i < _props.size(); ++i) {
 		Ref<PropDataEntry> entry = _props.get(i);
-
+		/*
 		Ref<PropDataMesh> pmesh = entry;
 
 		if (pmesh.is_valid() && pmesh->get_texture().is_valid()) {
 			texture_packer->add_texture(pmesh->get_texture());
 		}
-
+*/
 		Ref<PropDataProp> pdataprop = entry;
 
 		if (pdataprop.is_valid() && pdataprop->get_prop().is_valid()) {
@@ -148,6 +148,7 @@ void PropData::add_prop_lights_into(Ref<VoxelChunk> chunk, Transform parent_tran
 }
 
 void PropData::add_meshes_into(Ref<VoxelMesher> mesher, Ref<TexturePacker> texture_packer, Transform parent_transform, Spatial *snap_spatial) {
+	/*
 	ERR_FAIL_COND(!mesher.is_valid());
 	ERR_FAIL_COND(!texture_packer.is_valid());
 	ERR_FAIL_COND(texture_packer->get_generated_texture_count() == 0);
@@ -192,6 +193,7 @@ void PropData::add_meshes_into(Ref<VoxelMesher> mesher, Ref<TexturePacker> textu
 				pdataprop->get_prop()->add_meshes_into(mesher, texture_packer, parent_transform * pmesh->get_transform(), snap_spatial);
 		}
 	}
+	*/
 }
 void PropData::add_meshes_into_bind(Ref<VoxelMesher> mesher, Ref<TexturePacker> texture_packer, Transform parent_transform, Node *snap_spatial) {
 	Spatial *s = Object::cast_to<Spatial>(snap_spatial);
diff --git a/props/prop_data.h b/props/prop_data.h
index 28d1e86..5d64469 100644
--- a/props/prop_data.h
+++ b/props/prop_data.h
@@ -33,7 +33,6 @@ SOFTWARE.
 #include "servers/physics_server.h"
 
 #include "prop_data_entry.h"
-#include "prop_data_mesh.h"
 
 #include "../../voxelman/meshers/voxel_mesher.h"
 
diff --git a/props/prop_data_entry.cpp b/props/prop_data_entry.cpp
index 4330e35..a87a2ba 100644
--- a/props/prop_data_entry.cpp
+++ b/props/prop_data_entry.cpp
@@ -25,7 +25,7 @@ SOFTWARE.
 Transform PropDataEntry::get_transform() const {
 	return _transform;
 }
-void PropDataEntry::set_transform(const Transform value) {
+void PropDataEntry::set_transform(const Transform &value) {
 	_transform = value;
 }
 
diff --git a/props/prop_data_entry.h b/props/prop_data_entry.h
index 0657162..80286a1 100644
--- a/props/prop_data_entry.h
+++ b/props/prop_data_entry.h
@@ -31,7 +31,7 @@ class PropDataEntry : public Resource {
 
 public:
 	Transform get_transform() const;
-	void set_transform(const Transform value);
+	void set_transform(const Transform &value);
 
 	PropDataEntry();
 	~PropDataEntry();
diff --git a/props/prop_data_mesh.cpp b/props/prop_data_mesh.cpp
deleted file mode 100644
index f5471aa..0000000
--- a/props/prop_data_mesh.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-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.
-*/
-
-#include "prop_data_mesh.h"
-
-Ref<MeshDataResource> PropDataMesh::get_mesh() const {
-	return _mesh;
-}
-void PropDataMesh::set_mesh(const Ref<MeshDataResource> mesh) {
-	_mesh = mesh;
-}
-
-Ref<Texture> PropDataMesh::get_texture() const {
-	return _texture;
-}
-void PropDataMesh::set_texture(const Ref<Texture> texture) {
-	_texture = texture;
-}
-
-bool PropDataMesh::get_snap_to_mesh() {
-	return _snap_to_mesh;
-}
-void PropDataMesh::set_snap_to_mesh(bool value) {
-	_snap_to_mesh = value;
-}
-
-Vector3 PropDataMesh::get_snap_axis() {
-	return _snap_axis;
-}
-void PropDataMesh::set_snap_axis(Vector3 value) {
-	_snap_axis = value;
-}
-
-PropDataMesh::PropDataMesh() {
-	_snap_to_mesh = true;
-	_snap_axis = Vector3(0, 1, 0);
-}
-PropDataMesh::~PropDataMesh() {
-	if (_mesh.is_valid())
-		_mesh.unref();
-}
-
-void PropDataMesh::_bind_methods() {
-	ClassDB::bind_method(D_METHOD("get_mesh"), &PropDataMesh::get_mesh);
-	ClassDB::bind_method(D_METHOD("set_mesh", "value"), &PropDataMesh::set_mesh);
-	ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh");
-
-	ClassDB::bind_method(D_METHOD("get_texture"), &PropDataMesh::get_texture);
-	ClassDB::bind_method(D_METHOD("set_texture", "value"), &PropDataMesh::set_texture);
-	ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
-
-	ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropDataMesh::get_snap_to_mesh);
-	ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataMesh::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"), &PropDataMesh::get_snap_axis);
-	ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataMesh::set_snap_axis);
-	ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
-}
diff --git a/props/prop_data_mesh.h b/props/prop_data_mesh.h
deleted file mode 100644
index 314f57a..0000000
--- a/props/prop_data_mesh.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-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 PROP_DATA_MESH_H
-#define PROP_DATA_MESH_H
-
-#include "core/math/vector3.h"
-#include "prop_data_entry.h"
-
-#include "scene/resources/texture.h"
-
-#include "../../mesh_data_resource/mesh_data_resource.h"
-
-class PropDataMesh : public PropDataEntry {
-	GDCLASS(PropDataMesh, PropDataEntry);
-
-public:
-	Ref<MeshDataResource> get_mesh() const;
-	void set_mesh(const Ref<MeshDataResource> mesh);
-
-	Ref<Texture> get_texture() const;
-	void set_texture(const Ref<Texture> texture);
-
-	bool get_snap_to_mesh();
-	void set_snap_to_mesh(bool value);
-
-	Vector3 get_snap_axis();
-	void set_snap_axis(Vector3 value);
-
-	PropDataMesh();
-	~PropDataMesh();
-
-protected:
-	static void _bind_methods();
-
-private:
-	bool _snap_to_mesh;
-	Vector3 _snap_axis;
-	Ref<MeshDataResource> _mesh;
-	Ref<Texture> _texture;
-};
-
-#endif
diff --git a/register_types.cpp b/register_types.cpp
index ee1acd9..a796e47 100644
--- a/register_types.cpp
+++ b/register_types.cpp
@@ -26,7 +26,6 @@ SOFTWARE.
 #include "props/prop_data_entity.h"
 #include "props/prop_data_entry.h"
 #include "props/prop_data_light.h"
-#include "props/prop_data_mesh.h"
 #include "props/prop_data_prop.h"
 #include "props/prop_data_scene.h"
 
@@ -51,7 +50,6 @@ void register_props_types() {
 	ClassDB::register_class<PropData>();
 	ClassDB::register_class<PropDataEntry>();
 	ClassDB::register_class<PropDataScene>();
-	ClassDB::register_class<PropDataMesh>();
 	ClassDB::register_class<PropDataLight>();
 	ClassDB::register_class<PropDataProp>();
 	ClassDB::register_class<PropDataEntity>();