浏览代码

performance improvements...

/main
kg 5 年前
当前提交
996fd32d
共有 2 个文件被更改,包括 9 次插入9 次删除
  1. 2
      Runtime/physics/friction_simulation.cs
  2. 16
      Runtime/physics/spring_simulation.cs

2
Runtime/physics/friction_simulation.cs


readonly float _v;
static float _dragFor(float startPosition, float endPosition, float startVelocity, float endVelocity) {
return Mathf.Pow(Mathf.Epsilon, (startVelocity - endVelocity) / (startPosition - endPosition));
return Mathf.Pow((float) Math.E, (startVelocity - endVelocity) / (startPosition - endPosition));
}
public override float x(float time) {

16
Runtime/physics/spring_simulation.cs


readonly float _r, _c1, _c2;
public override float x(float time) {
return ((this._c1 + this._c2 * time) * Mathf.Pow(Mathf.Epsilon, this._r * time));
return ((this._c1 + this._c2 * time) * Mathf.Pow((float) Math.E, this._r * time));
float power = Mathf.Pow(Mathf.Epsilon, this._r * time);
float power = Mathf.Pow((float) Math.E, this._r * time);
return (this._r * (this._c1 + this._c2 * time) * power + this._c2 * power);
}

readonly float _r1, _r2, _c1, _c2;
public override float x(float time) {
return (this._c1 * Mathf.Pow(Mathf.Epsilon, this._r1 * time) +
this._c2 * Mathf.Pow(Mathf.Epsilon, this._r2 * time));
return (this._c1 * Mathf.Pow((float) Math.E, this._r1 * time) +
this._c2 * Mathf.Pow((float) Math.E, this._r2 * time));
return (this._c1 * this._r1 * Mathf.Pow(Mathf.Epsilon, this._r1 * time) +
this._c2 * this._r2 * Mathf.Pow(Mathf.Epsilon, this._r2 * time));
return (this._c1 * this._r1 * Mathf.Pow((float) Math.E, this._r1 * time) +
this._c2 * this._r2 * Mathf.Pow((float) Math.E, this._r2 * time));
}
public override SpringType type {

readonly float _w, _r, _c1, _c2;
public override float x(float time) {
return (Mathf.Pow(Mathf.Epsilon, this._r * time) *
return (Mathf.Pow((float) Math.E, this._r * time) *
float power = Mathf.Pow(Mathf.Epsilon, this._r * time);
float power = Mathf.Pow((float) Math.E, this._r * time);
float cosine = Mathf.Cos(this._w * time);
float sine = Mathf.Sin(this._w * time);
return (power * (this._c2 * this._w * cosine - this._c1 * this._w * sine) +

正在加载...
取消
保存