public ViewChunk[] View() { Point observerPoint = space.GetPointFromPosition(observer.position); if (view == null || !space.IsPointInRange(observerPoint, previousObserverPoint, updateDistace)) { previousObserverPoint = observerPoint; view = GetVisible(observerPoint); } return(view); }
public Vector3 GetHeightAtPosition(Vector3 targetStartPosition) { Point closestPoint = space.GetPointFromPosition(targetStartPosition); float heightValue = terrain.GetValue(closestPoint); Vector3 surfaceNormal = space.GetNormalFromPosition(targetStartPosition); return(closestPoint.GetPosition() + surfaceNormal * heightValue); }
public FixedViewer(ChunkedSpace space, Vector3 origin, float distace, MeshLod?visibleLod = null) { Point originPoint = space.GetPointFromPosition(origin); Chunk[] chunks = space.GetChunksWithin(originPoint, distace); view = chunks .Select(chunk => new ViewChunk(chunk, visibleLod ?? new MeshLod(0))) .ToArray(); }
public ViewChunk[] View() { Point observerPoint = space.GetPointFromPosition(observer.position); float altitude = space.GetDistanceFromSurface(observer.position); if (view == null) { previousObserverPoint = observerPoint; previousObserverAltitude = altitude; view = GetVisible(observerPoint); return(view); } bool pointIsOutsideUpdateDistance = !space.IsPointInRange(observerPoint, previousObserverPoint, updateDistace); // In this viewer we are also interesed in movement along the space normal bool normalDimensionIsOutsideUpdateDistance = Mathf.Abs(altitude - previousObserverAltitude) > updateDistace; if (pointIsOutsideUpdateDistance || normalDimensionIsOutsideUpdateDistance) { previousObserverPoint = observerPoint; previousObserverAltitude = altitude; view = GetVisible(observerPoint); } return(view); }