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

Bullet Physics is random because the solver is random,please support developer select the solver's mode or reset the solver's random seed #17769

Open
longchuan opened this issue Oct 23, 2024 · 6 comments
Labels
Feature Request Needs Triage Needs to be assigned by the team

Comments

@longchuan
Copy link
Contributor

longchuan commented Oct 23, 2024

Use Case

when I run the physics,the result was random.I read the bullet code,found the problem is random seed.Bullet support the random seed's reset,but cocos did not support it.

Problem Description

the physics' result is random,frame sync was blocked.If player restart the app,and reconnect the game,the physics' result will be different.If support the random seed's reset,developer can reset all seed to ensure the result's consistent.

Proposed Solution

No response

How it works

No response

Alternatives Considered

support reset the random seed or solver's mode select

Additional Information

No response

@longchuan longchuan added Feature Request Needs Triage Needs to be assigned by the team labels Oct 23, 2024
@longchuan longchuan changed the title Bullet Physics is random because of the solver is random,please support the solver select or solver reset Bullet Physics is random because the solver is random,please support the solver select or solver reset Oct 23, 2024
@longchuan longchuan changed the title Bullet Physics is random because the solver is random,please support the solver select or solver reset Bullet Physics is random because the solver is random,please support the select the solver's mode or reset the solver's random seed Oct 23, 2024
@longchuan longchuan changed the title Bullet Physics is random because the solver is random,please support the select the solver's mode or reset the solver's random seed Bullet Physics is random because the solver is random,please support to select the solver's mode or reset the solver's random seed Oct 23, 2024
@longchuan longchuan changed the title Bullet Physics is random because the solver is random,please support to select the solver's mode or reset the solver's random seed Bullet Physics is random because the solver is random,please support delveloper to select the solver's mode or reset the solver's random seed Oct 23, 2024
@minggo
Copy link
Contributor

minggo commented Oct 30, 2024

I don't quite understand the result is random.

I read the bullet code, found the problem is random seed.Bullet support the random seed's reset

Could you describe it in detail? Thanks.

@longchuan
Copy link
Contributor Author

I don't quite understand the result is random.

I read the bullet code, found the problem is random seed.Bullet support the random seed's reset

Could you describe it in detail? Thanks.

relaunch the scene,the result will be different,such as the order of many balls' collision.

@longchuan
Copy link
Contributor Author

image
search the codes,you will find the random seed.

@longchuan longchuan changed the title Bullet Physics is random because the solver is random,please support delveloper to select the solver's mode or reset the solver's random seed Bullet Physics is random because the solver is random,please support developer select the solver's mode or reset the solver's random seed Oct 30, 2024
@longchuan
Copy link
Contributor Author

longchuan commented Nov 1, 2024

I don't quite understand the result is random.

I read the bullet code, found the problem is random seed.Bullet support the random seed's reset

Could you describe it in detail? Thanks.

I bind the method,found the seed always be 0,there should have another reason.When I relaunch the scene, the result would be diffrent,But If I restart the app,the result would be same.So the random result was caused by random seed.

@longchuan
Copy link
Contributor Author

image
Demo has a method to reset a scene,maybe can solve the problem

@longchuan
Copy link
Contributor Author

longchuan commented Nov 1, 2024

Yes,I solved the problem.

void DLL_EXPORT ccDiscreteDynamicsWorld_reset(int dispatcher,int broadphase,int solver)
{
        btCollisionDispatcher *m_dispatcher = (btCollisionDispatcher *)dispatcher;
        btDbvtBroadphase *m_broadphase = (btDbvtBroadphase *)broadphase;
        btConstraintSolver *m_solver = (btConstraintSolver *)solver;
        m_broadphase->resetPool(m_dispatcher);
        m_solver->reset();
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Needs Triage Needs to be assigned by the team
Projects
None yet
Development

No branches or pull requests

2 participants