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

#include <ATerrainLocator.h>

Public Member Functions

 ATerrainLocatorList ()
 
 ~ATerrainLocatorList ()
 
ATerrainLocatorFindLocator (const TCHAR *a_pszLocatorName)
 
void LoadFromTRB (Toshi::TTRB *a_pTRB)
 
Toshi::TTRB * GetTRB ()
 
Toshi::TTransformObject & GetWorldTransform ()
 
TINT32 GetNumLocators () const
 
ATerrainLocatorTRBHeaderGetHeader () const
 

Detailed Description

Definition at line 37 of file ATerrainLocator.h.

Constructor & Destructor Documentation

◆ ATerrainLocatorList()

ATerrainLocatorList::ATerrainLocatorList ( )

Definition at line 14 of file ATerrainLocator.cpp.

15 : m_pTRB( TNULL )
16 , m_pLocatorsHeader( TNULL )
17 , m_pLocatorVISHeader( TNULL )
18 , m_bCreatedGrowings( TFALSE )
19{
20 m_oWorldTransform.SetMatrix( TMatrix44{
21 1.0f,
22 0.0f,
23 0.0f,
24 0.0f,
25 0.0f,
26 0.0f,
27 1.0f,
28 0.0f,
29 0.0f,
30 -1.0f,
31 0.0f,
32 0.0f,
33 0.0f,
34 0.0f,
35 0.0f,
36 1.0f,
37 } );
38}
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24

◆ ~ATerrainLocatorList()

ATerrainLocatorList::~ATerrainLocatorList ( )

Definition at line 40 of file ATerrainLocator.cpp.

41{
42}

Member Function Documentation

◆ FindLocator()

ATerrainLocator * ATerrainLocatorList::FindLocator ( const TCHAR * a_pszLocatorName)

Definition at line 45 of file ATerrainLocator.cpp.

46{
47 TVALIDPTR( m_pLocatorsHeader );
48
49 if ( m_pLocatorVISHeader == TNULL )
50 // No VIS data is provided, look for all the locators
51 {
52 for ( TINT i = 0; i < m_pLocatorsHeader->iNumLocators; i++ )
53 {
54 ATerrainLocator* pLocator = &m_pLocatorsHeader->pLocators[ i ];
55
56 if ( !TStringManager::String8Compare( m_pLocatorsHeader->ppNames[ pLocator->uiNameId ], a_pszLocatorName ) )
57 return &m_pLocatorsHeader->pLocators[ i ];
58 }
59 }
60 else
61 // We have VIS data, so it's easier to find the locator using binary search
62 {
63 for ( TINT i = 0; i < m_pLocatorVISHeader->iNumSections; i++ )
64 {
65 ATerrainLocatorVISSection* pSection = &m_pLocatorVISHeader->pSections[ i ];
66
67 // Do binary search
68 TUINT uiBase = pSection->uiFirstLocator;
69 TUINT uiEnd = uiBase + pSection->uiNumLocators;
70 TUINT uiCurrent = ( ( uiEnd - uiBase ) / 2 ) + uiBase;
71
72 while ( uiBase <= uiCurrent && uiCurrent < uiEnd )
73 {
74 ATerrainLocator* pLocator = &m_pLocatorsHeader->pLocators[ uiCurrent ];
75 TINT iCmpRes = TStringManager::String8Compare( m_pLocatorsHeader->ppNames[ pLocator->uiNameId ], a_pszLocatorName );
76
77 if ( iCmpRes == 0 ) return pLocator;
78
79 if ( iCmpRes < 1 )
80 // Check the right side of array
81 {
82 uiBase = uiCurrent + 1;
83 uiCurrent = ( ( uiEnd - uiBase ) / 2 ) + uiBase;
84 }
85 else
86 // Check the left side of array
87 {
88 uiEnd = uiCurrent;
89 uiCurrent = ( ( uiCurrent - uiBase ) / 2 ) + uiBase;
90 }
91 }
92 }
93 }
94
95 return TNULL;
96}
#define TVALIDPTR(PTR)
Definition Defines.h:139
unsigned int TUINT
Definition Typedefs.h:8
int TINT
Definition Typedefs.h:7
static TINT String8Compare(const TCHAR *str1, const TCHAR *str2, TSIZE size=-1)

◆ GetHeader()

ATerrainLocatorTRBHeader * ATerrainLocatorList::GetHeader ( ) const
inline

Definition at line 53 of file ATerrainLocator.h.

53{ return m_pLocatorsHeader; }

◆ GetNumLocators()

TINT32 ATerrainLocatorList::GetNumLocators ( ) const
inline

Definition at line 52 of file ATerrainLocator.h.

52{ return m_pLocatorsHeader->iNumLocators; }

◆ GetTRB()

Toshi::TTRB * ATerrainLocatorList::GetTRB ( )
inline

Definition at line 49 of file ATerrainLocator.h.

49{ return m_pTRB; }

◆ GetWorldTransform()

Toshi::TTransformObject & ATerrainLocatorList::GetWorldTransform ( )
inline

Definition at line 50 of file ATerrainLocator.h.

50{ return m_oWorldTransform; }

◆ LoadFromTRB()

void ATerrainLocatorList::LoadFromTRB ( Toshi::TTRB * a_pTRB)

Definition at line 99 of file ATerrainLocator.cpp.

100{
101 m_pTRB = a_pTRB;
102 m_pLocatorsHeader = a_pTRB->CastSymbol<ATerrainLocatorTRBHeader>( "Locators" );
103 m_pLocatorVISHeader = a_pTRB->CastSymbol<ATerrainLocatorVISTRBHeader>( "LocatorVIS" );
104
105 TASSERT( m_pLocatorsHeader && m_pLocatorVISHeader );
106
107 ATreeManager::GetSingleton()->CreateInstances( this );
108 TTODO( "Create regrowths, instances and other things from locators" );
109}
#define TASSERT(X,...)
Definition Defines.h:138
#define TTODO(DESC)
Definition Defines.h:134

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