2022-01-20 21:58:50 +08:00
|
|
|
package util
|
|
|
|
|
2024-08-02 18:38:33 +08:00
|
|
|
import "edgaru089.ink/go/gl01/internal/util/itype"
|
2022-01-20 21:58:50 +08:00
|
|
|
|
|
|
|
func BunnyhopAccelerate(accelDir, prevVel itype.Vec3d, accelVel, maxVel float64) (resultVel itype.Vec3d) {
|
|
|
|
if accelVel < 1e-4 {
|
|
|
|
return prevVel
|
|
|
|
}
|
|
|
|
projVel := prevVel.Dot(accelDir)
|
|
|
|
if projVel+accelVel > maxVel {
|
|
|
|
accelVel = maxVel - projVel
|
|
|
|
}
|
|
|
|
|
|
|
|
return prevVel.Add(accelDir.Normalize().Multiply(accelVel))
|
|
|
|
}
|