MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / PreDrawCamera

Method PreDrawCamera

Source/Objects/movementobject.cpp:365–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365void MovementObject::PreDrawCamera(float curr_game_time) {
366 Online* online = Online::Instance();
367
368 if (g_debug_runtime_disable_movement_object_pre_draw_camera) {
369 return;
370 }
371
372 {
373 PROFILER_ZONE(g_profiler_ctx, "Angelscript PreDrawCameraNoCull()");
374 ASArglist args;
375 args.Add(curr_game_time);
376 as_context->CallScriptFunction(as_funcs.pre_draw_camera_no_cull, &args);
377 }
378 if (visible && enabled_) {
379 Camera* cam = ActiveCameras::Get();
380 if (cam->checkSphereInFrustum(position, kCullRadius) || online->IsActive()) {
381 bool occluded = false;
382 if (g_perform_occlusion_query) {
383 // Check previous occlusion queries to update per-camera occlusion
384 {
385 PROFILER_ZONE(g_profiler_ctx, "Process occlusion queries");
386
387 for (auto& occlusion_querie : occlusion_queries) {
388 OcclusionQuery* query = &occlusion_querie;
389 if (!query->in_progress) {
390 continue;
391 }
392 PROFILER_ZONE(g_profiler_ctx, "Process occlusion query");
393 int count = -1;
394 {
395 PROFILER_ZONE(g_profiler_ctx, "GL_QUERY_RESULT");
396 glGetQueryObjectiv(query->id, GL_QUERY_RESULT_AVAILABLE, &count);
397 if (count == 1) {
398 glGetQueryObjectiv(query->id, GL_QUERY_RESULT, &count);
399 } else {
400 count = -1;
401 }
402 }
403 if (count != -1) {
404 // LOGI << "Query completed with " << count << "samples visible";
405 query->in_progress = false;
406
407 {
408 PROFILER_ZONE(g_profiler_ctx, "Update occlusion state");
409 int state_id = GetStateID(occlusion_states, query->cam_id);
410
411 if (count == 0) {
412 occlusion_states[state_id].occluded = true;
413 } else {
414 occlusion_states[state_id].occluded = false;
415 }
416 }
417 }
418 }
419 }
420
421 if (distance_squared(position, ActiveCameras::Get()->GetPos()) <= kCullRadius) {
422 int state_id = GetStateID(occlusion_states, ActiveCameras::GetID());

Callers

nothing calls this directly

Calls 9

GetStateIDFunction · 0.85
checkSphereInFrustumMethod · 0.80
GetRenderTimeMethod · 0.80
GetFunction · 0.50
distance_squaredFunction · 0.50
AddMethod · 0.45
CallScriptFunctionMethod · 0.45
IsActiveMethod · 0.45
GetPosMethod · 0.45

Tested by

no test coverage detected