예제 #1
0
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);
		}
	}
}
예제 #2
0
simulation_receiver::misprediction_candidate_entry simulation_receiver::acquire_potential_misprediction(const const_entity_handle& e) const {
	misprediction_candidate_entry candidate;
	
	if(e.has_logic_transform())
		candidate.transform = e.logic_transform();

	candidate.id = e.get_id();

	return candidate;
}
예제 #3
0
components::transform interpolation_system::get_interpolated(const const_entity_handle id) const {
	return enabled ? per_entity_cache[make_cache_id(id)].interpolated_transform : id.logic_transform();
}