I always keep in mind...
... that hauling yourself down to the lowest velocity is most important. You can't brake while swerving. So if you've only got a split second to decide than brake as hard as you can. It's better to hit him at 15 mph than to swerve and get clipped at 45 mph.I'd say you did it just right. Was there some luck involved? Maybe, but it was luck that you made.
Your regret seems to be focused on the fact that you braked rather than swerved. Was swerving even an option? In that situation, you'd have to be able to swerve to the right to go behind him (you wouldn't want to cross ahead of him). But then you'd have to know absolutely for sure that the lane(s) to your right were clear. If you didn't already know that--and you certainly didn't have time to check--braking was your only option.
You also seem to have second thoughts about your mental braking technique. Once you decided to brake, your main concern should have been effective braking. After that decision was made, the biggest controllable danger you faced was brake lockup. At that point you shouldn't worry about T-boning the truck, because it would just distract you. You need to concentrate every neuron on braking well.
Give yourself more credit for what you did right. Speed, awareness, expecting the incursion, and being ready to act are what saved you.