Continue LOD
This commit is contained in:
parent
5d9592bcd6
commit
0078bbf1cd
2 changed files with 34 additions and 17 deletions
47
renderer.h
47
renderer.h
|
@ -54,9 +54,7 @@ struct
|
||||||
*/
|
*/
|
||||||
uint8_t mapTriangleData[LCR_SETTING_MAX_MAP_TRIANGLES];
|
uint8_t mapTriangleData[LCR_SETTING_MAX_MAP_TRIANGLES];
|
||||||
|
|
||||||
|
uint8_t gridLOD[LCR_RENDERER_LOD_BLOCKS];
|
||||||
uint8_t gridLOD[LCR_RENDERER_LOD_BLOCKS];
|
|
||||||
|
|
||||||
|
|
||||||
// pixel function precomputed values:
|
// pixel function precomputed values:
|
||||||
int previousTriID;
|
int previousTriID;
|
||||||
|
@ -755,7 +753,7 @@ chk(>,z,LCR_MAP_SIZE_BLOCKS * LCR_RENDERER_UNIT / 2)
|
||||||
Fast and safe rect drawing function (handles out of screen coords).
|
Fast and safe rect drawing function (handles out of screen coords).
|
||||||
*/
|
*/
|
||||||
void LCR_rendererDrawRect(int x, int y, unsigned int w, unsigned int h,
|
void LCR_rendererDrawRect(int x, int y, unsigned int w, unsigned int h,
|
||||||
uint16_t color)
|
uint16_t color, int dither)
|
||||||
{
|
{
|
||||||
if (x >= LCR_EFFECTIVE_RESOLUTION_X || y >= LCR_EFFECTIVE_RESOLUTION_Y)
|
if (x >= LCR_EFFECTIVE_RESOLUTION_X || y >= LCR_EFFECTIVE_RESOLUTION_Y)
|
||||||
return;
|
return;
|
||||||
|
@ -777,7 +775,7 @@ void LCR_rendererDrawRect(int x, int y, unsigned int w, unsigned int h,
|
||||||
if (-1 * y > ((int) h))
|
if (-1 * y > ((int) h))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
y += h;
|
h += y;
|
||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,19 +784,32 @@ void LCR_rendererDrawRect(int x, int y, unsigned int w, unsigned int h,
|
||||||
|
|
||||||
unsigned long index = y * LCR_EFFECTIVE_RESOLUTION_X + x;
|
unsigned long index = y * LCR_EFFECTIVE_RESOLUTION_X + x;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < h; ++i)
|
if (dither)
|
||||||
{
|
{
|
||||||
for (unsigned int j = 0; j < w; ++j)
|
uint8_t parity = (x % 2) == (y % 2);
|
||||||
{
|
|
||||||
LCR_drawPixel(index,color);
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
index += LCR_EFFECTIVE_RESOLUTION_X - w;
|
for (unsigned int i = 0; i < h; ++i)
|
||||||
|
{
|
||||||
|
for (unsigned int j = ((i % 2) == parity); j < w; j += 2)
|
||||||
|
LCR_drawPixel(index + j,color);
|
||||||
|
|
||||||
|
index += LCR_EFFECTIVE_RESOLUTION_X;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
for (unsigned int i = 0; i < h; ++i)
|
||||||
|
{
|
||||||
|
for (unsigned int j = 0; j < w; ++j)
|
||||||
|
{
|
||||||
|
LCR_drawPixel(index,color);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
index += LCR_EFFECTIVE_RESOLUTION_X - w;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _LCR_drawLOD(int blockX, int blockY, int blockZ, unsigned int size,
|
void _LCR_drawLODBlock(int blockX, int blockY, int blockZ, unsigned int size,
|
||||||
uint16_t color)
|
uint16_t color)
|
||||||
{
|
{
|
||||||
S3L_Vec4 p, r;
|
S3L_Vec4 p, r;
|
||||||
|
@ -819,12 +830,13 @@ void _LCR_drawLOD(int blockX, int blockY, int blockZ, unsigned int size,
|
||||||
if (r.w > 0 && r.z > LCR_SETTING_LOD_DISTANCE * LCR_RENDERER_UNIT &&
|
if (r.w > 0 && r.z > LCR_SETTING_LOD_DISTANCE * LCR_RENDERER_UNIT &&
|
||||||
r.w < LCR_EFFECTIVE_RESOLUTION_X)
|
r.w < LCR_EFFECTIVE_RESOLUTION_X)
|
||||||
{
|
{
|
||||||
LCR_rendererDrawRect(r.x - r.w / 2,r.y - r.w / 2,
|
LCR_rendererDrawRect(r.x - r.w / 2,r.y - r.w / 2,(5 * r.w) / 8,
|
||||||
r.w,r.w,color);
|
(5 * r.w) / 8,color,1);
|
||||||
|
LCR_rendererDrawRect(r.x - r.w / 4,r.y,
|
||||||
|
(3 * r.w) / 4,r.w / 2,color,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Draws background sky, offsets are in multiples of screen dimensions
|
Draws background sky, offsets are in multiples of screen dimensions
|
||||||
(e.g. S3L_FRACTIONS_PER_UNIT / 2 for offsetH means half the screen width).
|
(e.g. S3L_FRACTIONS_PER_UNIT / 2 for offsetH means half the screen width).
|
||||||
|
@ -1039,7 +1051,8 @@ void LCR_rendererDrawLOD(void)
|
||||||
if (byte & 0x01)
|
if (byte & 0x01)
|
||||||
{
|
{
|
||||||
bx = j * 8 + 4;
|
bx = j * 8 + 4;
|
||||||
_LCR_drawLOD(bx,by,bz,LCR_EFFECTIVE_RESOLUTION_X,0);
|
_LCR_drawLODBlock(bx,by,bz,(LCR_EFFECTIVE_RESOLUTION_X * 3) / 2,
|
||||||
|
LCR_SETTING_LOD_COLOR);
|
||||||
} // TODO: this ^
|
} // TODO: this ^
|
||||||
|
|
||||||
byte >>= 1;
|
byte >>= 1;
|
||||||
|
|
|
@ -77,4 +77,8 @@
|
||||||
#define LCR_SETTING_LOD_DISTANCE 25
|
#define LCR_SETTING_LOD_DISTANCE 25
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef LCR_SETTING_LOD_COLOR
|
||||||
|
#define LCR_SETTING_LOD_COLOR 0x4229
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|
Loading…
Reference in a new issue