Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions trinity/Tr2CurveLineSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,17 @@ bool Tr2CurveLineSet::FillVertexBuffer()
// catch zero size, so we don't need to worry about empty arrays
if( m_lines.size() )
{
// can the big vertexbuffer handle this?
int currentNumOfLines = GetNumOfLines();

size_t byteSize = size_t( currentNumOfLines ) * 6 * sizeof( LineVertex );
auto buffer = Tr2Renderer::GetPoolAllocator()->Allocate( byteSize );
if( !buffer )
{
m_vertexBuffer = {};
return false;
}

// can the big vertexbuffer handle this?
if( !m_vertexBuffer.IsValid() || ( currentNumOfLines > m_vertexBufferSize ) )
{
// release old and create new
Expand All @@ -392,8 +401,6 @@ bool Tr2CurveLineSet::FillVertexBuffer()
m_vertexBufferSize = currentNumOfLines;
}

size_t byteSize = m_vertexBufferSize * 6 * sizeof( LineVertex );
auto buffer = Tr2Renderer::GetPoolAllocator()->Allocate( byteSize );
LineVertex* vertexBuffer = reinterpret_cast<LineVertex*>( buffer );

for( unsigned int i = 0; i < m_lines.size(); ++i )
Expand Down
Loading