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: 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
|
# recursion depth
|
||||||
depth 1
|
depth 1
|
||||||
|
@ -227,7 +227,7 @@ parseMesh' s m = do
|
|||||||
b = F.foldl' minmax (V3 (-infty) (-infty) (-infty), V3 infty infty infty) mv
|
b = F.foldl' minmax (V3 (-infty) (-infty) (-infty), V3 infty infty infty) mv
|
||||||
minmax (maxin,minin) vec = (max <$> maxin <*> vec, min <$> minin <*> vec)
|
minmax (maxin,minin) vec = (max <$> maxin <*> vec, min <$> minin <*> vec)
|
||||||
infty = 9999999999999 :: Float
|
infty = 9999999999999 :: Float
|
||||||
return $ OpI Mesh
|
return $ D.trace ("verts: "++show verts++"\nfaces:"++show faces) (OpI Mesh
|
||||||
{ meshShading = s
|
{ meshShading = s
|
||||||
, meshMaterial = m
|
, meshMaterial = m
|
||||||
, meshVertices = mv
|
, meshVertices = mv
|
||||||
@ -235,7 +235,7 @@ parseMesh' s m = do
|
|||||||
, meshNormals = mn
|
, meshNormals = mn
|
||||||
, meshFaceNormals = mfn
|
, meshFaceNormals = mfn
|
||||||
, meshBounds = bounds
|
, meshBounds = bounds
|
||||||
}
|
})
|
||||||
|
|
||||||
parseTriangle :: Parser (V3 Int)
|
parseTriangle :: Parser (V3 Int)
|
||||||
parseTriangle = do
|
parseTriangle = do
|
||||||
|
@ -140,7 +140,7 @@ intersect (Ray ro rd) p@(P (Plane pc pn _)) = if det == 0 || t < epsilon
|
|||||||
! det = dot rd' pn
|
! det = dot rd' pn
|
||||||
t = (dot (pc - ro) pn)/det
|
t = (dot (pc - ro) pn)/det
|
||||||
rd' = normalize rd
|
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
|
[] -> Nothing
|
||||||
a -> Just . P.head . L.sort $ a
|
a -> Just . P.head . L.sort $ a
|
||||||
where
|
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) =
|
hitsFlat verts norm f (V3 w1 w2 w3) =
|
||||||
if det == 0 || t < epsilon || not det2
|
if det == 0 || t < epsilon || not det2
|
||||||
then Nothing
|
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
|
where
|
||||||
! det = dot rd' (norm IM.! f) --do we hit the plane
|
! det = dot rd' (norm IM.! f) --do we hit the plane
|
||||||
rd' = normalize rd
|
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.
|
-- vectors are linear independent.
|
||||||
det2 = det2v ^. _x > 0 && det2v ^. _y > 0
|
det2 = det2v ^. _x > 0 && det2v ^. _y > 0
|
||||||
&& det2v ^. _x + det2v ^. _y < 1
|
&& det2v ^. _x + det2v ^. _y < 1
|
||||||
|
|
||||||
--hitsPhong :: IntMap (V3 Float) -> IntMap (V3 Float) -> V3 Int -> Maybe Collision
|
--hitsPhong :: IntMap (V3 Float) -> IntMap (V3 Float) -> V3 Int -> Maybe Collision
|
||||||
|
|
||||||
-- deprecated - wrong calculation of rays.
|
-- deprecated - wrong calculation of rays.
|
||||||
|
Loading…
Reference in New Issue
Block a user