S_StaticSound (s, f, PRVM_G_FLOAT(OFS_PARM2), PRVM_G_FLOAT(OFS_PARM3)*64);
}
-// #92 vector(vector org) getlight (DP_QC_GETLIGHT)
+// #92 vector(vector org[, float lpflag]) getlight (DP_QC_GETLIGHT)
static void VM_CL_getlight (void)
{
vec3_t ambientcolor, diffusecolor, diffusenormal;
vec_t *p;
- VM_SAFEPARMCOUNT(1, VM_CL_getlight);
+ VM_SAFEPARMCOUNTRANGE(1, 2, VM_CL_getlight);
p = PRVM_G_VECTOR(OFS_PARM0);
VectorClear(ambientcolor);
VectorClear(diffusecolor);
VectorClear(diffusenormal);
- if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
+ if (prog->argc >= 2)
+ R_CompleteLightPoint(ambientcolor, diffusecolor, diffusenormal, p, PRVM_G_FLOAT(OFS_PARM1));
+ else if (cl.worldmodel && cl.worldmodel->brush.LightPoint)
cl.worldmodel->brush.LightPoint(cl.worldmodel, p, ambientcolor, diffusecolor, diffusenormal);
VectorMA(ambientcolor, 0.5, diffusecolor, PRVM_G_VECTOR(OFS_RETURN));
}
-
//============================================================================
//[515]: SCENE MANAGER builtins
extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed, int edictnum);//csprogs.c
prog->globals.client->time = cl.time;
for(i=1;i<prog->num_edicts;i++)
{
+ // so we can easily check if CSQC entity #edictnum is currently drawn
+ cl.csqcrenderentities[i].entitynumber = 0;
ed = &prog->edicts[i];
if(ed->priv.required->free)
continue;
VM_SAFEPARMCOUNT(1, VM_CL_unproject);
f = PRVM_G_VECTOR(OFS_PARM0);
- if(v_flipped.integer)
- f[0] = (2 * r_refdef.view.x + r_refdef.view.width) * (vid_conwidth.integer / (float) vid.width) - f[0];
VectorSet(temp,
f[2],
- (-1.0 + 2.0 * (f[0] / (vid_conwidth.integer / (float) vid.width) - r_refdef.view.x) / r_refdef.view.width) * f[2] * -r_refdef.view.frustum_x,
- (-1.0 + 2.0 * (f[1] / (vid_conheight.integer / (float) vid.height) - r_refdef.view.y) / r_refdef.view.height) * f[2] * -r_refdef.view.frustum_y);
+ (-1.0 + 2.0 * (f[0] / vid_conwidth.integer)) * f[2] * -r_refdef.view.frustum_x,
+ (-1.0 + 2.0 * (f[1] / vid_conheight.integer)) * f[2] * -r_refdef.view.frustum_y);
+ if(v_flipped.integer)
+ temp[1] = -temp[1];
Matrix4x4_Transform(&r_refdef.view.matrix, temp, PRVM_G_VECTOR(OFS_RETURN));
}
if(v_flipped.integer)
v[1] = -v[1];
VectorSet(PRVM_G_VECTOR(OFS_RETURN),
- (vid_conwidth.integer / (float) vid.width) * (r_refdef.view.x + r_refdef.view.width*0.5*(1.0+v[1]/v[0]/-r_refdef.view.frustum_x)),
- (vid_conheight.integer / (float) vid.height) * (r_refdef.view.y + r_refdef.view.height*0.5*(1.0+v[2]/v[0]/-r_refdef.view.frustum_y)),
+ vid_conwidth.integer * (0.5*(1.0+v[1]/v[0]/-r_refdef.view.frustum_x)),
+ vid_conheight.integer * (0.5*(1.0+v[2]/v[0]/-r_refdef.view.frustum_y)),
v[0]);
+ // explanation:
+ // after transforming, relative position to viewport (0..1) = 0.5 * (1 + v[2]/v[0]/-frustum_{x \or y})
+ // as 2D drawing honors the viewport too, to get the same pixel, we simply multiply this by conwidth/height
}
//#330 float(float stnum) getstatf (EXT_CSQC)
static void VM_CL_boxparticles (void)
{
int effectnum;
- prvm_edict_t *own;
+ // prvm_edict_t *own;
float *origin_from, *origin_to, *dir_from, *dir_to;
float count;
int flags;
VM_SAFEPARMCOUNTRANGE(7, 8, VM_CL_boxparticles);
effectnum = (int)PRVM_G_FLOAT(OFS_PARM0);
- own = PRVM_G_EDICT(OFS_PARM1); // TODO find use for this
+ // own = PRVM_G_EDICT(OFS_PARM1); // TODO find use for this
origin_from = PRVM_G_VECTOR(OFS_PARM2);
origin_to = PRVM_G_VECTOR(OFS_PARM3);
dir_from = PRVM_G_VECTOR(OFS_PARM4);
// texture found and loaded
// skip over the jpeg as we don't need it
for(i = 0; i < size; ++i)
- MSG_ReadByte();
+ (void) MSG_ReadByte();
}
else
{
unsigned short *data_sortedelement3s;
qboolean begin_active;
+ int begin_draw2d;
rtexture_t *begin_texture;
int begin_drawflag;
int begin_vertices;
vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
if(polys->progstarttime != prog->starttime) // from other progs? won't draw these (this can cause crashes!)
return;
- R_Mesh_ResetTextureState();
+// R_Mesh_ResetTextureState();
R_EntityMatrix(&identitymatrix);
GL_CullFace(GL_NONE);
+ GL_DepthTest(true); // polys in 3D space shall always have depth test
+ GL_DepthRange(0, 1);
R_Mesh_PrepareVertices_Generic_Arrays(polys->num_vertices, polys->data_vertex3f, polys->data_color4f, polys->data_texcoord2f);
for (surfacelistindex = 0;surfacelistindex < numsurfaces;)
if(polys->begin_color[i][3] < 1)
hasalpha = true;
- if (r_refdef.draw2dstage)
+ if (polys->begin_draw2d)
{
// draw the polygon as 2D immediately
drawqueuemesh_t mesh;
int i;
if (polys->max_triangles < polys->num_triangles + polys->begin_vertices-2)
{
- polys->max_triangles *= 2;
+ while (polys->max_triangles < polys->num_triangles + polys->begin_vertices-2)
+ polys->max_triangles *= 2;
VM_ResizePolygons(polys);
}
if (polys->num_vertices + polys->begin_vertices <= polys->max_vertices)
polys->num_vertices = 0; // otherwise it's not rendered at all and prints an error message --blub */
}
-//void(string texturename, float flag) R_BeginPolygon
+//void(string texturename, float flag[, float is2d]) R_BeginPolygon
void VM_CL_R_PolygonBegin (void)
{
const char *picname;
// better management of flags, and is more suited for 3D rendering), what
// about supporting Q3 shaders?
- VM_SAFEPARMCOUNT(2, VM_CL_R_PolygonBegin);
+ VM_SAFEPARMCOUNTRANGE(2, 3, VM_CL_R_PolygonBegin);
if (!polys->initialized)
VM_InitPolygons(polys);
polys->begin_drawflag = (int)PRVM_G_FLOAT(OFS_PARM1) & DRAWFLAG_MASK;
polys->begin_vertices = 0;
polys->begin_active = true;
+ polys->begin_draw2d = (prog->argc >= 3 ? (int)PRVM_G_FLOAT(OFS_PARM2) : r_refdef.draw2dstage);
}
//void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
VM_CL_R_SetView, // #303 float(float property, ...) setproperty (EXT_CSQC)
VM_CL_R_RenderScene, // #304 void() renderscene (EXT_CSQC)
VM_CL_R_AddDynamicLight, // #305 void(vector org, float radius, vector lightcolours) adddynamiclight (EXT_CSQC)
-VM_CL_R_PolygonBegin, // #306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon
+VM_CL_R_PolygonBegin, // #306 void(string texturename, float flag, float is2d[NYI: , float lines]) R_BeginPolygon
VM_CL_R_PolygonVertex, // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
VM_CL_R_PolygonEnd, // #308 void() R_EndPolygon
NULL /* R_LoadWorldModel in menu VM, should stay unassigned in client*/, // #309
VM_uri_escape, // #510 string(string in) uri_escape = #510;
VM_uri_unescape, // #511 string(string in) uri_unescape = #511;
VM_etof, // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
-VM_uri_get, // #513 float(string uril, float id) uri_get = #512; (DP_QC_URI_GET)
+VM_uri_get, // #513 float(string uri, float id, [string post_contenttype, string post_delim, [float buf]]) uri_get = #513; (DP_QC_URI_GET, DP_QC_URI_POST)
VM_tokenize_console, // #514 float(string str) tokenize_console = #514; (DP_QC_TOKENIZE_CONSOLE)
VM_argv_start_index, // #515 float(float idx) argv_start_index = #515; (DP_QC_TOKENIZE_CONSOLE)
VM_argv_end_index, // #516 float(float idx) argv_end_index = #516; (DP_QC_TOKENIZE_CONSOLE)
NULL, // #537
NULL, // #538
NULL, // #539
-NULL, // #540
-NULL, // #541
-NULL, // #542
+VM_physics_enable, // #540 void(entity e, float physics_enabled) physics_enable = #540; (DP_PHYSICS_ODE)
+VM_physics_addforce, // #541 void(entity e, vector force, vector relative_ofs) physics_addforce = #541; (DP_PHYSICS_ODE)
+VM_physics_addtorque, // #542 void(entity e, vector torque) physics_addtorque = #542; (DP_PHYSICS_ODE)
NULL, // #543
NULL, // #544
NULL, // #545