meiyunyang / chipmunk-physics

Automatically exported from code.google.com/p/chipmunk-physics
MIT License
0 stars 0 forks source link

CGPoint <-> cpVect equivalency on Mac (cocos2d project) #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
When creating a new project using cocos2d and Chipmunk on MacOS, the CGPoint 
equivalence with cpVect is lost, this small patch fixes it.

diff --git a/external/Chipmunk/include/chipmunk/chipmunk_types.h 
b/external/Chipmunk/include/chipmunk/chipmunk_types.h
index 665302b..5e3f123 100644
--- a/external/Chipmunk/include/chipmunk/chipmunk_types.h
+++ b/external/Chipmunk/include/chipmunk/chipmunk_types.h
@@ -74,10 +74,14 @@ cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d)
    return f1 + cpfclamp(f2 - f1, -d, d);
 }

-#if TARGET_OS_IPHONE
+#if TARGET_OS_IPHONE || TARGET_OS_MAC
    // CGPoints are structurally the same, and allow
    // easy interoperability with other iPhone libraries
+#if TARGET_OS_IPHONE
    #import <CoreGraphics/CGGeometry.h>
+#else
+   #import <ApplicationServices/ApplicationServices.h>
+#endif
    typedef CGPoint cpVect;
 #else
    typedef struct cpVect{cpFloat x,y;} cpVect;

Original issue reported on code.google.com by rola...@gamesforfood.cl on 17 Nov 2010 at 9:18

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry about the delay. I came up with a little more generic solution to that 
and it's in trunk now. I added a flag CP_USE_CGPOINTS that you can set to build 
chipmunk to use CGPoints. It's set by default on iOS (like it was before) where 
there isn't really a reason not to always use CGPoints. 5.3.3 should be out 
very soon with that change.

Original comment by slemb...@gmail.com on 7 Dec 2010 at 2:08

GoogleCodeExporter commented 8 years ago

Original comment by slemb...@gmail.com on 7 Dec 2010 at 2:09

GoogleCodeExporter commented 8 years ago
excellent! can't wait for 5.3.3 :-D

Original comment by rola...@gamesforfood.cl on 7 Dec 2010 at 10:54