GithubHelp home page GithubHelp logo

Broadphase rebuild about joltphysics HOT 1 CLOSED

jrouwe avatar jrouwe commented on May 13, 2024
Broadphase rebuild

from joltphysics.

Comments (1)

jrouwe avatar jrouwe commented on May 13, 2024

When you said "we do this", it wasn't clear to me, whether "we" referred to Jolt in general, or the game and how it integrates Jolt. Ie. does Jolt rebuild/optimize the broadphase automatically as needed already or not?

This is how Jolt does it in general, it's part of PhysicsSystem::Update.

In my engine, I am adding and activating bodies one by one, which you mention is pretty bad. Of course most of that happens in the first frame when the level is loaded. Should I keep track of this and trigger a rebuild at some point? Should I just rebuild the broadphase for dynamic objects every frame? Are there helpers to do this in the background as you do in the game?

After loading I would recommend calling PhysicsSystem::OptimizeBroadPhase once to fully rebuild the tree (this you can do from a background thread but take care to not modify any bodies while you're doing this). Also when you're loading objects, try to collect all bodies that you're loading and add them as a single batch. If you don't, things will still work but it will be less efficient (in the first few frames).

Also you mentioned that the navmesh generation may run for several seconds, but you said that you swap the broadphase trees at the end of the frame.

I don't think it takes a couple of seconds, I think I said it takes more than a frame. We keep the old tree until the next physics update. At that time we'll lock the broad phase (see BroadPhaseQuadTree::FrameSync) and wait for any query that is still ongoing. Only the broadphase query part of the navmesh generation needs to have finished by that time, after that we've collected a list of TransformedShape which we can use to query triangles without requiring additional locking.

from joltphysics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.