Skip to content

Commit

Permalink
Don't let player physics body sleep.
Browse files Browse the repository at this point in the history
Keeps contact added from firing again when falling asleep in a sensor.
  • Loading branch information
afritz1 committed Jan 12, 2025

Verified

This commit was signed with the committer’s verified signature.
renovate-bot Mend Renovate
1 parent 6678651 commit 24e3882
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions OpenTESArena/src/Player/Player.cpp
Original file line number Diff line number Diff line change
@@ -102,6 +102,12 @@ namespace
constexpr uint64_t characterUserData = 0;
*outCharacter = new JPH::Character(&characterSettings, JPH::Vec3Arg::sZero(), JPH::QuatArg::sIdentity(), characterUserData, &physicsSystem);
(*outCharacter)->AddToPhysicsSystem(JPH::EActivation::Activate);

const JPH::BodyLockInterface &bodyLockInterface = physicsSystem.GetBodyLockInterface();
const JPH::BodyLockWrite characterBodyLock(bodyLockInterface, (*outCharacter)->GetBodyID());
DebugAssert(characterBodyLock.Succeeded());
JPH::Body &characterBody = characterBodyLock.GetBody();
characterBody.SetAllowSleeping(false); // Don't refire contact added when waking up inside sensor colliders

constexpr uint64_t characterVirtualUserData = 0;
*outCharacterVirtual = new JPH::CharacterVirtual(&characterVirtualSettings, JPH::Vec3Arg::sZero(), JPH::QuatArg::sIdentity(), characterVirtualUserData, &physicsSystem);

0 comments on commit 24e3882

Please sign in to comment.