mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-27 15:19:18 +01:00
Removed VoxelChunkPropData, the api of VoxelWorld, and VoxelChunk now uses PropDatas directly.
This commit is contained in:
parent
ff48f3738a
commit
6f7c4fbc8a
1
SCsub
1
SCsub
@ -44,7 +44,6 @@ sources = [
|
||||
"world/voxel_structure.cpp",
|
||||
"world/block_voxel_structure.cpp",
|
||||
"world/environment_data.cpp",
|
||||
"world/voxel_chunk_prop_data.cpp",
|
||||
|
||||
"world/blocky/voxel_chunk_blocky.cpp",
|
||||
"world/blocky/voxel_world_blocky.cpp",
|
||||
|
@ -35,7 +35,6 @@ def get_doc_classes():
|
||||
"VoxelMesher",
|
||||
|
||||
"EnvironmentData",
|
||||
"VoxelChunkPropData",
|
||||
"VoxelChunk",
|
||||
"VoxelChunkDefault",
|
||||
"VoxelStructure",
|
||||
|
@ -42,7 +42,6 @@ SOFTWARE.
|
||||
#include "world/block_voxel_structure.h"
|
||||
#include "world/environment_data.h"
|
||||
#include "world/voxel_chunk.h"
|
||||
#include "world/voxel_chunk_prop_data.h"
|
||||
#include "world/voxel_structure.h"
|
||||
#include "world/voxel_world.h"
|
||||
|
||||
@ -99,7 +98,6 @@ void register_voxelman_types() {
|
||||
ClassDB::register_class<VoxelStructure>();
|
||||
ClassDB::register_class<BlockVoxelStructure>();
|
||||
ClassDB::register_class<EnvironmentData>();
|
||||
ClassDB::register_class<VoxelChunkPropData>();
|
||||
|
||||
ClassDB::register_class<VoxelChunkDefault>();
|
||||
ClassDB::register_class<VoxelWorldDefault>();
|
||||
|
@ -1011,11 +1011,6 @@ void VoxelChunkDefault::_world_transform_changed() {
|
||||
update_transforms();
|
||||
}
|
||||
|
||||
//Props
|
||||
void VoxelChunkDefault::_add_prop(Ref<VoxelChunkPropData> prop) {
|
||||
ERR_FAIL_MSG("TODO! _add_prop not yet implemented, send prop to the relevant chunk");
|
||||
}
|
||||
|
||||
//Lights
|
||||
void VoxelChunkDefault::_bake_lights() {
|
||||
clear_baked_lights();
|
||||
@ -1936,9 +1931,6 @@ void VoxelChunkDefault::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_process", "delta"), &VoxelChunkDefault::_process);
|
||||
ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &VoxelChunkDefault::_physics_process);
|
||||
|
||||
//Props
|
||||
ClassDB::bind_method(D_METHOD("_add_prop", "prop"), &VoxelChunkDefault::_add_prop);
|
||||
|
||||
//lights
|
||||
ClassDB::bind_method(D_METHOD("_bake_lights"), &VoxelChunkDefault::_bake_lights);
|
||||
ClassDB::bind_method(D_METHOD("_bake_light", "light"), &VoxelChunkDefault::_bake_light);
|
||||
|
@ -46,8 +46,6 @@ SOFTWARE.
|
||||
#include "../../library/voxel_surface.h"
|
||||
#include "../../library/voxelman_library.h"
|
||||
|
||||
#include "../voxel_chunk_prop_data.h"
|
||||
|
||||
class VoxelWorld;
|
||||
|
||||
class VoxelChunkDefault : public VoxelChunk {
|
||||
@ -246,9 +244,6 @@ protected:
|
||||
virtual void _physics_process(float delta);
|
||||
virtual void _world_transform_changed();
|
||||
|
||||
//Props
|
||||
virtual void _add_prop(Ref<VoxelChunkPropData> prop);
|
||||
|
||||
//lights
|
||||
virtual void _bake_lights();
|
||||
virtual void _bake_light(Ref<VoxelLight> light);
|
||||
|
@ -671,20 +671,25 @@ void VoxelChunk::clear_baked_lights() {
|
||||
call("_clear_baked_lights");
|
||||
}
|
||||
|
||||
void VoxelChunk::add_prop(Ref<VoxelChunkPropData> prop) {
|
||||
#if PROPS_PRESENT
|
||||
void VoxelChunk::add_prop(const Transform &tarnsform, const Ref<PropData> &prop) {
|
||||
ERR_FAIL_COND(!prop.is_valid());
|
||||
ERR_FAIL_COND(prop->get_owner().is_valid());
|
||||
|
||||
prop->set_owner(Ref<VoxelChunk>(this));
|
||||
_props.push_back(prop);
|
||||
PropDataStore s;
|
||||
s.transform = tarnsform;
|
||||
s.prop = prop;
|
||||
|
||||
if (has_method("_prop_added"))
|
||||
call("_prop_added", prop);
|
||||
_props.push_back(s);
|
||||
}
|
||||
Ref<VoxelChunkPropData> VoxelChunk::get_prop(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _props.size(), Ref<VoxelChunkPropData>());
|
||||
Ref<PropData> VoxelChunk::get_prop(int index) {
|
||||
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropData>());
|
||||
|
||||
return _props.get(index);
|
||||
return _props.get(index).prop;
|
||||
}
|
||||
Transform VoxelChunk::get_prop_tarnsform(const int index) {
|
||||
ERR_FAIL_INDEX_V(index, _props.size(), Transform());
|
||||
|
||||
return _props.get(index).transform;
|
||||
}
|
||||
int VoxelChunk::get_prop_count() const {
|
||||
return _props.size();
|
||||
@ -692,23 +697,12 @@ int VoxelChunk::get_prop_count() const {
|
||||
void VoxelChunk::remove_prop(const int index) {
|
||||
ERR_FAIL_INDEX(index, _props.size());
|
||||
|
||||
Ref<VoxelChunkPropData> prop = _props.get(index);
|
||||
|
||||
if (prop.is_valid())
|
||||
prop->set_owner(Ref<VoxelChunk>());
|
||||
|
||||
_props.remove(index);
|
||||
}
|
||||
void VoxelChunk::clear_props() {
|
||||
for (int i = 0; i < _props.size(); ++i) {
|
||||
Ref<VoxelChunkPropData> prop = _props.get(i);
|
||||
|
||||
if (prop.is_valid())
|
||||
prop->set_owner(Ref<VoxelChunk>());
|
||||
}
|
||||
|
||||
_props.clear();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
int VoxelChunk::add_mesh_data_resource(const Transform &local_transform, const Ref<MeshDataResource> &mesh, const Ref<Texture> &texture, const Color &color) {
|
||||
@ -1036,8 +1030,6 @@ void VoxelChunk::_get_property_list(List<PropertyInfo> *p_list) const {
|
||||
void VoxelChunk::_bind_methods() {
|
||||
ADD_SIGNAL(MethodInfo("mesh_generation_finished", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_prop_added", PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunkPropData")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_mesh_data_resource_added", PropertyInfo(Variant::INT, "index")));
|
||||
|
||||
BIND_VMETHOD(MethodInfo("_create_meshers"));
|
||||
|
@ -49,7 +49,9 @@ include_pool_vector
|
||||
#include "../library/voxel_surface.h"
|
||||
#include "../library/voxelman_library.h"
|
||||
|
||||
#include "voxel_chunk_prop_data.h"
|
||||
#if PROPS_PRESENT
|
||||
#include "../../props/props/prop_data.h"
|
||||
#endif
|
||||
|
||||
#include "core/version.h"
|
||||
|
||||
@ -192,12 +194,14 @@ public:
|
||||
void bake_light(Ref<VoxelLight> light);
|
||||
void clear_baked_lights();
|
||||
|
||||
//props
|
||||
void add_prop(Ref<VoxelChunkPropData> prop);
|
||||
Ref<VoxelChunkPropData> get_prop(const int index);
|
||||
#if PROPS_PRESENT
|
||||
void add_prop(const Transform &tarnsform, const Ref<PropData> &prop);
|
||||
Ref<PropData> get_prop(const int index);
|
||||
Transform get_prop_tarnsform(const int index);
|
||||
int get_prop_count() const;
|
||||
void remove_prop(const int index);
|
||||
void clear_props();
|
||||
#endif
|
||||
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
int add_mesh_data_resource(const Transform &local_transform, const Ref<MeshDataResource> &mesh, const Ref<Texture> &texture = Ref<Texture>(), const Color &color = Color(1, 1, 1, 1));
|
||||
@ -258,6 +262,13 @@ public:
|
||||
~VoxelChunk();
|
||||
|
||||
protected:
|
||||
#if PROPS_PRESENT
|
||||
struct PropDataStore {
|
||||
Transform transform;
|
||||
Ref<PropData> prop;
|
||||
};
|
||||
#endif
|
||||
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
struct MeshDataResourceEntry {
|
||||
Ref<MeshDataResource> mesh;
|
||||
@ -324,8 +335,10 @@ protected:
|
||||
Vector<Ref<VoxelMesher> > _liquid_meshers;
|
||||
Ref<VoxelMesher> _prop_mesher;
|
||||
|
||||
//mergeable props
|
||||
Vector<Ref<VoxelChunkPropData> > _props;
|
||||
#if PROPS_PRESENT
|
||||
Vector<PropDataStore> _props;
|
||||
#endif
|
||||
|
||||
#if MESH_DATA_RESOURCE_PRESENT
|
||||
Vector<MeshDataResourceEntry> _mesh_data_resources;
|
||||
#endif
|
||||
|
@ -1,244 +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 "voxel_chunk_prop_data.h"
|
||||
|
||||
#include "voxel_chunk.h"
|
||||
|
||||
int VoxelChunkPropData::get_x() const {
|
||||
return _x;
|
||||
}
|
||||
void VoxelChunkPropData::set_x(const int value) {
|
||||
_x = value;
|
||||
}
|
||||
|
||||
int VoxelChunkPropData::get_y() const {
|
||||
return _y;
|
||||
}
|
||||
void VoxelChunkPropData::set_y(const int value) {
|
||||
_y = value;
|
||||
}
|
||||
|
||||
int VoxelChunkPropData::get_z() const {
|
||||
return _z;
|
||||
}
|
||||
void VoxelChunkPropData::set_z(const int value) {
|
||||
_z = value;
|
||||
}
|
||||
|
||||
Vector3 VoxelChunkPropData::get_rotation() const {
|
||||
return _rotation;
|
||||
}
|
||||
void VoxelChunkPropData::set_rotation(const Vector3 &value) {
|
||||
_rotation = value;
|
||||
}
|
||||
|
||||
Vector3 VoxelChunkPropData::get_scale() const {
|
||||
return _scale;
|
||||
}
|
||||
void VoxelChunkPropData::set_scale(const Vector3 &value) {
|
||||
_scale = value;
|
||||
}
|
||||
|
||||
bool VoxelChunkPropData::get_snap_to_mesh() const {
|
||||
return _snap_to_mesh;
|
||||
}
|
||||
void VoxelChunkPropData::set_snap_to_mesh(const bool value) {
|
||||
_snap_to_mesh = value;
|
||||
}
|
||||
|
||||
Vector3 VoxelChunkPropData::get_snap_axis() const {
|
||||
return _snap_axis;
|
||||
}
|
||||
void VoxelChunkPropData::set_snap_axis(const Vector3 &value) {
|
||||
_snap_axis = value;
|
||||
}
|
||||
|
||||
Ref<VoxelChunk> VoxelChunkPropData::get_owner() {
|
||||
return _owner;
|
||||
}
|
||||
void VoxelChunkPropData::set_owner(const Ref<VoxelChunk> &chunk) {
|
||||
_owner = chunk;
|
||||
}
|
||||
|
||||
int VoxelChunkPropData::get_scene_id() const {
|
||||
return _scene_id;
|
||||
}
|
||||
void VoxelChunkPropData::set_scene_id(const int id) {
|
||||
_scene_id = id;
|
||||
}
|
||||
|
||||
Transform VoxelChunkPropData::get_transform() const {
|
||||
return _transform;
|
||||
}
|
||||
void VoxelChunkPropData::set_transform(const Transform &value) {
|
||||
_transform = value;
|
||||
}
|
||||
|
||||
Ref<PackedScene> VoxelChunkPropData::get_scene() {
|
||||
return _scene;
|
||||
}
|
||||
void VoxelChunkPropData::set_scene(const Ref<PackedScene> &value) {
|
||||
_scene = value;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef PROPS_PRESENT
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
Node *VoxelChunkPropData::get_spawned_prop() const {
|
||||
return _spawned_prop;
|
||||
}
|
||||
void VoxelChunkPropData::set_spawned_prop(Node *value) {
|
||||
_spawned_prop = value;
|
||||
}
|
||||
Node *VoxelChunkPropData::spawn_prop(Node *parent) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void VoxelChunkPropData::free_prop() {
|
||||
}
|
||||
|
||||
void VoxelChunkPropData::set_translation_for_chunk(const Ref<VoxelChunk> &chunk, const int local_x, const int local_y, const int local_z) {
|
||||
}
|
||||
|
||||
VoxelChunkPropData::VoxelChunkPropData() {
|
||||
_x = 0;
|
||||
_y = 0;
|
||||
_z = 0;
|
||||
_scale = Vector3(1, 1, 1);
|
||||
_snap_to_mesh = false;
|
||||
_snap_axis = Vector3(0, -1, 0);
|
||||
|
||||
_spawned_prop = NULL;
|
||||
_scene_id = 0;
|
||||
}
|
||||
VoxelChunkPropData::~VoxelChunkPropData() {
|
||||
_mesh.unref();
|
||||
_texture.unref();
|
||||
#ifdef PROPS_PRESENT
|
||||
_light.unref();
|
||||
_prop.unref();
|
||||
#endif
|
||||
_scene.unref();
|
||||
|
||||
_owner.unref();
|
||||
}
|
||||
|
||||
void VoxelChunkPropData::_bind_methods() {
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
|
||||
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);
|
||||
|
||||
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");
|
||||
|
||||
#ifdef PROPS_PRESENT
|
||||
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");
|
||||
#endif
|
||||
|
||||
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");
|
||||
}
|
@ -1,134 +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 VOXEL_CHUNK_PROP_DATA_H
|
||||
#define VOXEL_CHUNK_PROP_DATA_H
|
||||
|
||||
#include "core/math/transform.h"
|
||||
#include "core/resource.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
|
||||
#include "../../mesh_data_resource/mesh_data_resource.h"
|
||||
|
||||
#ifdef PROPS_PRESENT
|
||||
#include "../../props/props/prop_data.h"
|
||||
#include "../../props/props/prop_data_light.h"
|
||||
#endif
|
||||
|
||||
#include "scene/resources/texture.h"
|
||||
|
||||
class VoxelChunk;
|
||||
|
||||
class VoxelChunkPropData : public Resource {
|
||||
GDCLASS(VoxelChunkPropData, Resource);
|
||||
|
||||
public:
|
||||
int get_x() const;
|
||||
void set_x(const int value);
|
||||
|
||||
int get_y() const;
|
||||
void set_y(const int value);
|
||||
|
||||
int get_z() const;
|
||||
void set_z(const int value);
|
||||
|
||||
Vector3 get_rotation() const;
|
||||
void set_rotation(const Vector3 &value);
|
||||
|
||||
Vector3 get_scale() const;
|
||||
void set_scale(const Vector3 &value);
|
||||
|
||||
bool get_snap_to_mesh() const;
|
||||
void set_snap_to_mesh(const bool value);
|
||||
|
||||
Vector3 get_snap_axis() const;
|
||||
void set_snap_axis(const Vector3 &value);
|
||||
|
||||
Ref<MeshDataResource> get_mesh();
|
||||
void set_mesh(const Ref<MeshDataResource> &value);
|
||||
|
||||
Ref<Texture> get_mesh_texture();
|
||||
void set_mesh_texture(const Ref<Texture> &value);
|
||||
|
||||
#ifdef PROPS_PRESENT
|
||||
Ref<PropDataLight> get_light();
|
||||
void set_light(const Ref<PropDataLight> &value);
|
||||
|
||||
Ref<PropData> get_prop();
|
||||
void set_prop(const Ref<PropData> &value);
|
||||
#endif
|
||||
|
||||
Ref<PackedScene> get_scene();
|
||||
void set_scene(const Ref<PackedScene> &value);
|
||||
|
||||
Ref<VoxelChunk> get_owner();
|
||||
void set_owner(const Ref<VoxelChunk> &chunk);
|
||||
|
||||
int get_scene_id() const;
|
||||
void set_scene_id(const int id);
|
||||
|
||||
Transform get_transform() const;
|
||||
void set_transform(const Transform &value);
|
||||
|
||||
Node *get_spawned_prop() const;
|
||||
void set_spawned_prop(Node *value);
|
||||
|
||||
Node *spawn_prop(Node *parent);
|
||||
void free_prop();
|
||||
|
||||
void set_translation_for_chunk(const Ref<VoxelChunk> &chunk, const int local_x, const int local_y, const int local_z);
|
||||
|
||||
VoxelChunkPropData();
|
||||
~VoxelChunkPropData();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _id;
|
||||
|
||||
int _x;
|
||||
int _y;
|
||||
int _z;
|
||||
Vector3 _rotation;
|
||||
Vector3 _scale;
|
||||
|
||||
bool _snap_to_mesh;
|
||||
Vector3 _snap_axis;
|
||||
|
||||
Ref<VoxelChunk> _owner;
|
||||
int _scene_id;
|
||||
Transform _transform;
|
||||
Node *_spawned_prop;
|
||||
Ref<PackedScene> _scene;
|
||||
|
||||
Ref<MeshDataResource> _mesh;
|
||||
Ref<Texture> _texture;
|
||||
|
||||
#ifdef PROPS_PRESENT
|
||||
Ref<PropDataLight> _light;
|
||||
Ref<PropData> _prop;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
@ -23,7 +23,6 @@ SOFTWARE.
|
||||
#include "voxel_world.h"
|
||||
|
||||
#include "voxel_chunk.h"
|
||||
#include "voxel_chunk_prop_data.h"
|
||||
#include "voxel_structure.h"
|
||||
|
||||
#include "../defines.h"
|
||||
@ -498,12 +497,10 @@ void VoxelWorld::set_chunks(const Vector<Variant> &chunks) {
|
||||
}
|
||||
}
|
||||
|
||||
//Props
|
||||
void VoxelWorld::add_prop(Ref<VoxelChunkPropData> prop) {
|
||||
ERR_FAIL_COND(!has_method("_add_prop"));
|
||||
|
||||
call("_add_prop", prop);
|
||||
#if PROPS_PRESENT
|
||||
void VoxelWorld::add_prop(const Transform &tarnsform, const Ref<PropData> &prop) {
|
||||
}
|
||||
#endif
|
||||
|
||||
//Lights
|
||||
void VoxelWorld::add_light(const Ref<VoxelLight> &light) {
|
||||
@ -1004,8 +1001,6 @@ void VoxelWorld::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("on_chunk_mesh_generation_finished", "chunk"), &VoxelWorld::on_chunk_mesh_generation_finished);
|
||||
|
||||
//Props
|
||||
BIND_VMETHOD(MethodInfo("_add_prop", PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunkPropData")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("add_prop", "prop"), &VoxelWorld::add_prop);
|
||||
|
||||
//Lights
|
||||
|
@ -36,9 +36,13 @@ SOFTWARE.
|
||||
|
||||
#include "core/os/os.h"
|
||||
|
||||
#if PROPS_PRESENT
|
||||
#include "../../props/props/prop_data.h"
|
||||
#endif
|
||||
|
||||
class VoxelStructure;
|
||||
class VoxelChunk;
|
||||
class VoxelChunkPropData;
|
||||
class PropData;
|
||||
|
||||
class VoxelWorld : public Navigation {
|
||||
GDCLASS(VoxelWorld, Navigation);
|
||||
@ -156,8 +160,9 @@ public:
|
||||
Vector<Variant> get_chunks();
|
||||
void set_chunks(const Vector<Variant> &chunks);
|
||||
|
||||
//Props
|
||||
void add_prop(Ref<VoxelChunkPropData> prop);
|
||||
#if PROPS_PRESENT
|
||||
void add_prop(const Transform &tarnsform, const Ref<PropData> &prop);
|
||||
#endif
|
||||
|
||||
//Lights
|
||||
void add_light(const Ref<VoxelLight> &light);
|
||||
@ -239,23 +244,23 @@ private:
|
||||
int _chunk_spawn_range;
|
||||
|
||||
HashMap<IntPos, Ref<VoxelChunk>, IntPosHasher> _chunks;
|
||||
Vector<Ref<VoxelChunk>> _chunks_vector;
|
||||
Vector<Ref<VoxelChunk> > _chunks_vector;
|
||||
|
||||
Vector<Ref<WorldArea>> _world_areas;
|
||||
Vector<Ref<WorldArea> > _world_areas;
|
||||
|
||||
Vector<Ref<VoxelStructure>> _voxel_structures;
|
||||
Vector<Ref<VoxelStructure> > _voxel_structures;
|
||||
|
||||
NodePath _player_path;
|
||||
Spatial *_player;
|
||||
|
||||
bool _use_threads;
|
||||
int _max_concurrent_generations;
|
||||
Vector<Ref<VoxelChunk>> _generation_queue;
|
||||
Vector<Ref<VoxelChunk>> _generating;
|
||||
Vector<Ref<VoxelChunk> > _generation_queue;
|
||||
Vector<Ref<VoxelChunk> > _generating;
|
||||
int _max_frame_chunk_build_steps;
|
||||
int _num_frame_chunk_build_steps;
|
||||
|
||||
Vector<Ref<VoxelLight>> _lights;
|
||||
Vector<Ref<VoxelLight> > _lights;
|
||||
};
|
||||
|
||||
_FORCE_INLINE_ bool operator==(const VoxelWorld::IntPos &a, const VoxelWorld::IntPos &b) {
|
||||
|
Loading…
Reference in New Issue
Block a user