std::optional<transformr> interpolation_system::find_interpolated(const const_entity_handle handle) const {
	const auto id = handle.get_id();

	auto result = [&]() -> std::optional<transformr> {
		if (enabled) {
			if (const auto cache = mapped_or_nullptr(per_entity_cache, id)) {
				return cache->interpolated_transform;
			}
		}

		return handle.find_logic_transform();
	}();

	/*
		Here, we integerize the transform of the viewed entity, (and later possibly of the vehicle that it drives)
		so that the rendered player does not shake when exactly followed by the camera,
		which is also integerized for pixel-perfect rendering.

		Ideally we shouldn't do it here because it introduces more state, but that's about the simplest solution
		that doesn't make a mess out of rendering scripts for this special case.	

		Additionally, if someone does not use interpolation (there should be no need to disable it, really)
		they will still suffer from the problem of shaky controlled player. We don't have time for now to handle it better.
	*/

	if (id == id_to_integerize) {
		if (result) {
			result->pos.discard_fract();
		}
	}

	return result;
}
void standard_confirm_go_to(const const_entity_handle match, const bool has_ctrl, editor_view& view, editor_view_ids& view_ids) {
	/* Confirm selection with quick search */

	if (match) {
		if (has_ctrl) {
			view_ids.selected_entities.emplace(match);
		}
		else {
			view_ids.selected_entities = { match };
		}

		if (!view.panned_camera.has_value()) {
			view.panned_camera = camera_eye();
		}

		if (const auto transform = match.find_logic_transform()) {
			view.panned_camera->transform.pos = transform->pos;
		}
		else {
			LOG("WARNING: transform of %x could not be found.", match);
		}
	}
}