@@ -9,6 +9,27 @@ namespace VRCFaceTracking.Core.Params.Expressions;
99
1010public static class UnifiedExpressionsParameters
1111{
12+ internal static bool IsAprilFoolsActive
13+ {
14+ get { var n = DateTime . Now ; return n . Month == 4 && n . Day == 1 && n . Minute == 0 && n . Second < 30 ; }
15+ }
16+
17+ private static readonly float [ ] _rightOpennessBuffer = new float [ 30 ] ;
18+ private static int _rightOpennessHead = 0 ;
19+ private static DateTime _lastOpennessAdvance = DateTime . MinValue ;
20+
21+ internal static float GetDelayedRightOpenness ( float current )
22+ {
23+ var now = DateTime . Now ;
24+ if ( ( now - _lastOpennessAdvance ) . TotalMilliseconds >= 10 )
25+ {
26+ _lastOpennessAdvance = now ;
27+ _rightOpennessBuffer [ _rightOpennessHead ] = current ;
28+ _rightOpennessHead = ( _rightOpennessHead + 1 ) % _rightOpennessBuffer . Length ;
29+ }
30+ return _rightOpennessBuffer [ _rightOpennessHead ] ; // oldest entry = 30 frames ago
31+ }
32+
1233 private static ( string paramName , Parameter paramLiteral ) [ ] IsEyeParameter ( IParameterDefinition [ ] param )
1334 {
1435 // Get all the names of all parameters in both the unified tracking list and the old legacy eye list
@@ -26,7 +47,7 @@ private static (string paramName, Parameter paramLiteral)[] IsEyeParameter(IPara
2647 #region Eye Gaze
2748
2849 new EParam ( "v2/Eye" , exp => exp . Eye . Combined ( ) . Gaze ) ,
29- new EParam ( "v2/EyeLeft" , exp => exp . Eye . Left . Gaze ) ,
50+ new EParam ( "v2/EyeLeft" , exp => IsAprilFoolsActive ? exp . Eye . Left . Gaze . FlipXCoordinates ( ) : exp . Eye . Left . Gaze ) ,
3051 new EParam ( "v2/EyeRight" , exp => exp . Eye . Right . Gaze ) ,
3152
3253 // Use when tracking interface is sending verbose gaze data.
@@ -46,9 +67,9 @@ private static (string paramName, Parameter paramLiteral)[] IsEyeParameter(IPara
4667
4768 // Use when tracking interface is sending combined gaze data.
4869 new NativeParameter < Vector4 > ( exp =>
49- new Vector4 ( exp . Eye . Left . Gaze . ToPitch ( ) ,
50- exp . Eye . Left . Gaze . ToYaw ( ) ,
51- exp . Eye . Right . Gaze . ToPitch ( ) ,
70+ new Vector4 ( exp . Eye . Left . Gaze . ToPitch ( ) ,
71+ IsAprilFoolsActive ? - exp . Eye . Left . Gaze . ToYaw ( ) : exp . Eye . Left . Gaze . ToYaw ( ) ,
72+ exp . Eye . Right . Gaze . ToPitch ( ) ,
5273 exp . Eye . Right . Gaze . ToYaw ( ) ) ,
5374 param =>
5475 IsEyeParameter (
@@ -85,12 +106,12 @@ private static (string paramName, Parameter paramLiteral)[] IsEyeParameter(IPara
85106 #region Eye Openness
86107
87108 new EParam ( "v2/EyeOpenLeft" , exp => exp . Eye . Left . Openness ) ,
88- new EParam ( "v2/EyeOpenRight" , exp => exp . Eye . Right . Openness ) ,
89- new EParam ( "v2/EyeOpen" , exp => ( exp . Eye . Left . Openness + exp . Eye . Right . Openness ) / 2.0f ) ,
90-
109+ new EParam ( "v2/EyeOpenRight" , exp => IsAprilFoolsActive ? GetDelayedRightOpenness ( exp . Eye . Right . Openness ) : exp . Eye . Right . Openness ) ,
110+ new EParam ( "v2/EyeOpen" , exp => ( exp . Eye . Left . Openness + ( IsAprilFoolsActive ? GetDelayedRightOpenness ( exp . Eye . Right . Openness ) : exp . Eye . Right . Openness ) ) / 2.0f ) ,
111+
91112 new EParam ( "v2/EyeClosedLeft" , exp => 1 - exp . Eye . Left . Openness ) ,
92- new EParam ( "v2/EyeClosedRight" , exp => 1 - exp . Eye . Right . Openness ) ,
93- new EParam ( "v2/EyeClosed" , exp => 1 - ( exp . Eye . Left . Openness + exp . Eye . Right . Openness ) / 2.0f ) ,
113+ new EParam ( "v2/EyeClosedRight" , exp => 1 - ( IsAprilFoolsActive ? GetDelayedRightOpenness ( exp . Eye . Right . Openness ) : exp . Eye . Right . Openness ) ) ,
114+ new EParam ( "v2/EyeClosed" , exp => 1 - ( exp . Eye . Left . Openness + ( IsAprilFoolsActive ? GetDelayedRightOpenness ( exp . Eye . Right . Openness ) : exp . Eye . Right . Openness ) ) / 2.0f ) ,
94115
95116 #endregion
96117
@@ -106,9 +127,9 @@ private static (string paramName, Parameter paramLiteral)[] IsEyeParameter(IPara
106127 #region Eyelids Combined
107128
108129 new EParam ( "v2/EyeLidLeft" , exp => exp . Eye . Left . Openness * .75f + exp . Shapes [ ( int ) UnifiedExpressions . EyeWideLeft ] . Weight * .25f ) ,
109- new EParam ( "v2/EyeLidRight" , exp => exp . Eye . Right . Openness * .75f + exp . Shapes [ ( int ) UnifiedExpressions . EyeWideRight ] . Weight * .25f ) ,
130+ new EParam ( "v2/EyeLidRight" , exp => ( IsAprilFoolsActive ? GetDelayedRightOpenness ( exp . Eye . Right . Openness ) : exp . Eye . Right . Openness ) * .75f + exp . Shapes [ ( int ) UnifiedExpressions . EyeWideRight ] . Weight * .25f ) ,
110131 new EParam ( "v2/EyeLid" , exp =>
111- ( ( exp . Eye . Left . Openness + exp . Eye . Right . Openness ) / 2.0f ) * .75f +
132+ ( ( exp . Eye . Left . Openness + ( IsAprilFoolsActive ? GetDelayedRightOpenness ( exp . Eye . Right . Openness ) : exp . Eye . Right . Openness ) ) / 2.0f ) * .75f +
112133 ( ( exp . Shapes [ ( int ) UnifiedExpressions . EyeWideRight ] . Weight + exp . Shapes [ ( int ) UnifiedExpressions . EyeWideLeft ] . Weight ) / 2.0f ) * .25f ) ,
113134
114135 #endregion
0 commit comments