static void CSQC_R_RecalcView (void)
{
extern matrix4x4_t viewmodelmatrix;
- Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], 1);
+ Matrix4x4_CreateFromQuakeEntity(&r_refdef.view.matrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], 1);
Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], cl_viewmodel_scale.value);
}
r_refdef.numentities = 0;
r_refdef.numlights = 0;
// FIXME: restore these to the values from VM_CL_UpdateView
- r_view.x = 0;
- r_view.y = 0;
- r_view.z = 0;
- r_view.width = vid.width;
- r_view.height = vid.height;
- r_view.depth = 1;
+ r_refdef.view.x = 0;
+ r_refdef.view.y = 0;
+ r_refdef.view.z = 0;
+ r_refdef.view.width = vid.width;
+ r_refdef.view.height = vid.height;
+ r_refdef.view.depth = 1;
// FIXME: restore frustum_x/frustum_y
- r_view.useperspective = true;
- r_view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
- r_view.frustum_x = r_view.frustum_y * (float)r_view.width / (float)r_view.height / vid_pixelheight.value;
- r_view.frustum_x *= r_refdef.frustumscale_x;
- r_view.frustum_y *= r_refdef.frustumscale_y;
- r_view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)r_view.width / (float)r_view.height / vid_pixelheight.value;
- r_view.ortho_y = scr_fov.value * (3.0 / 4.0);
+ r_refdef.view.useperspective = true;
+ r_refdef.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0) * cl.viewzoom;
+ r_refdef.view.frustum_x = r_refdef.view.frustum_y * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
+ r_refdef.view.frustum_x *= r_refdef.frustumscale_x;
+ r_refdef.view.frustum_y *= r_refdef.frustumscale_y;
+ r_refdef.view.ortho_x = scr_fov.value * (3.0 / 4.0) * (float)r_refdef.view.width / (float)r_refdef.view.height / vid_pixelheight.value;
+ r_refdef.view.ortho_y = scr_fov.value * (3.0 / 4.0);
// FIXME: restore cl.csqc_origin
// FIXME: restore cl.csqc_angles
cl.csqc_vidvars.drawworld = true;
switch(c)
{
case VF_MIN:
- r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
+ r_refdef.view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_refdef.view.y = (int)(f[1] * vid.height / vid_conheight.value);
break;
case VF_MIN_X:
- r_view.x = (int)(k * vid.width / vid_conwidth.value);
+ r_refdef.view.x = (int)(k * vid.width / vid_conwidth.value);
break;
case VF_MIN_Y:
- r_view.y = (int)(k * vid.height / vid_conheight.value);
+ r_refdef.view.y = (int)(k * vid.height / vid_conheight.value);
break;
case VF_SIZE:
- r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
+ r_refdef.view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_refdef.view.height = (int)(f[1] * vid.height / vid_conheight.value);
break;
case VF_SIZE_Y:
- r_view.width = (int)(k * vid.width / vid_conwidth.value);
+ r_refdef.view.width = (int)(k * vid.width / vid_conwidth.value);
break;
case VF_SIZE_X:
- r_view.height = (int)(k * vid.height / vid_conheight.value);
+ r_refdef.view.height = (int)(k * vid.height / vid_conheight.value);
break;
case VF_VIEWPORT:
- r_view.x = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.y = (int)(f[1] * vid.height / vid_conheight.value);
+ r_refdef.view.x = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_refdef.view.y = (int)(f[1] * vid.height / vid_conheight.value);
f = PRVM_G_VECTOR(OFS_PARM2);
- r_view.width = (int)(f[0] * vid.width / vid_conwidth.value);
- r_view.height = (int)(f[1] * vid.height / vid_conheight.value);
+ r_refdef.view.width = (int)(f[0] * vid.width / vid_conwidth.value);
+ r_refdef.view.height = (int)(f[1] * vid.height / vid_conheight.value);
break;
case VF_FOV:
- r_view.frustum_x = tan(f[0] * M_PI / 360.0);r_view.ortho_x = f[0];
- r_view.frustum_y = tan(f[1] * M_PI / 360.0);r_view.ortho_y = f[1];
+ r_refdef.view.frustum_x = tan(f[0] * M_PI / 360.0);r_refdef.view.ortho_x = f[0];
+ r_refdef.view.frustum_y = tan(f[1] * M_PI / 360.0);r_refdef.view.ortho_y = f[1];
break;
case VF_FOVX:
- r_view.frustum_x = tan(k * M_PI / 360.0);r_view.ortho_x = k;
+ r_refdef.view.frustum_x = tan(k * M_PI / 360.0);r_refdef.view.ortho_x = k;
break;
case VF_FOVY:
- r_view.frustum_y = tan(k * M_PI / 360.0);r_view.ortho_y = k;
+ r_refdef.view.frustum_y = tan(k * M_PI / 360.0);r_refdef.view.ortho_y = k;
break;
case VF_ORIGIN:
VectorCopy(f, cl.csqc_origin);
cl.viewangles[2] = k;
break;
case VF_PERSPECTIVE:
- r_view.useperspective = k != 0;
+ r_refdef.view.useperspective = k != 0;
break;
default:
PRVM_G_FLOAT(OFS_RETURN) = 0;
VM_SAFEPARMCOUNT(1, VM_CL_unproject);
f = PRVM_G_VECTOR(OFS_PARM0);
- VectorSet(temp, f[2], f[0] * f[2] * -r_view.frustum_x * 2.0 / r_view.width, f[1] * f[2] * -r_view.frustum_y * 2.0 / r_view.height);
- Matrix4x4_Transform(&r_view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
+ VectorSet(temp, f[2], f[0] * f[2] * -r_refdef.view.frustum_x * 2.0 / r_refdef.view.width, f[1] * f[2] * -r_refdef.view.frustum_y * 2.0 / r_refdef.view.height);
+ Matrix4x4_Transform(&r_refdef.view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
}
//#311 vector (vector v) cs_project (EXT_CSQC)
VM_SAFEPARMCOUNT(1, VM_CL_project);
f = PRVM_G_VECTOR(OFS_PARM0);
- Matrix4x4_Invert_Simple(&m, &r_view.matrix);
+ Matrix4x4_Invert_Simple(&m, &r_refdef.view.matrix);
Matrix4x4_Transform(&m, f, v);
- VectorSet(PRVM_G_VECTOR(OFS_RETURN), v[1]/v[0]/-r_view.frustum_x*0.5*r_view.width, v[2]/v[0]/-r_view.frustum_y*r_view.height*0.5, v[0]);
+ VectorSet(PRVM_G_VECTOR(OFS_RETURN), v[1]/v[0]/-r_refdef.view.frustum_x*0.5*r_refdef.view.width, v[2]/v[0]/-r_refdef.view.frustum_y*r_refdef.view.height*0.5, v[0]);
}
//#330 float(float stnum) getstatf (EXT_CSQC)
PRVM_G_FLOAT(OFS_RETURN) = MSG_ReadFloat();
}
-static void VM_CL_ReadEntity (void)
-{
- int ednum;
- VM_SAFEPARMCOUNT(0, VM_CL_ReadEntity);
- ednum = MSG_ReadShort();
- VM_RETURN_EDICT(PRVM_PROG_TO_EDICT(ednum));
-}
-
//////////////////////////////////////////////////////////
static void VM_CL_makestatic (void)
matrix4x4_t entitymatrix, tagmatrix, attachmatrix;
prvm_edict_t *attachent;
model_t *model;
+ float scale;
*out = identitymatrix; // warnings and errors return identical matrix
attachmatrix = identitymatrix;
// apply transformation by child entity matrix
+ scale = 1;
val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale);
- if (val->_float == 0)
- val->_float = 1;
- Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
+ if (val && val->_float != 0)
+ scale = val->_float;
+ Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], scale);
Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
Matrix4x4_Copy(&tagmatrix, out);
}
// normal or RENDER_VIEWMODEL entity (or main parent entity on attach chain)
+ scale = 1;
val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale);
- if (val->_float == 0)
- val->_float = 1;
+ if (val && val->_float != 0)
+ scale = val->_float;
// Alias models have inverse pitch, bmodels can't have tags, so don't check for modeltype...
- Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], val->_float);
+ Matrix4x4_CreateFromQuakeEntity(&entitymatrix, ent->fields.client->origin[0], ent->fields.client->origin[1], ent->fields.client->origin[2], -ent->fields.client->angles[0], ent->fields.client->angles[1], ent->fields.client->angles[2], scale);
Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
if ((val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.renderflags)) && (RF_VIEWMODEL & (int)val->_float))
{// RENDER_VIEWMODEL magic
Matrix4x4_Copy(&tagmatrix, out);
+ scale = 1;
val = PRVM_EDICTFIELDVALUE(ent, prog->fieldoffsets.scale);
- if (val->_float == 0)
- val->_float = 1;
+ if (val && val->_float != 0)
+ scale = val->_float;
- Matrix4x4_CreateFromQuakeEntity(&entitymatrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], val->_float);
+ Matrix4x4_CreateFromQuakeEntity(&entitymatrix, cl.csqc_origin[0], cl.csqc_origin[1], cl.csqc_origin[2], cl.csqc_angles[0], cl.csqc_angles[1], cl.csqc_angles[2], scale);
Matrix4x4_Concat(out, &entitymatrix, &tagmatrix);
/*
}
modelindex = (int)ent->fields.client->modelindex;
- if(modelindex < 0)
- modelindex = -(modelindex+1);
tag_index = 0;
- if (modelindex <= 0 || modelindex >= MAX_MODELS)
+ if (modelindex >= MAX_MODELS || (modelindex <= -MAX_MODELS /* client models */))
Con_DPrintf("gettagindex(entity #%i): null or non-precached model\n", PRVM_NUM_FOR_EDICT(ent));
else
{
VM_CL_ReadAngle, // #365 float() readangle (EXT_CSQC)
VM_CL_ReadString, // #366 string() readstring (EXT_CSQC)
VM_CL_ReadFloat, // #367 float() readfloat (EXT_CSQC)
-VM_CL_ReadEntity, // #368 entity() readentity
+NULL, // #368
NULL, // #369
NULL, // #370
NULL, // #371