Skip to content

Commit

Permalink
feat: remove velocity x and y value, make z velocity the only velocit…
Browse files Browse the repository at this point in the history
…y parameter in texture
  • Loading branch information
Marco Bacis committed May 17, 2023
1 parent 926e4d7 commit 196a94a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
6 changes: 2 additions & 4 deletions WeArtCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,9 @@ public static class WeArtConstants
public const int maxTextureIndex = (int)TextureType.DoubleSidedTape;
public const int nullTextureIndex = 255;

public const float defaultTextureVelocity_X = 0.5f;
public const float defaultTextureVelocity_Y = 0f;
public const float defaultTextureVelocity_Z = 0f;
public const float defaultTextureVelocity = 0f;
public const float minTextureVelocity = 0f;
public const float maxTextureVelocity = 1f;
public const float maxTextureVelocity = 0.5f;

public const float defaultCollisionMultiplier = 20.0f;
public const float minCollisionMultiplier = 0f;
Expand Down
5 changes: 4 additions & 1 deletion WeArtHapticObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public WeArtHapticObject(WeArtClient client)
/// as long as it is not removed or the haptic properties are programmatically
/// forced to have a specified value.
/// </summary>
/// <remarks>When called, this methods replaces the latest effect applied with the new one</remarks>
/// <param name="effect">The haptic effect to add to this object</param>
public void AddEffect(IWeArtEffect effect)
{
Expand All @@ -174,6 +175,8 @@ public void AddEffect(IWeArtEffect effect)
/// <summary>
/// Removes a haptic effect from the set of influencing effects
/// </summary>
/// <remarks>When called, this methods removes the (only) active effect, leaving the
/// haptic object without applied effects</remarks>
/// <param name="effect">The haptic effect to remove</param>
public void RemoveEffect(IWeArtEffect effect)
{
Expand Down Expand Up @@ -270,7 +273,7 @@ internal void StopControl()
private void SendSetTexture() => SendMessage((handSide, actuationPoint) => new SetTextureMessage()
{
TextureIndex = (int)_texture.TextureType,
TextureVelocity = new float[] { _texture.VelocityX, _texture.VelocityY, _texture.VelocityZ },
TextureVelocity = new float[] { 0.5f, 0.0f, _texture.Velocity },
TextureVolume = _texture.Volume,
HandSide = handSide,
ActuationPoint = actuationPoint
Expand Down
34 changes: 5 additions & 29 deletions WeArtTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ public struct Texture : ICloneable
public static Texture Default = new Texture
{
TextureType = (TextureType)WeArtConstants.defaultTextureIndex,
VelocityX = WeArtConstants.defaultTextureVelocity_X,
VelocityY = WeArtConstants.defaultTextureVelocity_Y,
VelocityZ = WeArtConstants.defaultTextureVelocity_Z,
Velocity = WeArtConstants.defaultTextureVelocity,
Volume = WeArtConstants.defaultVolumeTexture,
Active = false
};
Expand All @@ -33,9 +31,7 @@ public struct Texture : ICloneable
internal TextureType _textureType;

internal bool _active;

private float _vx, _vy, _vz;

private float _vz;
private float _volume;


Expand All @@ -58,27 +54,9 @@ public TextureType TextureType
}

/// <summary>
/// The horizontal component of the 3D velocity, normalized between 0 (min velocity) and 1 (max velocity)
/// </summary>
public float VelocityX
{
get => _vx;
set => _vx = Math.Clamp(value, WeArtConstants.minTextureVelocity, WeArtConstants.maxTextureVelocity);
}

/// <summary>
/// The vertical component of the 3D velocity, normalized between 0 (min velocity) and 1 (max velocity)
/// </summary>
public float VelocityY
{
get => _vy;
set => _vy = Math.Clamp(value, WeArtConstants.minTextureVelocity, WeArtConstants.maxTextureVelocity);
}

/// <summary>
/// The forward component of the 3D velocity, normalized between 0 (min velocity) and 1 (max velocity)
/// The forward component of the 3D velocity, normalized between 0 (min velocity) and 0.5 (max velocity)
/// </summary>
public float VelocityZ
public float Velocity
{
get => _vz;
set => _vz = Math.Clamp(value, WeArtConstants.minTextureVelocity, WeArtConstants.maxTextureVelocity);
Expand Down Expand Up @@ -109,9 +87,7 @@ public override bool Equals(object obj)
{
return obj is Texture texture &&
TextureType == texture.TextureType &&
ApproximateFloatComparer.Instance.Equals(VelocityX, texture.VelocityX) &&
ApproximateFloatComparer.Instance.Equals(VelocityY, texture.VelocityY) &&
ApproximateFloatComparer.Instance.Equals(VelocityZ, texture.VelocityZ) &&
ApproximateFloatComparer.Instance.Equals(Velocity, texture.Velocity) &&
Volume == texture.Volume &&
Active == texture.Active;
}
Expand Down

0 comments on commit 196a94a

Please sign in to comment.