Skip to content
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

Reset world for determinism #845

Open
erincatto opened this issue Nov 24, 2024 · 0 comments
Open

Reset world for determinism #845

erincatto opened this issue Nov 24, 2024 · 0 comments

Comments

@erincatto
Copy link
Owner

erincatto commented Nov 24, 2024

void b2World_ResetState( b2WorldId worldId )
{
    b2World* world = b2GetWorldFromId( worldId );
    B2_ASSERT( world->locked == false );
    if ( world->locked )
        return;

    // Contact Ids.
    {
        b2DestroyIdPool( &world->contactIdPool );
        world->contactIdPool = b2CreateIdPool();
    }

    // Broadphase Reset.
    // We might only need to do Kinematic and Dynamic?
    {
        b2BroadPhase* bp = &world->broadPhase;

        for ( int i = 0; i < b2_bodyTypeCount; ++i )
            b2DynamicTree_Destroy( bp->trees + i );

        for ( int i = 0; i < b2_bodyTypeCount; ++i )
            bp->trees[i] = b2DynamicTree_Create();
    }
}

From Melvyn. This would require a unit test.

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

No branches or pull requests

1 participant