-
Notifications
You must be signed in to change notification settings - Fork 34
Conversation
// We store the current value as an offset from the target rather than an absolute value, | ||
// because this provides higher precision when the value is getting close to the target and `T` | ||
// is a type of floating-point numbers, vectors of floating point numbers, or similar. The main | ||
// benefit is that we avoid non-termination that could otherwise happen due to rounding errors | ||
// when the target and current value are large. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand this description. "this provides higher precision when the value is getting close to the target" - why? Could you describe it with some examples and better explanation, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried to improve the explanation. Let me know if it is better.
fn animation_to_nan() { | ||
let mut data = SimulationData::<f32>::new(); | ||
data.set_value(0.0); | ||
data.set_target_value(f32::NAN); | ||
data.step(1.0); | ||
assert!(data.value().is_nan()); | ||
assert!(!data.active); | ||
} | ||
|
||
#[test] | ||
fn animation_from_nan() { | ||
let mut data = SimulationData::<f32>::new(); | ||
data.set_value(f32::NAN); | ||
data.set_target_value(0.0); | ||
data.step(1.0); | ||
assert_eq!(data.value(),0.0); | ||
assert!(!data.active); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add comments what these tests are for and how they should behave. They are testing a corner cases and this needs additional explanation
CHANGELOG.md
Outdated
editing node expression, the changes were occasionally reverted, or the | ||
grayed-out parameter names were added to the actual expression. | ||
- [Fixed freezing after inactivity.][1776] When the IDE window was minimized or |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in the "Next Release" section.
self.velocity = default(); | ||
self.active = false; | ||
if should_snap || distance.is_nan() { | ||
self.offset_from_target = default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a ::zero()
method available for Value
? That might be clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we do. But I agree with you. Maybe the Zero
trait should be included in the definition of Value
. But the code used default()
for zero before. It might have been a conscious decision.
let spring_stretch = value_delta.magnitude(); | ||
let coefficient = spring_stretch * self.spring.value; | ||
value_delta.normalize() * coefficient | ||
self.offset_from_target * -self.spring.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this subtraction is written as -value
, while other ones are value * -1.0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one is more readable. But the second one is necessary for values satisfying only the trait Value
, because we do not have subtraction on that trait.
# Conflicts: # CHANGELOG.md
Original commit: enso-org/ide@c67538b
Pull Request Description
This PR fixes issue #1748.
It solves multiple problems:
Important Notes
Checklist
Please include the following checklist in your PR:
CHANGELOG.md
was updated with the changes introduced in this PR.