Skip to content

Commit

Permalink
Fixed a long-standing math issue that caused strange jiggling artifac…
Browse files Browse the repository at this point in the history
…ts for QuadMeshes that were far away from the north pole. Turns out I had messed up the way that the mesh's location relative to the planet was calculated so it wasn't getting translated to the origin correctly when coordinates were converted to mesh space, so we were hitting rounding issues when the X and Y components got large.
  • Loading branch information
SaintGimp committed Nov 26, 2010
1 parent 274afad commit b05e527
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion GenesisEngine/Domain/QuadMesh.cs
Expand Up @@ -58,7 +58,8 @@ public void Initialize(double planetRadius, DoubleVector3 planeNormalVector, Dou
_extents = extents;
_level = level;

_locationRelativeToPlanet = (_planeNormalVector) + (_uVector * ((_extents.West + (_extents.Width / 2.0)))) + (_vVector * ((_extents.North + (_extents.Width / 2.0))));
// TODO: get this from the QuadNode instead
_locationRelativeToPlanet = (_planeNormalVector) + (_uVector * (_extents.North + (_extents.Width / 2.0))) + (_vVector * (_extents.West + (_extents.Width / 2.0)));
_locationRelativeToPlanet = _locationRelativeToPlanet.ProjectUnitPlaneToUnitSphere() * _planetRadius;

_meshStride = _extents.Width / (_gridSize - 1);
Expand Down
2 changes: 1 addition & 1 deletion GenesisEngine/Domain/QuadNode.cs
Expand Up @@ -53,7 +53,7 @@ public void Initialize(double planetRadius, DoubleVector3 planeNormalVector, Dou
_extents = extents;
Level = level;

_locationRelativeToPlanet = (_planeNormalVector) + (_uVector * ((_extents.West + (_extents.Width / 2.0)))) + (_vVector * ((_extents.North + (_extents.Width / 2.0))));
_locationRelativeToPlanet = (_planeNormalVector) + (_uVector * (_extents.North + (_extents.Width / 2.0))) + (_vVector * (_extents.West + (_extents.Width / 2.0)));
_locationRelativeToPlanet = _locationRelativeToPlanet.ProjectUnitPlaneToUnitSphere() * _planetRadius;

_mesh.Initialize(planetRadius, planeNormalVector, uVector, vVector, extents, level);
Expand Down

0 comments on commit b05e527

Please sign in to comment.