From f1ed7f4b7d96c695d52830ef4fa4fcec7a06e566 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 15 Apr 2020 10:53:31 -0600 Subject: [PATCH] Fix crazy camera stack issues (cherry picked from commit 6ece5e6341bc591c90408826e48637d7f4f571ce) Author: Adam Johnson Date: Fri Feb 8 00:15:56 2013 -0500 Fix crazy camera stack issues Turns out, it was an artifact of us suspending the simulation during links and partly because of Cyan's late adding of the avatar controller to the sim. Now, we add the avatar as soon as the age data is loaded. This causes the camera stack to be populated with whatever garbage PhysX decides on, then xJourneyClothsGen2 is free to set the real stack after we get all the SDL from the server. Verified to fix Teledahn oddness and not display a regression in Kemo. --- .../FeatureLib/pfCamera/plVirtualCamNeu.cpp | 2 +- .../Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp | 16 +++++++++++++--- .../PubUtilLib/plPhysX/plSimulationMgr.cpp | 7 ------- .../Plasma/PubUtilLib/plPhysX/plSimulationMgr.h | 4 +--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp index 550ede02..57e81d1a 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp @@ -1683,7 +1683,7 @@ void plVirtualCam1::PushCamera(plCameraModifier1* pCam, hsBool bDefault) void plVirtualCam1::PopCamera(plCameraModifier1* pCam) { - // sanity / new default camera check + // sanity / new default camera check if (fCameraStack.Count() <= 1) return; diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index 8d426153..6cf09ff3 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -1387,12 +1387,20 @@ hsBool plArmatureMod::MsgReceive(plMessage* msg) { // only the local player gets these NetworkSynch(hsTimer::GetSysSeconds(), true); - EnablePhysics(true); } else fIsLinkedIn = false; return true; } - + + plAgeLoaded2Msg *agePreLoadMsg = plAgeLoaded2Msg::ConvertNoRef(msg); + if (agePreLoadMsg) + { + // all the age data is loaded -- add our physical controller to the age + ValidatePhysics(); + EnablePhysics(true); + return true; + } + plAnimCmdMsg *cmdMsg = plAnimCmdMsg::ConvertNoRef(msg); if (cmdMsg) { @@ -1668,7 +1676,9 @@ void plArmatureMod::AddTarget(plSceneObject* so) // non-players will unregister when they learn the truth. if (IsLocallyOwned()) plgDispatch::Dispatch()->RegisterForExactType(plAgeLoadedMsg::Index(), GetKey()); - + + plgDispatch::Dispatch()->RegisterForType(plAgeLoaded2Msg::Index(), GetKey()); + // attach a clothingSDLModifier to handle clothing saveState delete fClothingSDLMod; fClothingSDLMod = TRACKED_NEW plClothingSDLModifier; diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index 84665a05..35a498ab 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -317,9 +317,7 @@ void plSimulationMgr::Init() hsAssert(!gTheInstance, "Initializing the sim when it's already been done"); gTheInstance = TRACKED_NEW plSimulationMgr(); if (gTheInstance->InitSimulation()) - { gTheInstance->RegisterAs(kSimulationMgr_KEY); - } else { // There was an error when creating the PhysX simulation @@ -769,11 +767,6 @@ void plSimulationMgr::ISendUpdates() } } -hsBool plSimulationMgr::MsgReceive(plMessage *msg) -{ - return hsKeyedObject::MsgReceive(msg); -} - ///////////////////////////////////////////////////////////////// // // RESOLUTION & TIMEOUT PARAMETERS diff --git a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h index a5d75c21..811fe426 100644 --- a/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h +++ b/MOULOpenSourceClientPlugin/Plasma20/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h @@ -75,8 +75,6 @@ public: // Advance the simulation by the given number of seconds void Advance(float delSecs); - hsBool MsgReceive(plMessage* msg); - // The simulation won't run at all if it is suspended void Suspend() { fSuspended = true; } void Resume() { fSuspended = false; } @@ -211,4 +209,4 @@ inline void SimLog(const char *str, ...) #endif -#endif \ No newline at end of file +#endif