Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoboticsDrift doesn't work with model hierarchies having a position/rotation offset #35

Closed
gotmachine opened this issue May 7, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@gotmachine
Copy link
Contributor

gotmachine commented May 7, 2022

All the stock robotics parts have a model hierarchy where the movingTransform (defined by servoTransformName in configs) has a zero position and rotation relative to the model root.

But this doesn't necessarily hold true for modded parts. The model hierarchy can have local pos/rot offsets, and the model itself can be translated/rotated relative to the part transform by defining a non-zero position/rotation in the part config MODEL{} node.

Failing to handle that case causes the orgRot/orgPos update to produce garbage results, resulting in wrong part positions when timewarping and after reloading a saved vessel. This can be seen in the BDB Hokulani OCO-RT90 Truss Structure. That part is victim of both issues, as it uses a MODEL{} rotation and has local position offsets between the model root and the movingTransform.

We need to fix things in 2 separate places. The position offset should likely be used when calling RecurseChildCoordsUpdate() the first time :

RecurseChildCoordsUpdate(part, Vector3d.zero);

The rotation offset should likely be accounted for at the GetLocalToVesselSpace() level :
protected QuaternionD GetLocalToVesselSpace()
{
// for some reason not normalizing can end up with a quaternion with near infinity components
// when it should be identity, leading to infinity and NaN down the line...
return (QuaternionD.Inverse(servo.part.orgRot) * (QuaternionD)servo.part.vessel.rootPart.orgRot).Normalize();
}

@gotmachine gotmachine added the bug Something isn't working label May 7, 2022
gotmachine pushed a commit that referenced this issue May 8, 2022
…o parts having `MODEL{}` rotation/position offsets and/or a model hierarchy where the rotation transform has a position/rotation offset relative to the model root. Notably fixes incorrect behavior with the BDB [Hokulani OCO-RT90 Truss Structure](https://forum.kerbalspaceprogram.com/index.php?/topic/122020-1123-bluedog-design-bureau-stockalike-saturn-apollo-and-more-v1101-%D0%BB%D1%83%D0%BD%D0%B0-24apr2022/&do=findComment&comment=4128194).
gotmachine added a commit that referenced this issue May 8, 2022
…ock servo parts having `MODEL{}` rotation/position offsets and/or a model hierarchy where the rotation transform has a position/rotation offset relative to the model root. Notably fixes incorrect behavior with the BDB [Hokulani OCO-RT90 Truss Structure](https://forum.kerbalspaceprogram.com/index.php?/topic/122020-1123-bluedog-design-bureau-stockalike-saturn-apollo-and-more-v1101-%D0%BB%D1%83%D0%BD%D0%B0-24apr2022/&do=findComment&comment=4128194)."

This reverts commit 65febd3.
gotmachine added a commit that referenced this issue May 8, 2022
…o parts having `MODEL{}` rotation/position offsets and/or a model hierarchy where the rotation transform has a position/rotation offset relative to the model root. Notably fixes incorrect behavior with the BDB [Hokulani OCO-RT90 Truss Structure](https://forum.kerbalspaceprogram.com/index.php?/topic/122020-1123-bluedog-design-bureau-stockalike-saturn-apollo-and-more-v1101-%D0%BB%D1%83%D0%BD%D0%B0-24apr2022/&do=findComment&comment=4128194).
gotmachine added a commit that referenced this issue Jan 30, 2023
…o parts having `MODEL{}` rotation/position offsets and/or a model hierarchy where the rotation transform has a position/rotation offset relative to the model root. Notably fixes incorrect behavior with the BDB [Hokulani OCO-RT90 Truss Structure](https://forum.kerbalspaceprogram.com/index.php?/topic/122020-1123-bluedog-design-bureau-stockalike-saturn-apollo-and-more-v1101-%D0%BB%D1%83%D0%BD%D0%B0-24apr2022/&do=findComment&comment=4128194).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant