コード例 #1
0
ファイル: r_bsp_model.c プロジェクト: darkshade9/aq2w
/*
 * R_LoadBspPlanes
 */
static void R_LoadBspPlanes(const d_bsp_lump_t *l) {
	int i, j;
	c_bsp_plane_t *out;
	const d_bsp_plane_t *in;
	int count;

	in = (const void *) (mod_base + l->file_ofs);
	if (l->file_len % sizeof(*in)) {
		Com_Error(ERR_DROP, "R_LoadBspPlanes: Funny lump size in %s.",
				r_load_model->name);
	}

	count = l->file_len / sizeof(*in);
	out = R_HunkAlloc(count * 2 * sizeof(*out));

	r_load_model->planes = out;
	r_load_model->num_planes = count;

	for (i = 0; i < count; i++, in++, out++) {

		for (j = 0; j < 3; j++) {
			out->normal[j] = LittleFloat(in->normal[j]);
		}

		out->dist = LittleFloat(in->dist);
		out->type = LittleLong(in->type);
		out->sign_bits = SignBitsForPlane(out);
	}
}
コード例 #2
0
ファイル: r_main.c プロジェクト: devilx4/quake2world
/*
 * @brief Updates the clipping planes for the view frustum based on the origin
 * and angles for this frame.
 */
void R_UpdateFrustum(void) {
	int32_t i;

	if (!r_cull->value)
		return;

	// rotate r_view.forward right by fov_x / 2 degrees
	RotatePointAroundVector(r_locals.frustum[0].normal, r_view.up, r_view.forward,
			-(90 - r_view.fov[0] / 2));
	// rotate r_view.forward left by fov_x / 2 degrees
	RotatePointAroundVector(r_locals.frustum[1].normal, r_view.up, r_view.forward,
			90 - r_view.fov[0] / 2);
	// rotate r_view.forward up by fov_x / 2 degrees
	RotatePointAroundVector(r_locals.frustum[2].normal, r_view.right, r_view.forward,
			90 - r_view.fov[1] / 2);
	// rotate r_view.forward down by fov_x / 2 degrees
	RotatePointAroundVector(r_locals.frustum[3].normal, r_view.right, r_view.forward,
			-(90 - r_view.fov[1] / 2));

	for (i = 0; i < 4; i++) {
		r_locals.frustum[i].type = PLANE_ANYZ;
		r_locals.frustum[i].dist = DotProduct(r_view.origin, r_locals.frustum[i].normal);
		r_locals.frustum[i].sign_bits = SignBitsForPlane(&r_locals.frustum[i]);
	}
}
コード例 #3
0
ファイル: r_bsp_model.c プロジェクト: devilx4/quake2world
/*
 * @brief
 */
static void R_LoadBspPlanes(r_bsp_model_t *bsp, const d_bsp_lump_t *l) {
	int32_t i, j;
	c_bsp_plane_t *out;
	const d_bsp_plane_t *in;
	int32_t count;

	in = (const void *) (mod_base + l->file_ofs);
	if (l->file_len % sizeof(*in)) {
		Com_Error(ERR_DROP, "Funny lump size\n");
	}

	count = l->file_len / sizeof(*in);
	out = Z_LinkMalloc(count * 2 * sizeof(*out), bsp);

	bsp->planes = out;
	bsp->num_planes = count;

	for (i = 0; i < count; i++, in++, out++) {

		for (j = 0; j < 3; j++) {
			out->normal[j] = LittleFloat(in->normal[j]);
		}

		out->dist = LittleFloat(in->dist);
		out->type = LittleLong(in->type);
		out->sign_bits = SignBitsForPlane(out);
	}
}