| 388 | } |
| 389 | |
| 390 | bool Mesh::Init(uint32 vertices, uint32 triangles, const Array<const void*, FixedAllocation<3>>& vbData, const void* ibData, bool use16BitIndexBuffer, Array<GPUVertexLayout*, FixedAllocation<3>> vbLayout) |
| 391 | { |
| 392 | // Inject lightmap uv coordinate index into the vertex layout of one of the buffers |
| 393 | if (LightmapUVsIndex != -1) |
| 394 | { |
| 395 | const auto vertexElementType = (VertexElement::Types)((int32)VertexElement::Types::TexCoord0 + LightmapUVsIndex); |
| 396 | for (int32 vbIndex = 0; vbIndex < vbLayout.Count(); vbIndex++) |
| 397 | { |
| 398 | // Check if layout contains lightmap uvs texcoords channel |
| 399 | GPUVertexLayout* layout = vbLayout[vbIndex]; |
| 400 | VertexElement element = layout->FindElement(vertexElementType); |
| 401 | if (element.Type == vertexElementType) |
| 402 | { |
| 403 | // Ensure element doesn't exist in this layout |
| 404 | if (layout->FindElement(VertexElement::Types::Lightmap).Format == PixelFormat::Unknown) |
| 405 | { |
| 406 | GPUVertexLayout::Elements elements = layout->GetElements(); |
| 407 | element.Type = VertexElement::Types::Lightmap; |
| 408 | elements.Add(element); |
| 409 | layout = GPUVertexLayout::Get(elements, true); |
| 410 | vbLayout[vbIndex] = layout; |
| 411 | } |
| 412 | break; |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | if (MeshBase::Init(vertices, triangles, vbData, ibData, use16BitIndexBuffer, vbLayout)) |
| 418 | return true; |
| 419 | |
| 420 | auto model = (Model*)_model; |
| 421 | if (model) |
| 422 | model->LODs[_lodIndex]._verticesCount += _vertices; |
| 423 | return false; |
| 424 | } |
| 425 | |
| 426 | void Mesh::Release() |
| 427 | { |
no test coverage detected