Kelsidavis-WoWee/include/game/transport_animator.hpp
Pavel Okhlopkov 39719cac82 refactor: decompose TransportManager and upgrade Entity to CatmullRom splines
TransportManager decomposition:
- Extract TransportClockSync: server clock offset, yaw flip detection,
  velocity bootstrap, client/server mode switching
- Extract TransportAnimator: spline evaluation, Z clamping, orientation
  from server yaw or spline tangent
- Slim TransportManager to thin orchestrator delegating to ClockSync and
  Animator; add pushTransform() helper to deduplicate WMO/M2 renderer calls
- Remove legacy orientationFromSplineTangent (now uses
  CatmullRomSpline::orientationFromTangent)

Entity path following upgrade:
- Replace pathPoints_/pathSegDists_ linear lerp with
  std::optional<CatmullRomSpline> activeSpline_
- startMoveAlongPath builds SplineKeys with distance-proportional timing
- updateMovement evaluates CatmullRomSpline for smooth Catmull-Rom
  interpolation matching server-side creature movement
- Reset activeSpline_ on setPosition/startMoveTo to prevent stale state

Tests:
- Add test_transport_components (9 cases): ClockSync client/server/reverse
  modes, yaw flip detection, Animator position eval, server yaw, Z clamping
- Link spline.cpp into test_entity for CatmullRomSpline dependency

Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
2026-04-11 09:50:38 +03:00

33 lines
1 KiB
C++

// include/game/transport_animator.hpp
// Path evaluation, Z clamping, and orientation for transports.
// Extracted from TransportManager (Phase 3b of spline refactoring).
#pragma once
#include <glm/glm.hpp>
#include <glm/gtc/quaternion.hpp>
#include <cstdint>
namespace wowee::math { class CatmullRomSpline; }
namespace wowee::game {
struct ActiveTransport;
struct PathEntry;
/// Evaluates a transport's position and orientation from a spline path and path time.
class TransportAnimator {
public:
/// Evaluate the spline at pathTimeMs, apply Z clamping, and update
/// transport.position and transport.rotation in-place.
void evaluateAndApply(
ActiveTransport& transport,
const PathEntry& pathEntry,
uint32_t pathTimeMs) const;
private:
/// Guard against bad fallback Z offsets on non-world-coordinate paths.
static float clampZOffset(float z, bool worldCoords, bool clientAnim,
int serverUpdateCount, bool hasServerClock);
};
} // namespace wowee::game