diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index 2d26b6ca..e1eb6c5f 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -1852,6 +1852,39 @@ void GameRenderer::renderSnowAndRain(float a) rainXa = new float[32 * 32]; rainZa = new float[32 * 32]; +#ifdef __AVX__ + const __m256 v16 = _mm256_set1_ps(16.0f); + const __m256 vZero = _mm256_setzero_ps(); + + for (int z = 0; z < 32; z++) + { + __m256 vZ = _mm256_set1_ps(static_cast(z)); + __m256 vZa = _mm256_sub_ps(vZ, v16); + __m256 vNegZa = _mm256_sub_ps(vZero, vZa); // -za + __m256 vZaSq = _mm256_mul_ps(vZa, vZa); // za * za + + for (int x = 0; x < 32; x += 8) + { + __m256 vX = _mm256_set_ps(x + 7.0f, x + 6.0f, x + 5.0f, x + 4.0f, + x + 3.0f, x + 2.0f, x + 1.0f, static_cast(x)); + + __m256 vXa = _mm256_sub_ps(vX, v16); + __m256 vXaSq = _mm256_mul_ps(vXa, vXa); + + __m256 vSumSq = _mm256_add_ps(vXaSq, vZaSq); + __m256 vD = _mm256_sqrt_ps(vSumSq); + + __m256 vRainXa = _mm256_div_ps(vNegZa, vD); + + __m256 vRainZa = _mm256_div_ps(vXa, vD); + + int index = (z << 5) | x; + + _mm256_storeu_ps(&rainXa[index], vRainXa); + _mm256_storeu_ps(&rainZa[index], vRainZa); + } + } +#else for (int z = 0; z < 32; z++) { for (int x = 0; x < 32; x++) @@ -1863,6 +1896,7 @@ void GameRenderer::renderSnowAndRain(float a) rainZa[z << 5 | x] = xa / d; } } +#endif } shared_ptr player = mc->cameraTargetPlayer; diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index d618c5ac..9b440e44 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -443,7 +443,7 @@ void LevelRenderer::allChanged(int playerIndex) lastPlayerCount[playerIndex] = activePlayers(); xChunks = dist; - yChunks = Level::maxBuildHeight / CHUNK_SIZE; + yChunks = CHUNK_Y_COUNT; zChunks = dist; if( chunks[playerIndex].data != nullptr ) @@ -3442,7 +3442,6 @@ void LevelRenderer::levelEvent(shared_ptr source, int type, int x, int y level[playerIndex]->playLocalSound(x + 0.5, y + 0.5, z + 0.5, eSoundType_MOB_BAT_TAKEOFF, .05f, (random->nextFloat() - random->nextFloat()) * 0.2f + 1.0f); break; } - } void LevelRenderer::destroyTileProgress(int id, int x, int y, int z, int progress) diff --git a/Minecraft.World/DoorTile.cpp b/Minecraft.World/DoorTile.cpp index f9f2ae5b..7600a450 100644 --- a/Minecraft.World/DoorTile.cpp +++ b/Minecraft.World/DoorTile.cpp @@ -148,7 +148,7 @@ bool DoorTile::isOpen(LevelSource *level, int x, int y, int z) bool DoorTile::isDoor(int t) { - return t == Tile::door_wood_Id || (t >= Tile::door_spruce_Id && t <= Tile::door_dark_oak_Id); + return (t == Tile::door_wood_Id) || (t >= Tile::door_spruce_Id && t <= Tile::door_dark_oak_Id); } void DoorTile::setShape(int compositeData) diff --git a/Minecraft.World/FenceGateTile.cpp b/Minecraft.World/FenceGateTile.cpp index b6b23afa..a42257de 100644 --- a/Minecraft.World/FenceGateTile.cpp +++ b/Minecraft.World/FenceGateTile.cpp @@ -24,7 +24,7 @@ bool FenceGateTile::isOpen(int data) bool FenceGateTile::isFenceGate(int t) { - return t == Tile::fenceGate_Id || (t >= Tile::spruceFenceGate_Id && t <= Tile::darkOakFenceGate_Id); + return (t == Tile::fenceGate_Id) || (t >= Tile::spruceFenceGate_Id && t <= Tile::darkOakFenceGate_Id); } AABB *FenceGateTile::getAABB(Level *level, int x, int y, int z) diff --git a/Minecraft.World/PathFinder.cpp b/Minecraft.World/PathFinder.cpp index 525664e3..80826c58 100644 --- a/Minecraft.World/PathFinder.cpp +++ b/Minecraft.World/PathFinder.cpp @@ -247,7 +247,7 @@ int PathFinder::isFree(Entity *entity, int x, int y, int z, Node *size, bool avo } if (tile->isPathfindable(entity->level, xx, yy, zz)) continue; - if (canOpenDoors && DoorTile::isDoor(Tile::door_wood_Id)) continue; + if (canOpenDoors && DoorTile::isDoor(tileId)) continue; int renderShape = tile->getRenderShape(); if (renderShape == Tile::SHAPE_FENCE || FenceGateTile::isFenceGate(tileId) || renderShape == Tile::SHAPE_WALL) return TYPE_FENCE;