]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
Fixed the 5.1 speaker layout when using SDL on Win32 (thanks to Willis for the report)
[xonotic/darkplaces.git] / clvm_cmds.c
index 59c34d5a57c8f0e3ba23ed39d6310f7cdc14b414..7c3ae0a75895925b388ed32734fff4ab0597eb84 100644 (file)
@@ -39,6 +39,7 @@ char *vm_cl_extensions =
 "DP_ENT_GLOW "
 "DP_ENT_SCALE "
 "DP_GFX_EXTERNALTEXTURES "
+"DP_GFX_EXTERNALTEXTURES_PERMAP "
 "DP_GFX_FOG "
 "DP_GFX_QUAKE3MODELTAGS "
 "DP_GFX_SKINFILES "
@@ -729,8 +730,8 @@ static void CSQC_R_RecalcView (void)
 {
        extern matrix4x4_t viewmodelmatrix;
        viewmodelmatrix = identitymatrix;
-       r_refdef.viewentitymatrix = identitymatrix;
-       Matrix4x4_CreateFromQuakeEntity(&r_refdef.viewentitymatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], 1);
+       r_view.matrix = identitymatrix;
+       Matrix4x4_CreateFromQuakeEntity(&r_view.matrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], 1);
        Matrix4x4_CreateFromQuakeEntity(&viewmodelmatrix, csqc_origin[0], csqc_origin[1], csqc_origin[2], csqc_angles[0], csqc_angles[1], csqc_angles[2], 0.3);
 }
 
@@ -774,25 +775,28 @@ void VM_R_SetView (void)
 
        switch(c)
        {
-       case VF_MIN:                    r_refdef.x = (int)f[0];
-                                                       r_refdef.y = (int)f[1];
+       case VF_MIN:                    r_view.x = (int)f[0];
+                                                       r_view.y = (int)f[1];
                                                        break;
-       case VF_MIN_X:                  r_refdef.x = (int)k;
+       case VF_MIN_X:                  r_view.x = (int)k;
                                                        break;
-       case VF_MIN_Y:                  r_refdef.y = (int)k;
+       case VF_MIN_Y:                  r_view.y = (int)k;
                                                        break;
-       case VF_SIZE:                   r_refdef.width = (int)f[0];
-                                                       r_refdef.height = (int)f[1];
+       case VF_SIZE:                   r_view.width = (int)f[0];
+                                                       r_view.height = (int)f[1];
                                                        break;
-       case VF_SIZE_Y:                 r_refdef.width = (int)k;
+       case VF_SIZE_Y:                 r_view.width = (int)k;
                                                        break;
-       case VF_SIZE_X:                 r_refdef.height = (int)k;
+       case VF_SIZE_X:                 r_view.height = (int)k;
                                                        break;
-       case VF_VIEWPORT:               r_refdef.x = (int)f[0];
-                                                       r_refdef.y = (int)f[1];
+       case VF_VIEWPORT:               r_view.x = (int)f[0];
+                                                       r_view.y = (int)f[1];
+                                                       r_view.z = 0;
+                                                       // TODO: make sure that view_z and view_depth are set properly even if csqc does not set them!
                                                        f = PRVM_G_VECTOR(OFS_PARM2);
-                                                       r_refdef.width = (int)f[0];
-                                                       r_refdef.height = (int)f[1];
+                                                       r_view.width = (int)f[0];
+                                                       r_view.height = (int)f[1];
+                                                       r_view.depth = 1;
                                                        break;
        case VF_FOV:                    //r_refdef.fov_x = f[0]; // FIXME!
                                                        //r_refdef.fov_y = f[1]; // FIXME!
@@ -886,8 +890,8 @@ void VM_CL_unproject (void)
 
        VM_SAFEPARMCOUNT(1, VM_CL_unproject);
        f = PRVM_G_VECTOR(OFS_PARM0);
-       VectorSet(temp, f[2], f[0] * f[2] * -r_refdef.frustum_x * 2.0 / r_refdef.width, f[1] * f[2] * -r_refdef.frustum_y * 2.0 / r_refdef.height);
-       Matrix4x4_Transform(&r_refdef.viewentitymatrix, temp, PRVM_G_VECTOR(OFS_RETURN));
+       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));
 }
 
 //#311 vector (vector v) cs_project (EXT_CSQC)
@@ -899,9 +903,9 @@ void VM_CL_project (void)
 
        VM_SAFEPARMCOUNT(1, VM_CL_project);
        f = PRVM_G_VECTOR(OFS_PARM0);
-       Matrix4x4_Invert_Simple(&m, &r_refdef.viewentitymatrix);
+       Matrix4x4_Invert_Simple(&m, &r_view.matrix);
        Matrix4x4_Transform(&m, f, v);
-       VectorSet(PRVM_G_VECTOR(OFS_RETURN), v[1]/v[0]/-r_refdef.frustum_x*0.5*r_refdef.width, v[2]/v[0]/-r_refdef.frustum_y*r_refdef.height*0.5, v[0]);
+       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]);
 }
 
 //#330 float(float stnum) getstatf (EXT_CSQC)
@@ -1029,45 +1033,6 @@ void VM_CL_particleeffectnum (void)
        PRVM_G_FLOAT(OFS_RETURN) = i;
 }
 
-void CSQC_ParseBeam (int ent, vec3_t start, vec3_t end, model_t *m, int lightning)
-{
-       int             i;
-       beam_t  *b;
-
-       // override any beam with the same entity
-       for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
-       {
-               if (b->entity == ent && ent)
-               {
-                       //b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
-               }
-       }
-
-       // find a free beam
-       for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
-       {
-               if (!b->model || b->endtime < cl.time)
-               {
-                       b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
-               }
-       }
-       Con_Print("beam list overflow!\n");
-}
-
 // #336 void(entity ent, float effectnum, vector start, vector end[, float color]) trailparticles (EXT_CSQC)
 void VM_CL_trailparticles (void)
 {
@@ -1653,74 +1618,32 @@ void VM_CL_te_explosion2 (void)
 }
 
 
-static void VM_CL_NewBeam (int ent, float *start, float *end, model_t *m, qboolean lightning)
-{
-       beam_t  *b;
-       int             i;
-
-       if (ent >= cl.max_csqcentities)
-               CL_ExpandCSQCEntities(ent);
-
-       // override any beam with the same entity
-       for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
-       {
-               if (b->entity == ent && ent)
-               {
-                       //b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
-               }
-       }
-
-       // find a free beam
-       for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
-       {
-               if (!b->model || b->endtime < cl.time)
-               {
-                       b->entity = ent;
-                       b->lightning = lightning;
-                       b->relativestartvalid = (ent && cl.csqcentities[ent].state_current.active) ? 2 : 0;
-                       b->model = m;
-                       b->endtime = cl.time + 0.2;
-                       VectorCopy (start, b->start);
-                       VectorCopy (end, b->end);
-                       return;
-               }
-       }
-       Con_Print("beam list overflow!\n");
-}
-
 // #428 void(entity own, vector start, vector end) te_lightning1 (DP_TE_STANDARDEFFECTBUILTINS)
 void VM_CL_te_lightning1 (void)
 {
        VM_SAFEPARMCOUNT(3, VM_CL_te_lightning1);
-       VM_CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt, true);
+       CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt, true);
 }
 
 // #429 void(entity own, vector start, vector end) te_lightning2 (DP_TE_STANDARDEFFECTBUILTINS)
 void VM_CL_te_lightning2 (void)
 {
        VM_SAFEPARMCOUNT(3, VM_CL_te_lightning2);
-       VM_CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt2, true);
+       CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt2, true);
 }
 
 // #430 void(entity own, vector start, vector end) te_lightning3 (DP_TE_STANDARDEFFECTBUILTINS)
 void VM_CL_te_lightning3 (void)
 {
        VM_SAFEPARMCOUNT(3, VM_CL_te_lightning3);
-       VM_CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt3, false);
+       CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_bolt3, false);
 }
 
 // #431 void(entity own, vector start, vector end) te_beam (DP_TE_STANDARDEFFECTBUILTINS)
 void VM_CL_te_beam (void)
 {
        VM_SAFEPARMCOUNT(3, VM_CL_te_beam);
-       VM_CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_beam, false);
+       CL_NewBeam(PRVM_G_EDICTNUM(OFS_PARM0), PRVM_G_VECTOR(OFS_PARM1), PRVM_G_VECTOR(OFS_PARM2), cl.model_beam, false);
 }
 
 // #433 void(vector org) te_plasmaburn (DP_TE_PLASMABURN)