Moved PropDataMesh to the mesh data resource module.

This commit is contained in:
Relintai 2020-07-05 14:54:15 +02:00
parent d6d034b8e9
commit a4a7949bc8
9 changed files with 6 additions and 149 deletions

1
SCsub
View File

@ -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",

View File

@ -13,7 +13,6 @@ def get_doc_classes():
"PropDataEntity",
"PropDataEntry",
"PropDataLight",
"PropDataMesh",
"PropDataProp",
"PropDataScene",
"PropData",

View File

@ -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);

View File

@ -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"

View File

@ -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;
}

View File

@ -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();

View File

@ -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");
}

View File

@ -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

View File

@ -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>();