Mercurial > mm7
diff Engine/Graphics/LightmapBuilder.cpp @ 2562:b8a56afc6ba1
new var no_actors, lights_flag, debug_lights, StationaryLights and MobileLights
author | Ritor1 |
---|---|
date | Sun, 17 May 2015 22:42:13 +0600 |
parents | 98057834c9a0 |
children | f2f2595fe308 |
line wrap: on
line diff
--- a/Engine/Graphics/LightmapBuilder.cpp Thu May 14 19:29:28 2015 +0600 +++ b/Engine/Graphics/LightmapBuilder.cpp Sun May 17 22:42:13 2015 +0600 @@ -38,12 +38,12 @@ // For initialization step(II) for ( int i = 0; i < 512; ++i )//for light type 1 - this->std__vector_000004[i] = Lightmap(); - this->std__vector_000004_size = 0; + this->StationaryLights[i] = Lightmap(); + this->StationaryLightsCount = 0; for ( int i = 0; i < 768; ++i )//for light type 2 - this->std__vector_183808[i] = Lightmap(); - this->std__vector_183808_size = 0; + this->MobileLights[i] = Lightmap(); + this->MobileLightsCount = 0; for ( int i = 0; i < 256; i++ ) this->field_3C8C34[i].flt_2C = 0.0f; @@ -58,9 +58,9 @@ bool result; // eax@9 int pSlot; // [sp+10h] [bp-4h]@1 - v3 = stru_F8AD28.uDefaultAmbientLightLevel + pFace->uShadeType; + v3 = Lights.uDefaultAmbientLightLevel + pFace->uShadeType; pSlot = 0; - stru_F8AD28.uCurrentAmbientLightLevel = v3 << 16; + Lights.uCurrentAmbientLightLevel = v3 << 16; for ( uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i ) { if ( pSlot >= 20 ) @@ -74,7 +74,7 @@ ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, 0); } result = pSlot; - stru_F8AD28.uNumLightsApplied = pSlot; + Lights.uNumLightsApplied = pSlot; return true; } @@ -154,65 +154,38 @@ return false; Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3); - float p_dot = (float)pLight->vPosition.x * pNormal->x + float p_dot = ((float)pLight->vPosition.x * pNormal->x + (float)pLight->vPosition.y * pNormal->y - + (float)pLight->vPosition.z * pNormal->z + *a3; - p_dot = p_dot + 0.5f; - if ( (//v49 = pNormal, - //Vec3_float_::NegDot(&a1->vWorldPosition, pNormal, a3), - //X = v8->vPosition.y, - //v50 = (double)v8->vPosition.y * v49->y, - //X = v8->vPosition.z, - //v51 = (double)v8->vPosition.z * v49->z, - //X = v8->vPosition.x, - //*(float *)&a3 = (double)pLight->vPosition.y * pNormal->y - //+ (double)pLight->vPosition.z * pNormal->z - //+ (double)pLight->vPosition.x * pNormal->x + *a3, - //v61 = *(float *)&a3 + 0.5f, - //result = LODWORD(v61), - //X = LODWORD(v61), - //v52 = v63, - p_dot > pLight->uRadius) ) + + (float)pLight->vPosition.z * pNormal->z + *a3)+0.5f; + if ( p_dot > pLight->uRadius ) return false; -/* - v49 = pNormal; - Vec3_float_::NegDot(&v11->vWorldPosition, pNormal, a3); - *(float *)a3 = (double)v8->vPosition.x * v49->x - + (double)v8->vPosition.y * v49->y - + (double)v8->vPosition.z * v49->z + *a3; - v61 = *(float *)a3 + 6.7553994e15; - result = LODWORD(v61); - X = LODWORD(v61); - v52 = radius_1; - if ( SLODWORD(v61) > radius_1)*/ - //v53 = pSlot; - //v60 = X; - stru_F8AD28._blv_lights_radii[*pSlot] = pLight->uRadius; - stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; - stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; - stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y; - stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z; + + Lights._blv_lights_radii[*pSlot] = pLight->uRadius; + Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; + Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x; + Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y; + Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z; - stru_F8AD28._blv_lights_rs[*pSlot] = pLight->uLightColorR / 255.0f; - stru_F8AD28._blv_lights_gs[*pSlot] = pLight->uLightColorG / 255.0f; - stru_F8AD28._blv_lights_bs[*pSlot] = pLight->uLightColorB / 255.0f; + Lights._blv_lights_rs[*pSlot] = pLight->uLightColorR / 255.0f; + Lights._blv_lights_gs[*pSlot] = pLight->uLightColorG / 255.0f; + Lights._blv_lights_bs[*pSlot] = pLight->uLightColorB / 255.0f; - stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs(p_dot); - stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType; + Lights._blv_lights_light_dot_faces[*pSlot] = abs(p_dot); + Lights._blv_lights_types[*pSlot] = pLight->uLightType; - v57 = stru_F8AD28._blv_lights_types[*pSlot]; - if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && stru_F8AD28._blv_lights_types[*pSlot] & 4 ) + v57 = Lights._blv_lights_types[*pSlot]; + if ( pRenderer->bUsingSpecular && Lights._blv_lights_types[*pSlot] & 4 ) v57 = _4E94D2_light_type; - stru_F8AD28._blv_lights_types[*pSlot] = v57; + Lights._blv_lights_types[*pSlot] = v57; int id = 4 * *pSlot; - if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular ) + if ( pRenderer->bUsingSpecular ) { - if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 ) + if ( Lights._blv_lights_types[*pSlot] & 4 ) { - stru_F8AD28._blv_lights_rs[id] = stru_F8AD28._blv_lights_rs[id] * 0.3300000131130219; - stru_F8AD28._blv_lights_gs[id] = stru_F8AD28._blv_lights_gs[id] * 0.3300000131130219; - stru_F8AD28._blv_lights_bs[id] = stru_F8AD28._blv_lights_bs[id] * 0.3300000131130219; + Lights._blv_lights_rs[id] = Lights._blv_lights_rs[id] * 0.3300000131130219; + Lights._blv_lights_gs[id] = Lights._blv_lights_gs[id] * 0.3300000131130219; + Lights._blv_lights_bs[id] = Lights._blv_lights_bs[id] * 0.3300000131130219; } } ++*pSlot; @@ -237,33 +210,33 @@ && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2 && ((a4) || v10 >= 0) && v10 <= pLight->uRadius ) { - stru_F8AD28._blv_lights_radii[*pSlot] = pLight->uRadius; - stru_F8AD28._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; - stru_F8AD28._blv_lights_xs[*pSlot] = pLight->vPosition.x; - stru_F8AD28._blv_lights_ys[*pSlot] = pLight->vPosition.y; - stru_F8AD28._blv_lights_zs[*pSlot] = pLight->vPosition.z; - stru_F8AD28._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; - stru_F8AD28._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; - stru_F8AD28._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; + Lights._blv_lights_radii[*pSlot] = pLight->uRadius; + Lights._blv_lights_inv_radii[*pSlot] = 65536 / pLight->uRadius; + Lights._blv_lights_xs[*pSlot] = pLight->vPosition.x; + Lights._blv_lights_ys[*pSlot] = pLight->vPosition.y; + Lights._blv_lights_zs[*pSlot] = pLight->vPosition.z; + Lights._blv_lights_rs[*pSlot] = (double)pLight->uLightColorR * 0.0039215689; + Lights._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG * 0.0039215689; + Lights._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB * 0.0039215689; //v11 = abs(v10); //v12 = pRenderer->bUsingSpecular; - stru_F8AD28._blv_lights_light_dot_faces[*pSlot] = abs(v10); - stru_F8AD28._blv_lights_types[*pSlot] = pLight->uLightType; + Lights._blv_lights_light_dot_faces[*pSlot] = abs(v10); + Lights._blv_lights_types[*pSlot] = pLight->uLightType; //v13 = pRenderer->pRenderD3D; - v14 = stru_F8AD28._blv_lights_types[*pSlot]; + v14 = Lights._blv_lights_types[*pSlot]; if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && v14 & 4 ) v14 = _4E94D2_light_type; - stru_F8AD28._blv_lights_types[*pSlot] = v14; + Lights._blv_lights_types[*pSlot] = v14; result = 4 * *pSlot; if ( /*v13*/true && pRenderer->bUsingSpecular ) { - if ( stru_F8AD28._blv_lights_types[*pSlot] & 4 ) + if ( Lights._blv_lights_types[*pSlot] & 4 ) { - *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) + *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result) * 0.33000001; - *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result) + *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result) * 0.33000001; - *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result) + *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result) * 0.33000001; } } @@ -283,7 +256,7 @@ BLVFace* pFace = &pIndoor->pFaces[uFaceID]; BLVSector* pSector = &pIndoor->pSectors[pFace->uSectorID]; - stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16;//0x00180000 + Lights.uCurrentAmbientLightLevel = (Lights.uDefaultAmbientLightLevel + pSector->uMinAmbientLightLevel) << 16;//0x00180000 uint uNumLightsApplied = 0; for (uint i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) @@ -312,7 +285,7 @@ ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type); } - stru_F8AD28.uNumLightsApplied = uNumLightsApplied; + Lights.uNumLightsApplied = uNumLightsApplied; return true; } @@ -337,16 +310,16 @@ { unsigned int slot = *pSlot; - stru_F8AD28._blv_lights_radii[slot] = pLight->uRadius; - stru_F8AD28._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius; - stru_F8AD28._blv_lights_xs[slot] = pLight->vPosition.x; - stru_F8AD28._blv_lights_ys[slot] = pLight->vPosition.y; - stru_F8AD28._blv_lights_zs[slot] = pLight->vPosition.z; - stru_F8AD28._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f; - stru_F8AD28._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f; - stru_F8AD28._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f; - stru_F8AD28._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f)); - stru_F8AD28._blv_lights_types[slot] = pLight->uLightType; + Lights._blv_lights_radii[slot] = pLight->uRadius; + Lights._blv_lights_inv_radii[slot] = 65536 / pLight->uRadius; + Lights._blv_lights_xs[slot] = pLight->vPosition.x; + Lights._blv_lights_ys[slot] = pLight->vPosition.y; + Lights._blv_lights_zs[slot] = pLight->vPosition.z; + Lights._blv_lights_rs[slot] = (double)pLight->uLightColorR / 255.0f; + Lights._blv_lights_gs[slot] = (double)pLight->uLightColorG / 255.0f; + Lights._blv_lights_bs[slot] = (double)pLight->uLightColorB / 255.0f; + Lights._blv_lights_light_dot_faces[slot] = abs((int)floorf(v13 + 0.5f)); + Lights._blv_lights_types[slot] = pLight->uLightType; *pSlot += 1; return true; @@ -365,8 +338,8 @@ v.y = 1.0; v.x = 1.0; - for (uint i = 0; i < std__vector_183808_size; ++i) - if (!pRenderer->DrawLightmap(std__vector_183808 + i, &v, z_bias)) + for (uint i = 0; i < MobileLightsCount; ++i) + if (!pRenderer->DrawLightmap(&MobileLights[i], &v, z_bias)) Error("Invalid lightmap detected! (%u)", i); return true; @@ -497,7 +470,7 @@ v6 = 0; //v7 = this; a7 = 0; - stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type; + Lights.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type; if ( pMobileLightsStack->uNumLightsActive > 0 ) { v8 = pMobileLightsStack->pLights; @@ -526,7 +499,7 @@ while ( v9 < pStationaryLightsStack->uNumLightsActive ); } - stru_F8AD28.uNumLightsApplied = a7; + Lights.uNumLightsApplied = a7; return true;*/ // bool __stdcall sub_45D036(struct Vec3<float> *pNormal, int a2, struct RenderVertex *a3, int a4, signed int X) //{ @@ -537,7 +510,7 @@ int i; num_lights = 0; - stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->max_terrain_dimming_level; + Lights.uCurrentAmbientLightLevel = pOutdoor->max_terrain_dimming_level; for (i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) { if ( num_lights >= 20 ) @@ -552,7 +525,7 @@ StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, Light_tile_dist, a3, uStripType, bLightBackfaces, &num_lights); } - stru_F8AD28.uNumLightsApplied = num_lights; + Lights.uNumLightsApplied = num_lights; return true; } @@ -560,7 +533,7 @@ /////////////////////////TOGETHER/////////////////////////////////////////////////////// //----- (0045BC07) -------------------------------------------------------- -bool LightmapBuilder::ApplyLights(stru320 *a2, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *a5, IndoorCameraD3D_Vec4 *a6, char uClipFlag) +bool LightmapBuilder::ApplyLights(LightsData *pLights, stru154 *a3, unsigned int uNumVertices, RenderVertexSoft *VertexRenderList, IndoorCameraD3D_Vec4 *a6, char uClipFlag) { //For outdoor terrain and indoor light (III)(III) Vec3_int_ pos; // [sp+2Ch] [bp-40h]@21 @@ -571,11 +544,11 @@ static RenderVertexSoft static_69B140[64]; - a9 = a5; + a9 = VertexRenderList; if (a6) { for (uint i = 0; i < uNumVertices; ++i) - memcpy(&static_69B140[i], a5 + i, sizeof(RenderVertexSoft)); + memcpy(&static_69B140[i], VertexRenderList + i, sizeof(RenderVertexSoft)); if (pIndoorCameraD3D->_437376(a3, static_69B140, &uNumVertices) == 1) { @@ -586,32 +559,32 @@ } static stru314 static_69B110; - static_69B110.field_4.x = a3->face_plane.vNormal.x; - static_69B110.field_4.y = a3->face_plane.vNormal.y; - static_69B110.field_4.z = a3->face_plane.vNormal.z; + static_69B110.Normal.x = a3->face_plane.vNormal.x; + static_69B110.Normal.y = a3->face_plane.vNormal.y; + static_69B110.Normal.z = a3->face_plane.vNormal.z; static_69B110.dist = a3->face_plane.dist; - if (!pIndoorCameraD3D->GetFacetOrientation(a3->polygonType, &static_69B110.field_4, + if (!pIndoorCameraD3D->GetFacetOrientation(a3->polygonType, &static_69B110.Normal, &static_69B110.field_10, &static_69B110.field_1C)) { MessageBoxW(nullptr, L"Error: Failed to get the facet orientation", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:119", 0); ExitProcess(0); } - for (uint i = 0; i < a2->uNumLightsApplied; ++i) + for (uint i = 0; i < pLights->uNumLightsApplied; ++i) { - pos.x = a2->_blv_lights_xs[i]; - pos.y = a2->_blv_lights_ys[i]; - pos.z = a2->_blv_lights_zs[i]; + pos.x = pLights->_blv_lights_xs[i]; + pos.y = pLights->_blv_lights_ys[i]; + pos.z = pLights->_blv_lights_zs[i]; - uint uColorR = (uint)floorf(a2->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF, - uColorG = (uint)floorf(a2->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF, - uColorB = (uint)floorf(a2->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF; + uint uColorR = (uint)floorf(pLights->_blv_lights_rs[i] * 255.0 + 0.5f) & 0xFF, + uColorG = (uint)floorf(pLights->_blv_lights_gs[i] * 255.0 + 0.5f) & 0xFF, + uColorB = (uint)floorf(pLights->_blv_lights_bs[i] * 255.0 + 0.5f) & 0xFF; uint uColor = (uColorR << 16) | (uColorG << 8) | uColorB; if (!uColor) uColor = 0x0FFFFF;//0x00FFFFF; - if (!_45BE86_build_light_polygon(&pos, a2->_blv_lights_radii[i], uColor, a2->_blv_lights_light_dot_faces[i], - a2->_blv_lights_types[i], &static_69B110, uNumVertices, a9, uClipFlag) ) + if (!_45BE86_build_light_polygon(&pos, pLights->_blv_lights_radii[i], uColor, pLights->_blv_lights_light_dot_faces[i], + pLights->_blv_lights_types[i], &static_69B110, uNumVertices, a9, uClipFlag) ) { MessageBoxW(nullptr, L"Error: Failed to build light polygon", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:138", 0); } @@ -634,59 +607,59 @@ if (radius < 0.0f) return true; - lightmap = uLightType & 1 ? &std__vector_000004[std__vector_000004_size] ://stationary - &std__vector_183808[std__vector_183808_size];//mobile + lightmap = uLightType & 1 ? &StationaryLights[StationaryLightsCount] ://stationary + &MobileLights[MobileLightsCount];//mobile tex_light_radius = radius - dot_dist; flt_3C8C28 = sqrt((radius + radius - tex_light_radius) * tex_light_radius); //flt_3C8C28 = sqrt(tex_light_radius * tex_light_radius); flt_3C8C2C_lightmaps_brightness = 1.0 - (radius - flt_3C8C28) / radius; - lightmap->position_x = (double)pos->x - dot_dist * a7->field_4.x; - lightmap->position_y = (double)pos->y - dot_dist * a7->field_4.y; - lightmap->position_z = (double)pos->z - dot_dist * a7->field_4.z; + lightmap->position_x = (double)pos->x - dot_dist * a7->Normal.x; + lightmap->position_y = (double)pos->y - dot_dist * a7->Normal.y; + lightmap->position_z = (double)pos->z - dot_dist * a7->Normal.z; - flt_3C8C30 = radius * flt_3C8C2C_lightmaps_brightness; - flt_3C8C0C = flt_3C8C30 * a7->field_10.x; - flt_3C8C10 = flt_3C8C30 * a7->field_10.y; - flt_3C8C14 = flt_3C8C30 * a7->field_10.z; + light_radius = radius * flt_3C8C2C_lightmaps_brightness; + light_length_x = light_radius * a7->field_10.x; + light_length_y = light_radius * a7->field_10.y; + light_length_z = light_radius * a7->field_10.z; - flt_3C8C18 = flt_3C8C30 * a7->field_1C.x; - flt_3C8C1C = flt_3C8C30 * a7->field_1C.y; - flt_3C8C20 = flt_3C8C30 * a7->field_1C.z; + light_length_x2 = light_radius * a7->field_1C.x; + light_length_y2 = light_radius * a7->field_1C.y; + light_length_z2 = light_radius * a7->field_1C.z; - lightmap->pVertices[0].vWorldPosition.x = lightmap->position_x - flt_3C8C18 + flt_3C8C0C; - lightmap->pVertices[0].vWorldPosition.y = lightmap->position_y - flt_3C8C1C + flt_3C8C10; - lightmap->pVertices[0].vWorldPosition.z = lightmap->position_z - flt_3C8C20 + flt_3C8C14; + lightmap->pVertices[0].vWorldPosition.x = lightmap->position_x - light_length_x2 + light_length_x; + lightmap->pVertices[0].vWorldPosition.y = lightmap->position_y - light_length_y2 + light_length_y; + lightmap->pVertices[0].vWorldPosition.z = lightmap->position_z - light_length_z2 + light_length_z; lightmap->pVertices[0].u = 0.0; lightmap->pVertices[0].v = 0.0; - lightmap->pVertices[1].vWorldPosition.x = lightmap->position_x - flt_3C8C18 - flt_3C8C0C; - lightmap->pVertices[1].vWorldPosition.y = lightmap->position_y - flt_3C8C1C - flt_3C8C10; - lightmap->pVertices[1].vWorldPosition.z = lightmap->position_z - flt_3C8C20 - flt_3C8C14; + lightmap->pVertices[1].vWorldPosition.x = lightmap->position_x - light_length_x2 - light_length_x; + lightmap->pVertices[1].vWorldPosition.y = lightmap->position_y - light_length_y2 - light_length_y; + lightmap->pVertices[1].vWorldPosition.z = lightmap->position_z - light_length_z2 - light_length_z; lightmap->pVertices[1].u = 0.0; lightmap->pVertices[1].v = 1.0; - lightmap->pVertices[2].vWorldPosition.x = lightmap->position_x + flt_3C8C18 - flt_3C8C0C; - lightmap->pVertices[2].vWorldPosition.y = lightmap->position_y + flt_3C8C1C - flt_3C8C10; - lightmap->pVertices[2].vWorldPosition.z = lightmap->position_z + flt_3C8C20 - flt_3C8C14; + lightmap->pVertices[2].vWorldPosition.x = lightmap->position_x + light_length_x2 - light_length_x; + lightmap->pVertices[2].vWorldPosition.y = lightmap->position_y + light_length_y2 - light_length_y; + lightmap->pVertices[2].vWorldPosition.z = lightmap->position_z + light_length_z2 - light_length_z; lightmap->pVertices[2].u = 1.0; lightmap->pVertices[2].v = 1.0; - lightmap->pVertices[3].vWorldPosition.x = lightmap->position_x + flt_3C8C18 + flt_3C8C0C; - lightmap->pVertices[3].vWorldPosition.y = lightmap->position_y + flt_3C8C1C + flt_3C8C10; - lightmap->pVertices[3].vWorldPosition.z = lightmap->position_z + flt_3C8C20 + flt_3C8C14; + lightmap->pVertices[3].vWorldPosition.x = lightmap->position_x + light_length_x2 + light_length_x; + lightmap->pVertices[3].vWorldPosition.y = lightmap->position_y + light_length_y2 + light_length_y; + lightmap->pVertices[3].vWorldPosition.z = lightmap->position_z + light_length_z2 + light_length_z; lightmap->pVertices[3].u = 1.0; lightmap->pVertices[3].v = 0.0; for (uint i = 0; i < 4; ++i) { - v24 = a7->field_4.y * lightmap->pVertices[i].vWorldPosition.y - + a7->field_4.z * lightmap->pVertices[i].vWorldPosition.z - + a7->field_4.x * lightmap->pVertices[i].vWorldPosition.x + v24 = a7->Normal.y * lightmap->pVertices[i].vWorldPosition.y + + a7->Normal.z * lightmap->pVertices[i].vWorldPosition.z + + a7->Normal.x * lightmap->pVertices[i].vWorldPosition.x + a7->dist; - lightmap->pVertices[i].vWorldPosition.x -= v24 * a7->field_4.x; - lightmap->pVertices[i].vWorldPosition.y -= v24 * a7->field_4.y; - lightmap->pVertices[i].vWorldPosition.z -= v24 * a7->field_4.z; + lightmap->pVertices[i].vWorldPosition.x -= v24 * a7->Normal.x; + lightmap->pVertices[i].vWorldPosition.y -= v24 * a7->Normal.y; + lightmap->pVertices[i].vWorldPosition.z -= v24 * a7->Normal.z; } lightmap->uColorMask = uColorMask; @@ -714,14 +687,14 @@ if (v38 > radius) return true; //radius = (1 / radius) * v38; - if ( uLightType & 4 ) + if ( uLightType & 4 )//LIGHT_ATTR_POINT { - v39 = fabs(a1.x * a7->field_4.x + a1.z * a7->field_4.z + a1.y * a7->field_4.y); + v39 = fabs(a1.x * a7->Normal.x + a1.z * a7->Normal.z + a1.y * a7->Normal.y); v40 = v39 * 1.0 * flt_4D86CC; lightmap->fBrightness = v40 - ((1 / radius) * v38) * v40; } - else if ( uLightType & 8 ) + else if ( uLightType & 8 )//LIGHT_ATTR_SPOTLIGHT { v40 = 1.0 * 1.0; lightmap->fBrightness = v40 - ((1 / radius) * v38); @@ -732,7 +705,7 @@ //Brightness(ÿðêîñòü)///////////////////////////////////////////////////// if (!pEngine->pStru9Instance->_4980B9(a9, uNumVertices, - a7->field_4.x, a7->field_4.y, a7->field_4.z, + a7->Normal.x, a7->Normal.y, a7->Normal.z, lightmap->pVertices, &lightmap->NumVertices)) return false; @@ -747,18 +720,18 @@ pIndoorCameraD3D->Project(lightmap->pVertices, lightmap->NumVertices, 0); unsigned int _a4 = 0; - if ( !(uClipFlag & 1) ) + if ( !(uClipFlag & 1) )//NoClipFlag _a4 = 1; else if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { - if ( uClipFlag & 2 ) + if ( uClipFlag & 2 )//NeerClipFlag { - pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4); + pIndoorCameraD3D->LightmapNeerClip(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4); pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->NumVertices); } - else if ( uClipFlag & 4 ) + else if ( uClipFlag & 4 )//FarClipFlag { - pIndoorCameraD3D->_436F09_mess_with_lightmap__clipflag_4(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4); + pIndoorCameraD3D->LightmapFarClip(lightmap->pVertices, lightmap->NumVertices, field_3C8C34, &_a4); pIndoorCameraD3D->_437143(_a4, lightmap->pVertices, field_3C8C34, &lightmap->NumVertices); } else @@ -771,13 +744,13 @@ { if (uLightType & 1) { - if (std__vector_000004_size < 512 - 1) - ++std__vector_000004_size; + if (StationaryLightsCount < 512 - 1) + ++StationaryLightsCount; } else { - if (std__vector_183808_size < 768 - 1) - ++std__vector_183808_size; + if (MobileLightsCount < 768 - 1) + ++MobileLightsCount; } //if ( v50 ^ v51 ) // *(unsigned int *)v48 = v49 + 1; @@ -786,7 +759,7 @@ } //----- (0045C6D6) -------------------------------------------------------- -int LightmapBuilder::_45C6D6(int a2, RenderVertexSoft *a3, Lightmap *pLightmap) +int LightmapBuilder::_45C6D6(int uNumVertices, RenderVertexSoft *a3, Lightmap *pLightmap) { //For outdoor terrain and indoor light (V)(V) signed int v6; // esi@1 @@ -802,9 +775,9 @@ { for ( uint i = 0; i < (signed int)pLightmap->NumVertices; ++i ) { - if ( a2 > 0 ) + if ( uNumVertices > 0 ) { - for ( uint j = 0; j < a2; ++j ) + for ( uint j = 0; j < uNumVertices; ++j ) { if ( pLightmap->pVertices[i].vWorldPosition.x <= (double)a3[j].vWorldPosition.x ) temp_x = a3[j].vWorldPosition.x - pLightmap->pVertices[i].vWorldPosition.x; @@ -854,13 +827,13 @@ } //----- (0045D74F) -------------------------------------------------------- -bool LightmapBuilder::DrawLightmaps(int *indices) +bool LightmapBuilder::DrawLightmaps(int indices) { //For outdoor terrain and indoor light (VI)(VI) Lightmap *v28; // [sp+50h] [bp-38h]@2 Vec3_float_ arg4; - if (std__vector_000004_size == 0) + if (StationaryLightsCount == 0) return true; if (byte_4D864C && pEngine->uFlags & GAME_FLAGS_1_01_lightmap_related) @@ -871,23 +844,23 @@ arg4.x = 1.0f; arg4.y = 1.0f; arg4.z = 1.0f; - if (indices) + if (lights_flag) { - for (int* i = indices; *i != -1; ++i) - { - __debugbreak();//Not used? - v28 = &std__vector_000004[*i]; - if ( !pRenderer->DrawLightmap(v28, &arg4, 0.0) ) - Error("Invalid lightmap detected! (%u)", *i); - } + if (indices != -1) + { + for (unsigned int i = 0; i < MobileLightsCount; ++i) + { + if ( !pRenderer->DrawLightmap(&MobileLights[i], &arg4, 0.0) ) + Error("Invalid lightmap detected! (%u)", i); + } + } + else + { + for (unsigned int i = 0; i < StationaryLightsCount; ++i) + if ( !pRenderer->DrawLightmap(&StationaryLights[i], &arg4, 0.0) ) + Error("Invalid lightmap detected! (%u)", i); + } } - else - if (for_refactoring) - { - for (unsigned int i = 0; i < std__vector_000004_size; ++i) - if ( !pRenderer->DrawLightmap(std__vector_000004 + i, &arg4, 0.0) ) - Error("Invalid lightmap detected! (%u)", i); - } pRenderer->EndLightmaps(); @@ -955,7 +928,7 @@ void LightmapBuilder::Draw_183808_Lightmaps() { //For outdoor and indoor light (III)(IX) - if (!std__vector_183808_size) + if (!MobileLightsCount) return; pRenderer->BeginLightmaps2(); @@ -968,10 +941,10 @@ ////////////////////////OTHER//////////////////////////////////////////////////////// //----- (0045CA88) -------------------------------------------------------- -int LightmapBuilder::_45CA88(stru320 *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal) +int LightmapBuilder::_45CA88(LightsData *a2, RenderVertexSoft *a3, int a4, Vec3_float_ *pNormal) { int result; // eax@1 - stru320 *v6; // ecx@2 + LightsData *v6; // ecx@2 RenderVertexSoft *v7; // ebx@2 double v8; // st7@2 double v9; // st6@2 @@ -1220,52 +1193,16 @@ // 519AB4: using guessed type int uNumStationaryLightsApplied; //----- (0045D698) -------------------------------------------------------- -bool LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2) +void LightmapBuilder::DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2) { - bool result; // eax@1 - LightmapBuilder *v3; // esi@1 - RenderVertexSoft *v4; // edi@3 - RenderVertexSoft *v5; // edi@7 - IndoorCameraD3D *thisa; // [sp+10h] [bp-8h]@1 - bool v7; // [sp+14h] [bp-4h]@2 - bool a2a; // [sp+20h] [bp+8h]@6 - - __debugbreak();//Not used? - result = (bool)pIndoorCameraD3D; - v3 = this; - thisa = pIndoorCameraD3D; if ( bit_one_for_list1__bit_two_for_list2 & 1 ) { - v7 = 0; - if ( (signed int)this->std__vector_000004_size > 0 ) - { - v4 = this->std__vector_000004[0].pVertices; - do - { - pIndoorCameraD3D->debug_outline_sw(v4, *((unsigned int *)v4 - 1), 0xFF00u, 0.0); - ++v7; - v4 = (RenderVertexSoft *)((char *)v4 + 3100); - result = v7; - } - while ( v7 < (signed int)v3->std__vector_000004_size ); - } + for (int i = 0; i < this->StationaryLightsCount; ++i) + pIndoorCameraD3D->debug_outline_sw(this->StationaryLights[i].pVertices, this->StationaryLights[i].NumVertices, 0xFF00, 0.0f); } if ( bit_one_for_list1__bit_two_for_list2 & 2 ) { - a2a = 0; - if ( (signed int)v3->std__vector_183808_size > 0 ) - { - v5 = v3->std__vector_183808[0].pVertices; - do - { - pIndoorCameraD3D->debug_outline_sw(v5, *((unsigned int *)v5 - 1), 0xC04000u, 0.00019999999); - ++a2a; - v5 = (RenderVertexSoft *)((char *)v5 + 3100); - result = a2a; - } - while ( a2a < (signed int)v3->std__vector_183808_size ); - } + for (uint i = 0; i < this->MobileLightsCount; ++i) + pIndoorCameraD3D->debug_outline_sw(this->MobileLights[i].pVertices, this->MobileLights[i].NumVertices, 0xC04000, 0.00019999999f); } - LOBYTE(result) = 1; - return result; }