Two million years of rain sparked the dinosaur's reign