| 525 | } |
| 526 | |
| 527 | void RiggedObject::PreDrawCamera(float curr_game_time) { |
| 528 | Online* online = Online::Instance(); |
| 529 | |
| 530 | if (g_debug_runtime_disable_rigged_object_pre_draw_camera) { |
| 531 | return; |
| 532 | } |
| 533 | |
| 534 | PROFILER_ZONE(g_profiler_ctx, "RiggedObject::PreDraw"); |
| 535 | for (bool& i : need_vbo_update) { |
| 536 | i = true; |
| 537 | } |
| 538 | Graphics::Instance()->setGLState(rigged_object_gl_state.gl_state); |
| 539 | |
| 540 | shadow_group_id = -1; |
| 541 | |
| 542 | lod_level = 0; |
| 543 | const vec3& avg_pos = GetAvgPosition(); |
| 544 | const vec3& cam_pos = ActiveCameras::Get()->GetPos(); |
| 545 | const float cam_zoom = 90.0f / ActiveCameras::Get()->GetFOV(); |
| 546 | const float _lod_switch_threshold = 20.0f * cam_zoom * cam_zoom * char_scale * char_scale; |
| 547 | if (!online->IsActive()) { |
| 548 | if (distance_squared(avg_pos, cam_pos) > _lod_switch_threshold * 16.0f) { |
| 549 | lod_level = 3; |
| 550 | } else if (distance_squared(avg_pos, cam_pos) > _lod_switch_threshold * 4.0f) { |
| 551 | lod_level = 2; |
| 552 | } else if (distance_squared(avg_pos, cam_pos) > _lod_switch_threshold) { |
| 553 | lod_level = 1; |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | // Use base LOD if lods are not loaded |
| 558 | if (model_id[lod_level] == -1) { |
| 559 | lod_level = 0; |
| 560 | } |
| 561 | |
| 562 | { |
| 563 | PROFILER_ZONE(g_profiler_ctx, "ApplyBoneMatricesToModel"); |
| 564 | ApplyBoneMatricesToModel(false, lod_level); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | // Find the closest points between line segments ab and cd |
| 569 | // Based on the theory described at: http://stackoverflow.com/questions/627563/calculating-the-shortest-distance-between-two-lines-line-segments-in-3d/702174#702174 |
no test coverage detected