Player12
An open source football management simulator
Loading...
Searching...
No Matches
match_renderer_3d.cpp File Reference
#include "gui/render/match_renderer_3d.h"
#include <fmt/printf.h>
#include <imgui.h>
#include <algorithm>
#include <array>
#include <cfloat>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <format>
#include <numbers>
#include <span>
#include <string>
#include <utility>
#include <vector>
#include "global/language_manager.h"
#include "gui/render/match_camera_3d.h"
#include "gui/render/match_kit_colors.h"
#include "gui/render/match_player_rig.h"
#include "gui/render/match_render_3d_tuning.h"
#include "gui/render/match_render_math.h"
#include "gui/render/match_renderer_2d.h"
#include "gui/render/match_shirt_numbers.h"
#include "gui/render/match_stadium_3d.h"
#include "gui/view_models/match_clock.h"
#include "gui/widgets/theme.h"
#include "model/player.h"
#include "model/role_utils.h"

Classes

struct  MatchRenderer3D::State
 
struct  CrowdFaceLayout
 
struct  GaitFrame
 
struct  PlayerTorsoFrame
 

Functions

ImVec2 crowdPoint (const CrowdFaceLayout &layout, float x, float y, float across, float up, float dx, float dy)
 
template<class RendererState >
void drawCrowdDot (RendererState &state, const CrowdFaceLayout &layout, const Stadium3D::CrowdClump &clump, const Stadium3D::CrowdDot &dot, std::uint32_t detail)
 
template<class RendererState >
void drawPitchCell (RendererState &state, const Stadium3D::PitchGrid &grid, std::size_t cell, std::size_t rows, std::size_t cellsPerStripe)
 
template<class RendererState >
void initializeAnimationSlot (RendererState &state, const MatchRenderPlayer &player, AnimationSlot &slot, Vec3 root, float yaw)
 
template<class RendererState >
float jumpTargetFor (const RendererState &state, const MatchRenderPlayer &player, Vec3 root, float scale)
 
float attackDirectionFor (std::span< const MatchRenderPlayer > players, const MatchRenderPlayer &carrier)
 
void setCelebrationFocus (MatchCameraFocus &focus, std::span< const MatchRenderPlayer > players, std::uint32_t scorer, float alpha)
 
template<class RendererState >
void drawPlayerMarker (RendererState &state, const MatchRenderPlayer &player, Vec3 root, float pixelHeight)
 
template<class RendererState >
void drawDayPlayerShadow (RendererState &state, Vec3 root, float standing, Vec3 sunAway, float sunLength)
 
template<class RendererState >
void drawFloodlightPlayerShadows (RendererState &state, Vec3 root, float pixelHeight, float standing, std::span< const Vec3 > lights)
 
template<class RendererState >
void drawPossessionRing (RendererState &state, Vec3 root)
 
template<class RendererState >
void drawPlayerShadow (RendererState &state, const MatchRenderPlayer &player, Vec3 root, float pixelHeight, float standing, Vec3 sunAway, float sunLength, std::span< const Vec3 > lights)
 
template<class RendererState >
void drawDistantCrowdClump (RendererState &state, const Stadium3D::CrowdClump &clump, const CrowdFaceLayout &layout, Vec4 clumpClip, float inverseDepth)
 
template<class RendererState >
void drawNearCrowdClump (RendererState &state, const Stadium3D::CrowdClump &clump, const CrowdFaceLayout &layout, Vec4 clumpClip, float seatPixels)
 
template<class RendererState >
void drawCrowdClump (RendererState &state, const Stadium3D::CrowdClump &clump, const CrowdFaceLayout &layout, float seatFocal)
 
template<class RendererState >
void drawStadiumFace (RendererState &state, const Stadium3D::Face &face)
 
GaitFrame advanceGait (AnimationSlot &slot, const MatchRenderPlayer &player, Vec3 root, float scale, float deltaSeconds)
 
void updateMotionRates (AnimationSlot &slot, float groundSpeed, float yaw, float simSeconds)
 
template<class RendererState >
void updateKeeperPose (RendererState &state, const MatchRenderPlayer &player, AnimationSlot &slot, Vec3 root, float yaw, float blend)
 
void updateFootPlanting (AnimationSlot &slot, Vec3 root, float yaw, float scale, float cycleMetres, float groundSpeed, float simSeconds)
 
Pose poseForTimedEvent (Pose pose, PlayerRig::Event event, float eventTime, float eventWeight, std::size_t eventLeg)
 
Pose poseForKeeper (Pose pose, bool keeper, float setBlend, float diveBlend, float diveSide, float stride)
 
Pose poseForCelebration (Pose pose, GoalMood mood, bool reducedMotion, float elapsedSeconds, std::uint32_t seed, float stride, float celebrationWeight)
 
void applyEventFootTargets (std::array< Vec3, 2 > &ankleTargets, std::array< bool, 2 > &planted, const AnimationSlot &slot, Vec3 pelvis, float ankleHeight, float scale, float eventTime, float eventWeight)
 
template<class RendererState >
void drawPlayerLeg (RendererState &state, const AnimationSlot &slot, std::size_t index, const std::array< Vec3, 2 > &hipJoint, const std::array< Vec3, 2 > &knee, const std::array< Vec3, 2 > &ankle, const std::array< float, 2 > &heel, const std::array< bool, 2 > &planted, Vec3 bodySide, float scale, float bulk, float objectDepth, PlayerLod lod, const KitColors &kit, const PlayerLook &look, ImU32 skin)
 
template<class RendererState >
void drawPlayerLegs (RendererState &state, const AnimationSlot &slot, const std::array< Vec3, 2 > &hipJoint, const std::array< Vec3, 2 > &knee, const std::array< Vec3, 2 > &ankle, const std::array< float, 2 > &heel, const std::array< bool, 2 > &planted, Vec3 bodySide, float scale, float bulk, float objectDepth, PlayerLod lod, const KitColors &kit, const PlayerLook &look, ImU32 skin)
 
float fitPelvisToPlantedFeet (float pelvisHeight, const AnimationSlot &slot, Vec3 root, Vec3 flatSide, Vec3 forward, float scale, float poseLift)
 
void buildPlayerAnkleTargets (const AnimationSlot &slot, const Pose &pose, Vec3 root, Vec3 pelvis, Vec3 bodyUp, Vec3 bodySide, Vec3 forward, float scale, float ankleHeight, std::array< Vec3, 2 > &hipJoint, std::array< Vec3, 2 > &ankleTarget, std::array< bool, 2 > &planted)
 
void solvePlayerLegJoints (const AnimationSlot &slot, const std::array< Vec3, 2 > &hipJoint, const std::array< Vec3, 2 > &ankleTarget, const std::array< bool, 2 > &planted, Vec3 forward, Vec3 bodyUp, float scale, std::array< Vec3, 2 > &knee, std::array< Vec3, 2 > &ankle, std::array< float, 2 > &heel)
 
template<class RendererState >
PlayerTorsoFrame drawPlayerTorso (RendererState &state, const AnimationSlot &slot, const Pose &pose, Vec3 pelvis, Vec3 bodyUp, Vec3 bodySide, Vec3 forward, float scale, float bulk, float objectDepth, PlayerLod lod, bool detailed, std::size_t kitIndex, const KitColors &kit)
 
template<class RendererState >
void detectTackleActions (RendererState &state, const MatchRenderSnapshot &snapshot, float alpha)
 
template<class RendererState >
void detectKickAction (RendererState &state, const MatchRenderSnapshot &snapshot, float alpha)
 
template<class RendererState >
void captureGoalEvent (RendererState &state, const MatchRenderSnapshot &snapshot)
 
template<class RendererState >
void addGoalNetPanel (RendererState &state, const Stadium3D::NetPanel &net, bool rippling, float age, Vec3 mouth)
 
template<class RendererState >
void addGoalFrame (RendererState &state, const Stadium3D::Goal &frame, std::size_t goalIndex)
 
template<class RendererState >
void updateBallRotation (RendererState &state, Vec3 world, Vec3 moved, float distance, const ScreenPoint &screen)
 
template<class RendererState >
void updateMatchSimulation (RendererState &state, const MatchRenderSnapshot &snapshot, float deltaSeconds, float alpha)
 
template<class RendererState >
void updateRenderCamera (RendererState &state, const MatchRenderSnapshot &snapshot, const MatchRenderOptions &options, const MatchViewport &viewport, float deltaSeconds, float alpha)
 
template<class RendererState >
void drawWorldLayers (RendererState &state, const MatchRenderSnapshot &snapshot, const MatchRenderOptions &options, float alpha)
 
template<class RendererState >
void drawSortedLayers (RendererState &state, const MatchRenderSnapshot &snapshot, const MatchRenderOptions &options, float alpha)
 

Function Documentation

◆ addGoalFrame()

template<class RendererState >
void addGoalFrame ( RendererState &  state,
const Stadium3D::Goal &  frame,
std::size_t  goalIndex 
)

◆ addGoalNetPanel()

template<class RendererState >
void addGoalNetPanel ( RendererState &  state,
const Stadium3D::NetPanel &  net,
bool  rippling,
float  age,
Vec3  mouth 
)

◆ advanceGait()

GaitFrame advanceGait ( AnimationSlot &  slot,
const MatchRenderPlayer &  player,
Vec3  root,
float  scale,
float  deltaSeconds 
)

◆ applyEventFootTargets()

void applyEventFootTargets ( std::array< Vec3, 2 > &  ankleTargets,
std::array< bool, 2 > &  planted,
const AnimationSlot &  slot,
Vec3  pelvis,
float  ankleHeight,
float  scale,
float  eventTime,
float  eventWeight 
)

◆ attackDirectionFor()

float attackDirectionFor ( std::span< const MatchRenderPlayer >  players,
const MatchRenderPlayer &  carrier 
)

◆ buildPlayerAnkleTargets()

void buildPlayerAnkleTargets ( const AnimationSlot &  slot,
const Pose &  pose,
Vec3  root,
Vec3  pelvis,
Vec3  bodyUp,
Vec3  bodySide,
Vec3  forward,
float  scale,
float  ankleHeight,
std::array< Vec3, 2 > &  hipJoint,
std::array< Vec3, 2 > &  ankleTarget,
std::array< bool, 2 > &  planted 
)

◆ captureGoalEvent()

template<class RendererState >
void captureGoalEvent ( RendererState &  state,
const MatchRenderSnapshot &  snapshot 
)

◆ crowdPoint()

ImVec2 crowdPoint ( const CrowdFaceLayout &  layout,
float  x,
float  y,
float  across,
float  up,
float  dx,
float  dy 
)

◆ detectKickAction()

template<class RendererState >
void detectKickAction ( RendererState &  state,
const MatchRenderSnapshot &  snapshot,
float  alpha 
)

◆ detectTackleActions()

template<class RendererState >
void detectTackleActions ( RendererState &  state,
const MatchRenderSnapshot &  snapshot,
float  alpha 
)

◆ drawCrowdClump()

template<class RendererState >
void drawCrowdClump ( RendererState &  state,
const Stadium3D::CrowdClump &  clump,
const CrowdFaceLayout &  layout,
float  seatFocal 
)

◆ drawCrowdDot()

template<class RendererState >
void drawCrowdDot ( RendererState &  state,
const CrowdFaceLayout &  layout,
const Stadium3D::CrowdClump &  clump,
const Stadium3D::CrowdDot &  dot,
std::uint32_t  detail 
)

◆ drawDayPlayerShadow()

template<class RendererState >
void drawDayPlayerShadow ( RendererState &  state,
Vec3  root,
float  standing,
Vec3  sunAway,
float  sunLength 
)

◆ drawDistantCrowdClump()

template<class RendererState >
void drawDistantCrowdClump ( RendererState &  state,
const Stadium3D::CrowdClump &  clump,
const CrowdFaceLayout &  layout,
Vec4  clumpClip,
float  inverseDepth 
)

◆ drawFloodlightPlayerShadows()

template<class RendererState >
void drawFloodlightPlayerShadows ( RendererState &  state,
Vec3  root,
float  pixelHeight,
float  standing,
std::span< const Vec3 >  lights 
)

◆ drawNearCrowdClump()

template<class RendererState >
void drawNearCrowdClump ( RendererState &  state,
const Stadium3D::CrowdClump &  clump,
const CrowdFaceLayout &  layout,
Vec4  clumpClip,
float  seatPixels 
)

◆ drawPitchCell()

template<class RendererState >
void drawPitchCell ( RendererState &  state,
const Stadium3D::PitchGrid &  grid,
std::size_t  cell,
std::size_t  rows,
std::size_t  cellsPerStripe 
)

◆ drawPlayerLeg()

template<class RendererState >
void drawPlayerLeg ( RendererState &  state,
const AnimationSlot &  slot,
std::size_t  index,
const std::array< Vec3, 2 > &  hipJoint,
const std::array< Vec3, 2 > &  knee,
const std::array< Vec3, 2 > &  ankle,
const std::array< float, 2 > &  heel,
const std::array< bool, 2 > &  planted,
Vec3  bodySide,
float  scale,
float  bulk,
float  objectDepth,
PlayerLod  lod,
const KitColors &  kit,
const PlayerLook &  look,
ImU32  skin 
)

◆ drawPlayerLegs()

template<class RendererState >
void drawPlayerLegs ( RendererState &  state,
const AnimationSlot &  slot,
const std::array< Vec3, 2 > &  hipJoint,
const std::array< Vec3, 2 > &  knee,
const std::array< Vec3, 2 > &  ankle,
const std::array< float, 2 > &  heel,
const std::array< bool, 2 > &  planted,
Vec3  bodySide,
float  scale,
float  bulk,
float  objectDepth,
PlayerLod  lod,
const KitColors &  kit,
const PlayerLook &  look,
ImU32  skin 
)

◆ drawPlayerMarker()

template<class RendererState >
void drawPlayerMarker ( RendererState &  state,
const MatchRenderPlayer &  player,
Vec3  root,
float  pixelHeight 
)

◆ drawPlayerShadow()

template<class RendererState >
void drawPlayerShadow ( RendererState &  state,
const MatchRenderPlayer &  player,
Vec3  root,
float  pixelHeight,
float  standing,
Vec3  sunAway,
float  sunLength,
std::span< const Vec3 >  lights 
)

◆ drawPlayerTorso()

template<class RendererState >
PlayerTorsoFrame drawPlayerTorso ( RendererState &  state,
const AnimationSlot &  slot,
const Pose &  pose,
Vec3  pelvis,
Vec3  bodyUp,
Vec3  bodySide,
Vec3  forward,
float  scale,
float  bulk,
float  objectDepth,
PlayerLod  lod,
bool  detailed,
std::size_t  kitIndex,
const KitColors &  kit 
)

◆ drawPossessionRing()

template<class RendererState >
void drawPossessionRing ( RendererState &  state,
Vec3  root 
)

◆ drawSortedLayers()

template<class RendererState >
void drawSortedLayers ( RendererState &  state,
const MatchRenderSnapshot &  snapshot,
const MatchRenderOptions &  options,
float  alpha 
)

◆ drawStadiumFace()

template<class RendererState >
void drawStadiumFace ( RendererState &  state,
const Stadium3D::Face &  face 
)

◆ drawWorldLayers()

template<class RendererState >
void drawWorldLayers ( RendererState &  state,
const MatchRenderSnapshot &  snapshot,
const MatchRenderOptions &  options,
float  alpha 
)

◆ fitPelvisToPlantedFeet()

float fitPelvisToPlantedFeet ( float  pelvisHeight,
const AnimationSlot &  slot,
Vec3  root,
Vec3  flatSide,
Vec3  forward,
float  scale,
float  poseLift 
)

◆ initializeAnimationSlot()

template<class RendererState >
void initializeAnimationSlot ( RendererState &  state,
const MatchRenderPlayer &  player,
AnimationSlot &  slot,
Vec3  root,
float  yaw 
)

◆ jumpTargetFor()

template<class RendererState >
float jumpTargetFor ( const RendererState &  state,
const MatchRenderPlayer &  player,
Vec3  root,
float  scale 
)

◆ poseForCelebration()

Pose poseForCelebration ( Pose  pose,
GoalMood  mood,
bool  reducedMotion,
float  elapsedSeconds,
std::uint32_t  seed,
float  stride,
float  celebrationWeight 
)

◆ poseForKeeper()

Pose poseForKeeper ( Pose  pose,
bool  keeper,
float  setBlend,
float  diveBlend,
float  diveSide,
float  stride 
)

◆ poseForTimedEvent()

Pose poseForTimedEvent ( Pose  pose,
PlayerRig::Event  event,
float  eventTime,
float  eventWeight,
std::size_t  eventLeg 
)

◆ setCelebrationFocus()

void setCelebrationFocus ( MatchCameraFocus &  focus,
std::span< const MatchRenderPlayer >  players,
std::uint32_t  scorer,
float  alpha 
)

◆ solvePlayerLegJoints()

void solvePlayerLegJoints ( const AnimationSlot &  slot,
const std::array< Vec3, 2 > &  hipJoint,
const std::array< Vec3, 2 > &  ankleTarget,
const std::array< bool, 2 > &  planted,
Vec3  forward,
Vec3  bodyUp,
float  scale,
std::array< Vec3, 2 > &  knee,
std::array< Vec3, 2 > &  ankle,
std::array< float, 2 > &  heel 
)

◆ updateBallRotation()

template<class RendererState >
void updateBallRotation ( RendererState &  state,
Vec3  world,
Vec3  moved,
float  distance,
const ScreenPoint &  screen 
)

◆ updateFootPlanting()

void updateFootPlanting ( AnimationSlot &  slot,
Vec3  root,
float  yaw,
float  scale,
float  cycleMetres,
float  groundSpeed,
float  simSeconds 
)

◆ updateKeeperPose()

template<class RendererState >
void updateKeeperPose ( RendererState &  state,
const MatchRenderPlayer &  player,
AnimationSlot &  slot,
Vec3  root,
float  yaw,
float  blend 
)

◆ updateMatchSimulation()

template<class RendererState >
void updateMatchSimulation ( RendererState &  state,
const MatchRenderSnapshot &  snapshot,
float  deltaSeconds,
float  alpha 
)

◆ updateMotionRates()

void updateMotionRates ( AnimationSlot &  slot,
float  groundSpeed,
float  yaw,
float  simSeconds 
)

◆ updateRenderCamera()

template<class RendererState >
void updateRenderCamera ( RendererState &  state,
const MatchRenderSnapshot &  snapshot,
const MatchRenderOptions &  options,
const MatchViewport &  viewport,
float  deltaSeconds,
float  alpha 
)