@@ -3615,22 +3615,17 @@ void R_LoadLightGrid( lump_t *l )
36153615 }
36163616
36173617 // standard spherical coordinates to cartesian coordinates conversion
3618-
3619- // decode X as cos( lat ) * sin( long )
3620- // decode Y as sin( lat ) * sin( long )
3621- // decode Z as cos( long )
3622-
36233618 // RB: having a look in NormalToLatLong used by q3map2 shows the order of latLong
3619+ // Lng = 0 at (1,0,0), 90 at (0,1,0), etc., encoded in 8-bit sine table format
3620+ // Lat = 0 at (0,0,1) to 180 (0,0,-1), encoded in 8-bit sine table format
3621+ // (so the upper bit of lat is wasted)
36243622
3625- // Lat = 0 at (1,0,0) to 360 (-1,0,0), encoded in 8-bit sine table format
3626- // Lng = 0 at (0,0,1) to 180 (0,0,-1), encoded in 8-bit sine table format
3627-
3628- lat = DEG2RAD ( in->latLong [ 1 ] * ( 360 .0f / 255 .0f ) );
3629- lng = DEG2RAD ( in->latLong [ 0 ] * ( 360 .0f / 255 .0f ) );
3623+ lat = DEG2RAD ( in->latLong [ 0 ] * ( 360 .0f / 255 .0f ) );
3624+ lng = DEG2RAD ( in->latLong [ 1 ] * ( 360 .0f / 255 .0f ) );
36303625
3631- direction[ 0 ] = cosf ( lat ) * sinf ( lng );
3632- direction[ 1 ] = sinf ( lat ) * sinf ( lng );
3633- direction[ 2 ] = cosf ( lng );
3626+ direction[ 0 ] = cosf ( lng ) * sinf ( lat );
3627+ direction[ 1 ] = sinf ( lng ) * sinf ( lat );
3628+ direction[ 2 ] = cosf ( lat );
36343629
36353630 // Pack data into an bspGridPoint
36363631 gridPoint1->color [ 0 ] = floatToUnorm8 ( 0 .5f * (ambientColor[ 0 ] + directedColor[ 0 ]) );
@@ -3651,6 +3646,8 @@ void R_LoadLightGrid( lump_t *l )
36513646
36523647 // fill in gridpoints with zero light (samples in walls) to avoid
36533648 // darkening of objects near walls
3649+ // FIXME: the interpolation includes other interpolated data points so the
3650+ // result depends on iteration order
36543651 gridPoint1 = w->lightGridData1 ;
36553652 gridPoint2 = w->lightGridData2 ;
36563653
0 commit comments