Skip to content

Conversation

@erincatto
Copy link
Owner

@erincatto erincatto commented Dec 14, 2025

Improved usefulness of total normal impulse on contact points
Distance joint now solves motor before limit
Code clean up and minor fixes
Logging
Update clang format
Dynamic tree unit test
b2FreeFcn now receives the allocation size
Added check for a missed call to b2Body_ApplyMassFromShapes
Calling b2CreateCapsuleShape with a very short capsule now returns b2_nullShapeId
Calling b2Shape_SetCapsule with a very short capsule now returns with no change.
Added b2ContactId to hit events.
b2Body_SetTargetTransform now has a wake option.

#1019
#1015
#1014
#1010
#1009
#1005

Distance joint now solves motor before limit
Code clean up and minor fixes
Logging
Update clang format
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes the total normal impulse calculation in contact points, reorders distance joint constraint solving to solve motor before limit, adds logging functionality, updates clang-format configuration, and introduces comprehensive dynamic tree unit tests. The changes also include code cleanup, minor API updates, and fixes for memory allocation and mass computation.

Key Changes

  • Contact Solver Fix: Corrected totalNormalImpulse to accumulate delta impulses instead of absolute impulses, making it more useful for tracking actual contact interactions
  • Distance Joint: Motor constraint now solves before limit constraint for better stability
  • Dynamic Tree Testing: Added comprehensive unit test suite with 462 lines covering tree operations, ray casting, queries, and movement

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test_dynamic_tree.c New comprehensive unit test suite for dynamic tree with ray casting, queries, and stress tests
test/main.c, test/CMakeLists.txt Registration of new dynamic tree test
src/contact_solver.c Fixed totalNormalImpulse to track delta impulse instead of newImpulse across warm start, solve, and restitution phases
src/distance_joint.c Reordered motor constraint to execute before limit constraints; removed unused include
src/weld_joint.c Experimental changes with commented spring code and hardcoded bias values
src/shape.c Added b2_dirtyMass flag support and capsule validation; added b2Chain_GetSurfaceMaterialCount
src/body.c Fixed missing shapeIndex increment; added b2_dirtyMass flag clearing; added wake parameter to SetTargetTransform
src/solver.c Added assertion for b2_dirtyMass flag; added contactId to hit events
src/table.c Fixed to use set.capacity instead of capacity parameter
src/core.c, src/core.h Added logging infrastructure with b2Log function and customizable log handler
src/dynamic_tree.c Code formatting fixes and minor comment corrections
src/constraint_graph.c Simplified dynamic-dynamic body color assignment logic
samples/*.cpp Updated all SetTargetTransform calls with wake parameter; added new CircleImpulse sample to demonstrate impulse tracking
include/box2d/*.h Updated API documentation, added wake parameter, added contactId to hit events, improved bullet documentation
.clang-format Updated configuration for VS 2022 with new spacing rules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +3248 to +3251
points[0] = { 3.0, -0.5 };
points[1] = { 3.0, 0.5 };
points[2] = { -3.0, 0.5 };
points[3] = { -3.0, -0.5 };
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code adds new hardcoded test points that overwrite the previous values but doesn't remove or comment out the old initialization. This creates confusion about which values are actually used. Consider either removing the old initialization (lines 3240-3246) or adding a comment explaining why both sets of values are present.

Copilot uses AI. Check for mistakes.
}

if ( m_drawSimplex )
if ( m_drawSimplex && m_simplexCount > 0 )
Copy link

Copilot AI Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the check "m_simplexCount > 0" before using m_simplexIndex is a good defensive programming practice that prevents potential issues when the slider is accessed with an empty simplex. However, this guards against a state that might indicate a logic error elsewhere. Consider whether this is masking an underlying issue or if an empty simplex is a valid state that should be handled gracefully.

Copilot uses AI. Check for mistakes.
@erincatto erincatto merged commit c05c487 into main Dec 15, 2025
15 checks passed
@erincatto erincatto deleted the minor branch December 15, 2025 00:01
ikpil added a commit to ikpil/Box2D.NET that referenced this pull request Dec 20, 2025
Improved usefulness of total normal impulse on contact points
Distance joint now solves motor before limit
Code clean up and minor fixes
Logging
Update clang format
Dynamic tree unit test
b2FreeFcn now receives the allocation size
Added check for a missed call to b2Body_ApplyMassFromShapes
Calling b2CreateCapsuleShape with a very short capsule now returns
b2_nullShapeId
Calling b2Shape_SetCapsule with a very short capsule now returns with no
change.
Added b2ContactId to hit events.
b2Body_SetTargetTransform now has a wake option.

erincatto/box2d#1019
erincatto/box2d#1015
erincatto/box2d#1014
erincatto/box2d#1010
erincatto/box2d#1009
erincatto/box2d#1005
ikpil added a commit to ikpil/Box2D.NET that referenced this pull request Dec 21, 2025
Improved usefulness of total normal impulse on contact points
Distance joint now solves motor before limit
Code clean up and minor fixes
Logging
Update clang format
Dynamic tree unit test
b2FreeFcn now receives the allocation size
Added check for a missed call to b2Body_ApplyMassFromShapes
Calling b2CreateCapsuleShape with a very short capsule now returns
b2_nullShapeId
Calling b2Shape_SetCapsule with a very short capsule now returns with no
change.
Added b2ContactId to hit events.
b2Body_SetTargetTransform now has a wake option.

erincatto/box2d#1019
erincatto/box2d#1015
erincatto/box2d#1014
erincatto/box2d#1010
erincatto/box2d#1009
erincatto/box2d#1005
ikpil added a commit to ikpil/Box2D.NET that referenced this pull request Dec 21, 2025
Improved usefulness of total normal impulse on contact points
Distance joint now solves motor before limit
Code clean up and minor fixes
Logging
Update clang format
Dynamic tree unit test
b2FreeFcn now receives the allocation size
Added check for a missed call to b2Body_ApplyMassFromShapes
Calling b2CreateCapsuleShape with a very short capsule now returns
b2_nullShapeId
Calling b2Shape_SetCapsule with a very short capsule now returns with no
change.
Added b2ContactId to hit events.
b2Body_SetTargetTransform now has a wake option.

erincatto/box2d#1019
erincatto/box2d#1015
erincatto/box2d#1014
erincatto/box2d#1010
erincatto/box2d#1009
erincatto/box2d#1005
ikpil added a commit to ikpil/Box2D.NET that referenced this pull request Dec 21, 2025
Improved usefulness of total normal impulse on contact points
Distance joint now solves motor before limit
Code clean up and minor fixes
Logging
Update clang format
Dynamic tree unit test
b2FreeFcn now receives the allocation size
Added check for a missed call to b2Body_ApplyMassFromShapes
Calling b2CreateCapsuleShape with a very short capsule now returns
b2_nullShapeId
Calling b2Shape_SetCapsule with a very short capsule now returns with no
change.
Added b2ContactId to hit events.
b2Body_SetTargetTransform now has a wake option.

erincatto/box2d#1019
erincatto/box2d#1015
erincatto/box2d#1014
erincatto/box2d#1010
erincatto/box2d#1009
erincatto/box2d#1005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants