With Permission from Jeff Faust. // AFX CODE BLOCK (bug-fix) << // avoids a divide-by-zero when maxEnergy is set to zero.