2020-01-31 19:52:37 +01:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2019-10-10 23:51:05 +02:00
|
|
|
#include "voxel_chunk_prop_data.h"
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
#include "voxel_chunk.h"
|
2019-10-10 23:51:05 +02:00
|
|
|
|
2020-06-23 01:05:41 +02:00
|
|
|
int VoxelChunkPropData::get_x() const {
|
2020-06-22 21:49:58 +02:00
|
|
|
return _x;
|
|
|
|
}
|
2020-06-23 01:05:41 +02:00
|
|
|
void VoxelChunkPropData::set_x(const int value) {
|
2020-06-22 21:49:58 +02:00
|
|
|
_x = value;
|
|
|
|
}
|
|
|
|
|
2020-06-23 01:05:41 +02:00
|
|
|
int VoxelChunkPropData::get_y() const {
|
2020-06-22 21:49:58 +02:00
|
|
|
return _y;
|
|
|
|
}
|
2020-06-23 01:05:41 +02:00
|
|
|
void VoxelChunkPropData::set_y(const int value) {
|
2020-06-22 21:49:58 +02:00
|
|
|
_y = value;
|
|
|
|
}
|
|
|
|
|
2020-06-23 01:05:41 +02:00
|
|
|
int VoxelChunkPropData::get_z() const {
|
2020-06-22 21:49:58 +02:00
|
|
|
return _z;
|
|
|
|
}
|
2020-06-23 01:05:41 +02:00
|
|
|
void VoxelChunkPropData::set_z(const int value) {
|
2020-06-22 21:49:58 +02:00
|
|
|
_z = value;
|
|
|
|
}
|
|
|
|
|
2020-06-23 01:05:41 +02:00
|
|
|
Vector3 VoxelChunkPropData::get_rotation() const {
|
2020-06-22 21:49:58 +02:00
|
|
|
return _rotation;
|
|
|
|
}
|
2020-06-23 01:05:41 +02:00
|
|
|
void VoxelChunkPropData::set_rotation(const Vector3 &value) {
|
2020-06-22 21:49:58 +02:00
|
|
|
_rotation = value;
|
|
|
|
}
|
|
|
|
|
2020-06-23 01:05:41 +02:00
|
|
|
Vector3 VoxelChunkPropData::get_scale() const {
|
2020-06-22 21:49:58 +02:00
|
|
|
return _scale;
|
|
|
|
}
|
2020-06-23 01:05:41 +02:00
|
|
|
void VoxelChunkPropData::set_scale(const Vector3 &value) {
|
2020-06-22 21:49:58 +02:00
|
|
|
_scale = value;
|
|
|
|
}
|
|
|
|
|
2020-06-23 01:05:41 +02:00
|
|
|
bool VoxelChunkPropData::get_snap_to_mesh() const {
|
2020-06-22 21:49:58 +02:00
|
|
|
return _snap_to_mesh;
|
|
|
|
}
|
2020-06-23 01:13:04 +02:00
|
|
|
void VoxelChunkPropData::set_snap_to_mesh(const bool value) {
|
2020-06-22 21:49:58 +02:00
|
|
|
_snap_to_mesh = value;
|
|
|
|
}
|
|
|
|
|
2020-06-23 01:05:41 +02:00
|
|
|
Vector3 VoxelChunkPropData::get_snap_axis() const {
|
2020-06-22 21:49:58 +02:00
|
|
|
return _snap_axis;
|
|
|
|
}
|
2020-06-23 01:05:41 +02:00
|
|
|
void VoxelChunkPropData::set_snap_axis(const Vector3 &value) {
|
2020-06-22 21:49:58 +02:00
|
|
|
_snap_axis = value;
|
|
|
|
}
|
|
|
|
|
2020-04-15 13:06:45 +02:00
|
|
|
Ref<VoxelChunk> VoxelChunkPropData::get_owner() {
|
|
|
|
return _owner;
|
|
|
|
}
|
|
|
|
void VoxelChunkPropData::set_owner(const Ref<VoxelChunk> &chunk) {
|
|
|
|
_owner = chunk;
|
|
|
|
}
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
int VoxelChunkPropData::get_scene_id() const {
|
|
|
|
return _scene_id;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
2020-04-04 17:22:07 +02:00
|
|
|
void VoxelChunkPropData::set_scene_id(const int id) {
|
|
|
|
_scene_id = id;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
Transform VoxelChunkPropData::get_transform() const {
|
|
|
|
return _transform;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
2020-04-04 17:22:07 +02:00
|
|
|
void VoxelChunkPropData::set_transform(const Transform &value) {
|
|
|
|
_transform = value;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
Ref<PackedScene> VoxelChunkPropData::get_scene() {
|
|
|
|
return _scene;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
2020-04-04 17:22:07 +02:00
|
|
|
void VoxelChunkPropData::set_scene(const Ref<PackedScene> &value) {
|
|
|
|
_scene = value;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
|
2020-06-22 21:49:58 +02:00
|
|
|
Ref<MeshDataResource> VoxelChunkPropData::get_mesh() {
|
|
|
|
return _mesh;
|
|
|
|
}
|
|
|
|
void VoxelChunkPropData::set_mesh(const Ref<MeshDataResource> &value) {
|
|
|
|
_mesh = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<Texture> VoxelChunkPropData::get_mesh_texture() {
|
|
|
|
return _texture;
|
|
|
|
}
|
|
|
|
void VoxelChunkPropData::set_mesh_texture(const Ref<Texture> &value) {
|
|
|
|
_texture = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<PropDataLight> VoxelChunkPropData::get_light() {
|
|
|
|
return _light;
|
|
|
|
}
|
|
|
|
void VoxelChunkPropData::set_light(const Ref<PropDataLight> &value) {
|
|
|
|
_light = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ref<PropData> VoxelChunkPropData::get_prop() {
|
|
|
|
return _prop;
|
|
|
|
}
|
|
|
|
void VoxelChunkPropData::set_prop(const Ref<PropData> &value) {
|
|
|
|
_prop = value;
|
|
|
|
}
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
Node *VoxelChunkPropData::get_spawned_prop() const {
|
|
|
|
return _spawned_prop;
|
2019-11-05 21:27:31 +01:00
|
|
|
}
|
2020-04-04 17:22:07 +02:00
|
|
|
void VoxelChunkPropData::set_spawned_prop(Node *value) {
|
|
|
|
_spawned_prop = value;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
2020-04-04 17:22:07 +02:00
|
|
|
Node *VoxelChunkPropData::spawn_prop(Node *parent) {
|
|
|
|
return NULL;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
void VoxelChunkPropData::free_prop() {
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
void VoxelChunkPropData::set_translation_for_chunk(const Ref<VoxelChunk> &chunk, const int local_x, const int local_y, const int local_z) {
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VoxelChunkPropData::VoxelChunkPropData() {
|
2020-06-22 21:49:58 +02:00
|
|
|
_x = 0;
|
|
|
|
_y = 0;
|
|
|
|
_z = 0;
|
|
|
|
_scale = Vector3(1, 1, 1);
|
|
|
|
_snap_to_mesh = false;
|
|
|
|
_snap_axis = Vector3(0, -1, 0);
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
_spawned_prop = NULL;
|
|
|
|
_scene_id = 0;
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
VoxelChunkPropData::~VoxelChunkPropData() {
|
2020-06-22 21:49:58 +02:00
|
|
|
_mesh.unref();
|
|
|
|
_texture.unref();
|
|
|
|
_light.unref();
|
|
|
|
_prop.unref();
|
2019-10-10 23:51:05 +02:00
|
|
|
_scene.unref();
|
2020-06-22 21:49:58 +02:00
|
|
|
|
|
|
|
_owner.unref();
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void VoxelChunkPropData::_bind_methods() {
|
2020-06-22 21:49:58 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_x"), &VoxelChunkPropData::get_x);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_x", "value"), &VoxelChunkPropData::set_x);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_y"), &VoxelChunkPropData::get_y);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_y", "value"), &VoxelChunkPropData::set_y);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "y"), "set_y", "get_y");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_z"), &VoxelChunkPropData::get_z);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_z", "value"), &VoxelChunkPropData::set_z);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "z"), "set_z", "get_z");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_rotation"), &VoxelChunkPropData::get_rotation);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &VoxelChunkPropData::set_rotation);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation"), "set_rotation", "get_rotation");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_scale"), &VoxelChunkPropData::get_scale);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_scale", "value"), &VoxelChunkPropData::set_scale);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &VoxelChunkPropData::get_snap_to_mesh);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &VoxelChunkPropData::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"), &VoxelChunkPropData::get_snap_axis);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &VoxelChunkPropData::set_snap_axis);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
|
|
|
|
2020-04-15 13:06:45 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_owner"), &VoxelChunkPropData::get_owner);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_owner", "value"), &VoxelChunkPropData::set_owner);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "owner", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), "set_owner", "get_owner");
|
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_scene_id"), &VoxelChunkPropData::get_scene_id);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_scene_id", "value"), &VoxelChunkPropData::set_scene_id);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "scene_id"), "set_scene_id", "get_scene_id");
|
2019-10-10 23:51:05 +02:00
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_transform"), &VoxelChunkPropData::get_transform);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelChunkPropData::set_transform);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform");
|
2019-10-10 23:51:05 +02:00
|
|
|
|
2020-04-04 17:22:07 +02:00
|
|
|
ClassDB::bind_method(D_METHOD("get_spawned_prop"), &VoxelChunkPropData::get_spawned_prop);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_spawned_prop", "value"), &VoxelChunkPropData::set_spawned_prop);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spawned_prop", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "set_spawned_prop", "get_spawned_prop");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("spawn_prop", "parent"), &VoxelChunkPropData::spawn_prop);
|
|
|
|
ClassDB::bind_method(D_METHOD("free_prop"), &VoxelChunkPropData::free_prop);
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("set_translation_for_chunk", "chunk", "local_x", "local_y", "local_z"), &VoxelChunkPropData::set_translation_for_chunk);
|
2020-06-22 21:49:58 +02:00
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_mesh"), &VoxelChunkPropData::get_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");
|
|
|
|
|
|
|
|
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("set_light", "value"), &VoxelChunkPropData::set_light);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "PropDataLight"), "set_light", "get_light");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_prop"), &VoxelChunkPropData::get_prop);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_prop", "value"), &VoxelChunkPropData::set_prop);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop", "get_prop");
|
|
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("get_scene"), &VoxelChunkPropData::get_scene);
|
|
|
|
ClassDB::bind_method(D_METHOD("set_scene", "value"), &VoxelChunkPropData::set_scene);
|
|
|
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
|
2019-10-10 23:51:05 +02:00
|
|
|
}
|