mirror of
https://github.com/Relintai/mesh_data_resource.git
synced 2024-11-12 10:15:21 +01:00
Update for Prop module's Processor removal.
This commit is contained in:
parent
6567ebe225
commit
1746de7130
1
SCsub
1
SCsub
@ -22,5 +22,4 @@ module_env.add_source_files(env.modules_sources,"plugin_gltf/editor_plugin_gltf_
|
|||||||
|
|
||||||
module_env.add_source_files(env.modules_sources,"nodes/mesh_data_instance.cpp")
|
module_env.add_source_files(env.modules_sources,"nodes/mesh_data_instance.cpp")
|
||||||
|
|
||||||
module_env.add_source_files(env.modules_sources,"props/mesh_data_instance_processor.cpp")
|
|
||||||
module_env.add_source_files(env.modules_sources,"props/prop_data_mesh_data.cpp")
|
module_env.add_source_files(env.modules_sources,"props/prop_data_mesh_data.cpp")
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
#include "mesh_data_instance_processor.h"
|
|
||||||
|
|
||||||
#if PROPS_PRESENT
|
|
||||||
|
|
||||||
#include "../nodes/mesh_data_instance.h"
|
|
||||||
#include "prop_data_mesh_data.h"
|
|
||||||
|
|
||||||
bool MeshDataInstanceProcessor::_handles(Node *node) {
|
|
||||||
MeshDataInstance *i = Object::cast_to<MeshDataInstance>(node);
|
|
||||||
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MeshDataInstanceProcessor::_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
|
|
||||||
MeshDataInstance *i = Object::cast_to<MeshDataInstance>(node);
|
|
||||||
|
|
||||||
ERR_FAIL_COND(!i);
|
|
||||||
|
|
||||||
Ref<PropDataMeshData> m;
|
|
||||||
m.instance();
|
|
||||||
m->set_mesh(i->get_mesh_data());
|
|
||||||
m->set_texture(i->get_texture());
|
|
||||||
m->set_transform(transform * i->get_transform());
|
|
||||||
prop_data->add_prop(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
MeshDataInstanceProcessor::MeshDataInstanceProcessor() {
|
|
||||||
}
|
|
||||||
MeshDataInstanceProcessor::~MeshDataInstanceProcessor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void MeshDataInstanceProcessor::_bind_methods() {
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,57 +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_MESH_DATA_INSTANCE_PROCESSOR_H
|
|
||||||
#define PROP_MESH_DATA_INSTANCE_PROCESSOR_H
|
|
||||||
|
|
||||||
#if PROPS_PRESENT
|
|
||||||
|
|
||||||
#include "../../props/processor/prop_data_processor.h"
|
|
||||||
|
|
||||||
#include "core/version.h"
|
|
||||||
#include "scene/resources/texture.h"
|
|
||||||
|
|
||||||
#include "core/math/vector3.h"
|
|
||||||
|
|
||||||
#include "../mesh_data_resource.h"
|
|
||||||
|
|
||||||
class PropInstance;
|
|
||||||
|
|
||||||
class MeshDataInstanceProcessor : public PropDataProcessor {
|
|
||||||
GDCLASS(MeshDataInstanceProcessor, PropDataProcessor);
|
|
||||||
|
|
||||||
public:
|
|
||||||
bool _handles(Node *node);
|
|
||||||
void _process(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
|
||||||
|
|
||||||
MeshDataInstanceProcessor();
|
|
||||||
~MeshDataInstanceProcessor();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -24,6 +24,8 @@ SOFTWARE.
|
|||||||
|
|
||||||
#if PROPS_PRESENT
|
#if PROPS_PRESENT
|
||||||
|
|
||||||
|
#include "../nodes/mesh_data_instance.h"
|
||||||
|
|
||||||
Ref<MeshDataResource> PropDataMeshData::get_mesh() const {
|
Ref<MeshDataResource> PropDataMeshData::get_mesh() const {
|
||||||
return _mesh;
|
return _mesh;
|
||||||
}
|
}
|
||||||
@ -60,6 +62,25 @@ void PropDataMeshData::_add_textures_into(Ref<TexturePacker> texture_packer) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool PropDataMeshData::_processor_handles(Node *node) {
|
||||||
|
MeshDataInstance *i = Object::cast_to<MeshDataInstance>(node);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropDataMeshData::_processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform) {
|
||||||
|
MeshDataInstance *i = Object::cast_to<MeshDataInstance>(node);
|
||||||
|
|
||||||
|
ERR_FAIL_COND(!i);
|
||||||
|
|
||||||
|
Ref<PropDataMeshData> m;
|
||||||
|
m.instance();
|
||||||
|
m->set_mesh(i->get_mesh_data());
|
||||||
|
m->set_texture(i->get_texture());
|
||||||
|
m->set_transform(transform * i->get_transform());
|
||||||
|
prop_data->add_prop(m);
|
||||||
|
}
|
||||||
|
|
||||||
PropDataMeshData::PropDataMeshData() {
|
PropDataMeshData::PropDataMeshData() {
|
||||||
_snap_to_mesh = false;
|
_snap_to_mesh = false;
|
||||||
_snap_axis = Vector3(0, 1, 0);
|
_snap_axis = Vector3(0, 1, 0);
|
||||||
|
@ -36,6 +36,8 @@ SOFTWARE.
|
|||||||
#include "../../texture_packer/texture_packer.h"
|
#include "../../texture_packer/texture_packer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../../props/props/prop_data.h"
|
||||||
|
|
||||||
class PropDataMeshData : public PropDataEntry {
|
class PropDataMeshData : public PropDataEntry {
|
||||||
GDCLASS(PropDataMeshData, PropDataEntry);
|
GDCLASS(PropDataMeshData, PropDataEntry);
|
||||||
|
|
||||||
@ -56,6 +58,9 @@ public:
|
|||||||
void _add_textures_into(Ref<TexturePacker> texture_packer);
|
void _add_textures_into(Ref<TexturePacker> texture_packer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool _processor_handles(Node *node);
|
||||||
|
void _processor_process(Ref<PropData> prop_data, Node *node, const Transform &transform);
|
||||||
|
|
||||||
PropDataMeshData();
|
PropDataMeshData();
|
||||||
~PropDataMeshData();
|
~PropDataMeshData();
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ SOFTWARE.
|
|||||||
|
|
||||||
#if PROPS_PRESENT
|
#if PROPS_PRESENT
|
||||||
#include "../props/singleton/prop_utils.h"
|
#include "../props/singleton/prop_utils.h"
|
||||||
#include "props/mesh_data_instance_processor.h"
|
|
||||||
#include "props/prop_data_mesh_data.h"
|
#include "props/prop_data_mesh_data.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -46,8 +45,7 @@ void register_mesh_data_resource_types() {
|
|||||||
|
|
||||||
#if PROPS_PRESENT
|
#if PROPS_PRESENT
|
||||||
ClassDB::register_class<PropDataMeshData>();
|
ClassDB::register_class<PropDataMeshData>();
|
||||||
ClassDB::register_class<MeshDataInstanceProcessor>();
|
Ref<PropDataMeshData> processor = Ref<PropDataMeshData>(memnew(PropDataMeshData));
|
||||||
Ref<PropDataProcessor> processor = memnew(MeshDataInstanceProcessor);
|
|
||||||
PropUtils::add_processor(processor);
|
PropUtils::add_processor(processor);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user