# HG changeset patch
# User Ritor1
# Date 1432211587 -21600
# Node ID d433439699beeb9a9af61b66b899f41f6fd8dc6d
# Parent f2f2595fe308f9efad12359504e47f8edc25dd25# Parent d569340b05ff9b66ec72cf58006023cefc9ca08b
Слияние
diff -r d569340b05ff -r d433439699be Build/Visual Studio 2012/World of Might and Magic.vcxproj
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj Thu May 21 01:50:59 2015 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj Thu May 21 18:33:07 2015 +0600
@@ -138,6 +138,7 @@
+
@@ -316,6 +317,7 @@
+
diff -r d569340b05ff -r d433439699be Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters
--- a/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Thu May 21 01:50:59 2015 +0200
+++ b/Build/Visual Studio 2012/World of Might and Magic.vcxproj.filters Thu May 21 18:33:07 2015 +0600
@@ -112,6 +112,9 @@
{6dd9bc0c-a6d9-40ea-9eb9-d0f38abd514b}
+
+ {19f2f2d9-edc3-4289-a610-8841b0d22b39}
+
@@ -613,6 +616,9 @@
Game
+
+ Engine\Serialization
+
@@ -1393,6 +1399,9 @@
Game
+
+ Engine\Serialization
+
diff -r d569340b05ff -r d433439699be Engine/Engine.cpp
--- a/Engine/Engine.cpp Thu May 21 01:50:59 2015 +0200
+++ b/Engine/Engine.cpp Thu May 21 18:33:07 2015 +0600
@@ -462,8 +462,8 @@
PickMouse(depth, cursor.x, cursor.y, false, v10, v11);
pLightmapBuilder->StationaryLightsCount = 0;
pLightmapBuilder->MobileLightsCount = 0;
- pDecalBuilder->std__vector_pDecals_size = 0;
- pDecalBuilder->field_308008 = 0;
+ pDecalBuilder->DecalsCount = 0;
+ pDecalBuilder->curent_decal_id = 0;
if (!_44F07B())
return false;
@@ -548,7 +548,7 @@
if (/*uFlags & 0x04*/ debug_lights)
{
pLightmapBuilder->DrawDebugOutlines(-1);
- //pDecalBuilder->DrawDecalDebugOutlines();
+ pDecalBuilder->DrawDecalDebugOutlines();
}
return true;
}
diff -r d569340b05ff -r d433439699be Engine/Graphics/DecalBuilder.cpp
--- a/Engine/Graphics/DecalBuilder.cpp Thu May 21 01:50:59 2015 +0200
+++ b/Engine/Graphics/DecalBuilder.cpp Thu May 21 18:33:07 2015 +0600
@@ -86,7 +86,7 @@
pBloodsplatContainer->std__vector_pBloodsplats_size = 0;
pBloodsplatContainer->uNumBloodsplats = 0;
}
- std__vector_pDecals_size = 0;
+ DecalsCount = 0;
}
//----- (0049B540) --------------------------------------------------------
@@ -218,13 +218,13 @@
unsigned int a8b = 0;
- if ( a6 == 0.0 )
+ if ( a6 == 0.0f )
return 1;
- decal = &this->std__vector_pDecals[this->field_308008];
- this->std__vector_pDecals[this->field_308008].field_C18 = (DecalBuilder_stru0 *)blood;
- this->std__vector_pDecals[this->field_308008].field_C1C = 0;
+ decal = &this->Decals[this->curent_decal_id];
+ this->Decals[this->curent_decal_id].field_C18 = (DecalBuilder_stru0 *)blood;
+ this->Decals[this->curent_decal_id].field_C1C = 0;
if ( a3 & 2 )
- this->std__vector_pDecals[this->field_308008].field_C1C = 1;
+ this->Decals[this->curent_decal_id].field_C1C = 1;
this->field_30C028 = a6 - a8;
this->field_30C02C = sqrt((a6 + a6 - this->field_30C028) * this->field_30C028);
@@ -289,13 +289,13 @@
pIndoorCameraD3D->Project(decal->pVertices, decal->uNumVertices, 0);
if ( !(uClipFlags & 1) )
{
- ++this->field_308008;
+ ++this->curent_decal_id;
v34 = 1024;
- if ( this->field_308008 == 1024 )
- this->field_308008 = 0;
- if ( (signed int)(this->std__vector_pDecals_size + 1) <= 1024 )
- v34 = this->std__vector_pDecals_size + 1;
- this->std__vector_pDecals_size = v34;
+ if ( this->curent_decal_id == 1024 )
+ this->curent_decal_id = 0;
+ if ( (signed int)(this->DecalsCount + 1) <= 1024 )
+ v34 = this->DecalsCount + 1;
+ this->DecalsCount = v34;
return 1;
}
if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor )
@@ -317,13 +317,13 @@
MessageBoxA(nullptr, "Lightpoly builder native indoor clipping not implemented", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\PolyProjector.cpp:263", 0);
if ( a8b != 0 )
{
- ++this->field_308008;
+ ++this->curent_decal_id;
v34 = 1024;
- if ( this->field_308008 == 1024 )
- this->field_308008 = 0;
- if ( (signed int)(this->std__vector_pDecals_size + 1) <= 1024 )
- v34 = this->std__vector_pDecals_size + 1;
- this->std__vector_pDecals_size = v34;
+ if ( this->curent_decal_id == 1024 )
+ this->curent_decal_id = 0;
+ if ( (signed int)(this->DecalsCount + 1) <= 1024 )
+ v34 = this->DecalsCount + 1;
+ this->DecalsCount = v34;
return 1;
}
result = 1;
@@ -537,14 +537,14 @@
//----- (0049C2CD) --------------------------------------------------------
void DecalBuilder::DrawDecals(float z_bias)
{
- for (uint i = 0; i < std__vector_pDecals_size; ++i)
- pRenderer->DrawDecal(std__vector_pDecals + i, z_bias);
+ for (uint i = 0; i < DecalsCount; ++i)
+ pRenderer->DrawDecal(&Decals[i], z_bias);
}
//----- (0049C304) --------------------------------------------------------
void DecalBuilder::DrawBloodsplats()
{
- if (!std__vector_pDecals_size)
+ if (!DecalsCount)
return;
pRenderer->BeginDecals();
@@ -557,8 +557,8 @@
//----- (0049C550) --------------------------------------------------------
void DecalBuilder::DrawDecalDebugOutlines()
{
- for(int i = 0; i < std__vector_pDecals_size; i++)
- pIndoorCameraD3D->debug_outline_sw(std__vector_pDecals[i].pVertices, std__vector_pDecals[i].uNumVertices, 0xC86400u, 0.0);
+ for(int i = 0; i < DecalsCount; i++)
+ pIndoorCameraD3D->debug_outline_sw(Decals[i].pVertices, Decals[i].uNumVertices, 0xC86400u, 0.0f);
}
//----- (0040E4C2) --------------------------------------------------------
diff -r d569340b05ff -r d433439699be Engine/Graphics/DecalBuilder.h
--- a/Engine/Graphics/DecalBuilder.h Thu May 21 01:50:59 2015 +0200
+++ b/Engine/Graphics/DecalBuilder.h Thu May 21 18:33:07 2015 +0600
@@ -137,27 +137,12 @@
//----- (0049B408) --------------------------------------------------------
DecalBuilder()
{
- char *v2; // eax@1
- signed int v3; // ecx@1
-
- DecalBuilder* v1 = this;
- /*_eh_vector_constructor_iterator_(
- this->std__vector_pDecals,
- 3104,
- 1024,
- (void ( *)(void *))Decal::Decal,
- (void ( *)(void *))Decal::dtor);*/
- v1->std__vector_pDecals_size = 0;
- v1->field_308008 = 0;
- v2 = (char *)&v1->pVertices[0].flt_2C;
- v3 = 256;
- do
- {
- *(float *)v2 = 0.0;
- v2 += 48;
- --v3;
- }
- while ( v3 );
+ this->DecalsCount = 0;
+ this->curent_decal_id = 0;
+ for (uint i = 0; i < 256; ++i)
+ {
+ this->pVertices[i].flt_2C = 0.0f;
+ }
}
//----- (0049B471) --------------------------------------------------------
@@ -179,9 +164,9 @@
//void ( ***vdestructor_ptr)(DecalBuilder *, bool);
- Decal std__vector_pDecals[1024];
- unsigned int std__vector_pDecals_size;
- int field_308008;
+ Decal Decals[1024];
+ unsigned int DecalsCount;
+ int curent_decal_id;//field_308008
RenderVertexSoft pVertices[256];
int std__vector_30B00C[1024];
int uNumDecals;
diff -r d569340b05ff -r d433439699be Engine/Graphics/LightmapBuilder.cpp
--- a/Engine/Graphics/LightmapBuilder.cpp Thu May 21 01:50:59 2015 +0200
+++ b/Engine/Graphics/LightmapBuilder.cpp Thu May 21 18:33:07 2015 +0600
@@ -65,13 +65,13 @@
{
if ( pSlot >= 20 )
break;
- ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, 1);
+ ApplyLight_ODM((StationaryLight *)pMobileLightsStack[i].pLights, pFace, (unsigned int *)&pSlot, true);
}
for ( uint i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i )
{
if ( pSlot >= 20 )
break;
- ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, 0);
+ ApplyLight_ODM(&pStationaryLightsStack->pLights[i], pFace, (unsigned int *)&pSlot, false);
}
result = pSlot;
Lights.uNumLightsApplied = pSlot;
@@ -79,7 +79,7 @@
}
//----- (0045D0D5) --------------------------------------------------------
-bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *a3, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot)
+bool LightmapBuilder::StackLight_TerrainFace(StationaryLight *pLight, Vec3_float_ *pNormal, float *light_tile_dist, RenderVertexSoft *TerrainVertices, unsigned int uStripType, int X, unsigned int *pSlot)
{
//For outdoor terrain light (II)
bool result; // eax@1
@@ -108,11 +108,11 @@
return false;
if ( uStripType == 4 )
{
- tX_0 = TerrainVertices[0].vWorldPosition.x;
- tX_1 = TerrainVertices[3].vWorldPosition.x;
+ tX_0 = TerrainVertices[0].vWorldPosition.x;
+ tX_1 = TerrainVertices[3].vWorldPosition.x;
- tY_0 = TerrainVertices[1].vWorldPosition.y;
- tY_1 = TerrainVertices[0].vWorldPosition.y;
+ tY_0 = TerrainVertices[1].vWorldPosition.y;
+ tY_1 = TerrainVertices[0].vWorldPosition.y;
}
else if(uStripType == 3)
{
@@ -153,10 +153,10 @@
|| (float)pLight->vPosition.z <= bounding_z1 || (float)pLight->vPosition.z >= bounding_z2 )
return false;
- Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, a3);
+ Vec3_float_::NegDot(&TerrainVertices->vWorldPosition, pNormal, light_tile_dist);
float p_dot = ((float)pLight->vPosition.x * pNormal->x
+ (float)pLight->vPosition.y * pNormal->y
- + (float)pLight->vPosition.z * pNormal->z + *a3)+0.5f;
+ + (float)pLight->vPosition.z * pNormal->z + *light_tile_dist)+0.5f;
if ( p_dot > pLight->uRadius )
return false;
@@ -193,52 +193,53 @@
}
//----- (0045CE50) --------------------------------------------------------
-bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, char a4)
+bool LightmapBuilder::ApplyLight_ODM(StationaryLight *pLight, ODMFace *pFace, unsigned int *pSlot, bool bLightBackfaces)
{
//For outdoor light (IV)
int result; // eax@0
- int v10; // ecx@8
+ double v10; // ecx@8
char v14; // dl@11
- v10 = (pFace->pFacePlane.dist
- + pLight->vPosition.x * pFace->pFacePlane.vNormal.x
- + pLight->vPosition.y * pFace->pFacePlane.vNormal.y
- + pLight->vPosition.z * pFace->pFacePlane.vNormal.z) >> 16;
- if ( pLight->uRadius > 0
- && (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2
+ if (!pLight->uRadius)
+ return false;
+
+ if ( (pLight->vPosition.x > pFace->pBoundingBox.x1 - pLight->uRadius) && pLight->vPosition.x < pLight->uRadius + pFace->pBoundingBox.x2
&& (pLight->vPosition.y > pFace->pBoundingBox.y1 - pLight->uRadius) && pLight->vPosition.y < pLight->uRadius + pFace->pBoundingBox.y2
- && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2
- && ((a4) || v10 >= 0) && v10 <= pLight->uRadius )
+ && (pLight->vPosition.z > pFace->pBoundingBox.z1 - pLight->uRadius) && pLight->vPosition.z < pLight->uRadius + pFace->pBoundingBox.z2)
{
- 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;
- Lights._blv_lights_light_dot_faces[*pSlot] = abs(v10);
- Lights._blv_lights_types[*pSlot] = pLight->uLightType;
- //v13 = pRenderer->pRenderD3D;
- v14 = Lights._blv_lights_types[*pSlot];
- if ( /*pRenderer->pRenderD3D &&*/ pRenderer->bUsingSpecular && v14 & 4 )
- v14 = _4E94D2_light_type;
- Lights._blv_lights_types[*pSlot] = v14;
- result = 4 * *pSlot;
- if ( /*v13*/true && pRenderer->bUsingSpecular )
- {
- if ( Lights._blv_lights_types[*pSlot] & 4 )
- {
- *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result)
- * 0.33000001;
- *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result)
- * 0.33000001;
- *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result)
- * 0.33000001;
- }
+ v10 = (double)(pLight->vPosition.x * pFace->pFacePlane.vNormal.x
+ + pLight->vPosition.y * pFace->pFacePlane.vNormal.y
+ + pLight->vPosition.z * pFace->pFacePlane.vNormal.z + pFace->pFacePlane.dist);
+ if(((bLightBackfaces) || v10 >= 0.0f) && fabsf(v10) <= pLight->uRadius)
+ {
+ 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 / 255.0f;
+ Lights._blv_lights_gs[*pSlot] = (double)pLight->uLightColorG / 255.0f;
+ Lights._blv_lights_bs[*pSlot] = (double)pLight->uLightColorB / 255.0f;
+ Lights._blv_lights_light_dot_faces[*pSlot] = abs((int)floorf(v10 + 0.5f));
+ Lights._blv_lights_types[*pSlot] = pLight->uLightType;
+ v14 = Lights._blv_lights_types[*pSlot];
+ if ( pRenderer->bUsingSpecular && Lights._blv_lights_types[*pSlot] & 4 )
+ v14 = _4E94D2_light_type;
+ Lights._blv_lights_types[*pSlot] = v14;
+ result = 4 * *pSlot;
+ if ( pRenderer->bUsingSpecular )
+ {
+ __debugbreak();
+ if ( Lights._blv_lights_types[*pSlot] & 4 )
+ {
+ *(float *)((char *)Lights._blv_lights_rs + result) = *(float *)((char *)Lights._blv_lights_rs + result)
+ * 0.33000001;
+ *(float *)((char *)Lights._blv_lights_gs + result) = *(float *)((char *)Lights._blv_lights_gs + result)
+ * 0.33000001;
+ *(float *)((char *)Lights._blv_lights_bs + result) = *(float *)((char *)Lights._blv_lights_bs + result)
+ * 0.33000001;
+ }
+ }
}
++*pSlot;
return true;
@@ -264,7 +265,7 @@
if (uNumLightsApplied >= 20)
break;
- ApplyLight_BLV((StationaryLight *)(pMobileLightsStack->pLights + i), pFace, &uNumLightsApplied, true, 0);
+ ApplyLight_BLV((StationaryLight *)&pMobileLightsStack->pLights[i], pFace, &uNumLightsApplied, true, 0);
}
for (uint i = 0; i < pSector->uNumLights; ++i)
@@ -282,7 +283,7 @@
if (uNumLightsApplied >= 20)
break;
- ApplyLight_BLV(pStationaryLightsStack->pLights + i, pFace, &uNumLightsApplied, false, &_4E94D0_light_type);
+ ApplyLight_BLV(&pStationaryLightsStack->pLights[i], pFace, &uNumLightsApplied, false, &_4E94D0_light_type);
}
Lights.uNumLightsApplied = uNumLightsApplied;
diff -r d569340b05ff -r d433439699be Engine/Graphics/LightmapBuilder.h
--- a/Engine/Graphics/LightmapBuilder.h Thu May 21 01:50:59 2015 +0200
+++ b/Engine/Graphics/LightmapBuilder.h Thu May 21 18:33:07 2015 +0600
@@ -46,7 +46,7 @@
//bool _45D3C7_sw(struct Polygon *a1);
bool StackLight_TerrainFace(struct StationaryLight *pLight, struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot);
bool StackLights_TerrainFace(struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces);
- bool ApplyLight_ODM(struct StationaryLight *pLight, struct ODMFace *pFace, unsigned int *pSlot, char a4);
+ bool ApplyLight_ODM(struct StationaryLight *pLight, struct ODMFace *pFace, unsigned int *pSlot, bool bLightBackfaces);
bool ApplyLights_OutdoorFace(struct ODMFace *pFace);
double _45CC0C_light(struct Vec3_float_ a1, float a2, float a3, struct Vec3_float_ *pNormal, float a5, int uLightType);
int _45CBD4(struct RenderVertexSoft *a2, int a3, int *a4, int *a5);