Example #1
0
// applyImpulse updates the linear and angular velocity change needed to
// solve constraints.
func (sb *solverBody) applyImpulse(linearComponent, angularComponent *lin.V3, impulseMagnitude float64) {
	if sb.oBody != nil {
		sb.deltaLinearVelocity.Add(sb.deltaLinearVelocity, linearComponent.Scale(linearComponent, impulseMagnitude))
		sb.deltaAngularVelocity.Add(sb.deltaAngularVelocity, angularComponent.Scale(angularComponent, impulseMagnitude))
	}
}
Example #2
0
// applyPushImpulse updates the push and turn velocity used to separate
// inter-penetrating bodies.
func (sb *solverBody) applyPushImpulse(linearComponent, angularComponent *lin.V3, impulseMagnitude float64) {
	if sb.oBody != nil {
		sb.pushVelocity.Add(sb.pushVelocity, linearComponent.Scale(linearComponent, impulseMagnitude))
		sb.turnVelocity.Add(sb.turnVelocity, angularComponent.Scale(angularComponent, impulseMagnitude))
	}
}