summaryrefslogtreecommitdiff
path: root/hammer/bsplightingthread.h
blob: b6988c51aaa492cef38387d66441b206e98ef663 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef BSPLIGHTINGTHREAD_H
#define BSPLIGHTINGTHREAD_H
#ifdef _WIN32
#pragma once
#endif


#include "stdafx.h"
#include "ibsplightingthread.h"
#include "utlvector.h"


class CBSPLightingThread : public IBSPLightingThread
{
public:

						CBSPLightingThread();


// IBSPLightingThread functions.
public:
	virtual				~CBSPLightingThread();
	virtual void		Release();
	virtual void		StartLighting( char const *pVMFFileWithEntities );
	virtual int			GetCurrentState();
	virtual void		Interrupt();
	virtual float		GetPercentComplete();


// Other functions.
public:

	// This is called immediately after the constructor. It creates the thread.
	bool				Init( IVRadDLL *pDLL );



// Threadsafe functions.
public:

	enum
	{
		THREADCMD_NONE=0,
		THREADCMD_LIGHT=1,
		THREADCMD_EXIT=2
	};

	// Get the current command to the thread. Resets to THREADCMD_NONE on exit.
	int					GetThreadCmd();
	void				SetThreadCmd( int cmd );

	// Returns an IBSPLightingThread::STATE_ define.
	int					GetThreadState();
	void				SetThreadState( int state );
	

public:

	// The thread's run function.
	DWORD				ThreadMainLoop();


public:

	int					m_ThreadCmd;		// Next command for the thread to run.
	int					m_ThreadState;		// Current state of the thread.

	CUtlVector<char>	m_VMFFileWithEntities;


public:
	IVRadDLL			*m_pVRadDLL;

	HANDLE				m_hThread;
	DWORD				m_ThreadID;
	CRITICAL_SECTION	m_CS;
};


#endif // BSPLIGHTINGTHREAD_H