Browse Source

PR from Huru to prevent dynamics from moving during age initilization

tickets/47/47/2
Adam Johnson 3 years ago committed by Edmond Mondor
parent
commit
54c768d966
  1. 15
      Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp

15
Sources/Plasma/PubUtilLib/plPhysX/plPXPhysical.cpp

@ -1328,15 +1328,15 @@ void plPXPhysical::GetSyncState(hsPoint3& pos, hsQuat& rot, hsVector3& linV, hsV
void plPXPhysical::SetSyncState(hsPoint3* pos, hsQuat* rot, hsVector3* linV, hsVector3* angV)
{
bool initialSync = plNetClientApp::GetInstance()->IsLoadingInitialAgeState() &&
plNetClientApp::GetInstance()->GetJoinOrder() == 0;
bool isLoading = plNetClientApp::GetInstance()->IsLoadingInitialAgeState();
bool isFirstIn = plNetClientApp::GetInstance()->GetJoinOrder() == 0;
bool initialSync = isLoading && isFirstIn;
// If the physical has fallen out of the sim, and this is initial age state, and we're
// the first person in, reset it to the original position. (ie, prop the default state
// we've got right now)
if (pos && pos->fZ < kMaxNegativeZPos && initialSync)
{
SimLog("Physical %s loaded out of range state. Forcing initial state to server.", GetKeyName());
SimLog("Physical %s loaded out of range state. Forcing initial state to server.", GetKeyName().c_str());
DirtySynchState(kSDLPhysical, plSynchedObject::kBCastToClients);
return;
}
@ -1350,6 +1350,13 @@ void plPXPhysical::SetSyncState(hsPoint3* pos, hsQuat* rot, hsVector3* linV, hsV
SetLinearVelocitySim(*linV);
if (angV)
SetAngularVelocitySim(*angV);
// If we're loading the age, then we should ensure the objects stay asleep if they're supposed to be asleep.
// NOTE: We should only do this if the objects are not at their initial locations. Otherwise, they might
// sleep inside each other and explode or float randomly in midair
if (isLoading && GetProperty(plSimulationInterface::kStartInactive) && !fActor->readBodyFlag(NX_BF_KINEMATIC)) {
if (!pos && !rot)
fActor->putToSleep();
}
SendNewLocation(false, true);
}

Loading…
Cancel
Save