Added a Texture property to VoxelChunkPropData aswell.

This commit is contained in:
Relintai 2019-11-05 21:27:31 +01:00
parent 588ed550c8
commit 440b4eadfb
2 changed files with 17 additions and 0 deletions

View File

@ -56,6 +56,13 @@ void VoxelChunkPropData::set_mesh(const Ref<MeshDataResource> value) {
_mesh = value; _mesh = value;
} }
Ref<Texture> VoxelChunkPropData::get_mesh_texture() const {
return _texture;
}
void VoxelChunkPropData::set_mesh_texture(const Ref<Texture> value) {
_texture = value;
}
Ref<VoxelmanPropLight> VoxelChunkPropData::get_light() const { Ref<VoxelmanPropLight> VoxelChunkPropData::get_light() const {
return _light; return _light;
} }
@ -86,6 +93,7 @@ VoxelChunkPropData::VoxelChunkPropData() {
} }
VoxelChunkPropData::~VoxelChunkPropData() { VoxelChunkPropData::~VoxelChunkPropData() {
_mesh.unref(); _mesh.unref();
_texture.unref();
_light.unref(); _light.unref();
_prop.unref(); _prop.unref();
_scene.unref(); _scene.unref();
@ -124,6 +132,10 @@ void VoxelChunkPropData::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &VoxelChunkPropData::set_mesh); ClassDB::bind_method(D_METHOD("set_mesh", "value"), &VoxelChunkPropData::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_mesh_texture"), &VoxelChunkPropData::get_mesh_texture);
ClassDB::bind_method(D_METHOD("set_mesh_texture", "value"), &VoxelChunkPropData::set_mesh_texture);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_mesh_texture", "get_mesh_texture");
ClassDB::bind_method(D_METHOD("get_light"), &VoxelChunkPropData::get_light); ClassDB::bind_method(D_METHOD("get_light"), &VoxelChunkPropData::get_light);
ClassDB::bind_method(D_METHOD("set_light", "value"), &VoxelChunkPropData::set_light); ClassDB::bind_method(D_METHOD("set_light", "value"), &VoxelChunkPropData::set_light);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanPropLight"), "set_light", "get_light"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanPropLight"), "set_light", "get_light");

View File

@ -4,6 +4,7 @@
#include "core/reference.h" #include "core/reference.h"
#include "core/math/vector3.h" #include "core/math/vector3.h"
#include "scene/resources/texture.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
#include "../props/voxelman_prop.h" #include "../props/voxelman_prop.h"
#include "../props/voxelman_prop_light.h" #include "../props/voxelman_prop_light.h"
@ -37,6 +38,9 @@ public:
Ref<MeshDataResource> get_mesh() const; Ref<MeshDataResource> get_mesh() const;
void set_mesh(const Ref<MeshDataResource> value); void set_mesh(const Ref<MeshDataResource> value);
Ref<Texture> get_mesh_texture() const;
void set_mesh_texture(const Ref<Texture> value);
Ref<VoxelmanPropLight> get_light() const; Ref<VoxelmanPropLight> get_light() const;
void set_light(const Ref<VoxelmanPropLight> value); void set_light(const Ref<VoxelmanPropLight> value);
@ -63,6 +67,7 @@ private:
Vector3 _snap_axis; Vector3 _snap_axis;
Ref<MeshDataResource> _mesh; Ref<MeshDataResource> _mesh;
Ref<Texture> _texture;
Ref<VoxelmanPropLight> _light; Ref<VoxelmanPropLight> _light;
Ref<VoxelmanProp> _prop; Ref<VoxelmanProp> _prop;
Ref<PackedScene> _scene; Ref<PackedScene> _scene;