Description:
After adding last range checks we have a problem.
If all rotations of GO is zero - we have broken quat and range check always false.
We have 974 spawns with zero fields in TDB 335.19051
Branch(es):
3.3.5
TC rev. hash/commit:
17057dbf3d357e9f05ed0e52b377038bf2930666
Operating system: any
Thank you for pointing out this. I noticed just yesterday that the stranded boat (containing embalmed corpses) near the "Decrepit Ferry" pier is incorrectly rotated (more than 90掳 off and pointing towards the beginning of the pier) compared to what it should look like. The tell-tale sign is that the corpses are still in the correct positions, but the boat is incorrectly rotated. The boat is also partially sunk into the ground, whereas it should look like this:

I doubt the rotation is related to range check, I fixed some gobs rotation yesterday https://github.com/TrinityCore/TrinityCore/commit/1a569bdec55fc8eb49296505637d39a3935bad05
I need to check in an older revision
@xvwyh Can you check this issue?
We maybe can set rotation3 to 1.0f if all four components is zero at loading. This should fix issue but...
I checked this gob:
SELECT * FROM gameobject WHERE id=1593 ;
SELECT * FROM gameobject_addon WHERE guid=33382 ;
current data
rotation0=0, rotation1=0, rotation2=-0.850353, rotation3=0.526213
parent_rotation0=0.022059, parent_rotation1=0.255141, parent_rotation2=-0.804415, parent_rotation3=0.536035
Edit: same issue in 2 old year revision
Hm, well, OK, does it mean that gameobject.rotation0 should be the same value as gameobject_addon.parent_rotation0 and so on?
(sorry if I have misunderstood your information)
I doubt the rotation is related to range check
Errrrr? Of course it is! Rotating the object rotates it's geobox, and range is checked to the geobox. It's a box, not a sphere, depending on its size and rotation the distance from it to the same point will be different.
rotation0=0, rotation1=0, rotation2=-0.850353, rotation3=0.526213
parent_rotation0=0.022059, parent_rotation1=0.255141, parent_rotation2=-0.804415, parent_rotation3=0.536035
For all I know, parent_rotation only affects non-mapobj transport paths. It allows you to rotate the entire path around its origin point. Regular rotation rotates the object itself around its position.
If you got rotation0 and rotation1 set to zero, it means the gameobject is only rotated on Z axis, i.e. it effectively serves the same function as orientation (orientation column is actually completely redundant in GOs case, but whatever). Looking at the screenshot, it's obvious that the boat needs to be rotated on multiple axes, hence the data in parent_rotation of your boat seems way more believable than that in rotation columns. Try moving the data from parent_rotation to rotation and see if the boat will look properly with it. gameobject_addon record, in this case, could then be deleted, unless you have a valid source for boat's GAMEOBJECT_PARENT_ROTATION fields.
@xvwyh @illfated @Killyana
Please, return to issue case. Fix needed.
Fix the rotation. That's all.
If you want an automated solution as opposed to fixing DB data - in GameObject::Create check if the quaternion is valid and if not - fallback to some other rotation. For example, use orientation as fallback.
if (G3D::Quat(rotation.x, rotation.y, rotation.z, rotation.w).isUnit())
SetLocalRotation(rotation.x, rotation.y, rotation.z, rotation.w);
else
SetLocalRotationAngles(GetOrientation(), 0, 0);
Going back to the boat topic - it's a very interesting topic! - blizzard seems to have screwed something up in boat models. Because just recently I noticed that all boats in Stormwind, that are supposed to be attached to docks with ropes - aren't. The model's geobox is correct, but the geometry is misplaced:
Screenshots





Perhaps they wanted to adjust one boat's model somewhere in the world, but accidentally changed it for everything, because that model was also used by all boat GOs and static map models.
Looks like a case of missed db data validation - we check isUnit() on gameobject_addon.parent_rotation but not gameobject.rotation
This will fix the main issue:
UPDATE `gameobject_addon` SET `parent_rotation0`=0, `parent_rotation1`=0, `parent_rotation2`=0.890985, `parent_rotation3`=-0.454032 WHERE `guid`=33382;
UPDATE `gameobject` SET `rotation0`=0.022059, `rotation1`=0.255141 WHERE `guid`=33382;
UPDATE `gameobject` SET `rotation2`=0.588741, `rotation3`=0.808322 WHERE `id` IN (1620,1621,1622,1623,1624,1628,2041,2042,2043,2044,2045,2046,142140,142144,181280,181281,185966,186221,186234,186615,186614) AND `rotation1`=0 AND `rotation2`=0;
UPDATE `gameobject` SET `rotation2`=-0.0348994, `rotation3`=0.999391 WHERE `guid` IN (66913, 66922, 43071,91,93,97,99,101,103,111,113,115,390,392,388,407);
For this boats it's a client side issue and cannot be fixed.
It's better to a get check for bad gameobject.rotation before pushing this.