I get a crash while I’m developing vehicle system in our game. When my character get on the vehicle and wait for a few minutes, the crash appears. Vehicle and character both has a trigger shape. There are my debug information.
void Sc::InteractionScene::notifyInteractionDeactivated(Interaction* interaction)
{
PX_ASSERT(interaction->mSceneId != PX_INVALID_INTERACTION_SCENE_ID);
const InteractionType type = interaction->getType();
PX_ASSERT(interaction->mSceneId < mActiveInteractionCount[type]);
if (mActiveInteractionCount[type] > 1)
swapInteractionArrayIndices(mActiveInteractionCount[type]-1, interaction->mSceneId, type);
mActiveInteractionCount[type]--;
}
function
void Sc::InteractionScene::swapInteractionArrayIndices(PxU32 id1, PxU32 id2, InteractionType type)
is like this.
void Sc::InteractionScene::swapInteractionArrayIndices(PxU32 id1, PxU32 id2, InteractionType type)
{
Ps::Array<Interaction*>& interArray = mInteractions[type];
Interaction* interaction1 = interArray[id1];
Interaction* interaction2 = interArray[id2];
interArray[id1] = interaction2;
interArray[id2] = interaction1;
interaction1->mSceneId = id2;
interaction2->mSceneId = id1;
}
It get crashes at swapInteractionArrayIndices. There is a wild pointer in mInteractions. And the type is always PX_INTERACTION_TYPE_TRIGGER(2)
I am so confused about the crash and spend a total day trying to solve it. Thanks so much if anyone can offer advice