collising detection and prevention. TODO: prevent false collision
positives on internal edges