Skip to content

Commit b1add5e

Browse files
committed
Avoid conversions when possible.
Former-commit-id: 8cd3903
1 parent 49163bf commit b1add5e

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cocos2d/CCPhysicsNode.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,13 @@ -(void)setDebugDraw:(BOOL)debugDraw
454454
static void
455455
DrawPolygon(int count, const cpVect *verts, cpFloat r, cpSpaceDebugColor outline, cpSpaceDebugColor fill, CCDrawNode *draw)
456456
{
457-
// TODO avoid copy on 32bit?
458-
457+
#if !CP_USE_CGTYPES
459458
CGPoint _verts[count];
460459
for(int i=0; i<count; i++) _verts[i] = CPV_TO_CCP(verts[i]);
461-
462460
[draw drawPolyWithVerts:_verts count:count fillColor:ToCCColor(fill) borderWidth:1.0 borderColor:ToCCColor(outline)];
461+
#else
462+
[draw drawPolyWithVerts:verts count:count fillColor:ToCCColor(fill) borderWidth:1.0 borderColor:ToCCColor(outline)];
463+
#endif
463464
}
464465

465466
static void

cocos2d/CCPhysicsShape.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,13 @@ -(id)initWithPolygonFromPoints:(CGPoint *)points count:(NSUInteger)count cornerR
329329
_points = calloc(count, sizeof(cpVect));
330330
_count = count;
331331

332+
#if !CP_USE_CGTYPES
332333
for(NSUInteger i=0; i<count; i++){
333334
_points[i] = CCP_TO_CPV(points[i]);
334335
}
336+
#else
337+
memcpy(_points, points, count*sizeof(CGPoint));
338+
#endif
335339

336340
_shape = [ChipmunkPolyShape polyWithBody:nil count:(int)_count verts:_points transform:cpTransformIdentity radius:_radius];
337341

0 commit comments

Comments
 (0)