Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bobbing of attached units and other transportees #1905

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rts/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1827,6 +1827,8 @@ void CGame::SimFrame() {

SCOPED_TIMER("Sim::Script");
unitScriptEngine->Tick(tickMs);

unitHandler.UpdatePostAnimation();
}
envResHandler.Update();
losHandler->Update();
Expand Down
4 changes: 2 additions & 2 deletions rts/Rendering/Units/UnitDrawerData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ void CUnitDrawerData::UpdateDrawPos(CUnit* u)
const CUnit* t = u->GetTransporter();

if (t != nullptr) {
u->drawPos = u->preFramePos + t->GetDrawDeltaPos(globalRendering->timeOffset);
u->drawPos = u->GetDrawPos(t->speed, globalRendering->timeOffset);
}
else {
u->drawPos = u->preFramePos + u->GetDrawDeltaPos(globalRendering->timeOffset);
u->drawPos = u->GetDrawPos( globalRendering->timeOffset);
}

u->drawMidPos = u->GetMdlDrawMidPos();
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Objects/WorldObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CWorldObject: public CObject
void SetRadiusAndHeight(const S3DModel* model);

// extrapolated base-positions; used in unsynced code
float3 GetDrawPos( float t) const { return (speed.w != 0.0f) ? (pos + speed * t) : pos; }
float3 GetDrawPos( float t) const { return (pos + speed * t); }
float3 GetDrawPos(const float3 v, float t) const { return (pos + v * t); }

void ResetDrawFlag() { drawFlag = DrawFlags::SO_NODRAW_FLAG; }
Expand Down
2 changes: 1 addition & 1 deletion rts/Sim/Units/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ void CUnit::Update()

UpdatePhysicalState(0.1f);
UpdatePosErrorParams(true, false);
UpdateTransportees(); // none if already dead
//UpdateTransportees(); // none if already dead

if (beingBuilt)
return;
Expand Down
9 changes: 9 additions & 0 deletions rts/Sim/Units/UnitHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,15 @@ void CUnitHandler::Update()
inUpdateCall = false;
}

void CUnitHandler::UpdatePostAnimation()
{
SCOPED_TIMER("Sim::Unit::UpdatePostAnimation");

for (auto* unit : activeUnits) {
unit->UpdateTransportees();
}
}



void CUnitHandler::AddBuilderCAI(CBuilderCAI* b)
Expand Down
1 change: 1 addition & 0 deletions rts/Sim/Units/UnitHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CUnitHandler
void DeleteScripts();

void Update();
void UpdatePostAnimation();
bool AddUnit(CUnit* unit);

bool CanAddUnit(int id) const {
Expand Down