fix(windows-nui): center skeleton in game's validity box via vFloorClipPlane.w=1-hip.y (SKELETON NOW RENDERS - gate was the gravity/floor transform Y-translation)
This commit is contained in:
1 parent
32e729a1f1
commit
36035cc9a2
1 file changed
+14
-6
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user