mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
Bonus: Some cleanups for collision message handling and slightly improved
logging
This commit is contained in:
@ -48,6 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
void DetectorLog(const char* format, ...) {}
|
||||
void DetectorLogSpecial(const char* format, ...) {}
|
||||
void DetectorLogRed(const char* format, ...) {}
|
||||
void DetectorLogYellow(const char* format, ...) {}
|
||||
|
||||
#else
|
||||
|
||||
@ -90,5 +91,12 @@ void DetectorLogRed(const char* format, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void DetectorLogYellow(const char* format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
gLog->AddLineV(plStatusLog::kYellow, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
#endif // PLASMA_EXTERNAL_RELEASE
|
||||
|
@ -45,6 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
void DetectorLog(const char* format, ...);
|
||||
void DetectorLogSpecial(const char* format, ...);
|
||||
void DetectorLogRed(const char* format, ...);
|
||||
void DetectorLogYellow(const char* format, ...);
|
||||
void DetectorDoLogfile();
|
||||
|
||||
#endif // plDetectorLog_h_inc
|
@ -40,6 +40,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plPXPhysicalControllerCore.h"
|
||||
#include "plgDispatch.h"
|
||||
#include "plSimulationMgr.h"
|
||||
#include "plPXPhysical.h"
|
||||
#include "plPXConvert.h"
|
||||
@ -372,13 +373,6 @@ void plPXPhysicalControllerCore::ISetGlobalLoc(const hsMatrix44& l2w)
|
||||
plPXPhysicalControllerCore::~plPXPhysicalControllerCore()
|
||||
{
|
||||
IDeleteController();
|
||||
//need to make sure my queued messages are released
|
||||
for(int j=0;j<fQueuedCollideMsgs.GetCount();j++)
|
||||
{
|
||||
delete fQueuedCollideMsgs[j];
|
||||
fQueuedCollideMsgs[j]=nil;
|
||||
}
|
||||
fQueuedCollideMsgs.SetCount(0);
|
||||
for (int i = 0; i < gControllers.size(); i++)
|
||||
{
|
||||
if (gControllers[i] == this)
|
||||
@ -706,26 +700,19 @@ void plPXPhysicalControllerCore::IInformDetectors(bool entering,bool deferUntilN
|
||||
msg->AddReceiver(physical->GetObjectKey());
|
||||
if(!deferUntilNextSim)
|
||||
{
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
DetectorLog("Sending an %s msg to %s" , entering? "entering":"exit", physical->GetObjectKey()->GetName());
|
||||
#endif
|
||||
msg->Send();
|
||||
DetectorLog("Sending an %s msg to %s" , entering? "entering":"exit", physical->GetObjectKey()->GetName());
|
||||
msg->Send();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
DetectorLog("Queuing an %s msg to %s, which will be sent after the next simstep" , entering? "entering":"exit", physical->GetObjectKey()->GetName());
|
||||
#endif
|
||||
//these will be fired in update prestep on the next lap
|
||||
fQueuedCollideMsgs.Append(msg);
|
||||
DetectorLog("Queuing an %s msg to %s, which will be sent after the client update" , entering? "entering":"exit", physical->GetObjectKey()->GetName());
|
||||
plgDispatch::Dispatch()->MsgQueue(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
DetectorLog("Done informing from plPXPhysicalControllerCore::IInformDetectors");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void plPXPhysicalControllerCore::Move(hsVector3 displacement, unsigned int collideWith, unsigned int &collisionResults)
|
||||
@ -932,16 +919,6 @@ void plPXPhysicalControllerCore::UpdatePrestep(hsScalar delSecs)
|
||||
if(ac)
|
||||
{
|
||||
if(ac->fNeedsResize)ac->IHandleResize();
|
||||
int storedCollideMsgs=ac->fQueuedCollideMsgs.GetCount();
|
||||
if(storedCollideMsgs)
|
||||
{
|
||||
plSimulationMgr* simMgr=plSimulationMgr::GetInstance();
|
||||
for(int j=0; j<storedCollideMsgs;j++)
|
||||
{
|
||||
simMgr->AddCollisionMsg(ac->fQueuedCollideMsgs[j]);
|
||||
}
|
||||
ac->fQueuedCollideMsgs.SetCount(0);
|
||||
}
|
||||
ac->Apply(delSecs);
|
||||
}
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
|
@ -151,7 +151,6 @@ protected:
|
||||
void IDrawDebugDisplay();
|
||||
#endif
|
||||
void IHandleResize();
|
||||
hsTArray<plCollideMsg*> fQueuedCollideMsgs;
|
||||
hsScalar fPreferedRadius;
|
||||
hsScalar fPreferedHeight;
|
||||
// The global position and rotation of the avatar last time we set it (so we
|
||||
|
@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include <NxPhysics.h>
|
||||
|
||||
#include "plgDispatch.h"
|
||||
#include "hsTimer.h"
|
||||
#include "plProfile.h"
|
||||
#include "plPXPhysical.h"
|
||||
@ -206,13 +207,13 @@ class SensorReport : public NxUserTriggerReport
|
||||
|
||||
void SendCollisionMsg(plKey receiver, plKey hitter, hsBool entering)
|
||||
{
|
||||
DetectorLogYellow("Collision: %s was triggered by %s. Sending an %s msg", receiver->GetName(),
|
||||
hitter ? hitter->GetName() : "(nil)" , entering ? "'enter'" : "'exit'");
|
||||
plCollideMsg* msg = TRACKED_NEW plCollideMsg;
|
||||
msg->fOtherKey = hitter;
|
||||
msg->fEntering = entering;
|
||||
msg->AddReceiver(receiver);
|
||||
// msg->Send();\
|
||||
//placing message in a list to be fired off after sim step
|
||||
plSimulationMgr::GetInstance()->AddCollisionMsg(msg);
|
||||
plgDispatch::Dispatch()->MsgQueue(msg); // Sends the msg on the next client update
|
||||
}
|
||||
|
||||
} gSensorReport;
|
||||
@ -536,6 +537,8 @@ void plSimulationMgr::ReleaseScene(plKey world)
|
||||
|
||||
void plSimulationMgr::ISendCollisionMsg(plKey receiver, plKey hitter, hsBool entering)
|
||||
{
|
||||
DetectorLogYellow("Collision: %s is inside %s. Sending an %s msg", hitter ? hitter->GetName() : "(nil)",
|
||||
receiver->GetName(), entering ? "'enter'" : "'exit'");
|
||||
plCollideMsg* msg = TRACKED_NEW plCollideMsg;
|
||||
msg->fOtherKey = hitter;
|
||||
msg->fEntering = entering;
|
||||
@ -543,34 +546,6 @@ void plSimulationMgr::ISendCollisionMsg(plKey receiver, plKey hitter, hsBool ent
|
||||
msg->Send();
|
||||
}
|
||||
|
||||
void plSimulationMgr::AddCollisionMsg(plCollideMsg* msg)
|
||||
{
|
||||
fCollisionMessages.Append(msg);
|
||||
}
|
||||
void plSimulationMgr::IDispatchCollisionMessages()
|
||||
{
|
||||
if(fCollisionMessages.GetCount())
|
||||
{
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
DetectorLog("--------------------------------------------------");
|
||||
DetectorLog("Dispatching collision messages from last sim step");
|
||||
#endif
|
||||
for(int i=0; i<fCollisionMessages.GetCount();i++)
|
||||
{
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
DetectorLog("%s was hit by %s. Sending an %s message",fCollisionMessages[i]->GetReceiver(0)->GetName(),
|
||||
fCollisionMessages[i]->GetSender()?fCollisionMessages[i]->GetSender()->GetName():"An Avatar",
|
||||
fCollisionMessages[i]->fEntering? "enter" : "exit");
|
||||
#endif
|
||||
fCollisionMessages[i]->Send();
|
||||
}
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
DetectorLog("--------------------------------------------------");
|
||||
#endif
|
||||
fCollisionMessages.SetCount(0);
|
||||
}
|
||||
}
|
||||
|
||||
void plSimulationMgr::UpdateDetectorsInScene(plKey world, plKey avatar, hsPoint3& pos, bool entering)
|
||||
{
|
||||
// search thru the actors in a scene looking for convex hull detectors and see if the avatar is inside it
|
||||
@ -679,9 +654,6 @@ void plSimulationMgr::Advance(float delSecs)
|
||||
}
|
||||
}
|
||||
plPXPhysicalControllerCore::UpdatePostSimStep(delSecs);
|
||||
|
||||
//sending off and clearing the Collision Messages generated by scene->simulate
|
||||
IDispatchCollisionMessages();
|
||||
|
||||
plProfile_EndTiming(Step);
|
||||
#ifndef PLASMA_EXTERNAL_RELEASE
|
||||
|
@ -139,12 +139,6 @@ protected:
|
||||
|
||||
plPhysicsSoundMgr* fSoundMgr;
|
||||
|
||||
//a list of collision messages generated by the simulation steps. Added to by AddCollisionMsg(plCollideMsg* msg)
|
||||
//cleared by IDispatchCollisionMessages when done
|
||||
hsTArray<plCollideMsg*> fCollisionMessages;
|
||||
|
||||
void IDispatchCollisionMessages();
|
||||
|
||||
// A mapping from a key to a PhysX scene. The key is either the
|
||||
// SimulationMgr key, for the main world, or a SceneObject key if it's a
|
||||
// subworld.
|
||||
|
Reference in New Issue
Block a user