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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,8 @@
#include "voxel_library.h"
VoxelLibrary::VoxelLibrary() :
Resource(), _atlas_size(1) {
Resource(),
_atlas_size(1) {
}
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) {
p_list->push_back(PropertyInfo(Variant::OBJECT, "voxels/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "Voxel"));
}
}
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");
}

View File

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

View File

@ -1,6 +1,6 @@
#include <core/os/os.h>
#include "voxel_mesh_updater.h"
#include "utility.h"
#include <core/os/os.h>
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());
}
}

View File

@ -1,13 +1,13 @@
#ifndef VOXEL_MESH_UPDATER_H
#define VOXEL_MESH_UPDATER_H
#include <core/vector.h>
#include <core/os/semaphore.h>
#include <core/os/thread.h>
#include <core/vector.h>
#include "transvoxel/voxel_mesher_transvoxel.h"
#include "voxel_buffer.h"
#include "voxel_mesher.h"
#include "transvoxel/voxel_mesher_transvoxel.h"
class VoxelMeshUpdater {
public:
@ -37,7 +37,11 @@ public:
uint64_t max_time;
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 {
@ -49,8 +53,9 @@ public:
bool baked_ao;
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);

View File

@ -1,7 +1,7 @@
#include "voxel_mesher.h"
#include "voxel_library.h"
#include "cube_tables.h"
#include "utility.h"
#include "voxel_library.h"
#include <core/os/os.h>
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));
}
VoxelMesher::VoxelMesher()
: _baked_occlusion_darkness(0.8),
VoxelMesher::VoxelMesher() :
_baked_occlusion_darkness(0.8),
_bake_occlusion(true) {}
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(memarr_len(type_buffer) != buffer.get_volume() * sizeof(uint8_t));
// Build lookup tables so to speed up voxel access.

View File

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

View File

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

View File

@ -126,5 +126,3 @@ void VoxelProviderTest::_bind_methods() {
BIND_ENUM_CONSTANT(MODE_FLAT);
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.h"
#include "voxel_map.h"
#include "core/os/os.h"
#include "core/os/semaphore.h"
#include "core/os/thread.h"
#include "utility.h"
#include "voxel_map.h"
#include "voxel_provider.h"
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());
}
}

View File

@ -37,7 +37,11 @@ public:
uint64_t max_time;
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 {

View File

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

View File

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