mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/GabsPuNs-MinecraftConsoles.git
synced 2026-05-21 21:35:50 +00:00
Code cleanup
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"displayName": "Windows64",
|
||||
"inherits": "base",
|
||||
"cacheVariables": {
|
||||
"PLATFORM_DEFINES": "_WINDOWS64;_WIN64",
|
||||
"PLATFORM_DEFINES": "_WINDOWS64",
|
||||
"PLATFORM_NAME": "Windows64",
|
||||
"IGGY_LIBS": "iggy_w64.lib;iggyperfmon_w64.lib;iggyexpruntime_w64.lib"
|
||||
}
|
||||
|
||||
@@ -129,8 +129,6 @@ void Chunk::setPos(int x, int y, int z)
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&levelRenderer->m_csDirtyChunks);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Chunk::translateToPos()
|
||||
@@ -490,7 +488,6 @@ void Chunk::rebuild()
|
||||
{
|
||||
levelRenderer->setGlobalChunkFlag(this->x, this->y, this->z, level, LevelRenderer::CHUNK_FLAG_EMPTY1 | LevelRenderer::CHUNK_FLAG_NOTSKYLIT);
|
||||
RenderManager.CBuffClear(lists + 1);
|
||||
RenderManager.CBuffClear(lists + 2);
|
||||
break;
|
||||
}
|
||||
if((currentLayer==2)&&(!renderNextLayer))
|
||||
@@ -1013,41 +1010,17 @@ void Chunk::_delete()
|
||||
level = nullptr;
|
||||
}
|
||||
|
||||
int Chunk::getList(int layer)
|
||||
{
|
||||
if (!clipChunk->visible) return -1;
|
||||
|
||||
int lists = levelRenderer->getGlobalIndexForChunk(x, y, z,level) * 3;
|
||||
lists += levelRenderer->chunkLists;
|
||||
|
||||
bool empty = levelRenderer->getGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_EMPTY0, layer);
|
||||
if (!empty) return lists + layer;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Chunk::cull(Culler *culler)
|
||||
{
|
||||
clipChunk->visible = culler->isVisible(bb.get());
|
||||
}
|
||||
|
||||
void Chunk::renderBB()
|
||||
{
|
||||
// glCallList(lists + 2); // 4J - removed - TODO put back in
|
||||
}
|
||||
|
||||
bool Chunk::isEmpty()
|
||||
{
|
||||
if (!levelRenderer->getGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_COMPILED)) return false;
|
||||
return levelRenderer->getGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_EMPTYBOTH);
|
||||
}
|
||||
|
||||
void Chunk::setDirty()
|
||||
{
|
||||
// 4J - not used, but if this starts being used again then we'll need to investigate how best to handle it.
|
||||
__debugbreak();
|
||||
levelRenderer->setGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_DIRTY);
|
||||
}
|
||||
|
||||
void Chunk::clearDirty()
|
||||
{
|
||||
levelRenderer->clearGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_DIRTY);
|
||||
|
||||
@@ -73,11 +73,8 @@ public:
|
||||
void reset();
|
||||
void _delete();
|
||||
|
||||
int getList(int layer);
|
||||
void cull(Culler *culler);
|
||||
void renderBB() ;
|
||||
bool isEmpty();
|
||||
void setDirty();
|
||||
void clearDirty(); // 4J added
|
||||
bool emptyFlagSet(int layer);
|
||||
~Chunk();
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "Camera.h"
|
||||
#include "..\Minecraft.World\SoundTypes.h"
|
||||
#include "HumanoidModel.h"
|
||||
#include "..\Minecraft.World\Item.h"
|
||||
#include "..\Minecraft.World\compression.h"
|
||||
#include "PS3\PS3Extras\ShutdownManager.h"
|
||||
#include "BossMobGuiInfo.h"
|
||||
@@ -1555,7 +1554,7 @@ void GameRenderer::renderLevel(float a, int64_t until)
|
||||
// @Patoke todo: implement, this is really important for rendering of order independent alpha objects
|
||||
// RenderManager.BeginOrderIndependentAlpha();
|
||||
|
||||
PIXBeginNamedEvent(0, "Second pass level render");
|
||||
PIXBeginNamedEvent(0, "Second pass level rendering");
|
||||
levelRenderer->render(cameraEntity, 1, a, updateChunks);
|
||||
PIXEndNamedEvent();
|
||||
|
||||
|
||||
@@ -656,10 +656,10 @@ void Texture::transferFromImage(BufferedImage *image)
|
||||
for (int x = 0; x < ww; x++)
|
||||
for (int y = 0; y < hh; y++)
|
||||
{
|
||||
int c0 = data[level - 1]->getInt(((x * 2 + 0) + (y * 2 + 0) * ow) * 4);
|
||||
int c1 = data[level - 1]->getInt(((x * 2 + 1) + (y * 2 + 0) * ow) * 4);
|
||||
int c2 = data[level - 1]->getInt(((x * 2 + 1) + (y * 2 + 1) * ow) * 4);
|
||||
int c3 = data[level - 1]->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4);
|
||||
unsigned int c0 = data[level - 1]->getInt(((x * 2 + 0) + (y * 2 + 0) * ow) * 4);
|
||||
unsigned int c1 = data[level - 1]->getInt(((x * 2 + 1) + (y * 2 + 0) * ow) * 4);
|
||||
unsigned int c2 = data[level - 1]->getInt(((x * 2 + 1) + (y * 2 + 1) * ow) * 4);
|
||||
unsigned int c3 = data[level - 1]->getInt(((x * 2 + 0) + (y * 2 + 1) * ow) * 4);
|
||||
#ifndef _XBOX
|
||||
// 4J - convert our RGBA texels to ARGB that crispBlend is expecting
|
||||
c0 = ( ( c0 >> 8 ) & 0x00ffffff ) | ( c0 << 24 );
|
||||
@@ -667,13 +667,13 @@ void Texture::transferFromImage(BufferedImage *image)
|
||||
c2 = ( ( c2 >> 8 ) & 0x00ffffff ) | ( c2 << 24 );
|
||||
c3 = ( ( c3 >> 8 ) & 0x00ffffff ) | ( c3 << 24 );
|
||||
#endif
|
||||
int col = crispBlend(crispBlend(c0, c1), crispBlend(c2, c3));
|
||||
unsigned int col = crispBlend(crispBlend(c0, c1), crispBlend(c2, c3));
|
||||
// 4J - and back from ARGB -> RGBA
|
||||
//col = ( col << 8 ) | (( col >> 24 ) & 0xff);
|
||||
//tempData[x + y * ww] = col;
|
||||
|
||||
int intIndex = y * ww + x;
|
||||
int byteIndex = intIndex * 4;
|
||||
unsigned int intIndex = y * ww + x;
|
||||
unsigned int byteIndex = intIndex * 4;
|
||||
|
||||
// Pull ARGB bytes into either RGBA or BGRA depending on format
|
||||
|
||||
@@ -711,53 +711,49 @@ void Texture::transferFromImage(BufferedImage *image)
|
||||
}
|
||||
}
|
||||
|
||||
// 4J Kept from older versions for where we create mip-maps for levels that do not have pre-made graphics
|
||||
int Texture::crispBlend(int c0, int c1)
|
||||
unsigned int Texture::crispBlend(unsigned int c0, unsigned int c1)
|
||||
{
|
||||
int a0 = static_cast<int>(((c0 & 0xff000000) >> 24)) & 0xff;
|
||||
int a1 = static_cast<int>(((c1 & 0xff000000) >> 24)) & 0xff;
|
||||
unsigned int a0 = (c0 >> 24) & 0xFF;
|
||||
unsigned int a1 = (c1 >> 24) & 0xFF;
|
||||
|
||||
// continue with crisp blend if it's likely to be an opaque/cutout tile in the atlas
|
||||
if (a0 >= 0xfa || a1 >= 0xfa || !Minecraft::GetInstance()->options->mipmapsBlend)
|
||||
{
|
||||
int a = 255;
|
||||
if ((a0 + a1) < 255)
|
||||
{
|
||||
unsigned int r = (((c0 >> 16) & 0xFF) + ((c1 >> 16) & 0xFF)) / 2;
|
||||
unsigned int g = (((c0 >> 8) & 0xFF) + ((c1 >> 8) & 0xFF)) / 2;
|
||||
unsigned int b = ((c0 & 0xFF) + (c1 & 0xFF)) / 2;
|
||||
|
||||
return (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
if (a0 + a1 < 255)
|
||||
{
|
||||
a = 0;
|
||||
a0 = 1;
|
||||
a1 = 1;
|
||||
}
|
||||
else if (a0 > a1)
|
||||
{
|
||||
a0 = 255;
|
||||
a1 = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
a0 = 1;
|
||||
a1 = 255;
|
||||
unsigned int r0 = (c0 >> 16) & 0xFF;
|
||||
unsigned int g0 = (c0 >> 8) & 0xFF;
|
||||
unsigned int b0 = c0 & 0xFF;
|
||||
|
||||
}
|
||||
unsigned int r1 = (c1 >> 16) & 0xFF;
|
||||
unsigned int g1 = (c1 >> 8) & 0xFF;
|
||||
unsigned int b1 = c1 & 0xFF;
|
||||
|
||||
int r0 = ((c0 >> 16) & 0xff) * a0;
|
||||
int g0 = ((c0 >> 8) & 0xff) * a0;
|
||||
int b0 = ((c0) & 0xff) * a0;
|
||||
unsigned int r, g, b;
|
||||
|
||||
int r1 = ((c1 >> 16) & 0xff) * a1;
|
||||
int g1 = ((c1 >> 8) & 0xff) * a1;
|
||||
int b1 = ((c1) & 0xff) * a1;
|
||||
if (a0 <= a1)
|
||||
{
|
||||
r = (r0 + 255 * r1) / 256;
|
||||
g = (g0 + 255 * g1) / 256;
|
||||
b = (b0 + 255 * b1) / 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = (255 * r0 + r1) / 256;
|
||||
g = (255 * g0 + g1) / 256;
|
||||
b = (255 * b0 + b1) / 256;
|
||||
}
|
||||
|
||||
int r = (r0 + r1) / (a0 + a1);
|
||||
int g = (g0 + g1) / (a0 + a1);
|
||||
int b = (b0 + b1) / (a0 + a1);
|
||||
|
||||
return (a << 24) | (r << 16) | (g << 8) | b;
|
||||
return 0xFF000000 | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
else // smoothblend if it's transparent
|
||||
{
|
||||
return (((a0 + a1) >> 1) << 24) | (((c0 & 0xfefefe) + (c1 & 0xfefefe)) >> 1);
|
||||
}
|
||||
}
|
||||
|
||||
int Texture::getManagerId()
|
||||
|
||||
@@ -94,5 +94,5 @@ public:
|
||||
void updateOnGPU();
|
||||
ByteBuffer *getData(unsigned int level = 0);
|
||||
|
||||
static int crispBlend(int c0, int c1);
|
||||
static unsigned int crispBlend(unsigned int c0, unsigned int c1);
|
||||
};
|
||||
@@ -4602,7 +4602,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tt, int x, int y, int z)
|
||||
if (level->getTile(x + 1, y, z) == Tile::farmland_Id) dirs[3] = false;
|
||||
}
|
||||
|
||||
float offs = (1.0f / 1024.0f);
|
||||
float offs = 0.001f;
|
||||
|
||||
if (noCulling || up)
|
||||
{
|
||||
@@ -4621,7 +4621,7 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tt, int x, int y, int z)
|
||||
|
||||
if (angle >= -999.0f)
|
||||
{
|
||||
float cc = SharedConstants::WORLD_RESOLUTION * .5f;
|
||||
float cc = 8.0f;
|
||||
float fsin = Mth::sin(angle) * 0.25f;
|
||||
float fcos = Mth::cos(angle) * 0.25f;
|
||||
u0 = tex->getU(cc + (-fcos - fsin) * SharedConstants::WORLD_RESOLUTION);
|
||||
@@ -4785,7 +4785,7 @@ float TileRenderer::getWaterHeight( int x, int y, int z, Material* m )
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return 1 - h / count;
|
||||
return (1 - (h / count));
|
||||
}
|
||||
|
||||
void TileRenderer::renderBlock( Tile* tt, Level* level, int x, int y, int z )
|
||||
@@ -4997,20 +4997,20 @@ bool TileRenderer::tesselateCocoaInWorld(CocoaTile *tt, int x, int y, int z)
|
||||
switch (dir)
|
||||
{
|
||||
case Direction::NORTH:
|
||||
offX = 8.0 - cocoaWidth / 2;
|
||||
offX = 8.0 - cocoaWidth / 2.0;
|
||||
offZ = 1.0;
|
||||
break;
|
||||
case Direction::SOUTH:
|
||||
offX = 8.0 - cocoaWidth / 2;
|
||||
offX = 8.0 - cocoaWidth / 2.0;
|
||||
offZ = 15.0 - cocoaWidth;
|
||||
break;
|
||||
case Direction::EAST:
|
||||
offX = 15.0 - cocoaWidth;
|
||||
offZ = 8.0 - cocoaWidth / 2;
|
||||
offZ = 8.0 - cocoaWidth / 2.0;
|
||||
break;
|
||||
case Direction::WEST:
|
||||
offX = 1.0;
|
||||
offZ = 8.0 - cocoaWidth / 2;
|
||||
offZ = 8.0 - cocoaWidth / 2.0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user