Skip to content

Commit 0bcda06

Browse files
authored
Merge pull request #286 from Jeka8833/master
Fixed incorrect float to binary conversion
2 parents 7bc1b8f + 2af9612 commit 0bcda06

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

VRCFaceTracking.Core/OSC/DataTypes/BinaryBaseParameter.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,16 @@ private bool ProcessBinary(UnifiedTrackingData data, int binaryIndex)
2121
if (!_negativeParam.Relevant &&
2222
value < 0) // If the negative parameter isn't set, cut the negative values
2323
return false;
24-
var adjustedValue = Math.Abs(value) + (1f / _maxPossibleBinaryInt);
25-
var bigValue = (int)(adjustedValue * (_maxPossibleBinaryInt - 1));
24+
25+
value = Math.Abs(value);
26+
27+
if (value > 0.99999f)
28+
{
29+
return true; // Platform independent fix for floor 1 and bigger
30+
}
31+
32+
var bigValue = (int)(value * _maxPossibleBinaryInt);
33+
2634
return ((bigValue >> binaryIndex) & 1) == 1;
2735
}
2836

0 commit comments

Comments
 (0)