OpenBarnyard
 
Loading...
Searching...
No Matches
ASkinMesh.cpp
Go to the documentation of this file.
1#include "pch.h"
2#include "ASkinMesh.h"
4
6
7//-----------------------------------------------------------------------------
8// Enables memory debugging.
9// Note: Should be the last include!
10//-----------------------------------------------------------------------------
11#include <Core/TMemoryDebugOn.h>
12
14
16
21
23{
24 if ( pIndexPool )
25 {
26 pIndexPool->DestroyResource();
28 }
29}
30
35
39
41{
42 if ( !IsValidated() )
43 {
45
46 m_pVertexPool->Validate();
47 BaseClass::Validate();
48 }
49
50 return TTRUE;
51}
52
54{
55 BaseClass::Invalidate();
56}
57
59{
60 return TTRUE;
61}
62
64{
65 AModelLoader::DestroyMaterial( m_pMaterial );
66 DestroyResource();
67 BaseClass::OnDestroy();
68}
69
70void ASkinMesh::Create( TUINT32 a_uiFlags, TUINT16 a_uiMaxVertices, TUINT16 a_uiNumSubMeshes )
71{
72 TASSERT( !IsCreated() );
73
74 m_uiMaxVertices = a_uiMaxVertices;
75 m_uiFlags = a_uiFlags;
76 m_uiNumSubMeshes = a_uiNumSubMeshes;
77
78 if ( CreateResource() )
79 {
80 BaseClass::Create();
81 }
82 else
83 {
84 TASSERT( !"Couldn't create ASkinMesh" );
85 }
86}
87
89{
90 TASSERT( 0 == ( m_uiFlags & FLAG_LOCKED ) );
91
92 if ( m_pVertexPool->Lock( &a_rLockBuffer ) )
93 {
94 m_uiFlags |= FLAG_LOCKED;
95 return TTRUE;
96 }
97
98 return TFALSE;
99}
100
101void ASkinMesh::Unlock( TUINT32 a_uiNumVertices )
102{
103 TASSERT( 0 != ( m_uiFlags & FLAG_LOCKED ) );
104
105 if ( TINT16( a_uiNumVertices ) == -1 )
106 {
107 a_uiNumVertices = m_pVertexPool->GetNumVertices();
108 }
109
110 m_pVertexPool->Unlock( a_uiNumVertices );
111 m_uiFlags &= ~FLAG_LOCKED;
112}
113
114Toshi::TVertexPoolResourceInterface* ASkinMesh::GetVertexPool()
115{
116 return m_pVertexPool;
117}
118
123
125{
126 TASSERT( a_uiIndex < m_uiNumSubMeshes );
127 return &m_pSubMeshes[ a_uiIndex ];
128}
129
130TBOOL ASkinMesh::CreateResource()
131{
133 TVALIDPTR( pVertexFactory );
134
135 m_pVertexPool = pVertexFactory->CreatePoolResource( m_uiMaxVertices, 1 );
137
138 return TTRUE;
139}
140
141void ASkinMesh::DestroyResource()
142{
143 if ( m_pVertexPool )
144 {
147 }
148
149 delete[] m_pSubMeshes;
151 m_uiFlags = 0;
152 m_uiMaxVertices = 0;
153}
@ SYSRESOURCE_VFSKIN
Definition TRender.h:10
Rendering system interface for the Toshi engine.
#define TASSERT(X,...)
Definition Defines.h:138
#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)
TUINT16 uiUnknown
Definition ASkinMesh.h:13
TUINT32 uiNumBones
Definition ASkinMesh.h:22
TUINT16 uiNumVertices
Definition ASkinMesh.h:14
Toshi::TIndexPoolResourceInterface * pIndexPool
Definition ASkinMesh.h:15
TUINT16 m_uiNumSubMeshes
Definition ASkinMesh.h:63
ASkinSubMesh * m_pSubMeshes
Definition ASkinMesh.h:65
virtual void OnDestroy() override
Definition ASkinMesh.cpp:63
Toshi::TVertexPoolResourceInterface * m_pVertexPool
Definition ASkinMesh.h:64
TUINT16 GetNumSubMeshes() const
virtual TBOOL Lock(LockBuffer &a_rLockBuffer)
Definition ASkinMesh.cpp:88
virtual Toshi::TVertexPoolResourceInterface * GetVertexPool()
TUINT32 m_uiFlags
Definition ASkinMesh.h:61
void * m_Unk
Definition ASkinMesh.h:66
TUINT16 m_uiMaxVertices
Definition ASkinMesh.h:62
Toshi::TVertexPoolResourceInterface::LockBuffer LockBuffer
Definition ASkinMesh.h:31
ASkinSubMesh * GetSubMesh(TUINT16 a_uiIndex)
virtual TBOOL Validate() override
Definition ASkinMesh.cpp:40
virtual void Unlock(TUINT32 a_uiNumVertices)
virtual TBOOL Render() override
Definition ASkinMesh.cpp:58
virtual void Create(TUINT32 a_uiFlags, TUINT16 a_uiMaxVertices, TUINT16 a_uiNumSubMeshes)
Definition ASkinMesh.cpp:70
virtual void Invalidate() override
Definition ASkinMesh.cpp:53