16 lines
377 B
Go
16 lines
377 B
Go
package util
|
|
|
|
import "edgaru089.ml/go/gl01/internal/util/itype"
|
|
|
|
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))
|
|
}
|