OpenBarnyard
 
Loading...
Searching...
No Matches
AGrassMesh.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "AGrassMesh.h"
4
6
7//-----------------------------------------------------------------------------
8// Enables memory debugging.
9// Note: Should be the last include!
10//-----------------------------------------------------------------------------
11#include <Core/TMemoryDebugOn.h>
12
14
16
17// $Barnyard: FUNCTION 005f79c0
19 : m_uiFlags( 0 )
20 , m_uiMaxVertices( 0 )
21 , m_pVertexPool( TNULL )
22 , m_Unk5( 0 )
23{
24}
25
26// $Barnyard: FUNCTION 005f7ae0
27// $Barnyard: FUNCTION 005f7ac0
29{
30 if ( m_aSubMeshes[ 0 ].pIndexPool )
31 {
32 TRenderInterface::GetSingleton()->DestroyResource( m_aSubMeshes[ 0 ].pIndexPool );
33 m_aSubMeshes[ 0 ].pIndexPool = TNULL;
34 }
35}
36
38{
39 if ( !IsValidated() )
40 {
41 TVALIDPTR( m_pVertexPool );
42
43 m_pVertexPool->Validate();
44 BaseClass::Validate();
45 }
46
47 return TTRUE;
48}
49
51{
52 BaseClass::Invalidate();
53}
54
55// $Barnyard: FUNCTION 005f7b50
57{
58 AModelLoader::DestroyMaterial( GetMaterial() );
59
60 if ( m_pVertexPool )
61 {
63 m_pVertexPool = TNULL;
64 }
65
66 m_uiFlags = 0;
67 m_uiMaxVertices = 0;
68}
69
70// $Barnyard: FUNCTION 005f7b50
71TBOOL AGrassMesh::Create( TUINT32 a_uiFlags, TUINT16 a_uiMaxVertices )
72{
73 m_uiFlags = a_uiFlags;
74 m_uiMaxVertices = a_uiMaxVertices;
75
77 TVALIDPTR( pVertexFactory );
78
79 m_pVertexPool = pVertexFactory->CreatePoolResource( m_uiMaxVertices, 1 );
80 BaseClass::Create();
81
82 return TTRUE;
83}
84
86{
87 if ( m_pVertexPool->Lock( &a_rLockBuffer ) )
88 {
89 m_uiFlags |= FLAG_LOCKED;
90 return TTRUE;
91 }
92
93 return TFALSE;
94}
95
96void AGrassMesh::Unlock( TUINT32 a_uiNumVertices )
97{
98 if ( TINT16( a_uiNumVertices ) == -1 )
99 {
100 a_uiNumVertices = m_pVertexPool->GetNumVertices();
101 }
102
103 m_pVertexPool->Unlock( a_uiNumVertices );
104 m_uiFlags &= ~FLAG_LOCKED;
105}
106
108{
109 return m_pVertexPool;
110}
@ SYSRESOURCE_VFWORLD
Definition TRender.h:14
Rendering system interface for the Toshi engine.
#define TOSHI_NAMESPACE_USING
Definition Defines.h:46
#define TVALIDPTR(PTR)
Definition Defines.h:139
#define TDEFINE_CLASS_NORUNTIME(...)
Definition TObject.h:138
uint16_t TUINT16
Definition Typedefs.h:15
int16_t TINT16
Definition Typedefs.h:14
#define TNULL
Definition Typedefs.h:23
uint32_t TUINT32
Definition Typedefs.h:13
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
T * GetSystemResource(SYSRESOURCE systemResource)
void DestroyResource(TResource *resource)
static TFORCEINLINE TRenderInterface * GetSingleton()
Definition TSingleton.h:49
static void DestroyMaterial(Toshi::TMaterial *a_pMaterial)
virtual TBOOL Lock(LockBuffer &a_rLockBuffer)
virtual Toshi::TVertexPoolResourceInterface * GetVertexPool()
virtual TBOOL Validate() override
virtual TBOOL Create(TUINT32 a_uiFlags, TUINT16 a_uiMaxVertices)
virtual void Invalidate() override
virtual void Unlock(TUINT32 a_uiNumVertices)
virtual void OnDestroy() override
Toshi::TVertexPoolResourceInterface::LockBuffer LockBuffer
Definition AGrassMesh.h:15