From aa5d0501b1c34b39e9acde57e9d6d1d96855a071 Mon Sep 17 00:00:00 2001 From: rt Date: Sun, 22 Jan 2012 23:31:10 +0100 Subject: [PATCH] fix MoveCtrl.SetRelativeVelocity --- rts/Sim/MoveTypes/ScriptMoveType.cpp | 16 +++++++--------- rts/Sim/Objects/SolidObject.cpp | 11 ----------- rts/Sim/Objects/SolidObject.h | 9 ++++++++- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/rts/Sim/MoveTypes/ScriptMoveType.cpp b/rts/Sim/MoveTypes/ScriptMoveType.cpp index aa939789cff..1cfdafc4bc1 100644 --- a/rts/Sim/MoveTypes/ScriptMoveType.cpp +++ b/rts/Sim/MoveTypes/ScriptMoveType.cpp @@ -124,20 +124,18 @@ bool CScriptMoveType::Update() owner->speed = vel; if (extrapolate) { - // quadratic drag does not work well here - // NOTE: also affects speed gained through gravity - vel *= (1.0f - drag); - if (useRelVel) { - // add the speed terms relative to the unit (if any) - vel += (owner->frontdir * relVel.z); - vel += (owner->updir * relVel.y); - vel += (owner->rightdir * -relVel.x); // x is left + // apply the speed terms relative to the unit (if any) + owner->Move3D(owner->frontdir * relVel.z, true); + owner->Move3D(owner->updir * relVel.y, true); + owner->Move3D(owner->rightdir * -relVel.x, true); // x is left } - // NOTE: strong wind plus low gravity can cause substantial position drift + // NOTE: strong wind plus low gravity can cause substantial drift vel.y += (mapInfo->map.gravity * gravityFactor); vel += (wind.GetCurrentWind() * windFactor); + // quadratic drag does not work well here + vel *= (1.0f - drag); owner->Move3D(vel, true); } diff --git a/rts/Sim/Objects/SolidObject.cpp b/rts/Sim/Objects/SolidObject.cpp index 196f6ce71ba..a1903e0fdc4 100644 --- a/rts/Sim/Objects/SolidObject.cpp +++ b/rts/Sim/Objects/SolidObject.cpp @@ -108,17 +108,6 @@ CSolidObject::~CSolidObject() { -void CSolidObject::UpdateMidPos() -{ - const float3 dz = (frontdir * relMidPos.z); - const float3 dy = (updir * relMidPos.y); - const float3 dx = (rightdir * relMidPos.x); - - midPos = pos + dz + dy + dx; -} - - - void CSolidObject::UnBlock() { if (isMarkedOnBlockingMap) { groundBlockingObjectMap->RemoveGroundBlockingObject(this); diff --git a/rts/Sim/Objects/SolidObject.h b/rts/Sim/Objects/SolidObject.h index b4d9a9d3d50..8c68b65d918 100644 --- a/rts/Sim/Objects/SolidObject.h +++ b/rts/Sim/Objects/SolidObject.h @@ -45,10 +45,17 @@ class CSolidObject: public CWorldObject { pos[d] += dv; midPos[d] += dv; } + // this should be called whenever the direction // vectors are changed (ie. after a rotation) in // eg. movetype code - void UpdateMidPos(); + void UpdateMidPos() { + const float3 dz = (frontdir * relMidPos.z); + const float3 dy = (updir * relMidPos.y); + const float3 dx = (rightdir * relMidPos.x); + + midPos = pos + dz + dy + dx; + } /** * Adds this object to the GroundBlockingMap if and only if its collidable