summaryrefslogtreecommitdiffstats
path: root/source/cFluidSimulator.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-21 13:29:05 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-21 13:29:05 +0100
commitb4a68e58a9badb0f33d43a4cce9877935b2cc917 (patch)
treeb9436d62cdd326166d6d0d3e6e35e04673d311f7 /source/cFluidSimulator.cpp
parentRevised GNUmakefile for header file dependencies (again; this time it should work ;) (diff)
downloadcuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.gz
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.bz2
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.lz
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.xz
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.tar.zst
cuberite-b4a68e58a9badb0f33d43a4cce9877935b2cc917.zip
Diffstat (limited to '')
-rw-r--r--source/cFluidSimulator.cpp65
1 files changed, 58 insertions, 7 deletions
diff --git a/source/cFluidSimulator.cpp b/source/cFluidSimulator.cpp
index 2d8952a05..68a6af599 100644
--- a/source/cFluidSimulator.cpp
+++ b/source/cFluidSimulator.cpp
@@ -199,8 +199,6 @@ public:
}
return Points;
-
-
}
std::set< Vector3i >* m_ActiveFluid;
@@ -228,6 +226,10 @@ public:
unsigned char m_CurResult;
};
+
+
+
+
cFluidSimulator::cFluidSimulator( cWorld* a_World )
: cSimulator(a_World)
, m_Data(0)
@@ -235,20 +237,35 @@ cFluidSimulator::cFluidSimulator( cWorld* a_World )
m_Data = new FluidData(a_World, this);
}
+
+
+
+
cFluidSimulator::~cFluidSimulator()
{
delete m_Data;
}
+
+
+
+
void cFluidSimulator::AddBlock( int a_X, int a_Y, int a_Z )
{
- if(!IsAllowedBlock(m_World->GetBlock(a_X, a_Y, a_Z))) //This should save very much time because it doesn´t have to iterate through all blocks
+ char BlockType = m_World->GetBlock(a_X, a_Y, a_Z);
+ if (!IsAllowedBlock(BlockType)) //This should save very much time because it doesn´t have to iterate through all blocks
+ {
return;
+ }
std::set< Vector3i > & ActiveFluid = *m_Data->m_ActiveFluid;
ActiveFluid.insert( Vector3i( a_X, a_Y, a_Z ) );
}
+
+
+
+
char cFluidSimulator::GetHighestLevelAround( int a_X, int a_Y, int a_Z )
{
char Max = m_MaxHeight + m_FlowReduction;
@@ -270,12 +287,18 @@ char cFluidSimulator::GetHighestLevelAround( int a_X, int a_Y, int a_Z )
return Max;
}
+
+
+
+
void cFluidSimulator::Simulate( float a_Dt )
{
m_Timer += a_Dt;
- if(m_Data->m_ActiveFluid->empty()) //Nothing to do if there is no active fluid ;) saves very little time ;D
+ if (m_Data->m_ActiveFluid->empty()) //Nothing to do if there is no active fluid ;) saves very little time ;D
+ {
return;
+ }
std::swap( m_Data->m_ActiveFluid, m_Data->m_Buffer ); // Swap so blocks can be added to empty ActiveFluid array
m_Data->m_ActiveFluid->clear();
@@ -393,6 +416,9 @@ void cFluidSimulator::Simulate( float a_Dt )
}
+
+
+
bool cFluidSimulator::IsPassableForFluid(char a_BlockID)
{
return a_BlockID == E_BLOCK_AIR
@@ -401,11 +427,19 @@ bool cFluidSimulator::IsPassableForFluid(char a_BlockID)
|| CanWashAway(a_BlockID);
}
+
+
+
+
bool cFluidSimulator::IsStationaryBlock (char a_BlockID)
{
return a_BlockID == m_StationaryFluidBlock;
}
+
+
+
+
bool cFluidSimulator::CanWashAway( char a_BlockID )
{
switch( a_BlockID )
@@ -421,6 +455,10 @@ bool cFluidSimulator::CanWashAway( char a_BlockID )
};
}
+
+
+
+
bool cFluidSimulator::IsSolidBlock( char a_BlockID )
{
return !(a_BlockID == E_BLOCK_AIR
@@ -430,6 +468,10 @@ bool cFluidSimulator::IsSolidBlock( char a_BlockID )
|| CanWashAway(a_BlockID));
}
+
+
+
+
//TODO Not working very well yet :s
Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a_Over)
{
@@ -489,7 +531,6 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
delete Pos;
}
-
if(LowestPoint == m_World->GetBlockMeta(a_X, a_Y, a_Z))
return NONE;
@@ -514,9 +555,11 @@ Direction cFluidSimulator::GetFlowingDirection(int a_X, int a_Y, int a_Z, bool a
}
return NONE;
+}
+
+
-}
bool cFluidSimulator::UniqueSituation(Vector3i a_Pos)
{
@@ -607,6 +650,10 @@ bool cFluidSimulator::UniqueSituation(Vector3i a_Pos)
return result;
}
+
+
+
+
void cFluidSimulator::ApplyUniqueToNearest(Vector3i a_Pos)
{
Vector3i NearPoints [] = {
@@ -621,4 +668,8 @@ void cFluidSimulator::ApplyUniqueToNearest(Vector3i a_Pos)
{
UniqueSituation(NearPoints[i]);
}
-} \ No newline at end of file
+}
+
+
+
+