| 403 | } |
| 404 | |
| 405 | std::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 | |
| 444 | void EveInstancedMeshManager::InstanceBuffer::DoneCopying() |
| 445 | { |