@@ -22,16 +22,21 @@ def test_ccd():
22
22
23
23
assert ipctk .is_step_collision_free (mesh , V0 , (V1 - V0 ) * toi + V0 )
24
24
25
+
25
26
def test_custom_ccd ():
26
27
class DumbNarrowPhaseCCD (ipctk .NarrowPhaseCCD ):
27
28
def __init__ (self ):
28
29
ipctk .NarrowPhaseCCD .__init__ (self )
30
+
29
31
def point_point_ccd (self , p0_t0 , p1_t0 , p0_t1 , p1_t1 , min_distance = 0.0 , tmax = 1.0 ):
30
32
return True , 0.0
33
+
31
34
def point_edge_ccd (self , p_t0 , e0_t0 , e1_t0 , p_t1 , e0_t1 , e1_t1 , min_distance = 0.0 , tmax = 1.0 ):
32
35
return True , 0.0
36
+
33
37
def point_triangle_ccd (self , p_t0 , t0_t0 , t1_t0 , t2_t0 , p_t1 , t0_t1 , t1_t1 , t2_t1 , min_distance = 0.0 , tmax = 1.0 ):
34
38
return True , 0.0
39
+
35
40
def edge_edge_ccd (self , ea0_t0 , ea1_t0 , eb0_t0 , eb1_t0 , ea0_t1 , ea1_t1 , eb0_t1 , eb1_t1 , min_distance = 0.0 , tmax = 1.0 ):
36
41
return True , 0.0
37
42
@@ -49,38 +54,48 @@ def edge_edge_ccd(self, ea0_t0, ea1_t0, eb0_t0, eb1_t0, ea0_t1, ea1_t1, eb0_t1,
49
54
mesh , V0 , V1 , narrow_phase_ccd = DumbNarrowPhaseCCD ())
50
55
assert 0 <= toi <= 1
51
56
57
+
52
58
def test_custom_broad_phase ():
59
+ V0 , E , F = load_mesh ("two-cubes-close.ply" )
60
+ V1 , E , F = load_mesh ("two-cubes-intersecting.ply" )
61
+
53
62
class DumbBroadPhase (ipctk .BroadPhase ):
54
63
def __init__ (self ):
55
64
ipctk .BroadPhase .__init__ (self )
65
+
56
66
def name (self ):
57
67
return "DumbBroadPhase"
68
+
58
69
def detect_vertex_vertex_candidates (self ):
59
70
return []
71
+
60
72
def detect_edge_vertex_candidates (self ):
61
73
return []
74
+
62
75
def detect_edge_edge_candidates (self ):
63
- return []
76
+ return [(0 , 232 )]
77
+
64
78
def detect_face_vertex_candidates (self ):
65
- return []
79
+ return [(16 , 205 )]
80
+
66
81
def detect_edge_face_candidates (self ):
67
82
return []
83
+
68
84
def detect_face_face_candidates (self ):
69
85
return []
70
86
71
- V0 , E , F = load_mesh ("two-cubes-close.ply" )
72
- V1 , E , F = load_mesh ("two-cubes-intersecting.ply" )
73
-
74
87
mesh = ipctk .CollisionMesh (V0 , E , F )
75
88
76
- ipctk . set_num_threads ( 1 )
89
+ broad_phase = DumbBroadPhase ( )
77
90
78
- assert ipctk .is_step_collision_free (mesh , V0 , V1 , broad_phase = DumbBroadPhase () )
91
+ assert ipctk .is_step_collision_free (mesh , V0 , V1 , broad_phase = broad_phase )
79
92
80
- toi = ipctk .compute_collision_free_stepsize (mesh , V0 , V1 , broad_phase = DumbBroadPhase ())
93
+ toi = ipctk .compute_collision_free_stepsize (
94
+ mesh , V0 , V1 , broad_phase = broad_phase )
81
95
assert toi == 1
82
96
83
- assert not ipctk .has_intersections (mesh , V0 , broad_phase = DumbBroadPhase ())
97
+ assert not ipctk .has_intersections (mesh , V0 , broad_phase = broad_phase )
98
+
84
99
85
100
def test_nonlinear_ccd ():
86
101
class LinearTrajectory (ipctk .NonlinearTrajectory ):
0 commit comments