somithing is wrong with ray/plane. indentation
This commit is contained in:
parent
89cefdb45c
commit
563ea7c26d
@ -1,5 +1,5 @@
|
||||
# camera: eye, center, up, fovy, width, height
|
||||
camera 5 2 5 0 0 0 0 1 0 45 500 500
|
||||
camera 5 2 5 0 0 0 0 1 0 45 50 50
|
||||
|
||||
# recursion depth
|
||||
depth 1
|
||||
|
@ -227,7 +227,7 @@ parseMesh' s m = do
|
||||
b = F.foldl' minmax (V3 (-infty) (-infty) (-infty), V3 infty infty infty) mv
|
||||
minmax (maxin,minin) vec = (max <$> maxin <*> vec, min <$> minin <*> vec)
|
||||
infty = 9999999999999 :: Float
|
||||
return $ OpI Mesh
|
||||
return $ D.trace ("verts: "++show verts++"\nfaces:"++show faces) (OpI Mesh
|
||||
{ meshShading = s
|
||||
, meshMaterial = m
|
||||
, meshVertices = mv
|
||||
@ -235,7 +235,7 @@ parseMesh' s m = do
|
||||
, meshNormals = mn
|
||||
, meshFaceNormals = mfn
|
||||
, meshBounds = bounds
|
||||
}
|
||||
})
|
||||
|
||||
parseTriangle :: Parser (V3 Int)
|
||||
parseTriangle = do
|
||||
|
@ -140,7 +140,7 @@ intersect (Ray ro rd) p@(P (Plane pc pn _)) = if det == 0 || t < epsilon
|
||||
! det = dot rd' pn
|
||||
t = (dot (pc - ro) pn)/det
|
||||
rd' = normalize rd
|
||||
intersect (Ray ro rd) m@(M (Mesh s _ v f n fn b)) = case catMaybes . elems $ possHits of
|
||||
intersect (Ray ro rd) m@(M (Mesh s _ v f vn fn b)) = case catMaybes . elems $ possHits of
|
||||
[] -> Nothing
|
||||
a -> Just . P.head . L.sort $ a
|
||||
where
|
||||
@ -152,7 +152,7 @@ intersect (Ray ro rd) m@(M (Mesh s _ v f n fn b)) = case catMaybes . elems $ pos
|
||||
hitsFlat verts norm f (V3 w1 w2 w3) =
|
||||
if det == 0 || t < epsilon || not det2
|
||||
then Nothing
|
||||
else Just $ Collision pos (norm IM.! f) t m
|
||||
else D.trace (show t ++ "\t" ++ show pos) (Just $ Collision pos (norm IM.! f) t m)
|
||||
where
|
||||
! det = dot rd' (norm IM.! f) --do we hit the plane
|
||||
rd' = normalize rd
|
||||
@ -166,7 +166,6 @@ intersect (Ray ro rd) m@(M (Mesh s _ v f n fn b)) = case catMaybes . elems $ pos
|
||||
-- vectors are linear independent.
|
||||
det2 = det2v ^. _x > 0 && det2v ^. _y > 0
|
||||
&& det2v ^. _x + det2v ^. _y < 1
|
||||
|
||||
--hitsPhong :: IntMap (V3 Float) -> IntMap (V3 Float) -> V3 Int -> Maybe Collision
|
||||
|
||||
-- deprecated - wrong calculation of rays.
|
||||
|
Loading…
Reference in New Issue
Block a user