Toast Engine
Loading...
Searching...
No Matches
fracture.hpp File Reference

How much of a voxel volume a hit breaks. More...

#include "fracture_pattern.hpp"
#include "fracture_profile.hpp"
#include "fracture_random.hpp"
#include "hardness.hpp"
#include "physics_settings.hpp"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <glm/glm.hpp>
#include <limits>
#include <numbers>
#include <optional>
#include <span>
#include <toast/voxel/palette.hpp>
#include <toast/voxel/voxel_constants.hpp>
#include <toast/voxel/voxel_volume.hpp>
#include <unordered_set>
#include <vector>
Include dependency graph for fracture.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  physics::FractureRequest
struct  physics::UnglueRegion
struct  physics::Crater
struct  physics::FractureCandidate
struct  physics::Penetration
struct  physics::EnergySplit

Functions

constexpr auto physics::voxelBreakEnergy (const voxel::PhysicalMaterial &material) -> float
constexpr auto physics::voxelKey (const glm::ivec3 &v) -> uint64_t
auto physics::craterRadiusAt (const Crater &crater, const glm::vec3 &point) -> float
constexpr auto physics::craterMaxRadius (const Crater &crater) -> float
constexpr auto physics::craterMinRadius (const Crater &crater) -> float
template<typename Visit>
void physics::forEachSolidVoxel (const voxel::Volume &volume, const glm::vec3 &low, const glm::vec3 &high, Visit &&visit)
auto physics::pointSegmentDistanceSquared (const glm::vec3 &point, const glm::vec3 &start, const glm::vec3 &end) -> float
auto physics::closestPointOnSegment (const glm::vec3 &point, const glm::vec3 &start, const glm::vec3 &end) -> glm::vec3
auto physics::reachesThroughMaterial (const voxel::Volume &volume, const glm::vec3 &from, const glm::vec3 &to) -> bool
auto physics::reachableMaterial (const voxel::Volume &volume, const glm::vec3 &start, const glm::vec3 &end, float radius) -> std::unordered_set< uint64_t >
auto physics::damageReaches (const std::unordered_set< uint64_t > &reachable, const voxel::Volume &volume, const glm::ivec3 &voxel, const glm::vec3 &from, const glm::vec3 &center) -> bool
constexpr auto physics::hitBreaks (const voxel::PhysicalMaterial &material, float energy_density, Hardness max_hardness) -> bool
auto physics::hitMaterial (const voxel::Volume &volume, const voxel::Palette &palette, const voxel::MaterialLibrary &materials, const glm::vec3 &point, float reach) -> std::optional< voxel::PhysicalMaterial >
auto physics::fractureCandidates (const voxel::Volume &volume, const voxel::Palette &palette, const voxel::MaterialLibrary &materials, const FractureRequest &request, const std::unordered_set< uint64_t > &reachable) -> std::vector< FractureCandidate >
auto physics::penetrationDepth (std::span< const FractureCandidate > candidates, float energy, float max_depth) -> Penetration
constexpr auto physics::capsuleVolume (float radius, float length) -> float
auto physics::overshootRadius (float energy_left, float toughness, float radius, float length, float max_overshoot) -> float
auto physics::splitLeftoverEnergy (float left, float debris_share, float fragment_share, FracturePattern pattern) -> EnergySplit
auto physics::planUnglue (const voxel::Volume &volume, const voxel::Palette &palette, const voxel::MaterialLibrary &materials, const glm::vec3 &start, const glm::vec3 &end, float radius, Hardness max_hardness, float energy, float bond_cost, uint32_t max_voxels) -> UnglueRegion
auto physics::planCrater (const voxel::Volume &volume, const voxel::Palette &palette, const voxel::MaterialLibrary &materials, const FractureRequest &request) -> Crater
auto physics::explosionDensityAt (float density, float distance, float falloff) -> float
auto physics::explosionReach (float density, float falloff, float toughness, float max_radius) -> float
auto physics::weakestToughness (const voxel::MaterialLibrary &materials, Hardness max_hardness) -> float
auto physics::impactDensity (float energy, float patch_radius) -> float

Variables

constexpr float physics::k_voxel_volume = voxel::k_voxel_size * voxel::k_voxel_size * voxel::k_voxel_size
constexpr float physics::k_joules_per_kilojoule = 1000.0f
constexpr uint32_t physics::k_unglue_neighbor_count = 6
constexpr float physics::k_max_edge_noise = 0.9f
constexpr float physics::k_min_radius_factor = 0.15f

Detailed Description

How much of a voxel volume a hit breaks.

Author
Xein
Date
12 Oct 2026