void simulation_receiver::drag_mispredictions_into_past(interpolation_system& interp, past_infection_system& past, const cosmos& predicted_cosmos, const std::vector<misprediction_candidate_entry>& mispredictions) const { for (const auto e : mispredictions) { const const_entity_handle reconciliated_entity = predicted_cosmos[e.id]; const bool identity_matches = reconciliated_entity.alive() && reconciliated_entity.has_logic_transform(); if (!identity_matches) continue; const auto& reconciliated_transform = reconciliated_entity.logic_transform(); const bool is_contagious_agent = reconciliated_entity.get_flag(entity_flag::IS_PAST_CONTAGIOUS); const bool should_smooth_rotation = !is_contagious_agent || predicted_cosmos[reconciliated_entity.get<components::driver>().owned_vehicle].alive(); auto& interp_data = interp.get_data(reconciliated_entity); const bool shouldnt_smooth = reconciliated_entity.has<components::crosshair>(); bool misprediction_detected = false; const float num_predicted_steps = static_cast<float>(predicted_steps.size()); if (!shouldnt_smooth && (reconciliated_transform.pos - e.transform.pos).length_sq() > 1.f) { interp_data.positional_slowdown_multiplier = std::max(1.f, misprediction_smoothing_multiplier * num_predicted_steps); misprediction_detected = true; } if (should_smooth_rotation && std::abs(reconciliated_transform.rotation - e.transform.rotation) > 1.f) { interp_data.rotational_slowdown_multiplier = std::max(1.f, misprediction_smoothing_multiplier * num_predicted_steps); misprediction_detected = true; } if (identity_matches || (!misprediction_detected && !is_contagious_agent)) { past.uninfect(reconciliated_entity); } } }
void viewing_session::spread_past_infection(const const_logic_step step) { const auto& cosm = step.cosm; const auto& events = step.transient.messages.get_queue<messages::collision_message>(); for (const auto& it : events) { const const_entity_handle subject_owner_body = cosm[it.subject].get_owner_body(); const const_entity_handle collider_owner_body = cosm[it.collider].get_owner_body(); auto& past_system = systems_audiovisual.get<past_infection_system>(); if (past_system.is_infected(subject_owner_body) && !collider_owner_body.get_flag(entity_flag::IS_IMMUNE_TO_PAST)) { past_system.infect(collider_owner_body); } } }