Skip to content
This repository was archived by the owner on Apr 29, 2021. It is now read-only.

Commit 47c4c94

Browse files
committed
performance improvements...
1 parent c332637 commit 47c4c94

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Runtime/physics/friction_simulation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static FrictionSimulation through(float startPosition, float endPosition,
3535
readonly float _v;
3636

3737
static float _dragFor(float startPosition, float endPosition, float startVelocity, float endVelocity) {
38-
return Mathf.Pow(Mathf.Epsilon, (startVelocity - endVelocity) / (startPosition - endPosition));
38+
return Mathf.Pow((float) Math.E, (startVelocity - endVelocity) / (startPosition - endPosition));
3939
}
4040

4141
public override float x(float time) {

Runtime/physics/spring_simulation.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,11 @@ float velocity
140140
readonly float _r, _c1, _c2;
141141

142142
public override float x(float time) {
143-
return ((this._c1 + this._c2 * time) * Mathf.Pow(Mathf.Epsilon, this._r * time));
143+
return ((this._c1 + this._c2 * time) * Mathf.Pow((float) Math.E, this._r * time));
144144
}
145145

146146
public override float dx(float time) {
147-
float power = Mathf.Pow(Mathf.Epsilon, this._r * time);
147+
float power = Mathf.Pow((float) Math.E, this._r * time);
148148
return (this._r * (this._c1 + this._c2 * time) * power + this._c2 * power);
149149
}
150150

@@ -179,13 +179,13 @@ float velocity
179179
readonly float _r1, _r2, _c1, _c2;
180180

181181
public override float x(float time) {
182-
return (this._c1 * Mathf.Pow(Mathf.Epsilon, this._r1 * time) +
183-
this._c2 * Mathf.Pow(Mathf.Epsilon, this._r2 * time));
182+
return (this._c1 * Mathf.Pow((float) Math.E, this._r1 * time) +
183+
this._c2 * Mathf.Pow((float) Math.E, this._r2 * time));
184184
}
185185

186186
public override float dx(float time) {
187-
return (this._c1 * this._r1 * Mathf.Pow(Mathf.Epsilon, this._r1 * time) +
188-
this._c2 * this._r2 * Mathf.Pow(Mathf.Epsilon, this._r2 * time));
187+
return (this._c1 * this._r1 * Mathf.Pow((float) Math.E, this._r1 * time) +
188+
this._c2 * this._r2 * Mathf.Pow((float) Math.E, this._r2 * time));
189189
}
190190

191191
public override SpringType type {
@@ -219,12 +219,12 @@ float velocity
219219
readonly float _w, _r, _c1, _c2;
220220

221221
public override float x(float time) {
222-
return (Mathf.Pow(Mathf.Epsilon, this._r * time) *
222+
return (Mathf.Pow((float) Math.E, this._r * time) *
223223
(this._c1 * Mathf.Cos(this._w * time) + this._c2 * Mathf.Sin(this._w * time)));
224224
}
225225

226226
public override float dx(float time) {
227-
float power = Mathf.Pow(Mathf.Epsilon, this._r * time);
227+
float power = Mathf.Pow((float) Math.E, this._r * time);
228228
float cosine = Mathf.Cos(this._w * time);
229229
float sine = Mathf.Sin(this._w * time);
230230
return (power * (this._c2 * this._w * cosine - this._c1 * this._w * sine) +

0 commit comments

Comments
 (0)