-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Character movement round 1 #881
base: main
Are you sure you want to change the base?
Conversation
…consider small distances as overlap.
…s in SIMD bias for capsule vs capsule to reduce feature flip-flop time of impact fallback now based on minExtent
sensors skip shapes on same body enableSensorEvents is back and defaults to false
Hello! I am testing this branch, this is really an improvement! Thanks! I would suggest to rename the new Anyway, thanks! |
bool isSensor; | ||
|
||
/// Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. | ||
/// Enable sensor events for this shape. This applies to sensors and non-sensors. False by default, even for sensors. | ||
bool enableSensorEvents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to rename the new enableSensorEvents
flag to detectedBySensors
because at first I thought I had to enable this in the sensor itself, but rather it must be enabled in all the other shapes that could be detected by a sensor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a feature request for sensors themselves to be disabled and for sensors to detect other sensors. Basically every combination.
Hmm, after further testing, I see that Shouldn't it work so that For now, I am setting Thanks! |
…tution Also fixed bug where contacts with no restitution were affected by the restitution solver. This affected the determinism test result.
src/world.c
Outdated
@@ -2488,6 +2577,112 @@ b2TreeStats b2World_CastPolygon( b2WorldId worldId, const b2Polygon* polygon, b2 | |||
return treeStats; | |||
} | |||
|
|||
static b2AABB b2ComputerShapeBounds( const b2ShapeProxy* shape, b2Transform xf ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Compute?
bool isSensor; | ||
|
||
/// Enable contact events for this shape. Only applies to kinematic and dynamic bodies. Ignored for sensors. | ||
/// Enable sensor events for this shape. This applies to sensors and non-sensors. False by default, even for sensors. | ||
bool enableSensorEvents; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this before enableHitEvents will subtly break bindings generated for 3.0.0 that point to a 3.1.0 shared library, which might be unexpected if people expect Open/Close Principle adherence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tend to organize structs to for good packing, not for adding new stuff to the end. Shouldn't a binding generator look at the names?
I also want these two bools to be close together because they are related.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, I just wanted to point it out.
Binding generators will create bindings at design time, but they are fixed at runtime - and so something compiled against Box2D 3.0.0 will have a layout mismatch if it's later pointed to 3.1.0. Because at the interface it's just a lump of data, there will be no compiletime or runtime errors and fields in the consumer code will just be in the wrong locations. The best thing for developers is to just recreate the bindings programmatically, but where someone's got, for example, a NuGet package that on the surface appears to do it for them, and they expect to be able to just drop in a Box2D 3.1.0 shared library, then they'll run into trouble when they use the 'displaced' fields.
In my case it's put together manually and I'm taking care to observe and absorb changes in 3.1.0. Here's what it looks like for me:
Each bool takes 1 byte but internalValue
is aligned to the next 4-byte boundary, so the packing is not affected in this case and it won't break as it would if you were 1 bool over the next boundary.
With all that said, I understand your reasons for putting EnableSensorEvents
adjacent to IsSensor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hoping to generate some json like raylib does to assist with binding generators. I wonder if some sort of version number check could be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my case I could call b2GetVersion at first use, but I'm building the shared libs and including them in the NuGet package so everything should be "joined up" anyway. That's something I might do at build time, so that I get the error if the shared lib version doesn't match, and then I can deal with it. A unit test would be a good place for it.
Those using what we could call "prepared bindings" could call b2GetVersion at their leisure, but I don't see a good way of using that to try to solve this problem. Even if you required that people include the version in b2WorldDef, if they get it from b2GetVersion then the value will be correct always. It would be the same for modifying B2_SECRET_COOKIE: because box2d itself is responsible for distributing it, it would always match.
@@ -1440,9 +1448,15 @@ typedef struct b2DebugDraw | |||
/// Option to draw contact normal impulses | |||
bool drawContactImpulses; | |||
|
|||
/// Option to draw contact feature ids | |||
bool drawContactFeatures; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this before drawFrictionImpulses will subtly break bindings generated for 3.0.0 that point to a 3.1.0 shared library, which might be unexpected if people expect Open/Close Principle adherence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot anticipate all the assumptions made by binding generators. I'll make a note of this in the 3.1 release notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had made my bindings against the partial 3.1.0 in main, which was an error on my part. I've changed everything so my Github actions build the latest tag instead, and my bindings work against 3.0.0, with a unit test to detect if b2Version returns something other than 3.0.0. When you're ready to release 3.1.0, I'll get a failing build and I'll update my code accordingly. The two I've mentioned in this PR would be the tip of the iceberg if we were to analyse the gap between 3.0.0 and 3.1.0, so if you're going to make a note in the release notes, it should probably either be vague about a number of changes that will require recreation of any bindings, or I can help you an exhaustive list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect any point release to have breaking changes. I feel a physics engine is a bit different than something like SDL where API stability is at a premium. For Box2D features, performance, and robustness are at a premium and there are a lot of features to come.
static shapes now invoke contact creation by default
Sensor updates:
[fix] body move events are now correctly adjusted for time of impact