68 const Vector3& muzzle_velocity_mps,
94 if (planar_speed > 1e-9) {
132 const std::string&
typeName()
const {
return type_name_; }
138 if (type_name_.empty())
return true;
139 std::string lower = type_name_;
140 std::transform(lower.begin(), lower.end(), lower.begin(), [](
unsigned char c){ return std::tolower(c); });
141 if (lower.find(
"ball") != std::string::npos)
return true;
142 if (lower.find(
"sphere") != std::string::npos)
return true;
143 if (lower.rfind(
"generic_", 0) == 0)
return true;
149 std::string type_name_{};
BallPhysicsSim3D()=default
const BallState & state() const
Returns current ball state.
Definition ball_physics.hpp:114
void setState(const BallState &state)
Replaces state and sanitizes non-finite values.
Definition ball_physics.hpp:117
void shoot(const Vector3 &muzzle_position_m, const Vector3 &muzzle_velocity_mps, const Vector3 &muzzle_spin_radps=Vector3::zero())
Places the ball at a muzzle pose and sets launch velocity/spin.
Definition ball_physics.hpp:168
bool requestPickup(const PickupRequest &pickup_request)
Attempts to pick up and hold the ball.
Definition ball_physics.hpp:138
const BallProperties & ballProperties() const
Returns active, sanitized ball properties.
Definition ball_physics.hpp:105
void step(double dt_s)
Advances simulation by dt seconds.
Definition ball_physics.hpp:182
const Config & config() const
Returns active, sanitized configuration.
Definition ball_physics.hpp:98
BallPhysicsSim3D()=default
State getGamepieceState() const
Definition gamepiece.hpp:36
void outtake(const Vector3 &muzzle_position_m, const Vector3 &muzzle_velocity_mps, const Vector3 &muzzle_spin_radps=Vector3::zero())
Outtake (launch) the gamepiece into free flight and mark as airborne.
Definition gamepiece.hpp:67
Gamepiece(const BallPhysicsSim3D::Config &cfg, const BallPhysicsSim3D::BallProperties &props)
Definition gamepiece.hpp:31
BallPhysicsSim3D::Config Config
Definition gamepiece.hpp:23
BallPhysicsSim3D::BallProperties Properties
Definition gamepiece.hpp:24
bool isBall() const
Definition gamepiece.hpp:137
void setTypeName(const std::string &name)
Definition gamepiece.hpp:127
bool pick(const PickupRequest &req)
Attempt to pick up the gamepiece into a carrier. Delegates to BallPhysicsSim3D::requestPickup and fli...
Definition gamepiece.hpp:43
void step(double dt_s)
Step wrapper that applies low-cost behavior for grounded/held.
Definition gamepiece.hpp:78
State
Definition gamepiece.hpp:28
@ kAirborne
Definition gamepiece.hpp:28
@ kGrounded
Definition gamepiece.hpp:28
@ kHeld
Definition gamepiece.hpp:28
void place(const Vector3 &pos)
Place the gamepiece at world position and mark as grounded.
Definition gamepiece.hpp:54
const std::string & typeName() const
Definition gamepiece.hpp:132
void setGamepieceState(State s)
Definition gamepiece.hpp:35
Physical parameters for the ball body.
Definition ball_physics.hpp:49
double radius_m
Definition ball_physics.hpp:53
Dynamic state advanced by step().
Definition ball_physics.hpp:66
bool held
Definition ball_physics.hpp:74
Vector3 velocity_mps
Definition ball_physics.hpp:70
Vector3 position_m
Definition ball_physics.hpp:68
Vector3 spin_radps
Definition ball_physics.hpp:72
Runtime physics environment parameters.
Definition ball_physics.hpp:25
double ground_height_m
Definition ball_physics.hpp:39
Request payload used to capture a ball into a carrier.
Definition ball_physics.hpp:78
3D vector utility used throughout JSim physics.
Definition vector.hpp:22
double z
Z component.
Definition vector.hpp:28
double planarSpeed() const noexcept
Returns magnitude of the XY projection.
Definition vector.hpp:177
static constexpr Vector3 zero() noexcept
Returns the zero vector.
Definition vector.hpp:360
double x
X component.
Definition vector.hpp:24
double y
Y component.
Definition vector.hpp:26