Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Unified Diff: sky/framework/animation/mechanics.dart

Issue 1008423002: Remove the "min velocity" hack from ParticleClimbingRamp (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/framework/animation/mechanics.dart
diff --git a/sky/framework/animation/mechanics.dart b/sky/framework/animation/mechanics.dart
index d862d75c8d38a3c08660b20d33ca5e0a16c56438..5df2833619d7d30b781f040fe3cd7742fae0f4a3 100644
--- a/sky/framework/animation/mechanics.dart
+++ b/sky/framework/animation/mechanics.dart
@@ -5,7 +5,6 @@
import 'dart:math' as math;
const double kGravity = -0.980;
-const double _kMinVelocity = 0.01;
abstract class System {
void update(double deltaT);
@@ -132,12 +131,12 @@ class ParticleClimbingRamp extends System {
}
void update(double deltaT) {
- particle.applyImpluse(kGravity * slope * deltaT);
- // If we don't apply a min velocity, error terms in the simulation can
- // prevent us from reaching the targetPosition before gravity overtakes our
- // initial velocity and we start rolling down the hill.
- particle.velocity = math.max(_kMinVelocity, particle.velocity);
particle.update(deltaT);
+ // Note that we apply the impluse from gravity after updating the particle's
+ // position so that we overestimate the distance traveled by the particle.
+ // That ensures that we actually hit the edge of the box and don't wind up
+ // reversing course.
+ particle.applyImpluse(kGravity * slope * deltaT);
box.confine(particle);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698