diff --git a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp index 2273db49..edd6f05c 100644 --- a/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp +++ b/sp/src/materialsystem/stdshaders/lightmappedgeneric_dx9_helper.cpp @@ -805,8 +805,8 @@ void DrawLightmappedGeneric_DX9_Internal(CBaseVSShader *pShader, IMaterialVar** (params[info.m_nBlendModulateTexture]->IsTexture() ); bool hasNormalMapAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK ); #ifdef PARALLAX_CORRECTED_CUBEMAPS - // Parallax cubemaps - bool hasParallaxCorrection = params[info.m_nEnvmapParallax]->GetIntValue() > 0; + // Parallax cubemaps. Check for envmap because if we don't, white splotchs can appear at certain viewing angles when mat_specular is 0. + bool hasParallaxCorrection = params[info.m_nEnvmap]->IsDefined() && params[info.m_nEnvmapParallax]->GetIntValue() > 0; #endif if ( hasFlashlight && !IsX360() ) diff --git a/sp/src/utils/vbsp/map.cpp b/sp/src/utils/vbsp/map.cpp index c479b279..d8bce641 100644 --- a/sp/src/utils/vbsp/map.cpp +++ b/sp/src/utils/vbsp/map.cpp @@ -15,9 +15,6 @@ #include "materialsub.h" #include "fgdlib/fgdlib.h" #include "manifest.h" -#ifdef PARALLAX_CORRECTED_CUBEMAPS -#include "matrixinvert.h" -#endif #ifdef MAPBASE_VSCRIPT #include "vscript_vbsp.h" #endif @@ -1657,9 +1654,11 @@ ChunkFileResult_t CMapFile::LoadEntityCallback(CChunkFile *pFile, int nParam) // if (!strcmp("parallax_obb", pClassName)) { - matrix3x4_t obbMatrix, invObbMatrix; - SetIdentityMatrix(obbMatrix); - SetIdentityMatrix(invObbMatrix); + //Originally was matrix3x2. Now we use built-in functions to the engine instead of a custom invert matrix + VMatrix obbMatrix, invObbMatrix; + MatrixSetIdentity(obbMatrix); + MatrixSetIdentity(invObbMatrix); + // Get corner and its 3 edges (scaled, local x, y, and z axes) mapbrush_t *brush = &mapbrushes[mapent->firstbrush]; @@ -1714,13 +1713,15 @@ ChunkFileResult_t CMapFile::LoadEntityCallback(CChunkFile *pFile, int nParam) x *= abs(DotProduct(diag, x)); // Build transformation matrix (what is needed to turn a [0,0,0] - [1,1,1] cube into this brush) - MatrixSetColumn(x, 0, obbMatrix); - MatrixSetColumn(y, 1, obbMatrix); - MatrixSetColumn(z, 2, obbMatrix); - MatrixSetColumn(corner, 3, obbMatrix); + //Originally was MatrixSetColum. Since we use VMatrix now, changed to obbMatrix + obbMatrix.SetForward(x); + obbMatrix.SetLeft(y); + obbMatrix.SetUp(z); + obbMatrix.SetTranslation(corner); //find inverse (we need the world to local matrix, "transformationmatrix" is kind of a misnomer) - MatrixInversion(obbMatrix, invObbMatrix); + //Originally was MatrixInversion. This is now using the built in functions, not relying on MatrixInversion and matrixinvert.h anymore + MatrixInverseGeneral(obbMatrix, invObbMatrix); break; } diff --git a/sp/src/utils/vbsp/matrixinvert.h b/sp/src/utils/vbsp/matrixinvert.h deleted file mode 100644 index 6e676ad3..00000000 --- a/sp/src/utils/vbsp/matrixinvert.h +++ /dev/null @@ -1,117 +0,0 @@ -// By Jason Yu-Tseh Chi -// From http://chi3x10.wordpress.com/2008/05/28/calculate-matrix-inversion-in-c/ -// Modified to work with valve's matrix_3x4_t - -#include "mathlib\mathlib.h" - -// Calculate the cofactor of element (row,col) -int GetMatrixMinor(float **src, float **dest, int row, int col, int order) -{ - // Indicate which col and row is being copied to dest - int colCount = 0, rowCount = 0; - - for (int i = 0; i < order; i++) - { - if (i != row) - { - colCount = 0; - for (int j = 0; j < order; j++) - { - // When j is not the element - if (j != col) - { - dest[rowCount][colCount] = src[i][j]; - colCount++; - } - } - rowCount++; - } - } - - return 1; -} - -// Calculate the determinant recursively. -double CalcMatrixDeterminant(float **mat, int order) -{ - // Order must be >= 0 - // Stop the recursion when matrix is a single element - if (order == 1) - return mat[0][0]; - - // The determinant value - float det = 0; - - // Allocate the cofactor matrix - float **minor; - minor = new float*[order - 1]; - for (int i = 0; i