void LE_Physics_Toss (localent_t *ent) { trace_t tr; vec3_t vel; //copy old origin FastVectorCopy (ent->ent.origin, ent->ent.oldorigin); //FIXME: properly scale this to client FPS. ent->velocity[2] -= 1; //scale velocity based on something stupid FastVectorCopy (ent->velocity, vel); VectorScale (vel, cl.lerpfrac, vel); //add velocity to origin VectorAdd (ent->ent.origin, vel, ent->ent.origin); //check we didn't hit the world tr = CM_BoxTrace (ent->ent.oldorigin, ent->ent.origin, ent->mins, ent->maxs, 0, MASK_SOLID); if (tr.fraction != 1.0f) { //vec3_t down; //if we did, back off. FastVectorCopy (tr.endpos, ent->ent.origin); if (ent->touch) ent->touch (ent, &tr.plane, tr.surface); //check for stop ClipVelocity (ent->velocity, tr.plane.normal, ent->velocity, ent->movetype == MOVETYPE_BOUNCE ? 1.7f : 1.0f); if ((tr.plane.normal[2] > 0.7f && ent->movetype == MOVETYPE_TOSS) || ((ent->velocity[2] < 0.01f && ent->velocity[2] > -0.01f) && ent->movetype == MOVETYPE_BOUNCE)) ent->movetype = MOVETYPE_NONE; } //note!! this only clips to entities that we currently know about (as the client). //this means if a localent is outside the PVS of a client, it will only clip to //the world. //fixme: do we want this? /*CL_ClipMoveToEntities (ent->ent.oldorigin, ent->mins, ent->maxs, ent->ent.origin, &tr); if (tr.ent) { if (ent->touch) ent->touch (ent, &tr.plane, tr.surface); VectorCopy (tr.endpos, ent->ent.origin); //check for stop ClipVelocity (ent->velocity, tr.plane.normal, ent->velocity, ent->movetype == MOVETYPE_BOUNCE ? 1.7 : 1); if (tr.plane.normal[2] > 0.7f && ent->movetype == MOVETYPE_TOSS || ((ent->velocity[2] < 0.01f && ent->velocity[2] > -0.01f) && ent->movetype == MOVETYPE_BOUNCE)) ent->movetype = MOVETYPE_NONE; }*/ }
/* ================= Mod_LoadBrushModel ================= */ void Mod_LoadBrushModel (model_t *mod, void *buffer) { int i; dheader_t *header; mmodel_t *bm; loadmodel->type = mod_brush; if (loadmodel != mod_known) VID_Error (ERR_DROP, "Loaded a brush model after the world"); header = (dheader_t *)buffer; i = LittleLong(header->version); if (i != BSPVERSION) VID_Error (ERR_DROP, "Mod_LoadBrushModel: %s has wrong version number (%i should be %i)", mod->name, i, BSPVERSION); // swap all the lumps mod_base = (byte *)header; //r1: check header pointers point within allocated data for (i = 0; i < MAX_LUMPS; i++) { //for some reason there are unused lumps with invalid values if (i == LUMP_POP) continue; if (header->lumps[i].fileofs < 0 || header->lumps[i].filelen < 0 || header->lumps[i].fileofs + header->lumps[i].filelen > modfilelen) VID_Error (ERR_DROP, "Mod_LoadBrushModel: offset %d of size %d is out of bounds (%s is possibly truncated)", header->lumps[i].fileofs, header->lumps[i].filelen, mod->name); } // load into heap Mod_LoadVertexes (&header->lumps[LUMP_VERTEXES]); Mod_LoadEdges (&header->lumps[LUMP_EDGES]); Mod_LoadSurfedges (&header->lumps[LUMP_SURFEDGES]); Mod_LoadLighting (&header->lumps[LUMP_LIGHTING]); Mod_LoadPlanes (&header->lumps[LUMP_PLANES]); Mod_LoadTexinfo (&header->lumps[LUMP_TEXINFO]); Mod_LoadFaces (&header->lumps[LUMP_FACES]); Mod_LoadMarksurfaces (&header->lumps[LUMP_LEAFFACES]); Mod_LoadVisibility (&header->lumps[LUMP_VISIBILITY]); Mod_LoadLeafs (&header->lumps[LUMP_LEAFS]); Mod_LoadNodes (&header->lumps[LUMP_NODES]); Mod_LoadSubmodels (&header->lumps[LUMP_MODELS]); mod->numframes = 2; // regular and alternate animation // // set up the submodels // for (i=0 ; i<mod->numsubmodels ; i++) { model_t *starmod; bm = &mod->submodels[i]; starmod = &mod_inline[i]; *starmod = *loadmodel; starmod->firstmodelsurface = bm->firstface; starmod->nummodelsurfaces = bm->numfaces; starmod->firstnode = bm->headnode; if (starmod->firstnode >= loadmodel->numnodes) VID_Error (ERR_DROP, "Inline model %i has bad firstnode", i); FastVectorCopy (bm->maxs, starmod->maxs); FastVectorCopy (bm->mins, starmod->mins); starmod->radius = bm->radius; if (i == 0) *loadmodel = *starmod; starmod->numleafs = bm->visleafs; } }