objective c - Collision detect on irregular shapes -


i've been working while on complicated problem. now, i'm posting here, hoping can give me hint solution.

the problem, stated on topic, collision detect on irregular shapes (uiview).

what i've done far:

using this starting point, i've done uiimageview subclass can check alpha/non-alpha points on frame property. on uipangesturerecognizer selector of object, i've attached check see if moved on obstacle (not alpha) or not:

- (void)panning:(id)sender {     uipangesturerecognizer = (uipangesturerecognizer *)sender;      if([(uipangesturerecognizer*)sender state] == uigesturerecognizerstateended) {         startpoint = cgpointzero;         oldpoint = cgpointzero;         return;     }     actualpoint = [(uipangesturerecognizer*)sender translationinview:parentview];      if(cgaffinetransformisidentity(panning)) {         panning = cgaffinetransformmaketranslation(actualpoint.x - startpoint.x, actualpoint.y - startpoint.y);     } else {         panning = cgaffinetransformtranslate(panning, actualpoint.x - startpoint.x, actualpoint.y - startpoint.y);     }      [self settransform:panning];      for(uiview *anobstacle in obstaclesarray) {         cgrect intersection = cgrectintersection(self.frame, anobstacle.frame);         if([anobstacle checkalpha:intersection] != null) {              nslog(@"booooooooooom");         }     } } 

all working well, except performance. check slow production application.

is there workaround or solution don't know, in order solve issue?

hoping clear, best regards

can generate circle around irregular objects reduce initial computation, , if there collision circle, go ahead , check if colliding. set of points checked potentially reduced based on over circle collision detected.


Comments

Popular posts from this blog

sql - text truncated using perl DBI insert -

c++ - Is it possible to compile a VST on linux? -

php - Pass object by reference or value -