Fixed floating point comparisons
This commit is contained in:
1 parent
9d481cabc1
commit
5cd47f0537
13 files changed
+32
-32
No files matched your search
@@ -211,7 +211,7 @@ namespace Vocaluxe.Base
|
||||
if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1)
|
||||
{
|
||||
float timeToPlay;
|
||||
if (_CurrentPlaylistElement.Finish == 0f) //No End-Tag defined
|
||||
if (Math.Abs(_CurrentPlaylistElement.Finish) < 0.001) //No End-Tag defined
|
||||
timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream);
|
||||
else //End-Tag found
|
||||
timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream);
|
||||
@@ -222,13 +222,13 @@ namespace Vocaluxe.Base
|
||||
if (_RepeatSong)
|
||||
{
|
||||
//Seek to #Start-Tag, if found
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
|
||||
else
|
||||
CSound.SetPosition(_CurrentMusicStream, 0);
|
||||
if (_VideoEnabled && _Video != -1)
|
||||
{
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
|
||||
else
|
||||
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
||||
@@ -269,7 +269,7 @@ namespace Vocaluxe.Base
|
||||
CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume);
|
||||
|
||||
//Seek to #Start-Tag, if found
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
|
||||
|
||||
if (_VideoEnabled)
|
||||
@@ -289,13 +289,13 @@ namespace Vocaluxe.Base
|
||||
if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f)
|
||||
{
|
||||
//Seek to #Start-Tag, if found
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
|
||||
else
|
||||
CSound.SetPosition(_CurrentMusicStream, 0);
|
||||
if (_VideoEnabled && _Video != -1)
|
||||
{
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
|
||||
else
|
||||
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
||||
@@ -321,13 +321,13 @@ namespace Vocaluxe.Base
|
||||
else if (_CurrentMusicStream != -1)
|
||||
{
|
||||
//Seek to #Start-Tag, if found
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
|
||||
else
|
||||
CSound.SetPosition(_CurrentMusicStream, 0);
|
||||
if (_VideoEnabled && _Video != -1)
|
||||
{
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
|
||||
else
|
||||
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
||||
@@ -434,7 +434,7 @@ namespace Vocaluxe.Base
|
||||
Pause();
|
||||
}
|
||||
|
||||
if (CConfig.BackgroundMusicVolume != newVolume)
|
||||
if (Math.Abs(CConfig.BackgroundMusicVolume - newVolume) > 0.01)
|
||||
{
|
||||
CConfig.BackgroundMusicVolume = (int)newVolume;
|
||||
ApplyVolume();
|
||||
@@ -499,7 +499,7 @@ namespace Vocaluxe.Base
|
||||
if (_Video == -1)
|
||||
{
|
||||
_Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath);
|
||||
if (_CurrentPlaylistElement.Start != 0f && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
|
||||
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
|
||||
else
|
||||
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace Vocaluxe.Base
|
||||
if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin ||
|
||||
Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin)
|
||||
{
|
||||
if (_CursorTargetAlpha == 0f)
|
||||
if (_CursorTargetAlpha < 0.01)
|
||||
_Fade(1f, 0.2f);
|
||||
|
||||
_Movetimer.Reset();
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace Vocaluxe.Base
|
||||
space += " ";
|
||||
|
||||
float ms;
|
||||
if (Stopwatch.IsHighResolution && _NanosecPerTick != 0.0)
|
||||
if (Stopwatch.IsHighResolution && _NanosecPerTick > 0)
|
||||
ms = (float)((_NanosecPerTick * _BenchmarkTimer[benchmarkNr].ElapsedTicks) / (1000.0 * 1000.0));
|
||||
else
|
||||
ms = _BenchmarkTimer[benchmarkNr].ElapsedMilliseconds;
|
||||
|
||||
@@ -319,7 +319,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public void CopyScreen(ref STexture texture)
|
||||
{
|
||||
if ((texture.Index == 0) || (texture.Width != GetScreenWidth()) || (texture.Height != GetScreenHeight()))
|
||||
if (texture.Index == 0 || (int)texture.Width != GetScreenWidth() || (int)texture.Height != GetScreenHeight())
|
||||
{
|
||||
RemoveTexture(ref texture);
|
||||
texture = CopyScreen();
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Vocaluxe.Lib.Input
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_Timer.IsRunning && _Duration != 0f)
|
||||
if (!_Timer.IsRunning && Math.Abs(_Duration) > float.Epsilon)
|
||||
{
|
||||
_Timer.Start();
|
||||
return true;
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
_CurrentTime = CSound.GetPosition(_CurrentStream);
|
||||
|
||||
if (_FinishTime != 0 && _CurrentTime >= _FinishTime)
|
||||
if (_FinishTime >0.001 && _CurrentTime >= _FinishTime)
|
||||
finish = true;
|
||||
}
|
||||
else
|
||||
@@ -1237,7 +1237,7 @@ namespace Vocaluxe.Screens
|
||||
return;
|
||||
|
||||
float totalTime = CSound.GetLength(_CurrentStream);
|
||||
if (song.Finish != 0)
|
||||
if (Math.Abs(song.Finish) > 0.001)
|
||||
totalTime = song.Finish;
|
||||
|
||||
float remainingTime = totalTime - _CurrentTime;
|
||||
@@ -1316,7 +1316,7 @@ namespace Vocaluxe.Screens
|
||||
return;
|
||||
|
||||
float totalTime = CSound.GetLength(_CurrentStream);
|
||||
if (song.Finish != 0)
|
||||
if (Math.Abs(song.Finish) > 0.001)
|
||||
totalTime = song.Finish;
|
||||
|
||||
totalTime -= song.Start;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public bool IsAlive
|
||||
{
|
||||
get { return _Age < _MaxAge || _MaxAge == 0f; }
|
||||
get { return _Age < _MaxAge || Math.Abs(_MaxAge) < float.Epsilon; }
|
||||
}
|
||||
#endregion public vars
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace VocaluxeLib.Menu
|
||||
if (Math.Round(Y) < maxy)
|
||||
{
|
||||
float vdx = 0f;
|
||||
if (_Vx != 0)
|
||||
if (Math.Abs(_Vx) > float.Epsilon)
|
||||
vdx = (float)Math.Sin(currentTime / _Vx * Math.PI);
|
||||
|
||||
X += _Vx * timediff * (0.5f + vdx);
|
||||
@@ -242,7 +242,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
|
||||
// update size
|
||||
if (_Vsize != 0f)
|
||||
if (Math.Abs(_Vsize) > float.Epsilon)
|
||||
{
|
||||
float size = _Size;
|
||||
switch (_Type)
|
||||
@@ -275,7 +275,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
// update rotation
|
||||
if (_Vr != 0f)
|
||||
if (Math.Abs(_Vr) > 0.01)
|
||||
{
|
||||
float r = currentTime * _Vr / 60f;
|
||||
_Angle = _Rotation + 360f * (r - (float)Math.Floor(r));
|
||||
|
||||
@@ -503,11 +503,11 @@ namespace VocaluxeLib.Menu
|
||||
writer.WriteElementString("TextH", TextH.ToString("#0.00"));
|
||||
|
||||
writer.WriteComment("<TextRelativeX>: Text relative x-position");
|
||||
if (TextRelativeX != 0)
|
||||
if (Math.Abs(TextRelativeX) > 0.01)
|
||||
writer.WriteElementString("TextRelativeX", TextRelativeX.ToString("#0.00"));
|
||||
|
||||
writer.WriteComment("<TextRelativeY>: Text relative y-position");
|
||||
if (TextRelativeY != 0)
|
||||
if (Math.Abs(TextRelativeY) > 0.01)
|
||||
writer.WriteElementString("TextRelativeY", TextRelativeY.ToString("#0.00"));
|
||||
|
||||
writer.WriteComment("<TextMaxW>: Maximum text width (if exists)");
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace VocaluxeLib.Menu
|
||||
get { return _X; }
|
||||
set
|
||||
{
|
||||
if (_X != value)
|
||||
if (Math.Abs(_X - value) > 0.01)
|
||||
{
|
||||
_X = value;
|
||||
_PositionNeedsUpdate = true;
|
||||
@@ -89,7 +89,7 @@ namespace VocaluxeLib.Menu
|
||||
get { return _Y; }
|
||||
set
|
||||
{
|
||||
if (_Y != value)
|
||||
if (Math.Abs(_Y - value) > 0.01)
|
||||
{
|
||||
_Y = value;
|
||||
_PositionNeedsUpdate = true;
|
||||
@@ -110,7 +110,7 @@ namespace VocaluxeLib.Menu
|
||||
get { return _Height; }
|
||||
set
|
||||
{
|
||||
if (_Height != value)
|
||||
if (Math.Abs(_Height - value) > 0.01)
|
||||
{
|
||||
_Height = value;
|
||||
_PositionNeedsUpdate = true;
|
||||
@@ -124,7 +124,7 @@ namespace VocaluxeLib.Menu
|
||||
get { return _MaxWidth; }
|
||||
set
|
||||
{
|
||||
if (_MaxWidth != value)
|
||||
if (Math.Abs(_MaxWidth - value) > 0.01)
|
||||
{
|
||||
_MaxWidth = value;
|
||||
if (_MaxWidth > 0)
|
||||
@@ -143,7 +143,7 @@ namespace VocaluxeLib.Menu
|
||||
get { return _Bounds; }
|
||||
set
|
||||
{
|
||||
if (_Bounds.X != value.X || _Bounds.Y != value.Y || _Bounds.W != value.W || _Bounds.H != value.H || _Bounds.Z != value.Z)
|
||||
if (Math.Abs(_Bounds.X - value.X) > 0.01 || Math.Abs(_Bounds.Y - value.Y) > 0.01 || Math.Abs(_Bounds.W - value.W) > 0.01 || Math.Abs(_Bounds.H - value.H) > 0.01 || Math.Abs(_Bounds.Z - value.Z) > 0.01)
|
||||
{
|
||||
_Bounds = value;
|
||||
_PositionNeedsUpdate = true;
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace VocaluxeLib.Menu.SingNotes
|
||||
|
||||
float beats = line.LastNoteBeat - line.FirstNoteBeat + 1;
|
||||
|
||||
if (beats == 0)
|
||||
if (beats < 1)
|
||||
return;
|
||||
|
||||
SColorF color = new SColorF(
|
||||
|
||||
@@ -988,7 +988,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
}
|
||||
}
|
||||
|
||||
if (PreviewStart == 0f)
|
||||
if (Math.Abs(PreviewStart) < 0.001)
|
||||
{
|
||||
if (Medley.Source == EMedleySource.Calculated)
|
||||
PreviewStart = CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM);
|
||||
|
||||
@@ -616,7 +616,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
float startposition = CBase.Songs.GetVisibleSong(_Actsong).PreviewStart;
|
||||
|
||||
if (startposition == 0f)
|
||||
if (Math.Abs(startposition) < 0.001)
|
||||
startposition = CBase.Sound.GetLength(stream) / 4f;
|
||||
|
||||
CBase.Sound.SetPosition(stream, startposition);
|
||||
|
||||
@@ -423,7 +423,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
_MedleyTagIcon.Visible = song.Medley.Source == EMedleySource.Tag;
|
||||
|
||||
float time = CBase.Sound.GetLength(_SongStream);
|
||||
if (song.Finish != 0)
|
||||
if (Math.Abs(song.Finish) > 0.001)
|
||||
time = song.Finish;
|
||||
|
||||
time -= song.Start;
|
||||
|
||||
Reference in new issue
Block a user