4 alias AABB
= AABBImpl
!vec3
;
8 auto a
= AABB(vec3(0, 0, 0), vec3(3, 3, 3));
9 auto b
= AABB(vec3(5, 5, 5), vec3(8, 8, 8));
11 immutable amove
= vec3(10, 10, 10);
12 immutable bmove
= vec3(0.1, 0.1, 0.1);
14 if (a
.sweep(amove
, b
, &u0
, &hitnorm
, &u1
)) {
15 writeln("COLLIDE; u0=", u0
, "; u1=", u1
, "; hitnorm=", hitnorm
);
16 writeln("u0v for a: ", a
.min
+amove
*u0
, " : ", a
.max
+amove
*u0
);
17 writeln("u1v for a: ", a
.min
+amove
*u1
, " : ", a
.max
+amove
*u1
);
18 writeln(" b: ", b
.min
, " : ", b
.max
);
22 writeln(a
.overlapsSphere(vec3(1, 1, 1), 1));
23 writeln(a
.overlapsSphere(vec3(2.5, 2.5, 2.5), 2));
24 writeln(a
.overlapsSphere(vec3(3.5, 3.5, 2.5), 2));
25 writeln(a
.overlapsSphere(vec3(4.5, 3.5, 2.5), 2));
26 writeln(a
.overlapsSphere(vec3(4.5, 5.5, 2.5), 2));
30 writeln(a
.overlaps(Sphere
!vec3(vec3(1, 1, 1), 1)));
31 writeln(a
.overlaps(Sphere
!vec3(vec3(2.5, 2.5, 2.5), 2)));
32 writeln(a
.overlaps(Sphere
!vec3(vec3(3.5, 3.5, 2.5), 2)));
33 writeln(a
.overlaps(Sphere
!vec3(vec3(4.5, 3.5, 2.5), 2)));
34 writeln(a
.overlaps(Sphere
!vec3(vec3(4.5, 5.5, 2.5), 2)));
37 auto s0
= Sphere
!vec3(vec3(1, 1, 1), 3);
38 auto s1
= Sphere
!vec3(vec3(5, 5, 5), 3);
40 if (s0
.sweep(amove
, s1
, &u0
, &u1
)) {
41 writeln("COLLIDE; u0=", u0
, "; u1=", u1
);
42 writeln("u0v for s0: ", s0
.orig
*u0
, " : ", s0
.orig
*u0
+s0
.radius
);
43 writeln("u0v for s1: ", s1
.orig
*u0
, " : ", s0
.orig
*u0
+s1
.radius
);
44 writeln("u1v for s0: ", s0
.orig
*u1
, " : ", s0
.orig
*u1
+s0
.radius
);
45 writeln("u1v for s1: ", s1
.orig
*u1
, " : ", s1
.orig
*u1
+s1
.radius
);
48 auto pl
= Plane3
!VFloat(vec3(0, 0, 1), vec3(0, -1, 1), vec3(0.5, 0.5, 1));
50 //pl.normal = vec3(0, 0, 1);
52 writeln("plane: ", pl
.normal
, "; w=", pl
.w
);
54 if (s1
.sweep(pl
, vec3(-5, -5, -5), &hitpos
, &u0
)) {
55 writeln("COLLIDE; hitpos=", hitpos
, "; u0=", u0
);