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:
@@ -0,0 +1,6 @@
|
|||||||
|
-- Add parent rotation columns to gameobject_addon table for transport rotation support
|
||||||
|
ALTER TABLE `gameobject_addon`
|
||||||
|
ADD COLUMN `parent_rotation0` FLOAT NOT NULL DEFAULT 0 AFTER `guid`,
|
||||||
|
ADD COLUMN `parent_rotation1` FLOAT NOT NULL DEFAULT 0 AFTER `parent_rotation0`,
|
||||||
|
ADD COLUMN `parent_rotation2` FLOAT NOT NULL DEFAULT 0 AFTER `parent_rotation1`,
|
||||||
|
ADD COLUMN `parent_rotation3` FLOAT NOT NULL DEFAULT 1 AFTER `parent_rotation2`;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- DB/Gameobject: Update "Dangerous!" sign with sniffed values
|
||||||
|
-- Closes https://github.com/azerothcore/azerothcore-wotlk/issues/16834
|
||||||
|
DELETE FROM `gameobject` WHERE `guid` = 17154 AND `id` = 2008;
|
||||||
|
INSERT INTO `gameobject` (`guid`, `id`, `map`, `zoneId`, `areaId`, `spawnMask`, `phaseMask`, `position_x`, `position_y`, `position_z`, `orientation`, `rotation0`, `rotation1`, `rotation2`, `rotation3`, `spawntimesecs`, `animprogress`, `state`, `VerifiedBuild`) VALUES
|
||||||
|
(17154, 2008, 0, 267, 272, 1, 1, -19.4826393127441406, -935.3038330078125, 58.09708786010742187, 2.65289926528930664, -0.04655265808105468, 0.011606216430664062, 0.969178199768066406, 0.241643846035003662, 120, 255, 1, 42328);
|
||||||
@@ -38,6 +38,11 @@
|
|||||||
#include <G3D/CoordinateFrame.h>
|
#include <G3D/CoordinateFrame.h>
|
||||||
#include <G3D/Quat.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(),
|
GameObject::GameObject() : WorldObject(), MovableMapObject(),
|
||||||
m_model(nullptr), m_goValue(), m_AI(nullptr)
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameObjectAddon const* addon = sObjectMgr->GetGameObjectAddon(GetSpawnId());
|
SetLocalRotation(rotation);
|
||||||
|
|
||||||
// hackfix for the hackfix down below
|
GameObjectAddon const* gameObjectAddon = sObjectMgr->GetGameObjectAddon(GetSpawnId());
|
||||||
switch (goinfo->entry)
|
QuaternionData parentRotation;
|
||||||
{
|
if (gameObjectAddon)
|
||||||
// excluded ids from the hackfix below
|
parentRotation = gameObjectAddon->ParentRotation;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// pussywizard: no PathRotation for normal gameobjects
|
SetTransportPathRotation(parentRotation.x, parentRotation.y, parentRotation.z, parentRotation.w);
|
||||||
SetTransportPathRotation(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
|
|
||||||
SetObjectScale(goinfo->size);
|
SetObjectScale(goinfo->size);
|
||||||
|
|
||||||
@@ -403,12 +387,12 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addon)
|
if (gameObjectAddon)
|
||||||
{
|
{
|
||||||
if (addon->InvisibilityValue)
|
if (gameObjectAddon->InvisibilityValue)
|
||||||
{
|
{
|
||||||
m_invisibility.AddFlag(addon->invisibilityType);
|
m_invisibility.AddFlag(gameObjectAddon->invisibilityType);
|
||||||
m_invisibility.AddValue(addon->invisibilityType, addon->InvisibilityValue);
|
m_invisibility.AddValue(gameObjectAddon->invisibilityType, gameObjectAddon->InvisibilityValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -678,9 +678,23 @@ struct GameObjectLocale
|
|||||||
std::vector<std::string> CastBarCaption;
|
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
|
// `gameobject_addon` table
|
||||||
struct GameObjectAddon
|
struct GameObjectAddon
|
||||||
{
|
{
|
||||||
|
QuaternionData ParentRotation;
|
||||||
InvisibilityType invisibilityType;
|
InvisibilityType invisibilityType;
|
||||||
uint32 InvisibilityValue;
|
uint32 InvisibilityValue;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1355,8 +1355,8 @@ void ObjectMgr::LoadGameObjectAddons()
|
|||||||
{
|
{
|
||||||
uint32 oldMSTime = getMSTime();
|
uint32 oldMSTime = getMSTime();
|
||||||
|
|
||||||
// 0 1 2
|
// 0 1 2 3 4 5 6
|
||||||
QueryResult result = WorldDatabase.Query("SELECT guid, invisibilityType, invisibilityValue FROM gameobject_addon");
|
QueryResult result = WorldDatabase.Query("SELECT guid, parent_rotation0, parent_rotation1, parent_rotation2, parent_rotation3, invisibilityType, invisibilityValue FROM gameobject_addon");
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
@@ -1380,8 +1380,9 @@ void ObjectMgr::LoadGameObjectAddons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
|
GameObjectAddon& gameObjectAddon = _gameObjectAddonStore[guid];
|
||||||
gameObjectAddon.invisibilityType = InvisibilityType(fields[1].Get<uint8>());
|
gameObjectAddon.ParentRotation = QuaternionData(fields[1].Get<float>(), fields[2].Get<float>(), fields[3].Get<float>(), fields[4].Get<float>());
|
||||||
gameObjectAddon.InvisibilityValue = fields[2].Get<uint32>();
|
gameObjectAddon.invisibilityType = InvisibilityType(fields[5].Get<uint8>());
|
||||||
|
gameObjectAddon.InvisibilityValue = fields[6].Get<uint32>();
|
||||||
|
|
||||||
if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
|
if (gameObjectAddon.invisibilityType >= TOTAL_INVISIBILITY_TYPES)
|
||||||
{
|
{
|
||||||
@@ -1396,6 +1397,12 @@ void ObjectMgr::LoadGameObjectAddons()
|
|||||||
gameObjectAddon.InvisibilityValue = 1;
|
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;
|
++count;
|
||||||
} while (result->NextRow());
|
} while (result->NextRow());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user