From fe983a1a45b23c67cf6c758a4f0ffe6a8ba764d6 Mon Sep 17 00:00:00 2001 From: x12xx12x <44411062+12xx12@users.noreply.github.com> Date: Wed, 20 Apr 2022 00:10:35 +0200 Subject: Valid Height is now checked by vector. --- src/Simulator/FluidSimulator.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/Simulator/FluidSimulator.cpp') diff --git a/src/Simulator/FluidSimulator.cpp b/src/Simulator/FluidSimulator.cpp index 0c4dc791d..968b8bd6e 100644 --- a/src/Simulator/FluidSimulator.cpp +++ b/src/Simulator/FluidSimulator.cpp @@ -130,14 +130,14 @@ bool cFluidSimulator::IsHigherMeta(NIBBLETYPE a_Meta1, NIBBLETYPE a_Meta2) -Vector3f cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z) +Vector3f cFluidSimulator::GetFlowingDirection(Vector3i a_Pos) { - if (!cChunkDef::IsValidHeight(a_Y)) + if (!cChunkDef::IsValidHeight(a_Pos)) { return {}; } - if (!IsAllowedBlock(m_World.GetBlock({ a_X, a_Y, a_Z }))) // No Fluid -> No Flowing direction :D + if (!IsAllowedBlock(m_World.GetBlock(a_Pos))) // No Fluid -> No Flowing direction :D { return {}; } @@ -148,24 +148,24 @@ Vector3f cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z) return ((a_BlockMeta & 0x08) != 0) ? 0 : a_BlockMeta; }; - auto BlockMeta = m_World.GetBlockMeta({ a_X, a_Y, a_Z }); + auto BlockMeta = m_World.GetBlockMeta(a_Pos); NIBBLETYPE CentralPoint = HeightFromMeta(BlockMeta); NIBBLETYPE LevelPoint[4]; // blocks around the checking pos - Vector3i Points[] + std::array Offsets { { - { a_X + 1, a_Y, a_Z }, - { a_X, a_Y, a_Z + 1 }, - { a_X - 1, a_Y, a_Z }, - { a_X, a_Y, a_Z - 1 } - }; + { 1, 0, 0 }, + { 0, 0, 1 }, + { 1, 0, 0 }, + { 0, 0, 1 } + }}; - for (size_t i = 0; i < ARRAYCOUNT(LevelPoint); i++) + for (size_t i = 0; i < Offsets.size(); i++) { - if (IsAllowedBlock(m_World.GetBlock(Points[i]))) + if (IsAllowedBlock(m_World.GetBlock(a_Pos + Offsets[i]))) { - LevelPoint[i] = HeightFromMeta(m_World.GetBlockMeta(Points[i])); + LevelPoint[i] = HeightFromMeta(m_World.GetBlockMeta(Offsets[i])); } else { -- cgit v1.2.3