fixes for trigger onenter/onleave

1- corrects onleavetrigger for deletions
2-adds a testObjects to trip onenter when creating or moving a trigger itself so that that will list objects already there as opposed to only going off when something moves into it
This commit is contained in:
AzaezelX 2020-06-13 12:12:52 -05:00
parent 341c7eeee1
commit 8ecb474a67
2 changed files with 21 additions and 2 deletions

View file

@ -389,6 +389,20 @@ bool Trigger::setTickCmd(void *object, const char *index, const char *data)
return true; // to update the actual field
}
//------------------------------------------------------------------------------
void Trigger::testObjects()
{
Vector<SceneObject*> foundobjs;
gServerContainer.findObjectList(getWorldBox(), 0xFFFFFFFF, &foundobjs);
for (S32 i = 0; i < foundobjs.size(); ++i)
{
GameBase* so = dynamic_cast<GameBase*>(foundobjs[i]);
if (so)
potentialEnterObject(so);
}
}
//--------------------------------------------------------------------------
bool Trigger::onAdd()
@ -405,7 +419,9 @@ bool Trigger::onAdd()
if (isServerObject())
scriptOnAdd();
testObjects();
return true;
}
@ -441,7 +457,7 @@ void Trigger::onDeleteNotify( SimObject *obj )
{
mObjects.erase(i);
if (mDataBlock)
mDataBlock->onLeaveTrigger_callback( this, pScene );
mDataBlock->onLeaveTrigger_callback( this, NULL );
break;
}
}
@ -517,6 +533,8 @@ void Trigger::setTransform(const MatrixF & mat)
setMaskBits(TransformMask | ScaleMask);
}
testObjects();
}
void Trigger::prepRenderImage( SceneRenderState *state )