OpenBarnyard
 
Loading...
Searching...
No Matches
ASectionDoneJob.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "ASectionDoneJob.h"
4
5//-----------------------------------------------------------------------------
6// Enables memory debugging.
7// Note: Should be the last include!
8//-----------------------------------------------------------------------------
10
12
16
18{
19 if ( !m_bIsCanceled )
20 {
21 // Loading is done and it is not canceled
22 TINT iNumLODs = m_pSection->GetLODCount( m_eLODType );
23
24 ATerrainLODBlock** ppLODBlocks;
25 TUINT16 uiNumMemBlocks;
26 m_pSection->GetLODBlocks( m_eLODType, ppLODBlocks, uiNumMemBlocks );
27
28 // Set memory block of the LOD
29 auto pOldMemBlock = g_pMemory->SetGlobalBlock( ppLODBlocks[ uiNumMemBlocks - 1 ]->GetMemBlock() );
30
31 for ( TINT i = 0; i < iNumLODs; i++ )
32 {
33 auto pModelNode = m_pSection->m_ppLODModelsData[ m_eLODType ][ i ];
34 ATerrainInterface::GetSingleton()->CreateModelInstance( pModelNode, "", TNULL );
35
36 if ( !ISZERO( m_pSection->m_aLODFlags[ m_eLODType ][ i ] & 1 ) )
37 {
38 pModelNode->SetUseLighting( TTRUE );
39 pModelNode->SetGlow( TTRUE );
40 }
41 }
42
43 // Set new state of LOD
44 m_pSection->SetLODLoaded( m_eLODType, TTRUE );
45 m_pSection->SetLODLoading( m_eLODType, TFALSE );
46 m_pSection->SetLODEmpty( m_eLODType, TTRUE );
47
48 // Restore memory block
49 g_pMemory->SetGlobalBlock( pOldMemBlock );
50
51 // Execute model node ready event if it is assigned
52 auto cbModelNodeReady = ATerrainInterface::GetSingleton()->GetOnModelNodeReadyCallback();
53
54 if ( TNULL != cbModelNodeReady )
55 {
56 for ( TINT i = 0; i < iNumLODs; i++ )
57 {
58 cbModelNodeReady( m_pSection->m_ppLODModelsData[ m_eLODType ][ i ] );
59 }
60 }
61
62 return TTRUE;
63 }
64 else
65 {
66 // Loading was canceled before it was done
67 m_pSection->SetLODLoading( m_eLODType, TFALSE );
68 m_pSection->SetLODQueued( m_eLODType, TFALSE );
69 m_pSection->SetLODEmpty( m_eLODType, TFALSE );
70 m_pSection->DestroyLOD( m_eLODType );
71
72 ATerrainInterface::GetSingleton()->QueueStreamingAssets();
73 return TTRUE;
74 }
75
76 return TTRUE;
77}
78
80{
81 m_bIsCanceled = TTRUE;
82 return TFALSE;
83}
84
86{
87 m_eLODType = a_eLODType;
88 m_pSection = a_pVISGroup;
89 m_bIsCanceled = TFALSE;
90}
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
#define ISZERO(X)
Definition Defines.h:3
uint16_t TUINT16
Definition Typedefs.h:15
#define TNULL
Definition Typedefs.h:23
int TINT
Definition Typedefs.h:7
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
TINT8 ATerrainLODType
TMemory * g_pMemory
Definition TMemory.cpp:131
virtual void BeginJob() override
virtual TBOOL CancelJob() override
void InitJob(ATerrainSection *a_pSection, ATerrainLODType a_eLODType)
virtual TBOOL RunJob() override