diff --git a/areas/world_area.cpp b/areas/world_area.cpp index 6bd5c2c..38faed5 100644 --- a/areas/world_area.cpp +++ b/areas/world_area.cpp @@ -28,10 +28,10 @@ void WorldArea::set_name(const String value) { _name = value; } -int WorldArea::get_level() const { - return _level; +int WorldArea::get_level() const { + return _level; } -void WorldArea::set_level(const int level) { +void WorldArea::set_level(const int level) { _level = level; } @@ -45,7 +45,7 @@ WorldArea::~WorldArea() { void WorldArea::_bind_methods() { ClassDB::bind_method(D_METHOD("get_aabb"), &WorldArea::get_aabb); ClassDB::bind_method(D_METHOD("set_aabb"), &WorldArea::set_aabb); - ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb"); ClassDB::bind_method(D_METHOD("get_map_texture"), &WorldArea::get_map_texture); ClassDB::bind_method(D_METHOD("set_map_texture"), &WorldArea::set_map_texture); diff --git a/areas/world_area.h b/areas/world_area.h index ad6e787..ea73b71 100644 --- a/areas/world_area.h +++ b/areas/world_area.h @@ -3,8 +3,8 @@ #include "core/reference.h" -#include "core/ustring.h" #include "core/math/aabb.h" +#include "core/ustring.h" #include "scene/resources/texture.h" class WorldArea : public Reference { diff --git a/clutter/ground_clutter.h b/clutter/ground_clutter.h index 7fe3601..b9b6167 100644 --- a/clutter/ground_clutter.h +++ b/clutter/ground_clutter.h @@ -3,8 +3,8 @@ #include "core/resource.h" -#include "../meshers/voxel_mesher.h" #include "../../texture_packer/texture_packer.h" +#include "../meshers/voxel_mesher.h" class VoxelChunk; class VoxelMesher; diff --git a/containers/voxelman_queue.cpp b/containers/voxelman_queue.cpp index 221a148..b9b4662 100644 --- a/containers/voxelman_queue.cpp +++ b/containers/voxelman_queue.cpp @@ -2,142 +2,142 @@ /// VMQUeue -template +template void VMQueue::enqueue(T obj) { - _lock->write_lock(); + _lock->write_lock(); - if (_size == _count) { - _resize(_size + 10); - } + if (_size == _count) { + _resize(_size + 10); + } - _items[(_head + _count) % _size] = obj; - ++_count; + _items[(_head + _count) % _size] = obj; + ++_count; - _lock->write_unlock(); + _lock->write_unlock(); } -template +template T VMQueue::dequeue() { - if (_size == 0) - return T(); + if (_size == 0) + return T(); - if (_count == 0) - return T(); + if (_count == 0) + return T(); - T obj; + T obj; - _lock->write_lock(); + _lock->write_lock(); - obj = _items[_head]; + obj = _items[_head]; - _items[_head] = T(); + _items[_head] = T(); - ++_head; - --_count; + ++_head; + --_count; - if (_head >= _size) - _head -= _size; + if (_head >= _size) + _head -= _size; - _lock->write_unlock(); + _lock->write_unlock(); - return obj; + return obj; } -template +template T VMQueue::peek() { - T obj; + T obj; - _lock->read_lock(); - obj = _items[_head]; - _lock->read_unlock(); + _lock->read_lock(); + obj = _items[_head]; + _lock->read_unlock(); - return obj; + return obj; } -template +template void VMQueue::resize(int new_size) { - _lock->write_lock(); + _lock->write_lock(); - _resize(new_size); + _resize(new_size); - _lock->write_unlock(); + _lock->write_unlock(); } -template +template void VMQueue::_resize(int new_size) { - if (new_size == _size) - return; + if (new_size == _size) + return; - if (new_size > _size) { + if (new_size > _size) { - T *narr = memnew_arr(T, new_size); - //copymem(narr, _items, sizeof(T) * _size); + T *narr = memnew_arr(T, new_size); + //copymem(narr, _items, sizeof(T) * _size); - for (int i = 0; i < _size; ++i) { - narr[i] = _items[i]; - } + for (int i = 0; i < _size; ++i) { + narr[i] = _items[i]; + } - memdelete_arr(_items); - _items = narr; + memdelete_arr(_items); + _items = narr; - _size = new_size; + _size = new_size; - return; - } + return; + } } -template +template VMQueue::VMQueue(int initial_size) { - _items = NULL; - _head = 0; - _count = 0; - _size = initial_size; + _items = NULL; + _head = 0; + _count = 0; + _size = initial_size; - if (unlikely(initial_size <= 0)) { - _size = 10; - - print_error("initial_size <= 0"); - } + if (unlikely(initial_size <= 0)) { + _size = 10; - _lock = RWLock::create(); + print_error("initial_size <= 0"); + } - _items = memnew_arr(T, _size); + _lock = RWLock::create(); + + _items = memnew_arr(T, _size); } -template +template VMQueue::VMQueue() { - _items = NULL; - _head = 0; - _count = 0; - _size = 10; + _items = NULL; + _head = 0; + _count = 0; + _size = 10; - _lock = RWLock::create(); + _lock = RWLock::create(); - _items = memnew_arr(T, _size); + _items = memnew_arr(T, _size); } -template +template VMQueue::~VMQueue() { - if (_items) - memdelete_arr(_items); + if (_items) + memdelete_arr(_items); - memdelete(_lock); + memdelete(_lock); } ///VoxelmanQueue void VoxelmanQueue::enqueue(Variant obj) { - _queue.enqueue(obj); + _queue.enqueue(obj); } Variant VoxelmanQueue::dequeue() { - return _queue.dequeue(); + return _queue.dequeue(); } Variant VoxelmanQueue::peek() { - return _queue.peek(); + return _queue.peek(); } void VoxelmanQueue::resize(int new_size) { - _queue.resize(new_size); + _queue.resize(new_size); } VoxelmanQueue::VoxelmanQueue() { @@ -147,8 +147,8 @@ VoxelmanQueue::~VoxelmanQueue() { } void VoxelmanQueue::_bind_methods() { - ClassDB::bind_method(D_METHOD("enqueue", "obj"), &VoxelmanQueue::enqueue); - ClassDB::bind_method(D_METHOD("dequeue"), &VoxelmanQueue::dequeue); - ClassDB::bind_method(D_METHOD("peek"), &VoxelmanQueue::peek); - ClassDB::bind_method(D_METHOD("resize", "new_size"), &VoxelmanQueue::resize); + ClassDB::bind_method(D_METHOD("enqueue", "obj"), &VoxelmanQueue::enqueue); + ClassDB::bind_method(D_METHOD("dequeue"), &VoxelmanQueue::dequeue); + ClassDB::bind_method(D_METHOD("peek"), &VoxelmanQueue::peek); + ClassDB::bind_method(D_METHOD("resize", "new_size"), &VoxelmanQueue::resize); } diff --git a/containers/voxelman_queue.h b/containers/voxelman_queue.h index 374308a..d115912 100644 --- a/containers/voxelman_queue.h +++ b/containers/voxelman_queue.h @@ -8,50 +8,50 @@ #include "core/os/rw_lock.h" #include "core/variant.h" -template +template class VMQueue { public: - void enqueue(T obj); - T dequeue(); - T peek(); + void enqueue(T obj); + T dequeue(); + T peek(); - void resize(int new_size); + void resize(int new_size); - VMQueue(int initial_size); - VMQueue(); - ~VMQueue(); + VMQueue(int initial_size); + VMQueue(); + ~VMQueue(); protected: - void _resize(int new_size); + void _resize(int new_size); private: - RWLock *_lock; + RWLock *_lock; - int _head; - int _count; - int _size; - T *_items; + int _head; + int _count; + int _size; + T *_items; }; class VoxelmanQueue : public Reference { - GDCLASS(VoxelmanQueue, Reference); + GDCLASS(VoxelmanQueue, Reference); public: - void enqueue(Variant obj); - Variant dequeue(); - Variant peek(); + void enqueue(Variant obj); + Variant dequeue(); + Variant peek(); - void resize(int new_size); + void resize(int new_size); - VoxelmanQueue(); - ~VoxelmanQueue(); + VoxelmanQueue(); + ~VoxelmanQueue(); protected: - static void _bind_methods(); + static void _bind_methods(); private: - VMQueue _queue; + VMQueue _queue; }; #endif \ No newline at end of file diff --git a/containers/voxelman_unbounded_queue.cpp b/containers/voxelman_unbounded_queue.cpp index 5513726..52435a4 100644 --- a/containers/voxelman_unbounded_queue.cpp +++ b/containers/voxelman_unbounded_queue.cpp @@ -2,81 +2,81 @@ /// VMQUeue -template +template void VMUBQueue::enqueue(T obj) { - _enqueue_lock->write_lock(); + _enqueue_lock->write_lock(); - UBQueueNode *n = memnew(UBQueueNode(obj)); + UBQueueNode *n = memnew(UBQueueNode(obj)); - _tail->next = n; - _tail = n; + _tail->next = n; + _tail = n; - _enqueue_lock->write_unlock(); + _enqueue_lock->write_unlock(); } -template +template T VMUBQueue::dequeue() { - T result; + T result; - _dequeue_lock->write_lock(); + _dequeue_lock->write_lock(); - if (_head->next == NULL) { - return result; - } + if (_head->next == NULL) { + return result; + } - result = _head->next->data; - - UBQueueNode *h = _head; + result = _head->next->data; - _head = _head->next; + UBQueueNode *h = _head; - memdelete(h); + _head = _head->next; - _dequeue_lock->write_unlock(); + memdelete(h); - return result; + _dequeue_lock->write_unlock(); + + return result; } -template +template T VMUBQueue::peek() { - return _head->data; + return _head->data; } -template +template VMUBQueue::VMUBQueue() { - _head = memnew(UBQueueNode); - _tail = _head; + _head = memnew(UBQueueNode); + _tail = _head; - _enqueue_lock = RWLock::create(); - _dequeue_lock = RWLock::create(); + _enqueue_lock = RWLock::create(); + _dequeue_lock = RWLock::create(); } -template +template VMUBQueue::~VMUBQueue() { - memdelete(_enqueue_lock); - memdelete(_dequeue_lock); + memdelete(_enqueue_lock); + memdelete(_dequeue_lock); - UBQueueNode *h = _head; + UBQueueNode *h = _head; - while (h) { - UBQueueNode *n = h->next; + while (h) { + UBQueueNode *n = h->next; - memdelete(h); + memdelete(h); - h = n; - } + h = n; + } } ///VoxelmanUnboundedQueue void VoxelmanUnboundedQueue::enqueue(Variant obj) { - _queue.enqueue(obj); + _queue.enqueue(obj); } Variant VoxelmanUnboundedQueue::dequeue() { - return _queue.dequeue(); + return _queue.dequeue(); } Variant VoxelmanUnboundedQueue::peek() { - return _queue.peek(); + return _queue.peek(); } VoxelmanUnboundedQueue::VoxelmanUnboundedQueue() { @@ -86,7 +86,7 @@ VoxelmanUnboundedQueue::~VoxelmanUnboundedQueue() { } void VoxelmanUnboundedQueue::_bind_methods() { - ClassDB::bind_method(D_METHOD("enqueue", "obj"), &VoxelmanUnboundedQueue::enqueue); - ClassDB::bind_method(D_METHOD("dequeue"), &VoxelmanUnboundedQueue::dequeue); - ClassDB::bind_method(D_METHOD("peek"), &VoxelmanUnboundedQueue::peek); + ClassDB::bind_method(D_METHOD("enqueue", "obj"), &VoxelmanUnboundedQueue::enqueue); + ClassDB::bind_method(D_METHOD("dequeue"), &VoxelmanUnboundedQueue::dequeue); + ClassDB::bind_method(D_METHOD("peek"), &VoxelmanUnboundedQueue::peek); } diff --git a/containers/voxelman_unbounded_queue.h b/containers/voxelman_unbounded_queue.h index 8c5bd05..76ca2c6 100644 --- a/containers/voxelman_unbounded_queue.h +++ b/containers/voxelman_unbounded_queue.h @@ -8,56 +8,56 @@ #include "core/os/rw_lock.h" #include "core/variant.h" -template +template struct UBQueueNode { - T data; - UBQueueNode *next; + T data; + UBQueueNode *next; - UBQueueNode() { - next = NULL; - } + UBQueueNode() { + next = NULL; + } - UBQueueNode(T value) { - data = value; - next = NULL; - } + UBQueueNode(T value) { + data = value; + next = NULL; + } }; -template +template class VMUBQueue { public: - void enqueue(T obj); - T dequeue(); - T peek(); + void enqueue(T obj); + T dequeue(); + T peek(); - VMUBQueue(); - ~VMUBQueue(); + VMUBQueue(); + ~VMUBQueue(); private: - RWLock *_enqueue_lock; - RWLock *_dequeue_lock; + RWLock *_enqueue_lock; + RWLock *_dequeue_lock; - UBQueueNode *_head; - UBQueueNode *_tail; + UBQueueNode *_head; + UBQueueNode *_tail; }; class VoxelmanUnboundedQueue : public Reference { - GDCLASS(VoxelmanUnboundedQueue, Reference); + GDCLASS(VoxelmanUnboundedQueue, Reference); public: - void enqueue(Variant obj); - Variant dequeue(); - Variant peek(); + void enqueue(Variant obj); + Variant dequeue(); + Variant peek(); - VoxelmanUnboundedQueue(); - ~VoxelmanUnboundedQueue(); + VoxelmanUnboundedQueue(); + ~VoxelmanUnboundedQueue(); protected: - static void _bind_methods(); + static void _bind_methods(); private: - VMUBQueue _queue; + VMUBQueue _queue; }; #endif \ No newline at end of file diff --git a/data/voxel_light.cpp b/data/voxel_light.cpp index 90fe52c..dfb0103 100644 --- a/data/voxel_light.cpp +++ b/data/voxel_light.cpp @@ -1,58 +1,55 @@ #include "voxel_light.h" _FORCE_INLINE_ int VoxelLight::get_world_position_x() const { - return _world_position_x; + return _world_position_x; } _FORCE_INLINE_ int VoxelLight::get_world_position_y() const { - return _world_position_y; + return _world_position_y; } _FORCE_INLINE_ int VoxelLight::get_world_position_z() const { - return _world_position_z; + return _world_position_z; } -Vector3 VoxelLight::get_world_position() { - return Vector3(_world_position_x, _world_position_y, _world_position_z); - +Vector3 VoxelLight::get_world_position() { + return Vector3(_world_position_x, _world_position_y, _world_position_z); } void VoxelLight::set_world_position(const int x, const int y, const int z) { - _world_position_x = x; - _world_position_y = y; - _world_position_z = z; + _world_position_x = x; + _world_position_y = y; + _world_position_z = z; } -_FORCE_INLINE_ Color VoxelLight::get_color() const { - return _color; - +_FORCE_INLINE_ Color VoxelLight::get_color() const { + return _color; } -void VoxelLight::set_color(Color color) { - _color = color; - +void VoxelLight::set_color(Color color) { + _color = color; } -_FORCE_INLINE_ float VoxelLight::get_size() const { - return _size; +_FORCE_INLINE_ float VoxelLight::get_size() const { + return _size; } -void VoxelLight::set_size(const float size) { - _size = size; +void VoxelLight::set_size(const float size) { + _size = size; } VoxelLight::VoxelLight() { - _size = 0; + _size = 0; } VoxelLight::~VoxelLight() { } void VoxelLight::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_world_position_x"), &VoxelLight::get_world_position_x); - ClassDB::bind_method(D_METHOD("get_world_position_y"), &VoxelLight::get_world_position_y); - ClassDB::bind_method(D_METHOD("get_world_position_z"), &VoxelLight::get_world_position_z); - ClassDB::bind_method(D_METHOD("set_world_position", "x", "y", "z"), &VoxelLight::set_world_position); - - ClassDB::bind_method(D_METHOD("get_color"), &VoxelLight::get_color); - ClassDB::bind_method(D_METHOD("set_color"), &VoxelLight::set_color); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); - - ClassDB::bind_method(D_METHOD("get_size"), &VoxelLight::get_size); - ClassDB::bind_method(D_METHOD("set_size"), &VoxelLight::set_size); - ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size"); + ClassDB::bind_method(D_METHOD("get_world_position_x"), &VoxelLight::get_world_position_x); + ClassDB::bind_method(D_METHOD("get_world_position_y"), &VoxelLight::get_world_position_y); + ClassDB::bind_method(D_METHOD("get_world_position_z"), &VoxelLight::get_world_position_z); + ClassDB::bind_method(D_METHOD("set_world_position", "x", "y", "z"), &VoxelLight::set_world_position); + + ClassDB::bind_method(D_METHOD("get_color"), &VoxelLight::get_color); + ClassDB::bind_method(D_METHOD("set_color"), &VoxelLight::set_color); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); + + ClassDB::bind_method(D_METHOD("get_size"), &VoxelLight::get_size); + ClassDB::bind_method(D_METHOD("set_size"), &VoxelLight::set_size); + ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size"); } diff --git a/docs/_templates/breadcrumbs.html b/docs/_templates/breadcrumbs.html index 804ad69..3f21269 100644 --- a/docs/_templates/breadcrumbs.html +++ b/docs/_templates/breadcrumbs.html @@ -4,4 +4,4 @@ {% if not meta or meta.get('github_url') != 'hide' %} {{ super() }} {% endif %} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html index e0125e6..ac54000 100644 --- a/docs/_templates/layout.html +++ b/docs/_templates/layout.html @@ -1,4 +1,4 @@ {% extends "!layout.html" %} {% block linktags %} - {{ super() }} -{% endblock %} +{{ super() }} +{% endblock %} \ No newline at end of file diff --git a/level_generator/voxelman_level_generator.cpp b/level_generator/voxelman_level_generator.cpp index 81cc48e..f253f2d 100644 --- a/level_generator/voxelman_level_generator.cpp +++ b/level_generator/voxelman_level_generator.cpp @@ -3,12 +3,12 @@ #include "../world/voxel_chunk.h" void VoxelmanLevelGenerator::generate_chunk_bind(Node *chunk) { - generate_chunk(Object::cast_to(chunk)); + generate_chunk(Object::cast_to(chunk)); } void VoxelmanLevelGenerator::generate_chunk(VoxelChunk *chunk) { - if (has_method("_generate_chunk")) { - call("_generate_chunk", chunk); - } + if (has_method("_generate_chunk")) { + call("_generate_chunk", chunk); + } } VoxelmanLevelGenerator::VoxelmanLevelGenerator() { @@ -18,7 +18,7 @@ VoxelmanLevelGenerator::~VoxelmanLevelGenerator() { } void VoxelmanLevelGenerator::_bind_methods() { - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &VoxelmanLevelGenerator::generate_chunk_bind); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &VoxelmanLevelGenerator::generate_chunk_bind); } diff --git a/level_generator/voxelman_level_generator.h b/level_generator/voxelman_level_generator.h index 50b6aa3..b129f1d 100644 --- a/level_generator/voxelman_level_generator.h +++ b/level_generator/voxelman_level_generator.h @@ -17,8 +17,6 @@ public: protected: static void _bind_methods(); - }; #endif - diff --git a/library/voxel_surface.h b/library/voxel_surface.h index 5726440..36540b0 100644 --- a/library/voxel_surface.h +++ b/library/voxel_surface.h @@ -8,8 +8,8 @@ #include "core/vector.h" #include "scene/resources/material.h" -#include "voxelman_library.h" #include "../clutter/ground_clutter.h" +#include "voxelman_library.h" class VoxelmanLibrary; class GroundClutter; @@ -47,22 +47,22 @@ public: int get_id() const; void set_id(const int value); - bool is_transparent() const; + bool is_transparent() const; void set_transparent(const bool transparent); - + Rect2 get_rect(const VoxelSurfaceSides side) const; void set_rect(const VoxelSurfaceSides side, const Rect2 rect); Ref get_clutter(); void set_clutter(Ref clutter); - Ref get_library() const; + Ref get_library() const; void set_library(Ref library); Vector2 transform_uv(const VoxelSurfaceSides side, const Vector2 uv) const; virtual void refresh_rects(); - + VoxelSurface(); ~VoxelSurface(); diff --git a/library/voxel_surface_merger.cpp b/library/voxel_surface_merger.cpp index 2a077a8..20cbc8a 100644 --- a/library/voxel_surface_merger.cpp +++ b/library/voxel_surface_merger.cpp @@ -36,7 +36,7 @@ void VoxelSurfaceMerger::refresh_rects() { } Rect2 region = at->get_region(); - float w = tex->get_width(); + float w = tex->get_width(); float h = tex->get_height(); Rect2 r; @@ -72,5 +72,4 @@ void VoxelSurfaceMerger::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_top", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", VOXEL_SIDE_TOP); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_bottom", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", VOXEL_SIDE_BOTTOM); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_side", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", VOXEL_SIDE_SIDE); - } diff --git a/library/voxel_surface_simple.cpp b/library/voxel_surface_simple.cpp index 2e909cd..4ec6eb4 100644 --- a/library/voxel_surface_simple.cpp +++ b/library/voxel_surface_simple.cpp @@ -57,7 +57,7 @@ VoxelSurfaceSimple::~VoxelSurfaceSimple() { void VoxelSurfaceSimple::_bind_methods() { ClassDB::bind_method(D_METHOD("get_atlas_x", "side"), &VoxelSurfaceSimple::get_atlas_x); ClassDB::bind_method(D_METHOD("set_atlas_x", "side", "value"), &VoxelSurfaceSimple::set_atlas_x); - + ClassDB::bind_method(D_METHOD("get_atlas_y", "side"), &VoxelSurfaceSimple::get_atlas_y); ClassDB::bind_method(D_METHOD("set_atlas_y", "side", "value"), &VoxelSurfaceSimple::set_atlas_y); diff --git a/meshers/cubic_mesher/voxel_cube_points.cpp b/meshers/cubic_mesher/voxel_cube_points.cpp index 3e448f7..f5f5cf9 100644 --- a/meshers/cubic_mesher/voxel_cube_points.cpp +++ b/meshers/cubic_mesher/voxel_cube_points.cpp @@ -317,7 +317,6 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) { _point_neighbours[P001] = neighbours; - neighbours = 0; x = _x + 1; y = _y; @@ -376,7 +375,6 @@ void VoxelCubePoints::refresh_neighbours(VoxelChunk *chunk) { _point_neighbours[P011] = neighbours; - neighbours = 0; x = _x + 1; y = _y + 1; @@ -444,7 +442,7 @@ void VoxelCubePoints::setup(VoxelChunk *chunk, int x, int y, int z, int size) { _point_fills[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL); _point_fills[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_ISOLEVEL); - _point_aos[P000] = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_AO); + _point_aos[P000] = chunk->get_voxel(x, y, z, VoxelChunk::DEFAULT_CHANNEL_AO); _point_aos[P100] = chunk->get_voxel(x + size, y, z, VoxelChunk::DEFAULT_CHANNEL_AO); _point_aos[P010] = chunk->get_voxel(x, y + size, z, VoxelChunk::DEFAULT_CHANNEL_AO); _point_aos[P001] = chunk->get_voxel(x, y, z + size, VoxelChunk::DEFAULT_CHANNEL_AO); @@ -461,13 +459,12 @@ void VoxelCubePoints::setup(VoxelChunk *chunk, int x, int y, int z, int size) { _point_colors[P011] = Color(chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); _point_colors[P101] = Color(chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); _point_colors[P111] = Color(chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunk::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - + refresh_neighbours(chunk); refresh_points(); } - void VoxelCubePoints::reset() { for (int i = 0; i < POINT_COUNT; ++i) { _point_types[i] = 0; @@ -557,7 +554,6 @@ Vector3 VoxelCubePoints::get_vertex_vector3_for_point(int face, int index) { vector.z -= num2; vector /= num; - return vector; } @@ -580,19 +576,19 @@ int VoxelCubePoints::get_point_neighbours(int index) { } int VoxelCubePoints::get_point_ao(int index) { - ERR_FAIL_INDEX_V(index, POINT_COUNT, 0); - - return _point_aos[index]; + ERR_FAIL_INDEX_V(index, POINT_COUNT, 0); + + return _point_aos[index]; } int VoxelCubePoints::get_face_point_ao(int face, int index) { - int indx = get_point_index(face, index); + int indx = get_point_index(face, index); return _point_aos[indx]; } Color VoxelCubePoints::get_face_point_ao_color(int face, int index) { - int indx = get_point_index(face, index); + int indx = get_point_index(face, index); float ao_value = (_point_aos[indx] / 255.0) * 0.75; @@ -744,7 +740,6 @@ VoxelCubePoints::VoxelCubePoints() { VoxelCubePoints::~VoxelCubePoints() { } - void VoxelCubePoints::_bind_methods() { ClassDB::bind_method(D_METHOD("get_x"), &VoxelCubePoints::get_x); @@ -783,9 +778,9 @@ void VoxelCubePoints::_bind_methods() { ClassDB::bind_method(D_METHOD("get_point_type", "index"), &VoxelCubePoints::get_point_type); ClassDB::bind_method(D_METHOD("get_point_fill", "index"), &VoxelCubePoints::get_point_fill); ClassDB::bind_method(D_METHOD("get_point_neighbours", "index"), &VoxelCubePoints::get_point_neighbours); - - ClassDB::bind_method(D_METHOD("get_point_ao", "index"), &VoxelCubePoints::get_point_ao); - ClassDB::bind_method(D_METHOD("get_face_point_ao", "face", "index"), &VoxelCubePoints::get_face_point_ao); + + ClassDB::bind_method(D_METHOD("get_point_ao", "index"), &VoxelCubePoints::get_point_ao); + ClassDB::bind_method(D_METHOD("get_face_point_ao", "face", "index"), &VoxelCubePoints::get_face_point_ao); ClassDB::bind_method(D_METHOD("get_face_point_ao_color", "face", "index"), &VoxelCubePoints::get_face_point_ao_color); ClassDB::bind_method(D_METHOD("get_face_point_light_color", "face", "index"), &VoxelCubePoints::get_face_point_light_color); ClassDB::bind_method(D_METHOD("get_face_point_color_mixed", "face", "index"), &VoxelCubePoints::get_face_point_color_mixed); diff --git a/meshers/cubic_mesher/voxel_cube_points.h b/meshers/cubic_mesher/voxel_cube_points.h index f9e41f9..d0f459f 100644 --- a/meshers/cubic_mesher/voxel_cube_points.h +++ b/meshers/cubic_mesher/voxel_cube_points.h @@ -113,8 +113,8 @@ public: int get_point_fill(int index); int get_point_neighbours(int index); - int get_point_ao(int index); - int get_face_point_ao(int face, int index); + int get_point_ao(int index); + int get_face_point_ao(int face, int index); Color get_face_point_ao_color(int face, int index); Color get_face_point_light_color(int face, int index); Color get_face_point_color_mixed(int face, int index); @@ -148,8 +148,8 @@ private: uint8_t _point_types[POINT_COUNT]; uint8_t _point_fills[POINT_COUNT]; - uint8_t _point_aos[POINT_COUNT]; - Color _point_colors[POINT_COUNT]; + uint8_t _point_aos[POINT_COUNT]; + Color _point_colors[POINT_COUNT]; unsigned int _point_neighbours[POINT_COUNT]; int _size; diff --git a/meshers/cubic_mesher/voxel_mesher_cubic.cpp b/meshers/cubic_mesher/voxel_mesher_cubic.cpp index 8207b3e..d732f93 100644 --- a/meshers/cubic_mesher/voxel_mesher_cubic.cpp +++ b/meshers/cubic_mesher/voxel_mesher_cubic.cpp @@ -1,6 +1,5 @@ #include "voxel_mesher_cubic.h" - void VoxelMesherCubic::_add_buffer(Node *p_chunk) { VoxelChunk *chunk = Object::cast_to(p_chunk); @@ -85,7 +84,6 @@ void VoxelMesherCubic::_add_buffer(Node *p_chunk) { } VoxelMesherCubic::VoxelMesherCubic() { - } VoxelMesherCubic::~VoxelMesherCubic() { diff --git a/meshers/cubic_mesher/voxel_mesher_cubic.h b/meshers/cubic_mesher/voxel_mesher_cubic.h index 8b31845..9f6f648 100644 --- a/meshers/cubic_mesher/voxel_mesher_cubic.h +++ b/meshers/cubic_mesher/voxel_mesher_cubic.h @@ -2,8 +2,8 @@ #define VOXEL_MESHER_CUBIC_H #include "core/color.h" -#include "core/math/vector3.h" #include "core/math/vector2.h" +#include "core/math/vector3.h" #include "../voxel_mesher.h" @@ -14,13 +14,12 @@ class VoxelMesherCubic : public VoxelMesher { public: void _add_buffer(Node *p_chunk); - + VoxelMesherCubic(); ~VoxelMesherCubic(); protected: static void _bind_methods(); - }; #endif diff --git a/meshers/transvoxel_cell_data.cpp b/meshers/transvoxel_cell_data.cpp index dbf089f..02a21a0 100644 --- a/meshers/transvoxel_cell_data.cpp +++ b/meshers/transvoxel_cell_data.cpp @@ -4,8 +4,8 @@ int TransvoxelCellData::get_vertex_index(int index) const { return static_cast(vertexIndex[index]); } void TransvoxelCellData::set_vertex_index(int index, int value) { - ERR_FAIL_INDEX(index, 36); - + ERR_FAIL_INDEX(index, 36); + vertexIndex[index] = static_cast(value); } @@ -13,8 +13,8 @@ int TransvoxelCellData::get_vertex_count() const { return (geometryCounts >> 4); } void TransvoxelCellData::set_vertex_count(int value) { - geometryCounts &= 0xFF0F; - + geometryCounts &= 0xFF0F; + geometryCounts |= value << 4; } @@ -23,32 +23,32 @@ int TransvoxelCellData::get_triangle_count() const { } void TransvoxelCellData::set_triangle_count(int value) { geometryCounts &= 0xFFF0; - + geometryCounts |= value; } TransvoxelCellData::TransvoxelCellData() { - geometryCounts = 0; - - for (int i = 0; i < 36; ++i) { - vertexIndex[i] = 0; - } + geometryCounts = 0; + + for (int i = 0; i < 36; ++i) { + vertexIndex[i] = 0; + } } TransvoxelCellData::TransvoxelCellData(const RegularCellData &cell_data) { geometryCounts = cell_data.geometryCounts; - - for (int i = 0; i < 15; ++i) { - vertexIndex[i] = cell_data.vertexIndex[i]; - } + + for (int i = 0; i < 15; ++i) { + vertexIndex[i] = cell_data.vertexIndex[i]; + } } TransvoxelCellData::TransvoxelCellData(const TransitionCellData &cell_data) { - geometryCounts = cell_data.geometryCounts; - - for (int i = 0; i < 36; ++i) { - vertexIndex[i] = cell_data.vertexIndex[i]; - } + geometryCounts = cell_data.geometryCounts; + + for (int i = 0; i < 36; ++i) { + vertexIndex[i] = cell_data.vertexIndex[i]; + } } TransvoxelCellData::~TransvoxelCellData() { @@ -56,13 +56,11 @@ TransvoxelCellData::~TransvoxelCellData() { void TransvoxelCellData::_bind_methods() { ClassDB::bind_method(D_METHOD("get_vertex_index", "index"), &TransvoxelCellData::get_vertex_index); - ClassDB::bind_method(D_METHOD("set_vertex_index", "index", "value"), &TransvoxelCellData::set_vertex_index); + ClassDB::bind_method(D_METHOD("set_vertex_index", "index", "value"), &TransvoxelCellData::set_vertex_index); ClassDB::bind_method(D_METHOD("get_vertex_count"), &TransvoxelCellData::get_vertex_count); - ClassDB::bind_method(D_METHOD("set_vertex_count", "value"), &TransvoxelCellData::set_vertex_count); - + ClassDB::bind_method(D_METHOD("set_vertex_count", "value"), &TransvoxelCellData::set_vertex_count); + ClassDB::bind_method(D_METHOD("get_triangle_count"), &TransvoxelCellData::get_triangle_count); - ClassDB::bind_method(D_METHOD("set_triangle_count", "value"), &TransvoxelCellData::set_triangle_count); + ClassDB::bind_method(D_METHOD("set_triangle_count", "value"), &TransvoxelCellData::set_triangle_count); } - - diff --git a/meshers/transvoxel_cell_data.h b/meshers/transvoxel_cell_data.h index 84b42a1..edfc06a 100644 --- a/meshers/transvoxel_cell_data.h +++ b/meshers/transvoxel_cell_data.h @@ -12,15 +12,15 @@ class TransvoxelCellData : public Reference { public: int get_vertex_index(int index) const; - void set_vertex_index(int index, int value); + void set_vertex_index(int index, int value); int get_vertex_count() const; - void set_vertex_count(int value); + void set_vertex_count(int value); int get_triangle_count() const; - void set_triangle_count(int value); + void set_triangle_count(int value); TransvoxelCellData(); TransvoxelCellData(const RegularCellData &cell_data); - TransvoxelCellData(const TransitionCellData &cell_data); + TransvoxelCellData(const TransitionCellData &cell_data); ~TransvoxelCellData(); protected: diff --git a/meshers/transvoxel_tables.cpp b/meshers/transvoxel_tables.cpp index 609bd93..7214893 100644 --- a/meshers/transvoxel_tables.cpp +++ b/meshers/transvoxel_tables.cpp @@ -41,7 +41,7 @@ namespace Transvoxel { // that the class index ranges from 0 to 15. const unsigned char regularCellClass[256] = { -// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0x00, 0x01, 0x01, 0x03, 0x01, 0x03, 0x02, 0x04, 0x01, 0x02, 0x03, 0x04, 0x03, 0x04, 0x04, 0x03, // 0 0x01, 0x03, 0x02, 0x04, 0x02, 0x04, 0x06, 0x0C, 0x02, 0x05, 0x05, 0x0B, 0x05, 0x0A, 0x07, 0x04, // 16 0x01, 0x02, 0x03, 0x04, 0x02, 0x05, 0x05, 0x0A, 0x02, 0x06, 0x04, 0x0C, 0x05, 0x07, 0x0B, 0x04, // 32 @@ -57,7 +57,7 @@ const unsigned char regularCellClass[256] = { 0x03, 0x05, 0x05, 0x08, 0x04, 0x0A, 0x07, 0x0E, 0x04, 0x07, 0x0B, 0x0E, 0x03, 0x04, 0x04, 0x03, // 192 0x04, 0x0B, 0x07, 0x0E, 0x0C, 0x04, 0x0F, 0x0D, 0x0A, 0x0E, 0x0E, 0x02, 0x04, 0x03, 0x0D, 0x01, // 208 0x04, 0x07, 0x0A, 0x0E, 0x0B, 0x0E, 0x0E, 0x02, 0x0C, 0x0F, 0x04, 0x0D, 0x04, 0x0D, 0x03, 0x01, // 224 - 0x03, 0x04, 0x04, 0x03, 0x04, 0x03, 0x0D, 0x01, 0x04, 0x0D, 0x03, 0x01, 0x03, 0x01, 0x01, 0x00 // 240 + 0x03, 0x04, 0x04, 0x03, 0x04, 0x03, 0x0D, 0x01, 0x04, 0x0D, 0x03, 0x01, 0x03, 0x01, 0x01, 0x00 // 240 }; // The regularCellData table holds the triangulation data for all 16 distinct classes to @@ -66,20 +66,20 @@ const unsigned char regularCellClass[256] = { const RegularCellData regularCellData[16] = { { 0x00, {} }, { 0x31, { 0, 1, 2 } }, - { 0x62, { 0, 1, 2, 3, 4, 5 } }, - { 0x62, { 0, 1, 2, 4, 5, 3 } }, //{ 0x42, { 0, 1, 2, 0, 2, 3 } } - { 0x93, { 0, 1, 4, 5, 3, 6, 7, 2, 8 } }, //{ 0x53, { 0, 1, 4, 1, 3, 4, 1, 2, 3 } } - { 0x73, { 0, 1, 2, 0, 2, 3, 4, 5, 6 } }, - { 0x93, { 0, 1, 2, 3, 4, 5, 6, 7, 8 } }, - { 0xC4, { 0, 1, 4, 8, 3, 9, 10, 2, 11, 5, 6, 7 } }, //7 { 0x84, { 0, 1, 4, 1, 3, 4, 1, 2, 3, 5, 6, 7 } }, - { 0x84, { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7 } }, - { 0xC4, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } }, - { 0xC4, { 0, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3 } }, //A { 0x64, { 0, 4, 5, 0, 1, 4, 1, 3, 4, 1, 2, 3 } }, - { 0xC4, { 0, 5, 4, 6, 8, 7, 9, 11, 10, 1, 3, 2 } }, //B { 0x64, { 0, 5, 4, 0, 4, 1, 1, 4, 3, 1, 3, 2 } }, - { 0xC4, { 0, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3 } }, //C { 0x64, { 0, 4, 5, 0, 3, 4, 0, 1, 3, 1, 2, 3 } }, - { 0xC4, { 0, 1, 2, 6, 7, 3, 8, 9, 4, 10, 11, 5 } }, //D { 0x64, { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 } }, - { 0xF5, { 0, 1, 2, 7, 8, 3, 9, 10, 4, 11, 12, 5, 13, 14, 6 } }, //E { 0x75, { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6 } }, - { 0xF5, { 0, 4, 5, 9, 3, 10, 11, 1, 12, 13, 2, 14, 6, 7, 8 } } //F { 0x95, { 0, 4, 5, 0, 3, 4, 0, 1, 3, 1, 2, 3, 6, 7, 8 } } + { 0x62, { 0, 1, 2, 3, 4, 5 } }, + { 0x62, { 0, 1, 2, 4, 5, 3 } }, //{ 0x42, { 0, 1, 2, 0, 2, 3 } } + { 0x93, { 0, 1, 4, 5, 3, 6, 7, 2, 8 } }, //{ 0x53, { 0, 1, 4, 1, 3, 4, 1, 2, 3 } } + { 0x73, { 0, 1, 2, 0, 2, 3, 4, 5, 6 } }, + { 0x93, { 0, 1, 2, 3, 4, 5, 6, 7, 8 } }, + { 0xC4, { 0, 1, 4, 8, 3, 9, 10, 2, 11, 5, 6, 7 } }, //7 { 0x84, { 0, 1, 4, 1, 3, 4, 1, 2, 3, 5, 6, 7 } }, + { 0x84, { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7 } }, + { 0xC4, { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 } }, + { 0xC4, { 0, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3 } }, //A { 0x64, { 0, 4, 5, 0, 1, 4, 1, 3, 4, 1, 2, 3 } }, + { 0xC4, { 0, 5, 4, 6, 8, 7, 9, 11, 10, 1, 3, 2 } }, //B { 0x64, { 0, 5, 4, 0, 4, 1, 1, 4, 3, 1, 3, 2 } }, + { 0xC4, { 0, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3 } }, //C { 0x64, { 0, 4, 5, 0, 3, 4, 0, 1, 3, 1, 2, 3 } }, + { 0xC4, { 0, 1, 2, 6, 7, 3, 8, 9, 4, 10, 11, 5 } }, //D { 0x64, { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5 } }, + { 0xF5, { 0, 1, 2, 7, 8, 3, 9, 10, 4, 11, 12, 5, 13, 14, 6 } }, //E { 0x75, { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6 } }, + { 0xF5, { 0, 4, 5, 9, 3, 10, 11, 1, 12, 13, 2, 14, 6, 7, 8 } } //F { 0x95, { 0, 4, 5, 0, 3, 4, 0, 1, 3, 1, 2, 3, 6, 7, 8 } } }; // The regularVertexData table gives the vertex locations for every one of the 256 possible @@ -105,7 +105,7 @@ const unsigned short regularVertexData[256][15] = { { 0x4113, 0x8337, 0x1326, 0x3304, 0x6201, 0x8337, 0x6201, 0x8337, 0x3304 }, { 0x6201, 0x2315, 0x8337, 0x1326, 0x5102, 0x2315, 0x5102, 0x2315, 0x1326 }, { 0x3304, 0x2315, 0x8337, 0x1326, 0x3304, 0x8337 }, - //16 3 5 15 + //16 3 5 15 { 0x3304, 0x1146, 0x2245 }, { 0x6201, 0x5102, 0x1146, 0x2245, 0x6201, 0x1146 }, { 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245 }, @@ -122,7 +122,7 @@ const unsigned short regularVertexData[256][15] = { { 0x4113, 0x8337, 0x1326, 0x1146, 0x2245, 0x6201, 0x4113, 0x8337, 0x2245, 0x8337, 0x1146, 0x2245 }, { 0x6201, 0x2315, 0x8337, 0x1326, 0x5102, 0x3304, 0x1146, 0x2245, 0x2315, 0x5102, 0x2315, 0x1326 }, { 0x2245, 0x2315, 0x8337, 0x1326, 0x1146, 0x2315, 0x1146, 0x2315, 0x1326 }, - //32 3 10 15 + //32 3 10 15 { 0x2315, 0x2245, 0x8157 }, { 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157 }, { 0x4113, 0x6201, 0x2245, 0x8157, 0x4113, 0x2245 }, @@ -139,7 +139,7 @@ const unsigned short regularVertexData[256][15] = { { 0x4113, 0x8337, 0x1326, 0x3304, 0x6201, 0x2315, 0x2245, 0x8157, 0x8337, 0x6201, 0x8337, 0x3304 }, { 0x5102, 0x1326, 0x8337, 0x8157, 0x2245, 0x6201, 0x5102, 0x1326, 0x2245, 0x1326, 0x8157, 0x2245 }, { 0x8157, 0x8337, 0x1326, 0x3304, 0x2245, 0x8337, 0x2245, 0x8337, 0x3304 }, - //48 1 2 7 11 + //48 1 2 7 11 { 0x2315, 0x3304, 0x1146, 0x8157, 0x2315, 0x1146 }, { 0x6201, 0x5102, 0x1146, 0x8157, 0x2315, 0x5102, 0x2315, 0x5102, 0x8157 }, { 0x3304, 0x1146, 0x8157, 0x4113, 0x6201, 0x1146, 0x6201, 0x1146, 0x4113 }, @@ -156,7 +156,7 @@ const unsigned short regularVertexData[256][15] = { { 0x6201, 0x4113, 0x8337, 0x1326, 0x1146, 0x8157, 0x2315, 0x6201, 0x8337, 0x6201, 0x1326, 0x6201, 0x1146, 0x6201, 0x8157 }, { 0x6201, 0x3304, 0x1146, 0x8157, 0x8337, 0x1326, 0x5102, 0x6201, 0x1146, 0x6201, 0x8157, 0x6201, 0x8337, 0x6201, 0x1326 }, { 0x1326, 0x1146, 0x8157, 0x8337, 0x1326, 0x8157 }, - //64 5 12 15 + //64 5 12 15 { 0x1326, 0x8267, 0x1146 }, { 0x6201, 0x5102, 0x3304, 0x1326, 0x8267, 0x1146 }, { 0x6201, 0x2315, 0x4113, 0x1326, 0x8267, 0x1146 }, @@ -173,7 +173,7 @@ const unsigned short regularVertexData[256][15] = { { 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304, 0x6201, 0x8267, 0x1146, 0x6201, 0x4113, 0x8267 }, { 0x6201, 0x2315, 0x8337, 0x8267, 0x1146, 0x5102, 0x6201, 0x2315, 0x1146, 0x2315, 0x8267, 0x1146 }, { 0x1146, 0x3304, 0x2315, 0x8337, 0x8267, 0x3304, 0x8267, 0x3304, 0x8337 }, - //80 1 4 7 13 + //80 1 4 7 13 { 0x3304, 0x1326, 0x8267, 0x2245, 0x3304, 0x8267 }, { 0x1326, 0x8267, 0x2245, 0x6201, 0x5102, 0x8267, 0x5102, 0x8267, 0x6201 }, { 0x3304, 0x1326, 0x8267, 0x2245, 0x6201, 0x2315, 0x4113 }, @@ -190,7 +190,7 @@ const unsigned short regularVertexData[256][15] = { { 0x8337, 0x8267, 0x2245, 0x6201, 0x4113, 0x8267, 0x4113, 0x8267, 0x6201 }, { 0x5102, 0x6201, 0x2315, 0x8337, 0x8267, 0x2245, 0x3304, 0x5102, 0x2315, 0x5102, 0x8337, 0x5102, 0x8267, 0x5102, 0x2245 }, { 0x2315, 0x8337, 0x8267, 0x2245, 0x2315, 0x8267 }, - //96 - + //96 - { 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 }, { 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 }, { 0x6201, 0x2245, 0x8157, 0x4113, 0x1326, 0x8267, 0x1146 }, @@ -207,7 +207,7 @@ const unsigned short regularVertexData[256][15] = { { 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304, 0x2315, 0x2245, 0x8157, 0x6201, 0x1146, 0x6201, 0x8267, 0x4113, 0x8267 }, { 0x8337, 0x8267, 0x1146, 0x5102, 0x6201, 0x2245, 0x8157, 0x8337, 0x1146, 0x8337, 0x5102, 0x8337, 0x6201, 0x8337, 0x2245 }, { 0x3304, 0x2245, 0x8157, 0x8337, 0x8267, 0x1146, 0x3304, 0x8157, 0x3304, 0x8337, 0x3304, 0x8267 }, - //112 0 3 5 + //112 0 3 5 { 0x8157, 0x2315, 0x3304, 0x1326, 0x8267, 0x2315, 0x8267, 0x2315, 0x1326 }, { 0x8267, 0x8157, 0x2315, 0x6201, 0x5102, 0x1326, 0x8267, 0x6201, 0x5102, 0x8267, 0x8157, 0x6201 }, { 0x8267, 0x1326, 0x3304, 0x6201, 0x4113, 0x8157, 0x8267, 0x1326, 0x4113, 0x1326, 0x6201, 0x4113 }, @@ -224,7 +224,7 @@ const unsigned short regularVertexData[256][15] = { { 0x6201, 0x4113, 0x8337, 0x8267, 0x8157, 0x2315, 0x6201, 0x8337, 0x6201, 0x8267, 0x6201, 0x8157 }, { 0x6201, 0x3304, 0x5102, 0x8337, 0x8267, 0x8157 }, { 0x8337, 0x8267, 0x8157 }, - //128 10 12 15 + //128 10 12 15 { 0x8337, 0x8157, 0x8267 }, { 0x6201, 0x5102, 0x3304, 0x8337, 0x8157, 0x8267 }, { 0x6201, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 }, @@ -241,7 +241,7 @@ const unsigned short regularVertexData[256][15] = { { 0x8157, 0x4113, 0x6201, 0x3304, 0x1326, 0x8267, 0x8157, 0x4113, 0x1326, 0x4113, 0x3304, 0x1326 }, { 0x1326, 0x5102, 0x6201, 0x2315, 0x8157, 0x8267, 0x1326, 0x2315, 0x8157, 0x1326, 0x5102, 0x2315 }, { 0x8267, 0x1326, 0x3304, 0x2315, 0x8157, 0x1326, 0x8157, 0x1326, 0x2315 }, - //144 - + //144 - { 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 }, { 0x6201, 0x5102, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 }, { 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 }, @@ -258,7 +258,7 @@ const unsigned short regularVertexData[256][15] = { { 0x1326, 0x1146, 0x2245, 0x6201, 0x4113, 0x8157, 0x8267, 0x1326, 0x2245, 0x1326, 0x6201, 0x1326, 0x4113, 0x1326, 0x8157 }, { 0x5102, 0x6201, 0x2315, 0x8157, 0x8267, 0x1326, 0x3304, 0x1146, 0x2245, 0x5102, 0x8267, 0x5102, 0x8157, 0x6201, 0x8157 }, { 0x1326, 0x1146, 0x2245, 0x2315, 0x8157, 0x8267, 0x1326, 0x2245, 0x1326, 0x2315, 0x1326, 0x8157 }, - //160 2 8 11 14 + //160 2 8 11 14 { 0x2315, 0x2245, 0x8267, 0x8337, 0x2315, 0x8267 }, { 0x2315, 0x2245, 0x8267, 0x8337, 0x6201, 0x5102, 0x3304 }, { 0x4113, 0x6201, 0x2245, 0x8267, 0x8337, 0x6201, 0x8337, 0x6201, 0x8267 }, @@ -275,7 +275,7 @@ const unsigned short regularVertexData[256][15] = { { 0x4113, 0x2315, 0x2245, 0x8267, 0x1326, 0x3304, 0x6201, 0x4113, 0x2245, 0x4113, 0x8267, 0x4113, 0x1326, 0x4113, 0x3304 }, { 0x5102, 0x6201, 0x2245, 0x8267, 0x1326, 0x6201, 0x1326, 0x6201, 0x8267 }, { 0x3304, 0x2245, 0x8267, 0x1326, 0x3304, 0x8267 }, - //176 0 3 10 + //176 0 3 10 { 0x8267, 0x8337, 0x2315, 0x3304, 0x1146, 0x8337, 0x1146, 0x8337, 0x3304 }, { 0x5102, 0x1146, 0x8267, 0x8337, 0x2315, 0x6201, 0x5102, 0x1146, 0x2315, 0x1146, 0x8337, 0x2315 }, { 0x3304, 0x1146, 0x8267, 0x8337, 0x4113, 0x6201, 0x3304, 0x8337, 0x4113, 0x3304, 0x1146, 0x8337 }, @@ -292,7 +292,7 @@ const unsigned short regularVertexData[256][15] = { { 0x6201, 0x4113, 0x2315, 0x1326, 0x1146, 0x8267 }, { 0x6201, 0x3304, 0x1146, 0x8267, 0x1326, 0x5102, 0x6201, 0x1146, 0x6201, 0x8267, 0x6201, 0x1326 }, { 0x1326, 0x1146, 0x8267 }, - //192 4 8 13 14 + //192 4 8 13 14 { 0x1326, 0x8337, 0x8157, 0x1146, 0x1326, 0x8157 }, { 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x5102, 0x3304 }, { 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x2315, 0x4113 }, @@ -309,7 +309,7 @@ const unsigned short regularVertexData[256][15] = { { 0x6201, 0x4113, 0x8157, 0x1146, 0x3304, 0x4113, 0x3304, 0x4113, 0x1146 }, { 0x2315, 0x8157, 0x1146, 0x5102, 0x6201, 0x8157, 0x6201, 0x8157, 0x5102 }, { 0x2315, 0x8157, 0x1146, 0x3304, 0x2315, 0x1146 }, - //208 0 5 12 + //208 0 5 12 { 0x2245, 0x3304, 0x1326, 0x8337, 0x8157, 0x3304, 0x8157, 0x3304, 0x8337 }, { 0x6201, 0x2245, 0x8157, 0x8337, 0x1326, 0x5102, 0x6201, 0x2245, 0x1326, 0x2245, 0x8337, 0x1326 }, { 0x2245, 0x3304, 0x1326, 0x8337, 0x8157, 0x6201, 0x2315, 0x4113, 0x3304, 0x8157, 0x3304, 0x8337 }, @@ -326,7 +326,7 @@ const unsigned short regularVertexData[256][15] = { { 0x4113, 0x8157, 0x2245, 0x6201, 0x4113, 0x2245 }, { 0x5102, 0x6201, 0x2315, 0x8157, 0x2245, 0x3304, 0x5102, 0x2315, 0x5102, 0x8157, 0x5102, 0x2245 }, { 0x2315, 0x8157, 0x2245 }, - //224 0 10 12 + //224 0 10 12 { 0x1146, 0x1326, 0x8337, 0x2315, 0x2245, 0x1326, 0x2245, 0x1326, 0x2315 }, { 0x1146, 0x1326, 0x8337, 0x2315, 0x2245, 0x6201, 0x5102, 0x3304, 0x1326, 0x2245, 0x1326, 0x2315 }, { 0x6201, 0x2245, 0x1146, 0x1326, 0x8337, 0x4113, 0x6201, 0x2245, 0x8337, 0x2245, 0x1326, 0x8337 }, @@ -343,7 +343,7 @@ const unsigned short regularVertexData[256][15] = { { 0x4113, 0x2315, 0x2245, 0x1146, 0x3304, 0x6201, 0x4113, 0x2245, 0x4113, 0x1146, 0x4113, 0x3304 }, { 0x6201, 0x2245, 0x1146, 0x5102, 0x6201, 0x1146 }, { 0x3304, 0x2245, 0x1146 }, - //240 1 2 4 8 + //240 1 2 4 8 { 0x3304, 0x1326, 0x8337, 0x2315, 0x3304, 0x8337 }, { 0x5102, 0x1326, 0x8337, 0x2315, 0x6201, 0x1326, 0x6201, 0x1326, 0x2315 }, { 0x6201, 0x3304, 0x1326, 0x8337, 0x4113, 0x3304, 0x4113, 0x3304, 0x8337 }, @@ -359,7 +359,7 @@ const unsigned short regularVertexData[256][15] = { { 0x5102, 0x4113, 0x2315, 0x3304, 0x5102, 0x2315 }, { 0x6201, 0x4113, 0x2315 }, { 0x6201, 0x3304, 0x5102 }, - {} + {} //256 }; diff --git a/meshers/voxel_mesh_data.h b/meshers/voxel_mesh_data.h index cbe64b0..b077473 100644 --- a/meshers/voxel_mesh_data.h +++ b/meshers/voxel_mesh_data.h @@ -3,9 +3,9 @@ #include "core/reference.h" #include "core/vector.h" +#include "scene/resources/material.h" #include "scene/resources/mesh.h" #include "scene/resources/surface_tool.h" -#include "scene/resources/material.h" class VoxelMeshData : public Reference { GDCLASS(VoxelMeshData, Reference) diff --git a/meshers/voxel_mesher.cpp b/meshers/voxel_mesher.cpp index e9aafe7..b157f37 100644 --- a/meshers/voxel_mesher.cpp +++ b/meshers/voxel_mesher.cpp @@ -702,7 +702,7 @@ void VoxelMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("add_chunk", "chunk"), &VoxelMesher::add_chunk_bind); ClassDB::bind_method(D_METHOD("add_chunk_liquid", "chunk"), &VoxelMesher::add_chunk_liquid_bind); - + ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &VoxelMesher::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3())); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &VoxelMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); diff --git a/meshers/voxel_mesher.h b/meshers/voxel_mesher.h index d351b03..54149ef 100644 --- a/meshers/voxel_mesher.h +++ b/meshers/voxel_mesher.h @@ -1,23 +1,23 @@ #ifndef VOXEL_TOOLS_H #define VOXEL_TOOLS_H -#include "core/reference.h" #include "core/color.h" +#include "core/math/rect2.h" #include "core/math/vector2.h" #include "core/math/vector3.h" -#include "core/math/rect2.h" +#include "core/reference.h" #include "core/vector.h" -#include "scene/3d/mesh_instance.h" -#include "scene/resources/material.h" -#include "scene/resources/mesh.h" -#include "scene/resources/surface_tool.h" #include "scene/3d/immediate_geometry.h" +#include "scene/3d/mesh_instance.h" #include "scene/3d/spatial.h" #include "scene/main/node.h" #include "scene/resources/concave_polygon_shape.h" +#include "scene/resources/material.h" +#include "scene/resources/mesh.h" +#include "scene/resources/surface_tool.h" -#include "../library/voxelman_library.h" #include "../../mesh_data_resource/mesh_data_resource.h" +#include "../library/voxelman_library.h" const double PI_2 = 3.141592653589793238463 / 2; const double PI = 3.141592653589793238463; diff --git a/meshers/voxel_mesher_transvoxel.cpp b/meshers/voxel_mesher_transvoxel.cpp index 4b46371..9a15f9b 100644 --- a/meshers/voxel_mesher_transvoxel.cpp +++ b/meshers/voxel_mesher_transvoxel.cpp @@ -20,9 +20,9 @@ int VoxelMesherTransvoxel::get_regular_vertex_data(int index1, int index2) const } //void VoxelMesherTransvoxel::set_regular_vertex_data(int index1, int index2, int value) { - // ERR_FAIL_INDEX(index1, 256); +// ERR_FAIL_INDEX(index1, 256); // ERR_FAIL_INDEX(index2, 13); - + // regularVertexData[index1][index2] = value; //} @@ -108,7 +108,6 @@ Vector3 VoxelMesherTransvoxel::get_transition_vertex_direction(int index1, int i return transvoxel_vertices[vert2] - transvoxel_vertices[vert1]; } - VoxelMesherTransvoxel::VoxelMesherTransvoxel() { for (int i = 0; i < 16; ++i) { _regular_cell_datas[i] = Ref(memnew(TransvoxelCellData(regularCellData[i]))); @@ -117,11 +116,9 @@ VoxelMesherTransvoxel::VoxelMesherTransvoxel() { for (int i = 0; i < 56; ++i) { _transition_cell_data[i] = Ref(memnew(TransvoxelCellData(transitionCellData[i]))); } - } VoxelMesherTransvoxel::~VoxelMesherTransvoxel() { - } void VoxelMesherTransvoxel::_bind_methods() { @@ -130,7 +127,7 @@ void VoxelMesherTransvoxel::_bind_methods() { ClassDB::bind_method(D_METHOD("get_regular_cell_class", "index"), &VoxelMesherTransvoxel::get_regular_cell_class); ClassDB::bind_method(D_METHOD("get_regular_cell_data", "index"), &VoxelMesherTransvoxel::get_regular_cell_data); ClassDB::bind_method(D_METHOD("get_regular_vertex_data", "index1", "index2"), &VoxelMesherTransvoxel::get_regular_vertex_data); - // ClassDB::bind_method(D_METHOD("set_regular_vertex_data", "index1", "index2", "value"), &VoxelMesherTransvoxel::set_regular_vertex_data); + // ClassDB::bind_method(D_METHOD("set_regular_vertex_data", "index1", "index2", "value"), &VoxelMesherTransvoxel::set_regular_vertex_data); ClassDB::bind_method(D_METHOD("get_regular_vertex_data_first_vertex", "index1", "index2"), &VoxelMesherTransvoxel::get_regular_vertex_data_first_vertex); ClassDB::bind_method(D_METHOD("get_regular_vertex_data_second_vertex", "index1", "index2"), &VoxelMesherTransvoxel::get_regular_vertex_data_second_vertex); ClassDB::bind_method(D_METHOD("get_regular_vertex_first_position", "index1", "index2"), &VoxelMesherTransvoxel::get_regular_vertex_first_position); diff --git a/meshers/voxel_mesher_transvoxel.h b/meshers/voxel_mesher_transvoxel.h index acd4d4e..83fa06c 100644 --- a/meshers/voxel_mesher_transvoxel.h +++ b/meshers/voxel_mesher_transvoxel.h @@ -49,7 +49,7 @@ public: Ref get_regular_cell_data(int index) const; int get_regular_vertex_data(int index10, int index2) const; - // void set_regular_vertex_data(int index1, int index2, int value); + // void set_regular_vertex_data(int index1, int index2, int value); int get_regular_vertex_data_first_vertex(int index1, int index2) const; int get_regular_vertex_data_second_vertex(int index1, int index2) const; Vector3 get_regular_vertex_first_position(int index1, int index2) const; diff --git a/props/prop_data.cpp b/props/prop_data.cpp index c5d98f5..5ad9b66 100644 --- a/props/prop_data.cpp +++ b/props/prop_data.cpp @@ -88,7 +88,7 @@ void PropData::add_prop_lights_into(VoxelChunk *chunk, Transform parent_transfor Transform t = parent_transform * pl->get_transform(); Vector3 px = t.origin / chunk->get_voxel_scale(); - + Ref vl; vl.instance(); vl->set_world_position(px.x + chunk->get_position_x() * chunk->get_size_x(), px.y + chunk->get_position_y() * chunk->get_size_y(), px.z + chunk->get_position_z() * chunk->get_size_z()); @@ -166,7 +166,6 @@ void PropData::add_meshes_into(Ref mesher, Ref textu else pdataprop->get_prop()->add_meshes_into(mesher, texture_packer, parent_transform * pmesh->get_transform(), snap_spatial); } - } } void PropData::add_meshes_into_bind(Ref mesher, Ref texture_packer, Transform parent_transform, Node *snap_spatial) { diff --git a/props/prop_data.h b/props/prop_data.h index 7a372e9..8b3e0d4 100644 --- a/props/prop_data.h +++ b/props/prop_data.h @@ -1,12 +1,12 @@ #ifndef PROP_DATA_H #define PROP_DATA_H -#include "core/reference.h" -#include "core/vector.h" +#include "core/math/rect2.h" #include "core/math/transform.h" #include "core/math/vector2.h" #include "core/math/vector3.h" -#include "core/math/rect2.h" +#include "core/reference.h" +#include "core/vector.h" #include "servers/physics_server.h" @@ -39,8 +39,8 @@ public: Vector get_props(); void set_props(const Vector &props); - - void add_textures_into(Ref texture_packer); + + void add_textures_into(Ref texture_packer); void add_prop_lights_into(VoxelChunk *chunk, Transform parent_transform, bool allow_snap); void add_prop_lights_into_bind(Node *chunk, Transform parent_transform, bool allow_snap); void add_meshes_into(Ref mesher, Ref texture_packer, Transform parent_transform, Spatial *snap_spatial = NULL); diff --git a/props/prop_data_entity.cpp b/props/prop_data_entity.cpp index 1419a84..6f4f0f0 100644 --- a/props/prop_data_entity.cpp +++ b/props/prop_data_entity.cpp @@ -1,6 +1,5 @@ #include "prop_data_entity.h" - int PropDataEntity::get_entity_data_id() const { return _entity_data_id; } diff --git a/props/prop_data_entity.h b/props/prop_data_entity.h index 90da5b3..e58eb50 100644 --- a/props/prop_data_entity.h +++ b/props/prop_data_entity.h @@ -5,7 +5,7 @@ class PropDataEntity : public PropDataEntry { GDCLASS(PropDataEntity, PropDataEntry); - + public: int get_entity_data_id() const; void set_entity_data_id(const int value); diff --git a/props/prop_data_entry.cpp b/props/prop_data_entry.cpp index 74cfac6..3cc7b5c 100644 --- a/props/prop_data_entry.cpp +++ b/props/prop_data_entry.cpp @@ -8,10 +8,8 @@ void PropDataEntry::set_transform(const Transform value) { } PropDataEntry::PropDataEntry() { - } PropDataEntry::~PropDataEntry() { - } void PropDataEntry::_bind_methods() { diff --git a/props/prop_data_entry.h b/props/prop_data_entry.h index e04ed14..3712d9e 100644 --- a/props/prop_data_entry.h +++ b/props/prop_data_entry.h @@ -1,14 +1,13 @@ #ifndef PROP_DATA_DATA_H #define PROP_DATA_DATA_H -#include "core/resource.h" #include "core/math/transform.h" +#include "core/resource.h" class PropDataEntry : public Resource { GDCLASS(PropDataEntry, Resource); - -public: +public: Transform get_transform() const; void set_transform(const Transform value); @@ -19,7 +18,6 @@ protected: static void _bind_methods(); private: - Transform _transform; }; diff --git a/props/prop_data_light.cpp b/props/prop_data_light.cpp index 34f48eb..636af6c 100644 --- a/props/prop_data_light.cpp +++ b/props/prop_data_light.cpp @@ -1,6 +1,5 @@ #include "prop_data_light.h" - Color PropDataLight::get_light_color() const { return _light_color; } diff --git a/props/prop_data_light.h b/props/prop_data_light.h index 22ea7f9..732760f 100644 --- a/props/prop_data_light.h +++ b/props/prop_data_light.h @@ -7,7 +7,7 @@ class PropDataLight : public PropDataEntry { GDCLASS(PropDataLight, PropDataEntry); - + public: Color get_light_color() const; void set_light_color(const Color value); diff --git a/props/prop_data_mesh.h b/props/prop_data_mesh.h index 285be48..7e88ba9 100644 --- a/props/prop_data_mesh.h +++ b/props/prop_data_mesh.h @@ -1,8 +1,8 @@ #ifndef PROP_DATA_MESH_H #define PROP_DATA_MESH_H -#include "prop_data_entry.h" #include "core/math/vector3.h" +#include "prop_data_entry.h" #include "scene/resources/texture.h" @@ -10,7 +10,7 @@ class PropDataMesh : public PropDataEntry { GDCLASS(PropDataMesh, PropDataEntry); - + public: Ref get_mesh() const; void set_mesh(const Ref mesh); diff --git a/props/prop_data_prop.h b/props/prop_data_prop.h index 29ff534..af3c59e 100644 --- a/props/prop_data_prop.h +++ b/props/prop_data_prop.h @@ -1,14 +1,14 @@ #ifndef PROP_DATA_PROP_H #define PROP_DATA_PROP_H -#include "prop_data_entry.h" #include "core/math/vector3.h" +#include "prop_data_entry.h" #include "prop_data.h" class PropDataProp : public PropDataEntry { GDCLASS(PropDataProp, PropDataEntry); - + public: Ref get_prop() const; void set_prop(const Ref value); diff --git a/props/prop_data_scene.h b/props/prop_data_scene.h index adeee34..193dcb6 100644 --- a/props/prop_data_scene.h +++ b/props/prop_data_scene.h @@ -1,14 +1,14 @@ #ifndef PROP_DATA_SCENE_H #define PROP_DATA_SCENE_H -#include "prop_data_entry.h" #include "core/math/vector3.h" +#include "prop_data_entry.h" #include "scene/resources/packed_scene.h" class PropDataScene : public PropDataEntry { GDCLASS(PropDataScene, PropDataEntry); - + public: Ref get_scene() const; void set_scene(const Ref value); diff --git a/register_types.cpp b/register_types.cpp index 6926d62..3487e06 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -4,34 +4,34 @@ #include "containers/voxelman_unbounded_queue.h" #include "library/voxel_surface.h" -#include "library/voxel_surface_simple.h" #include "library/voxel_surface_merger.h" +#include "library/voxel_surface_simple.h" #include "library/voxelman_library.h" -#include "library/voxelman_library_simple.h" #include "library/voxelman_library_merger.h" +#include "library/voxelman_library_simple.h" #include "data/voxel_light.h" -#include "meshers/voxel_mesher.h" #include "meshers/transvoxel_cell_data.h" +#include "meshers/voxel_mesher.h" #include "meshers/voxel_mesher_transvoxel.h" -#include "world/voxel_world.h" -#include "world/voxel_chunk.h" -#include "world/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" -#include "meshers/cubic_mesher/voxel_mesher_cubic.h" #include "meshers/cubic_mesher/voxel_cube_points.h" +#include "meshers/cubic_mesher/voxel_mesher_cubic.h" #include "props/prop_data.h" -#include "props/prop_data_entry.h" -#include "props/prop_data_scene.h" -#include "props/prop_data_mesh.h" -#include "props/prop_data_light.h" -#include "props/prop_data_prop.h" #include "props/prop_data_entity.h" +#include "props/prop_data_entry.h" +#include "props/prop_data_light.h" +#include "props/prop_data_mesh.h" +#include "props/prop_data_prop.h" +#include "props/prop_data_scene.h" #include "level_generator/voxelman_level_generator.h" @@ -40,9 +40,8 @@ #include "clutter/ground_clutter.h" #include "clutter/ground_clutter_foliage.h" - void register_voxelman_types() { - ClassDB::register_class();\ + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -58,15 +57,15 @@ void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); - - ClassDB::register_class(); - ClassDB::register_class(); + + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -75,15 +74,13 @@ void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - - ClassDB::register_class(); + + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); -} - -void unregister_voxelman_types() { - } +void unregister_voxelman_types() { +} diff --git a/world/environment_data.h b/world/environment_data.h index b287d5a..3656ae0 100644 --- a/world/environment_data.h +++ b/world/environment_data.h @@ -1,11 +1,11 @@ #ifndef ENVIRONMENT_DATA_H #define ENVIRONMENT_DATA_H -#include "core/resource.h" #include "core/color.h" -#include "scene/main/node.h" -#include "scene/3d/world_environment.h" +#include "core/resource.h" #include "scene/3d/light.h" +#include "scene/3d/world_environment.h" +#include "scene/main/node.h" class EnvironmentData : public Resource { GDCLASS(EnvironmentData, Resource); diff --git a/world/voxel_chunk.cpp b/world/voxel_chunk.cpp index 1b848df..3f8e927 100644 --- a/world/voxel_chunk.cpp +++ b/world/voxel_chunk.cpp @@ -83,11 +83,11 @@ void VoxelChunk::set_position(int x, int y, int z) { _position_z = z; } -_FORCE_INLINE_ int VoxelChunk::get_margin_start() const { - return _margin_start; +_FORCE_INLINE_ int VoxelChunk::get_margin_start() const { + return _margin_start; } _FORCE_INLINE_ int VoxelChunk::get_margin_end() const { - return _margin_end; + return _margin_end; } Ref VoxelChunk::get_library() { @@ -216,7 +216,7 @@ void VoxelChunk::set_size(int size_x, int size_y, int size_z, int margin_start, } for (int i = 0; i < _channels.size(); ++i) { - uint8_t * ch = _channels[i]; + uint8_t *ch = _channels[i]; if (ch != NULL) { memdelete_arr(ch); @@ -245,7 +245,7 @@ uint8_t VoxelChunk::get_voxel(int x, int y, int z, int channel_index) const { ERR_FAIL_INDEX_V(channel_index, _channels.size(), 0); ERR_FAIL_COND_V(!validate_channel_data_position(x, y, z), 0); - uint8_t * ch = _channels.get(channel_index); + uint8_t *ch = _channels.get(channel_index); if (!ch) return 0; @@ -267,7 +267,7 @@ void VoxelChunk::set_channel_count(int count) { if (_channels.size() >= count) { for (int i = count; i < _channels.size(); ++i) { - uint8_t * ch = _channels[i]; + uint8_t *ch = _channels[i]; if (ch != NULL) { memdelete_arr(ch); @@ -287,12 +287,12 @@ void VoxelChunk::set_channel_count(int count) { } void VoxelChunk::allocate_channel(int channel_index, uint8_t default_value) { ERR_FAIL_INDEX(channel_index, _channels.size()); - + if (_channels[channel_index] != NULL) return; uint32_t size = _data_size_x * _data_size_y * _data_size_z; - + uint8_t *ch = memnew_arr(uint8_t, size); memset(ch, default_value, size); @@ -309,7 +309,7 @@ void VoxelChunk::fill_channel(uint8_t value, int channel_index) { } uint32_t size = get_data_size(); - + for (int i = 0; i < size; ++i) { ch[i] = value; } @@ -321,7 +321,7 @@ void VoxelChunk::dealloc_channel(int channel_index) { if (ch != NULL) { memdelete_arr(ch); - + _channels.set(channel_index, NULL); } } @@ -576,13 +576,13 @@ void VoxelChunk::_build_phase(int phase) { if (_clutter_mesh_instance_rid != RID()) VS::get_singleton()->instance_set_visible(_clutter_mesh_instance_rid, is_visible()); - + next_phase(); return; } } - + next_phase(); } @@ -842,7 +842,6 @@ void VoxelChunk::allocate_prop_mesh() { VS::get_singleton()->instance_set_transform(_prop_mesh_instance_rid, Transform(Basis(), Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale))); } - void VoxelChunk::free_prop_mesh() { if (_prop_mesh_instance_rid != RID()) { VS::get_singleton()->free(_prop_mesh_instance_rid); @@ -1117,7 +1116,7 @@ VoxelChunk::~VoxelChunk() { _props.clear(); for (int i = 0; i < _channels.size(); ++i) { - uint8_t * ch = _channels[i]; + uint8_t *ch = _channels[i]; if (ch != NULL) { memdelete_arr(ch); @@ -1186,7 +1185,6 @@ void VoxelChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("get_size_z"), &VoxelChunk::get_size_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "size_z"), "", "get_size_z"); - ClassDB::bind_method(D_METHOD("get_data_size_x"), &VoxelChunk::get_data_size_x); ADD_PROPERTY(PropertyInfo(Variant::INT, "data_size_x"), "", "get_data_size_x"); @@ -1196,7 +1194,6 @@ void VoxelChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("get_data_size_z"), &VoxelChunk::get_data_size_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "data_size_z"), "", "get_data_size_z"); - ClassDB::bind_method(D_METHOD("get_position"), &VoxelChunk::get_position); ClassDB::bind_method(D_METHOD("get_size"), &VoxelChunk::get_size); ClassDB::bind_method(D_METHOD("set_position", "x", "y", "z"), &VoxelChunk::set_position); @@ -1204,7 +1201,6 @@ void VoxelChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("get_margin_start"), &VoxelChunk::get_margin_start); ClassDB::bind_method(D_METHOD("get_margin_end"), &VoxelChunk::get_margin_end); - ClassDB::bind_method(D_METHOD("get_library"), &VoxelChunk::get_library); ClassDB::bind_method(D_METHOD("set_library", "value"), &VoxelChunk::set_library); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"), "set_library", "get_library"); @@ -1385,5 +1381,4 @@ void VoxelChunk::_bind_methods() { BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_FILL); BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_LIQUID_FLOW); BIND_ENUM_CONSTANT(MAX_DEFAULT_CHANNELS); - } diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index e547a6f..4a6efa1 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -4,17 +4,17 @@ #include "scene/3d/spatial.h" #include "core/engine.h" -#include "core/ustring.h" #include "core/os/thread.h" #include "core/os/thread_safe.h" +#include "core/ustring.h" -#include "scene/3d/mesh_instance.h" -#include "scene/resources/packed_scene.h" #include "core/array.h" #include "scene/3d/collision_shape.h" +#include "scene/3d/mesh_instance.h" #include "scene/3d/physics_body.h" -#include "scene/resources/concave_polygon_shape.h" #include "scene/3d/spatial.h" +#include "scene/resources/concave_polygon_shape.h" +#include "scene/resources/packed_scene.h" #include "voxel_world.h" @@ -29,9 +29,9 @@ #include "../../mesh_data_resource/mesh_data_resource.h" #include "../props/prop_data.h" #include "../props/prop_data_entry.h" -#include "../props/prop_data_scene.h" -#include "../props/prop_data_mesh.h" #include "../props/prop_data_light.h" +#include "../props/prop_data_mesh.h" +#include "../props/prop_data_scene.h" #include "voxel_chunk_prop_data.h" class VoxelWorld; @@ -72,7 +72,7 @@ public: DEFAULT_CHANNEL_LIGHT_COLOR_R, DEFAULT_CHANNEL_LIGHT_COLOR_G, DEFAULT_CHANNEL_LIGHT_COLOR_B, - DEFAULT_CHANNEL_AO, + DEFAULT_CHANNEL_AO, DEFAULT_CHANNEL_RANDOM_AO, DEFAULT_CHANNEL_LIQUID_TYPES, DEFAULT_CHANNEL_LIQUID_FILL, @@ -177,11 +177,11 @@ public: uint32_t get_data_index(uint32_t x, uint32_t y, uint32_t z) const; uint32_t get_data_size() const; - + //Data Management functions void generate_ao(); - void add_light(int local_x, int local_y, int local_z, int size, Color color); + void add_light(int local_x, int local_y, int local_z, int size, Color color); void clear_baked_lights(); //Meshing @@ -195,7 +195,7 @@ public: void build_phase(); void _build_phase(int phase); void next_phase(); - + void clear(); //Colliders @@ -211,13 +211,13 @@ public: void clear_voxel_lights(); void add_lights_into(Array target); - void add_unique_lights_into(Array target); - Array get_lights(); + void add_unique_lights_into(Array target); + Array get_lights(); - void bake_lights(); + void bake_lights(); void bake_light(Ref light); - - void add_prop_light(Ref light); + + void add_prop_light(Ref light); //props void add_prop(Ref prop); @@ -226,20 +226,20 @@ public: void remove_prop(int index); void clear_props(); - void process_props(); - + void process_props(); + void build_prop_meshes(); void build_prop_collider(); - void free_spawn_props(); + void free_spawn_props(); //Meshes - void allocate_main_mesh(); + void allocate_main_mesh(); void free_main_mesh(); - + void allocate_prop_mesh(); void free_prop_mesh(); - - void allocate_prop_colliders(); + + void allocate_prop_colliders(); void free_prop_colliders(); void allocate_liquid_mesh(); diff --git a/world/voxel_chunk_prop_data.h b/world/voxel_chunk_prop_data.h index a75faec..9e50456 100644 --- a/world/voxel_chunk_prop_data.h +++ b/world/voxel_chunk_prop_data.h @@ -1,18 +1,18 @@ #ifndef VOXEL_CHUNK_PROP_DATA_H #define VOXEL_CHUNK_PROP_DATA_H -#include "core/reference.h" #include "core/math/vector3.h" +#include "core/reference.h" -#include "scene/resources/texture.h" -#include "scene/resources/packed_scene.h" +#include "../../mesh_data_resource/mesh_data_resource.h" #include "../props/prop_data.h" #include "../props/prop_data_light.h" -#include "../../mesh_data_resource/mesh_data_resource.h" +#include "scene/resources/packed_scene.h" +#include "scene/resources/texture.h" class VoxelChunkPropData : public Reference { GDCLASS(VoxelChunkPropData, Reference); - + public: int get_x(); void set_x(int value); diff --git a/world/voxel_structure.cpp b/world/voxel_structure.cpp index 641d403..ae87182 100644 --- a/world/voxel_structure.cpp +++ b/world/voxel_structure.cpp @@ -45,7 +45,7 @@ void VoxelStructure::set_world_position_z(const int value) { VoxelChunk *VoxelStructure::get_chunk_voxel_pos(int x, int y, int z) { VoxelChunk *b = get_chunk(x / _chunk_size_x, y / _chunk_size_y, z / _chunk_size_z); -/* + /* if (!b.is_valid()) { b.instance(); @@ -71,7 +71,6 @@ void VoxelStructure::set_voxel(int value, int x, int y, int z, unsigned int chan } void add_chunk_bind(Node *chunk, const int x, const int y, const int z) { - } void VoxelStructure::add_chunk(VoxelChunk *chunk, const int x, const int y, const int z) { //_chunks.set(Vector3i(x, y, z), chunk); diff --git a/world/voxel_structure.h b/world/voxel_structure.h index eaac173..c6e5667 100644 --- a/world/voxel_structure.h +++ b/world/voxel_structure.h @@ -19,7 +19,6 @@ public: int get_chunk_size_z() const; void set_chunk_size_z(const int value); - int get_world_position_x() const; void set_world_position_x(const int value); @@ -47,7 +46,7 @@ public: VoxelStructure(); ~VoxelStructure(); - + protected: static void _bind_methods(); @@ -74,8 +73,8 @@ private: int _world_position_y; int _world_position_z; - HashMap _chunks; - Vector _chunks_vector; + HashMap _chunks; + Vector _chunks_vector; }; #endif diff --git a/world/voxel_world.cpp b/world/voxel_world.cpp index 7573c96..f2a2953 100644 --- a/world/voxel_world.cpp +++ b/world/voxel_world.cpp @@ -199,7 +199,6 @@ int VoxelWorld::get_generation_size() { return _generating.size(); } - void VoxelWorld::clear() { for (int i = 0; i < _chunks_vector.size(); ++i) { _chunks_vector.get(i)->queue_delete(); @@ -218,7 +217,7 @@ VoxelChunk *VoxelWorld::create_chunk(int x, int y, int z) { Node *n = call("_create_chunk", x, y, z, np); - return(Object::cast_to(n)); + return (Object::cast_to(n)); } VoxelChunk *VoxelWorld::_create_chunk(int x, int y, int z, Node *p_chunk) { VoxelChunk *chunk; @@ -263,7 +262,6 @@ void VoxelWorld::generate_chunk(VoxelChunk *p_chunk) { if (has_method("_prepare_chunk_for_generation")) call("_prepare_chunk_for_generation", p_chunk); - call("_generate_chunk", p_chunk); p_chunk->build(); @@ -439,7 +437,7 @@ void VoxelWorld::_bind_methods() { BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); ClassDB::bind_method(D_METHOD("create_chunk", "x", "y", "z"), &VoxelWorld::create_chunk); - ClassDB::bind_method(D_METHOD("_create_chunk", "x", "y", "z", "chunk"), &VoxelWorld::_create_chunk); + ClassDB::bind_method(D_METHOD("_create_chunk", "x", "y", "z", "chunk"), &VoxelWorld::_create_chunk); - ClassDB::bind_method(D_METHOD("_generate_chunk", "chunk"), &VoxelWorld::_generate_chunk); + ClassDB::bind_method(D_METHOD("_generate_chunk", "chunk"), &VoxelWorld::_generate_chunk); } diff --git a/world/voxel_world.h b/world/voxel_world.h index 318109c..e440363 100644 --- a/world/voxel_world.h +++ b/world/voxel_world.h @@ -1,13 +1,13 @@ #ifndef VOXEL_WORLD_H #define VOXEL_WORLD_H -#include "scene/3d/navigation.h" -#include "core/hash_map.h" #include "core/engine.h" +#include "core/hash_map.h" +#include "scene/3d/navigation.h" -#include "../library/voxelman_library.h" -#include "../level_generator/voxelman_level_generator.h" #include "../areas/world_area.h" +#include "../level_generator/voxelman_level_generator.h" +#include "../library/voxelman_library.h" #include "core/os/os.h" @@ -17,29 +17,29 @@ class VoxelWorld : public Navigation { GDCLASS(VoxelWorld, Navigation); public: - int get_chunk_size_x() const; - void set_chunk_size_x(const int value); - - int get_chunk_size_y() const; - void set_chunk_size_y(const int value); - - int get_chunk_size_z() const; - void set_chunk_size_z(const int value); + int get_chunk_size_x() const; + void set_chunk_size_x(const int value); - int get_current_seed() const; - void set_current_seed(const int value); + int get_chunk_size_y() const; + void set_chunk_size_y(const int value); + + int get_chunk_size_z() const; + void set_chunk_size_z(const int value); + + int get_current_seed() const; + void set_current_seed(const int value); bool get_use_threads(); void set_use_threads(bool value); uint32_t get_max_concurrent_generations(); void set_max_concurrent_generations(uint32_t value); - - Ref get_library() const; - void set_library(const Ref library); - - Ref get_level_generator() const; - void set_level_generator(const Ref level_generator); + + Ref get_library() const; + void set_library(const Ref library); + + Ref get_level_generator() const; + void set_level_generator(const Ref level_generator); float get_voxel_scale() const; void set_voxel_scale(const float value); @@ -49,8 +49,8 @@ public: NodePath get_player_path(); void set_player_path(NodePath player_path); - - Spatial *get_player() const; + + Spatial *get_player() const; void set_player(Spatial *player); void set_player_bind(Node *player); @@ -124,18 +124,18 @@ public: }; private: - int _chunk_size_x; + int _chunk_size_x; int _chunk_size_y; int _chunk_size_z; int _current_seed; - - Ref _library; - Ref _level_generator; + + Ref _library; + Ref _level_generator; float _voxel_scale; int _chunk_spawn_range; - - HashMap _chunks; - Vector _chunks_vector; + + HashMap _chunks; + Vector _chunks_vector; Vector > _world_areas;