Project
Voxel Destruction
Introduction
Physics simulations on 3D volumes typically utilize a finite element method (FEM) that represents objects as collections of tetrahedra. Nevertheless, video games like Minecraft and Teardown intentionally choose to use voxels ("volumetric pixels") rendered as cubes for their aesthetic appeal. In this project, we seek to create a fast system for simulating physics natively on hexahedral geometry instead of the tetrahedral geometry that is commonplace in FEM. In particular, we model collisions, elastic deformation, and fracture directly on voxelized geometry.
Alexander Thaep and I originally created this project for our CSCI 2240 (Advanced Graphics) final project at Brown University.
Voxels
We represent each voxel using a lattice spring model (LSM). Every voxel has eight corner nodes, each having its own position , velocity , and lumped mass . A voxel with edge length and density contributes mass to each corner. If a node is shared by several voxels, then the corresponding mass contributions are accumulated.
Our model uses springs along each voxel edge, face diagonal, and body diagonal (in essence, every node has a spring between it and every other node). In total, each voxel has 28 springs.
Figure 2.2 (Lattice Spring Model)
12 edge springs
12 face diagonal springs
4 body diagonal springs
28 springs per voxel
Adjacent voxels are connected by a face link. Each link identifies four coincident corner pairs, which are merged into shared nodes. When neighboring voxels define a spring between the same pair of shared nodes, we store that spring once and scale its stiffness by the number of voxels that contributed it.
Figure 2.3 (Face Links)
Face links therefore encode both object topology and mechanical continuity. The distance between the two voxel centroids is used to compute the tensile strain defining when a link fractures. The fracture process later removes failed links and reconstructs the affected node and spring arrays.
Dynamics
Springs
For an edge with current vector , length , rest length , unit direction , and effective stiffness , the spring energy and force follow the classical Hookean model [Liu et al. 2013].
Implicit Step
Stiff springs make explicit integration unstable at useful time steps. We instead linearize an implicit Euler step and solve directly for the position increment . With diagonal mass matrix , time step , total force , and stiffness matrix (the Hessian of the total spring energy), the system follows the formulation in Section 3.1 of [Wu et al. 2022].
We avoid manifesting due to its size. The implementation computes directly by summing the contribution from each spring. The preconditioned conjugate gradient (PCG) method can be used to solve the linear system efficiently. This matrix free form maps cleanly to PyTorch tensor operations and adapts immediately when fracture changes the spring graph.
The exact spring Hessian contains both axial and transverse terms (Eq. 3 of [Choi and Ko 2002]). We retain the positive semidefinite axial term
as a rank one approximation. Following the argument after Eq. 12 of [Choi and Ko 2002], we drop the transverse term because it becomes negative under compression. Omitting this term for every spring makes the linear operator symmetric positive definite (required for PCG).
Preconditioning
We evaluated the multilevel additive Schwarz preconditioner proposed by Wu et al. [2022], but did not use it in the final solver. Because fracture changes topology frequently, rebuilding its hierarchy offset the reduction in conjugate gradient iterations in our scenes. A Jacobi preconditioner, formed from the diagonal of , produced lower overall solve time with much less setup work.
Fracture
An intact face link is tested using the distance between its two voxel centroids. If the rest spacing is , its tensile strain is
The link is severed when exceeds the material yield threshold. Because both voxels still reference the same four nodes, removing a face link is insufficient on its own. We must therefore rebuild the topology, duplicate nodes along the new fracture surface, regenerate unique springs and rest lengths, recompute lumped masses, and copy position and velocity from each former parent node.
Figure 4.1 (Broken Link)
Tensile strain across the interface is determined by the distance between voxel centroids.
The link is severed once its tensile strain exceeds the yield threshold.
Each side is then rebuilt with its own nodes and springs.
Shared nodes are rebuilt from a graph whose vertices are the voxel corners. Each intact face link contributes four edges, one per coincident corner pair. Each connected component becomes one node. A shared node therefore splits only once broken links disconnect its corners. Components are labeled in parallel by label propagation combined with the pointer jumping approach used in the Shiloach–Vishkin algorithm [Shiloach and Vishkin 1982]. Every corner starts with its own index as its label. In one iteration, every corner is assigned the smallest label carried by it or its neighbors. Each label is then replaced with the current label of corner . Both steps are repeated until no label changes.
Figure 4.2 (Node Rebuild)
Collisions
Collision handling proceeds in four stages. 1) Produce collision candidates based on spatial locality, 2) define an oriented bounding box (OBB) around candidate voxels, 3) determine contact via the separating axis theorem, and 4) resolve penetration using a compliant positional constraint.
Figure 5.1 (Collision Pipeline)
Candidate Pairs
Testing every pair of voxels would require quadratic work. Instead, we only test pairs of voxels that are in proximity of one another. To find these collision candidates, we search over an axis aligned bounding box that encloses every voxel centroid (with padding on each side). This box is partitioned into cubic cells of width , numbered in row-major order.
Each voxel is assigned to the cell containing its centroid. With and cells along the and axes of the box, the cell at integer coordinates within the box receives the key
Sorting voxels by key gathers the voxels of each cell into one contiguous range that a binary search can retrieve. Collision candidates come from the neighborhood of a voxel's cell. Since adjacency is symmetric, only a voxel's own cell and the 13 neighboring cells with larger keys are searched. These 14 searches visit every adjacent pair of cells exactly once. Pairs that share a corner node are already attached and are discarded.
Figure 5.2 (Cell Search)
Each voxel centroid lies in one cell of an axis-aligned grid with width h.
Cells in the bounding box of occupied cells, padded by one cell, are numbered in row-major order.
For each voxel, its own cell and the 4 neighbors with larger keys are searched (13 of 26 in 3D).
Voxels in searched cells form candidate pairs. Pairs that share a node are discarded.
Bounding Boxes
Each candidate voxel is represented by an oriented bounding box with a centroid, three orthogonal axes, and three half extents. Before contact testing, we recover the orientation of each box from its deformed voxel.
Let and denote current and rest corner offsets from their respective centroids. Following the shape matching construction in Eqs. 15 and 16 of [Macklin et al. 2014], we form the covariance matrix and compute its singular value decomposition.
The determinant correction excludes reflections and yields the closest proper rotation. Projecting all eight current corner offsets onto the axes of gives the box half extents.
Contact Test
The separating axis theorem states that two convex shapes are disjoint if and only if their projections onto some axis are disjoint. Two oriented boxes require fifteen tests: three face directions from each box and nine pairwise cross products of their edge directions. If every interval overlaps, the axis with minimum penetration supplies the contact direction and depth.
This geometric test replaces the centroid distance approximation described by Mazarak et al. [1999]. It remains plausible when voxels rotate, shear, or approach one another corner first.
Figure 5.3 (Separating Axes)
Projection
Each overlap becomes a positional constraint on penetration. We accumulate one Lagrange multiplier per candidate pair and update it with the extended position based dynamics (XPBD) rule from Eq. 18 of [Macklin et al. 2016]. With contact compliance , , penetration depth , and reciprocal of mean voxel mass , our sign convention gives
With clamped at zero, contacts can push but never pull. Macklin et al. [2016] treat contacts as rigid. We keep a small compliance instead, which gives each contact a stiffness of . Projection runs for up to four passes per step. Each pass moves the corners of the two voxels along the contact normal by times the change in after clamping. A corner shared by several contacts receives the average of their corrections.
Sliding is then limited by Coulomb friction. With friction coefficient , normal correction , and relative tangential displacement of the two centroids over the step, tangential displacement is reduced to
Each voxel receives half of the removed displacement. Sliding is effectively zeroed out when and otherwise shrinks by . Voxel nodes below the ground plane are projected onto it, and Coulomb friction with equal to penetration depth is applied instead.
Credits
Voxel models come from ephtracy's voxel model collection.
References
- Tiantian Liu, Adam W. Bargteil, James F. O'Brien, and Ladislav Kavan. 2013. Fast Simulation of Mass-Spring Systems. ACM Transactions on Graphics 32, 6 (2013), Article 214. doi:10.1145/2508363.2508406
- Botao Wu, Zhendong Wang, and Huamin Wang. 2022. A GPU-Based Multilevel Additive Schwarz Preconditioner for Cloth and Deformable Body Simulation. ACM Transactions on Graphics 41, 4 (2022), Article 63. doi:10.1145/3528223.3530085
- Kwang-Jin Choi and Hyeong-Seok Ko. 2002. Stable but Responsive Cloth. ACM Transactions on Graphics 21, 3 (2002), 604–611. doi:10.1145/566654.566624
- Yossi Shiloach and Uzi Vishkin. 1982. An O(log n) Parallel Connectivity Algorithm. Journal of Algorithms 3, 1 (1982), 57–67. doi:10.1016/0196-6774(82)90008-6
- Miles Macklin, Matthias Müller, Nuttapong Chentanez, and Tae-Yong Kim. 2014. Unified Particle Physics for Real-Time Applications. ACM Transactions on Graphics 33, 4 (2014), Article 153. doi:10.1145/2601097.2601152
- Oleg Mazarak, Claude Martins, and John Amanatides. 1999. Animating Exploding Objects. In Proceedings of Graphics Interface 1999. Canadian Human-Computer Communications Society, 211–218. doi:10.20380/GI1999.27
- Miles Macklin, Matthias Müller, and Nuttapong Chentanez. 2016. XPBD: Position-Based Simulation of Compliant Constrained Dynamics. In Proceedings of the 9th International Conference on Motion in Games. Association for Computing Machinery, 49–54. doi:10.1145/2994258.2994272
