We proposed a general optimization-based receding-horizon lattice-based motion planning framework with collision avoidance functionality for both complex 3D environments and moving obstacles. This includes planning with both dynamics and time, such that the quadcopter can plan trajectories around, and move out of the way of, other agents. We also demonstrated real-time performance on a difficult warehouse scenario with multiple moving obstacles, both people and other UAVs flying at varying altitudes. To the best of our knowledge, no other optimization-based and dynamically-feasible approach has demonstrated this capability in real-time.