-
-
Notifications
You must be signed in to change notification settings - Fork 911
/
ComputeConstCurve.cs
58 lines (52 loc) · 1.54 KB
/
ComputeConstCurve.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright (c) Stride contributors (https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using Stride.Core;
using Stride.Core.Annotations;
namespace Stride.Animations
{
/// <summary>
/// A node which describes a constant value for a compute curve
/// </summary>
/// <typeparam name="T">Sampled data's type</typeparam>
[DataContract(Inherited = true)]
[Display("Constant")]
[InlineProperty]
public class ComputeConstCurve<T> : IComputeCurve<T> where T : struct
{
/// <summary>
/// Constant value to return every time this flat curve is sampled
/// </summary>
/// <userdoc>
/// The constant value to return every time this flat function is sampled
/// </userdoc>
[DataMember(10)]
[Display("Value")]
[InlineProperty]
public T Value
{
get { return typeValue; }
set
{
typeValue = value;
hasChanged = true;
}
}
private T typeValue;
private bool hasChanged = true;
/// <inheritdoc/>
public bool UpdateChanges()
{
if (hasChanged)
{
hasChanged = false;
return true;
}
return false;
}
/// <inheritdoc/>
public T Evaluate(float location)
{
return Value;
}
}
}