Skip to content

Commit 967d98d

Browse files
author
teejay
committed
Somemwhat optimized the line drawing for hopefully lower resource intensive collisions.
1 parent 7f52c5d commit 967d98d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

FlickBall/MFLDynamicsHelpers/Alpha Only Collision/MFLAlphaCollision.m

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ + (void)addBoundaryToBehavior:(UICollisionBehavior*)behavior
3636
UIImage *flippedImage = [imageView.image imageRotatedByDegrees:180];
3737

3838
UIBezierPath *viewPath = [[[PathBuilder alloc] initWithMask:flippedImage.CGImage] path];
39+
[viewPath setMiterLimit:20];
3940
[viewPath applyTransform:CGAffineTransformMakeTranslation(imageView.frame.origin.x, imageView.frame.origin.y)];
4041
[behavior addBoundaryWithIdentifier:identifier forPath:viewPath];
4142
}

FlickBall/MFLDynamicsHelpers/Alpha Only Collision/PathBuilder.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ - (UIBezierPath *) convertSegmentsIntoPath:(NSMutableDictionary*)segments
185185
// until all line segments have been consumed.
186186

187187
UIBezierPath *path = [UIBezierPath bezierPath];
188-
188+
[path setLineJoinStyle:kCGLineJoinRound];
189189
// While we still have line segments to consume, unwind one bezier path
190190
while ( [segments count] > 0 )
191191
[self unwindOneSegmentPath:segments intoPath:path];
@@ -318,7 +318,7 @@ - (void) addPoint:(CGPoint)newPoint toPath:(UIBezierPath *)path cachedPoint1:(CG
318318
*point2 = newPoint;
319319
} else {
320320
// We changed direction, so flush the current segment, and reset the cache
321-
[path addLineToPoint:*point2];
321+
[path addQuadCurveToPoint:*point2 controlPoint:*point1];
322322

323323
*point1 = *point2;
324324
*point2 = newPoint;

0 commit comments

Comments
 (0)