Transition from damage to fragmentation in collision of solids