From 80213f3edd75f9a9f87ba7f63c69190233c8c3a4 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 11 Feb 2012 22:40:42 -0500 Subject: [PATCH] Fix weird jitters when jumping and kicking NOTE: If you are using a version of PhysX prior to 2.6.4, then you should test very carefully if you should keep this commit. This change fixed a bug that caused avatars to get stuck falling against certain colliders. It seems to no longer be needed. --- .../plAvatar/plPhysicalControllerCore.cpp | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp index f43af2ec..66c0cc7a 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp +++ b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp @@ -323,48 +323,7 @@ void plWalkingStrategy::Apply(float delSecs) LinearVelocity.fX = AchievedLinearVelocity.fX; LinearVelocity.fY = AchievedLinearVelocity.fY; } - if (!IsOnGround() || IsOnFalseGround()) - { - // We're not on solid ground, so we should be sliding against whatever - // we're hitting (like a rock cliff). Each vector in fSlidingNormals is - // the surface normal of a collision that's too steep to be ground, so - // we project our current velocity onto that plane and slide along the - // wall. - // - // Also, sometimes PhysX reports a bunch of collisions from the wall, - // but nothing from underneath (when there should be). So if we're not - // touching ground, we offset the avatar in the direction of the - // surface normal(s). This doesn't fix the issue 100%, but it's a hell - // of a lot better than nothing, and suitable duct tape until a future - // PhysX revision fixes the issue. - // - // Yes, there's room for optimization here if we care. - hsVector3 offset(0.f, 0.f, 0.f); - for (int i = 0; i < fContactNormals.GetCount(); i++) - { - offset += fContactNormals[i]; - hsVector3 velNorm = LinearVelocity; - - if (velNorm.MagnitudeSquared() > 0) - velNorm.Normalize(); - if (velNorm * fContactNormals[i] < 0) - { - hsVector3 proj = (velNorm % fContactNormals[i]) % fContactNormals[i]; - if (velNorm * proj < 0) - proj *= -1.f; - LinearVelocity = LinearVelocity.Magnitude() * proj; - } - } - if (offset.MagnitudeSquared() > 0) - { - // 5 ft/sec is roughly the speed we walk backwards. - // The higher the value, the less likely you'll trip - // the bug, and this seems reasonable. - offset.Normalize(); - LinearVelocity += offset * 5.0f; - } - } //make terminal velocity equal to k. it is wrong but has been this way and //don't want to break any puzzles. on top of that it will reduce tunneling behavior if(LinearVelocity.fZ