MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Init

Method Init

Source/Engine/Graphics/Models/Mesh.cpp:390–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388}
389
390bool 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
426void Mesh::Release()
427{

Callers 3

UpdateMeshMethod · 0.45
SetupMethod · 0.45
OnDataChangedMethod · 0.45

Calls 5

FindElementMethod · 0.80
InitFunction · 0.70
GetFunction · 0.50
CountMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected