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

Method LoadMesh

Source/Engine/Graphics/Models/MeshBase.cpp:202–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202bool MeshAccessor::LoadMesh(const MeshBase* mesh, bool forceGpu, Span<MeshBufferType> buffers)
203{
204 CHECK_RETURN(mesh, true);
205 constexpr MeshBufferType allBuffers[(int32)MeshBufferType::MAX] = { MeshBufferType::Index, MeshBufferType::Vertex0, MeshBufferType::Vertex1, MeshBufferType::Vertex2 };
206 if (buffers.IsInvalid())
207 buffers = Span<MeshBufferType>(allBuffers, ARRAY_COUNT(allBuffers));
208 Array<BytesContainer, FixedAllocation<4>> meshBuffers;
209 Array<GPUVertexLayout*, FixedAllocation<4>> meshLayouts;
210 if (ModelBase* model = mesh->GetModelBase())
211 {
212 // Maintain reference to mesh data (it's buffers might be referenced, not copied)
213 model->AddReference();
214 if (model->Storage)
215 model->Storage->LockChunks();
216 _usedModels.Add(model);
217 }
218 if (mesh->DownloadData(buffers, meshBuffers, meshLayouts, forceGpu))
219 return true;
220 for (int32 i = 0; i < buffers.Length(); i++)
221 {
222 const int32 buffer = (int32)buffers[i];
223 _data[buffer] = MoveTemp(meshBuffers[i]);
224 _layouts[buffer] = meshLayouts[i];
225
226 // Get format if using a single item (eg. index buffer type)
227 PixelFormat format = PixelFormat::Unknown;
228 if (meshLayouts[i] && meshLayouts[i]->GetElements().Count() == 1)
229 format = meshLayouts[i]->GetElements()[0].Format;
230 _formats[buffer] = format;
231 }
232 return false;
233}
234
235bool MeshAccessor::LoadBuffer(MeshBufferType bufferType, Span<byte> bufferData, GPUVertexLayout* layout)
236{

Callers 15

DownloadBufferMethod · 0.45
DownloadDataCPUMethod · 0.45
DownloadIndexBufferMethod · 0.45
DownloadBufferMethod · 0.45
DownloadMeshDataMethod · 0.45
SetPaintMethod · 0.45
IntersectsItselfMethod · 0.45
DrawPhysicsDebugMethod · 0.45
OnDebugDrawSelectedMethod · 0.45
CreateClothMethod · 0.45
OnPreUpdateMethod · 0.45
RunClothDeformerMethod · 0.45

Calls 7

LockChunksMethod · 0.80
IsInvalidMethod · 0.45
AddReferenceMethod · 0.45
AddMethod · 0.45
DownloadDataMethod · 0.45
LengthMethod · 0.45
CountMethod · 0.45

Tested by

no test coverage detected