diff --git a/Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h b/Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h index 743fbec7771..ba0e0765bb3 100644 --- a/Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h +++ b/Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h @@ -156,7 +156,7 @@ class BaseHeightMapRenderObjClass : public RenderObjClass, public DX8_CleanupHoo void updateMacroTexture(AsciiString textureName); void doTextures(Bool flag) {m_disableTextures = !flag;}; /// Update the diffuse value from static light info for one vertex. - void doTheLight(VERTEX_FORMAT *vb, Vector3*light, Vector3*normal, RefRenderObjListIterator *pLightsIterator, UnsignedByte alpha); + void doTheLight(VERTEX_FORMAT *vb, const Vector3*light, Vector3*normal, RefRenderObjListIterator *pLightsIterator, UnsignedByte alpha); void addScorch(Vector3 location, Real radius, Scorches type); void addTree(DrawableID id, Coord3D location, Real scale, Real angle, Real randomScaleAmount, const W3DTreeDrawModuleData *data); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp index 54f5a420810..893ac2592aa 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp @@ -497,7 +497,7 @@ static lights into account as well. It is possible to just use the normal in th vertex and let D3D do the lighting, but it is slower to render, and can only handle 4 lights at this point. */ //============================================================================= -void BaseHeightMapRenderObjClass::doTheLight(VERTEX_FORMAT *vb, Vector3*light, Vector3*normal, RefRenderObjListIterator *pLightsIterator, UnsignedByte alpha) +void BaseHeightMapRenderObjClass::doTheLight(VERTEX_FORMAT *vb, const Vector3*light, Vector3*normal, RefRenderObjListIterator *pLightsIterator, UnsignedByte alpha) { #ifdef USE_NORMALS vb->nx = normal->X; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp index 248bf1afea2..b7ff7ae8347 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp @@ -306,7 +306,6 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, VERTEX_FORMAT * { Int i,j; Vector3 lightRay[MAX_GLOBAL_LIGHTS]; - const Coord3D *lightPos; Int xCoord, yCoord; Int vn0,un0,vp1,up1; Vector3 l2r,n2f,normalAtTexel; @@ -320,6 +319,12 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, VERTEX_FORMAT * assert(x0 >= originX && y0 >= originY && x1>x0 && y1>y0 && x1<=originX+VERTEX_BUFFER_TILE_LENGTH && y1<=originY+VERTEX_BUFFER_TILE_LENGTH); #endif + 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 = data; @@ -362,12 +367,6 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, VERTEX_FORMAT * pMap->getUVData(mapX, mapY, U, V); pMap->getAlphaUVData(mapX, mapY, UA, VA, alpha, &flipForBlend); - 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 sample l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX+cellOffset, mapY) - pMap->getDisplayHeight(un0, mapY))); n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX, (mapY+cellOffset)) - pMap->getDisplayHeight(mapX, vn0)));