fix(cuda): report surface intersection diagnostics - #458
Conversation
Log edge-triangle intersection details with geometry, instance, object, and self-collision identifiers to make sanity-check failures easier to trace. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Code Review
This pull request updates the SimplicialSurfaceIntersectionCheck to include more detailed logging for intersection detection. The changes include adding necessary headers, adjusting code formatting, and introducing diagnostic logging for edges and triangles. However, a high-severity issue was identified regarding the indexing of SelfCollision attributes and the inconsistency in using F[1] instead of F[0] for triangle attribute retrieval, which deviates from established patterns in the codebase.
| auto GeoIdR = VGeoIds[F[1]]; | ||
|
|
||
| auto ObjIdL = VObjectIds[E[0]]; | ||
| auto ObjIdR = VObjectIds[F[0]]; | ||
| auto ObjIdR = VObjectIds[F[1]]; | ||
|
|
||
| auto InstIdL = VInstanceIds[E[0]]; | ||
| auto InstIdR = VInstanceIds[F[1]]; | ||
|
|
||
| auto SelfCollL = SelfCollision[InstIdL]; | ||
| auto SelfCollR = SelfCollision[InstIdR]; |
There was a problem hiding this comment.
The indexing for SelfCollision is incorrect. SelfCollision is a vertex attribute (retrieved from scene_surface.vertices()), so it must be indexed by a vertex index (e.g., E[0] or F[0]), not by an instance ID (InstIdL or InstIdR). Indexing with an instance ID will likely lead to out-of-bounds access or incorrect diagnostic values.
Additionally, the change from F[0] to F[1] for triangle attributes is inconsistent with the edge handling (which uses E[0]) and with the CUDA kernel implementation (which uses F[0] for tri_bids and tri_cids at lines 134-135). Maintaining consistency in debug export functionality is required to ensure uniform semantics across the repository.
auto GeoIdR = VGeoIds[F[0]];
auto ObjIdL = VObjectIds[E[0]];
auto ObjIdR = VObjectIds[F[0]];
auto InstIdL = VInstanceIds[E[0]];
auto InstIdR = VInstanceIds[F[0]];
auto SelfCollL = SelfCollision[E[0]];
auto SelfCollR = SelfCollision[F[0]];
References
- When adding new debug export functionality, ensure its implementation is consistent with existing, similar functionalities to maintain uniform semantics.
Use triangle vertex indices consistently for right-side metadata and vertex indices for self-collision diagnostics. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Test plan
clang-format -i src/backends/cuda/sanity_check/simplicial_surface_intersection_check.cugit diff --check main...HEAD