Would PinchScaler.cs support MinimumMultiplier/MaximumMultiplier or MinimumScale/MaximumScale and Only change Scale X/Y/Z?
Environment
- VRTK.Prefab 1.1.4
- Unity 2019.2.1f1
- Hardware used (Oculus Rift)
- SDK used (Oculus Intergation)
Expected behavior
I expect the intention of the set up is Secondary_Scale to support the limit of minimum/maximum scale and only change Scale X/Y/Z.
Current behavior
The source feature has very limited use.
The solution I'd like
I rewrite PinchScaler.cs to support. may be humble:
public float MinMultiple = 0.2f;
public float MaxMultiple = 4.0f;
private bool m_Flag;
public override void Process()
{
if (Target == null)
{
m_Flag = false;
return;
}
if (Target != null)
{
if (!m_Flag)
{
originalScale = GetTargetScale();
}
m_Flag = true;
var curLocalScale = GetTargetScale();
var minLocalScale = originalScale * MinMultiple;
var maxLocalScale = originalScale * MaxMultiple;
previousDistance = previousDistance ?? GetDistance();
var distanceDelta = GetDistance() - (float) previousDistance;
var scale = distanceDelta * Multiplier;
if (curLocalScale.x <= minLocalScale.x)
{
if (scale <= 0)
{
return;
}
}
if (curLocalScale.x >= maxLocalScale.x)
{
if (scale > 0)
{
return;
}
}
}
base.Process();
}
Is it true that it can be coupled with a Vector3Restrictor
The component right now does the scaling so you wouldn't be able to pass the data out to a 3rd party component via events. but some sort of a restrictor, or clamper that you can optionally inject into scripts could work.
So yeah I think some sort of data clampers would work in this instance.
So you could have
- int clamper
- float clamper
- vector2 clamper
- vector3 clamper
And you call Clamp passing the input type and it emits the clamped value.
Then in this regard because PinchScaler is a process, you could do:
TransformScaleExtractor.Extract -> Vector3Clamper -> TransformScaleMutator.SetGlobal/Local
PR https://github.com/ExtendRealityLtd/Zinnia.Unity/pull/587