group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
MapConfig.hpp
Go to the documentation of this file.
1
20
21#pragma once
22
23#include "ecs/AssetCatalog.hpp"
25
26#include <SDL3/SDL_filesystem.h>
27#include <SDL3/SDL_log.h>
28
29#include <string>
30
31namespace gamemap
32{
33
45inline constexpr bool k_separatedCollisionMap = true;
46
49inline constexpr const char* k_collisionPattern = "COL_";
50
64inline constexpr bool k_guessShapesProcessed = true;
65
88inline constexpr bool k_useVhacd = false;
89
96{
98 opts.scale = kMapAsset.loadScale;
103 opts.decomposeNonConvex = k_useVhacd; // PR-30: project-wide V-HACD gate.
104 opts.addFloorPlane = false; // Map geometry provides its own floor.
105 return opts;
106}
107
112[[nodiscard]] inline std::string mapAbsolutePath()
113{
114 const char* const base = SDL_GetBasePath();
115 return std::string(base ? base : "") + "assets/" + kMapAsset.filename;
116}
117
127inline bool loadConfiguredMap(physics::MapCollisionData& out, const char* tag)
128{
129 const std::string path = mapAbsolutePath();
131
132 if (physics::loadMapCollision(path, out, opts)) {
133 SDL_Log("[%s] map collision loaded (%s): %zu planes, %zu boxes, %zu brushes, %zu cylinders, %zu spheres, "
134 "%zu trimeshes",
135 tag,
136 kMapAsset.filename,
137 out.planes.size(),
138 out.boxes.size(),
139 out.brushes.size(),
140 out.cylinders.size(),
141 out.spheres.size(),
142 out.triMeshes.size());
143 return true;
144 }
145
146 SDL_Log("[%s] WARNING: map collision load failed (%s) — falling back to testWorld()", tag, kMapAsset.filename);
147 return false;
148}
149
150} // namespace gamemap
Static asset loading and render-default metadata.
const AssetDefinition kMapAsset
Definition AssetCatalog.hpp:26
Load collision geometry (and optionally visual data) from a map GLB file.
Definition MapConfig.hpp:32
bool loadConfiguredMap(physics::MapCollisionData &out, const char *tag)
Load the configured map's collision into out.
Definition MapConfig.hpp:127
constexpr bool k_useVhacd
Run V-HACD convex decomposition on non-convex prop meshes?
Definition MapConfig.hpp:88
std::string mapAbsolutePath()
Resolve the absolute path of the configured map file.
Definition MapConfig.hpp:112
constexpr bool k_separatedCollisionMap
Does this map use SEPARATED collision and visual meshes?
Definition MapConfig.hpp:45
physics::MapLoadOptions makeLoadOptions()
Build the MapLoadOptions used by both client and server.
Definition MapConfig.hpp:95
constexpr bool k_guessShapesProcessed
Should collision meshes be auto-fit to primitive shapes, or kept as raw triMeshes (the exact artist-a...
Definition MapConfig.hpp:64
constexpr const char * k_collisionPattern
Substring that identifies collision-only nodes in separated mode.
Definition MapConfig.hpp:49
bool loadMapCollision(const std::string &path, MapCollisionData &out, const MapLoadOptions &opts)
API.
Definition MapLoader.cpp:1232
Collision data.
Definition MapLoader.hpp:38
std::vector< WorldTriMesh > triMeshes
Definition MapLoader.hpp:44
std::vector< WorldAABB > boxes
Definition MapLoader.hpp:40
std::vector< WorldSphere > spheres
Definition MapLoader.hpp:43
std::vector< WorldBrush > brushes
Definition MapLoader.hpp:41
std::vector< WorldCylinder > cylinders
Definition MapLoader.hpp:42
std::vector< Plane > planes
Definition MapLoader.hpp:39
Load options.
Definition MapLoader.hpp:66
bool guessShapesProcessed
In separated mode (allMeshesAreCollision = false), should the loader auto-detect/guess each collision...
Definition MapLoader.hpp:109
bool allMeshesAreCollision
When true, every mesh in the file is treated as both visual and collision geometry.
Definition MapLoader.hpp:79
std::string collisionCollection
Name of the Blender collection (= Assimp parent node) whose children are collision geometry.
Definition MapLoader.hpp:74
float scale
Uniform scale applied to every vertex position (e.g. 39.37 for m → in).
Definition MapLoader.hpp:68
bool addFloorPlane
When true, an infinite floor plane is added at the lowest Y coordinate found across all collision geo...
Definition MapLoader.hpp:84
bool decomposeNonConvex
In separated mode with shape-guessing on, when a collision mesh is non-convex (so it can't be a singl...
Definition MapLoader.hpp:131