mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-10 03:00:28 +00:00
fix(Core/GameObject): Use quaternion rotation directly instead of orientation hackfix (#24602)
Co-authored-by: blinkysc <blinkysc@users.noreply.github.com> Co-authored-by: zergtmn <zerg@myisp.com>
This commit is contained in:
@@ -38,6 +38,11 @@
|
||||
#include <G3D/CoordinateFrame.h>
|
||||
#include <G3D/Quat.h>
|
||||
|
||||
bool QuaternionData::IsUnit() const
|
||||
{
|
||||
return fabs(x * x + y * y + z * z + w * w - 1.0f) < 1e-5f;
|
||||
}
|
||||
|
||||
GameObject::GameObject() : WorldObject(), MovableMapObject(),
|
||||
m_model(nullptr), m_goValue(), m_AI(nullptr)
|
||||
{
|
||||
@@ -293,35 +298,14 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(GetSpawnId());
|
||||
SetLocalRotation(rotation);
|
||||
|
||||
// hackfix for the hackfix down below
|
||||
switch (goinfo->entry)
|
||||
{
|
||||
// excluded ids from the hackfix below
|
||||
// used switch since there should be more
|
||||
case 181233: // maexxna portal effect
|
||||
case 181575: // maexxna portal
|
||||
case 20992: // theramore black shield
|
||||
case 21042: // theramore guard badge
|
||||
SetLocalRotation(rotation);
|
||||
break;
|
||||
default:
|
||||
// xinef: hackfix - but make it possible to use original WorldRotation (using special gameobject addon data)
|
||||
// pussywizard: temporarily calculate WorldRotation from orientation, do so until values in db are correct
|
||||
if (addon && addon->invisibilityType == INVISIBILITY_GENERAL && addon->InvisibilityValue == 0)
|
||||
{
|
||||
SetLocalRotation(rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLocalRotationAngles(NormalizeOrientation(GetOrientation()), 0.0f, 0.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
GameObjectAddon const* gameObjectAddon = sObjectMgr->GetGameObjectAddon(GetSpawnId());
|
||||
QuaternionData parentRotation;
|
||||
if (gameObjectAddon)
|
||||
parentRotation = gameObjectAddon->ParentRotation;
|
||||
|
||||
// pussywizard: no PathRotation for normal gameobjects
|
||||
SetTransportPathRotation(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
SetTransportPathRotation(parentRotation.x, parentRotation.y, parentRotation.z, parentRotation.w);
|
||||
|
||||
SetObjectScale(goinfo->size);
|
||||
|
||||
@@ -403,12 +387,12 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
|
||||
break;
|
||||
}
|
||||
|
||||
if (addon)
|
||||
if (gameObjectAddon)
|
||||
{
|
||||
if (addon->InvisibilityValue)
|
||||
if (gameObjectAddon->InvisibilityValue)
|
||||
{
|
||||
m_invisibility.AddFlag(addon->invisibilityType);
|
||||
m_invisibility.AddValue(addon->invisibilityType, addon->InvisibilityValue);
|
||||
m_invisibility.AddFlag(gameObjectAddon->invisibilityType);
|
||||
m_invisibility.AddValue(gameObjectAddon->invisibilityType, gameObjectAddon->InvisibilityValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -678,9 +678,23 @@ struct GameObjectLocale
|
||||
std::vector<std::string> CastBarCaption;
|
||||
};
|
||||
|
||||
struct AC_GAME_API QuaternionData
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float w;
|
||||
|
||||
QuaternionData() : x(0.0f), y(0.0f), z(0.0f), w(1.0f) { }
|
||||
QuaternionData(float X, float Y, float Z, float W) : x(X), y(Y), z(Z), w(W) { }
|
||||
|
||||
[[nodiscard]] bool IsUnit() const;
|
||||
};
|
||||
|
||||
// `gameobject_addon` table
|
||||
struct GameObjectAddon
|
||||
{
|
||||
QuaternionData ParentRotation;
|
||||
InvisibilityType invisibilityType;
|
||||
uint32 InvisibilityValue;
|
||||
};
|
||||
|
||||
@@ -1355,8 +1355,8 @@ void ObjectMgr::LoadGameObjectAddons()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// 0 1 2
|
||||
QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon");
|
||||
// 0 1 2 3 4 5 6
|
||||
QueryResult result = WorldDatabase.Query("SELECT guid, parent_rotation0, parent_rotation1, parent_rotation2, parent_rotation3, invisibilityType, invisibilityValue FROM gameobject_addon");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -1380,8 +1380,9 @@ void ObjectMgr::LoadGameObjectAddons()
|
||||
}
|
||||
|
||||
GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
|
||||
gameObjectAddon.invisibilityType = InvisibilityType(fields[1].Get<uint8>());
|
||||
gameObjectAddon.InvisibilityValue = fields[2].Get<uint32>();
|
||||
gameObjectAddon.ParentRotation = QuaternionData(fields[1].Get<float>(), fields[2].Get<float>(), fields[3].Get<float>(), fields[4].Get<float>());
|
||||
gameObjectAddon.invisibilityType = InvisibilityType(fields[5].Get<uint8>());
|
||||
gameObjectAddon.InvisibilityValue = fields[6].Get<uint32>();
|
||||
|
||||
if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
|
||||
{
|
||||
@@ -1396,6 +1397,12 @@ void ObjectMgr::LoadGameObjectAddons()
|
||||
gameObjectAddon.InvisibilityValue = 1;
|
||||
}
|
||||
|
||||
if (!gameObjectAddon.ParentRotation.IsUnit())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "GameObject (GUID: {}) has invalid parent rotation in `gameobject_addon`, set to default", guid);
|
||||
gameObjectAddon.ParentRotation = QuaternionData();
|
||||
}
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user