INNER CODE UNIT · C++

state_pos

trillek-team/tec · client/client-game-state-queue.cpp:146

	glm::vec3 state_pos = this->stats.server_position_next;
	this->stats.server_position = this->stats.server_position_next;
	this->stats.server_position_next = new_state.positions[this->client_id].value;

	glm::vec3 position_diff = glm::vec3();
	glm::vec3 velocity_diff = glm::vec3();

	// delete from the prediction queue anything that's not newer than the latest ack
	for (auto itr = this->predictions.begin(); itr != this->predictions.end();) {
		if (itr->first <= new_state.command_id) {
			// if this was an acked command, calculate the difference between where we thought we were
			// this gives feedback on how good our prediction was
			if (itr->first == new_state.command_id) {
				glm::vec3 predict_pos = itr->second.positions[this->client_id].value;
				position_diff = state_pos - predict_pos;
				glm::vec3 state_vel = new_state.velocities[this->client_id].linear;
				glm::vec3 predict_vel = itr->second.velocities[this->client_id].linear;
				velocity_diff = state_vel - predict_vel;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…