Renamed PropDataMesh to PropDataMeshData, so later normal meshes can be easily added if needed.

This commit is contained in:
Relintai 2020-07-05 18:48:13 +02:00
parent 172b7afd6c
commit 6567ebe225
6 changed files with 32 additions and 32 deletions

2
SCsub
View File

@ -23,4 +23,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/mesh_data_instance_processor.cpp")
module_env.add_source_files(env.modules_sources,"props/prop_data_mesh.cpp") module_env.add_source_files(env.modules_sources,"props/prop_data_mesh_data.cpp")

View File

@ -14,7 +14,7 @@ def get_doc_classes():
"MeshDataInstance", "MeshDataInstance",
"MeshDataInstanceProcessor", "MeshDataInstanceProcessor",
"PropDataMesh", "PropDataMeshData",
] ]
def get_doc_path(): def get_doc_path():

View File

@ -3,7 +3,7 @@
#if PROPS_PRESENT #if PROPS_PRESENT
#include "../nodes/mesh_data_instance.h" #include "../nodes/mesh_data_instance.h"
#include "prop_data_mesh.h" #include "prop_data_mesh_data.h"
bool MeshDataInstanceProcessor::_handles(Node *node) { bool MeshDataInstanceProcessor::_handles(Node *node) {
MeshDataInstance *i = Object::cast_to<MeshDataInstance>(node); MeshDataInstance *i = Object::cast_to<MeshDataInstance>(node);
@ -16,7 +16,7 @@ void MeshDataInstanceProcessor::_process(Ref<PropData> prop_data, Node *node, co
ERR_FAIL_COND(!i); ERR_FAIL_COND(!i);
Ref<PropDataMesh> m; Ref<PropDataMeshData> m;
m.instance(); m.instance();
m->set_mesh(i->get_mesh_data()); m->set_mesh(i->get_mesh_data());
m->set_texture(i->get_texture()); m->set_texture(i->get_texture());

View File

@ -20,74 +20,74 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. SOFTWARE.
*/ */
#include "prop_data_mesh.h" #include "prop_data_mesh_data.h"
#if PROPS_PRESENT #if PROPS_PRESENT
Ref<MeshDataResource> PropDataMesh::get_mesh() const { Ref<MeshDataResource> PropDataMeshData::get_mesh() const {
return _mesh; return _mesh;
} }
void PropDataMesh::set_mesh(const Ref<MeshDataResource> mesh) { void PropDataMeshData::set_mesh(const Ref<MeshDataResource> mesh) {
_mesh = mesh; _mesh = mesh;
} }
Ref<Texture> PropDataMesh::get_texture() const { Ref<Texture> PropDataMeshData::get_texture() const {
return _texture; return _texture;
} }
void PropDataMesh::set_texture(const Ref<Texture> texture) { void PropDataMeshData::set_texture(const Ref<Texture> texture) {
_texture = texture; _texture = texture;
} }
bool PropDataMesh::get_snap_to_mesh() { bool PropDataMeshData::get_snap_to_mesh() {
return _snap_to_mesh; return _snap_to_mesh;
} }
void PropDataMesh::set_snap_to_mesh(bool value) { void PropDataMeshData::set_snap_to_mesh(bool value) {
_snap_to_mesh = value; _snap_to_mesh = value;
} }
Vector3 PropDataMesh::get_snap_axis() { Vector3 PropDataMeshData::get_snap_axis() {
return _snap_axis; return _snap_axis;
} }
void PropDataMesh::set_snap_axis(Vector3 value) { void PropDataMeshData::set_snap_axis(Vector3 value) {
_snap_axis = value; _snap_axis = value;
} }
#if TEXTURE_PACKER_PRESENT #if TEXTURE_PACKER_PRESENT
void PropDataMesh::_add_textures_into(Ref<TexturePacker> texture_packer) { void PropDataMeshData::_add_textures_into(Ref<TexturePacker> texture_packer) {
if (get_texture().is_valid()) { if (get_texture().is_valid()) {
texture_packer->add_texture(get_texture()); texture_packer->add_texture(get_texture());
} }
} }
#endif #endif
PropDataMesh::PropDataMesh() { PropDataMeshData::PropDataMeshData() {
_snap_to_mesh = false; _snap_to_mesh = false;
_snap_axis = Vector3(0, 1, 0); _snap_axis = Vector3(0, 1, 0);
} }
PropDataMesh::~PropDataMesh() { PropDataMeshData::~PropDataMeshData() {
if (_mesh.is_valid()) if (_mesh.is_valid())
_mesh.unref(); _mesh.unref();
} }
void PropDataMesh::_bind_methods() { void PropDataMeshData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_mesh"), &PropDataMesh::get_mesh); ClassDB::bind_method(D_METHOD("get_mesh"), &PropDataMeshData::get_mesh);
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &PropDataMesh::set_mesh); ClassDB::bind_method(D_METHOD("set_mesh", "value"), &PropDataMeshData::set_mesh);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_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("get_texture"), &PropDataMeshData::get_texture);
ClassDB::bind_method(D_METHOD("set_texture", "value"), &PropDataMesh::set_texture); ClassDB::bind_method(D_METHOD("set_texture", "value"), &PropDataMeshData::set_texture);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_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("get_snap_to_mesh"), &PropDataMeshData::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataMesh::set_snap_to_mesh); ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropDataMeshData::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_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("get_snap_axis"), &PropDataMeshData::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataMesh::set_snap_axis); ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropDataMeshData::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
#if TEXTURE_PACKER_PRESENT #if TEXTURE_PACKER_PRESENT
ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataMesh::_add_textures_into); ClassDB::bind_method(D_METHOD("_add_textures_into", "texture_packer"), &PropDataMeshData::_add_textures_into);
#endif #endif
} }

View File

@ -36,8 +36,8 @@ SOFTWARE.
#include "../../texture_packer/texture_packer.h" #include "../../texture_packer/texture_packer.h"
#endif #endif
class PropDataMesh : public PropDataEntry { class PropDataMeshData : public PropDataEntry {
GDCLASS(PropDataMesh, PropDataEntry); GDCLASS(PropDataMeshData, PropDataEntry);
public: public:
Ref<MeshDataResource> get_mesh() const; Ref<MeshDataResource> get_mesh() const;
@ -56,8 +56,8 @@ public:
void _add_textures_into(Ref<TexturePacker> texture_packer); void _add_textures_into(Ref<TexturePacker> texture_packer);
#endif #endif
PropDataMesh(); PropDataMeshData();
~PropDataMesh(); ~PropDataMeshData();
protected: protected:
static void _bind_methods(); static void _bind_methods();

View File

@ -36,7 +36,7 @@ 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/mesh_data_instance_processor.h"
#include "props/prop_data_mesh.h" #include "props/prop_data_mesh_data.h"
#endif #endif
void register_mesh_data_resource_types() { void register_mesh_data_resource_types() {
@ -45,7 +45,7 @@ void register_mesh_data_resource_types() {
ClassDB::register_class<MeshDataInstance>(); ClassDB::register_class<MeshDataInstance>();
#if PROPS_PRESENT #if PROPS_PRESENT
ClassDB::register_class<PropDataMesh>(); ClassDB::register_class<PropDataMeshData>();
ClassDB::register_class<MeshDataInstanceProcessor>(); ClassDB::register_class<MeshDataInstanceProcessor>();
Ref<PropDataProcessor> processor = memnew(MeshDataInstanceProcessor); Ref<PropDataProcessor> processor = memnew(MeshDataInstanceProcessor);
PropUtils::add_processor(processor); PropUtils::add_processor(processor);