26 float restitution = material_defaults::k_restitution;
27 float static_friction = material_defaults::k_static_friction;
28 float dynamic_friction = material_defaults::k_dynamic_friction;
30 float spin_friction = material_defaults::k_spin_friction;
34 glm::vec3 position = {};
35 float penetration = 0.0f;
43 glm::vec3 normal = {};
44 uint8_t normal_index = k_primitive_manifold_normal_index;
45 std::array<ContactPoint, 4> contacts = {};
46 uint8_t contact_count = 0;
51 if (lhs.pair != rhs.pair) {
52 return lhs.pair < rhs.pair;
55 if (lhs.normal_index != rhs.normal_index) {
56 return lhs.normal_index < rhs.normal_index;
59 if (lhs.contact_count != rhs.contact_count) {
60 return lhs.contact_count < rhs.contact_count;
63 for (std::size_t index = 0; index < lhs.contact_count && index < lhs.contacts.size(); ++index) {
67 if (lhs_contact.feature_a != rhs_contact.feature_a) {
68 return lhs_contact.feature_a < rhs_contact.feature_a;
70 if (lhs_contact.feature_b != rhs_contact.feature_b) {
71 return lhs_contact.feature_b < rhs_contact.feature_b;
81 float normal_impulse = 0.0f;
82 glm::vec3 tangent_impulse = {};
89 uint8_t normal_index = k_primitive_manifold_normal_index;
90 uint32_t shape_a_revision = 0;
91 uint32_t shape_b_revision = 0;
92 std::array<CachedContact, 4> contacts = {};
93 uint8_t contact_count = 0;
98inline constexpr float direction_epsilon_sq = 1.0e-10f;
99inline constexpr float parallel_axis_epsilon_sq = 1.0e-10f;
100inline constexpr float contact_tolerance = 1.0e-5f;
101inline constexpr float duplicate_point_epsilon_sq = 1.0e-8f;
102inline constexpr float unit_normal_tolerance = 1.0e-3f;
118 glm::vec3 half_extents;
133enum class BoxFeatureType : uint8_t {
141 BoxFeatureType type = BoxFeatureType::interior;
142 uint8_t axis_mask = 0;
143 uint8_t positive_mask = 0;
144 auto operator<=>(
const BoxFeature&)
const =
default;
148 glm::vec3 segment_point;
150 float segment_parameter;
155 glm::vec3 segment_point;
157 float segment_parameter;
161 glm::vec3 local_normal;
162 glm::vec3 local_point;
163 glm::vec3 local_surface;
165 float segment_parameter;
169 glm::vec3 position {};
170 float penetration = 0.0f;
176auto boxFeature(
const glm::vec3& point,
const glm::vec3& half_extents) ->
BoxFeature;
186auto closestPointOnSegment(
const glm::vec3& point,
const glm::vec3& segment_a,
const glm::vec3& segment_b) ->
SegmentClosestPoint;
188auto closestPointsBetweenSegments(
const glm::vec3& a0,
const glm::vec3& a1,
const glm::vec3& b0,
const glm::vec3& b1)
191auto closestPointOnBox(
const glm::vec3& point,
const WorldBox& box) -> glm::vec3;
193auto closestPointsSegmentBox(
const glm::vec3& segment_a,
const glm::vec3& segment_b,
const WorldBox& box)
196auto closestPointsSegmentAabb(
const glm::vec3& local_a,
const glm::vec3& local_b,
const glm::vec3& half_extents)
199auto capsuleVoxelContact(
200 const glm::vec3& segment_a,
const glm::vec3& segment_b,
float radius,
const glm::vec3& voxel_min, uint8_t normal_index
201) -> std::optional<CapsuleVoxelContact>;
203auto perpendicularTo(
const glm::vec3& segment) -> glm::vec3;
221 bool voxel_is_a =
false;
239auto splitVoxelRegions(
const AABB& local_bounds,
size_t region_count) -> std::vector<AABB>;
243 std::array<std::vector<_detail::ContactCandidate>, voxel::k_normal_direction_count> candidates_per_normal;
244 std::array<glm::vec3, voxel::k_normal_direction_count> normal_per_group {};
245 std::array<glm::vec3, voxel::k_normal_direction_count> normal_sum_per_group {};
246 std::array<ContactMaterial, voxel::k_normal_direction_count> material_per_group {};
247 std::array<bool, voxel::k_normal_direction_count> group_started {};
253void mergeBoxVoxelPartials(
263 bool a_is_probe =
false;
278auto classifyVoxelVoxelSplit(
const VoxelVoxelPairView& view) -> std::optional<VoxelVoxelSplitInfo>;
283void mergeVoxelVoxelPartials(
296void collideSphereVoxel(
298 std::vector<Manifold>& output
306 std::vector<Manifold>& output
312void collideCapsuleVoxel(
314 std::vector<Manifold>& output
320void collideVoxelVoxel(
322 std::vector<Manifold>& output
Canonical collision-pair records shared by broad and narrow phases.
Read-only access to physics data used by collision detection.
The values a material has when nothing sets them.
constexpr float k_rolling_friction
A ball rolling on a hard floor loses a few percent of its speed per metre.
Definition material_defaults.hpp:22
Box/voxel roles already resolved so splitting one pair across jobs only pays that resolution once.
Definition manifold.hpp:217
Definition manifold.hpp:227
AABB local_bounds
The box AABB in voxel local space safe to partition spatially across jobs.
Definition manifold.hpp:229
uint64_t estimated_voxels
Cheap surface area estimate, not an actual walk, since queryVoxelSurface only visits surface voxels.
Definition manifold.hpp:231
Definition collision.hpp:24
Definition manifold.hpp:85
glm::vec3 normal
Points from pair.a to pair.b.
Definition manifold.hpp:88
Definition manifold.hpp:211
Definition collision_world.hpp:16
Definition manifold.hpp:41
One region share of a split pair candidates owned per call since concurrent regions need independent ...
Definition manifold.hpp:242
Definition voxel_shape_data.hpp:26
A voxel-voxel pair with the smaller-shape-is-probe role already resolved, same reasoning as BoxVoxelP...
Definition manifold.hpp:258
Definition manifold.hpp:269
uint64_t estimated_voxels
Same surface area estimate as BoxVoxelSplitInfo::estimated_voxels, see its comment for why.
Definition manifold.hpp:273
AABB probe_search_bounds
The probe shape search bounds in its own local space safe to partition spatially across jobs.
Definition manifold.hpp:271
Definition manifold.hpp:140
Definition manifold.hpp:154
Definition manifold.hpp:147
Definition manifold.hpp:121
Definition manifold.hpp:126
Definition manifold.hpp:115
Definition manifold.hpp:109
Definition manifold.hpp:104
Definition palette.hpp:94
Voxel data structures for physics system.