| 1 |
/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software |
| 2 |
* |
| 3 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 |
* of this software and associated documentation files (the "Software"), to deal |
| 5 |
* in the Software without restriction, including without limitation the rights |
| 6 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 |
* copies of the Software, and to permit persons to whom the Software is |
| 8 |
* furnished to do so, subject to the following conditions: |
| 9 |
* |
| 10 |
* The above copyright notice and this permission notice shall be included in |
| 11 |
* all copies or substantial portions of the Software. |
| 12 |
* |
| 13 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 |
* SOFTWARE. |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "chipmunk/chipmunk_private.h"cxx . . $ `<file>/include/chipmunk/chipmunk_private.h`/ |
| 23 |
#include "chipmunk/chipmunk_unsafe.h"cxx . . $ `<file>/include/chipmunk/chipmunk_unsafe.h`/ |
| 24 |
|
| 25 |
#define CP_DefineShapeGettercxx . . $ `src/cpShape.c:25:9`!(struct, type, member, name) \ |
| 26 |
CP_DeclareShapeGetter(struct, type, name){ \ |
| 27 |
cpAssertHard(shape->klass == &struct##Class, "shape is not a "#struct); \ |
| 28 |
return ((struct *)shape)->member; \ |
| 29 |
} |
| 30 |
|
| 31 |
cpShapecxx . . $ cpShape# * |
| 32 |
cpShapeInitcxx . . $ cpShapeInit(fe460fb3c2ea2ff0).(cpShapecxx . . $ cpShape# *shape, const cpShapeClasscxx . . $ cpShapeClass# *klass, cpBodycxx . . $ cpBody# *body, struct cpShapeMassInfocxx . . $ cpShapeMassInfo# massInfo) |
| 33 |
{ |
| 34 |
shape->klasscxx . . $ cpShape#klass. = klass; |
| 35 |
|
| 36 |
shape->bodycxx . . $ cpShape#body. = body; |
| 37 |
shape->massInfocxx . . $ cpShape#massInfo. = massInfo; |
| 38 |
|
| 39 |
shape->sensorcxx . . $ cpShape#sensor. = 0; |
| 40 |
|
| 41 |
shape->ecxx . . $ cpShape#e. = 0.0f; |
| 42 |
shape->ucxx . . $ cpShape#u. = 0.0f; |
| 43 |
shape->surfaceVcxx . . $ cpShape#surfaceV. = cpvzerocxx . . $ cpvzero.; |
| 44 |
|
| 45 |
shape->typecxx . . $ cpShape#type. = 0; |
| 46 |
shape->filtercxx . . $ cpShape#filter..groupcxx . . $ cpShapeFilter#group. = CP_NO_GROUPcxx . . $ `include/chipmunk/chipmunk_types.h:228:10`!; |
| 47 |
shape->filtercxx . . $ cpShape#filter..categoriescxx . . $ cpShapeFilter#categories. = CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!; |
| 48 |
shape->filtercxx . . $ cpShape#filter..maskcxx . . $ cpShapeFilter#mask. = CP_ALL_CATEGORIEScxx . . $ `include/chipmunk/chipmunk_types.h:233:10`!; |
| 49 |
|
| 50 |
shape->userDatacxx . . $ cpShape#userData. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 51 |
|
| 52 |
shape->spacecxx . . $ cpShape#space. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 53 |
|
| 54 |
shape->nextcxx . . $ cpShape#next. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 55 |
shape->prevcxx . . $ cpShape#prev. = NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!; |
| 56 |
|
| 57 |
return shape; |
| 58 |
} |
| 59 |
|
| 60 |
void |
| 61 |
cpShapeDestroycxx . . $ cpShapeDestroy(49d28a84d341894).(cpShapecxx . . $ cpShape# *shape) |
| 62 |
{ |
| 63 |
if(shape->klasscxx . . $ cpShape#klass. && shape->klasscxx . . $ cpShape#klass.->destroycxx . . $ cpShapeClass#destroy.) shape->klasscxx . . $ cpShape#klass.->destroycxx . . $ cpShapeClass#destroy.(shape); |
| 64 |
} |
| 65 |
|
| 66 |
void |
| 67 |
cpShapeFreecxx . . $ cpShapeFree(49d28a84d341894).(cpShapecxx . . $ cpShape# *shape) |
| 68 |
{ |
| 69 |
if(shape){ |
| 70 |
cpShapeDestroycxx . . $ cpShapeDestroy(49d28a84d341894).(shape); |
| 71 |
cpfreecxx . . $ `include/chipmunk/chipmunk.h:82:10`!(shape); |
| 72 |
} |
| 73 |
} |
| 74 |
|
| 75 |
cpSpacecxx . . $ cpSpace# * |
| 76 |
cpShapeGetSpacecxx . . $ cpShapeGetSpace(275806f4eec241f1).(const cpShapecxx . . $ cpShape# *shape) |
| 77 |
{ |
| 78 |
return shape->spacecxx . . $ cpShape#space.; |
| 79 |
} |
| 80 |
|
| 81 |
cpBodycxx . . $ cpBody# * |
| 82 |
cpShapeGetBodycxx . . $ cpShapeGetBody(abc772114277478f).(const cpShapecxx . . $ cpShape# *shape) |
| 83 |
{ |
| 84 |
return shape->bodycxx . . $ cpShape#body.; |
| 85 |
} |
| 86 |
|
| 87 |
void |
| 88 |
cpShapeSetBodycxx . . $ cpShapeSetBody(9f8bf64d3e40beb).(cpShapecxx . . $ cpShape# *shape, cpBodycxx . . $ cpBody# *body) |
| 89 |
{ |
| 90 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(!cpShapeActive(shape), "You cannot change the body on an active shape. You must remove the shape from the space before changing the body."); |
| 91 |
shape->bodycxx . . $ cpShape#body. = body; |
| 92 |
} |
| 93 |
|
| 94 |
cpFloatcxx . . $ cpFloat# cpShapeGetMasscxx . . $ cpShapeGetMass(43ed29e1cacd1d72).(cpShapecxx . . $ cpShape# *shape){ return shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m.; } |
| 95 |
|
| 96 |
void |
| 97 |
cpShapeSetMasscxx . . $ cpShapeSetMass(2eca2465ee202d41).(cpShapecxx . . $ cpShape# *shape, cpFloatcxx . . $ cpFloat# mass){ |
| 98 |
cpBodycxx . . $ cpBody# *body = shape->bodycxx . . $ cpShape#body.; |
| 99 |
cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(body); |
| 100 |
|
| 101 |
shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m. = mass; |
| 102 |
cpBodyAccumulateMassFromShapescxx . . $ cpBodyAccumulateMassFromShapes(92943d3541b63e72).(body); |
| 103 |
} |
| 104 |
|
| 105 |
cpFloatcxx . . $ cpFloat# cpShapeGetDensitycxx . . $ cpShapeGetDensity(43ed29e1cacd1d72).(cpShapecxx . . $ cpShape# *shape){ return shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m./shape->massInfocxx . . $ cpShape#massInfo..areacxx . . $ cpShapeMassInfo#area.; } |
| 106 |
void cpShapeSetDensitycxx . . $ cpShapeSetDensity(2eca2465ee202d41).(cpShapecxx . . $ cpShape# *shape, cpFloatcxx . . $ cpFloat# density){ cpShapeSetMasscxx . . $ cpShapeSetMass(2eca2465ee202d41).(shape, density*shape->massInfocxx . . $ cpShape#massInfo..areacxx . . $ cpShapeMassInfo#area.); } |
| 107 |
|
| 108 |
cpFloatcxx . . $ cpFloat# cpShapeGetMomentcxx . . $ cpShapeGetMoment(43ed29e1cacd1d72).(cpShapecxx . . $ cpShape# *shape){ return shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m.*shape->massInfocxx . . $ cpShape#massInfo..icxx . . $ cpShapeMassInfo#i.; } |
| 109 |
cpFloatcxx . . $ cpFloat# cpShapeGetAreacxx . . $ cpShapeGetArea(43ed29e1cacd1d72).(cpShapecxx . . $ cpShape# *shape){ return shape->massInfocxx . . $ cpShape#massInfo..areacxx . . $ cpShapeMassInfo#area.; } |
| 110 |
cpVectcxx . . $ cpVect# cpShapeGetCenterOfGravitycxx . . $ cpShapeGetCenterOfGravity(6264bca344117c55).(cpShapecxx . . $ cpShape# *shape) { return shape->massInfocxx . . $ cpShape#massInfo..cogcxx . . $ cpShapeMassInfo#cog.; } |
| 111 |
|
| 112 |
cpBBcxx . . $ cpBB# |
| 113 |
cpShapeGetBBcxx . . $ cpShapeGetBB(44a9343cdf942fdb).(const cpShapecxx . . $ cpShape# *shape) |
| 114 |
{ |
| 115 |
return shape->bbcxx . . $ cpShape#bb.; |
| 116 |
} |
| 117 |
|
| 118 |
cpBoolcxx . . $ cpBool# |
| 119 |
cpShapeGetSensorcxx . . $ cpShapeGetSensor(1e47cac20e9f9f40).(const cpShapecxx . . $ cpShape# *shape) |
| 120 |
{ |
| 121 |
return shape->sensorcxx . . $ cpShape#sensor.; |
| 122 |
} |
| 123 |
|
| 124 |
void |
| 125 |
cpShapeSetSensorcxx . . $ cpShapeSetSensor(eff4d15739771431).(cpShapecxx . . $ cpShape# *shape, cpBoolcxx . . $ cpBool# sensor) |
| 126 |
{ |
| 127 |
cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 128 |
shape->sensorcxx . . $ cpShape#sensor. = sensor; |
| 129 |
} |
| 130 |
|
| 131 |
cpFloatcxx . . $ cpFloat# |
| 132 |
cpShapeGetElasticitycxx . . $ cpShapeGetElasticity(1bf41e75729c6179).(const cpShapecxx . . $ cpShape# *shape) |
| 133 |
{ |
| 134 |
return shape->ecxx . . $ cpShape#e.; |
| 135 |
} |
| 136 |
|
| 137 |
void |
| 138 |
cpShapeSetElasticitycxx . . $ cpShapeSetElasticity(2eca2465ee202d41).(cpShapecxx . . $ cpShape# *shape, cpFloatcxx . . $ cpFloat# elasticity) |
| 139 |
{ |
| 140 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(elasticity >= 0.0f, "Elasticity must be positive."); |
| 141 |
cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 142 |
shape->ecxx . . $ cpShape#e. = elasticity; |
| 143 |
} |
| 144 |
|
| 145 |
cpFloatcxx . . $ cpFloat# |
| 146 |
cpShapeGetFrictioncxx . . $ cpShapeGetFriction(1bf41e75729c6179).(const cpShapecxx . . $ cpShape# *shape) |
| 147 |
{ |
| 148 |
return shape->ucxx . . $ cpShape#u.; |
| 149 |
} |
| 150 |
|
| 151 |
void |
| 152 |
cpShapeSetFrictioncxx . . $ cpShapeSetFriction(2eca2465ee202d41).(cpShapecxx . . $ cpShape# *shape, cpFloatcxx . . $ cpFloat# friction) |
| 153 |
{ |
| •154 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(friction >= 0.0f, "Friction must be positive."); |
| 155 |
cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 156 |
shape->ucxx . . $ cpShape#u. = friction; |
| 157 |
} |
| 158 |
|
| 159 |
cpVectcxx . . $ cpVect# |
| 160 |
cpShapeGetSurfaceVelocitycxx . . $ cpShapeGetSurfaceVelocity(b2bcd93d530feb1b).(const cpShapecxx . . $ cpShape# *shape) |
| 161 |
{ |
| 162 |
return shape->surfaceVcxx . . $ cpShape#surfaceV.; |
| 163 |
} |
| 164 |
|
| 165 |
void |
| 166 |
cpShapeSetSurfaceVelocitycxx . . $ cpShapeSetSurfaceVelocity(8d797f1d6eed9a8f).(cpShapecxx . . $ cpShape# *shape, cpVectcxx . . $ cpVect# surfaceVelocity) |
| 167 |
{ |
| 168 |
cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 169 |
shape->surfaceVcxx . . $ cpShape#surfaceV. = surfaceVelocity; |
| 170 |
} |
| 171 |
|
| 172 |
cpDataPointercxx . . $ cpDataPointer# |
| 173 |
cpShapeGetUserDatacxx . . $ cpShapeGetUserData(403f0d6a0e6d1842).(const cpShapecxx . . $ cpShape# *shape) |
| 174 |
{ |
| 175 |
return shape->userDatacxx . . $ cpShape#userData.; |
| 176 |
} |
| 177 |
|
| 178 |
void |
| 179 |
cpShapeSetUserDatacxx . . $ cpShapeSetUserData(ebab24832b4ea92d).(cpShapecxx . . $ cpShape# *shape, cpDataPointercxx . . $ cpDataPointer# userData) |
| 180 |
{ |
| 181 |
shape->userDatacxx . . $ cpShape#userData. = userData; |
| 182 |
} |
| 183 |
|
| 184 |
cpCollisionTypecxx . . $ cpCollisionType# |
| 185 |
cpShapeGetCollisionTypecxx . . $ cpShapeGetCollisionType(62d1dad3c94cce13).(const cpShapecxx . . $ cpShape# *shape) |
| 186 |
{ |
| 187 |
return shape->typecxx . . $ cpShape#type.; |
| 188 |
} |
| 189 |
|
| 190 |
void |
| 191 |
cpShapeSetCollisionTypecxx . . $ cpShapeSetCollisionType(2dd430e3162ea2fe).(cpShapecxx . . $ cpShape# *shape, cpCollisionTypecxx . . $ cpCollisionType# collisionType) |
| 192 |
{ |
| 193 |
cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 194 |
shape->typecxx . . $ cpShape#type. = collisionType; |
| 195 |
} |
| 196 |
|
| 197 |
cpShapeFiltercxx . . $ cpShapeFilter# |
| 198 |
cpShapeGetFiltercxx . . $ cpShapeGetFilter(9b2eb493b38cd4f0).(const cpShapecxx . . $ cpShape# *shape) |
| 199 |
{ |
| 200 |
return shape->filtercxx . . $ cpShape#filter.; |
| 201 |
} |
| 202 |
|
| 203 |
void |
| 204 |
cpShapeSetFiltercxx . . $ cpShapeSetFilter(ec7e03c52efe89d5).(cpShapecxx . . $ cpShape# *shape, cpShapeFiltercxx . . $ cpShapeFilter# filter) |
| 205 |
{ |
| 206 |
cpBodyActivatecxx . . $ cpBodyActivate(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 207 |
shape->filtercxx . . $ cpShape#filter. = filter; |
| 208 |
} |
| 209 |
|
| 210 |
cpBBcxx . . $ cpBB# |
| 211 |
cpShapeCacheBBcxx . . $ cpShapeCacheBB(e4bf0be2c162867c).(cpShapecxx . . $ cpShape# *shape) |
| 212 |
{ |
| 213 |
return cpShapeUpdatecxx . . $ cpShapeUpdate(67a5b3d30c6115fd).(shape, shape->bodycxx . . $ cpShape#body.->transformcxx . . $ cpBody#transform.); |
| 214 |
} |
| 215 |
|
| 216 |
cpBBcxx . . $ cpBB# |
| 217 |
cpShapeUpdatecxx . . $ cpShapeUpdate(67a5b3d30c6115fd).(cpShapecxx . . $ cpShape# *shape, cpTransformcxx . . $ cpTransform# transform) |
| 218 |
{ |
| 219 |
return (shape->bbcxx . . $ cpShape#bb. = shape->klasscxx . . $ cpShape#klass.->cacheDatacxx . . $ cpShapeClass#cacheData.(shape, transform)); |
| 220 |
} |
| 221 |
|
| 222 |
cpFloatcxx . . $ cpFloat# |
| 223 |
cpShapePointQuerycxx . . $ cpShapePointQuery(fba695676919fb41).(const cpShapecxx . . $ cpShape# *shape, cpVectcxx . . $ cpVect# p, cpPointQueryInfocxx . . $ cpPointQueryInfo# *info) |
| 224 |
{ |
| 225 |
cpPointQueryInfocxx . . $ cpPointQueryInfo# blank = {NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, cpvzerocxx . . $ cpvzero., INFINITYcxx . . $ `<external>/11263917310783833665/math.h:93:12`!, cpvzerocxx . . $ cpvzero.}; |
| 226 |
if(info){ |
| 227 |
(*info) = blank; |
| 228 |
} else { |
| 229 |
info = ␣ |
| 230 |
} |
| 231 |
|
| 232 |
shape->klasscxx . . $ cpShape#klass.->pointQuerycxx . . $ cpShapeClass#pointQuery.(shape, p, info); |
| 233 |
return info->distancecxx . . $ cpPointQueryInfo#distance.; |
| 234 |
} |
| 235 |
|
| 236 |
|
| 237 |
cpBoolcxx . . $ cpBool# |
| 238 |
cpShapeSegmentQuerycxx . . $ cpShapeSegmentQuery(b386381aae6390da).(const cpShapecxx . . $ cpShape# *shape, cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpFloatcxx . . $ cpFloat# radius, cpSegmentQueryInfocxx . . $ cpSegmentQueryInfo# *info){ |
| 239 |
cpSegmentQueryInfocxx . . $ cpSegmentQueryInfo# blank = {NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, b, cpvzerocxx . . $ cpvzero., 1.0f}; |
| 240 |
if(info){ |
| 241 |
(*info) = blank; |
| 242 |
} else { |
| 243 |
info = ␣ |
| 244 |
} |
| 245 |
|
| 246 |
cpPointQueryInfocxx . . $ cpPointQueryInfo# nearest; |
| 247 |
shape->klasscxx . . $ cpShape#klass.->pointQuerycxx . . $ cpShapeClass#pointQuery.(shape, a, &nearest); |
| 248 |
if(nearest.distancecxx . . $ cpPointQueryInfo#distance. <= radius){ |
| 249 |
info->shapecxx . . $ cpSegmentQueryInfo#shape. = shape; |
| 250 |
info->alphacxx . . $ cpSegmentQueryInfo#alpha. = 0.0; |
| 251 |
info->normalcxx . . $ cpSegmentQueryInfo#normal. = cpvnormalizecxx . . $ cpvnormalize(e06142a62109ae08).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(a, nearest.pointcxx . . $ cpPointQueryInfo#point.)); |
| 252 |
} else { |
| 253 |
shape->klasscxx . . $ cpShape#klass.->segmentQuerycxx . . $ cpShapeClass#segmentQuery.(shape, a, b, radius, info); |
| 254 |
} |
| 255 |
|
| 256 |
return (info->shapecxx . . $ cpSegmentQueryInfo#shape. != NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!); |
| 257 |
} |
| 258 |
|
| 259 |
cpContactPointSetcxx . . $ cpContactPointSet# |
| 260 |
cpShapesCollidecxx . . $ cpShapesCollide(f75c4ecc6571f5c9).(const cpShapecxx . . $ cpShape# *a, const cpShapecxx . . $ cpShape# *b) |
| 261 |
{ |
| 262 |
struct cpContactcxx . . $ cpContact# contacts[CP_MAX_CONTACTS_PER_ARBITERcxx . . $ `include/chipmunk/cpArbiter.h:32:9`!]; |
| 263 |
struct cpCollisionInfocxx . . $ cpCollisionInfo# info = cpCollidecxx . . $ cpCollide(f8bb8df86a1fa46f).(a, b, 0, contacts); |
| 264 |
|
| 265 |
cpContactPointSetcxx . . $ cpContactPointSet# set; |
| 266 |
set.countcxx . . $ cpContactPointSet#count. = info.countcxx . . $ cpCollisionInfo#count.; |
| 267 |
|
| 268 |
// cpCollideShapes() may have swapped the contact order. Flip the normal. |
| 269 |
cpBoolcxx . . $ cpBool# swapped = (a != info.acxx . . $ cpCollisionInfo#a.); |
| 270 |
set.normalcxx . . $ cpContactPointSet#normal. = (swapped ? cpvnegcxx . . $ cpvneg(e06142a62109ae08).(info.ncxx . . $ cpCollisionInfo#n.) : info.ncxx . . $ cpCollisionInfo#n.); |
| 271 |
|
| 272 |
for(int i=0; i<info.countcxx . . $ cpCollisionInfo#count.; i++){ |
| 273 |
// cpCollideShapesInfo() returns contacts with absolute positions. |
| 274 |
cpVectcxx . . $ cpVect# p1 = contacts[i].r1cxx . . $ cpContact#r1.; |
| 275 |
cpVectcxx . . $ cpVect# p2 = contacts[i].r2cxx . . $ cpContact#r2.; |
| 276 |
|
| 277 |
set.pointscxx . . $ cpContactPointSet#points.[i].pointAcxx . . $ cpContactPointSet#$anonymous_type_0#pointA. = (swapped ? p2 : p1); |
| 278 |
set.pointscxx . . $ cpContactPointSet#points.[i].pointBcxx . . $ cpContactPointSet#$anonymous_type_0#pointB. = (swapped ? p1 : p2); |
| 279 |
set.pointscxx . . $ cpContactPointSet#points.[i].distancecxx . . $ cpContactPointSet#$anonymous_type_0#distance. = cpvdotcxx . . $ cpvdot(7d57c1c4dd559d53).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(p2, p1), set.normalcxx . . $ cpContactPointSet#normal.); |
| 280 |
} |
| 281 |
|
| 282 |
return set; |
| 283 |
} |
| 284 |
|
| 285 |
cpCircleShapecxx . . $ cpCircleShape# * |
| 286 |
cpCircleShapeAlloccxx . . $ cpCircleShapeAlloc(d5e6298b004254c7).(void) |
| 287 |
{ |
| 288 |
return (cpCircleShapecxx . . $ cpCircleShape# *)cpcalloccxx . . $ `include/chipmunk/chipmunk.h:72:10`!(1, sizeof(cpCircleShapecxx . . $ cpCircleShape#)); |
| 289 |
} |
| 290 |
|
| 291 |
static cpBBcxx . . $ cpBB# |
| 292 |
cpCircleShapeCacheDatacxx . . $ cpCircleShapeCacheData(e5483dc93812bc17).(cpCircleShapecxx . . $ cpCircleShape# *circle, cpTransformcxx . . $ cpTransform# transform) |
| 293 |
{ |
| 294 |
cpVectcxx . . $ cpVect# c = circle->tccxx . . $ cpCircleShape#tc. = cpTransformPointcxx . . $ cpTransformPoint(7fc9e234cc6e750a).(transform, circle->ccxx . . $ cpCircleShape#c.); |
| 295 |
return cpBBNewForCirclecxx . . $ cpBBNewForCircle(3659726deb36ce15).(c, circle->rcxx . . $ cpCircleShape#r.); |
| 296 |
} |
| 297 |
|
| 298 |
static void |
| 299 |
cpCircleShapePointQuerycxx . . $ cpCircleShapePointQuery(739dc5e05bf45e70).(cpCircleShapecxx . . $ cpCircleShape# *circle, cpVectcxx . . $ cpVect# p, cpPointQueryInfocxx . . $ cpPointQueryInfo# *info) |
| 300 |
{ |
| 301 |
cpVectcxx . . $ cpVect# delta = cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(p, circle->tccxx . . $ cpCircleShape#tc.); |
| 302 |
cpFloatcxx . . $ cpFloat# d = cpvlengthcxx . . $ cpvlength(c4ef53c170268e01).(delta); |
| 303 |
cpFloatcxx . . $ cpFloat# r = circle->rcxx . . $ cpCircleShape#r.; |
| 304 |
|
| 305 |
info->shapecxx . . $ cpPointQueryInfo#shape. = (cpShapecxx . . $ cpShape# *)circle; |
| 306 |
cpFloatcxx . . $ cpFloat# r_over_d = d > 0.0f ? r/d : r; |
| 307 |
info->pointcxx . . $ cpPointQueryInfo#point. = cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(circle->tccxx . . $ cpCircleShape#tc., cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(delta, r_over_d)); // TODO: div/0 |
| 308 |
info->distancecxx . . $ cpPointQueryInfo#distance. = d - r; |
| 309 |
|
| 310 |
// Use up for the gradient if the distance is very small. |
| 311 |
info->gradientcxx . . $ cpPointQueryInfo#gradient. = (d > MAGIC_EPSILONcxx . . $ `include/chipmunk/chipmunk_private.h:32:9`! ? cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(delta, 1.0f/d) : cpvcxx . . $ cpv(3142d57d978b2176).(0.0f, 1.0f)); |
| 312 |
} |
| 313 |
|
| 314 |
static void |
| 315 |
cpCircleShapeSegmentQuerycxx . . $ cpCircleShapeSegmentQuery(e4df8861be26af7c).(cpCircleShapecxx . . $ cpCircleShape# *circle, cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpFloatcxx . . $ cpFloat# radius, cpSegmentQueryInfocxx . . $ cpSegmentQueryInfo# *info) |
| 316 |
{ |
| 317 |
CircleSegmentQuerycxx . . $ CircleSegmentQuery(bf928cae3d166851).((cpShapecxx . . $ cpShape# *)circle, circle->tccxx . . $ cpCircleShape#tc., circle->rcxx . . $ cpCircleShape#r., a, b, radius, info); |
| 318 |
} |
| 319 |
|
| 320 |
static struct cpShapeMassInfocxx . . $ cpShapeMassInfo# |
| 321 |
cpCircleShapeMassInfocxx . . $ cpCircleShapeMassInfo(951f5c3e3638956a).(cpFloatcxx . . $ cpFloat# mass, cpFloatcxx . . $ cpFloat# radius, cpVectcxx . . $ cpVect# center) |
| 322 |
{ |
| 323 |
struct cpShapeMassInfocxx . . $ cpShapeMassInfo# info = { |
| 324 |
mass, cpMomentForCirclecxx . . $ cpMomentForCircle(a539e2d95614f770).(1.0f, 0.0f, radius, cpvzerocxx . . $ cpvzero.), |
| 325 |
center, |
| 326 |
cpAreaForCirclecxx . . $ cpAreaForCircle(d8e7e0733fa41c87).(0.0f, radius), |
| 327 |
}; |
| 328 |
|
| 329 |
return info; |
| 330 |
} |
| 331 |
|
| 332 |
static const cpShapeClasscxx . . $ cpShapeClass# cpCircleShapeClasscxx . . $ cpCircleShapeClass. = { |
| 333 |
CP_CIRCLE_SHAPEcxx . . $ CP_CIRCLE_SHAPE., |
| 334 |
(cpShapeCacheDataImplcxx . . $ cpShapeCacheDataImpl#)cpCircleShapeCacheDatacxx . . $ cpCircleShapeCacheData(e5483dc93812bc17)., |
| 335 |
NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, |
| 336 |
(cpShapePointQueryImplcxx . . $ cpShapePointQueryImpl#)cpCircleShapePointQuerycxx . . $ cpCircleShapePointQuery(739dc5e05bf45e70)., |
| 337 |
(cpShapeSegmentQueryImplcxx . . $ cpShapeSegmentQueryImpl#)cpCircleShapeSegmentQuerycxx . . $ cpCircleShapeSegmentQuery(e4df8861be26af7c)., |
| 338 |
}; |
| 339 |
|
| 340 |
cpCircleShapecxx . . $ cpCircleShape# * |
| 341 |
cpCircleShapeInitcxx . . $ cpCircleShapeInit(620e24939f403bac).(cpCircleShapecxx . . $ cpCircleShape# *circle, cpBodycxx . . $ cpBody# *body, cpFloatcxx . . $ cpFloat# radius, cpVectcxx . . $ cpVect# offset) |
| 342 |
{ |
| 343 |
circle->ccxx . . $ cpCircleShape#c. = offset; |
| 344 |
circle->rcxx . . $ cpCircleShape#r. = radius; |
| 345 |
|
| 346 |
cpShapeInitcxx . . $ cpShapeInit(fe460fb3c2ea2ff0).((cpShapecxx . . $ cpShape# *)circle, &cpCircleShapeClasscxx . . $ cpCircleShapeClass., body, cpCircleShapeMassInfocxx . . $ cpCircleShapeMassInfo(951f5c3e3638956a).(0.0f, radius, offset)); |
| 347 |
|
| 348 |
return circle; |
| 349 |
} |
| 350 |
|
| 351 |
cpShapecxx . . $ cpShape# * |
| 352 |
cpCircleShapeNewcxx . . $ cpCircleShapeNew(e5e4e3a52c89533b).(cpBodycxx . . $ cpBody# *body, cpFloatcxx . . $ cpFloat# radius, cpVectcxx . . $ cpVect# offset) |
| 353 |
{ |
| 354 |
return (cpShapecxx . . $ cpShape# *)cpCircleShapeInitcxx . . $ cpCircleShapeInit(620e24939f403bac).(cpCircleShapeAlloccxx . . $ cpCircleShapeAlloc(d5e6298b004254c7).(), body, radius, offset); |
| 355 |
} |
| 356 |
|
| 357 |
cpVectcxx . . $ cpVect# |
| 358 |
cpCircleShapeGetOffsetcxx . . $ cpCircleShapeGetOffset(b2bcd93d530feb1b).(const cpShapecxx . . $ cpShape# *shape) |
| 359 |
{ |
| 360 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); |
| 361 |
return ((cpCircleShapecxx . . $ cpCircleShape# *)shape)->ccxx . . $ cpCircleShape#c.; |
| 362 |
} |
| 363 |
|
| 364 |
cpFloatcxx . . $ cpFloat# |
| 365 |
cpCircleShapeGetRadiuscxx . . $ cpCircleShapeGetRadius(1bf41e75729c6179).(const cpShapecxx . . $ cpShape# *shape) |
| 366 |
{ |
| 367 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); |
| 368 |
return ((cpCircleShapecxx . . $ cpCircleShape# *)shape)->rcxx . . $ cpCircleShape#r.; |
| 369 |
} |
| 370 |
|
| 371 |
|
| 372 |
cpSegmentShapecxx . . $ cpSegmentShape# * |
| 373 |
cpSegmentShapeAlloccxx . . $ cpSegmentShapeAlloc(698af3ee7f73b073).(void) |
| 374 |
{ |
| 375 |
return (cpSegmentShapecxx . . $ cpSegmentShape# *)cpcalloccxx . . $ `include/chipmunk/chipmunk.h:72:10`!(1, sizeof(cpSegmentShapecxx . . $ cpSegmentShape#)); |
| 376 |
} |
| 377 |
|
| 378 |
static cpBBcxx . . $ cpBB# |
| 379 |
cpSegmentShapeCacheDatacxx . . $ cpSegmentShapeCacheData(12d7e7dad6e8811b).(cpSegmentShapecxx . . $ cpSegmentShape# *seg, cpTransformcxx . . $ cpTransform# transform) |
| 380 |
{ |
| 381 |
seg->tacxx . . $ cpSegmentShape#ta. = cpTransformPointcxx . . $ cpTransformPoint(7fc9e234cc6e750a).(transform, seg->acxx . . $ cpSegmentShape#a.); |
| 382 |
seg->tbcxx . . $ cpSegmentShape#tb. = cpTransformPointcxx . . $ cpTransformPoint(7fc9e234cc6e750a).(transform, seg->bcxx . . $ cpSegmentShape#b.); |
| 383 |
seg->tncxx . . $ cpSegmentShape#tn. = cpTransformVectcxx . . $ cpTransformVect(7fc9e234cc6e750a).(transform, seg->ncxx . . $ cpSegmentShape#n.); |
| 384 |
|
| 385 |
cpFloatcxx . . $ cpFloat# l,r,b,t; |
| 386 |
|
| 387 |
if(seg->tacxx . . $ cpSegmentShape#ta..xcxx . . $ cpVect#x. < seg->tbcxx . . $ cpSegmentShape#tb..xcxx . . $ cpVect#x.){ |
| 388 |
l = seg->tacxx . . $ cpSegmentShape#ta..xcxx . . $ cpVect#x.; |
| 389 |
r = seg->tbcxx . . $ cpSegmentShape#tb..xcxx . . $ cpVect#x.; |
| 390 |
} else { |
| 391 |
l = seg->tbcxx . . $ cpSegmentShape#tb..xcxx . . $ cpVect#x.; |
| 392 |
r = seg->tacxx . . $ cpSegmentShape#ta..xcxx . . $ cpVect#x.; |
| 393 |
} |
| 394 |
|
| 395 |
if(seg->tacxx . . $ cpSegmentShape#ta..ycxx . . $ cpVect#y. < seg->tbcxx . . $ cpSegmentShape#tb..ycxx . . $ cpVect#y.){ |
| 396 |
b = seg->tacxx . . $ cpSegmentShape#ta..ycxx . . $ cpVect#y.; |
| 397 |
t = seg->tbcxx . . $ cpSegmentShape#tb..ycxx . . $ cpVect#y.; |
| 398 |
} else { |
| 399 |
b = seg->tbcxx . . $ cpSegmentShape#tb..ycxx . . $ cpVect#y.; |
| 400 |
t = seg->tacxx . . $ cpSegmentShape#ta..ycxx . . $ cpVect#y.; |
| 401 |
} |
| 402 |
|
| 403 |
cpFloatcxx . . $ cpFloat# rad = seg->rcxx . . $ cpSegmentShape#r.; |
| 404 |
return cpBBNewcxx . . $ cpBBNew(f05aa3203068e6d3).(l - rad, b - rad, r + rad, t + rad); |
| 405 |
} |
| 406 |
|
| 407 |
static void |
| 408 |
cpSegmentShapePointQuerycxx . . $ cpSegmentShapePointQuery(9b5b8f15efd9c8ca).(cpSegmentShapecxx . . $ cpSegmentShape# *seg, cpVectcxx . . $ cpVect# p, cpPointQueryInfocxx . . $ cpPointQueryInfo# *info) |
| 409 |
{ |
| 410 |
cpVectcxx . . $ cpVect# closest = cpClosetPointOnSegmentcxx . . $ cpClosetPointOnSegment(7c4544d786004357).(p, seg->tacxx . . $ cpSegmentShape#ta., seg->tbcxx . . $ cpSegmentShape#tb.); |
| 411 |
|
| 412 |
cpVectcxx . . $ cpVect# delta = cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(p, closest); |
| 413 |
cpFloatcxx . . $ cpFloat# d = cpvlengthcxx . . $ cpvlength(c4ef53c170268e01).(delta); |
| 414 |
cpFloatcxx . . $ cpFloat# r = seg->rcxx . . $ cpSegmentShape#r.; |
| 415 |
cpVectcxx . . $ cpVect# g = cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(delta, 1.0f/d); |
| 416 |
|
| 417 |
info->shapecxx . . $ cpPointQueryInfo#shape. = (cpShapecxx . . $ cpShape# *)seg; |
| 418 |
info->pointcxx . . $ cpPointQueryInfo#point. = (d ? cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(closest, cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(g, r)) : closest); |
| 419 |
info->distancecxx . . $ cpPointQueryInfo#distance. = d - r; |
| 420 |
|
| 421 |
// Use the segment's normal if the distance is very small. |
| 422 |
info->gradientcxx . . $ cpPointQueryInfo#gradient. = (d > MAGIC_EPSILONcxx . . $ `include/chipmunk/chipmunk_private.h:32:9`! ? g : seg->ncxx . . $ cpSegmentShape#n.); |
| 423 |
} |
| 424 |
|
| 425 |
static void |
| 426 |
cpSegmentShapeSegmentQuerycxx . . $ cpSegmentShapeSegmentQuery(e3c91a389ec21b2b).(cpSegmentShapecxx . . $ cpSegmentShape# *seg, cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpFloatcxx . . $ cpFloat# r2, cpSegmentQueryInfocxx . . $ cpSegmentQueryInfo# *info) |
| 427 |
{ |
| 428 |
cpVectcxx . . $ cpVect# n = seg->tncxx . . $ cpSegmentShape#tn.; |
| 429 |
cpFloatcxx . . $ cpFloat# d = cpvdotcxx . . $ cpvdot(7d57c1c4dd559d53).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(seg->tacxx . . $ cpSegmentShape#ta., a), n); |
| 430 |
cpFloatcxx . . $ cpFloat# r = seg->rcxx . . $ cpSegmentShape#r. + r2; |
| 431 |
|
| 432 |
cpVectcxx . . $ cpVect# flipped_n = (d > 0.0f ? cpvnegcxx . . $ cpvneg(e06142a62109ae08).(n) : n); |
| 433 |
cpVectcxx . . $ cpVect# seg_offset = cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(flipped_n, r), a); |
| 434 |
|
| 435 |
// Make the endpoints relative to 'a' and move them by the thickness of the segment. |
| 436 |
cpVectcxx . . $ cpVect# seg_a = cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(seg->tacxx . . $ cpSegmentShape#ta., seg_offset); |
| 437 |
cpVectcxx . . $ cpVect# seg_b = cpvaddcxx . . $ cpvadd(47eb3f105675e23c).(seg->tbcxx . . $ cpSegmentShape#tb., seg_offset); |
| 438 |
cpVectcxx . . $ cpVect# delta = cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(b, a); |
| 439 |
|
| 440 |
if(cpvcrosscxx . . $ cpvcross(7d57c1c4dd559d53).(delta, seg_a)*cpvcrosscxx . . $ cpvcross(7d57c1c4dd559d53).(delta, seg_b) <= 0.0f){ |
| 441 |
cpFloatcxx . . $ cpFloat# d_offset = d + (d > 0.0f ? -r : r); |
| 442 |
cpFloatcxx . . $ cpFloat# ad = -d_offset; |
| 443 |
cpFloatcxx . . $ cpFloat# bd = cpvdotcxx . . $ cpvdot(7d57c1c4dd559d53).(delta, n) - d_offset; |
| 444 |
|
| 445 |
if(ad*bd < 0.0f){ |
| 446 |
cpFloatcxx . . $ cpFloat# t = ad/(ad - bd); |
| 447 |
|
| 448 |
info->shapecxx . . $ cpSegmentQueryInfo#shape. = (cpShapecxx . . $ cpShape# *)seg; |
| 449 |
info->pointcxx . . $ cpSegmentQueryInfo#point. = cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(cpvlerpcxx . . $ cpvlerp(12b05c0b9acd6d4b).(a, b, t), cpvmultcxx . . $ cpvmult(f5cc44da17d64838).(flipped_n, r2)); |
| 450 |
info->normalcxx . . $ cpSegmentQueryInfo#normal. = flipped_n; |
| 451 |
info->alphacxx . . $ cpSegmentQueryInfo#alpha. = t; |
| 452 |
} |
| 453 |
} else if(r != 0.0f){ |
| 454 |
cpSegmentQueryInfocxx . . $ cpSegmentQueryInfo# info1 = {NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, b, cpvzerocxx . . $ cpvzero., 1.0f}; |
| 455 |
cpSegmentQueryInfocxx . . $ cpSegmentQueryInfo# info2 = {NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, b, cpvzerocxx . . $ cpvzero., 1.0f}; |
| 456 |
CircleSegmentQuerycxx . . $ CircleSegmentQuery(bf928cae3d166851).((cpShapecxx . . $ cpShape# *)seg, seg->tacxx . . $ cpSegmentShape#ta., seg->rcxx . . $ cpSegmentShape#r., a, b, r2, &info1); |
| 457 |
CircleSegmentQuerycxx . . $ CircleSegmentQuery(bf928cae3d166851).((cpShapecxx . . $ cpShape# *)seg, seg->tbcxx . . $ cpSegmentShape#tb., seg->rcxx . . $ cpSegmentShape#r., a, b, r2, &info2); |
| 458 |
|
| 459 |
if(info1.alphacxx . . $ cpSegmentQueryInfo#alpha. < info2.alphacxx . . $ cpSegmentQueryInfo#alpha.){ |
| 460 |
(*info) = info1; |
| 461 |
} else { |
| 462 |
(*info) = info2; |
| 463 |
} |
| 464 |
} |
| 465 |
} |
| 466 |
|
| 467 |
static struct cpShapeMassInfocxx . . $ cpShapeMassInfo# |
| 468 |
cpSegmentShapeMassInfocxx . . $ cpSegmentShapeMassInfo(2c70e76453900241).(cpFloatcxx . . $ cpFloat# mass, cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpFloatcxx . . $ cpFloat# r) |
| 469 |
{ |
| 470 |
struct cpShapeMassInfocxx . . $ cpShapeMassInfo# info = { |
| 471 |
mass, cpMomentForBoxcxx . . $ cpMomentForBox(7678bba071383ab).(1.0f, cpvdistcxx . . $ cpvdist(7d57c1c4dd559d53).(a, b) + 2.0f*r, 2.0f*r), // TODO is an approximation. |
| 472 |
cpvlerpcxx . . $ cpvlerp(12b05c0b9acd6d4b).(a, b, 0.5f), |
| 473 |
cpAreaForSegmentcxx . . $ cpAreaForSegment(753c01a8c1fee84f).(a, b, r), |
| 474 |
}; |
| 475 |
|
| 476 |
return info; |
| 477 |
} |
| 478 |
|
| 479 |
static const cpShapeClasscxx . . $ cpShapeClass# cpSegmentShapeClasscxx . . $ cpSegmentShapeClass. = { |
| 480 |
CP_SEGMENT_SHAPEcxx . . $ CP_SEGMENT_SHAPE., |
| 481 |
(cpShapeCacheDataImplcxx . . $ cpShapeCacheDataImpl#)cpSegmentShapeCacheDatacxx . . $ cpSegmentShapeCacheData(12d7e7dad6e8811b)., |
| 482 |
NULLcxx . . $ `<external>/16391990256953433862/stddef.h:419:9`!, |
| 483 |
(cpShapePointQueryImplcxx . . $ cpShapePointQueryImpl#)cpSegmentShapePointQuerycxx . . $ cpSegmentShapePointQuery(9b5b8f15efd9c8ca)., |
| 484 |
(cpShapeSegmentQueryImplcxx . . $ cpShapeSegmentQueryImpl#)cpSegmentShapeSegmentQuerycxx . . $ cpSegmentShapeSegmentQuery(e3c91a389ec21b2b)., |
| 485 |
}; |
| 486 |
|
| 487 |
cpSegmentShapecxx . . $ cpSegmentShape# * |
| 488 |
cpSegmentShapeInitcxx . . $ cpSegmentShapeInit(864111a370fa79ec).(cpSegmentShapecxx . . $ cpSegmentShape# *seg, cpBodycxx . . $ cpBody# *body, cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpFloatcxx . . $ cpFloat# r) |
| 489 |
{ |
| 490 |
seg->acxx . . $ cpSegmentShape#a. = a; |
| 491 |
seg->bcxx . . $ cpSegmentShape#b. = b; |
| 492 |
seg->ncxx . . $ cpSegmentShape#n. = cpvrperpcxx . . $ cpvrperp(e06142a62109ae08).(cpvnormalizecxx . . $ cpvnormalize(e06142a62109ae08).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(b, a))); |
| 493 |
|
| 494 |
seg->rcxx . . $ cpSegmentShape#r. = r; |
| 495 |
|
| 496 |
seg->a_tangentcxx . . $ cpSegmentShape#a_tangent. = cpvzerocxx . . $ cpvzero.; |
| 497 |
seg->b_tangentcxx . . $ cpSegmentShape#b_tangent. = cpvzerocxx . . $ cpvzero.; |
| 498 |
|
| 499 |
cpShapeInitcxx . . $ cpShapeInit(fe460fb3c2ea2ff0).((cpShapecxx . . $ cpShape# *)seg, &cpSegmentShapeClasscxx . . $ cpSegmentShapeClass., body, cpSegmentShapeMassInfocxx . . $ cpSegmentShapeMassInfo(2c70e76453900241).(0.0f, a, b, r)); |
| 500 |
|
| 501 |
return seg; |
| 502 |
} |
| 503 |
|
| 504 |
cpShapecxx . . $ cpShape#* |
| 505 |
cpSegmentShapeNewcxx . . $ cpSegmentShapeNew(3a41acb06b39b945).(cpBodycxx . . $ cpBody# *body, cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b, cpFloatcxx . . $ cpFloat# r) |
| 506 |
{ |
| 507 |
return (cpShapecxx . . $ cpShape# *)cpSegmentShapeInitcxx . . $ cpSegmentShapeInit(864111a370fa79ec).(cpSegmentShapeAlloccxx . . $ cpSegmentShapeAlloc(698af3ee7f73b073).(), body, a, b, r); |
| 508 |
} |
| 509 |
|
| 510 |
cpVectcxx . . $ cpVect# |
| 511 |
cpSegmentShapeGetAcxx . . $ cpSegmentShapeGetA(b2bcd93d530feb1b).(const cpShapecxx . . $ cpShape# *shape) |
| 512 |
{ |
| 513 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); |
| 514 |
return ((cpSegmentShapecxx . . $ cpSegmentShape# *)shape)->acxx . . $ cpSegmentShape#a.; |
| 515 |
} |
| 516 |
|
| 517 |
cpVectcxx . . $ cpVect# |
| 518 |
cpSegmentShapeGetBcxx . . $ cpSegmentShapeGetB(b2bcd93d530feb1b).(const cpShapecxx . . $ cpShape# *shape) |
| 519 |
{ |
| 520 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); |
| 521 |
return ((cpSegmentShapecxx . . $ cpSegmentShape# *)shape)->bcxx . . $ cpSegmentShape#b.; |
| 522 |
} |
| 523 |
|
| 524 |
cpVectcxx . . $ cpVect# |
| 525 |
cpSegmentShapeGetNormalcxx . . $ cpSegmentShapeGetNormal(b2bcd93d530feb1b).(const cpShapecxx . . $ cpShape# *shape) |
| 526 |
{ |
| 527 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); |
| 528 |
return ((cpSegmentShapecxx . . $ cpSegmentShape# *)shape)->ncxx . . $ cpSegmentShape#n.; |
| 529 |
} |
| 530 |
|
| 531 |
cpFloatcxx . . $ cpFloat# |
| 532 |
cpSegmentShapeGetRadiuscxx . . $ cpSegmentShapeGetRadius(1bf41e75729c6179).(const cpShapecxx . . $ cpShape# *shape) |
| 533 |
{ |
| 534 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); |
| 535 |
return ((cpSegmentShapecxx . . $ cpSegmentShape# *)shape)->rcxx . . $ cpSegmentShape#r.; |
| 536 |
} |
| 537 |
|
| 538 |
void |
| 539 |
cpSegmentShapeSetNeighborscxx . . $ cpSegmentShapeSetNeighbors(3d449d351e6cce3).(cpShapecxx . . $ cpShape# *shape, cpVectcxx . . $ cpVect# prev, cpVectcxx . . $ cpVect# next) |
| 540 |
{ |
| 541 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); |
| 542 |
cpSegmentShapecxx . . $ cpSegmentShape# *seg = (cpSegmentShapecxx . . $ cpSegmentShape# *)shape; |
| 543 |
|
| 544 |
seg->a_tangentcxx . . $ cpSegmentShape#a_tangent. = cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(prev, seg->acxx . . $ cpSegmentShape#a.); |
| 545 |
seg->b_tangentcxx . . $ cpSegmentShape#b_tangent. = cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(next, seg->bcxx . . $ cpSegmentShape#b.); |
| 546 |
} |
| 547 |
|
| 548 |
// Unsafe API (chipmunk_unsafe.h) |
| 549 |
|
| 550 |
// TODO setters should wake the shape up? |
| 551 |
|
| 552 |
void |
| 553 |
cpCircleShapeSetRadiuscxx . . $ cpCircleShapeSetRadius(2eca2465ee202d41).(cpShapecxx . . $ cpShape# *shape, cpFloatcxx . . $ cpFloat# radius) |
| 554 |
{ |
| 555 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); |
| 556 |
cpCircleShapecxx . . $ cpCircleShape# *circle = (cpCircleShapecxx . . $ cpCircleShape# *)shape; |
| 557 |
|
| 558 |
circle->rcxx . . $ cpCircleShape#r. = radius; |
| 559 |
|
| 560 |
cpFloatcxx . . $ cpFloat# mass = shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m.; |
| 561 |
shape->massInfocxx . . $ cpShape#massInfo. = cpCircleShapeMassInfocxx . . $ cpCircleShapeMassInfo(951f5c3e3638956a).(mass, circle->rcxx . . $ cpCircleShape#r., circle->ccxx . . $ cpCircleShape#c.); |
| 562 |
if(mass > 0.0f) cpBodyAccumulateMassFromShapescxx . . $ cpBodyAccumulateMassFromShapes(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 563 |
} |
| 564 |
|
| 565 |
void |
| 566 |
cpCircleShapeSetOffsetcxx . . $ cpCircleShapeSetOffset(8d797f1d6eed9a8f).(cpShapecxx . . $ cpShape# *shape, cpVectcxx . . $ cpVect# offset) |
| 567 |
{ |
| 568 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); |
| 569 |
cpCircleShapecxx . . $ cpCircleShape# *circle = (cpCircleShapecxx . . $ cpCircleShape# *)shape; |
| 570 |
|
| 571 |
circle->ccxx . . $ cpCircleShape#c. = offset; |
| 572 |
|
| 573 |
cpFloatcxx . . $ cpFloat# mass = shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m.; |
| 574 |
shape->massInfocxx . . $ cpShape#massInfo. = cpCircleShapeMassInfocxx . . $ cpCircleShapeMassInfo(951f5c3e3638956a).(shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m., circle->rcxx . . $ cpCircleShape#r., circle->ccxx . . $ cpCircleShape#c.); |
| 575 |
if(mass > 0.0f) cpBodyAccumulateMassFromShapescxx . . $ cpBodyAccumulateMassFromShapes(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 576 |
} |
| 577 |
|
| 578 |
void |
| 579 |
cpSegmentShapeSetEndpointscxx . . $ cpSegmentShapeSetEndpoints(3d449d351e6cce3).(cpShapecxx . . $ cpShape# *shape, cpVectcxx . . $ cpVect# a, cpVectcxx . . $ cpVect# b) |
| 580 |
{ |
| 581 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); |
| 582 |
cpSegmentShapecxx . . $ cpSegmentShape# *seg = (cpSegmentShapecxx . . $ cpSegmentShape# *)shape; |
| 583 |
|
| 584 |
seg->acxx . . $ cpSegmentShape#a. = a; |
| 585 |
seg->bcxx . . $ cpSegmentShape#b. = b; |
| 586 |
seg->ncxx . . $ cpSegmentShape#n. = cpvperpcxx . . $ cpvperp(e06142a62109ae08).(cpvnormalizecxx . . $ cpvnormalize(e06142a62109ae08).(cpvsubcxx . . $ cpvsub(47eb3f105675e23c).(b, a))); |
| 587 |
|
| 588 |
cpFloatcxx . . $ cpFloat# mass = shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m.; |
| 589 |
shape->massInfocxx . . $ cpShape#massInfo. = cpSegmentShapeMassInfocxx . . $ cpSegmentShapeMassInfo(2c70e76453900241).(shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m., seg->acxx . . $ cpSegmentShape#a., seg->bcxx . . $ cpSegmentShape#b., seg->rcxx . . $ cpSegmentShape#r.); |
| 590 |
if(mass > 0.0f) cpBodyAccumulateMassFromShapescxx . . $ cpBodyAccumulateMassFromShapes(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 591 |
} |
| 592 |
|
| 593 |
void |
| 594 |
cpSegmentShapeSetRadiuscxx . . $ cpSegmentShapeSetRadius(2eca2465ee202d41).(cpShapecxx . . $ cpShape# *shape, cpFloatcxx . . $ cpFloat# radius) |
| 595 |
{ |
| 596 |
cpAssertHardcxx . . $ `include/chipmunk/chipmunk.h:58:9`!(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); |
| 597 |
cpSegmentShapecxx . . $ cpSegmentShape# *seg = (cpSegmentShapecxx . . $ cpSegmentShape# *)shape; |
| 598 |
|
| 599 |
seg->rcxx . . $ cpSegmentShape#r. = radius; |
| 600 |
|
| 601 |
cpFloatcxx . . $ cpFloat# mass = shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m.; |
| 602 |
shape->massInfocxx . . $ cpShape#massInfo. = cpSegmentShapeMassInfocxx . . $ cpSegmentShapeMassInfo(2c70e76453900241).(shape->massInfocxx . . $ cpShape#massInfo..mcxx . . $ cpShapeMassInfo#m., seg->acxx . . $ cpSegmentShape#a., seg->bcxx . . $ cpSegmentShape#b., seg->rcxx . . $ cpSegmentShape#r.); |
| 603 |
if(mass > 0.0f) cpBodyAccumulateMassFromShapescxx . . $ cpBodyAccumulateMassFromShapes(92943d3541b63e72).(shape->bodycxx . . $ cpShape#body.); |
| 604 |
} |