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
As clear from #267 and #226 and others its really easy to forget to set a valid mass on a body. And when it happens you will get a difficult-to-understand error, most common is debug draw failure because of NaNs. This must be possible to handle better.
The text was updated successfully, but these errors were encountered:
The problem with this error is that is not easy where to stop the 0 mass.
Its valid to create a body with 0 mass, if you attach a shape with mass to it before simulation step.
Chipmunk contains already an assert that checks that if a shape attached to a body has mass >0, then the body have a valid mass calculated.
I dont want to have to check the mass every call to step. I do however think its reasonable to require that bodies have >0 mass once the simulation is run even if that is not the case now.
Even if debug draw had a better error message, there's no guarantee that debug draw is used, so does not solve it fully.
Bodies are not fully connected to the shapes before they are added to a space.
To be able to check for this the API needs to be more strict.
The least breaking solution I can think of is:
Restrict so that if you have a body with 0 mass, add a shape to it and add the shape to the space, at this time the body must get a mass > 0. This means you cant do a 0 mass body, add 0 mass shape to it, add both to the space, and afterwards make a 2nd shape with mass > 0 to fix it.
As clear from #267 and #226 and others its really easy to forget to set a valid mass on a body. And when it happens you will get a difficult-to-understand error, most common is debug draw failure because of NaNs. This must be possible to handle better.
The text was updated successfully, but these errors were encountered: