mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
physics: implement player-controlled flying mount physics
When CAN_FLY + FLYING movement flags are both set (flying mounts, Druid Flight Form), the CameraController now uses 3D pitch-following movement instead of ground physics: - Forward/back follows the camera's 3D look direction (ascend when looking up, descend when looking down) - Space = ascend vertically, X (while mounted) = descend - No gravity, no grounding, no jump coyote time - Fall-damage checks suppressed (grounded=true) Also wire up all remaining server movement state flags to CameraController: - Feather Fall: cap terminal velocity at -2 m/s - Water Walk: clamp to water surface, skip swim entry - Flying: 3D movement with no gravity All states synced each frame from GameHandler via isPlayerFlying(), isFeatherFalling(), isWaterWalking(), isGravityDisabled().
This commit is contained in:
parent
1853e8aa56
commit
27d18b2189
4 changed files with 39 additions and 1 deletions
|
|
@ -1166,6 +1166,11 @@ public:
|
||||||
bool isWaterWalking() const {
|
bool isWaterWalking() const {
|
||||||
return (movementInfo.flags & static_cast<uint32_t>(MovementFlags::WATER_WALK)) != 0;
|
return (movementInfo.flags & static_cast<uint32_t>(MovementFlags::WATER_WALK)) != 0;
|
||||||
}
|
}
|
||||||
|
bool isPlayerFlying() const {
|
||||||
|
const uint32_t flyMask = static_cast<uint32_t>(MovementFlags::CAN_FLY) |
|
||||||
|
static_cast<uint32_t>(MovementFlags::FLYING);
|
||||||
|
return (movementInfo.flags & flyMask) == flyMask;
|
||||||
|
}
|
||||||
void dismount();
|
void dismount();
|
||||||
|
|
||||||
// Taxi / Flight Paths
|
// Taxi / Flight Paths
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,7 @@ public:
|
||||||
void setGravityDisabled(bool disabled) { gravityDisabled_ = disabled; }
|
void setGravityDisabled(bool disabled) { gravityDisabled_ = disabled; }
|
||||||
void setFeatherFallActive(bool active) { featherFallActive_ = active; }
|
void setFeatherFallActive(bool active) { featherFallActive_ = active; }
|
||||||
void setWaterWalkActive(bool active) { waterWalkActive_ = active; }
|
void setWaterWalkActive(bool active) { waterWalkActive_ = active; }
|
||||||
|
void setFlyingActive(bool active) { flyingActive_ = active; }
|
||||||
void setMounted(bool m) { mounted_ = m; }
|
void setMounted(bool m) { mounted_ = m; }
|
||||||
void setMountHeightOffset(float offset) { mountHeightOffset_ = offset; }
|
void setMountHeightOffset(float offset) { mountHeightOffset_ = offset; }
|
||||||
void setExternalFollow(bool enabled) { externalFollow_ = enabled; }
|
void setExternalFollow(bool enabled) { externalFollow_ = enabled; }
|
||||||
|
|
@ -285,6 +286,8 @@ private:
|
||||||
bool featherFallActive_ = false;
|
bool featherFallActive_ = false;
|
||||||
// Server-driven water walk: treat water surface as ground (don't swim).
|
// Server-driven water walk: treat water surface as ground (don't swim).
|
||||||
bool waterWalkActive_ = false;
|
bool waterWalkActive_ = false;
|
||||||
|
// Player-controlled flight (CAN_FLY + FLYING): 3D movement, no gravity.
|
||||||
|
bool flyingActive_ = false;
|
||||||
bool mounted_ = false;
|
bool mounted_ = false;
|
||||||
float mountHeightOffset_ = 0.0f;
|
float mountHeightOffset_ = 0.0f;
|
||||||
bool externalMoving_ = false;
|
bool externalMoving_ = false;
|
||||||
|
|
|
||||||
|
|
@ -1015,6 +1015,7 @@ void Application::update(float deltaTime) {
|
||||||
renderer->getCameraController()->setGravityDisabled(gameHandler->isGravityDisabled());
|
renderer->getCameraController()->setGravityDisabled(gameHandler->isGravityDisabled());
|
||||||
renderer->getCameraController()->setFeatherFallActive(gameHandler->isFeatherFalling());
|
renderer->getCameraController()->setFeatherFallActive(gameHandler->isFeatherFalling());
|
||||||
renderer->getCameraController()->setWaterWalkActive(gameHandler->isWaterWalking());
|
renderer->getCameraController()->setWaterWalkActive(gameHandler->isWaterWalking());
|
||||||
|
renderer->getCameraController()->setFlyingActive(gameHandler->isPlayerFlying());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onTaxi = gameHandler &&
|
bool onTaxi = gameHandler &&
|
||||||
|
|
|
||||||
|
|
@ -692,6 +692,34 @@ void CameraController::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
swimming = false;
|
swimming = false;
|
||||||
|
|
||||||
|
// Player-controlled flight (flying mount / druid Flight Form):
|
||||||
|
// Use 3D pitch-following movement with no gravity or grounding.
|
||||||
|
if (flyingActive_) {
|
||||||
|
grounded = true; // suppress fall-damage checks
|
||||||
|
verticalVelocity = 0.0f;
|
||||||
|
jumpBufferTimer = 0.0f;
|
||||||
|
coyoteTimer = 0.0f;
|
||||||
|
|
||||||
|
// Forward/back follows camera 3D direction (same as swim)
|
||||||
|
glm::vec3 flyFwd = glm::normalize(forward3D);
|
||||||
|
if (glm::length(flyFwd) < 1e-4f) flyFwd = forward;
|
||||||
|
glm::vec3 flyMove(0.0f);
|
||||||
|
if (nowForward) flyMove += flyFwd;
|
||||||
|
if (nowBackward) flyMove -= flyFwd;
|
||||||
|
if (nowStrafeLeft) flyMove += right;
|
||||||
|
if (nowStrafeRight) flyMove -= right;
|
||||||
|
// Space = ascend, X = descend while airborne
|
||||||
|
bool flyDescend = !uiWantsKeyboard && xDown && mounted_;
|
||||||
|
if (nowJump) flyMove.z += 1.0f;
|
||||||
|
if (flyDescend) flyMove.z -= 1.0f;
|
||||||
|
if (glm::length(flyMove) > 0.001f) {
|
||||||
|
flyMove = glm::normalize(flyMove);
|
||||||
|
targetPos += flyMove * speed * physicsDeltaTime;
|
||||||
|
}
|
||||||
|
targetPos.z += verticalVelocity * physicsDeltaTime;
|
||||||
|
// Skip all ground physics — go straight to collision/WMO sections
|
||||||
|
} else {
|
||||||
|
|
||||||
if (glm::length(movement) > 0.001f) {
|
if (glm::length(movement) > 0.001f) {
|
||||||
movement = glm::normalize(movement);
|
movement = glm::normalize(movement);
|
||||||
targetPos += movement * speed * physicsDeltaTime;
|
targetPos += movement * speed * physicsDeltaTime;
|
||||||
|
|
@ -738,7 +766,8 @@ void CameraController::update(float deltaTime) {
|
||||||
verticalVelocity = -2.0f;
|
verticalVelocity = -2.0f;
|
||||||
}
|
}
|
||||||
targetPos.z += verticalVelocity * physicsDeltaTime;
|
targetPos.z += verticalVelocity * physicsDeltaTime;
|
||||||
}
|
} // end !flyingActive_ ground physics
|
||||||
|
} // end !inWater
|
||||||
} else {
|
} else {
|
||||||
// External follow (e.g., taxi): trust server position without grounding.
|
// External follow (e.g., taxi): trust server position without grounding.
|
||||||
swimming = false;
|
swimming = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue