Skip to main content

3d-diffs - CAD code reviews

Kurt Hutten

Kurt Hutten

CadHub Core Team

When making a change to a repo, we're all familiar with code diffs, so common we don't give them a second thought. What's so powerful about code-diffs is they let us to apply our entire conceptual model of how the software functions to a laser focused section the code, to both check that the change is good, as well as giving us a chance to update that mental model incrementally.

CodeCAD is in a unique position that it outputs a 3d artifact, but we can also produce diff artifacts for the purpose of reviewing, it's so intuitive that it needs little explanation, so here's an example:

Green represents where material has been added to the model, and red where it's been removed. Because the hole count has decreased from 3 to 2, the middle hole has been filled in. The holes have also increased in diameter which is why there are red rings around the two outer holes where material has been removed.

The process for creating these diffs is rather elegant, here's some pseudo-code:

noChange = intersection(newShape, oldShape)
addedMaterial = subtract(newShape, oldShape)
removedMaterial = subtract(oldShape, newShape)
colorGray(noChange)
colorGreen(addedMaterial)
colorRed(removedMaterial)

3d diffs are part of the reason why Github integration is on the road-map for Cadhub, it's such a low hanging fruit that will immediately make code reviews better, I'm excited to make them happen.