Mercurial > projects > chipmunkd
comparison trunk/chipmunkd/cpShape.d @ 14:d88862c82f06
more properties
author | Extrawurst |
---|---|
date | Fri, 03 Dec 2010 23:55:20 +0100 |
parents | c03a41d47b60 |
children | df4ebc8add66 |
comparison
equal
deleted
inserted
replaced
13:c03a41d47b60 | 14:d88862c82f06 |
---|---|
97 //cpBB cpShapeCacheBB(cpShape *shape); | 97 //cpBB cpShapeCacheBB(cpShape *shape); |
98 // | 98 // |
99 //// Test if a point lies within a shape. | 99 //// Test if a point lies within a shape. |
100 //cpBool cpShapePointQuery(cpShape *shape, cpVect p); | 100 //cpBool cpShapePointQuery(cpShape *shape, cpVect p); |
101 | 101 |
102 //TODO | 102 template CP_DefineShapeGetter(string _struct,string type,string member,string name) |
103 //#define CP_DeclareShapeGetter(struct, type, name) type struct##Get##name(cpShape *shape) | 103 { |
104 // | 104 enum CP_DefineShapeGetter = |
105 type~" "~_struct~"Get"~name~"(cpShape *shape){"~ | |
106 "assert(shape.klass == &"~_struct~"Class, \"shape is not a "~_struct~"\");"~ | |
107 "return (cast("~_struct~"*)shape)."~member~";"~ | |
108 "}"; | |
109 } | |
105 | 110 |
106 // Circle shape structure. | 111 // Circle shape structure. |
107 struct cpCircleShape{ | 112 struct cpCircleShape{ |
108 cpShape shape; | 113 cpShape shape; |
109 | 114 |
118 | 123 |
119 //// Basic allocation functions for cpCircleShape. | 124 //// Basic allocation functions for cpCircleShape. |
120 //cpCircleShape *cpCircleShapeAlloc(void); | 125 //cpCircleShape *cpCircleShapeAlloc(void); |
121 //cpCircleShape *cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset); | 126 //cpCircleShape *cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset); |
122 //cpShape *cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset); | 127 //cpShape *cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset); |
123 // | 128 |
124 //CP_DeclareShapeGetter(cpCircleShape, cpVect, Offset); | 129 mixin(CP_DefineShapeGetter!("cpCircleShape", "cpVect", "c", "Offset")); |
125 //CP_DeclareShapeGetter(cpCircleShape, cpFloat, Radius); | 130 mixin(CP_DefineShapeGetter!("cpCircleShape", "cpFloat", "r", "Radius")); |
126 | 131 |
127 // Segment shape structure. | 132 // Segment shape structure. |
128 struct cpSegmentShape{ | 133 struct cpSegmentShape{ |
129 cpShape shape; | 134 cpShape shape; |
130 | 135 |
139 // | 144 // |
140 //// Basic allocation functions for cpSegmentShape. | 145 //// Basic allocation functions for cpSegmentShape. |
141 //cpSegmentShape* cpSegmentShapeAlloc(void); | 146 //cpSegmentShape* cpSegmentShapeAlloc(void); |
142 //cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat radius); | 147 //cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat radius); |
143 //cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius); | 148 //cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius); |
144 // | 149 |
145 //CP_DeclareShapeGetter(cpSegmentShape, cpVect, A); | 150 mixin(CP_DefineShapeGetter!("cpSegmentShape", "cpVect", "a", "A")); |
146 //CP_DeclareShapeGetter(cpSegmentShape, cpVect, B); | 151 mixin(CP_DefineShapeGetter!("cpSegmentShape", "cpVect", "b", "B")); |
147 //CP_DeclareShapeGetter(cpSegmentShape, cpVect, Normal); | 152 mixin(CP_DefineShapeGetter!("cpSegmentShape", "cpVect", "n", "Normal")); |
148 //CP_DeclareShapeGetter(cpSegmentShape, cpFloat, Radius); | 153 mixin(CP_DefineShapeGetter!("cpSegmentShape", "cpFloat", "r", "Radius")); |
149 // | 154 // |
150 //// For determinism, you can reset the shape id counter. | 155 //// For determinism, you can reset the shape id counter. |
151 //void cpResetShapeIdCounter(void); | 156 //void cpResetShapeIdCounter(void); |
152 // | 157 // |
153 //// Directed segment queries against individual shapes. | 158 //// Directed segment queries against individual shapes. |
329 cpShape * | 334 cpShape * |
330 cpCircleShapeNew(cpBody *_body, cpFloat radius, cpVect offset) | 335 cpCircleShapeNew(cpBody *_body, cpFloat radius, cpVect offset) |
331 { | 336 { |
332 return cast(cpShape *)cpCircleShapeInit(cpCircleShapeAlloc(), _body, radius, offset); | 337 return cast(cpShape *)cpCircleShapeInit(cpCircleShapeAlloc(), _body, radius, offset); |
333 } | 338 } |
334 //TODO: | |
335 //CP_DefineShapeGetter(cpCircleShape, cpVect, c, Offset) | |
336 //CP_DefineShapeGetter(cpCircleShape, cpFloat, r, Radius) | |
337 | 339 |
338 cpSegmentShape * | 340 cpSegmentShape * |
339 cpSegmentShapeAlloc() | 341 cpSegmentShapeAlloc() |
340 { | 342 { |
341 return cast(cpSegmentShape *)cpcalloc(1, cpSegmentShape.sizeof); | 343 return cast(cpSegmentShape *)cpcalloc(1, cpSegmentShape.sizeof); |
485 cpShape* | 487 cpShape* |
486 cpSegmentShapeNew(cpBody *_body, cpVect a, cpVect b, cpFloat r) | 488 cpSegmentShapeNew(cpBody *_body, cpVect a, cpVect b, cpFloat r) |
487 { | 489 { |
488 return cast(cpShape *)cpSegmentShapeInit(cpSegmentShapeAlloc(), _body, a, b, r); | 490 return cast(cpShape *)cpSegmentShapeInit(cpSegmentShapeAlloc(), _body, a, b, r); |
489 } | 491 } |
490 //TODO: | |
491 //CP_DefineShapeGetter(cpSegmentShape, cpVect, a, A) | |
492 //CP_DefineShapeGetter(cpSegmentShape, cpVect, b, B) | |
493 //CP_DefineShapeGetter(cpSegmentShape, cpVect, n, Normal) | |
494 //CP_DefineShapeGetter(cpSegmentShape, cpFloat, r, Radius) | |
495 | 492 |
496 // Unsafe API (chipmunk_unsafe.h) | 493 // Unsafe API (chipmunk_unsafe.h) |
497 | 494 |
498 void | 495 void |
499 cpCircleShapeSetRadius(cpShape *shape, cpFloat radius) | 496 cpCircleShapeSetRadius(cpShape *shape, cpFloat radius) |