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

Language Clarification: Concurrently accessing the physics simulation #95

Closed
moonshineTheleocat opened this issue Mar 14, 2022 · 4 comments

Comments

@moonshineTheleocat
Copy link

In games we usually need to do many more things than to simulate the physics world and we need to do this across multiple threads. We therefore place a lot of emphasis on concurrently accessing the physics simulation data outside of the main physics simulation update:

Just asking for a clarification here, as the language makes it a bit confusing. Is Jolt intended to be run on it's own thread, while sharing a thread pool with the main application thread. Or is it designed to run on the main application thread.

@jrouwe
Copy link
Owner

jrouwe commented Mar 14, 2022

The simulation runs across many threads (doesn't matter if you kick it from the main thread or another thread, it will use that thread and as many other threads as you give it - this is abstracted in the JobSystem class with JobSystemThreadPool as a possible implementation). The text above is talking about what happens outside of the physics simulation: You can manipulate bodies and perform collision queries from many threads at the same time.

@moonshineTheleocat
Copy link
Author

Ok. So the main physics loop can exist on the application's main thread, or continuously running on its own thread, and it can be handled just fine provided it has interface access to the application's thread-pool implementation.

@jrouwe
Copy link
Owner

jrouwe commented Mar 15, 2022

Correct. I'm assuming b.t.w. that 'continuously running' means that the thread continuously runs, not the simulation. During PhysicsSystem::Update the physics system is locked, so other threads cannot read/modify any state. Outside of the PhysicsSystem::Update multiple threads can access and modify the simulation data if you want.

@moonshineTheleocat
Copy link
Author

moonshineTheleocat commented Mar 17, 2022

Gotcha, gotcha. That basically answers the question. So I'm gonna go ahead and close the thread.

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

2 participants