0

Add .clang_format

Also applies clang-format to the current code base, using command:
`find . -regex '.*\.\(c\|h\)' -exec clang-format -style=file -i {} \;`
This commit is contained in:
Wunkolo
2019-06-23 18:43:32 -07:00
parent 676bf32af9
commit 8162f3f877
36 changed files with 1299 additions and 1372 deletions

View File

@@ -15,40 +15,40 @@
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../overviewer.h"
#include <math.h>
#include "../overviewer.h"
typedef struct {
int only_lit;
} RenderPrimitiveCave;
static inline int
touches_light(RenderState *state, DataType type, unsigned int x, unsigned int y, unsigned int z) {
if (get_data(state, type, x, y+1, z))
touches_light(RenderState* state, DataType type, unsigned int x, unsigned int y, unsigned int z) {
if (get_data(state, type, x, y + 1, z))
return 1;
if (get_data(state, type, x+1, y, z))
if (get_data(state, type, x + 1, y, z))
return 1;
if (get_data(state, type, x-1, y, z))
if (get_data(state, type, x - 1, y, z))
return 1;
if (get_data(state, type, x, y, z+1))
if (get_data(state, type, x, y, z + 1))
return 1;
if (get_data(state, type, x, y, z-1))
if (get_data(state, type, x, y, z - 1))
return 1;
return 0;
}
static int
cave_occluded(void *data, RenderState *state, int x, int y, int z) {
cave_occluded(void* data, RenderState* state, int x, int y, int z) {
/* check for normal occlusion */
/* use ajacent chunks, if not you get blocks spreaded in chunk edges */
if (!is_known_transparent(get_data(state, BLOCKS, x-1, y, z)) &&
!is_known_transparent(get_data(state, BLOCKS, x, y, z+1)) &&
!is_known_transparent(get_data(state, BLOCKS, x, y+1, z))) {
if (!is_known_transparent(get_data(state, BLOCKS, x - 1, y, z)) &&
!is_known_transparent(get_data(state, BLOCKS, x, y, z + 1)) &&
!is_known_transparent(get_data(state, BLOCKS, x, y + 1, z))) {
return 1;
}
/* special handling for section boundaries */
if (x == 0 && (!(state->chunks[0][1].loaded) || state->chunks[0][1].sections[state->chunky].blocks == NULL))
return 1;
@@ -56,21 +56,21 @@ cave_occluded(void *data, RenderState *state, int x, int y, int z) {
return 1;
if (z == 15 && (!(state->chunks[1][2].loaded) || state->chunks[1][2].sections[state->chunky].blocks == NULL))
return 1;
return 0;
}
static int
cave_hidden(void *data, RenderState *state, int x, int y, int z) {
cave_hidden(void* data, RenderState* state, int x, int y, int z) {
RenderPrimitiveCave* self;
int dy = 0;
self = (RenderPrimitiveCave *)data;
self = (RenderPrimitiveCave*)data;
/* check if the block is touching skylight */
if (touches_light(state, SKYLIGHT, x, y, z)) {
return 1;
}
if (self->only_lit && !touches_light(state, BLOCKLIGHT, x, y, z)) {
return 1;
}
@@ -80,9 +80,9 @@ cave_hidden(void *data, RenderState *state, int x, int y, int z) {
* but a deep sea can be completely dark
*/
if ((getArrayShort3D(state->blocks, x, y, z) == 9) ||
(get_data(state, BLOCKS, x, y+1, z) == 9)) {
for (dy = y+1; dy < (SECTIONS_PER_CHUNK - state->chunky) * 16; dy++) {
(get_data(state, BLOCKS, x, y + 1, z) == 9)) {
for (dy = y + 1; dy < (SECTIONS_PER_CHUNK - state->chunky) * 16; dy++) {
/* go up and check for skylight */
if (get_data(state, SKYLIGHT, x, dy, z) != 0) {
return 1;
@@ -94,7 +94,7 @@ cave_hidden(void *data, RenderState *state, int x, int y, int z) {
}
}
}
/* unfortunate side-effect of lit cave mode: we need to count occluded
* blocks as hidden for the lighting to look right, since technically our
* hiding depends on occlusion as well
@@ -103,18 +103,19 @@ cave_hidden(void *data, RenderState *state, int x, int y, int z) {
}
static int
cave_start(void *data, RenderState *state, PyObject *support) {
cave_start(void* data, RenderState* state, PyObject* support) {
RenderPrimitiveCave* self;
self = (RenderPrimitiveCave *)data;
self = (RenderPrimitiveCave*)data;
if (!render_mode_parse_option(support, "only_lit", "i", &(self->only_lit)))
return 1;
return 0;
}
RenderPrimitiveInterface primitive_cave = {
"cave", sizeof(RenderPrimitiveCave),
"cave",
sizeof(RenderPrimitiveCave),
cave_start,
NULL,
cave_occluded,