Maniphest T60136

Rigid body simulation does not bake when using Python API to create and remove mesh data in frame_change_pre_handler
Closed, Resolved

Assigned To
Sergey Sharybin (sergey)
Authored By
Ryan Guy (rlguy)
Jan 4 2019, 12:17 AM
Tags
  • BF Blender
Subscribers
André Savik (klutz)
Brecht Van Lommel (brecht)
Campbell Barton (campbellbarton)
Marco (nacioss)
Ryan Guy (rlguy)
Sebastian Parborg (zeddb)
shaun (toxsickcity)
Todor Nikolov (ToshiCG)

Description

System Information
Operating system: Windows 10 Home
Graphics card: GTX 1070 8GB

Blender Version
Broken: 2.80, 11f2c65128dc, 2019-01-03
Worked: 2.79b release

Short description of error

A rigid body simulation does not bake to completion when the frame_change_pre handler is used to create and then immediately remove a mesh data object. The simulation only bakes the first two frames and then stops.

Here is a short script that reproduces the issue:

import bpy

def frame_change_pre(scene):    
    new_mesh_data = bpy.data.meshes.new("mesh_name")
    bpy.data.meshes.remove(new_mesh_data)
    
bpy.app.handlers.frame_change_pre.append(frame_change_pre)

I have also reported another issue related to unexpected behavior when using the frame_change_pre handler here: T60094

Exact steps for others to reproduce the error

I have attached a .blend file that includes the script to reproduce this issue.

To reproduce:

  1. Open the .blend file
  2. Press 'Run Script'
  3. Playback animation or attempt to bake the rigid body cache

To reproduce from a new .blend file:

  1. Add default cube as a rigid body object
  2. Run the script
  3. Playback animation or attempt to bake the rigid body cache

Event Timeline

Ryan Guy (rlguy) created this task.Jan 4 2019, 12:17 AM
Sebastian Parborg (zeddb) assigned this task to Campbell Barton (campbellbarton).Jan 25 2019, 12:09 PM
Sebastian Parborg (zeddb) lowered the priority of this task from 90 to 50.
Sebastian Parborg (zeddb) added subscribers: shaun (toxsickcity), Sebastian Parborg (zeddb).
Sebastian Parborg (zeddb) merged a task: T60893: Handler frame_change_post not working properly.
Sebastian Parborg (zeddb) added a subscriber: Marco (nacioss).

Seems like frame_change_post is having issues as well.

Brecht Van Lommel (brecht) reassigned this task from Campbell Barton (campbellbarton) to Sergey Sharybin (sergey).Mar 18 2019, 2:57 PM
Brecht Van Lommel (brecht) added a subscriber: Campbell Barton (campbellbarton).
Brecht Van Lommel (brecht) added a subscriber: Brecht Van Lommel (brecht).Mar 18 2019, 3:01 PM

This sounds like a dependency graph issue, and more of a design issue.

I did not investigate the file, but the dependency graph is intended to reset the physics caches when the scene is edited. This makes sense for user edits, but less so for scripts that change the scene in the frame change handler.

Maybe those should not be considered user edits. As mention in T60094, the design here should be clarified.

André Savik (klutz) added a subscriber: André Savik (klutz).May 5 2019, 1:48 AM
Todor Nikolov (ToshiCG) added a subscriber: Todor Nikolov (ToshiCG).Jun 8 2019, 4:12 PM
Sergey Sharybin (sergey) changed the task status from Unknown Status to Resolved.Jun 13 2019, 4:51 PM

Was fixed by rB27441c7. Thanks for the report, closing.