fix(Core/Cinematics): Cinematic camera improvements (#25097)

This commit is contained in:
Takenbacon
2026-03-20 18:04:52 -07:00
committed by GitHub
parent 67918db7a0
commit 1d7c5e4b71
20 changed files with 164 additions and 131 deletions

View File

@@ -1703,7 +1703,7 @@ void GameObject::Use(Unit* user)
Player* player = user->ToPlayer();
if (info->camera.cinematicId)
player->SendCinematicStart(info->camera.cinematicId);
player->GetCinematicMgr().StartCinematic(info->camera.cinematicId);
if (info->camera.eventID)
{
@@ -2142,7 +2142,32 @@ void GameObject::SendCustomAnim(uint32 anim)
SendMessageToSet(&data, true);
}
bool GameObject::IsInRange(float x, float y, float z, float radius) const
bool GameObject::IsInRange2d(float x, float y, float radius) const
{
GameObjectDisplayInfoEntry const* info = sGameObjectDisplayInfoStore.LookupEntry(m_goInfo->displayId);
if (!info)
return IsWithinDist2d(x, y, radius);
float sinA = std::sin(GetOrientation());
float cosA = cos(GetOrientation());
float dx = x - GetPositionX();
float dy = y - GetPositionY();
float dist = std::sqrt(dx * dx + dy * dy);
//! Check if the distance between the 2 objects is 0, can happen if both objects are on the same position.
//! The code below this check wont crash if dist is 0 because 0/0 in float operations is valid, and returns infinite
if (G3D::fuzzyEq(dist, 0.0f))
return true;
float scale = GetObjectScale();
float sinB = dx / dist;
float cosB = dy / dist;
dx = dist * (cosA * cosB + sinA * sinB);
dy = dist * (cosA * sinB - sinA * cosB);
return dx < (info->maxX * scale) + radius && dx >(info->minX * scale) - radius
&& dy < (info->maxY * scale) + radius && dy >(info->minY * scale) - radius;
}
bool GameObject::IsInRange3d(float x, float y, float z, float radius) const
{
GameObjectDisplayInfoEntry const* info = sGameObjectDisplayInfoStore.LookupEntry(m_goInfo->displayId);
if (!info)
@@ -2217,6 +2242,11 @@ void GameObject::UpdatePackedRotation()
m_packedRotation = z | (y << 21) | (x << 42);
}
bool GameObject::IsWithinSightRange(Position const& pos, float dist) const
{
return IsInRange2d(pos.GetPositionX(), pos.GetPositionY(), dist);
}
void GameObject::SetWorldRotation(G3D::Quat const& rot)
{
G3D::Quat rotation = rot;

View File

@@ -284,7 +284,8 @@ public:
void CastSpell(Unit* target, uint32 spell);
void SendCustomAnim(uint32 anim);
[[nodiscard]] bool IsInRange(float x, float y, float z, float radius) const;
bool IsInRange2d(float x, float y, float radius) const;
bool IsInRange3d(float x, float y, float z, float radius) const;
void ModifyHealth(int32 change, Unit* attackerOrHealer = nullptr, uint32 spellId = 0);
void SetDestructibleBuildingModifyState(bool allow) { m_allowModifyDestructibleBuilding = allow; }
@@ -418,8 +419,11 @@ private:
{
//! Following check does check 3d distance
dist2compare += obj->GetObjectSize();
return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
return IsInRange3d(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
}
bool IsWithinSightRange(Position const& pos, float dist) const override;
GameObjectAI* m_AI;
bool m_saveStateOnDb = false;