You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have a separate collision handler, and you remove an overlapping shape from a space, that handler will (rightly) get called, but the shapes function will crash the program. It will attempt to lookup the shapes in the space from their Ptr values, but one of them is no longer there.
Example code:
importControl.Monad.IO.ClassimportData.StateVarasSVimportPhysics.HipmunkasH
main =doH.initChipmunk
space <-H.newSpace
H.setDefaultCollisionHandler space $H.Handler { H.beginHandler =Just hBegin
, H.preSolveHandler =Nothing
, H.postSolveHandler =Nothing
, H.separateHandler =Just hSeparate}
b0 <-H.newBody 10$H.infinity
s0 <-H.newShape b0 (H.Circle10) 0H.position b0 SV.$=H.Vector00
b1 <-H.newBody 10$H.infinity
s1 <-H.newShape b1 (H.Circle10) 0H.position b1 SV.$=H.Vector00H.spaceAdd space b0 >>H.spaceAdd space s0
H.spaceAdd space b1 >>H.spaceAdd space s1
step space 10H.spaceRemove space s0 >>H.spaceRemove space b0
where
hBegin = liftIO (putStrLn"collision") >>returnTrue
hSeparate =do
(s0, s1) <-H.shapes
liftIO $doH.resetForces $H.body s0
H.resetForces $H.body s1
The text was updated successfully, but these errors were encountered:
If you have a
separate
collision handler, and you remove an overlapping shape from a space, that handler will (rightly) get called, but theshapes
function will crash the program. It will attempt to lookup the shapes in the space from their Ptr values, but one of them is no longer there.Example code:
The text was updated successfully, but these errors were encountered: