Adaptive Trajectory Refinement for Optimization-based Local Planning in Narrow Passages