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:
parent
676bf32af9
commit
8162f3f877
|
@ -0,0 +1,38 @@
|
|||
---
|
||||
Language: Cpp
|
||||
AlignEscapedNewlinesLeft: 'true'
|
||||
AlignTrailingComments: 'true'
|
||||
AllowShortBlocksOnASingleLine: 'false'
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: 'false'
|
||||
AllowShortLoopsOnASingleLine: 'false'
|
||||
ColumnLimit: '0'
|
||||
ContinuationIndentWidth: '4'
|
||||
IndentWidth: '4'
|
||||
SortIncludes: true
|
||||
IncludeCategories:
|
||||
- Regex: '<[[:alnum:].]+>'
|
||||
Priority: -1
|
||||
- Regex: '\".*\"'
|
||||
Priority: 1
|
||||
IndentCaseLabels: false
|
||||
MaxEmptyLinesToKeep: '1'
|
||||
PointerAlignment: Left
|
||||
SpaceBeforeAssignmentOperators: 'true'
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceInEmptyParentheses: 'false'
|
||||
SpacesBeforeTrailingComments: '1'
|
||||
SpacesInCStyleCastParentheses: 'false'
|
||||
SpacesInContainerLiterals: 'false'
|
||||
SpacesInParentheses: 'false'
|
||||
TabWidth: '4'
|
||||
BreakBeforeTernaryOperators: true
|
||||
Cpp11BracedListStyle: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
BeforeElse: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
...
|
|
@ -78,22 +78,19 @@ typedef struct {
|
|||
} Edge;
|
||||
|
||||
static inline void
|
||||
point8(Imaging im, int x, int y, int ink)
|
||||
{
|
||||
point8(Imaging im, int x, int y, int ink) {
|
||||
if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize)
|
||||
im->image8[y][x] = (UINT8)ink;
|
||||
}
|
||||
|
||||
static inline void
|
||||
point32(Imaging im, int x, int y, int ink)
|
||||
{
|
||||
point32(Imaging im, int x, int y, int ink) {
|
||||
if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize)
|
||||
im->image32[y][x] = ink;
|
||||
}
|
||||
|
||||
static inline void
|
||||
point32rgba(Imaging im, int x, int y, int ink)
|
||||
{
|
||||
point32rgba(Imaging im, int x, int y, int ink) {
|
||||
unsigned int tmp1, tmp2;
|
||||
|
||||
if (x >= 0 && x < im->xsize && y >= 0 && y < im->ysize) {
|
||||
|
@ -106,8 +103,7 @@ point32rgba(Imaging im, int x, int y, int ink)
|
|||
}
|
||||
|
||||
static inline void
|
||||
hline8(Imaging im, int x0, int y0, int x1, int ink)
|
||||
{
|
||||
hline8(Imaging im, int x0, int y0, int x1, int ink) {
|
||||
int tmp;
|
||||
|
||||
if (y0 >= 0 && y0 < im->ysize) {
|
||||
|
@ -127,8 +123,7 @@ hline8(Imaging im, int x0, int y0, int x1, int ink)
|
|||
}
|
||||
|
||||
static inline void
|
||||
hline32(Imaging im, int x0, int y0, int x1, int ink)
|
||||
{
|
||||
hline32(Imaging im, int x0, int y0, int x1, int ink) {
|
||||
int tmp;
|
||||
INT32* p;
|
||||
|
||||
|
@ -150,8 +145,7 @@ hline32(Imaging im, int x0, int y0, int x1, int ink)
|
|||
}
|
||||
|
||||
static inline void
|
||||
hline32rgba(Imaging im, int x0, int y0, int x1, int ink)
|
||||
{
|
||||
hline32rgba(Imaging im, int x0, int y0, int x1, int ink) {
|
||||
int tmp;
|
||||
unsigned int tmp1, tmp2;
|
||||
|
||||
|
@ -173,15 +167,15 @@ hline32rgba(Imaging im, int x0, int y0, int x1, int ink)
|
|||
out[0] = OV_BLEND(in[3], out[0], in[0], tmp1, tmp2);
|
||||
out[1] = OV_BLEND(in[3], out[1], in[1], tmp1, tmp2);
|
||||
out[2] = OV_BLEND(in[3], out[2], in[2], tmp1, tmp2);
|
||||
x0++; out += 4;
|
||||
x0++;
|
||||
out += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
line8(Imaging im, int x0, int y0, int x1, int y1, int ink)
|
||||
{
|
||||
line8(Imaging im, int x0, int y0, int x1, int y1, int ink) {
|
||||
int i, n, e;
|
||||
int dx, dy;
|
||||
int xs, ys;
|
||||
|
@ -251,13 +245,11 @@ line8(Imaging im, int x0, int y0, int x1, int y1, int ink)
|
|||
e += dx;
|
||||
y0 += ys;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
line32(Imaging im, int x0, int y0, int x1, int y1, int ink)
|
||||
{
|
||||
line32(Imaging im, int x0, int y0, int x1, int y1, int ink) {
|
||||
int i, n, e;
|
||||
int dx, dy;
|
||||
int xs, ys;
|
||||
|
@ -327,13 +319,11 @@ line32(Imaging im, int x0, int y0, int x1, int y1, int ink)
|
|||
e += dx;
|
||||
y0 += ys;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
line32rgba(Imaging im, int x0, int y0, int x1, int y1, int ink)
|
||||
{
|
||||
line32rgba(Imaging im, int x0, int y0, int x1, int y1, int ink) {
|
||||
int i, n, e;
|
||||
int dx, dy;
|
||||
int xs, ys;
|
||||
|
@ -403,13 +393,11 @@ line32rgba(Imaging im, int x0, int y0, int x1, int y1, int ink)
|
|||
e += dx;
|
||||
y0 += ys;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
x_cmp(const void *x0, const void *x1)
|
||||
{
|
||||
x_cmp(const void* x0, const void* x1) {
|
||||
float diff = *((float*)x0) - *((float*)x1);
|
||||
if (diff < 0)
|
||||
return -1;
|
||||
|
@ -420,8 +408,7 @@ x_cmp(const void *x0, const void *x1)
|
|||
}
|
||||
|
||||
static inline int
|
||||
polygon8(Imaging im, int n, Edge *e, int ink, int eofill)
|
||||
{
|
||||
polygon8(Imaging im, int n, Edge* e, int ink, int eofill) {
|
||||
int i, j;
|
||||
float* xx;
|
||||
int ymin, ymax;
|
||||
|
@ -435,8 +422,10 @@ polygon8(Imaging im, int n, Edge *e, int ink, int eofill)
|
|||
ymin = e[0].ymin;
|
||||
ymax = e[0].ymax;
|
||||
for (i = 1; i < n; i++) {
|
||||
if (e[i].ymin < ymin) ymin = e[i].ymin;
|
||||
if (e[i].ymax > ymax) ymax = e[i].ymax;
|
||||
if (e[i].ymin < ymin)
|
||||
ymin = e[i].ymin;
|
||||
if (e[i].ymax > ymax)
|
||||
ymax = e[i].ymax;
|
||||
}
|
||||
|
||||
if (ymin < 0)
|
||||
|
@ -477,8 +466,7 @@ polygon8(Imaging im, int n, Edge *e, int ink, int eofill)
|
|||
}
|
||||
|
||||
static inline int
|
||||
polygon32(Imaging im, int n, Edge *e, int ink, int eofill)
|
||||
{
|
||||
polygon32(Imaging im, int n, Edge* e, int ink, int eofill) {
|
||||
int i, j;
|
||||
float* xx;
|
||||
int ymin, ymax;
|
||||
|
@ -492,8 +480,10 @@ polygon32(Imaging im, int n, Edge *e, int ink, int eofill)
|
|||
ymin = e[0].ymin;
|
||||
ymax = e[0].ymax;
|
||||
for (i = 1; i < n; i++) {
|
||||
if (e[i].ymin < ymin) ymin = e[i].ymin;
|
||||
if (e[i].ymax > ymax) ymax = e[i].ymax;
|
||||
if (e[i].ymin < ymin)
|
||||
ymin = e[i].ymin;
|
||||
if (e[i].ymax > ymax)
|
||||
ymax = e[i].ymax;
|
||||
}
|
||||
|
||||
if (ymin < 0)
|
||||
|
@ -535,8 +525,7 @@ polygon32(Imaging im, int n, Edge *e, int ink, int eofill)
|
|||
}
|
||||
|
||||
static inline int
|
||||
polygon32rgba(Imaging im, int n, Edge *e, int ink, int eofill)
|
||||
{
|
||||
polygon32rgba(Imaging im, int n, Edge* e, int ink, int eofill) {
|
||||
int i, j;
|
||||
float* xx;
|
||||
int ymin, ymax;
|
||||
|
@ -550,8 +539,10 @@ polygon32rgba(Imaging im, int n, Edge *e, int ink, int eofill)
|
|||
ymin = e[0].ymin;
|
||||
ymax = e[0].ymax;
|
||||
for (i = 1; i < n; i++) {
|
||||
if (e[i].ymin < ymin) ymin = e[i].ymin;
|
||||
if (e[i].ymax > ymax) ymax = e[i].ymax;
|
||||
if (e[i].ymin < ymin)
|
||||
ymin = e[i].ymin;
|
||||
if (e[i].ymax > ymax)
|
||||
ymax = e[i].ymax;
|
||||
}
|
||||
|
||||
if (ymin < 0)
|
||||
|
@ -593,8 +584,7 @@ polygon32rgba(Imaging im, int n, Edge *e, int ink, int eofill)
|
|||
}
|
||||
|
||||
static inline void
|
||||
add_edge(Edge *e, int x0, int y0, int x1, int y1)
|
||||
{
|
||||
add_edge(Edge* e, int x0, int y0, int x1, int y1) {
|
||||
/* printf("edge %d %d %d %d\n", x0, y0, x1, y1); */
|
||||
|
||||
if (x0 <= x1)
|
||||
|
@ -646,9 +636,7 @@ DRAW draw32rgba = { point32rgba, hline32rgba, line32rgba, polygon32rgba };
|
|||
ink = INK32(ink_); \
|
||||
}
|
||||
|
||||
int
|
||||
ImagingDrawPoint(Imaging im, int x0, int y0, const void* ink_, int op)
|
||||
{
|
||||
int ImagingDrawPoint(Imaging im, int x0, int y0, const void* ink_, int op) {
|
||||
DRAW* draw;
|
||||
INT32 ink;
|
||||
|
||||
|
@ -659,10 +647,8 @@ ImagingDrawPoint(Imaging im, int x0, int y0, const void* ink_, int op)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ImagingDrawLine(Imaging im, int x0, int y0, int x1, int y1, const void* ink_,
|
||||
int op)
|
||||
{
|
||||
int ImagingDrawLine(Imaging im, int x0, int y0, int x1, int y1, const void* ink_,
|
||||
int op) {
|
||||
DRAW* draw;
|
||||
INT32 ink;
|
||||
|
||||
|
@ -673,10 +659,8 @@ ImagingDrawLine(Imaging im, int x0, int y0, int x1, int y1, const void* ink_,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ImagingDrawWideLine(Imaging im, int x0, int y0, int x1, int y1,
|
||||
const void* ink_, int width, int op)
|
||||
{
|
||||
int ImagingDrawWideLine(Imaging im, int x0, int y0, int x1, int y1,
|
||||
const void* ink_, int width, int op) {
|
||||
DRAW* draw;
|
||||
INT32 ink;
|
||||
|
||||
|
@ -715,8 +699,6 @@ ImagingDrawWideLine(Imaging im, int x0, int y0, int x1, int y1,
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* standard shapes */
|
||||
|
||||
|
@ -724,7 +706,6 @@ ImagingDrawWideLine(Imaging im, int x0, int y0, int x1, int y1,
|
|||
#define CHORD 1
|
||||
#define PIESLICE 2
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
/* experimental level 2 ("arrow") graphics stuff. this implements
|
||||
|
@ -744,14 +725,9 @@ struct ImagingOutlineInstance {
|
|||
Edge* edges;
|
||||
|
||||
int size;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
void
|
||||
ImagingOutlineDelete(ImagingOutline outline)
|
||||
{
|
||||
void ImagingOutlineDelete(ImagingOutline outline) {
|
||||
if (!outline)
|
||||
return;
|
||||
|
||||
|
@ -761,10 +737,8 @@ ImagingOutlineDelete(ImagingOutline outline)
|
|||
free(outline);
|
||||
}
|
||||
|
||||
|
||||
static Edge*
|
||||
allocate(ImagingOutline outline, int extra)
|
||||
{
|
||||
allocate(ImagingOutline outline, int extra) {
|
||||
Edge* e;
|
||||
|
||||
if (outline->count + extra > outline->size) {
|
||||
|
@ -786,18 +760,14 @@ allocate(ImagingOutline outline, int extra)
|
|||
return e;
|
||||
}
|
||||
|
||||
int
|
||||
ImagingOutlineMove(ImagingOutline outline, float x0, float y0)
|
||||
{
|
||||
int ImagingOutlineMove(ImagingOutline outline, float x0, float y0) {
|
||||
outline->x = outline->x0 = x0;
|
||||
outline->y = outline->y0 = y0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ImagingOutlineLine(ImagingOutline outline, float x1, float y1)
|
||||
{
|
||||
int ImagingOutlineLine(ImagingOutline outline, float x1, float y1) {
|
||||
Edge* e;
|
||||
|
||||
e = allocate(outline, 1);
|
||||
|
@ -812,10 +782,8 @@ ImagingOutlineLine(ImagingOutline outline, float x1, float y1)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ImagingOutlineCurve(ImagingOutline outline, float x1, float y1,
|
||||
float x2, float y2, float x3, float y3)
|
||||
{
|
||||
int ImagingOutlineCurve(ImagingOutline outline, float x1, float y1,
|
||||
float x2, float y2, float x3, float y3) {
|
||||
Edge* e;
|
||||
int i;
|
||||
float xo, yo;
|
||||
|
@ -847,7 +815,6 @@ ImagingOutlineCurve(ImagingOutline outline, float x1, float y1,
|
|||
add_edge(e++, xo, yo, (int)x, (int)y);
|
||||
|
||||
xo = x, yo = y;
|
||||
|
||||
}
|
||||
|
||||
outline->x = xo;
|
||||
|
@ -856,10 +823,8 @@ ImagingOutlineCurve(ImagingOutline outline, float x1, float y1,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ImagingOutlineCurve2(ImagingOutline outline, float cx, float cy,
|
||||
float x3, float y3)
|
||||
{
|
||||
int ImagingOutlineCurve2(ImagingOutline outline, float cx, float cy,
|
||||
float x3, float y3) {
|
||||
/* add bezier curve based on three control points (as
|
||||
in the Flash file format) */
|
||||
|
||||
|
@ -870,19 +835,14 @@ ImagingOutlineCurve2(ImagingOutline outline, float cx, float cy,
|
|||
x3, y3);
|
||||
}
|
||||
|
||||
int
|
||||
ImagingOutlineClose(ImagingOutline outline)
|
||||
{
|
||||
int ImagingOutlineClose(ImagingOutline outline) {
|
||||
if (outline->x == outline->x0 && outline->y == outline->y0)
|
||||
return 0;
|
||||
return ImagingOutlineLine(outline, outline->x0, outline->y0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ImagingDrawOutline(Imaging im, ImagingOutline outline, const void* ink_,
|
||||
int fill, int op)
|
||||
{
|
||||
int ImagingDrawOutline(Imaging im, ImagingOutline outline, const void* ink_,
|
||||
int fill, int op) {
|
||||
DRAW* draw;
|
||||
INT32 ink;
|
||||
|
||||
|
|
|
@ -25,15 +25,13 @@
|
|||
bool block_class_is_subset(
|
||||
mc_block_t block,
|
||||
const mc_block_t block_class[],
|
||||
size_t block_class_len
|
||||
) {
|
||||
size_t block_class_len) {
|
||||
size_t i = 0;
|
||||
|
||||
#ifdef __SSE2__
|
||||
for (; i / 8 < block_class_len / 8; i += 8) {
|
||||
const __m128i block_class_vec = _mm_loadu_si128(
|
||||
(__m128i*)&block_class[i]
|
||||
);
|
||||
(__m128i*)&block_class[i]);
|
||||
const __m128i block_vec = _mm_set1_epi16(block);
|
||||
const __m128i block_cmp = _mm_cmpeq_epi16(block_vec, block_class_vec);
|
||||
if (_mm_movemask_epi8(block_cmp)) {
|
||||
|
@ -44,8 +42,7 @@ bool block_class_is_subset(
|
|||
#ifdef __MMX__
|
||||
for (; i / 4 < block_class_len / 4; i += 4) {
|
||||
const __m64 block_class_vec = _mm_cvtsi64_m64(
|
||||
*(uint64_t*)&block_class[i]
|
||||
);
|
||||
*(uint64_t*)&block_class[i]);
|
||||
const __m64 block_vec = _mm_set1_pi16(block);
|
||||
const __m64 block_cmp = _mm_cmpeq_pi16(block_vec, block_class_vec);
|
||||
if (_mm_cvtm64_si64(block_cmp)) {
|
||||
|
@ -61,7 +58,6 @@ bool block_class_is_subset(
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
const mc_block_t block_class_stair[] = {
|
||||
block_oak_stairs,
|
||||
block_stone_stairs,
|
||||
|
@ -79,8 +75,7 @@ const mc_block_t block_class_stair[] = {
|
|||
block_purpur_stairs,
|
||||
block_prismarine_stairs,
|
||||
block_dark_prismarine_stairs,
|
||||
block_prismarine_brick_stairs
|
||||
};
|
||||
block_prismarine_brick_stairs};
|
||||
const size_t block_class_stair_len = COUNT_OF(block_class_stair);
|
||||
|
||||
const mc_block_t block_class_door[] = {
|
||||
|
@ -90,8 +85,7 @@ const mc_block_t block_class_door[] = {
|
|||
block_birch_door,
|
||||
block_jungle_door,
|
||||
block_acacia_door,
|
||||
block_dark_oak_door
|
||||
};
|
||||
block_dark_oak_door};
|
||||
const size_t block_class_door_len = COUNT_OF(block_class_door);
|
||||
|
||||
const mc_block_t block_class_fence[] = {
|
||||
|
@ -101,8 +95,7 @@ const mc_block_t block_class_fence[] = {
|
|||
block_birch_fence,
|
||||
block_jungle_fence,
|
||||
block_dark_oak_fence,
|
||||
block_acacia_fence
|
||||
};
|
||||
block_acacia_fence};
|
||||
const size_t block_class_fence_len = COUNT_OF(block_class_fence);
|
||||
|
||||
const mc_block_t block_class_fence_gate[] = {
|
||||
|
@ -111,8 +104,7 @@ const mc_block_t block_class_fence_gate[] = {
|
|||
block_birch_fence_gate,
|
||||
block_jungle_fence_gate,
|
||||
block_dark_oak_fence_gate,
|
||||
block_acacia_fence_gate
|
||||
};
|
||||
block_acacia_fence_gate};
|
||||
const size_t block_class_fence_gate_len = COUNT_OF(block_class_fence_gate);
|
||||
|
||||
const mc_block_t block_class_ancil[] = {
|
||||
|
@ -162,8 +154,7 @@ const mc_block_t block_class_ancil[] = {
|
|||
block_birch_fence,
|
||||
block_jungle_fence,
|
||||
block_dark_oak_fence,
|
||||
block_acacia_fence
|
||||
};
|
||||
block_acacia_fence};
|
||||
const size_t block_class_ancil_len = COUNT_OF(block_class_ancil);
|
||||
|
||||
const mc_block_t block_class_alt_height[] = {
|
||||
|
@ -206,7 +197,5 @@ const mc_block_t block_class_alt_height[] = {
|
|||
block_stone_slab2,
|
||||
block_purpur_stairs,
|
||||
block_purpur_slab,
|
||||
block_wooden_slab
|
||||
};
|
||||
block_wooden_slab};
|
||||
const size_t block_class_alt_height_len = COUNT_OF(block_class_alt_height);
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
bool block_class_is_subset(
|
||||
mc_block_t block,
|
||||
const mc_block_t block_class[],
|
||||
size_t block_class_len
|
||||
);
|
||||
size_t block_class_len);
|
||||
|
||||
extern const mc_block_t block_class_stair[];
|
||||
extern const size_t block_class_stair_len;
|
||||
|
@ -48,4 +47,3 @@ extern const mc_block_t block_class_alt_height[];
|
|||
extern const size_t block_class_alt_height_len;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ typedef struct {
|
|||
} ImagingObject;
|
||||
|
||||
inline Imaging
|
||||
imaging_python_to_c(PyObject *obj)
|
||||
{
|
||||
imaging_python_to_c(PyObject* obj) {
|
||||
PyObject* im;
|
||||
Imaging image;
|
||||
|
||||
|
@ -57,8 +56,7 @@ imaging_python_to_c(PyObject *obj)
|
|||
in these composite functions -- even handles auto-sizing to src! */
|
||||
static inline void
|
||||
setup_source_destination(Imaging src, Imaging dest,
|
||||
int *sx, int *sy, int *dx, int *dy, int *xsize, int *ysize)
|
||||
{
|
||||
int* sx, int* sy, int* dx, int* dy, int* xsize, int* ysize) {
|
||||
/* handle negative/zero sizes appropriately */
|
||||
if (*xsize <= 0 || *ysize <= 0) {
|
||||
*xsize = src->xsize;
|
||||
|
@ -231,8 +229,7 @@ alpha_over_full(PyObject *dest, PyObject *src, PyObject *mask, float overall_alp
|
|||
/* wraps alpha_over so it can be called directly from python */
|
||||
/* properly refs the return value when needed: you DO need to decref the return */
|
||||
PyObject*
|
||||
alpha_over_wrap(PyObject *self, PyObject *args)
|
||||
{
|
||||
alpha_over_wrap(PyObject* self, PyObject* args) {
|
||||
/* raw input python variables */
|
||||
PyObject *dest, *src, *pos = NULL, *mask = NULL;
|
||||
/* destination position and size */
|
||||
|
@ -421,9 +418,15 @@ draw_triangle(PyObject *dest, int inclusive,
|
|||
ymax = OV_MIN(ymax, imDest->ysize);
|
||||
|
||||
/* setup coefficients */
|
||||
a12 = y1 - y2; b12 = x2 - x1; c12 = (x1 * y2) - (x2 * y1);
|
||||
a20 = y2 - y0; b20 = x0 - x2; c20 = (x2 * y0) - (x0 * y2);
|
||||
a01 = y0 - y1; b01 = x1 - x0; c01 = (x0 * y1) - (x1 * y0);
|
||||
a12 = y1 - y2;
|
||||
b12 = x2 - x1;
|
||||
c12 = (x1 * y2) - (x2 * y1);
|
||||
a20 = y2 - y0;
|
||||
b20 = x0 - x2;
|
||||
c20 = (x2 * y0) - (x0 * y2);
|
||||
a01 = y0 - y1;
|
||||
b01 = x1 - x0;
|
||||
c01 = (x0 * y1) - (x1 * y0);
|
||||
|
||||
/* setup normalizers */
|
||||
alpha_norm = 1.0f / ((a12 * x0) + (b12 * y0) + c12);
|
||||
|
@ -446,9 +449,12 @@ draw_triangle(PyObject *dest, int inclusive,
|
|||
unsigned int g = alpha * g0 + beta * g1 + gamma * g2;
|
||||
unsigned int b = alpha * b0 + beta * b1 + gamma * b2;
|
||||
|
||||
*out = OV_MULDIV255(*out, r, tmp); out++;
|
||||
*out = OV_MULDIV255(*out, g, tmp); out++;
|
||||
*out = OV_MULDIV255(*out, b, tmp); out++;
|
||||
*out = OV_MULDIV255(*out, r, tmp);
|
||||
out++;
|
||||
*out = OV_MULDIV255(*out, g, tmp);
|
||||
out++;
|
||||
*out = OV_MULDIV255(*out, b, tmp);
|
||||
out++;
|
||||
|
||||
/* keep alpha the same */
|
||||
out++;
|
||||
|
@ -482,9 +488,12 @@ draw_triangle(PyObject *dest, int inclusive,
|
|||
g = alpha * g0 + beta * g1 + gamma * g2;
|
||||
b = alpha * b0 + beta * b1 + gamma * b2;
|
||||
|
||||
*out = OV_MULDIV255(*out, r, tmp); out++;
|
||||
*out = OV_MULDIV255(*out, g, tmp); out++;
|
||||
*out = OV_MULDIV255(*out, b, tmp); out++;
|
||||
*out = OV_MULDIV255(*out, r, tmp);
|
||||
out++;
|
||||
*out = OV_MULDIV255(*out, g, tmp);
|
||||
out++;
|
||||
*out = OV_MULDIV255(*out, b, tmp);
|
||||
out++;
|
||||
}
|
||||
|
||||
return dest;
|
||||
|
@ -572,8 +581,7 @@ resize_half(PyObject *dest, PyObject *src) {
|
|||
in_row1++;
|
||||
in_row2++;
|
||||
|
||||
if (src_has_alpha)
|
||||
{
|
||||
if (src_has_alpha) {
|
||||
a = *in_row1;
|
||||
a += *in_row2;
|
||||
in_row1++;
|
||||
|
@ -594,8 +602,7 @@ resize_half(PyObject *dest, PyObject *src) {
|
|||
in_row1++;
|
||||
in_row2++;
|
||||
|
||||
if (src_has_alpha)
|
||||
{
|
||||
if (src_has_alpha) {
|
||||
a += *in_row1;
|
||||
a += *in_row2;
|
||||
in_row1++;
|
||||
|
@ -610,8 +617,7 @@ resize_half(PyObject *dest, PyObject *src) {
|
|||
*out = (UINT8)(b >> 2);
|
||||
out++;
|
||||
|
||||
if (dest_has_alpha)
|
||||
{
|
||||
if (dest_has_alpha) {
|
||||
*out = (UINT8)(a >> 2);
|
||||
out++;
|
||||
}
|
||||
|
@ -623,8 +629,7 @@ resize_half(PyObject *dest, PyObject *src) {
|
|||
|
||||
/* wraps resize_half so it can be called directly from python */
|
||||
PyObject*
|
||||
resize_half_wrap(PyObject *self, PyObject *args)
|
||||
{
|
||||
resize_half_wrap(PyObject* self, PyObject* args) {
|
||||
/* raw input python variables */
|
||||
PyObject *dest, *src;
|
||||
/* return value: dest image on success */
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "overviewer.h"
|
||||
#include "mc_id.h"
|
||||
#include "block_class.h"
|
||||
#include "mc_id.h"
|
||||
#include "overviewer.h"
|
||||
|
||||
static PyObject* textures = NULL;
|
||||
|
||||
|
@ -132,8 +132,7 @@ int load_chunk(RenderState* state, int x, int z, unsigned char required) {
|
|||
|
||||
/* set up reasonable defaults */
|
||||
dest->biomes = NULL;
|
||||
for (i = 0; i < SECTIONS_PER_CHUNK; i++)
|
||||
{
|
||||
for (i = 0; i < SECTIONS_PER_CHUNK; i++) {
|
||||
dest->sections[i].blocks = NULL;
|
||||
dest->sections[i].data = NULL;
|
||||
dest->sections[i].skylight = NULL;
|
||||
|
@ -389,7 +388,6 @@ generate_pseudo_data(RenderState *state, unsigned short ancilData) {
|
|||
} else {
|
||||
data = ancilData;
|
||||
}
|
||||
|
||||
}
|
||||
return data;
|
||||
} else if (state->block == block_cobblestone_wall) {
|
||||
|
@ -535,7 +533,6 @@ generate_pseudo_data(RenderState *state, unsigned short ancilData) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* TODO triple check this to make sure reference counting is correct */
|
||||
PyObject*
|
||||
chunk_render(PyObject* self, PyObject* args) {
|
||||
|
@ -688,8 +685,7 @@ chunk_render(PyObject *self, PyObject *args) {
|
|||
t = PyList_GET_ITEM(blockmap, max_data * state.block);
|
||||
|
||||
/* if we found a proper texture, render it! */
|
||||
if (t != NULL && t != Py_None)
|
||||
{
|
||||
if (t != NULL && t != Py_None) {
|
||||
PyObject *src, *mask, *mask_light;
|
||||
int do_rand = (state.block == block_tallgrass /*|| state.block == block_red_flower || state.block == block_double_plant*/);
|
||||
int randx = 0, randy = 0;
|
||||
|
|
|
@ -43,13 +43,10 @@ static PyModuleDef COverviewerModule = {
|
|||
"c_overviewer",
|
||||
"", // TODO: Add documentation here.
|
||||
-1,
|
||||
COverviewerMethods
|
||||
};
|
||||
|
||||
COverviewerMethods};
|
||||
|
||||
PyMODINIT_FUNC
|
||||
PyInit_c_overviewer(void)
|
||||
{
|
||||
PyInit_c_overviewer(void) {
|
||||
PyObject *mod, *numpy;
|
||||
mod = PyModule_Create(&COverviewerModule);
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
enum mc_block_id
|
||||
{
|
||||
enum mc_block_id {
|
||||
block_air = 0,
|
||||
block_stone = 1,
|
||||
block_grass = 2,
|
||||
|
@ -284,9 +283,7 @@ enum mc_block_id
|
|||
|
||||
typedef uint16_t mc_block_t;
|
||||
|
||||
|
||||
enum mc_item_id
|
||||
{
|
||||
enum mc_item_id {
|
||||
item_iron_shovel = 256,
|
||||
item_iron_pickaxe = 257,
|
||||
item_iron_axe = 258,
|
||||
|
|
|
@ -24,27 +24,24 @@
|
|||
#ifndef __OVERVIEWER_H_INCLUDED__
|
||||
#define __OVERVIEWER_H_INCLUDED__
|
||||
|
||||
|
||||
#define WINVER 0x0601
|
||||
#define _WIN32_WINNT 0x0601
|
||||
|
||||
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
||||
|
||||
|
||||
// increment this value if you've made a change to the c extesion
|
||||
// and want to force users to rebuild
|
||||
#define OVERVIEWER_EXTENSION_VERSION 65
|
||||
|
||||
/* Python PIL, and numpy headers */
|
||||
#include <Imaging.h>
|
||||
#include <Python.h>
|
||||
#include <numpy/arrayobject.h>
|
||||
#include <Imaging.h>
|
||||
/* Fix Pillow on mingw-w64 which includes windows.h in Imaging.h */
|
||||
#undef TRANSPARENT
|
||||
/* Utility macros */
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/* macro for getting a value out of various numpy arrays the 3D arrays have
|
||||
interesting, swizzled coordinates because minecraft (anvil) stores blocks
|
||||
in y/z/x order for 3D, z/x order for 2D */
|
||||
|
@ -52,7 +49,6 @@
|
|||
#define getArrayShort3D(array, x, y, z) (*(unsigned short*)(PyArray_GETPTR3((array), (y), (z), (x))))
|
||||
#define getArrayByte2D(array, x, y) (*(unsigned char*)(PyArray_GETPTR2((array), (y), (x))))
|
||||
|
||||
|
||||
/* in composite.c */
|
||||
Imaging imaging_python_to_c(PyObject* obj);
|
||||
PyObject* alpha_over(PyObject* dest, PyObject* src, PyObject* mask,
|
||||
|
@ -123,8 +119,7 @@ PyObject *init_chunk_render(void);
|
|||
/* returns true on error, x,z relative */
|
||||
int load_chunk(RenderState* state, int x, int z, unsigned char required);
|
||||
PyObject* chunk_render(PyObject* self, PyObject* args);
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
KNOWN,
|
||||
TRANSPARENT,
|
||||
SOLID,
|
||||
|
@ -152,16 +147,14 @@ block_has_property(unsigned short b, BlockProperty prop) {
|
|||
#define is_known_transparent(b) block_has_property((b), TRANSPARENT) && block_has_property((b), KNOWN)
|
||||
|
||||
/* helper for indexing section data possibly across section boundaries */
|
||||
typedef enum
|
||||
{
|
||||
typedef enum {
|
||||
BLOCKS,
|
||||
DATA,
|
||||
BLOCKLIGHT,
|
||||
SKYLIGHT,
|
||||
BIOMES,
|
||||
} DataType;
|
||||
static inline unsigned int get_data(RenderState *state, DataType type, int x, int y, int z)
|
||||
{
|
||||
static inline unsigned int get_data(RenderState* state, DataType type, int x, int y, int z) {
|
||||
int chunkx = 1, chunky = state->chunky, chunkz = 1;
|
||||
PyArrayObject* data_array = NULL;
|
||||
unsigned int def = 0;
|
||||
|
@ -194,14 +187,12 @@ static inline unsigned int get_data(RenderState *state, DataType type, int x, in
|
|||
if (chunky < 0 || chunky >= SECTIONS_PER_CHUNK)
|
||||
return def;
|
||||
|
||||
if (!(state->chunks[chunkx][chunkz].loaded))
|
||||
{
|
||||
if (!(state->chunks[chunkx][chunkz].loaded)) {
|
||||
if (load_chunk(state, chunkx - 1, chunkz - 1, 0))
|
||||
return def;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case BLOCKS:
|
||||
data_array = state->chunks[chunkx][chunkz].sections[chunky].blocks;
|
||||
break;
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../overviewer.h"
|
||||
#include "biomes.h"
|
||||
|
||||
typedef struct {
|
||||
|
@ -28,7 +28,6 @@ typedef struct {
|
|||
PyObject* grass_texture;
|
||||
} PrimitiveBase;
|
||||
|
||||
|
||||
static int
|
||||
base_start(void* data, RenderState* state, PyObject* support) {
|
||||
PrimitiveBase* self = (PrimitiveBase*)data;
|
||||
|
@ -96,14 +95,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
|||
*/
|
||||
if (/* grass, but not snowgrass */
|
||||
(state->block == block_grass && get_data(state, BLOCKS, state->x, state->y + 1, state->z) != 78) ||
|
||||
block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_vine,
|
||||
block_waterlily,
|
||||
block_flowing_water,
|
||||
block_water,
|
||||
block_leaves,
|
||||
block_leaves2
|
||||
},
|
||||
block_class_is_subset(state->block, (mc_block_t[]){block_vine, block_waterlily, block_flowing_water, block_water, block_leaves, block_leaves2},
|
||||
6) ||
|
||||
/* tallgrass, but not dead shrubs */
|
||||
(state->block == block_tallgrass && state->block_data != 0) ||
|
||||
|
@ -113,8 +105,7 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
|||
/* doublePlant grass & ferns */
|
||||
(state->block == block_double_plant && (state->block_data == 2 || state->block_data == 3)) ||
|
||||
/* doublePlant grass & ferns tops */
|
||||
(state->block == block_double_plant && below_block == block_double_plant && (below_data == 2 || below_data == 3)) )
|
||||
{
|
||||
(state->block == block_double_plant && below_block == block_double_plant && (below_data == 2 || below_data == 3))) {
|
||||
/* do the biome stuff! */
|
||||
PyObject* facemask = mask;
|
||||
unsigned char r = 255, g = 255, b = 255;
|
||||
|
@ -125,28 +116,13 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
|||
/* grass needs a special facemask */
|
||||
facemask = self->grass_texture;
|
||||
}
|
||||
if(block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_grass,
|
||||
block_tallgrass,
|
||||
block_pumpkin_stem,
|
||||
block_melon_stem,
|
||||
block_vine,
|
||||
block_waterlily,
|
||||
block_double_plant
|
||||
},7)) {
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_grass, block_tallgrass, block_pumpkin_stem, block_melon_stem, block_vine, block_waterlily, block_double_plant}, 7)) {
|
||||
color_table = self->grasscolor;
|
||||
}
|
||||
else if(block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_flowing_water,block_water
|
||||
},2)) {
|
||||
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_flowing_water, block_water}, 2)) {
|
||||
color_table = self->watercolor;
|
||||
}
|
||||
else if(block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_leaves,block_leaves2
|
||||
},2)) {
|
||||
} else if (block_class_is_subset(state->block, (mc_block_t[]){block_leaves, block_leaves2}, 2)) {
|
||||
color_table = self->foliagecolor;
|
||||
if (state->block_data == 2)
|
||||
{
|
||||
if (state->block_data == 2) {
|
||||
/* birch!
|
||||
birch foliage color is flipped XY-ways */
|
||||
flip_xy = 1;
|
||||
|
@ -232,7 +208,8 @@ base_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObjec
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_base = {
|
||||
"base", sizeof(PrimitiveBase),
|
||||
"base",
|
||||
sizeof(PrimitiveBase),
|
||||
base_start,
|
||||
base_finish,
|
||||
base_occluded,
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#define DEFAULT_BIOME 4 /* forest, nice and green */
|
||||
|
||||
typedef struct {
|
||||
|
@ -245,4 +244,3 @@ static Biome biome_table[] = {
|
|||
};
|
||||
|
||||
#define NUM_BIOMES (sizeof(biome_table) / sizeof(Biome))
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* 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;
|
||||
|
@ -114,7 +114,8 @@ cave_start(void *data, RenderState *state, PyObject *support) {
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_cave = {
|
||||
"cave", sizeof(RenderPrimitiveCave),
|
||||
"cave",
|
||||
sizeof(RenderPrimitiveCave),
|
||||
cave_start,
|
||||
NULL,
|
||||
cave_occluded,
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include <math.h>
|
||||
#include "../overviewer.h"
|
||||
|
||||
typedef struct {
|
||||
/* list of colors used for tinting */
|
||||
|
@ -64,7 +64,8 @@ depth_tinting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_depth_tinting = {
|
||||
"depth-tinting", sizeof(RenderPrimitiveDepthTinting),
|
||||
"depth-tinting",
|
||||
sizeof(RenderPrimitiveDepthTinting),
|
||||
depth_tinting_start,
|
||||
depth_tinting_finish,
|
||||
NULL,
|
||||
|
|
|
@ -45,7 +45,8 @@ depth_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_depth = {
|
||||
"depth", sizeof(PrimitiveDepth),
|
||||
"depth",
|
||||
sizeof(PrimitiveDepth),
|
||||
depth_start,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../overviewer.h"
|
||||
|
||||
typedef struct {
|
||||
float opacity;
|
||||
|
@ -36,8 +36,7 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
|||
PrimitiveEdgeLines* self = (PrimitiveEdgeLines*)data;
|
||||
|
||||
/* Draw some edge lines! */
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_stone_slab,block_snow_layer}, 2)
|
||||
|| !is_transparent(state->block)) {
|
||||
if (block_class_is_subset(state->block, (mc_block_t[]){block_stone_slab, block_snow_layer}, 2) || !is_transparent(state->block)) {
|
||||
Imaging img_i = imaging_python_to_c(state->img);
|
||||
unsigned char ink[] = {0, 0, 0, 255 * self->opacity};
|
||||
unsigned short side_block;
|
||||
|
@ -54,9 +53,7 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
|||
if (side_block != state->block && (is_transparent(side_block) || render_mode_hidden(state->rendermode, x + 1, y, z)) &&
|
||||
/* WARNING: ugly special case approaching */
|
||||
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
|
||||
!(block_class_is_subset(state->block, (mc_block_t[]){block_wooden_slab, block_stone_slab}, 2)
|
||||
&& (block_class_is_subset(side_block, block_class_stair, block_class_stair_len))
|
||||
)) {
|
||||
!(block_class_is_subset(state->block, (mc_block_t[]){block_wooden_slab, block_stone_slab}, 2) && (block_class_is_subset(side_block, block_class_stair, block_class_stair_len)))) {
|
||||
ImagingDrawLine(img_i, state->imgx + 12, state->imgy + 1 + increment, state->imgx + 22 + 1, state->imgy + 5 + 1 + increment, &ink, 1);
|
||||
ImagingDrawLine(img_i, state->imgx + 12, state->imgy + increment, state->imgx + 22 + 1, state->imgy + 5 + increment, &ink, 1);
|
||||
}
|
||||
|
@ -67,9 +64,7 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
|||
/* WARNING: ugly special case approaching */
|
||||
/* if the block is a slab and the side block is a stair don't draw anything, it can give very ugly results */
|
||||
!(
|
||||
block_class_is_subset(state->block, (mc_block_t[]){block_stone_slab,block_wooden_slab}, 2)
|
||||
&& (block_class_is_subset(side_block, block_class_stair, block_class_stair_len))
|
||||
)) {
|
||||
block_class_is_subset(state->block, (mc_block_t[]){block_stone_slab, block_wooden_slab}, 2) && (block_class_is_subset(side_block, block_class_stair, block_class_stair_len)))) {
|
||||
ImagingDrawLine(img_i, state->imgx, state->imgy + 6 + 1 + increment, state->imgx + 12 + 1, state->imgy + 1 + increment, &ink, 1);
|
||||
ImagingDrawLine(img_i, state->imgx, state->imgy + 6 + increment, state->imgx + 12 + 1, state->imgy + increment, &ink, 1);
|
||||
}
|
||||
|
@ -77,7 +72,8 @@ edge_lines_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, P
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_edge_lines = {
|
||||
"edge-lines", sizeof(PrimitiveEdgeLines),
|
||||
"edge-lines",
|
||||
sizeof(PrimitiveEdgeLines),
|
||||
edge_lines_start,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -92,7 +92,6 @@ exposed_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
* shows us if we're rendering exposed blocks
|
||||
*/
|
||||
return self->mode;
|
||||
|
||||
}
|
||||
|
||||
/* We have no valid evidence that the block is exposed */
|
||||
|
@ -100,7 +99,8 @@ exposed_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_exposed = {
|
||||
"exposed", sizeof(PrimitiveExposed),
|
||||
"exposed",
|
||||
sizeof(PrimitiveExposed),
|
||||
exposed_start,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -68,7 +68,8 @@ height_fading_draw(void *data, RenderState *state, PyObject *src, PyObject *mask
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_height_fading = {
|
||||
"height-fading", sizeof(PrimitiveHeightFading),
|
||||
"height-fading",
|
||||
sizeof(PrimitiveHeightFading),
|
||||
height_fading_start,
|
||||
height_fading_finish,
|
||||
NULL,
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../overviewer.h"
|
||||
|
||||
struct HideRule {
|
||||
unsigned short blockid;
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "lighting.h"
|
||||
#include <math.h>
|
||||
#include "lighting.h"
|
||||
#include "../block_class.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../overviewer.h"
|
||||
|
||||
/* figures out the color from a given skylight and blocklight,
|
||||
used in lighting calculations */
|
||||
|
@ -182,7 +182,6 @@ get_lighting_color(RenderPrimitiveLighting *self, RenderState *state,
|
|||
/* the block has a bad blocklevel, estimate it from neigborhood
|
||||
* use given coordinates, no local ones! */
|
||||
blocklevel = estimate_blocklevel(self, state, x, y, z, NULL);
|
||||
|
||||
}
|
||||
|
||||
if (block_class_is_subset(block, (mc_block_t[]){block_flowing_lava, block_lava}, 2)) {
|
||||
|
@ -331,7 +330,8 @@ lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyO
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_lighting = {
|
||||
"lighting", sizeof(RenderPrimitiveLighting),
|
||||
"lighting",
|
||||
sizeof(RenderPrimitiveLighting),
|
||||
lighting_start,
|
||||
lighting_finish,
|
||||
NULL,
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "nether.h"
|
||||
#include "../block_class.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../overviewer.h"
|
||||
|
||||
static void
|
||||
walk_chunk(RenderState* state, RenderPrimitiveNether* data) {
|
||||
|
@ -62,7 +62,8 @@ nether_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_nether = {
|
||||
"nether", sizeof(RenderPrimitiveNether),
|
||||
"nether",
|
||||
sizeof(RenderPrimitiveNether),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -25,8 +25,7 @@ netherold_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
empty sections as 'solid'
|
||||
*/
|
||||
unsigned char missing_section = 0;
|
||||
while (y < (SECTIONS_PER_CHUNK - state->chunky) * 16)
|
||||
{
|
||||
while (y < (SECTIONS_PER_CHUNK - state->chunky) * 16) {
|
||||
if (state->chunks[1][1].sections[state->chunky + (y / 16)].blocks == NULL) {
|
||||
missing_section = 1;
|
||||
y += 16;
|
||||
|
@ -39,8 +38,7 @@ netherold_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
missing_section = 0;
|
||||
}
|
||||
|
||||
if (!missing_section && get_data(state, BLOCKS, x, y, z) == 0)
|
||||
{
|
||||
if (!missing_section && get_data(state, BLOCKS, x, y, z) == 0) {
|
||||
return 0;
|
||||
}
|
||||
y++;
|
||||
|
@ -49,7 +47,8 @@ netherold_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_nether_old = {
|
||||
"netherold", 0,
|
||||
"netherold",
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -28,7 +28,8 @@ no_fluids_hidden(void *data, RenderState *state, int x, int y, int z) {
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_no_fluids = {
|
||||
"no-fluids", 0,
|
||||
"no-fluids",
|
||||
0,
|
||||
no_fluids_start,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include "biomes.h"
|
||||
#include "overlay.h"
|
||||
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
|
@ -73,8 +73,7 @@ static struct BiomeColor default_biomes[] = {
|
|||
{39, 255, 100, 100}, /* Mesa Plateau */
|
||||
|
||||
/* end of list marker */
|
||||
{255, 0, 0, 0}
|
||||
};
|
||||
{255, 0, 0, 0}};
|
||||
|
||||
static void get_color(void* data, RenderState* state,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include "../mc_id.h"
|
||||
#include "overlay.h"
|
||||
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
|
@ -45,8 +45,7 @@ static struct MineralColor default_minerals[] = {
|
|||
{block_coal_ore, 54, 54, 54},
|
||||
|
||||
/* end of list marker */
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
{0, 0, 0, 0}};
|
||||
|
||||
static void get_color(void* data, RenderState* state,
|
||||
unsigned char* r, unsigned char* g, unsigned char* b, unsigned char* a) {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include <math.h>
|
||||
#include "overlay.h"
|
||||
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
|
@ -66,7 +66,8 @@ static int is_slime(long long map_seed, int chunkx, int chunkz) {
|
|||
(long long)(chunkx * chunkx * 0x4c1906) +
|
||||
(long long)(chunkx * 0x5ac0db) +
|
||||
(long long)(chunkz * chunkz * 0x4307a7LL) +
|
||||
(long long)(chunkz * 0x5f24f)) ^ 0x3ad8025f);
|
||||
(long long)(chunkz * 0x5f24f)) ^
|
||||
0x3ad8025f);
|
||||
return (random_next_int(&seed, 10) == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include <math.h>
|
||||
#include "overlay.h"
|
||||
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "overlay.h"
|
||||
#include "../mc_id.h"
|
||||
#include "overlay.h"
|
||||
|
||||
typedef enum { false, true } bool;
|
||||
typedef enum { false,
|
||||
true } bool;
|
||||
|
||||
typedef struct {
|
||||
/* inherits from overlay */
|
||||
|
@ -240,4 +241,3 @@ RenderPrimitiveInterface primitive_overlay_structure = {
|
|||
NULL,
|
||||
overlay_draw,
|
||||
};
|
||||
|
||||
|
|
|
@ -78,8 +78,7 @@ overlay_finish(void *data, RenderState *state) {
|
|||
Py_DECREF(self->white_color);
|
||||
}
|
||||
|
||||
void
|
||||
overlay_draw(void *data, RenderState *state, PyObject *src, PyObject *mask, PyObject *mask_light) {
|
||||
void overlay_draw(void* data, RenderState* state, PyObject* src, PyObject* mask, PyObject* mask_light) {
|
||||
RenderPrimitiveOverlay* self = (RenderPrimitiveOverlay*)data;
|
||||
unsigned char r, g, b, a;
|
||||
unsigned short top_block;
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../overviewer.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../block_class.h"
|
||||
#include "lighting.h"
|
||||
#include <math.h>
|
||||
#include "../block_class.h"
|
||||
#include "../mc_id.h"
|
||||
#include "../overviewer.h"
|
||||
#include "lighting.h"
|
||||
|
||||
typedef struct {
|
||||
/* inherits from lighting */
|
||||
|
@ -72,59 +72,37 @@ static struct SmoothLightingFace lighting_rules[] = {
|
|||
|
||||
/* top */
|
||||
{0, 1, 0, {
|
||||
{0, 6,
|
||||
-1, 0, 0,
|
||||
0, 0, -1},
|
||||
{12, 0,
|
||||
1, 0, 0,
|
||||
0, 0, -1},
|
||||
{24, 6,
|
||||
1, 0, 0,
|
||||
0, 0, 1},
|
||||
{12, 12,
|
||||
-1, 0, 0,
|
||||
0, 0, 1},
|
||||
{0, 6, -1, 0, 0, 0, 0, -1},
|
||||
{12, 0, 1, 0, 0, 0, 0, -1},
|
||||
{24, 6, 1, 0, 0, 0, 0, 1},
|
||||
{12, 12, -1, 0, 0, 0, 0, 1},
|
||||
},
|
||||
top_touchups, 6},
|
||||
top_touchups,
|
||||
6},
|
||||
|
||||
/* left */
|
||||
{-1, 0, 0, {
|
||||
{0, 18,
|
||||
0, 0, -1,
|
||||
0, -1, 0},
|
||||
{0, 6,
|
||||
0, 0, -1,
|
||||
0, 1, 0},
|
||||
{12, 12,
|
||||
0, 0, 1,
|
||||
0, 1, 0},
|
||||
{12, 24,
|
||||
0, 0, 1,
|
||||
0, -1, 0},
|
||||
{0, 18, 0, 0, -1, 0, -1, 0},
|
||||
{0, 6, 0, 0, -1, 0, 1, 0},
|
||||
{12, 12, 0, 0, 1, 0, 1, 0},
|
||||
{12, 24, 0, 0, 1, 0, -1, 0},
|
||||
},
|
||||
NULL, 0},
|
||||
NULL,
|
||||
0},
|
||||
|
||||
/* right */
|
||||
{0, 0, 1, {
|
||||
{24, 6,
|
||||
1, 0, 0,
|
||||
0, 1, 0},
|
||||
{12, 12,
|
||||
-1, 0, 0,
|
||||
0, 1, 0},
|
||||
{12, 24,
|
||||
-1, 0, 0,
|
||||
0, -1, 0},
|
||||
{24, 18,
|
||||
1, 0, 0,
|
||||
0, -1, 0},
|
||||
{24, 6, 1, 0, 0, 0, 1, 0},
|
||||
{12, 12, -1, 0, 0, 0, 1, 0},
|
||||
{12, 24, -1, 0, 0, 0, -1, 0},
|
||||
{24, 18, 1, 0, 0, 0, -1, 0},
|
||||
},
|
||||
NULL, 0},
|
||||
NULL,
|
||||
0},
|
||||
};
|
||||
|
||||
/* helpers for indexing the rule list */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
FACE_TOP = 0,
|
||||
FACE_LEFT = 1,
|
||||
FACE_RIGHT = 2,
|
||||
|
@ -149,30 +127,37 @@ do_shading_with_rule(RenderPrimitiveSmoothLighting *self, RenderState *state, st
|
|||
return;
|
||||
|
||||
/* calculate the lighting colors for each point */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
for (i = 0; i < 4; i++) {
|
||||
unsigned char r, g, b;
|
||||
unsigned int rgather = 0, ggather = 0, bgather = 0;
|
||||
|
||||
get_lighting_color(lighting, state, cx, cy, cz,
|
||||
&r, &g, &b);
|
||||
rgather += r; ggather += g; bgather += b;
|
||||
rgather += r;
|
||||
ggather += g;
|
||||
bgather += b;
|
||||
|
||||
get_lighting_color(lighting, state,
|
||||
cx + pts[i].dx1, cy + pts[i].dy1, cz + pts[i].dz1,
|
||||
&r, &g, &b);
|
||||
rgather += r; ggather += g; bgather += b;
|
||||
rgather += r;
|
||||
ggather += g;
|
||||
bgather += b;
|
||||
|
||||
get_lighting_color(lighting, state,
|
||||
cx + pts[i].dx2, cy + pts[i].dy2, cz + pts[i].dz2,
|
||||
&r, &g, &b);
|
||||
rgather += r; ggather += g; bgather += b;
|
||||
rgather += r;
|
||||
ggather += g;
|
||||
bgather += b;
|
||||
|
||||
/* FIXME special far corner handling */
|
||||
get_lighting_color(lighting, state,
|
||||
cx + pts[i].dx1 + pts[i].dx2, cy + pts[i].dy1 + pts[i].dy2, cz + pts[i].dz1 + pts[i].dz2,
|
||||
&r, &g, &b);
|
||||
rgather += r; ggather += g; bgather += b;
|
||||
rgather += r;
|
||||
ggather += g;
|
||||
bgather += b;
|
||||
|
||||
rgather += (255 * 4 - rgather) * comp_shade_strength;
|
||||
ggather += (255 * 4 - ggather) * comp_shade_strength;
|
||||
|
@ -220,10 +205,7 @@ smooth_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *ma
|
|||
|
||||
/* special case for leaves, water 8, water 9, ice 79
|
||||
-- these are also smooth-lit! */
|
||||
if (!block_class_is_subset(state->block, (mc_block_t[]){
|
||||
block_leaves,block_flowing_water,block_water,block_ice
|
||||
}, 4) && is_transparent(state->block))
|
||||
{
|
||||
if (!block_class_is_subset(state->block, (mc_block_t[]){block_leaves, block_flowing_water, block_water, block_ice}, 4) && is_transparent(state->block)) {
|
||||
/* transparent blocks are rendered as usual, with flat lighting */
|
||||
primitive_lighting.draw(data, state, src, mask, mask_light);
|
||||
return;
|
||||
|
@ -232,8 +214,7 @@ smooth_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *ma
|
|||
/* non-transparent blocks get the special smooth treatment */
|
||||
|
||||
/* special code for water */
|
||||
if (state->block == block_water)
|
||||
{
|
||||
if (state->block == block_water) {
|
||||
if (!(state->block_pdata & (1 << 4)))
|
||||
light_top = 0;
|
||||
if (!(state->block_pdata & (1 << 1)))
|
||||
|
@ -251,7 +232,8 @@ smooth_lighting_draw(void *data, RenderState *state, PyObject *src, PyObject *ma
|
|||
}
|
||||
|
||||
RenderPrimitiveInterface primitive_smooth_lighting = {
|
||||
"smooth-lighting", sizeof(RenderPrimitiveSmoothLighting),
|
||||
"smooth-lighting",
|
||||
sizeof(RenderPrimitiveSmoothLighting),
|
||||
smooth_lighting_start,
|
||||
smooth_lighting_finish,
|
||||
NULL,
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
* with the Overviewer. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "overviewer.h"
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include "overviewer.h"
|
||||
|
||||
/* this file defines render_primitives,
|
||||
a list of all render primitives, ending in NULL
|
||||
|
|
Loading…
Reference in New Issue