|
1 | | -'' FreeBASIC binding for Chipmunk-7.0.1 |
| 1 | +'' FreeBASIC binding for Chipmunk-7.0.3 |
2 | 2 | '' |
3 | 3 | '' based on the C header files: |
4 | 4 | '' Copyright (c) 2007-2015 Scott Lembcke and Howling Moon Software |
|
22 | 22 | '' SOFTWARE. |
23 | 23 | '' |
24 | 24 | '' translated to FreeBASIC by: |
25 | | -'' Copyright © 2015 FreeBASIC development team |
| 25 | +'' Copyright © 2020 FreeBASIC development team |
26 | 26 |
|
27 | 27 | #pragma once |
28 | 28 |
|
@@ -276,24 +276,34 @@ end type |
276 | 276 | #define cpBBMergedArea(a, b) cast(cpFloat, (cpfmax((a).r, (b).r) - cpfmin((a).l, (b).l)) * (cpfmax((a).t, (b).t) - cpfmin((a).(b), (b).(b)))) |
277 | 277 |
|
278 | 278 | private function cpBBSegmentQuery(byval bb as cpBB, byval a as cpVect, byval b as cpVect) as cpFloat |
279 | | - dim idx as cpFloat = 1.0f / (b.x - a.x) |
280 | | - dim tx1 as cpFloat = iif(bb.l = a.x, -INFINITY, (bb.l - a.x) * idx) |
281 | | - dim tx2 as cpFloat = iif(bb.r = a.x, INFINITY, (bb.r - a.x) * idx) |
282 | | - dim txmin as cpFloat = cpfmin(tx1, tx2) |
283 | | - dim txmax as cpFloat = cpfmax(tx1, tx2) |
284 | | - dim idy as cpFloat = 1.0f / (b.y - a.y) |
285 | | - dim ty1 as cpFloat = iif(bb.b = a.y, -INFINITY, (bb.b - a.y) * idy) |
286 | | - dim ty2 as cpFloat = iif(bb.t = a.y, INFINITY, (bb.t - a.y) * idy) |
287 | | - dim tymin as cpFloat = cpfmin(ty1, ty2) |
288 | | - dim tymax as cpFloat = cpfmax(ty1, ty2) |
289 | | - if (tymin <= txmax) andalso (txmin <= tymax) then |
290 | | - dim min as cpFloat = cpfmax(txmin, tymin) |
291 | | - dim max as cpFloat = cpfmin(txmax, tymax) |
292 | | - if (0.0 <= max) andalso (min <= 1.0) then |
293 | | - return cpfmax(min, 0.0) |
| 279 | + dim delta as cpVect = cpvsub(b, a) |
| 280 | + dim tmin as cpFloat = -INFINITY |
| 281 | + dim tmax as cpFloat = INFINITY |
| 282 | + if delta.x = 0.0f then |
| 283 | + if (a.x < bb.l) orelse (bb.r < a.x) then |
| 284 | + return INFINITY |
294 | 285 | end if |
| 286 | + else |
| 287 | + dim t1 as cpFloat = (bb.l - a.x) / delta.x |
| 288 | + dim t2 as cpFloat = (bb.r - a.x) / delta.x |
| 289 | + tmin = cpfmax(tmin, cpfmin(t1, t2)) |
| 290 | + tmax = cpfmin(tmax, cpfmax(t1, t2)) |
| 291 | + end if |
| 292 | + if delta.y = 0.0f then |
| 293 | + if (a.y < bb.b) orelse (bb.t < a.y) then |
| 294 | + return INFINITY |
| 295 | + end if |
| 296 | + else |
| 297 | + dim t1 as cpFloat = (bb.b - a.y) / delta.y |
| 298 | + dim t2 as cpFloat = (bb.t - a.y) / delta.y |
| 299 | + tmin = cpfmax(tmin, cpfmin(t1, t2)) |
| 300 | + tmax = cpfmin(tmax, cpfmax(t1, t2)) |
| 301 | + end if |
| 302 | + if ((tmin <= tmax) andalso (0.0f <= tmax)) andalso (tmin <= 1.0f) then |
| 303 | + return cpfmax(tmin, 0.0f) |
| 304 | + else |
| 305 | + return INFINITY |
295 | 306 | end if |
296 | | - return INFINITY |
297 | 307 | end function |
298 | 308 |
|
299 | 309 | #define cpBBIntersectsSegment(bb, a, b) cast(cpBool, -(cpBBSegmentQuery((bb), (a), (b)) <> INFINITY)) |
@@ -949,7 +959,7 @@ end type |
949 | 959 | declare sub cpSpaceDebugDraw(byval space as cpSpace ptr, byval options as cpSpaceDebugDrawOptions ptr) |
950 | 960 | const CP_VERSION_MAJOR = 7 |
951 | 961 | const CP_VERSION_MINOR = 0 |
952 | | -const CP_VERSION_RELEASE = 1 |
| 962 | +const CP_VERSION_RELEASE = 3 |
953 | 963 | extern cpVersionString as const zstring ptr |
954 | 964 |
|
955 | 965 | declare function cpMomentForCircle(byval m as cpFloat, byval r1 as cpFloat, byval r2 as cpFloat, byval offset as cpVect) as cpFloat |
|
0 commit comments