Beispiel #1
0
/*
 * R_LoadBspModel
 */
void R_LoadBspModel(r_model_t *mod, void *buffer) {
	extern void Cl_LoadProgress(int percent);
	d_bsp_header_t header;
	unsigned int i;

	if (r_world_model)
		Com_Error(ERR_DROP, "R_LoadBspModel: Loaded bsp model after world.");

	header = *(d_bsp_header_t *) buffer;
	for (i = 0; i < sizeof(d_bsp_header_t) / 4; i++)
		((int *) &header)[i] = LittleLong(((int *) &header)[i]);

	if (header.version != BSP_VERSION && header.version != BSP_VERSION_) {
		Com_Error(ERR_DROP, "R_LoadBspModel: %s has unsupported version: %d",
				mod->name, header.version);
	}

	mod->type = mod_bsp;
	mod->version = header.version;

	// set the base pointer for lump loading
	mod_base = (byte *) buffer;

	// load into heap
	R_LoadBspVertexes(&header.lumps[LUMP_VERTEXES]);
	Cl_LoadProgress(4);

	if (header.version == BSP_VERSION_) // enhanced format
		R_LoadBspNormals(&header.lumps[LUMP_NORMALS]);

	R_LoadBspEdges(&header.lumps[LUMP_EDGES]);
	Cl_LoadProgress(8);

	R_LoadBspSurfaceEdges(&header.lumps[LUMP_FACE_EDGES]);
	Cl_LoadProgress(12);

	R_LoadBspLightmaps(&header.lumps[LUMP_LIGHMAPS]);
	Cl_LoadProgress(16);

	R_LoadBspPlanes(&header.lumps[LUMP_PLANES]);
	Cl_LoadProgress(20);

	R_LoadBspTexinfo(&header.lumps[LUMP_TEXINFO]);
	Cl_LoadProgress(24);

	R_LoadBspSurfaces(&header.lumps[LUMP_FACES]);
	Cl_LoadProgress(28);

	R_LoadBspLeafSurfaces(&header.lumps[LUMP_LEAF_FACES]);
	Cl_LoadProgress(32);

	R_LoadBspVisibility(&header.lumps[LUMP_VISIBILITY]);
	Cl_LoadProgress(36);

	R_LoadBspLeafs(&header.lumps[LUMP_LEAFS]);
	Cl_LoadProgress(40);

	R_LoadBspNodes(&header.lumps[LUMP_NODES]);
	Cl_LoadProgress(44);

	R_LoadBspSubmodels(&header.lumps[LUMP_MODELS]);
	Cl_LoadProgress(48);

	R_SetupBspSubmodels();

	Com_Debug("================================\n");
	Com_Debug("R_LoadBspModel: %s\n", r_load_model->name);
	Com_Debug("  Verts:          %d\n", r_load_model->num_vertexes);
	Com_Debug("  Edges:          %d\n", r_load_model->num_edges);
	Com_Debug("  Surface edges:  %d\n", r_load_model->num_surface_edges);
	Com_Debug("  Faces:          %d\n", r_load_model->num_surfaces);
	Com_Debug("  Nodes:          %d\n", r_load_model->num_nodes);
	Com_Debug("  Leafs:          %d\n", r_load_model->num_leafs);
	Com_Debug("  Leaf surfaces:  %d\n", r_load_model->num_leaf_surfaces);
	Com_Debug("  Models:         %d\n", r_load_model->num_submodels);
	Com_Debug("  Lightmaps:      %d\n", r_load_model->lightmap_data_size);
	Com_Debug("  Vis:            %d\n", r_load_model->vis_size);

	if (r_load_model->vis)
		Com_Debug("  Clusters:   %d\n", r_load_model->vis->num_clusters);

	Com_Debug("================================\n");

	R_LoadBspVertexArrays();

	R_LoadBspSurfacesArrays();

	R_LoadBspLights();

	r_locals.old_cluster = -1; // force bsp iteration
}
Beispiel #2
0
/*
 * @brief
 */
void R_LoadBspModel(r_model_t *mod, void *buffer) {
	extern void Cl_LoadProgress(int32_t percent);
	d_bsp_header_t header;
	uint32_t i;

	header = *(d_bsp_header_t *) buffer;
	for (i = 0; i < sizeof(d_bsp_header_t) / sizeof(int32_t); i++)
		((int32_t *) &header)[i] = LittleLong(((int32_t *) &header)[i]);

	if (header.version != BSP_VERSION && header.version != BSP_VERSION_Q2W) {
		Com_Error(ERR_DROP, "%s has unsupported version: %d\n", mod->media.name, header.version);
	}

	mod->bsp = Z_LinkMalloc(sizeof(r_bsp_model_t), mod);
	mod->bsp->version = header.version;

	// set the base pointer for lump loading
	mod_base = (byte *) buffer;

	// load into heap
	R_LoadBspVertexes(mod->bsp, &header.lumps[BSP_LUMP_VERTEXES]);
	Cl_LoadProgress(4);

	if (header.version == BSP_VERSION_Q2W) // enhanced format
		R_LoadBspNormals(mod->bsp, &header.lumps[BSP_LUMP_NORMALS]);

	R_LoadBspEdges(mod->bsp, &header.lumps[BSP_LUMP_EDGES]);
	Cl_LoadProgress(8);

	R_LoadBspSurfaceEdges(mod->bsp, &header.lumps[BSP_LUMP_FACE_EDGES]);
	Cl_LoadProgress(12);

	R_LoadBspLightmaps(mod->bsp, &header.lumps[BSP_LUMP_LIGHMAPS]);
	Cl_LoadProgress(16);

	R_LoadBspPlanes(mod->bsp, &header.lumps[BSP_LUMP_PLANES]);
	Cl_LoadProgress(20);

	R_LoadBspTexinfo(mod->bsp, &header.lumps[BSP_LUMP_TEXINFO]);
	Cl_LoadProgress(24);

	R_LoadBspSurfaces(mod->bsp, &header.lumps[BSP_LUMP_FACES]);
	Cl_LoadProgress(28);

	R_LoadBspLeafSurfaces(mod->bsp, &header.lumps[BSP_LUMP_LEAF_FACES]);
	Cl_LoadProgress(32);

	R_LoadBspLeafs(mod->bsp, &header.lumps[BSP_LUMP_LEAFS]);
	Cl_LoadProgress(36);

	R_LoadBspNodes(mod->bsp, &header.lumps[BSP_LUMP_NODES]);
	Cl_LoadProgress(40);

	R_LoadBspClusters(mod->bsp, &header.lumps[BSP_LUMP_VISIBILITY]);
	Cl_LoadProgress(44);

	R_LoadBspInlineModels(mod->bsp, &header.lumps[BSP_LUMP_MODELS]);
	Cl_LoadProgress(48);

	R_LoadBspLights(mod->bsp);
	Cl_LoadProgress(50);

	Com_Debug("!================================\n");
	Com_Debug("!R_LoadBspModel: %s\n", mod->media.name);
	Com_Debug("!  Verts:          %d\n", mod->bsp->num_vertexes);
	Com_Debug("!  Edges:          %d\n", mod->bsp->num_edges);
	Com_Debug("!  Surface edges:  %d\n", mod->bsp->num_surface_edges);
	Com_Debug("!  Faces:          %d\n", mod->bsp->num_surfaces);
	Com_Debug("!  Nodes:          %d\n", mod->bsp->num_nodes);
	Com_Debug("!  Leafs:          %d\n", mod->bsp->num_leafs);
	Com_Debug("!  Leaf surfaces:  %d\n", mod->bsp->num_leaf_surfaces);
	Com_Debug("!  Clusters:       %d\n", mod->bsp->num_clusters);
	Com_Debug("!  Inline models   %d\n", mod->bsp->num_inline_models);
	Com_Debug("!  Lights:         %d\n", mod->bsp->num_bsp_lights);
	Com_Debug("!================================\n");

	R_SetupBspInlineModels(mod);
	Cl_LoadProgress(52);

	R_LoadBspVertexArrays(mod);
	Cl_LoadProgress(54);

	R_LoadBspSurfacesArrays(mod);
	Cl_LoadProgress(58);

	r_locals.old_cluster = -1; // force bsp iteration
}