Added the skeleton of the cLightingThread object
git-svn-id: http://mc-server.googlecode.com/svn/trunk@286 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
510133bd35
commit
7a9925f982
@ -553,6 +553,14 @@
|
|||||||
RelativePath="..\source\LeakFinder.h"
|
RelativePath="..\source\LeakFinder.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\LightingThread.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\source\LightingThread.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\source\LuaFunctions.h"
|
RelativePath="..\source\LuaFunctions.h"
|
||||||
>
|
>
|
||||||
|
@ -399,6 +399,7 @@
|
|||||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\source\LightingThread.cpp" />
|
||||||
<ClCompile Include="..\Source\ManualBindings.cpp" />
|
<ClCompile Include="..\Source\ManualBindings.cpp" />
|
||||||
<ClCompile Include="..\source\Matrix4f.cpp" />
|
<ClCompile Include="..\source\Matrix4f.cpp" />
|
||||||
<ClCompile Include="..\source\md5\md5.cpp" />
|
<ClCompile Include="..\source\md5\md5.cpp" />
|
||||||
@ -572,6 +573,7 @@
|
|||||||
<ClInclude Include="..\Source\FileDefine.h" />
|
<ClInclude Include="..\Source\FileDefine.h" />
|
||||||
<ClInclude Include="..\source\Globals.h" />
|
<ClInclude Include="..\source\Globals.h" />
|
||||||
<ClInclude Include="..\source\LeakFinder.h" />
|
<ClInclude Include="..\source\LeakFinder.h" />
|
||||||
|
<ClInclude Include="..\source\LightingThread.h" />
|
||||||
<ClInclude Include="..\Source\LuaFunctions.h" />
|
<ClInclude Include="..\Source\LuaFunctions.h" />
|
||||||
<ClInclude Include="..\Source\ManualBindings.h" />
|
<ClInclude Include="..\Source\ManualBindings.h" />
|
||||||
<ClInclude Include="..\source\Matrix4f.h" />
|
<ClInclude Include="..\source\Matrix4f.h" />
|
||||||
|
@ -911,6 +911,7 @@
|
|||||||
<ClCompile Include="..\source\WorldStorage.cpp" />
|
<ClCompile Include="..\source\WorldStorage.cpp" />
|
||||||
<ClCompile Include="..\source\WSSCompact.cpp" />
|
<ClCompile Include="..\source\WSSCompact.cpp" />
|
||||||
<ClCompile Include="..\source\StringCompression.cpp" />
|
<ClCompile Include="..\source\StringCompression.cpp" />
|
||||||
|
<ClCompile Include="..\source\LightingThread.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\source\cServer.h">
|
<ClInclude Include="..\source\cServer.h">
|
||||||
@ -1406,6 +1407,7 @@
|
|||||||
<ClInclude Include="..\source\StackWalker.h" />
|
<ClInclude Include="..\source\StackWalker.h" />
|
||||||
<ClInclude Include="..\source\WorldStorage.h" />
|
<ClInclude Include="..\source\WorldStorage.h" />
|
||||||
<ClInclude Include="..\source\StringCompression.h" />
|
<ClInclude Include="..\source\StringCompression.h" />
|
||||||
|
<ClInclude Include="..\source\LightingThread.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\source\AllToLua.pkg">
|
<None Include="..\source\AllToLua.pkg">
|
||||||
|
114
source/LightingThread.cpp
Normal file
114
source/LightingThread.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
// LightingThread.cpp
|
||||||
|
|
||||||
|
// Implements the cLightingThread class representing the thread that processes requests for lighting
|
||||||
|
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "LightingThread.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// cLightingThread:
|
||||||
|
|
||||||
|
cLightingThread::cLightingThread(void) :
|
||||||
|
super("cLightingThread")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cLightingThread::~cLightingThread()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cLightingThread::Stop(void)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
cCSLock Lock(m_CS);
|
||||||
|
for (cLightingBufferQueue::iterator itr = m_Queue.begin(); itr != m_Queue.end(); ++itr)
|
||||||
|
{
|
||||||
|
delete *itr;
|
||||||
|
} // for itr - m_Queue[]
|
||||||
|
}
|
||||||
|
mShouldTerminate = true;
|
||||||
|
m_Event.Set();
|
||||||
|
|
||||||
|
Wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cLightingThread::QueueLighting(cWorld * a_World, int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cLightingThread::Execute(void)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// cLightingThread::cLightingBuffer:
|
||||||
|
|
||||||
|
cLightingThread::cLightingBuffer::cLightingBuffer(int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ) :
|
||||||
|
m_MinX(a_MinX),
|
||||||
|
m_MaxX(a_MaxX),
|
||||||
|
m_MinY(a_MinY),
|
||||||
|
m_MaxY(a_MaxY),
|
||||||
|
m_MinZ(a_MinZ),
|
||||||
|
m_MaxZ(a_MaxZ)
|
||||||
|
{
|
||||||
|
// TODO: initialize strides
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cLightingThread::cLightingBuffer::GetFromWorld(cWorld * a_World)
|
||||||
|
{
|
||||||
|
// TODO: Set m_BlockData, m_SkyLight and m_BlockLight from the world's chunks
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cLightingThread::cLightingBuffer::SetToWorld (cWorld * a_World)
|
||||||
|
{
|
||||||
|
// TODO: Set world's chunks from m_BlockData, m_SkyLight and m_BlockLight
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cLightingThread::cLightingBuffer::Process(void)
|
||||||
|
{
|
||||||
|
// TODO: Does the actual lighting on this buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
82
source/LightingThread.h
Normal file
82
source/LightingThread.h
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
|
||||||
|
// LightingThread.h
|
||||||
|
|
||||||
|
// Interfaces to the cLightingThread class representing the thread that processes requests for lighting
|
||||||
|
// Note that the world generators need direct access to the lighting methods so that they can light the generated chunk
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cIsThread.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// fwd:
|
||||||
|
class cWorld;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class cLightingThread :
|
||||||
|
public cIsThread
|
||||||
|
{
|
||||||
|
typedef cIsThread super;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
class cLightingBuffer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
cLightingBuffer(int m_MinX, int m_MaxX, int m_MinY, int m_MaxY, int m_MinZ, int m_MaxZ);
|
||||||
|
|
||||||
|
/// Copies the world's existing chunks into m_BlockData, m_Skylight and m_BlockLight
|
||||||
|
void GetFromWorld(cWorld * a_World);
|
||||||
|
void SetToWorld (cWorld * a_World);
|
||||||
|
|
||||||
|
void Process(void); // Does the actual lighting on this buffer
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Block coords:
|
||||||
|
int m_MinX, m_MaxX;
|
||||||
|
int m_MinY, m_MaxY;
|
||||||
|
int m_MinZ, m_MaxZ;
|
||||||
|
|
||||||
|
int m_StrideX; // = OffsetOfBlock(x, y, z) - OffsetOfBlock(x + 1, y, z)
|
||||||
|
int m_StrideZ; // = OffsetOfBlock(x, y, z) - OffsetOfBlock(x, y, z + 1)
|
||||||
|
|
||||||
|
// These buffers actually store 1 block in each direction more than is specified in the coords
|
||||||
|
// This way we can throw out a lot of conditions inside the processing cycles
|
||||||
|
// And it allows us to light a chunk with regard to its surrounding chunks without much work
|
||||||
|
// (So if m_MinX is 16 and m_MaxX is 32, the buffers actually contain data for X in range from 15 to 33 (18 items)
|
||||||
|
char * m_BlockData;
|
||||||
|
char * m_SkyLight;
|
||||||
|
char * m_BlockLight;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
cLightingThread(void);
|
||||||
|
~cLightingThread();
|
||||||
|
|
||||||
|
void Stop(void);
|
||||||
|
|
||||||
|
void QueueLighting(cWorld * a_World, int a_MinX, int a_MaxX, int a_MinY, int a_MaxY, int a_MinZ, int a_MaxZ); // queues the request
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
typedef std::list<cLightingBuffer *> cLightingBufferQueue;
|
||||||
|
|
||||||
|
cCriticalSection m_CS;
|
||||||
|
cLightingBufferQueue m_Queue;
|
||||||
|
cEvent m_Event; // Set when queue is appended or to stop the thread
|
||||||
|
|
||||||
|
virtual void Execute(void) override;
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user