mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Fix mounted first-person camera pivot
This commit is contained in:
parent
0ebf4d1e5e
commit
5eebd805ba
3 changed files with 14 additions and 4 deletions
|
|
@ -74,6 +74,7 @@ public:
|
|||
void setUseWoWSpeed(bool use) { useWoWSpeed = use; }
|
||||
void setRunSpeedOverride(float speed) { runSpeedOverride_ = speed; }
|
||||
void setMounted(bool m) { mounted_ = m; }
|
||||
void setMountHeightOffset(float offset) { mountHeightOffset_ = offset; }
|
||||
|
||||
// For first-person player hiding
|
||||
void setCharacterRenderer(class CharacterRenderer* cr, uint32_t playerId) {
|
||||
|
|
@ -193,6 +194,7 @@ private:
|
|||
// Server-driven run speed override (0 = use default WOW_RUN_SPEED)
|
||||
float runSpeedOverride_ = 0.0f;
|
||||
bool mounted_ = false;
|
||||
float mountHeightOffset_ = 0.0f;
|
||||
|
||||
// Online mode: trust server position, don't prefer outdoors over WMO floors
|
||||
bool onlineMode = false;
|
||||
|
|
|
|||
|
|
@ -643,7 +643,8 @@ void CameraController::update(float deltaTime) {
|
|||
|
||||
// ===== WoW-style orbit camera =====
|
||||
// Pivot point at upper chest/neck
|
||||
glm::vec3 pivot = targetPos + glm::vec3(0.0f, 0.0f, PIVOT_HEIGHT);
|
||||
float mountedOffset = mounted_ ? mountHeightOffset_ : 0.0f;
|
||||
glm::vec3 pivot = targetPos + glm::vec3(0.0f, 0.0f, PIVOT_HEIGHT + mountedOffset);
|
||||
|
||||
// Camera direction from yaw/pitch (already computed as forward3D)
|
||||
glm::vec3 camDir = -forward3D; // Camera looks at pivot, so it's behind
|
||||
|
|
@ -1219,7 +1220,8 @@ void CameraController::reset() {
|
|||
currentDistance = userTargetDistance;
|
||||
collisionDistance = currentDistance;
|
||||
|
||||
glm::vec3 pivot = spawnPos + glm::vec3(0.0f, 0.0f, PIVOT_HEIGHT);
|
||||
float mountedOffset = mounted_ ? mountHeightOffset_ : 0.0f;
|
||||
glm::vec3 pivot = spawnPos + glm::vec3(0.0f, 0.0f, PIVOT_HEIGHT + mountedOffset);
|
||||
glm::vec3 camDir = -forward3D;
|
||||
glm::vec3 camPos = pivot + camDir * currentDistance;
|
||||
smoothedCamPos = camPos;
|
||||
|
|
|
|||
|
|
@ -499,14 +499,20 @@ void Renderer::setMounted(uint32_t mountInstId, float heightOffset) {
|
|||
mountInstanceId_ = mountInstId;
|
||||
mountHeightOffset_ = heightOffset;
|
||||
charAnimState = CharAnimState::MOUNT;
|
||||
if (cameraController) cameraController->setMounted(true);
|
||||
if (cameraController) {
|
||||
cameraController->setMounted(true);
|
||||
cameraController->setMountHeightOffset(heightOffset);
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::clearMount() {
|
||||
mountInstanceId_ = 0;
|
||||
mountHeightOffset_ = 0.0f;
|
||||
charAnimState = CharAnimState::IDLE;
|
||||
if (cameraController) cameraController->setMounted(false);
|
||||
if (cameraController) {
|
||||
cameraController->setMounted(false);
|
||||
cameraController->setMountHeightOffset(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t Renderer::resolveMeleeAnimId() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue