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

Method Draw

Source/Engine/Graphics/Models/SkinnedMesh.cpp:312–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

310}
311
312void SkinnedMesh::Draw(const RenderContext& renderContext, const DrawInfo& info, float lodDitherFactor) const
313{
314 const auto& entry = info.Buffer->At(_materialSlotIndex);
315 if (!entry.Visible || !IsInitialized())
316 return;
317 const MaterialSlot& slot = _model->MaterialSlots[_materialSlotIndex];
318
319 // Select material
320 MaterialBase* material;
321 if (entry.Material && entry.Material->IsLoaded())
322 material = entry.Material;
323 else if (slot.Material && slot.Material->IsLoaded())
324 material = slot.Material;
325 else
326 material = GPUDevice::Instance->GetDefaultMaterial();
327 if (!material || !material->IsSurface())
328 return;
329
330 // Check if skip rendering
331 const auto shadowsMode = entry.ShadowsMode & slot.ShadowsMode;
332 const auto drawModes = info.DrawModes & renderContext.View.Pass & renderContext.View.GetShadowsDrawPassMask(shadowsMode) & material->GetDrawModes();
333 if (drawModes == DrawPass::None)
334 return;
335
336 // Setup draw call
337 DrawCall drawCall;
338 drawCall.Geometry.IndexBuffer = _indexBuffer;
339 drawCall.Geometry.VertexBuffers[0] = _vertexBuffers[0];
340 if (info.Deformation)
341 info.Deformation->RunDeformers(this, MeshBufferType::Vertex0, drawCall.Geometry.VertexBuffers[0]);
342 drawCall.Draw.StartIndex = 0;
343 drawCall.Draw.IndicesCount = _triangles * 3;
344 drawCall.InstanceCount = 1;
345 drawCall.Material = material;
346 drawCall.World = *info.World;
347 drawCall.ObjectPosition = drawCall.World.GetTranslation();
348 drawCall.ObjectRadius = (float)info.Bounds.Radius; // TODO: should it be kept in sync with ObjectPosition?
349 drawCall.Surface.GeometrySize = _box.GetSize();
350 drawCall.Surface.PrevWorld = info.DrawState->PrevWorld;
351 drawCall.Surface.Skinning = info.Skinning;
352 drawCall.Surface.LODDitherFactor = lodDitherFactor;
353 drawCall.PerInstanceRandom = info.PerInstanceRandom;
354 drawCall.StencilValue = info.StencilValue;
355
356 // Push draw call to the render list
357 renderContext.List->AddDrawCall(renderContext, drawModes, StaticFlags::None, drawCall, entry.ReceiveDecals, info.SortOrder);
358}
359
360void SkinnedMesh::Draw(const RenderContextBatch& renderContextBatch, const DrawInfo& info, float lodDitherFactor) const
361{

Callers

nothing calls this directly

Calls 8

RunDeformersMethod · 0.80
AddDrawCallMethod · 0.80
IsInitializedFunction · 0.70
IsLoadedMethod · 0.45
GetDefaultMaterialMethod · 0.45
GetDrawModesMethod · 0.45
GetSizeMethod · 0.45
GetMainContextMethod · 0.45

Tested by

no test coverage detected