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
fix(w3ddevice): keep infantry shadows at every zoom level
Olcay Seygane80b09e30560
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0647e6862..ba4d57400 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,7 +3,7 @@EA released the 2003 source for preservation. It did not compile, did not run, and nobody had touchedthe bugs inside it in twenty-two years. This build compiles, runs and plays.-**122 changes. ~580 engine source files ported. 14 automated test suites. Around 60 original bugs+**121 changes. ~580 engine source files ported. 14 automated test suites. Around 60 original bugsfound and fixed — EA's own, not port damage.**---@@ -610,7 +610,6 @@ found and fixed — EA's own, not port damage.**## Soldiers cast real shadows- Infantry shadows are built from the pose: arms, head, weapon, moving with him.-- A crowd of infantry no longer rebuilds a posed shadow for every man too small to make out. Zoom in and the pose is still there.- `UseShadowVolumesForSkins = No` puts the old flat blobs back.- Scuds, rockets and falling bombs cast a shadow running along the ground.- A big smoke cloud darkens the ground under it and fades as it does.@@ -979,6 +978,9 @@ found and fixed — EA's own, not port damage.**shadow trees have now is the opposite trick, and cost about thirty lines: the batch of trianglesthe trees are already drawn from, drawn a second time with the tree laid flat on its own base andslid along the sun. The shape comes free because it is the same triangles and the same texture.+- Soldiers used to drop their posed shadow once the camera pulled far enough back to make each man a+ few pixels tall. It saved frame time in a big crowd and it made the army look flat at the zoom+ most games are played at, so it came out again: every soldier on screen keeps his shadow.- The six-rung difficulty ladder is back down to three. The three extra rungs were built, played and taken out again: a player picks a level once and wants to know what it means, and six names that each moved one switch was a worse answer to that than three that each describe an opponent. The machinery underneath is the same, so the levels are still tunable in the data files, and Brutal kept the top rung's numbers rather than the old Brutal ones.- The three-piece command bar was reverted once, for having nowhere to put the painting of the bar, and is back now that the painting has been cut into three to match. Each piece is fitted by matching it against the artwork it was cut from rather than by eye: the eyeballed fit was four percent out, which nobody sees on the metal and everybody sees on the money readout.- The opponent's decisions are argued with a number: 20 headless matches per change, same seeds, win rate and match length before and after.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.hindex 096ad72ad..da604f84b 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h@@ -65,16 +65,6 @@ static const char* TheShadowNames[] =#define MAX_SHADOW_LIGHTS 1 //maximum number of shadow casting light sources in scene - support for more than 1 has been dropped from most code.-// A posed skin volume whose bounding sphere is smaller than this many pixels-// on screen is not rebuilt or drawn that frame. Zoom in and it comes back.-enum { SHADOW_SKIN_VOLUME_MIN_SCREEN_RADIUS = 20 };--inline Bool Shadow_skinVolumeLargeEnoughOnScreen( Int dx, Int dy )-{- return ( dx * dx + dy * dy ) >=- SHADOW_SKIN_VOLUME_MIN_SCREEN_RADIUS * SHADOW_SKIN_VOLUME_MIN_SCREEN_RADIUS;-}-class RenderObjClass; //forward referenceclass RenderCost; //forward referencediff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cppindex cae58e5f7..918c2da8e 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp@@ -59,7 +59,6 @@#include "GameLogic/TerrainLogic.h"#include "WW3D2/DX8Caps.h"#include "GameClient/Drawable.h"-#include "GameClient/View.h"#include "wwshade/shdmesh.h"#include "wwshade/shdsubmesh.h"@@ -370,7 +369,6 @@ protected:return m_verts[dwVertId];}-public:Bool isSkin (void) const { return m_isSkin;}Int getNumSourceVerts (void) const { return m_numSourceVerts;}/**Point the vertex and face normal accessors at externally owned, per-frame data. Used while a@@ -1987,36 +1985,6 @@ void W3DVolumetricShadow::SetGeometry( W3DShadowGeometry *geometry )} // end SetGeometry-static Bool geometryHasSkinMesh( W3DShadowGeometry *geometry )-{- if( geometry == NULL )- return FALSE;- Int n = geometry->getMeshCount();- for( Int i = 0; i < n; ++i )- if( geometry->getMesh( i )->isSkin() )- return TRUE;- return FALSE;-}--static Bool skinCasterLargeEnoughOnScreen( RenderObjClass *robj )-{- if( robj == NULL || TheTacticalView == NULL )- return TRUE;-- const SphereClass &sphere = robj->Get_Bounding_Sphere();- Coord3D p;- p.x = sphere.Center.X;- p.y = sphere.Center.Y;- p.z = sphere.Center.Z;- ICoord2D s0, s1;- if( !TheTacticalView->worldToScreen( &p, &s0 ) )- return FALSE;- p.x += sphere.Radius;- if( !TheTacticalView->worldToScreen( &p, &s1 ) )- return TRUE;- return Shadow_skinVolumeLargeEnoughOnScreen( s1.x - s0.x, s1.y - s0.y );-}-/**Called once per frame for each object, when necessary it will reconstructthe shadow volume for this shadow from the silhouette of the geometryand any light sources@@ -2033,12 +2001,6 @@ void W3DVolumetricShadow::Update()if( m_geometry == NULL)return;- // Infantry at max zoom are a few pixels; rebuilding a posed volume for- // each of a thousand of them is the frame. The pose is still there when- // the caster is large enough to see it.- if( geometryHasSkinMesh( m_geometry ) && !skinCasterLargeEnoughOnScreen( m_robj ) )- return;-//// for now we will just rebuild a shadow volume every so often, this// should be changed to be built only when the light angle sufficientlydiff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 936d6f33a..c8c119b58 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -10910,21 +10910,6 @@ TEST(build_placement_preview_defaults_are_the_ones_the_game_always_used)delete scratch;}-//--------------------------------------------------------------------------------------------------// A posed skin volume smaller than this on screen is not rebuilt that frame. The threshold is-// the shipped contract: 20 pixels of radius is still drawn, 19 is not.-//--------------------------------------------------------------------------------------------------TEST(skin_volume_screen_lod_keeps_readable_shadows)-{- CHECK( Shadow_skinVolumeLargeEnoughOnScreen( SHADOW_SKIN_VOLUME_MIN_SCREEN_RADIUS, 0 ) );- CHECK( Shadow_skinVolumeLargeEnoughOnScreen( 0, SHADOW_SKIN_VOLUME_MIN_SCREEN_RADIUS ) );- CHECK( !Shadow_skinVolumeLargeEnoughOnScreen( SHADOW_SKIN_VOLUME_MIN_SCREEN_RADIUS - 1, 0 ) );- CHECK( !Shadow_skinVolumeLargeEnoughOnScreen( 0, 0 ) );- // 16^2 + 12^2 = 400, which is exactly the 20-pixel radius- CHECK( Shadow_skinVolumeLargeEnoughOnScreen( 16, 12 ) );- CHECK( !Shadow_skinVolumeLargeEnoughOnScreen( 15, 12 ) );-}-//-------------------------------------------------------------------------------------------------// A map name with a non-ASCII byte in it reaches isalnum as a negative number, which is undefined// and is what the CRT asserted on while building the map cache. Every byte over 127 has to encode,