Skip to content

Commit

Permalink
Merge pull request #132 from benaclejames/parameters/v2-plural-removals
Browse files Browse the repository at this point in the history
v2 Parameter Adjustments and Fixes
  • Loading branch information
benaclejames authored Apr 23, 2023
2 parents 88461e6 + f74853b commit 7d442f6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
43 changes: 24 additions & 19 deletions VRCFaceTracking.Core/Params/Expressions/UnifiedExpressionsMerger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,35 @@ private static (string paramName, IParameter paramLiteral)[] IsEyeParameter(Conf
new EParam(exp => exp.Eye.Left.Gaze, "v2/EyeLeft"),
new EParam(exp => exp.Eye.Right.Gaze, "v2/EyeRight"),

// Use when tracking interface is sending verbose gaze data.
new NativeParameter<Vector2>(exp =>
{
var combined = exp.Eye.Combined().Gaze;
return new Vector2(-combined.ToPitch().y, combined.ToYaw().x);
},
param => IsEyeParameter(
new Vector2(exp.Eye.Combined().Gaze.ToPitch(),
exp.Eye.Combined().Gaze.ToYaw()),
param =>
IsEyeParameter(
param.Where(p =>
p.name.Contains("Eye") &&
(p.name.Contains("Left") || p.name.Contains("Right") || p.name.Contains("Eyes")) &&
(p.name.Contains('X') || p.name.Contains('Y'))).ToArray())
.Length == 0,
"/tracking/eye/CenterPitchYaw"
),
/*
// Use when tracking interface is sending combined gaze data.
new NativeParameter<Vector4>(exp =>
new Vector4(exp.Eye.Right.Gaze.ToPitch(),
exp.Eye.Right.Gaze.ToYaw(),
exp.Eye.Left.Gaze.ToPitch(),
exp.Eye.Left.Gaze.ToYaw()),
param =>
IsEyeParameter(
param.Where(p =>
p.name.Contains("Eye") &&
(p.name.Contains('X') || p.name.Contains('Y'))).ToArray())
.Length == 0,
"/tracking/eye/LeftRightPitchYaw" // THE INPUT IS BACKWARDSSSSS
),
*/

new NativeParameter<float>(exp =>
{
Expand All @@ -48,22 +64,11 @@ private static (string paramName, IParameter paramLiteral)[] IsEyeParameter(Conf
param => IsEyeParameter(
param.Where(p =>
p.name.Contains("Eye") &&
(p.name.Contains("Left") || p.name.Contains("Right") || p.name.Contains("Eyes")) &&
(p.name.Contains('X') || p.name.Contains('Y'))).ToArray())
(p.name.Contains("Open") || p.name.Contains("Lid"))).ToArray())
.Length == 0,
"/tracking/eye/EyesClosedAmount"
),

/*new AlwaysRelevantParameter<Vector4>(exp =>
{
float[] randomFloats = new float[6];
for (int i = 0; i < randomFloats.Length; i++) {
randomFloats[i] = (float) (rand.NextDouble() * 720 - 360);
}
return new Vector4(randomFloats[0], randomFloats[1], randomFloats[2], randomFloats[3]);
}, "/tracking/eye/LeftRightPitchYaw"),*/ // Screw you vrchat give us individual eyes and fix ur docs u poopyheads

#endregion

#region Eye Pupils
Expand Down Expand Up @@ -158,8 +163,8 @@ private static (string paramName, IParameter paramLiteral)[] IsEyeParameter(Conf

new EParam(exp => (exp.Shapes[(int)UnifiedExpressions.CheekSquintLeft].Weight + exp.Shapes[(int)UnifiedExpressions.CheekSquintRight].Weight) / 2.0f, "v2/CheekSquint"),

new EParam(exp => exp.Shapes[(int)UnifiedExpressions.CheekPuffLeft].Weight - exp.Shapes[(int)UnifiedExpressions.CheekSuckLeft].Weight, "v2/CheekLeftPuffSuck"),
new EParam(exp => exp.Shapes[(int)UnifiedExpressions.CheekPuffRight].Weight - exp.Shapes[(int)UnifiedExpressions.CheekSuckRight].Weight, "v2/CheekRightPuffSuck"),
new EParam(exp => exp.Shapes[(int)UnifiedExpressions.CheekPuffLeft].Weight - exp.Shapes[(int)UnifiedExpressions.CheekSuckLeft].Weight, "v2/CheekPuffSuckLeft"),
new EParam(exp => exp.Shapes[(int)UnifiedExpressions.CheekPuffRight].Weight - exp.Shapes[(int)UnifiedExpressions.CheekSuckRight].Weight, "v2/CheekPuffSuckRight"),

new EParam(exp =>
(exp.Shapes[(int)UnifiedExpressions.CheekPuffRight].Weight + exp.Shapes[(int)UnifiedExpressions.CheekPuffLeft].Weight) / 2.0f -
Expand Down
9 changes: 5 additions & 4 deletions VRCFaceTracking.Core/Types/Vector2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ public Vector2 FlipXCoordinates()
return this;
}

public Vector2 ToYaw()
=> new Vector2((float)(Math.Atan(this.x) * (180/Math.PI)), (float)(Math.Atan(this.y) * (180 / Math.PI)));
public Vector2 ToPitch()
=> new Vector2((float)(Math.Asin(this.x) * (180 / Math.PI)), (float)(Math.Asin(this.y) * (180 / Math.PI)));
public float ToYaw()
=> (float)(Math.Atan(x) * (180 / Math.PI));

public float ToPitch()
=> -(float)(Math.Atan(y) * (180 / Math.PI));
}
}

0 comments on commit 7d442f6

Please sign in to comment.