示例#1
0
/*
 * @brief
 */
static void Cm_LoadBspPlanes(const d_bsp_lump_t *l) {

	const d_bsp_plane_t *in = (const void *) (cm_bsp.base + l->file_ofs);

	if (l->file_len % sizeof(*in)) {
		Com_Error(ERR_DROP, "Funny lump size\n");
	}

	const int32_t count = l->file_len / sizeof(*in);

	if (count < 1) {
		Com_Error(ERR_DROP, "Invalid plane count: %d\n", count);
	}
	if (count > MAX_BSP_PLANES) {
		Com_Error(ERR_DROP, "%d > MAX_BSP_PLANES\n", count);
	}

	cm_bsp_plane_t *out = cm_bsp.planes;
	cm_bsp.num_planes = count;

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

		for (int32_t 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 = Cm_SignBitsForPlane(out);
		out->num = (i >> 1) + 1;
	}
}
示例#2
0
/*
 * @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;

	cm_bsp_plane_t *p = r_locals.frustum;

	const vec_t fov_x = r_view.fov[0];
	const vec_t fov_y = r_view.fov[1];

	// rotate r_view.forward right by fov_x degrees
	RotatePointAroundVector(r_view.forward, r_view.right, -(90.0 - fov_x), (p++)->normal);
	// rotate r_view.forward left by fov_x degrees
	RotatePointAroundVector(r_view.forward, r_view.right, 90.0 - fov_x, (p++)->normal);
	// rotate r_view.forward up by fov_y degrees
	RotatePointAroundVector(r_view.forward, r_view.up, 90.0 - fov_y, (p++)->normal);
	// rotate r_view.forward down by fov_y degrees
	RotatePointAroundVector(r_view.forward, r_view.up, -(90.0 - fov_y), p->normal);

	for (i = 0; i < 4; i++) {
		r_locals.frustum[i].type = PLANE_ANY_Z;
		r_locals.frustum[i].dist = DotProduct(r_view.origin, r_locals.frustum[i].normal);
		r_locals.frustum[i].sign_bits = Cm_SignBitsForPlane(&r_locals.frustum[i]);
	}
}
示例#3
0
文件: cm_model.c 项目: jdolan/quetoo
/**
 * @brief
 */
static void Cm_LoadBspPlanes(void) {

    const int32_t num_planes = cm_bsp.bsp.num_planes;
    const bsp_plane_t *in = cm_bsp.bsp.planes;

    cm_bsp_plane_t *out = cm_bsp.planes = Mem_TagMalloc(sizeof(cm_bsp_plane_t) * (num_planes + 12), MEM_TAG_CMODEL); // extra for box hull

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

        // copied from bsp_
        VectorCopy(in->normal, out->normal);
        out->dist = in->dist;
        out->type = in->type;

        // local to cm_
        out->sign_bits = Cm_SignBitsForPlane(out);
        out->num = (i >> 1) + 1;
    }
}