Skip to content

Commit 76c90f2

Browse files
authored
Fix STQ vertex id assignment (#204)
* fix vertex id assignment * follow scalable ccd convention * remove unused include
1 parent d2cb640 commit 76c90f2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/ipc/broad_phase/sweep_and_tiniest_queue.cu

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ void SweepAndTiniestQueue::build(
8989
boxes->vertices[i].max.z =
9090
vertex_boxes[i].max.size() > 2 ? vertex_boxes[i].max.z() : 0;
9191

92-
boxes->vertices[i].min.x = vertex_boxes[i].vertex_ids[0];
93-
boxes->vertices[i].min.y = vertex_boxes[i].vertex_ids[1];
94-
boxes->vertices[i].min.z = vertex_boxes[i].vertex_ids[2];
92+
// If vertex id == -1 it means this slot is not used.
93+
// But Scalable CCD does not have this kind of special value so we map
94+
// it to unique negative id.
95+
const auto [vi, vj, vk] = vertex_boxes[i].vertex_ids;
96+
assert(vi >= 0);
97+
boxes->vertices[i].vertex_ids.x = vi;
98+
boxes->vertices[i].vertex_ids.y = vj >= 0 ? vj : (-vi - 1);
99+
boxes->vertices[i].vertex_ids.z = vk >= 0 ? vk : (-vi - 1);
95100

96101
boxes->vertices[i].element_id = i;
97102
}
@@ -271,4 +276,4 @@ bool SweepAndTiniestQueue::can_faces_collide(size_t fai, size_t fbi) const
271276

272277
} // namespace ipc
273278

274-
#endif
279+
#endif

0 commit comments

Comments
 (0)