Skip to content

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.

feat(gameengine): ground vehicles turn faster and roll through bends

Olcay Seygan3a631e3b6bf0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9b8af0092..6f3fb8f57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -72,7 +72,7 @@ found and fixed, EA's own, not port damage.**
- A first start now opens the game EA shipped: its own textures and ground, the hard stencil shadows, the flat 2003 light, no glow, bilinear filtering, the original sound mix, health bars only on what you select or point at. The HD art stays on your disk, unmounted. Every setting this build added to the picture, the sound and the controls starts off, and each one is a box in Options.
- One click brings the other game back. Options, Graphics, untick Classic Graphics: the High preset fills in every Reforged box on the page, you can move the quality slider from there, and Accept saves it for the next start. Tick it again and the same boxes go off.
- Defaults in Options now means this game too. It used to leave every setting this build added where you had put it, so a Reforged page stayed Reforged after the click. Now it ticks Classic Graphics and puts every row back where a first start has it, the controls and the sound included. Your language, window mode and resolution stay, and unticking the box still gives you High.
-- Classic now means EA's picture in a fight too, checked side by side against the real 2003 game on this machine. Every explosion, every muzzle flash and all the black smoke this build retuned goes back to EA's own numbers under Classic: 132 effect lists and 235 particle systems stand as shipped, and the 51 particle systems this build invented draw nothing. So do the slow water, the eased hull turn, tank barrels that tilt to the target and the grade insignia on units, which return to the three chevrons, and a match opens at EA's camera height. Tick off Classic and Reforged has all of it, down to the pixel. Two players on different looks still share a match, and we ran one 3000 frames with no mismatch.
+- Classic now means EA's picture in a fight too, checked side by side against the real 2003 game on this machine. Every explosion, every muzzle flash and all the black smoke this build retuned goes back to EA's own numbers under Classic: 132 effect lists and 235 particle systems stand as shipped, and the 51 particle systems this build invented draw nothing. So do the slow water, tank barrels that tilt to the target and the grade insignia on units, which return to the three chevrons, and a match opens at EA's camera height. Tick off Classic and Reforged has all of it, down to the pixel. Two players on different looks still share a match, and we ran one 3000 frames with no mismatch.
- Classic was the slower look in a big fight, and the picture never asked for that. Every explosion's light tested every patch of ground for every light on the map, and each shadow was copied a second time for a graphics device that draws nothing. Both are gone and the picture is the same. In a late 8-player match the drawing behind one frame falls from 9.6 ms to 5.4 ms, and the slowest frame in a thousand from 21.25 ms to 17.75 ms.
- The Performance / Quality slider stopped short of this version's own looks: you had to find each box by hand. Now it reaches all nine. One stop past High brings tone mapping, the sky and ground light, ambient occlusion and water splashes, the next adds battle marks and weather, and Ultra adds firelight, atmosphere and collapsing buildings. All nine together cost 1.4 ms of graphics card time a frame on an RTX 2060 in our chaos fight, 9.36 against 7.99. High is the picture it always was, and under Classic Graphics the slider leaves every one of them off at any stop. Firelight, atmosphere and collapsing buildings carry known faults, a stall, a black smear at a flat camera and a hitch, which is why they wait for Ultra.
- The launcher's Options page has the same slider, with every new box beside it. Move it there or in the game and each opens on what the other saved.
@@ -486,8 +486,9 @@ found and fixed, EA's own, not port damage.**
## Tanks and cars move as they did in Zero Hour
-- Players said the Humvee drove nothing like the original and the Dragon Tank crawled, and they were right. Since October every tank, car and bike had eased up to speed over a second, braked early for each stop and bend and backed up to a spot behind it, and even with a quarter more acceleration and turn rate on top it lost to Zero Hour over any distance. Tanks, cars and bikes drive on EA's own code and EA's own numbers again. Sent 300 east, a Crusader arrives in 9.7 seconds where it took 10.3. Sent 300 on a diagonal it arrives in 7.0 where it took 10.2, because EA measured a vehicle's speed in a way that let it run 41% faster at 45 degrees, and players have planned their raids on that since 2003, so it stays. A Humvee covers the same diagonal in 3.6 seconds instead of 5.6 and a Scorpion in 5.3 instead of 7.9. Start, stop, turns and the pivot on the spot are Zero Hour's to the frame, and a car still gains one or two frames on a short hop by sliding onto its spot a frame sooner. Soldiers keep their true speed at every heading.
-- They still look driven. The hull swings into a turn and settles out of it a few frames behind the tank's real heading, so a pivot no longer starts and stops dead, while the turret stays on its target. The squat as a tank pulls away, the dip when it brakes, the suspension and the moving treads are all still there, and none of it moves the tank by a step. Tanks keep firing on the move.
+- Players said the Humvee drove nothing like the original and the Dragon Tank crawled, and they were right. Since October every tank, car and bike had eased up to speed over a second, braked early for each stop and bend and backed up to a spot behind it, and even with a quarter more acceleration and turn rate on top it lost to Zero Hour over any distance. Tanks, cars and bikes drive on EA's own code and EA's own numbers again. Sent 300 east, a Crusader arrives in 9.7 seconds where it took 10.3. Sent 300 on a diagonal it arrives in 7.0 where it took 10.2, because EA measured a vehicle's speed in a way that let it run 41% faster at 45 degrees, and players have planned their raids on that since 2003, so it stays. A Humvee covers the same diagonal in 3.6 seconds instead of 5.6 and a Scorpion in 5.3 instead of 7.9. Start and stop are Zero Hour's to the frame, and a car still gains one or two frames on a short hop by sliding onto its spot a frame sooner. Soldiers keep their true speed at every heading.
+- Turning is the one place they beat Zero Hour. Every vehicle on the ground swings round half as fast again as it used to and no healthy one turns slower than 100 degrees a second, a damaged one still slower than that by the same share as before, so a Crusader comes about at 270 degrees a second where it managed 180, and an Overlord reverses its heading in 1.8 seconds instead of 3. A tank sent somewhere more than 45 degrees off its nose used to stop dead and pivot on the spot first. Now it rolls through the turn, slower the tighter it is, and stands to pivot only for a hairpin past 135 degrees. Jets and helicopters taxiing on the ground turn as they did. Replays recorded before this change play back differently.
+- What you see points where the tank points. Reforged's picture used to swing the hull into a turn up to 15 degrees and 83 milliseconds behind where the tank was really heading, so a fast turn looked mushy and a shot seemed to leave a hull still coming round. The hull now follows its real heading in every graphics mode, and the turret stays on its target. They still look driven: the squat as a tank pulls away, the dip when it brakes, the suspension and the moving treads are all still there, and none of it moves the tank by a step. Tanks keep firing on the move.
- Columns get there sooner and bump each other less. EA's tanks stop dead, so a tank behind another now stops a short gap back instead of nosing into its tail. Over four runs each of a column through the streets of Alpine Assault, twenty Crusaders over the Golden Oasis bridge and nineteen tanks down the ramps of a generated map, the average tank arrived about a tenth sooner than before, 74 of the 80 Crusaders made it over the bridge where 67 had, and tanks spent fewer moments shoving the one ahead or wedged against it in every one of the three.
- Replays recorded before this change play back differently, and this version cannot join a game hosted on an older one.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
index b0365900d..1c2b7a9b5 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
@@ -208,11 +208,6 @@ public:
Real m_groundPitch; ///< a ground vehicle's chassis pitch, roll and lift from that frame, drawn until the next one
Real m_groundRoll;
Real m_groundZ;
- Real m_headingLag; ///< a ground vehicle's drawn heading minus its logic heading, sprung back towards 0
- Real m_headingLagRate; ///< and how fast that changes, a logic frame
- Real m_headingLogic; ///< the logic heading on m_headingFrame
- UnsignedInt m_headingFrame; ///< the logic frame the heading spring last stepped on
- Bool m_headingSeeded; ///< m_headingLogic and m_headingFrame hold a real heading and frame
TWheelInfo m_wheelInfo; ///< Wheel offset & angle info for a wheeled type locomotor.
DrawableLocoInfo();
@@ -631,8 +626,6 @@ public:
const TWheelInfo *getWheelInfo(void) const { return m_locoInfo ? &m_locoInfo->m_wheelInfo : NULL; }
const DrawableLocoInfo *getLocoInfo() const { return m_locoInfo; }
- /// how far the drawn hull of a tank or car trails its logic heading (calcPhysicsXformGround), 0 for anything else
- Real getDrawnHeadingLag() const { return m_locoInfo ? m_locoInfo->m_headingLag : 0.0f; }
// this method must ONLY be called from the client, NEVER From the logic, not even indirectly.
Bool clientOnly_getFirstRenderObjInfo(Coord3D* pos, Real* boundingSphereRadius, Matrix3D* transform);
@@ -790,9 +783,8 @@ protected:
Real m_totalRoll; ///< Current total roll for this frame.
Real m_totalYaw; ///< Current total yaw for this frame
Real m_totalZ;
- Real m_headingYaw; ///< a ground vehicle's heading lag, turned before the pitch and roll
- PhysicsXformInfo() : m_totalPitch(0), m_totalRoll(0), m_totalYaw(0), m_totalZ(0), m_headingYaw(0) { }
+ PhysicsXformInfo() : m_totalPitch(0), m_totalRoll(0), m_totalYaw(0), m_totalZ(0) { }
};
Bool calcPhysicsXform(PhysicsXformInfo& info);
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
index c45e6cfaa..55dc9cf74 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
@@ -253,7 +253,8 @@ public:
Bool locoUpdate_maintainCurrentPosition(Object* obj);
Real getMaxSpeedForCondition(BodyDamageType condition) const; ///< get max speed given condition
- Real getMaxTurnRate(BodyDamageType condition) const; ///< get max turning rate given condition
+ /// get max turning rate given condition; given its owner, a tank, car or bike turns faster than its TurnRate
+ Real getMaxTurnRate(BodyDamageType condition, const Object* obj = NULL) const;
Real getMaxAcceleration(BodyDamageType condition) const; ///< get acceleration given condition
Real getMaxLift(BodyDamageType condition) const; ///< get acceleration given condition
Real getBraking() const; ///< get braking given condition
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
index fea643bbb..20443440a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
@@ -242,11 +242,6 @@ DrawableLocoInfo::DrawableLocoInfo()
m_groundPitch = 0.0f;
m_groundRoll = 0.0f;
m_groundZ = 0.0f;
- m_headingLag = 0.0f;
- m_headingLagRate = 0.0f;
- m_headingLogic = 0.0f;
- m_headingFrame = 0;
- m_headingSeeded = FALSE;
}
// ------------------------------------------------------------------------------------------------
@@ -1766,17 +1761,11 @@ void Drawable::applyPhysicsXform(Matrix3D* mtx)
Bool frozen = TheTacticalView->isTimeFrozen() && !TheTacticalView->isCameraMovementFinished();
frozen = frozen || TheScriptEngine->isTimeFrozenDebug() || TheScriptEngine->isTimeFrozenScript();
if( !obj || obj->isDisabledByType( DISABLED_HELD ) || !TheGlobalData->m_showClientPhysics || frozen )
- {
- // drawn on its logic heading, which is what the turret is drawn against (getDrawnHeadingLag)
- if (m_locoInfo)
- m_locoInfo->m_headingLag = 0.0f;
return;
- }
PhysicsXformInfo info;
if (calcPhysicsXform(info))
{
mtx->Translate(0.0f, 0.0f, info.m_totalZ);
- mtx->Rotate_Z( info.m_headingYaw );
mtx->Rotate_Y( info.m_totalPitch );
mtx->Rotate_X( -info.m_totalRoll );
mtx->Rotate_Z( info.m_totalYaw );
@@ -1791,7 +1780,6 @@ Bool Drawable::calcPhysicsXform(PhysicsXformInfo& info)
const Object* obj = getObject();
const AIUpdateInterface *ai = obj ? obj->getAIUpdateInterface() : NULL;
Bool hasPhysicsXform = false;
- Bool ground = false;
if (ai)
{
const Locomotor *locomotor = ai->getCurLocomotor();
@@ -1804,7 +1792,6 @@ Bool Drawable::calcPhysicsXform(PhysicsXformInfo& info)
case LOCO_TREADS:
calcPhysicsXformGround(locomotor, info);
hasPhysicsXform = true;
- ground = true;
break;
case LOCO_HOVER:
case LOCO_WINGS:
@@ -1818,9 +1805,6 @@ Bool Drawable::calcPhysicsXform(PhysicsXformInfo& info)
}
}
}
- // off its ground locomotor the hull is drawn on its logic heading, and so is its turret
- if (!ground && m_locoInfo)
- m_locoInfo->m_headingLag = 0.0f;
if (hasPhysicsXform)
{
@@ -2226,12 +2210,7 @@ void Drawable::calcPhysicsXformHoverOrWings( const Locomotor *locomotor, Physics
* has gone by about half a second, and a slower pull away leans less for longer. That one frame
* start is how a tank or car pulls away again (Locomotor::isGroundVehicle), so the share of top
* speed and of the turn is held to one: a diagonal start, at up to 1.41 times Speed, or a shove
- * leans no further than a straight start.
- *
- * The drawn heading of a tank or car trails the logic one through a critically damped spring,
- * HEADING_LAG_FRAMES behind on a steady turn, so EA's pivot, which starts and stops dead at full
- * TurnRate, swings the hull up to speed and settles it. It is the picture only: the turret is drawn
- * against the logic heading (W3DModelDraw::handleClientTurretPositioning). */
+ * leans no further than a straight start. */
//-------------------------------------------------------------------------------------------------
void Drawable::calcPhysicsXformGround( const Locomotor *locomotor, PhysicsXformInfo& info )
{
@@ -2242,49 +2221,12 @@ void Drawable::calcPhysicsXformGround( const Locomotor *locomotor, PhysicsXformI
const Real LEAN_EASE_FRAMES = 3.0f; // each of the three smoothing stages, in retail frames
const Real START_GAIN = 11.0f; // a one frame start from rest to top speed peaks at tanh(1.2) of the limit
const Real DEFAULT_LEAN_LIMIT = 0.07f; // 4 degrees, for a locomotor that reacts but names no limit, like the Humvee's
- const Real HEADING_LAG_FRAMES = 5.0f; // logic frames the drawn hull trails a steady turn by
- const Real HEADING_MAX_LAG = PI / 4.0f; // never further behind than this: a heading a script sets is drawn there soon
- const UnsignedInt HEADING_CATCH_UP_FRAMES = 8; // more logic frames than this unseen and the hull is drawn on its heading
-
- /* The spring is stepped once a logic frame, the rate the heading itself changes at. The heading and
- the frame are read once: with -logicthread 1 the logic can move on between two reads. */
- const Object *owner = getObject();
- UnsignedInt logicFrame = TheGameLogic->getFrame();
- Real logicAngle = getOrientation();
- UnsignedInt gap = logicFrame - m_locoInfo->m_headingFrame;
- if (!m_locoInfo->m_headingSeeded || gap > HEADING_CATCH_UP_FRAMES || owner->isKindOf(KINDOF_AIRCRAFT) || TheGlobalData->m_classicGraphics)
- {
- // first drawn, long unseen, or a taxiing jet or landed helicopter, which eases its own turn in the logic
- m_locoInfo->m_headingLag = 0.0f;
- m_locoInfo->m_headingLagRate = 0.0f;
- m_locoInfo->m_headingSeeded = TRUE;
- }
- else if (gap != 0)
- {
- const Real omega = 2.0f / HEADING_LAG_FRAMES; // a ramp's lag is 2 / omega
- Real turned = stdAngleDiff(logicAngle, m_locoInfo->m_headingLogic) / gap;
- for (UnsignedInt i = 0; i < gap; ++i)
- {
- m_locoInfo->m_headingLag -= turned;
- m_locoInfo->m_headingLagRate += -omega * omega * m_locoInfo->m_headingLag - 2.0f * omega * m_locoInfo->m_headingLagRate;
- m_locoInfo->m_headingLag += m_locoInfo->m_headingLagRate;
- }
- if (fabs(m_locoInfo->m_headingLag) > HEADING_MAX_LAG)
- {
- m_locoInfo->m_headingLag = (m_locoInfo->m_headingLag > 0.0f) ? HEADING_MAX_LAG : -HEADING_MAX_LAG;
- m_locoInfo->m_headingLagRate = 0.0f;
- }
- }
- m_locoInfo->m_headingLogic = logicAngle;
- m_locoInfo->m_headingFrame = logicFrame;
- // turned first, under the lean, so the lean tips along the hull as drawn (applyPhysicsXform)
- info.m_headingYaw = m_locoInfo->m_headingLag;
/* Stepped on the retail clock, every second logic frame, so the springs, the locomotor's
stiffness and damping and the ease frames below keep the timing they were tuned at. Speeds are
per logic frame and only ever divided by the locomotor's own top speed, which cancels; the turn
rate does not, so it is taken per retail frame. */
- UnsignedInt now = logicFrame / LOGICFRAMES_PER_RETAIL_FRAME;
+ UnsignedInt now = TheGameLogic->getFrame() / LOGICFRAMES_PER_RETAIL_FRAME;
UnsignedInt steps = now - m_locoInfo->m_groundFrame;
if (steps != 0)
{
@@ -2295,7 +2237,7 @@ void Drawable::calcPhysicsXformGround( const Locomotor *locomotor, PhysicsXformI
return;
BodyDamageType bdt = obj->getBodyModule()->getDamageState();
Real speed = physics->getForwardSpeed2D();
- Real angle = logicAngle + m_locoInfo->m_headingLag; // the turn as drawn
+ Real angle = getOrientation();
if (steps > MAX_CATCH_UP_FRAMES)
{
// long unseen, or just loaded: let the springs settle without a lurch from the gap
@@ -2318,7 +2260,7 @@ void Drawable::calcPhysicsXformGround( const Locomotor *locomotor, PhysicsXformI
if (locomotor->getForwardAccelCoef() != 0.0f || locomotor->getLateralAccelCoef() != 0.0f)
{
Real maxSpeed = locomotor->getMaxSpeedForCondition(bdt);
- Real maxLateral = maxSpeed * locomotor->getMaxTurnRate(bdt) * LOGICFRAMES_PER_RETAIL_FRAME;
+ Real maxLateral = maxSpeed * locomotor->getMaxTurnRate(bdt, obj) * LOGICFRAMES_PER_RETAIL_FRAME;
pitchIn = maxSpeed > 0.0f ? -START_GAIN * clamp(-1.0f, forwardAccel / maxSpeed, 1.0f) : 0.0f;
rollIn = maxLateral > 0.0f ? -clamp(-1.0f, lateralAccel / maxLateral, 1.0f) : 0.0f;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
index 34d4a043d..a42880462 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
@@ -2407,9 +2407,6 @@ Bool ParticleSystem::updateEmission( Int localPlayerIndex, Bool *keepSystem )
Bool transformSet = false;
const Matrix3D *parentXfrm = NULL;
Bool isShrouded = false;
- // the hull of a tank or car is drawn trailing its logic heading, and exhaust and damage smoke
- // hang off the hull as drawn (Drawable::getDrawnHeadingLag)
- Matrix3D drawnXfrm;
if (m_attachedToDrawableID)
{
@@ -2420,9 +2417,7 @@ Bool ParticleSystem::updateEmission( Int localPlayerIndex, Bool *keepSystem )
if (attachedTo->getFullyObscuredByShroud())
isShrouded = true;
- drawnXfrm = *attachedTo->getTransformMatrix();
- drawnXfrm.Rotate_Z( attachedTo->getDrawnHeadingLag() );
- parentXfrm = &drawnXfrm;
+ parentXfrm = attachedTo->getTransformMatrix();
m_lastPos = m_pos;
m_pos = *attachedTo->getPosition();
@@ -2448,11 +2443,7 @@ Bool ParticleSystem::updateEmission( Int localPlayerIndex, Bool *keepSystem )
const Drawable * draw = objectAttachedTo->getDrawable();
m_attachedObjectDrawableForDraw = draw ? draw->getID() : INVALID_DRAWABLE_ID;
if ( draw )
- {
- drawnXfrm = *draw->getTransformMatrix();
- drawnXfrm.Rotate_Z( draw->getDrawnHeadingLag() );
- parentXfrm = &drawnXfrm;
- }
+ parentXfrm = draw->getTransformMatrix();
else
parentXfrm = objectAttachedTo->getTransformMatrix();
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
index d62e69a4c..27a177f57 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp
@@ -5193,7 +5193,7 @@ void Pathfinder::beginFlowSearch( const Object *obj )
{
const BodyDamageType damage = obj->getBodyModule()->getDamageState();
const Real speed = loco->getMaxSpeedForCondition( damage );
- const Real turn = loco->getMaxTurnRate( damage );
+ const Real turn = loco->getMaxTurnRate( damage, obj );
// per frame over per frame: world units of driving in the time it takes to turn a radian,
// which is one cost unit per world unit here
if (speed > 0.01f && turn > 0.0001f)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
index bc5ce2933..a66d485fd 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
@@ -1014,7 +1014,7 @@ Real Locomotor::getMaxSpeedForCondition(BodyDamageType condition) const
}
//-------------------------------------------------------------------------------------------------
-Real Locomotor::getMaxTurnRate(BodyDamageType condition) const
+Real Locomotor::getMaxTurnRate(BodyDamageType condition, const Object* obj) const
{
Real turn;
@@ -1023,6 +1023,24 @@ Real Locomotor::getMaxTurnRate(BodyDamageType condition) const
else
turn = m_template->m_maxTurnRateDamaged;
+ /* A tank, car or bike swings onto a new order half as fast again as EA's TurnRate, and a healthy
+ one no slower than GROUND_MIN_TURN_DEG_PER_SEC: EA's 60 degrees a second left an Overlord three
+ seconds pointing the wrong way after a reversal. One scale for both rates, taken from the healthy
+ one, so a damaged hull still turns slower by EA's ratio. Aircraft on treads or wheels (a
+ helicopter or jet taxiing) keep their number. */
+ const Real GROUND_TURN_RATE_FACTOR = 1.5f;
+ const Real GROUND_MIN_TURN_DEG_PER_SEC = 100.0f;
+ if (obj != NULL && isGroundDrive() && !obj->isKindOf(KINDOF_AIRCRAFT))
+ {
+ Real scale = GROUND_TURN_RATE_FACTOR;
+ Real healthy = m_template->m_maxTurnRate;
+ Real minTurn = ConvertAngularVelocityInDegreesPerSecToRadsPerFrame(GROUND_MIN_TURN_DEG_PER_SEC);
+ if (healthy > 0.0f && healthy * scale < minTurn)
+ scale = minTurn / healthy; // a TurnRate of 0, a hull that cannot turn, stays 0
+ turn *= scale;
+ }
+
+ // the per-instance cap (setMaxTurnRate) has the last word over the scale above
if (turn > m_maxTurnRate)
turn = m_maxTurnRate;
@@ -1149,7 +1167,7 @@ void Locomotor::locoUpdate_moveTowardsAngle(Object* obj, Real goalAngle)
PhysicsTurningType Locomotor::rotateTowardsPosition(Object* obj, const Coord3D& goalPos, Real *relAngle)
{
BodyDamageType bdt = obj->getBodyModule()->getDamageState();
- Real turnRate = getMaxTurnRate(bdt);
+ Real turnRate = getMaxTurnRate(bdt, obj);
PhysicsTurningType rotating = rotateObjAroundLocoPivot(obj, goalPos, turnRate, relAngle);
return rotating;
@@ -1338,8 +1356,8 @@ void Locomotor::locoUpdate_moveTowardsPosition(Object* obj, const Coord3D& chase
if (*blocked)
{
physics->scrubVelocity2D(desiredSpeed); // stop if we are about to run into the blocking object.
- Real turnRate = getMaxTurnRate(obj->getBodyModule()->getDamageState());
- if (m_template->m_wanderWidthFactor == 0.0f)
+ Real turnRate = getMaxTurnRate(obj->getBodyModule()->getDamageState(), obj);
+ if (m_template->m_wanderWidthFactor == 0.0f)
{
*blocked = (TURN_NONE != rotateObjAroundLocoPivot(obj, goalPos, turnRate));
}
@@ -1510,9 +1528,21 @@ void Locomotor::moveTowardsPositionTreads(Object* obj, PhysicsBehavior *physics,
Real dx = obj->getPosition()->x - goalPos.x;
Real dy = obj->getPosition()->y - goalPos.y;
-
- Real goalSpeed = (1.0f - angleCoeff) * desiredSpeed;
+
+ /* EA's speed fell to nothing at 45 degrees off the heading, so a tank stopped dead and pivoted
+ after nearly every move order. It rolls through the turn now, slower the tighter it is, and
+ stands to pivot only past TREAD_PIVOT_ANGLE, a hairpin. A helicopter taxiing on treads keeps
+ EA's. */
+ const Real TREAD_PIVOT_ANGLE = PI * 0.75f;
+ Real rollCoeff = angleCoeff;
+ if (!obj->isKindOf(KINDOF_AIRCRAFT))
+ {
+ rollCoeff = (Real)fabs( relAngle ) / TREAD_PIVOT_ANGLE;
+ if (rollCoeff > 1.0f)
+ rollCoeff = 1.0f;
+ }
+ Real goalSpeed = (1.0f - rollCoeff) * desiredSpeed;
// if (speed < m_minTurnSpeed)
@@ -1604,7 +1634,7 @@ void Locomotor::moveTowardsPositionWheels(Object* obj, PhysicsBehavior *physics,
{
BodyDamageType bdt = obj->getBodyModule()->getDamageState();
Real maxSpeed = getMaxSpeedForCondition(bdt);
- Real maxTurnRate = getMaxTurnRate(bdt);
+ Real maxTurnRate = getMaxTurnRate(bdt, obj);
Real maxAcceleration = getMaxAcceleration(bdt);
// sanity, we cannot use desired speed that is greater than our max speed we are capable of moving at
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index fd16eb4ce..b042c2b87 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -2823,7 +2823,7 @@ void AIUpdateInterface::updateProgress( void )
}
Real turnBar = STUCK_TURN_EPSILON;
- const Real rate = m_curLocomotor->getMaxTurnRate( damage );
+ const Real rate = m_curLocomotor->getMaxTurnRate( damage, self );
if (rate * 0.5f > turnBar)
turnBar = rate * 0.5f;
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DDependencyModelDraw.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DDependencyModelDraw.h
index c691756f5..62eacd720 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DDependencyModelDraw.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DDependencyModelDraw.h
@@ -65,7 +65,6 @@ public:
virtual void doDrawModule(const Matrix3D* transformMtx);
virtual void notifyDrawModuleDependencyCleared( );///< if you were waiting for something before you drew, it's ready now
virtual void adjustTransformMtx(Matrix3D& mtx) const;
- virtual Real getHullHeadingLag() const;
protected:
Bool m_dependencyCleared; // The thing we depend on will clear this, and we will relatch it after we draw.
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
index 4d4bf5d37..051f2134c 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h
@@ -478,8 +478,6 @@ protected:
void stopClientParticleSystems();
void doHideShowSubObjs(const std::vector<ModelConditionInfo::HideShowSubObjInfo>* vec);
virtual void adjustTransformMtx(Matrix3D& mtx) const;
- /// how far the hull this model is drawn on trails its logic heading, which a turret aims from
- virtual Real getHullHeadingLag() const;
Real getCurAnimDistanceCovered() const;
Bool setCurAnimDurationInMsec(Real duration);
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp
index 68f0872fe..3fe280bd9 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp
@@ -124,24 +124,6 @@ void W3DDependencyModelDraw::notifyDrawModuleDependencyCleared( )
m_dependencyCleared = TRUE;
}
-// ------------------------------------------------------------------------------------------------
-/** Riding on a container's bone, the rider is drawn on the container's hull, so its turret trails
- * that hull's heading as well (an Overlord's or an Emperor's Gattling Cannon). */
-Real W3DDependencyModelDraw::getHullHeadingLag() const
-{
- Real lag = W3DModelDraw::getHullHeadingLag();
- const Object *me = getDrawable()->getObject();
- if( getW3DDependencyModelDrawModuleData()->m_attachToDrawableBoneInContainer.isNotEmpty()
- && me
- && me->getContainedBy()
- && !me->getContainedBy()->getContain()->isEnclosingContainerFor(me)
- && me->getContainedBy()->getDrawable() )
- {
- lag += me->getContainedBy()->getDrawable()->getDrawnHeadingLag();
- }
- return lag;
-}
-
// ------------------------------------------------------------------------------------------------
void W3DDependencyModelDraw::adjustTransformMtx(Matrix3D& mtx) const
{
@@ -170,7 +152,6 @@ void W3DDependencyModelDraw::adjustTransformMtx(Matrix3D& mtx) const
else
{
mtx = *theirDrawable->getTransformMatrix();//TransformMatrix();
- mtx.Rotate_Z( theirDrawable->getDrawnHeadingLag() ); // the container as drawn, as its bone would be
DEBUG_LOG_DEV(("m_attachToDrawableBoneInContainer %s not found\n",getW3DDependencyModelDrawModuleData()->m_attachToDrawableBoneInContainer.str()));
}
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
index 5c1f0a8a0..5d05a0b3f 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp
@@ -2352,12 +2352,6 @@ void W3DModelDraw::adjustAnimSpeedToMovementSpeed()
}
}
-//-------------------------------------------------------------------------------------------------
-Real W3DModelDraw::getHullHeadingLag() const
-{
- return getDrawable()->getDrawnHeadingLag();
-}
-
//-------------------------------------------------------------------------------------------------
void W3DModelDraw::adjustTransformMtx(Matrix3D& mtx) const
{
@@ -2952,9 +2946,8 @@ void W3DModelDraw::handleClientTurretPositioning()
if (obj)
{
const AIUpdateInterface* ai = obj->getAIUpdateInterface();
- // a turret aims from the logic heading, which the drawn hull of a tank or car trails
- if (ai && ai->getTurretRotAndPitch((WhichTurretType)tslot, &turretAngle, &turretPitch))
- turretAngle -= getHullHeadingLag();
+ if (ai)
+ ai->getTurretRotAndPitch((WhichTurretType)tslot, &turretAngle, &turretPitch);
}
// do turret, if any