+entity_t cl_meshentities[NUM_MESHENTITIES];
+dp_model_t cl_meshentitymodels[NUM_MESHENTITIES];
+const char *cl_meshentitynames[NUM_MESHENTITIES] =
+{
+ "MESH_DEBUG",
+ "MESH_CSQC_POLYGONS",
+ "MESH_PARTICLES",
+ "MESH_UI",
+};
+
+void CL_MeshEntities_Restart(void)
+{
+ int i;
+ entity_t *ent;
+ for (i = 0; i < NUM_MESHENTITIES; i++)
+ {
+ ent = cl_meshentities + i;
+ Mod_Mesh_Create(ent->render.model, cl_meshentitynames[i]);
+ }
+}
+
+void CL_MeshEntities_Init(void)
+{
+ int i;
+ entity_t *ent;
+ for (i = 0; i < NUM_MESHENTITIES; i++)
+ {
+ ent = cl_meshentities + i;
+ ent->state_current.active = true;
+ ent->render.model = cl_meshentitymodels + i;
+ ent->render.alpha = 1;
+ ent->render.flags = RENDER_SHADOW | RENDER_LIGHT;
+ ent->render.framegroupblend[0].lerp = 1;
+ ent->render.frameblend[0].lerp = 1;
+ VectorSet(ent->render.colormod, 1, 1, 1);
+ VectorSet(ent->render.glowmod, 1, 1, 1);
+ VectorSet(ent->render.modellight_ambient, 1, 1, 1);
+ VectorSet(ent->render.modellight_diffuse, 0, 0, 0);
+ VectorSet(ent->render.modellight_lightdir, 0, 0, 1);
+ Matrix4x4_CreateIdentity(&ent->render.matrix);
+ CL_UpdateRenderEntity(&ent->render);
+ }
+ R_RegisterModule("cl_meshentities", CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart, CL_MeshEntities_Restart);
+}
+
+void CL_MeshEntities_AddToScene(void)
+{
+ int i;
+ entity_t *ent;
+ for (i = 0; i < NUM_MESHENTITIES && r_refdef.scene.numentities < r_refdef.scene.maxentities; i++)
+ {
+ ent = cl_meshentities + i;
+ if (ent->render.model->num_surfaces == 0)
+ continue;
+ Mod_Mesh_Finalize(ent->render.model);
+ VectorCopy(ent->render.model->normalmins, ent->render.mins);
+ VectorCopy(ent->render.model->normalmaxs, ent->render.maxs);
+ r_refdef.scene.entities[r_refdef.scene.numentities++] = &ent->render;
+ }
+}
+
+void CL_MeshEntities_Reset(void)
+{
+ int i;
+ entity_t *ent;
+ for (i = 0; i < NUM_MESHENTITIES && r_refdef.scene.numentities < r_refdef.scene.maxentities; i++)
+ {
+ ent = cl_meshentities + i;
+ Mod_Mesh_Reset(ent->render.model);
+ }
+}
+
+void CL_MeshEntities_Shutdown(void)
+{
+}
+