Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
perf(w3ddevice): lift the terrain light rays out of the per-vertex loop
Olcay Seygan3a4e64ba1dba
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cppindex 4aed7d541..73cb762a5 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp@@ -315,7 +315,6 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int{Int i,j;Vector3 lightRay[MAX_GLOBAL_LIGHTS];- const Coord3D *lightPos;Int xCoord, yCoord;Int vn0,un0,vp1,up1;Vector3 l2r,n2f,normalAtTexel;@@ -333,6 +332,15 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Intassert(x0 >= originX && y0 >= originY && x1>x0 && y1>y0 && x1<=originX+VERTEX_BUFFER_TILE_LENGTH && y1<=originY+VERTEX_BUFFER_TILE_LENGTH);#endif+ // the global light directions do not change while one vertex buffer tile is being filled,+ // so build the rays once here instead of once per vertex - this loop used to sit inside+ // the i/j double loop and ran for every one of the tile's vertices.+ for (Int lightIndex=0; lightIndex < TheGlobalData->m_numGlobalLights; lightIndex++)+ {+ const Coord3D *lightPos = &TheGlobalData->m_terrainLightPos[lightIndex];+ lightRay[lightIndex].Set(-lightPos->x, -lightPos->y, -lightPos->z);+ }+DX8VertexBufferClass::WriteLockClass lockVtxBuffer(pVB);VERTEX_FORMAT *vbHardware = (VERTEX_FORMAT*)lockVtxBuffer.Get_Vertex_Array();VERTEX_FORMAT *vBase = (VERTEX_FORMAT*)data;@@ -384,12 +392,6 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int}- for (Int lightIndex=0; lightIndex < TheGlobalData->m_numGlobalLights; lightIndex++)- {- lightPos=&TheGlobalData->m_terrainLightPos[lightIndex];- lightRay[lightIndex].Set(-lightPos->x,-lightPos->y, -lightPos->z);- }-//top-left samplel2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset, getYWithOrigin(j)) - pMap->getDisplayHeight(un0, getYWithOrigin(j))));n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i), (getYWithOrigin(j)+cellOffset)) - pMap->getDisplayHeight(getXWithOrigin(i), vn0)));