void RenderingEngine::HandleTouchesBegan(vector<Touch *> &rTouches) const { m_touches->insert(m_touches->end(), rTouches.begin(), rTouches.end()); for (int touchIndex = 0; touchIndex < rTouches.size(); touchIndex++) { Touch *touch = rTouches[touchIndex]; Point3 touchPosition = touch->GetProjectionPosition(); DrawingComponent *hitDrawing = m_drawingController->GetDrawing()->HitTest(touchPosition); touch->SetDrawingComponent(hitDrawing); } map<DrawingComponent *, vector<Touch *>> sortedTouches = SortTouchesByDrawingComponent(rTouches); for (map<DrawingComponent *, vector<Touch *>>::iterator iterator = sortedTouches.begin(); iterator != sortedTouches.end(); iterator++) { DrawingComponent *pDrawing = iterator->first; vector<Touch *> &rDrawingTouches = iterator->second; pDrawing->TouchesBegan(rDrawingTouches); } }