zen-mod / ZEN

Zeus enhancement mod for Arma 3
https://zen-mod.github.io/ZEN
GNU General Public License v3.0
111 stars 49 forks source link

Fix attach offsets not being relative to the object's center #663

Closed RedFoxIV closed 2 years ago

RedFoxIV commented 2 years ago

https://github.com/zen-mod/ZEN/blob/36ed48447508f6020a5be609ec8da5b31624b312/addons/common/functions/fnc_serializeObjects.sqf#L200

At this line worldToModel ASLtoAGL getPosASL is used to get the offset required for correct attachment of _x. The problem is, the resulting coordinate is not relative to the center of the _object, but it's base. (This may be more complicated if the object is tilted, but it's still not the center.) As a result, _x is displaced vertically.

I have tested the following method for every degree of rotation along the global X axis, from 0 to 359. It seems to be a lot more accurate without any special olympics tier of crutches to negate the error in the offset.

_object WorldToModel ASLToAGL getPosWorld _x

Related issue - https://github.com/zen-mod/ZEN/issues/649

mharis001 commented 2 years ago

Please remove the shortcut file as well.

RedFoxIV commented 2 years ago

Done

Kexanone commented 2 years ago

Well spotted, but needs to be fixed for exported SQF as well: https://github.com/zen-mod/ZEN/blob/7b27ef2ba30215edda21a4bbac4515dd0edb4309/addons/common/functions/fnc_exportMissionSQF.sqf#L172