group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
CookedMeshFormat.hpp File Reference

Binary on-disk format for cooked WorldTriMesh collision data. More...

#include "ecs/physics/SweptCollision.hpp"
#include <cstdint>
#include <span>
#include <string_view>
#include <vector>
Include dependency graph for CookedMeshFormat.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  physics::cook::Header
 32-byte fixed-size header that opens every cooked-mesh blob. More...

Namespaces

namespace  physics
 Pure physics math — no ECS types, no registry.
namespace  physics::cook

Functions

std::vector< uint8_t > physics::cook::serialize (const WorldTriMesh &mesh)
 Serialize a fully-cooked WorldTriMesh to a contiguous byte vector.
bool physics::cook::deserialize (std::span< const uint8_t > blob, WorldTriMesh &out)
 Deserialize a cooked blob back into a WorldTriMesh.
bool physics::cook::writeToFile (std::string_view path, const WorldTriMesh &mesh)
 Convenience: write a serialized blob to a file.
bool physics::cook::readFromFile (std::string_view path, WorldTriMesh &out)
 Convenience: read a file into memory and deserialize.

Variables

constexpr uint32_t physics::cook::k_magic = 0x6D63'3267u
constexpr uint32_t physics::cook::k_version = 1u

Detailed Description

Binary on-disk format for cooked WorldTriMesh collision data.

Eliminates load-time BVH build + welding + V-HACD (the cooker runs all of those once at content-build time and writes the result here). Runtime load is a single contiguous read + sanity check.

Format. Little-endian, 4-byte-aligned. Versioned via the header magic ('g2cm') and version int. Older cookers / loaders must reject mismatched versions.

Layout: Header (32 B) Vertices (N * vec3) (N * 12 B) Indices (M * uint32) (M * 4 B) FaceNormals (Tri * vec3) (Tri * 12 B) Tri = M/3 EdgeActive (Tri * uint8) (Tri B) VertActive (Tri * uint8) (Tri B) TriangleMaterials (Tri * u8) (Tri B) — 0xFF sentinel = none, use default (Optional alignment padding to 4 B) BVHNodes (K * BVHNode) (K * sizeof(BVHNode)) TriIndices (Tri * uint32) (Tri * 4 B)