]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
RF_MODELLIGHT compatible with getlight() - assuming light direction is worldspace...
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 Dec 2011 23:13:04 +0000 (23:13 +0000)
committervortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 8 Dec 2011 23:13:04 +0000 (23:13 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11603 d7cf8633-e32d-0410-b094-e92efae38249

csprogs.c

index f4ddce2cf5f27d3a65cf6ae6ad5eaf5b70ba273f..289f678c197f6280dbc04a9afcfbcd2c6798fd0e 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -357,15 +357,6 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        if (renderflags & RF_USETRANSPARENTOFFSET)
                entrender->transparent_offset = PRVM_clientglobalfloat(transparent_offset);
 
-       // model light
-       if (renderflags & RF_MODELLIGHT)
-       {
-               if(PRVM_clientedictvector(ed, modellight_ambient)) VectorCopy(PRVM_clientedictvector(ed, modellight_ambient), entrender->modellight_ambient);
-               if(PRVM_clientedictvector(ed, modellight_diffuse)) VectorCopy(PRVM_clientedictvector(ed, modellight_diffuse), entrender->modellight_diffuse);
-               if(PRVM_clientedictvector(ed, modellight_dir))     VectorCopy(PRVM_clientedictvector(ed, modellight_dir), entrender->modellight_lightdir);
-               entrender->flags |= RENDER_CUSTOMIZEDMODELLIGHT;
-       }
-
        if(renderflags)
        {
                if(renderflags & RF_VIEWMODEL) entrender->flags |= RENDER_VIEWMODEL | RENDER_NODEPTHTEST;
@@ -413,6 +404,19 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        // make the other useful stuff
        memcpy(entrender->framegroupblend, ed->priv.server->framegroupblend, sizeof(ed->priv.server->framegroupblend));
        CL_UpdateRenderEntity(entrender);
+
+       // model light
+       if (renderflags & RF_MODELLIGHT)
+       {
+               if(PRVM_clientedictvector(ed, modellight_ambient)) VectorCopy(PRVM_clientedictvector(ed, modellight_ambient), entrender->modellight_ambient);
+               if(PRVM_clientedictvector(ed, modellight_diffuse)) VectorCopy(PRVM_clientedictvector(ed, modellight_diffuse), entrender->modellight_diffuse);
+               if(PRVM_clientedictvector(ed, modellight_dir))     Matrix4x4_Transform3x3(&entrender->matrix, PRVM_clientedictvector(ed, modellight_dir), entrender->modellight_lightdir);
+               if (VectorLength2(entrender->modellight_lightdir) == 0)
+                       VectorSet(entrender->modellight_lightdir, 0, 0, 1); // have to set SOME valid vector here
+               VectorNormalize(entrender->modellight_lightdir);
+               entrender->flags |= RENDER_CUSTOMIZEDMODELLIGHT;
+       }
+
        // override animation data with full control
        memcpy(entrender->frameblend, ed->priv.server->frameblend, sizeof(ed->priv.server->frameblend));
        if (ed->priv.server->skeleton.relativetransforms)