| 18 | } |
| 19 | |
| 20 | void from_points(AABB &b, u32 num, u32 stride, const void *points) |
| 21 | { |
| 22 | CE_ENSURE(num > 0); |
| 23 | CE_ENSURE(points != NULL); |
| 24 | |
| 25 | const char *pts = (char *)points; |
| 26 | const f32 *point = (f32 *)pts; |
| 27 | |
| 28 | b.min.x = b.max.x = point[0]; |
| 29 | b.min.y = b.max.y = point[1]; |
| 30 | b.min.z = b.max.z = point[2]; |
| 31 | pts += stride; |
| 32 | |
| 33 | for (u32 i = 1; i < num; ++i, pts += stride) { |
| 34 | point = (f32 *)pts; |
| 35 | |
| 36 | b.min.x = min(b.min.x, point[0]); |
| 37 | b.min.y = min(b.min.y, point[1]); |
| 38 | b.min.z = min(b.min.z, point[2]); |
| 39 | b.max.x = max(b.max.x, point[0]); |
| 40 | b.max.y = max(b.max.y, point[1]); |
| 41 | b.max.z = max(b.max.z, point[2]); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | void from_boxes(AABB &b, u32 num, const AABB *boxes) |
| 46 | { |