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

Method Draw

Source/Engine/Level/Actors/StaticModel.cpp:341–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341void StaticModel::Draw(RenderContext& renderContext)
342{
343 if (!Model || !Model->IsLoaded() || !Model->CanBeRendered())
344 return;
345 if (renderContext.View.Pass == DrawPass::GlobalSDF)
346 {
347 if (EnumHasAnyFlags(_drawModes, DrawPass::GlobalSDF) && Model->SDF.Texture)
348 GlobalSignDistanceFieldPass::Instance()->RasterizeModelSDF(this, Model->SDF, _transform, _box);
349 return;
350 }
351 if (renderContext.View.Pass == DrawPass::GlobalSurfaceAtlas)
352 {
353 if (EnumHasAnyFlags(_drawModes, DrawPass::GlobalSurfaceAtlas) && Model->SDF.Texture)
354 GlobalSurfaceAtlasPass::Instance()->RasterizeActor(this, this, _sphere, _transform, Model->LODs.Last().GetBox());
355 return;
356 }
357 ACTOR_GET_WORLD_MATRIX(this, view, world);
358 GEOMETRY_DRAW_STATE_EVENT_BEGIN(_drawState, world);
359 if (_vertexColorsDirty)
360 FlushVertexColors();
361
362 Mesh::DrawInfo draw;
363 draw.Buffer = &Entries;
364 draw.World = &world;
365 draw.DrawState = &_drawState;
366 draw.Deformation = _deformation;
367 draw.Lightmap = _scene ? _scene->LightmapsData.GetReadyLightmap(Lightmap.TextureIndex) : nullptr;
368 draw.LightmapUVs = &Lightmap.UVsArea;
369 draw.Flags = _staticFlags;
370 draw.DrawModes = _drawModes;
371 draw.Bounds = _sphere;
372 draw.Bounds.Center -= renderContext.View.Origin;
373 draw.PerInstanceRandom = GetPerInstanceRandom();
374 draw.LODBias = _lodBias;
375 draw.ForcedLOD = _forcedLod;
376 draw.SortOrder = _sortOrder;
377 draw.VertexColors = _vertexColorsCount ? _vertexColorsBuffer : nullptr;
378 draw.SetStencilValue(_layer);
379#if USE_EDITOR
380 if (HasStaticFlag(StaticFlags::Lightmap))
381 draw.LightmapScale = _scaleInLightmap;
382#endif
383
384 Model->Draw(renderContext, draw);
385
386 GEOMETRY_DRAW_STATE_EVENT_END(_drawState, world);
387}
388
389void StaticModel::Draw(RenderContextBatch& renderContextBatch)
390{

Callers

nothing calls this directly

Calls 11

EnumHasAnyFlagsFunction · 0.85
HasStaticFlagFunction · 0.85
RasterizeModelSDFMethod · 0.80
RasterizeActorMethod · 0.80
GetReadyLightmapMethod · 0.80
InstanceClass · 0.70
IsLoadedMethod · 0.45
GetBoxMethod · 0.45
LastMethod · 0.45
SetStencilValueMethod · 0.45
GetMainContextMethod · 0.45

Tested by

no test coverage detected