GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — rcssserver/src/leg.cpp at master · CLSFramework/rcssserver Expand file tree/ Copy pathleg.cppMore file actions 181 lines (148 loc) · 4.41 KB / Copy pathleg.cppFile metadata and controls181 lines (148 loc) · 4.41 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 // -*-c++-*- /*************************************************************************** leg.cpp ------------------- begin : 23-OCT-2023 copyright : (C) 2023 by The RoboCup Soccer Simulator Maintenance Group. ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU LGPL as published by the Free Software * * Foundation; either version 3 of the License, or (at your option) any * * later version. * * * ***************************************************************************/ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include "leg.h" #include "player.h" #include "heteroplayer.h" #include "serverparam.h" #include "playerparam.h" #include <algorithm> #include <cmath> namespace { double normalize_dash_power( const double p ) { return std::clamp( p, ServerParam::instance().minDashPower(), ServerParam::instance().maxDashPower() ); } double normalize_dash_angle( const double d ) { double dir = std::clamp( d, ServerParam::instance().minDashAngle(), ServerParam::instance().maxDashAngle() ); if ( ServerParam::instance().dashAngleStep() < EPS ) { // players can dash any direction. } else { // The dash direction is discretized by server::dash_angle_step dir = ServerParam::instance().dashAngleStep() * rint( dir / ServerParam::instance().dashAngleStep() ); } return dir; } } Leg::Leg( const Player & player ) : M_player( player ), M_command_type( NONE ), M_kick_power( 0.0 ), M_kick_dir( 0.0 ), M_dash_power( 0.0 ), M_dash_dir( 0.0 ) { } void Leg::resetCommand() { M_command_type = NONE; M_kick_power = 0.0; M_kick_dir = 0.0; M_dash_power = 0.0; M_dash_dir = 0.0; } void Leg::move() { if ( commandDone() ) { return; } M_command_type = MOVE; } void Leg::kick( const double power, const double dir ) { if ( commandDone() ) { return; } M_kick_power = power; M_kick_dir = dir; M_command_type = KICK; } void Leg::turn() { if ( commandDone() ) { return; } M_command_type = TURN; } void Leg::dash( const double power, const double dir ) { if ( commandDone() ) { return; } M_dash_power = normalize_dash_power( power ); M_dash_dir = normalize_dash_angle( dir ); M_command_type = DASH; } void Leg::tackle() { if ( commandDone() ) { return; } M_command_type = TACKLE; } PVector Leg::calcDashAccel( const double consumed_stamina ) const { const ServerParam & param = ServerParam::instance(); const double power = normalize_dash_power( dashPower() < 0.0 ? -consumed_stamina : consumed_stamina * 2.0 ); const double dir_rate = std::clamp( std::fabs( dashDir() ) > 90.0 ? param.backDashRate() - ( ( param.backDashRate() - param.sideDashRate() ) * ( 1.0 - ( std::fabs( dashDir() ) - 90.0 ) / 90.0 ) ) : param.sideDashRate() + ( ( 1.0 - param.sideDashRate() ) * ( 1.0 - std::fabs( dashDir() ) / 90.0 ) ), 0.0, 1.0 ); double accel_magnitude = std::fabs( M_player.effort() * power * dir_rate * M_player.playerType()->dashPowerRate() ); if ( M_player.pos().y < 0.0 ) { accel_magnitude /= ( M_player.side() == LEFT ? param.slownessOnTopForLeft() : param.slownessOnTopForRight() ); } PVector accel = PVector::fromPolar( accel_magnitude, normalize_angle( M_player.angleBodyCommitted() + Deg2Rad( dashDir() ) ) ); if ( power < 0.0 ) { accel = -accel; } return accel; } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |