From 6ece5e6341bc591c90408826e48637d7f4f571ce Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 8 Feb 2013 00:15:56 -0500 Subject: [PATCH] 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 | 12 +---------- .../PubUtilLib/plAvatar/plArmatureMod.cpp | 20 +++++++++++++------ .../PubUtilLib/plPhysX/plSimulationMgr.cpp | 16 --------------- .../PubUtilLib/plPhysX/plSimulationMgr.h | 2 -- 4 files changed, 15 insertions(+), 35 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp index 63c23665..44f73c51 100644 --- a/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp +++ b/Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp @@ -1680,19 +1680,9 @@ void plVirtualCam1::PushCamera(plCameraModifier1* pCam, bool bDefault) void plVirtualCam1::PopCamera(plCameraModifier1* pCam) { - // sanity / new default camera check + // sanity / new default camera check if (fCameraStack.size() <= 1) return; - - // Crazy Special Casing Turd: [based on some Cyan crap] - // is it the current camera AND the same camera we would otherwise switch to? - // if so, pop off the dupe if we're going to the age default... otherwise, go crazy. - if (fCameraStack.size() > 2 && pCam == GetCurrentStackCamera()) - { - int theDupe = fCameraStack.size() - 1; - if (pCam == fCameraStack[theDupe] && theDupe == 2) - fCameraStack.pop_back(); - } // are we mouse-looking? bool mLook = false; diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp index f22bc9ff..40f37d21 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plArmatureMod.cpp @@ -1370,20 +1370,27 @@ bool plArmatureMod::MsgReceive(plMessage* msg) IFireBehaviorNotify(plHBehavior::kBehaviorTypeLinkIn, false); return true; } - + plAgeLoadedMsg *ageLoadMsg = plAgeLoadedMsg::ConvertNoRef(msg); if (ageLoadMsg) { if (ageLoadMsg->fLoaded) - { // only the local player gets these NetworkSynch(hsTimer::GetSysSeconds(), true); - EnablePhysics(true); - } else + 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) { @@ -1651,7 +1658,8 @@ 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 = new plClothingSDLModifier; diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index c3a445e3..309aebe1 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp @@ -248,10 +248,7 @@ void plSimulationMgr::Init() hsAssert(!gTheInstance, "Initializing the sim when it's already been done"); gTheInstance = new plSimulationMgr(); if (gTheInstance->InitSimulation()) - { gTheInstance->RegisterAs(kSimulationMgr_KEY); - plgDispatch::Dispatch()->RegisterForExactType(plAgeLoadedMsg::Index(), gTheInstance->GetKey()); - } else { // There was an error when creating the PhysX simulation @@ -267,7 +264,6 @@ void plSimulationMgr::Shutdown() hsAssert(gTheInstance, "Simulation manager missing during shutdown."); if (gTheInstance) { - plgDispatch::Dispatch()->UnRegisterForExactType(plAgeLoadedMsg::Index(), gTheInstance->GetKey()); gTheInstance->UnRegisterAs(kSimulationMgr_KEY); // this will destroy the instance gTheInstance = nil; } @@ -624,18 +620,6 @@ void plSimulationMgr::ISendUpdates() } } -bool plSimulationMgr::MsgReceive(plMessage *msg) -{ - // Suspend/resume the simulation based on whether or not we're in an age... - if (plAgeLoadedMsg* aMsg = plAgeLoadedMsg::ConvertNoRef(msg)) - { - fSuspended = !aMsg->fLoaded; - return true; - } - - return hsKeyedObject::MsgReceive(msg); -} - ///////////////////////////////////////////////////////////////// // // RESOLUTION & TIMEOUT PARAMETERS diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h index 506fe239..752306e1 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h +++ b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.h @@ -75,8 +75,6 @@ public: // Advance the simulation by the given number of seconds void Advance(float delSecs); - bool MsgReceive(plMessage* msg); - // The simulation won't run at all if it is suspended void Suspend() { fSuspended = true; } void Resume() { fSuspended = false; }