MCPcopy Create free account
hub / github.com/carbonengine/trinity / GetUnusedRegion

Method GetUnusedRegion

trinity/Eve/EveInstancedMeshManager.cpp:405–442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403}
404
405std::optional<uint32_t> EveInstancedMeshManager::InstanceBuffer::GetUnusedRegion( uint32_t count )
406{
407 if( !buffer || !buffer->IsValid() )
408 {
409 return {};
410 }
411 uint32_t totalCount = buffer->GetDesc().count * buffer->GetDesc().stride;
412
413 if( regions.empty() )
414 {
415 if( count <= totalCount )
416 {
417 return 0;
418 }
419 return {};
420 }
421
422 auto offset = regions.back().offset + regions.back().length;
423 uint32_t endOffset = regions.front().offset;
424 if( endOffset < offset )
425 {
426 if( count < totalCount - offset )
427 {
428 return offset;
429 }
430 if( count < endOffset )
431 {
432 offset = 0;
433 return offset;
434 }
435 return {};
436 }
437 if( endOffset >= offset + count )
438 {
439 return offset;
440 }
441 return {};
442}
443
444void EveInstancedMeshManager::InstanceBuffer::DoneCopying()
445{

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.80
IsValidMethod · 0.45

Tested by

no test coverage detected