| 382 | } |
| 383 | |
| 384 | MeshAccessor::Stream MeshAccessor::Attribute(VertexElement::Types attribute) |
| 385 | { |
| 386 | Span<byte> data; |
| 387 | PixelFormat format = PixelFormat::Unknown; |
| 388 | int32 stride = 0, count = 0; |
| 389 | for (int32 vbIndex = 0; vbIndex < 3 && format == PixelFormat::Unknown; vbIndex++) |
| 390 | { |
| 391 | static_assert((int32)MeshBufferType::Vertex0 == 1, "Update code."); |
| 392 | const int32 idx = vbIndex + 1; |
| 393 | auto layout = _layouts[idx]; |
| 394 | if (!layout) |
| 395 | continue; |
| 396 | for (const VertexElement& e : layout->GetElements()) |
| 397 | { |
| 398 | auto& vb = _data[idx]; |
| 399 | if (e.Type == attribute && vb.IsValid()) |
| 400 | { |
| 401 | data = vb.Slice(e.Offset); |
| 402 | format = e.Format; |
| 403 | stride = layout->GetStride(); |
| 404 | count = vb.Length() / stride; |
| 405 | break; |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | return Stream(data, format, stride, count); |
| 410 | } |
| 411 | |
| 412 | MeshBase::~MeshBase() |
| 413 | { |