group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
GripPose.cpp File Reference

TOML loader/saver for per-weapon hand grip poses (pitch+yaw schema). More...

#include "ecs/components/GripPose.hpp"
#include <SDL3/SDL_log.h>
#include <array>
#include <cstdio>
#include <filesystem>
#include <fstream>
#include <toml++/toml.hpp>
Include dependency graph for GripPose.cpp:

Functions

bool loadWeaponGripPose (const std::string &path, WeaponGripPose &out)
 Load a weapon grip pose from a TOML side-table.
bool saveWeaponGripPoseToml (const std::string &path, const WeaponGripPose &pose, bool rightHandValid, bool leftHandValid)
 Save a grip pose back to a TOML file.

Detailed Description

TOML loader/saver for per-weapon hand grip poses (pitch+yaw schema).

Function Documentation

◆ loadWeaponGripPose()

bool loadWeaponGripPose ( const std::string & path,
WeaponGripPose & out )

Load a weapon grip pose from a TOML side-table.

File format (pitch / yaw degrees per joint):

[right_hand.thumb]
joints = [[pitch, yaw], [pitch, yaw], [pitch, yaw], [pitch, yaw]]
[right_hand.index]
joints = [...]
# ... middle, ring, pinky
[left_hand.thumb]
joints = [...]
# ... (sections may be omitted; missing hand stays invalid + falls back
# to the animated finger pose at runtime)
Returns
True if the file parsed successfully (at least one hand valid).

◆ saveWeaponGripPoseToml()

bool saveWeaponGripPoseToml ( const std::string & path,
const WeaponGripPose & pose,
bool rightHandValid,
bool leftHandValid )

Save a grip pose back to a TOML file.

Writes the same shape the loader expects. Sections for a hand are omitted when the matching hand is invalid (so a single-hand TOML round-trips correctly). Returns false on filesystem failure; the caller is expected to log appropriately.