chose other reference points.
- camera is smoother now - but still a bit shaky
This commit is contained in:
		@@ -5,6 +5,8 @@ import Map.Types
 | 
				
			|||||||
import Data.Array    (bounds, (!))
 | 
					import Data.Array    (bounds, (!))
 | 
				
			||||||
import Data.List     (sort, group)
 | 
					import Data.List     (sort, group)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import Debug.Trace
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- WARNING: Does NOT Check for neighbours exceeding maximum map coordinates yet.
 | 
					-- WARNING: Does NOT Check for neighbours exceeding maximum map coordinates yet.
 | 
				
			||||||
unsafeGiveNeighbours :: (Int, Int)  -- ^ original coordinates
 | 
					unsafeGiveNeighbours :: (Int, Int)  -- ^ original coordinates
 | 
				
			||||||
                     -> [(Int,Int)] -- ^ list of neighbours
 | 
					                     -> [(Int,Int)] -- ^ list of neighbours
 | 
				
			||||||
@@ -43,9 +45,20 @@ giveMapHeight :: PlayMap
 | 
				
			|||||||
             -> Double
 | 
					             -> Double
 | 
				
			||||||
giveMapHeight mop (x, z)
 | 
					giveMapHeight mop (x, z)
 | 
				
			||||||
  | outsideMap (x,z') = 0.0
 | 
					  | outsideMap (x,z') = 0.0
 | 
				
			||||||
  | otherwise         = sum $ map (\(p,d) -> hlu p * (d / totald)) tups
 | 
					  | otherwise         = height --sum $ map (\(p,d) -> hlu p * (d / totald)) tups
 | 
				
			||||||
  where
 | 
					  where
 | 
				
			||||||
    z' = z * 2/ sqrt 3
 | 
					    z' = z * 2/ sqrt 3
 | 
				
			||||||
 | 
					    rx = x  - (fromIntegral $ floor (x +0.5))
 | 
				
			||||||
 | 
					    rz = z' - (fromIntegral $ floor (z'+0.5))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    hoi = map (hlu . clmp . tadd (floor x, floor z')) mods
 | 
				
			||||||
 | 
					      where
 | 
				
			||||||
 | 
					        mods = [(0,0),(0,1),(1,0),(1,1)]
 | 
				
			||||||
 | 
					        tadd (a,b) (c,d) = (a+c,b+d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    height = --trace (show [rx,rz] ++ show hoi)
 | 
				
			||||||
 | 
					             rz     * (rx * (hoi !! 0) + (1-rx) * (hoi !! 2))
 | 
				
			||||||
 | 
					           + (1-rz) * (rx * (hoi !! 1) + (1-rx) * (hoi !! 3))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    outsideMap :: (Double, Double) -> Bool
 | 
					    outsideMap :: (Double, Double) -> Bool
 | 
				
			||||||
    outsideMap (mx, mz) = let ((a,b),(c,d)) = bounds mop
 | 
					    outsideMap (mx, mz) = let ((a,b),(c,d)) = bounds mop
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user