mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Greatly simplify collision detectors
This commit is contained in:
@ -595,10 +595,12 @@ void plSimulationMgr::AddCollisionMsg(plKey hitee, plKey hitter, bool enter)
|
||||
plCollideMsg* pMsg = *it;
|
||||
|
||||
// Should only ever be one receiver.
|
||||
// If there's more than one, you suck.
|
||||
// Oh, it seems we should update the hit status. The latest might be different than the older...
|
||||
// Even in the same frame >.<
|
||||
if (pMsg->fOtherKey == hitter && pMsg->GetReceiver(0) == hitee)
|
||||
{
|
||||
DetectorLogRed("DUPE: %s hit %s",
|
||||
pMsg->fEntering = enter;
|
||||
DetectorLogRed("DUPLICATE COLLISION: %s hit %s",
|
||||
(hitter ? hitter->GetName().c_str() : "(nil)"),
|
||||
(hitee ? hitee->GetName().c_str() : "(nil)"));
|
||||
return;
|
||||
|
@ -242,67 +242,28 @@ plCameraRegionDetector::~plCameraRegionDetector()
|
||||
|
||||
void plCameraRegionDetector::ITrigger(plKey hitter, bool entering, bool immediate)
|
||||
{
|
||||
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
// PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
if (entering && fNumEvals - fLastExitEval <= 1 && fSavingSendMsg)
|
||||
{
|
||||
DetectorLog("%s: Skipping Camera Entering volume", GetKeyName().c_str());
|
||||
fLastEnterEval = fNumEvals;
|
||||
if (fSavingSendMsg)
|
||||
{
|
||||
DetectorLog("%s: Dumping saved Camera Exiting volume", GetKeyName().c_str());
|
||||
}
|
||||
fSavingSendMsg = false;
|
||||
return;
|
||||
}
|
||||
if (!entering && fNumEvals - fLastEnterEval <= 1 && fSavingSendMsg)
|
||||
{
|
||||
DetectorLog("%s: Skipping Exiting volume", GetKeyName().c_str());
|
||||
fLastExitEval = fNumEvals;
|
||||
if (fSavingSendMsg)
|
||||
{
|
||||
DetectorLog("%s: Dumping saved Camera Entering volume", GetKeyName().c_str());
|
||||
}
|
||||
fSavingSendMsg = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// get rid of any saved messages... this should happen though
|
||||
if (fSavingSendMsg)
|
||||
{
|
||||
DetectorLog("%s: Killing saved camera message... shouldn't happen", GetKeyName().c_str());
|
||||
}
|
||||
// end PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
DetectorLogRed("%s: Stale messages on ITrigger. This should never happen!", GetKeyName().c_str());
|
||||
if (fIsInside && entering)
|
||||
DetectorLogRed("%s: Duplicate enter! Did we miss an exit?", GetKeyName().c_str());
|
||||
else if (!fIsInside && !entering)
|
||||
DetectorLogRed("%s: Duplicate exit! Did we miss an enter?", GetKeyName().c_str());
|
||||
|
||||
fSavingSendMsg = true;
|
||||
fSavedMsgEnterFlag = entering;
|
||||
if (entering)
|
||||
{
|
||||
//DetectorLog("%s: Saving camera Entering volume - Evals=%d", GetKeyName().c_str(),fNumEvals);
|
||||
DetectorLog("%s: Saving camera Entering volume - Evals=%d", GetKeyName().c_str(),fNumEvals);
|
||||
fLastEnterEval = fNumEvals;
|
||||
}
|
||||
else
|
||||
{
|
||||
//DetectorLog("%s: Saving camera Exiting volume - Evals=%d", GetKeyName().c_str(),fNumEvals);
|
||||
DetectorLog("%s: Saving camera Exiting volume - Evals=%d", GetKeyName().c_str(),fNumEvals);
|
||||
fLastExitEval = fNumEvals;
|
||||
}
|
||||
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
// PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
// we're saving the message to be dispatched later...
|
||||
if (immediate)
|
||||
{
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
|
||||
ISendSavedTriggerMsgs();
|
||||
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
}
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
|
||||
|
||||
}
|
||||
|
||||
void plCameraRegionDetector::ISendSavedTriggerMsgs()
|
||||
@ -311,23 +272,20 @@ void plCameraRegionDetector::ISendSavedTriggerMsgs()
|
||||
{
|
||||
for (size_t i = 0; i < fMessages.size(); ++i)
|
||||
{
|
||||
char str[256];
|
||||
|
||||
hsRefCnt_SafeRef(fMessages[i]);
|
||||
if (fSavedMsgEnterFlag)
|
||||
{
|
||||
fMessages[i]->SetCmd(plCameraMsg::kEntering);
|
||||
sprintf(str, "Entering cameraRegion: %s - Evals=%d -msg %d of %d\n", GetKeyName().c_str(),fNumEvals,i+1,fMessages.size());
|
||||
DetectorLog("Entering cameraRegion: %s - Evals=%d -msg %d of %d\n", GetKeyName().c_str(),fNumEvals,i+1,fMessages.size());
|
||||
fIsInside = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fMessages[i]->ClearCmd(plCameraMsg::kEntering);
|
||||
sprintf(str, "Exiting cameraRegion: %s - Evals=%d -msg %d of %d\n", GetKeyName().c_str(),fNumEvals,i+1,fMessages.size());
|
||||
DetectorLog("Exiting cameraRegion: %s - Evals=%d -msg %d of %d\n", GetKeyName().c_str(),fNumEvals,i+1,fMessages.size());
|
||||
fIsInside = false;
|
||||
}
|
||||
plgDispatch::MsgSend(fMessages[i]);
|
||||
DetectorLog("%s", str);
|
||||
}
|
||||
}
|
||||
fSavingSendMsg = false;
|
||||
@ -337,30 +295,15 @@ void plCameraRegionDetector::ISendSavedTriggerMsgs()
|
||||
hsBool plCameraRegionDetector::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plCollideMsg* pCollMsg = plCollideMsg::ConvertNoRef(msg);
|
||||
|
||||
if (pCollMsg)
|
||||
{
|
||||
// camera collisions are only for the local player
|
||||
if (plNetClientApp::GetInstance()->GetLocalPlayerKey() != pCollMsg->fOtherKey)
|
||||
return true;
|
||||
|
||||
|
||||
#ifdef USE_PHYSX_MULTIPLE_CAMREGION_ENTER
|
||||
// first determine if this is a multiple camera region enter (PHYSX BUG WORKAROUND)
|
||||
if (!fWaitingForEval)
|
||||
{//plObjectInVolumeCollisionDetector::MsgReceive() will flip fWaitingForEval
|
||||
// and registers for the Eval, child objects of plObjectInVolumeCollisionDetector
|
||||
//must decide when they are no longer interested in Evals. I suggest using IHandleEvals()
|
||||
|
||||
fNumEvals = 0;
|
||||
fLastEnterEval=-999;
|
||||
fLastExitEval=-999;
|
||||
}
|
||||
|
||||
// end of (PHYSX BUG WORKAROUND)
|
||||
#endif // USE_PHYSX_MULTIPLE_CAMREG_ENTER
|
||||
|
||||
// Fall through to plObjectInVolumeDetector, which will register us for plEvalMsg
|
||||
// and handle it for us. (Hint: See ISendSavedTriggerMsgs)
|
||||
}
|
||||
|
||||
return plObjectInVolumeDetector::MsgReceive(msg);
|
||||
}
|
||||
void plCameraRegionDetector::Read(hsStream* stream, hsResMgr* mgr)
|
||||
@ -383,23 +326,6 @@ void plCameraRegionDetector::Write(hsStream* stream, hsResMgr* mgr)
|
||||
mgr->WriteCreatable( stream, *it );
|
||||
|
||||
}
|
||||
void plCameraRegionDetector::IHandleEval(plEvalMsg *pEval)
|
||||
{
|
||||
fNumEvals++;
|
||||
if (fNumEvals - fLastEnterEval > 1 && fNumEvals-fLastExitEval>1)
|
||||
{
|
||||
ISendSavedTriggerMsgs();
|
||||
plgDispatch::Dispatch()->UnRegisterForExactType(plEvalMsg::Index(), GetKey());
|
||||
fWaitingForEval = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fSavedActivatorMsg)
|
||||
DetectorLog("%s didn't send its message. fNumEvals=%d fLastEnterEval=%d, fLastExit=%d",
|
||||
GetKeyName().c_str(),fNumEvals, fLastEnterEval, fLastExitEval);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
/////////////////////////////////
|
||||
@ -409,127 +335,8 @@ void plCameraRegionDetector::IHandleEval(plEvalMsg *pEval)
|
||||
|
||||
void plObjectInVolumeDetector::ITrigger(plKey hitter, bool entering, bool immediate)
|
||||
{
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
// PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
/* if (entering && fNumEvals - fLastExitEval <= 1 && fSavedActivatorMsg)
|
||||
{
|
||||
//DetectorLog("%s: Skipping Entering volume", GetKeyName());
|
||||
fLastEnterEval = fNumEvals;
|
||||
if (fSavedActivatorMsg)
|
||||
{
|
||||
//DetectorLog("%s: Dumping saved Exiting volume", GetKeyName());
|
||||
delete fSavedActivatorMsg;
|
||||
}
|
||||
fSavedActivatorMsg = nil;
|
||||
return;
|
||||
}
|
||||
if (!entering && fNumEvals - fLastEnterEval <= 1 && fSavedActivatorMsg)
|
||||
{
|
||||
//DetectorLog("%s: Skipping Exiting volume", GetKeyName());
|
||||
fLastExitEval = fNumEvals;
|
||||
if (fSavedActivatorMsg)
|
||||
{
|
||||
//DetectorLog("%s: Dumping saved Entering volume", GetKeyName());
|
||||
delete fSavedActivatorMsg;
|
||||
}
|
||||
fSavedActivatorMsg = nil;
|
||||
return;
|
||||
}
|
||||
|
||||
// get rid of any saved messages... this should happen though
|
||||
if (fSavedActivatorMsg)
|
||||
{
|
||||
delete fSavedActivatorMsg;
|
||||
DetectorLog("%s: Killing saved message... shouldn't happen", GetKeyName());
|
||||
}
|
||||
// end PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
*/
|
||||
if(!immediate)
|
||||
{
|
||||
|
||||
bookKeepingList::iterator curit=fCollisionList.begin();
|
||||
while(curit!=fCollisionList.end())
|
||||
{
|
||||
if(hitter==(*curit)->hitter)
|
||||
{//hey the object is already in my list
|
||||
//try and figure out what my real state is
|
||||
if(entering)
|
||||
{
|
||||
(*curit)->enters++;
|
||||
if(!(*curit)->fSubStepCurState)
|
||||
{//We weren't already in
|
||||
(*curit)->fSubStepCurState =true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(*curit)->exits++;
|
||||
if((*curit)->fSubStepCurState)
|
||||
{//We were already in
|
||||
(*curit)->fSubStepCurState =false;
|
||||
}
|
||||
}
|
||||
//get out
|
||||
break;
|
||||
}
|
||||
curit++;
|
||||
}
|
||||
if(curit==fCollisionList.end())
|
||||
{
|
||||
//hitter was not in the list add him in
|
||||
//hitter was not in the current frame list
|
||||
//lets find out its state in the begining of the frame
|
||||
ResidentSet::iterator curres = fCurrentResidents.find(hitter);
|
||||
bool initialState;
|
||||
if(curres != fCurrentResidents.end())
|
||||
initialState =true;
|
||||
else
|
||||
initialState =false;
|
||||
|
||||
plCollisionBookKeepingInfo* BookKeeper=new plCollisionBookKeepingInfo(hitter);
|
||||
if(entering)
|
||||
{
|
||||
BookKeeper->enters++;
|
||||
BookKeeper->fSubStepCurState =true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BookKeeper->exits++;
|
||||
BookKeeper->fSubStepCurState =false;
|
||||
}
|
||||
fCollisionList.push_front(BookKeeper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
plActivatorMsg* ActivatorMsg = new plActivatorMsg;
|
||||
ActivatorMsg->AddReceivers(fReceivers);
|
||||
if (fProxyKey)
|
||||
ActivatorMsg->fHiteeObj = fProxyKey;
|
||||
else
|
||||
ActivatorMsg->fHiteeObj = GetTarget()->GetKey();
|
||||
|
||||
ActivatorMsg->fHitterObj = hitter;
|
||||
ActivatorMsg->SetSender(GetKey());
|
||||
if (entering)
|
||||
{
|
||||
ActivatorMsg->SetTriggerType(plActivatorMsg::kVolumeEnter);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActivatorMsg->SetTriggerType(plActivatorMsg::kVolumeExit);
|
||||
}
|
||||
|
||||
plgDispatch::MsgSend(ActivatorMsg);
|
||||
|
||||
|
||||
}
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
|
||||
/* fSavedActivatorMsg = new plActivatorMsg;
|
||||
|
||||
hsRefCnt_SafeUnRef(fSavedActivatorMsg);
|
||||
fSavedActivatorMsg = new plActivatorMsg;
|
||||
fSavedActivatorMsg->AddReceivers(fReceivers);
|
||||
|
||||
if (fProxyKey)
|
||||
@ -542,47 +349,36 @@ void plObjectInVolumeDetector::ITrigger(plKey hitter, bool entering, bool immedi
|
||||
|
||||
if (entering)
|
||||
{
|
||||
//DetectorLog("%s: Saving Entering volume - Evals=%d", GetKeyName(),fNumEvals);
|
||||
DetectorLog("%s: Saving Entering volume - Evals=%d", GetKeyName().c_str(), fNumEvals);
|
||||
fSavedActivatorMsg->SetTriggerType(plActivatorMsg::kVolumeEnter);
|
||||
fLastEnterEval = fNumEvals;
|
||||
}
|
||||
else
|
||||
{
|
||||
//DetectorLog("%s: Saving Exiting volume - Evals=%d", GetKeyName(),fNumEvals);
|
||||
DetectorLog("%s: Saving Exiting volume - Evals=%d", GetKeyName().c_str(), fNumEvals);
|
||||
fSavedActivatorMsg->SetTriggerType(plActivatorMsg::kVolumeExit);
|
||||
fLastExitEval = fNumEvals;
|
||||
}
|
||||
*/
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
// PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
// we're saving the message to be dispatched later...
|
||||
|
||||
if (immediate)
|
||||
{
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
|
||||
|
||||
// fSavedActivatorMsg = nil;
|
||||
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
}
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
ISendSavedTriggerMsgs();
|
||||
}
|
||||
/*
|
||||
|
||||
void plObjectInVolumeDetector::ISendSavedTriggerMsgs()
|
||||
{
|
||||
if (fSavedActivatorMsg)
|
||||
{
|
||||
if (fSavedActivatorMsg->fTriggerType == plActivatorMsg::kVolumeEnter)
|
||||
DetectorLog("%s: Sending Entering volume - Evals=%d", GetKeyName(),fNumEvals);
|
||||
DetectorLog("%s: Sending Entering volume - Evals=%d", GetKeyName().c_str(), fNumEvals);
|
||||
else
|
||||
DetectorLog("%s: Sending Exiting volume - Evals=%d", GetKeyName(),fNumEvals);
|
||||
DetectorLog("%s: Sending Exiting volume - Evals=%d", GetKeyName().c_str(), fNumEvals);
|
||||
|
||||
// we're saving the message to be dispatched later...
|
||||
plgDispatch::MsgSend(fSavedActivatorMsg);
|
||||
}
|
||||
fSavedActivatorMsg = nil;
|
||||
}
|
||||
*/
|
||||
|
||||
hsBool plObjectInVolumeDetector::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plCollideMsg* pCollMsg = plCollideMsg::ConvertNoRef(msg);
|
||||
@ -591,36 +387,18 @@ hsBool plObjectInVolumeDetector::MsgReceive(plMessage* msg)
|
||||
// If the avatar is disabled (flying around), don't trigger
|
||||
if (IIsDisabledAvatar(pCollMsg->fOtherKey))
|
||||
return false;
|
||||
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
// PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
if (!fWaitingForEval)
|
||||
{
|
||||
plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey());
|
||||
fWaitingForEval = true;
|
||||
}
|
||||
// end PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
ITrigger(pCollMsg->fOtherKey, (pCollMsg->fEntering != 0));
|
||||
|
||||
plgDispatch::Dispatch()->RegisterForExactType(plEvalMsg::Index(), GetKey());
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
// PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
plEvalMsg* pEval = plEvalMsg::ConvertNoRef(msg);
|
||||
if (pEval)
|
||||
plEvalMsg* pEvalMsg = plEvalMsg::ConvertNoRef(msg);
|
||||
if (pEvalMsg)
|
||||
{
|
||||
|
||||
//if (fSavedActivatorMsg)
|
||||
// DetectorLog("%s: InVolumeEval=%d with saved message", GetKeyName(), fNumEvals);
|
||||
//else
|
||||
// DetectorLog("%s: InVolumeEval=%d without saved message", GetKeyName(), fNumEvals);
|
||||
IHandleEval(pEval);
|
||||
|
||||
fNumEvals++;
|
||||
ISendSavedTriggerMsgs();
|
||||
plgDispatch::Dispatch()->UnRegisterForExactType(plEvalMsg::Index(), GetKey());
|
||||
}
|
||||
// end PHYSX_FIXME hack for PhysX turd that sends bunches of enter/exits over one frame
|
||||
#endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND
|
||||
|
||||
plPlayerPageMsg* pageMsg = plPlayerPageMsg::ConvertNoRef(msg);
|
||||
if (pageMsg && pageMsg->fUnload)
|
||||
@ -631,75 +409,6 @@ hsBool plObjectInVolumeDetector::MsgReceive(plMessage* msg)
|
||||
return plCollisionDetector::MsgReceive(msg);
|
||||
}
|
||||
|
||||
void plObjectInVolumeDetector::IHandleEval(plEvalMsg* pEval)
|
||||
{
|
||||
plgDispatch::Dispatch()->UnRegisterForExactType(plEvalMsg::Index(), GetKey());
|
||||
fWaitingForEval = false;
|
||||
for(bookKeepingList::reverse_iterator it= fCollisionList.rbegin();it!=fCollisionList.rend(); it++)
|
||||
{
|
||||
bool alreadyInside;
|
||||
ResidentSet::iterator HitIt;
|
||||
HitIt = fCurrentResidents.find((*it)->hitter);
|
||||
if(HitIt != fCurrentResidents.end()) alreadyInside = true;
|
||||
else alreadyInside=false;
|
||||
plActivatorMsg* actout=new plActivatorMsg;
|
||||
actout->fHitterObj=((*it)->hitter);
|
||||
actout->SetSender(GetKey());
|
||||
if (fProxyKey)
|
||||
actout->fHiteeObj = fProxyKey;
|
||||
else
|
||||
actout->fHiteeObj = GetTarget()->GetKey();
|
||||
if((*it)->fSubStepCurState)//current substate says we are entered
|
||||
{//different enters and exits
|
||||
//figure out what to do
|
||||
if(!alreadyInside)
|
||||
{//we are actuall entering
|
||||
actout->SetTriggerType(plActivatorMsg::kVolumeEnter);
|
||||
fCurrentResidents.insert((*it)->hitter);
|
||||
actout->AddReceivers(fReceivers);
|
||||
actout->Send();
|
||||
DetectorLog("%s sent an Enter ActivatorMsg. To: %s", GetKeyName().c_str(), GetTarget()->GetKeyName().c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
DetectorLog("%s squelched an Enter ActivatorMsg.", GetKeyName().c_str());
|
||||
delete actout;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//fSubStepCurState says we are outside
|
||||
if(alreadyInside)
|
||||
{//we are actuall exiting
|
||||
actout->SetTriggerType(plActivatorMsg::kVolumeExit);
|
||||
fCurrentResidents.erase((*it)->hitter);
|
||||
actout->AddReceivers(fReceivers);
|
||||
actout->Send();
|
||||
DetectorLog("%s sent an Exit ActivatorMsg. To: %s", GetKeyName().c_str(), GetTarget()->GetKeyName().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
DetectorLog("%s squelched an Exit ActivatorMsg.", GetKeyName().c_str());
|
||||
delete actout;
|
||||
}
|
||||
}
|
||||
}
|
||||
DetectorLog("*********");
|
||||
for(bookKeepingList::iterator it = fCollisionList.begin(); it != fCollisionList.end(); it ++)
|
||||
{
|
||||
delete (*it);
|
||||
}
|
||||
DetectorLog("This is the regions inhabitants after the op");
|
||||
for(ResidentSet::iterator it = fCurrentResidents.begin(); it!= fCurrentResidents.end(); it++)
|
||||
{
|
||||
DetectorLog("%s", (*it)->GetName().c_str());
|
||||
}
|
||||
DetectorLog("*********");
|
||||
|
||||
fCollisionList.clear();
|
||||
|
||||
}
|
||||
|
||||
void plObjectInVolumeDetector::SetTarget(plSceneObject* so)
|
||||
{
|
||||
plCollisionDetector::SetTarget(so);
|
||||
@ -725,6 +434,7 @@ void plObjectInVolumeDetector::Write(hsStream* stream, hsResMgr* mgr)
|
||||
|
||||
|
||||
plObjectInVolumeAndFacingDetector::plObjectInVolumeAndFacingDetector() :
|
||||
plObjectInVolumeDetector(),
|
||||
fFacingTolerance(0),
|
||||
fNeedWalkingForward(false),
|
||||
fAvatarInVolume(false),
|
||||
|
@ -73,7 +73,8 @@ public:
|
||||
kTypeBump = 0x20,
|
||||
};
|
||||
|
||||
plCollisionDetector() : fType(0), fTriggered(false), fBumped(false){;}
|
||||
plCollisionDetector() : fType(0), fTriggered(false), fBumped(false){ }
|
||||
plCollisionDetector(int8_t type) : fType(type), fTriggered(false), fBumped(false) { }
|
||||
virtual ~plCollisionDetector(){;}
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
@ -90,48 +91,26 @@ public:
|
||||
// sub type for object-in-volume detectors
|
||||
class plObjectInVolumeDetector : public plCollisionDetector
|
||||
{
|
||||
public:
|
||||
class plCollisionBookKeepingInfo
|
||||
{
|
||||
friend class plObjectInVolumeDetector;
|
||||
public:
|
||||
plCollisionBookKeepingInfo(plKey& hit)
|
||||
{
|
||||
hitter=hit;
|
||||
enters=0;
|
||||
exits=0;
|
||||
}
|
||||
~plCollisionBookKeepingInfo()
|
||||
{
|
||||
hitter=nil;
|
||||
}
|
||||
protected:
|
||||
plKey hitter;
|
||||
int enters,exits;
|
||||
bool fSubStepCurState;
|
||||
};
|
||||
protected:
|
||||
virtual void ITrigger(plKey hitter, bool entering, bool immediate=false);
|
||||
//virtual void ISendSavedTriggerMsgs();
|
||||
virtual void IHandleEval(plEvalMsg* pEval);
|
||||
bool fWaitingForEval;
|
||||
virtual void ISendSavedTriggerMsgs();
|
||||
|
||||
plActivatorMsg* fSavedActivatorMsg;
|
||||
|
||||
typedef std::list<plCollisionBookKeepingInfo*> bookKeepingList;
|
||||
bookKeepingList fCollisionList;
|
||||
typedef std::set<plKey> ResidentSet;
|
||||
ResidentSet fCurrentResidents;
|
||||
uint32_t fNumEvals;
|
||||
uint32_t fLastEnterEval;
|
||||
uint32_t fLastExitEval;
|
||||
|
||||
public:
|
||||
|
||||
plObjectInVolumeDetector()
|
||||
{
|
||||
fWaitingForEval=false;fSavedActivatorMsg=nil;
|
||||
|
||||
}
|
||||
plObjectInVolumeDetector(int8_t i){fType = i;fWaitingForEval=false;fSavedActivatorMsg=nil;}
|
||||
virtual ~plObjectInVolumeDetector(){;}
|
||||
plObjectInVolumeDetector()
|
||||
: plCollisionDetector(), fSavedActivatorMsg(nil), fNumEvals(0), fLastEnterEval(0), fLastExitEval(0)
|
||||
{ }
|
||||
|
||||
plObjectInVolumeDetector(int8_t type)
|
||||
: plCollisionDetector(type), fSavedActivatorMsg(nil), fNumEvals(0), fLastEnterEval(0), fLastExitEval(0)
|
||||
{ }
|
||||
|
||||
virtual ~plObjectInVolumeDetector() { }
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
@ -183,15 +162,13 @@ protected:
|
||||
bool fIsInside;
|
||||
bool fSavingSendMsg;
|
||||
bool fSavedMsgEnterFlag;
|
||||
int fNumEvals;
|
||||
int fLastEnterEval;
|
||||
int fLastExitEval;
|
||||
|
||||
virtual void ITrigger(plKey hitter, bool entering, bool immediate=false);
|
||||
virtual void ISendSavedTriggerMsgs();
|
||||
virtual void IHandleEval(plEvalMsg* pEval);
|
||||
public:
|
||||
plCameraRegionDetector(){ fIsInside = false; fSavingSendMsg = false; }
|
||||
plCameraRegionDetector()
|
||||
: plObjectInVolumeDetector(), fIsInside(false), fSavingSendMsg(false)
|
||||
{ }
|
||||
~plCameraRegionDetector();
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
Reference in New Issue
Block a user