MCPcopy Create free account
hub / github.com/defold/defold / DrawRenderList

Function DrawRenderList

engine/render/src/render/render.cpp:942–1097  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

940 }
941
942 Result DrawRenderList(HRenderContext context, HPredicate predicate, HNamedConstantBuffer constant_buffer, const FrustumOptions* frustum_options, SortOrder sort_order)
943 {
944 DM_PROFILE("DrawRenderList");
945
946 // This will add new entries for the most recent debug draw render objects.
947 // The internal dispatch functions knows to only actually use the latest ones.
948 // The sort order is also one below the Texts flush which is only also debug stuff.
949 FlushDebug(context, 0xfffffe);
950
951 FrustumPlanes frustum_num_planes = dmRender::FRUSTUM_PLANES_SIDES;
952 const dmVMath::Matrix4* frustum_matrix = 0;
953
954 if (frustum_options)
955 {
956 frustum_num_planes = frustum_options->m_NumPlanes;
957 frustum_matrix = &frustum_options->m_Matrix;
958 }
959
960 if (context->m_CurrentRenderCamera != 0)
961 {
962 RenderCamera* camera = context->m_RenderCameras.Get(context->m_CurrentRenderCamera);
963 if (camera)
964 {
965 // In case the camera has changed since last update
966 if (camera->m_Dirty)
967 {
968 UpdateRenderCamera(context, context->m_CurrentRenderCamera, &camera->m_LastPosition, &camera->m_LastRotation);
969 }
970
971 UpdateRenderContextMatrices(context, camera->m_View, camera->m_Projection);
972
973 if (context->m_CurrentRenderCameraUseFrustum)
974 {
975 frustum_matrix = &camera->m_ViewProjection;
976 }
977 }
978 }
979
980 // Cleared once per frame
981 if (context->m_RenderListRanges.Empty())
982 {
983 SortRenderList(context);
984 }
985
986 uint32_t frustum_hash = 0;
987
988 if (frustum_matrix)
989 {
990 uint8_t frustum_key_buffer[sizeof(Matrix4) + sizeof(FrustumPlanes)];
991 memcpy(frustum_key_buffer, frustum_matrix, sizeof(Matrix4));
992 memcpy(frustum_key_buffer + sizeof(Matrix4), &frustum_num_planes, sizeof(frustum_num_planes));
993 frustum_hash = dmHashBuffer32(frustum_key_buffer, (uint32_t)sizeof(frustum_key_buffer));
994
995 dmIntersection::Frustum frustum;
996 dmIntersection::CreateFrustumFromMatrix(*frustum_matrix, true, (int) frustum_num_planes, frustum);
997 FrustumCulling(context, frustum, frustum_hash);
998 }
999 else

Callers 13

RenderProfilerFunction · 0.85
TEST_FFunction · 0.85
StepFrameFunction · 0.85
QueueTextAndCopyVerticesFunction · 0.85
TEST_FFunction · 0.85
ParseCommandsFunction · 0.85
DrawDebug3dFunction · 0.85
RenderCollectionFunction · 0.85
TEST_FFunction · 0.85
TEST_PFunction · 0.85

Calls 15

FlushDebugFunction · 0.85
UpdateRenderCameraFunction · 0.85
SortRenderListFunction · 0.85
CreateFrustumFromMatrixFunction · 0.85
FrustumCullingFunction · 0.85
SetVisibilityFunction · 0.85
MakeSortBufferFunction · 0.85
DrawFunction · 0.70
dmHashBuffer32Function · 0.50
assertFunction · 0.50
GetMethod · 0.45

Tested by 9

TEST_FFunction · 0.68
QueueTextAndCopyVerticesFunction · 0.68
TEST_FFunction · 0.68
RenderCollectionFunction · 0.68
TEST_FFunction · 0.68
TEST_PFunction · 0.68
WaitForTestsDoneMethod · 0.68