Ejemplo n.º 1
0
/*
 * @brief Updates the r_view_t for the renderer. Origin, angles, etc are calculated.
 * Scene population is then delegated (asynchronously) to the client game.
 */
void Cl_UpdateView(void) {

	if (!cl.frame.valid && !r_view.update)
		return; // not a valid frame, and no forced update

	Cl_ClearView();

	const cl_frame_t *frame = &cl.frames[(cl.frame.frame_num - 1) & PACKET_MASK];
	const player_state_t *from = frame->frame_num == cl.frame.frame_num - 1 ? &frame->ps : &cl.frame.ps;

	Cl_UpdateOrigin(from, &cl.frame.ps);

	Cl_UpdateAngles(from, &cl.frame.ps);

	Cl_UpdateViewSize();

	cls.cgame->UpdateView(&cl.frame);

	// set time
	r_view.time = cl.time;

	// set area bits to mark visible leafs
	r_view.area_bits = cl.frame.area_bits;

	// create the thread which populates the view
	r_view.thread = Thread_Create((ThreadRunFunc) cls.cgame->PopulateView, &cl.frame);
}
Ejemplo n.º 2
0
/*
 * @brief Updates the r_view_t for the renderer. Origin, angles, etc are calculated.
 * Scene population is then delegated to the client game.
 */
void Cl_UpdateView(void) {

	if (!cl.frame.valid && !r_view.update)
		return; // not a valid frame, and no forced update

	// find the previous frame to interpolate from
	cl_frame_t *prev = &cl.frames[(cl.frame.frame_num - 1) & PACKET_MASK];

	if (prev->frame_num != cl.frame.frame_num - 1 || !prev->valid)
		prev = &cl.frame; // previous frame was dropped or invalid

	Cl_UpdateLerp(prev);

	const player_state_t *ps = &cl.frame.ps;
	const player_state_t *ops = &prev->ps;

	if (ps != ops) { // see if we've teleported
		vec3_t org, old_org, delta;

		UnpackVector(ps->pm_state.origin, org);
		UnpackVector(ops->pm_state.origin, old_org);

		VectorSubtract(org, old_org, delta);

		if (VectorLength(delta) > 256.0) {
			ops = ps; // don't interpolate
		}
	}

	Cl_ClearView();

	Cl_UpdateOrigin(ps, ops);

	Cl_UpdateAngles(ps, ops);

	Cl_UpdateViewSize();

	cls.cgame->UpdateView(&cl.frame);

	// set time
	r_view.time = cl.time;

	// set area bits to mark visible leafs
	r_view.area_bits = cl.frame.area_bits;

	// create the thread which populates the view
	r_view.thread = Thread_Create((ThreadRunFunc) cls.cgame->PopulateView, &cl.frame);
}