Skip to content

Commit 3bddfe0

Browse files
committed
Improve naming, replace constantly updating params with on-demand updates
1 parent be9bba7 commit 3bddfe0

5 files changed

Lines changed: 8 additions & 13 deletions

File tree

ETVRTrackingModule.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public override void Teardown()
3434

3535
public override void Update()
3636
{
37-
_expressionMapper?.UpdateVRCFTEyeData();
3837
Thread.Sleep(10);
3938
}
4039
}

ExpressionStrategies/IExpressionMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ETVRTrackingModule.ExpressionStrategies;
44

5-
public interface IExpressionMapper
5+
public interface ImappingStategy
66
{
77
public static string GetParamToMap(string oscAddress)
88
{

ExpressionStrategies/V1Mapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace ETVRTrackingModule.ExpressionStrategies;
77

8-
public class V1Mapper : IExpressionMapper
8+
public class V1Mapper : ImappingStategy
99
{
1010
private Dictionary<string, float> _parameterValues = new()
1111
{
@@ -25,7 +25,7 @@ public V1Mapper(ILogger logger)
2525

2626
public void handleOSCMessage(OSCMessage message)
2727
{
28-
var paramToMap = IExpressionMapper.GetParamToMap(message.address);
28+
var paramToMap = ImappingStategy.GetParamToMap(message.address);
2929
if (_parameterValues.ContainsKey(paramToMap))
3030
{
3131
_parameterValues[paramToMap] = message.value;

ExpressionStrategies/V2Mapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace ETVRTrackingModule.ExpressionStrategies;
55

6-
public class V2Mapper : IExpressionMapper
6+
public class V2Mapper : ImappingStategy
77
{
88
private Dictionary<string, float> parameterValues = new()
99
{
@@ -25,7 +25,7 @@ public V2Mapper(ILogger logger)
2525
}
2626
public void handleOSCMessage(OSCMessage message)
2727
{
28-
string paramToMap = IExpressionMapper.GetParamToMap(message.address);
28+
string paramToMap = ImappingStategy.GetParamToMap(message.address);
2929
if (parameterValues.ContainsKey(paramToMap))
3030
{
3131
parameterValues[paramToMap] = message.value;

ExpressionsMapper.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace ETVRTrackingModule
66
{
77
public class ExpressionsMapper
88
{
9-
private IExpressionMapper _mappingStrategy;
9+
private ImappingStategy _mappingStrategy;
1010

1111
ILogger _logger;
1212
public ExpressionsMapper(ILogger logger)
@@ -20,14 +20,15 @@ public void MapMessage(OSCMessage msg)
2020
if (!msg.success)
2121
return;
2222

23-
var nextStrategy = IsV2Param(msg) ? (IExpressionMapper) new V2Mapper(_logger) : new V1Mapper(_logger);
23+
var nextStrategy = IsV2Param(msg) ? (ImappingStategy) new V2Mapper(_logger) : new V1Mapper(_logger);
2424

2525
if (_mappingStrategy.GetType() != nextStrategy.GetType())
2626
{
2727
_logger.LogInformation($"Detected differing strategy, changing from {_mappingStrategy.GetType()} to {nextStrategy.GetType()}");
2828
_mappingStrategy = nextStrategy;
2929
}
3030
_mappingStrategy.handleOSCMessage(msg);
31+
_mappingStrategy.UpdateVRCFTEyeData(ref UnifiedTracking.Data.Eye, ref UnifiedTracking.Data.Shapes);
3132
}
3233

3334
private bool IsV2Param(OSCMessage oscMessage)
@@ -36,10 +37,5 @@ private bool IsV2Param(OSCMessage oscMessage)
3637
_logger.LogInformation($"is V2 param: {isv2Param.ToString()}");
3738
return isv2Param;
3839
}
39-
40-
public void UpdateVRCFTEyeData()
41-
{
42-
_mappingStrategy.UpdateVRCFTEyeData(ref UnifiedTracking.Data.Eye, ref UnifiedTracking.Data.Shapes);
43-
}
4440
}
4541
}

0 commit comments

Comments
 (0)