OpenBarnyard
 
Loading...
Searching...
No Matches
ASectionDoneJob Class Reference

#include <ASectionDoneJob.h>

Inheritance diagram for ASectionDoneJob:
AMainThreadJob

Public Member Functions

virtual void BeginJob () override
 
virtual TBOOL RunJob () override
 
virtual TBOOL CancelJob () override
 
void InitJob (ATerrainSection *a_pSection, ATerrainLODType a_eLODType)
 
- Public Member Functions inherited from AMainThreadJob
virtual ~AMainThreadJob ()=default
 
TBOOL IsFinished () const
 

Additional Inherited Members

- Protected Attributes inherited from AMainThreadJob
TBOOL m_bIsFinished = TFALSE
 

Detailed Description

Definition at line 5 of file ASectionDoneJob.h.

Member Function Documentation

◆ BeginJob()

void ASectionDoneJob::BeginJob ( )
overridevirtual

Implements AMainThreadJob.

Definition at line 13 of file ASectionDoneJob.cpp.

14{
15}

◆ CancelJob()

TBOOL ASectionDoneJob::CancelJob ( )
overridevirtual

Reimplemented from AMainThreadJob.

Definition at line 79 of file ASectionDoneJob.cpp.

80{
81 m_bIsCanceled = TTRUE;
82 return TFALSE;
83}
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25

◆ InitJob()

void ASectionDoneJob::InitJob ( ATerrainSection * a_pSection,
ATerrainLODType a_eLODType )

Definition at line 85 of file ASectionDoneJob.cpp.

86{
87 m_eLODType = a_eLODType;
88 m_pSection = a_pVISGroup;
89 m_bIsCanceled = TFALSE;
90}

◆ RunJob()

TBOOL ASectionDoneJob::RunJob ( )
overridevirtual

Implements AMainThreadJob.

Definition at line 17 of file ASectionDoneJob.cpp.

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}
#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
TMemory * g_pMemory
Definition TMemory.cpp:131
TMemory::MemBlock * SetGlobalBlock(MemBlock *a_pMemBlock)
Sets the global memory block.
Definition TMemory.cpp:793

The documentation for this class was generated from the following files: