Clang-format did things

This commit is contained in:
Marc Gilleron 2019-04-24 01:29:47 +01:00
parent 70881ce255
commit 1b9e7257df
18 changed files with 210 additions and 206 deletions

View File

@ -7,15 +7,18 @@
class Rect3i { class Rect3i {
public: public:
Vector3i pos; Vector3i pos;
Vector3i size; Vector3i size;
Rect3i() {} Rect3i() {}
Rect3i(Vector3i p_pos, Vector3i p_size) : pos(p_pos), size(p_size) {} Rect3i(Vector3i p_pos, Vector3i p_size) :
pos(p_pos),
size(p_size) {}
Rect3i(const Rect3i &other) : pos(other.pos), size(other.size) {} Rect3i(const Rect3i &other) :
pos(other.pos),
size(other.size) {}
static inline Rect3i from_center_extents(Vector3i center, Vector3i extents) { static inline Rect3i from_center_extents(Vector3i center, Vector3i extents) {
return Rect3i(center - extents, 2 * extents); return Rect3i(center - extents, 2 * extents);
@ -41,12 +44,12 @@ public:
bool inline contains(Vector3i p_pos) const { bool inline contains(Vector3i p_pos) const {
Vector3i end = pos + size; Vector3i end = pos + size;
return p_pos.x >= pos.x return p_pos.x >= pos.x &&
&& p_pos.y >= pos.y p_pos.y >= pos.y &&
&& p_pos.z >= pos.z p_pos.z >= pos.z &&
&& p_pos.x < end.x p_pos.x < end.x &&
&& p_pos.y < end.y p_pos.y < end.y &&
&& p_pos.z < end.z; p_pos.z < end.z;
} }
String to_string() const { String to_string() const {
@ -68,7 +71,6 @@ public:
return false; return false;
return true; return true;
} }
}; };
inline bool operator!=(const Rect3i &a, const Rect3i &b) { inline bool operator!=(const Rect3i &a, const Rect3i &b) {

View File

@ -15,14 +15,20 @@ struct Vector3i {
int coords[3]; int coords[3];
}; };
_FORCE_INLINE_ Vector3i() _FORCE_INLINE_ Vector3i() :
: x(0), y(0), z(0) {} x(0),
y(0),
z(0) {}
_FORCE_INLINE_ Vector3i(int xyz) _FORCE_INLINE_ Vector3i(int xyz) :
: x(xyz), y(xyz), z(xyz) {} x(xyz),
y(xyz),
z(xyz) {}
_FORCE_INLINE_ Vector3i(int px, int py, int pz) _FORCE_INLINE_ Vector3i(int px, int py, int pz) :
: x(px), y(py), z(pz) {} x(px),
y(py),
z(pz) {}
_FORCE_INLINE_ Vector3i(const Vector3i &other) { _FORCE_INLINE_ Vector3i(const Vector3i &other) {
*this = other; *this = other;

View File

@ -11,8 +11,7 @@ Voxel::Voxel():
_is_transparent(false), _is_transparent(false),
_color(1.f, 1.f, 1.f), _color(1.f, 1.f, 1.f),
_geometry_type(GEOMETRY_NONE), _geometry_type(GEOMETRY_NONE),
_cube_geometry_padding_y(0) _cube_geometry_padding_y(0) {}
{}
static Cube::Side name_to_side(const String &s) { static Cube::Side name_to_side(const String &s) {
if (s == "left") if (s == "left")

View File

@ -1,8 +1,8 @@
#ifndef VOXEL_TYPE_H #ifndef VOXEL_TYPE_H
#define VOXEL_TYPE_H #define VOXEL_TYPE_H
#include <core/resource.h>
#include "cube_tables.h" #include "cube_tables.h"
#include <core/resource.h>
class VoxelLibrary; class VoxelLibrary;

View File

@ -15,8 +15,9 @@ VoxelBlock *VoxelBlock::create(Vector3i bpos, Ref<VoxelBuffer> buffer, unsigned
return block; return block;
} }
VoxelBlock::VoxelBlock() VoxelBlock::VoxelBlock() :
: voxels(NULL), _mesh_update_count(0) { voxels(NULL),
_mesh_update_count(0) {
VisualServer &vs = *VisualServer::get_singleton(); VisualServer &vs = *VisualServer::get_singleton();
@ -82,5 +83,3 @@ void VoxelBlock::set_visible(bool visible) {
vs.instance_set_visible(_mesh_instance, visible); vs.instance_set_visible(_mesh_instance, visible);
} }
} }

View File

@ -161,4 +161,3 @@ void VoxelBoxMover::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_motion", "pos", "motion", "aabb", "terrain"), &VoxelBoxMover::_get_motion_binding); ClassDB::bind_method(D_METHOD("get_motion", "pos", "motion", "aabb", "terrain"), &VoxelBoxMover::_get_motion_binding);
} }

View File

@ -1,7 +1,8 @@
#include "voxel_library.h" #include "voxel_library.h"
VoxelLibrary::VoxelLibrary() : VoxelLibrary::VoxelLibrary() :
Resource(), _atlas_size(1) { Resource(),
_atlas_size(1) {
} }
VoxelLibrary::~VoxelLibrary() { VoxelLibrary::~VoxelLibrary() {
@ -90,7 +91,6 @@ void VoxelLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
for (int i = 0; i < MAX_VOXEL_TYPES; ++i) { for (int i = 0; i < MAX_VOXEL_TYPES; ++i) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "voxels/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Voxel")); p_list->push_back(PropertyInfo(Variant::OBJECT, "voxels/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Voxel"));
} }
} }
void VoxelLibrary::set_atlas_size(int s) { void VoxelLibrary::set_atlas_size(int s) {
@ -123,5 +123,3 @@ void VoxelLibrary::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "atlas_size"), "set_atlas_size", "get_atlas_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "atlas_size"), "set_atlas_size", "get_atlas_size");
} }

View File

@ -1,12 +1,11 @@
#include "voxel_map.h" #include "voxel_map.h"
#include "voxel_block.h"
#include "cube_tables.h" #include "cube_tables.h"
#include "voxel_block.h"
#include "core/os/os.h" #include "core/os/os.h"
VoxelMap::VoxelMap() :
VoxelMap::VoxelMap() _last_accessed_block(NULL) {
: _last_accessed_block(NULL) {
// TODO Make it configurable in editor (with all necessary notifications and updatings!) // TODO Make it configurable in editor (with all necessary notifications and updatings!)
set_block_size_pow2(4); set_block_size_pow2(4);

View File

@ -1,6 +1,6 @@
#include <core/os/os.h>
#include "voxel_mesh_updater.h" #include "voxel_mesh_updater.h"
#include "utility.h" #include "utility.h"
#include <core/os/os.h>
VoxelMeshUpdater::VoxelMeshUpdater(Ref<VoxelLibrary> library, MeshingParams params) { VoxelMeshUpdater::VoxelMeshUpdater(Ref<VoxelLibrary> library, MeshingParams params) {
@ -244,4 +244,3 @@ void VoxelMeshUpdater::thread_sync(int queue_index, Stats stats) {
sorter.sort(_input.blocks.ptrw(), _input.blocks.size()); sorter.sort(_input.blocks.ptrw(), _input.blocks.size());
} }
} }

View File

@ -1,13 +1,13 @@
#ifndef VOXEL_MESH_UPDATER_H #ifndef VOXEL_MESH_UPDATER_H
#define VOXEL_MESH_UPDATER_H #define VOXEL_MESH_UPDATER_H
#include <core/vector.h>
#include <core/os/semaphore.h> #include <core/os/semaphore.h>
#include <core/os/thread.h> #include <core/os/thread.h>
#include <core/vector.h>
#include "transvoxel/voxel_mesher_transvoxel.h"
#include "voxel_buffer.h" #include "voxel_buffer.h"
#include "voxel_mesher.h" #include "voxel_mesher.h"
#include "transvoxel/voxel_mesher_transvoxel.h"
class VoxelMeshUpdater { class VoxelMeshUpdater {
public: public:
@ -37,7 +37,11 @@ public:
uint64_t max_time; uint64_t max_time;
uint32_t remaining_blocks; uint32_t remaining_blocks;
Stats() : first(true), min_time(0), max_time(0), remaining_blocks(0) {} Stats() :
first(true),
min_time(0),
max_time(0),
remaining_blocks(0) {}
}; };
struct Output { struct Output {
@ -49,8 +53,9 @@ public:
bool baked_ao; bool baked_ao;
float baked_ao_darkness; float baked_ao_darkness;
MeshingParams(): baked_ao(true), baked_ao_darkness(0.75) MeshingParams() :
{ } baked_ao(true),
baked_ao_darkness(0.75) {}
}; };
VoxelMeshUpdater(Ref<VoxelLibrary> library, MeshingParams params); VoxelMeshUpdater(Ref<VoxelLibrary> library, MeshingParams params);

View File

@ -1,7 +1,7 @@
#include "voxel_mesher.h" #include "voxel_mesher.h"
#include "voxel_library.h"
#include "cube_tables.h" #include "cube_tables.h"
#include "utility.h" #include "utility.h"
#include "voxel_library.h"
#include <core/os/os.h> #include <core/os/os.h>
template <typename T> template <typename T>
@ -11,9 +11,8 @@ void raw_copy_to(PoolVector<T> &to, const Vector<T> &from) {
memcpy(w.ptr(), from.ptr(), from.size() * sizeof(T)); memcpy(w.ptr(), from.ptr(), from.size() * sizeof(T));
} }
VoxelMesher::VoxelMesher() :
VoxelMesher::VoxelMesher() _baked_occlusion_darkness(0.8),
: _baked_occlusion_darkness(0.8),
_bake_occlusion(true) {} _bake_occlusion(true) {}
void VoxelMesher::set_library(Ref<VoxelLibrary> library) { void VoxelMesher::set_library(Ref<VoxelLibrary> library) {
@ -132,7 +131,6 @@ Array VoxelMesher::build(const VoxelBuffer &buffer, unsigned int channel, Vector
// \ / // \ /
CRASH_COND(type_buffer == NULL); CRASH_COND(type_buffer == NULL);
//CRASH_COND(memarr_len(type_buffer) != buffer.get_volume() * sizeof(uint8_t)); //CRASH_COND(memarr_len(type_buffer) != buffer.get_volume() * sizeof(uint8_t));
// Build lookup tables so to speed up voxel access. // Build lookup tables so to speed up voxel access.

View File

@ -1,8 +1,8 @@
#ifndef VOXEL_PROVIDER_H #ifndef VOXEL_PROVIDER_H
#define VOXEL_PROVIDER_H #define VOXEL_PROVIDER_H
#include <core/resource.h>
#include "voxel_buffer.h" #include "voxel_buffer.h"
#include <core/resource.h>
class VoxelProvider : public Resource { class VoxelProvider : public Resource {
GDCLASS(VoxelProvider, Resource) GDCLASS(VoxelProvider, Resource)

View File

@ -4,6 +4,7 @@
#include "voxel_provider.h" #include "voxel_provider.h"
#include <core/image.h> #include <core/image.h>
// TODO Rename VoxelProviderHeightmap
// Provides infinite tiling heightmap based on an image // Provides infinite tiling heightmap based on an image
class VoxelProviderImage : public VoxelProvider { class VoxelProviderImage : public VoxelProvider {
GDCLASS(VoxelProviderImage, VoxelProvider) GDCLASS(VoxelProviderImage, VoxelProvider)

View File

@ -126,5 +126,3 @@ void VoxelProviderTest::_bind_methods() {
BIND_ENUM_CONSTANT(MODE_FLAT); BIND_ENUM_CONSTANT(MODE_FLAT);
BIND_ENUM_CONSTANT(MODE_WAVES); BIND_ENUM_CONSTANT(MODE_WAVES);
} }

View File

@ -1,11 +1,10 @@
#include "core/os/os.h"
#include "core/os/thread.h"
#include "core/os/semaphore.h"
#include "voxel_provider_thread.h" #include "voxel_provider_thread.h"
#include "voxel_provider.h" #include "core/os/os.h"
#include "voxel_map.h" #include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "utility.h" #include "utility.h"
#include "voxel_map.h"
#include "voxel_provider.h"
VoxelProviderThread::VoxelProviderThread(Ref<VoxelProvider> provider, int block_size_pow2) { VoxelProviderThread::VoxelProviderThread(Ref<VoxelProvider> provider, int block_size_pow2) {
@ -202,5 +201,3 @@ void VoxelProviderThread::thread_sync(int emerge_index, Stats stats) {
sorter.sort(_input.blocks_to_emerge.ptrw(), _input.blocks_to_emerge.size()); sorter.sort(_input.blocks_to_emerge.ptrw(), _input.blocks_to_emerge.size());
} }
} }

View File

@ -37,7 +37,11 @@ public:
uint64_t max_time; uint64_t max_time;
int remaining_blocks; int remaining_blocks;
Stats() : first(true), min_time(0), max_time(0), remaining_blocks(0) {} Stats() :
first(true),
min_time(0),
max_time(0),
remaining_blocks(0) {}
}; };
struct OutputData { struct OutputData {

View File

@ -1,18 +1,18 @@
#include "voxel_terrain.h" #include "voxel_terrain.h"
#include "voxel_map.h" #include "utility.h"
#include "voxel_block.h" #include "voxel_block.h"
#include "voxel_map.h"
#include "voxel_provider_test.h"
#include "voxel_provider_thread.h" #include "voxel_provider_thread.h"
#include "voxel_raycast.h" #include "voxel_raycast.h"
#include "voxel_provider_test.h"
#include "utility.h"
#include <core/engine.h>
#include <core/os/os.h> #include <core/os/os.h>
#include <scene/3d/mesh_instance.h> #include <scene/3d/mesh_instance.h>
#include <core/engine.h>
VoxelTerrain::VoxelTerrain() :
VoxelTerrain::VoxelTerrain() Spatial(),
: Spatial(), _generate_collisions(true) { _generate_collisions(true) {
_map = Ref<VoxelMap>(memnew(VoxelMap)); _map = Ref<VoxelMap>(memnew(VoxelMap));
@ -431,7 +431,8 @@ void VoxelTerrain::make_area_dirty(Rect3i box) {
struct EnterWorldAction { struct EnterWorldAction {
World *world; World *world;
EnterWorldAction(World *w) : world(w) {} EnterWorldAction(World *w) :
world(w) {}
void operator()(VoxelBlock *block) { void operator()(VoxelBlock *block) {
block->enter_world(world); block->enter_world(world);
} }
@ -445,7 +446,8 @@ struct ExitWorldAction {
struct SetVisibilityAction { struct SetVisibilityAction {
bool visible; bool visible;
SetVisibilityAction(bool v) : visible(v) {} SetVisibilityAction(bool v) :
visible(v) {}
void operator()(VoxelBlock *block) { void operator()(VoxelBlock *block) {
block->set_visible(visible); block->set_visible(visible);
} }

View File

@ -1,12 +1,12 @@
#ifndef VOXEL_TERRAIN_H #ifndef VOXEL_TERRAIN_H
#define VOXEL_TERRAIN_H #define VOXEL_TERRAIN_H
#include "rect3i.h"
#include "vector3i.h" #include "vector3i.h"
#include "zprofiling.h" #include "voxel_mesh_updater.h"
#include "voxel_provider.h" #include "voxel_provider.h"
#include "voxel_provider_thread.h" #include "voxel_provider_thread.h"
#include "voxel_mesh_updater.h" #include "zprofiling.h"
#include "rect3i.h"
#include <scene/3d/spatial.h> #include <scene/3d/spatial.h>
@ -15,10 +15,9 @@ class VoxelLibrary;
// Infinite static terrain made of voxels. // Infinite static terrain made of voxels.
// It is loaded around VoxelTerrainStreamers. // It is loaded around VoxelTerrainStreamers.
class VoxelTerrain : public Spatial /*, public IVoxelMapObserver*/ { class VoxelTerrain : public Spatial {
GDCLASS(VoxelTerrain, Spatial) GDCLASS(VoxelTerrain, Spatial)
public: public:
enum BlockDirtyState { enum BlockDirtyState {
BLOCK_NONE, BLOCK_NONE,
BLOCK_LOAD, BLOCK_LOAD,
@ -80,8 +79,7 @@ public:
time_send_load_requests(0), time_send_load_requests(0),
time_process_load_responses(0), time_process_load_responses(0),
time_send_update_requests(0), time_send_update_requests(0),
time_process_update_responses(0) time_process_update_responses(0) {}
{ }
}; };
protected: protected: