Skip to content

Commit

Permalink
Don't step static objects
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottt committed Jul 31, 2010
1 parent 1b27859 commit 76ec283
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions Physics/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,20 @@ isStationary ps =

stepPhysicalState :: Physical a
=> GLfloat -> PhysicalState a -> PhysicalState a
stepPhysicalState dt ps = ps
{ psData = a'
, psAABB = aabb'
, psTransform = t'
}
where
-- modify the translation vector of the transformation matrix
t = psTransform ps
Vector dx dy = scaleVector dt (psAcceleration ps)
t' = t { mat02 = mat02 t + dx, mat12 = mat12 t + dy }
a' = transform t' (psData ps)
aabb' = boundingBox a'
stepPhysicalState dt ps
| isStationary ps = ps
| otherwise = ps
{ psData = a'
, psAABB = aabb'
, psTransform = t'
}
where
-- modify the translation vector of the transformation matrix
t = psTransform ps
Vector dx dy = scaleVector dt (psAcceleration ps)
t' = t { mat02 = mat02 t + dx, mat12 = mat12 t + dy }
a' = transform t' (psData ps)
aabb' = boundingBox a'

applyImpulse :: Vector -> PhysicalState a -> PhysicalState a
applyImpulse (Vector x y) ps = ps
Expand Down

0 comments on commit 76ec283

Please sign in to comment.