The quake off Sumatra badly damaged buildings along the coast and could be felt in at least four countries, with tall buildings swaying as far as 1,200 miles away.