bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.

Home Page:http://bulletphysics.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flicker in GUI

Huster-YZY opened this issue · comments

I'm visualizing Material Point Method Simulation results to PyBullet's GUI, my simulation loop is as follows:

particles_list=[]
while 1:
    mpm3d.step()

    for i in particles_list:
        p.removeUserDebugItem(i)
    particles_list.clear()

    pld_id = p.addUserDebugPoints(
        mpm3d.F_x.to_numpy() * 3,
        [mpm3d.ORIANGE for _ in range(mpm3d.n_particles)],
        pointSize=10)
    particles_list.append(pld_id)

However, my simulation result(points update and delete) is not synchronous to GUI's rendering, which leads to a flicker, how can I get a smoother visual effect? Thanks.

Can I stop rendering to update points' positions and then start rendering manually?
Is there any function in pybullet which can control the GUI's rendering?

I think I have found the solution to this problem.

p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 0)
load your model or transform your model dynamically
p.configureDebugVisualizer(p.COV_ENABLE_RENDERING, 1)

If you can ensure that your change can be made in one step, you can also write code like this which also helps solve the problem.

p.configureDebugVisualizer(p.COV_ENABLE_SINGLE_STEP_RENDERING,1)