diff --git a/fallback/windows-nui/src/sensor.cpp b/fallback/windows-nui/src/sensor.cpp index 1dc3cd5..a2eee82 100644 --- a/fallback/windows-nui/src/sensor.cpp +++ b/fallback/windows-nui/src/sensor.cpp @@ -663,12 +663,20 @@ void VirtualKinectSensor::BuildSkeletonFrame(const SourceFrame& src) { frame.liTimeStamp = ts; frame.dwFrameNumber = src.meta.frame_number; frame.dwFlags = 0; - // A real Kinect always reports the floor plane (Hessian form Ax+By+Cz+D=0, - // unit up-normal, D = -sensor-height) and the up gravity normal. The game - // builds a floor/gravity-relative transform from these and validates each - // skeleton's center of mass against it; leaving them zero makes that - // transform degenerate so no skeleton is ever a selectable candidate. - frame.vFloorClipPlane = {0.0f, 1.0f, 0.0f, -1.5f}; + // Skeleton-selection gate (reverse-engineered from gamekdm FUN_10018570/ + // FUN_100e4140/FUN_101ab6d0): the game builds a gravity/floor-relative + // transform M from vNormalToGravity (-> manager+0x2c) and vFloorClipPlane, + // then for each candidate computes P1 = (-px, py + m13, -pz + m14) and keeps + // it only if P1 lies within 0.05 of the box [A-B, A+B] (A=(0,1,0), + // B=(1.22,1,0.675) -> box y in [0,2], centre 1). m14 (=2.5) matches our hip z + // so P1.z lands centred; the Y-translation m13 is taken straight from this + // plane's w, so to center P1.y at 1 we set w = 1 - hip.y. A level up-gravity + // normal keeps M a clean (non-degenerate) rotation. + const float hip_y = + src.has_player + ? src.meta.skeleton.joints[NUI_SKELETON_POSITION_HIP_CENTER].position.y + : 0.0f; + frame.vFloorClipPlane = {0.0f, 1.0f, 0.0f, 1.0f - hip_y}; frame.vNormalToGravity = {0.0f, 1.0f, 0.0f, 0.0f}; for (auto& data : frame.SkeletonData) {