CesiumGS / CesiumGS/cesium-unity
Tileset displacement incorrect after origin change
- Dominant language
- C#
- Stars
- 535
- Forks
- 132
- Avg merge
- 6h 45m
- Merged PRs (30d)
- 1
Description
#65 was partially fixed in #122, but still seems to have the following issue.
Currently transforms for tiles in Unity generally get constructed like this:
```tileLocalToUnity = UnityAdjustmentTransform * ECEFToUnity * tileLocalToECEF```
where "UnityAdjustmentTransform" is the hand-edited transform applied in addition to the default tileset transform.
The problem is that the ECEFToUnity transform changes every time the origin moves. This means that a "UnityAdjustmentTransform" relative to an original georeference origin, will be _incorrect_ when composed onto the ECEFToUnity corresponding to a new georeference origin. To fix this, we'll need to do a change of basis on the UnityAdjustmentTransform _at the time the change is commited_, so it becomes an ECEFAdjustmentTransform:
```ECEFAdjustmentTransform = UnityToECEF * UnityAdjustmentTransform * ECEFToUnity```
Later we can compute tile transforms by:
```tileLocalToUnity = ECEFToUnity * ECEFAdjustmentTransform * tileLocalToECEF```
Note the new adjustment matrix is no longer relative to a transient frame-of-reference. Further Unity adjustments can similarly be changed to an ECEF basis and composed with the previous adjustment.
The only tricky part will be automatically detecting / overriding Unity tileset transform events (whether in editor or during play). But I suspect some of these details have already been sorted out over the course of #122 and the globe anchor implementation.
Contributor guide
Research direction
Start by tracing the tileset transform construction around ECEFToUnity, UnityAdjustmentTransform, and the georeference-origin change path. Review the partial fix in #122 and the globe anchor implementation for existing transform event handling. Done means Unity adjustments are converted to an ECEF basis when committed and remain correct after the origin moves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, unity
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100