fix(Core/GameObject): Handle zero quaternion rotation for dynamically spawned gameobjects (#24662)
Co-authored-by: blinkysc <blinkysc@users.noreply.github.com> Co-authored-by: zergtmn <zergtmn@users.noreply.github.com>
This commit is contained in:
@@ -2888,6 +2888,13 @@ void ObjectMgr::LoadGameobjects()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fabs(data.rotation.x * data.rotation.x + data.rotation.y * data.rotation.y +
|
||||
data.rotation.z * data.rotation.z + data.rotation.w * data.rotation.w - 1.0f) >= 1e-5f)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotation quaternion (non-unit), defaulting to orientation on Z axis only", guid, data.id);
|
||||
data.rotation = G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(data.orientation, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
if (!MapMgr::IsValidMapCoord(data.mapid, data.posX, data.posY, data.posZ, data.orientation))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skip", guid, data.id);
|
||||
@@ -3028,6 +3035,13 @@ GameObjectData const* ObjectMgr::LoadGameObjectDataFromDB(ObjectGuid::LowType sp
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (fabs(goData.rotation.x * goData.rotation.x + goData.rotation.y * goData.rotation.y +
|
||||
goData.rotation.z * goData.rotation.z + goData.rotation.w * goData.rotation.w - 1.0f) >= 1e-5f)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid rotation quaternion (non-unit), defaulting to orientation on Z axis only", spawnId, entry);
|
||||
goData.rotation = G3D::Quat(G3D::Matrix3::fromEulerAnglesZYX(goData.orientation, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
if (!MapMgr::IsValidMapCoord(goData.mapid, goData.posX, goData.posY, goData.posZ, goData.orientation))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: {} Entry: {}) with invalid coordinates, skipped.", spawnId, entry);
|
||||
|
||||
Reference in New Issue
Block a user