void CL_LinkEdict(prvm_edict_t *ent)
{
+ vec3_t mins, maxs;
+
if (ent == prog->edicts)
return; // don't add the world
if (ent->priv.server->free)
return;
- VectorAdd(ent->fields.client->origin, ent->fields.client->mins, ent->fields.client->absmin);
- VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, ent->fields.client->absmax);
+ // set the abs box
+
+ if (ent->fields.client->solid == SOLID_BSP)
+ {
+ model_t *model = CL_GetModelByIndex( (int)ent->fields.client->modelindex );
+ if (model == NULL)
+ {
+ Con_Printf("edict %i: SOLID_BSP with invalid modelindex!\n", PRVM_NUM_FOR_EDICT(ent));
+
+ model = CL_GetModelByIndex( 0 );
+ }
+
+ if( model != NULL )
+ {
+ if (!model->TraceBox && developer.integer >= 1)
+ Con_Printf("edict %i: SOLID_BSP with non-collidable model\n", PRVM_NUM_FOR_EDICT(ent));
+
+ if (ent->fields.client->angles[0] || ent->fields.client->angles[2] || ent->fields.client->avelocity[0] || ent->fields.client->avelocity[2])
+ {
+ VectorAdd(ent->fields.client->origin, model->rotatedmins, mins);
+ VectorAdd(ent->fields.client->origin, model->rotatedmaxs, maxs);
+ }
+ else if (ent->fields.client->angles[1] || ent->fields.client->avelocity[1])
+ {
+ VectorAdd(ent->fields.client->origin, model->yawmins, mins);
+ VectorAdd(ent->fields.client->origin, model->yawmaxs, maxs);
+ }
+ else
+ {
+ VectorAdd(ent->fields.client->origin, model->normalmins, mins);
+ VectorAdd(ent->fields.client->origin, model->normalmaxs, maxs);
+ }
+ }
+ else
+ {
+ // SOLID_BSP with no model is valid, mainly because some QC setup code does so temporarily
+ VectorAdd(ent->fields.client->origin, ent->fields.client->mins, mins);
+ VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, maxs);
+ }
+ }
+ else
+ {
+ VectorAdd(ent->fields.client->origin, ent->fields.client->mins, mins);
+ VectorAdd(ent->fields.client->origin, ent->fields.client->maxs, maxs);
+ }
+
+ VectorCopy(mins, ent->fields.client->absmin);
+ VectorCopy(maxs, ent->fields.client->absmax);
World_LinkEdict(&cl.world, ent, ent->fields.client->absmin, ent->fields.client->absmax);
}
CL_LinkEdict(e);
}
+static void SetMinMaxSize (prvm_edict_t *e, float *min, float *max)
+{
+ int i;
+
+ for (i=0 ; i<3 ; i++)
+ if (min[i] > max[i])
+ PRVM_ERROR("SetMinMaxSize: backwards mins/maxs");
+
+ // set derived values
+ VectorCopy (min, e->fields.client->mins);
+ VectorCopy (max, e->fields.client->maxs);
+ VectorSubtract (max, min, e->fields.client->size);
+
+ CL_LinkEdict (e);
+}
+
// #3 void(entity e, string m) setmodel
void VM_CL_setmodel (void)
{
prvm_edict_t *e;
const char *m;
- struct model_s *mod;
+ model_t *mod;
int i;
VM_SAFEPARMCOUNT(2, VM_CL_setmodel);
e->fields.client->modelindex = 0;
e->fields.client->model = 0;
VM_Warning ("setmodel: model '%s' not precached\n", m);
+
+ // TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
+ if (mod)
+ {
+ SetMinMaxSize (e, mod->normalmins, mod->normalmaxs);
+ }
+ else
+ SetMinMaxSize (e, vec3_origin, vec3_origin);
}
// #4 void(entity e, vector min, vector max) setsize
min = PRVM_G_VECTOR(OFS_PARM1);
max = PRVM_G_VECTOR(OFS_PARM2);
- VectorCopy (min, e->fields.client->mins);
- VectorCopy (max, e->fields.client->maxs);
- VectorSubtract (max, min, e->fields.client->size);
+ SetMinMaxSize( e, min, max );
CL_LinkEdict(e);
}
{
prvm_edict_t *ed;
ed = PRVM_ED_Alloc();
- // FIXME: WTF.. this should be removed imo.. entnum points to the server.. [12/17/2007 Black]
- ed->fields.client->entnum = PRVM_NUM_FOR_EDICT(ed); //[515]: not needed any more ?
VM_RETURN_EDICT(ed);
}
}
t->fields.client->model = PRVM_SetEngineString(model->name);
t->fields.client->modelindex = i;
+
+ // TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
+ if (model)
+ {
+ SetMinMaxSize (t, model->normalmins, model->normalmaxs);
+ }
+ else
+ SetMinMaxSize (t, vec3_origin, vec3_origin);
}
//#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
SV_LinkEdict (e, false);
}
-
-void SetMinMaxSize (prvm_edict_t *e, float *min, float *max, qboolean rotate)
+// TODO: rotate param isnt used.. could be a bug. please check this and remove it if possible [1/10/2008 Black]
+static void SetMinMaxSize (prvm_edict_t *e, float *min, float *max, qboolean rotate)
{
int i;