blender: create a debug panel to test the update of depsgraph (#110)

This commit is contained in:
Sindharta Tanuwijaya 2021-05-11 12:11:25 +09:00 коммит произвёл GitHub
Родитель 18568a9fb9
Коммит 2b8aa6960a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 76 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,76 @@
bl_info = {
"name": "MeshSync Debug",
"blender": (2, 91, 2),
"category": "Object",
}
import bpy;
import time;
class MeshSyncDebugView:
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Tool"
class MeshSyncDebugMainPanel(MeshSyncDebugView, bpy.types.Panel):
bl_label = "MeshSyncDebugView"
def draw(self, context):
layout = self.layout
layout.operator("object.update_depsgraph", text="Update Depsgraph for each frame")
class UpdateDepsgraph(bpy.types.Operator):
"""Update Depsgraph for each frame""" # tooltip
bl_idname = "object.update_depsgraph" # Unique ID
bl_label = "Update Depsgraph for each frame" # Interface label
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
scene = bpy.context.scene
depsgraph = bpy.context.evaluated_depsgraph_get()
id_types = ['ACTION', 'ARMATURE', 'BRUSH', 'CAMERA', 'CACHEFILE', 'CURVE', 'FONT', 'GREASEPENCIL', 'COLLECTION', 'IMAGE', 'KEY', 'LIGHT', 'LIBRARY', 'LINESTYLE', 'LATTICE', 'MASK', 'MATERIAL', 'META', 'MESH', 'MOVIECLIP', 'NODETREE', 'OBJECT', 'PAINTCURVE', 'PALETTE', 'PARTICLE', 'LIGHT_PROBE', 'SCENE', 'SIMULATION', 'SOUND', 'SPEAKER', 'TEXT', 'TEXTURE', 'HAIR', 'POINTCLOUD', 'VOLUME', 'WINDOWMANAGER', 'WORLD', 'WORKSPACE']
for i in range(scene.frame_start, scene.frame_end):
startTime = time.time()
scene.frame_current = i
depsgraph.update()
for j in id_types:
updated = depsgraph.id_type_updated(j)
if (updated):
print (" Change status of %s : %d" % (j, updated))
endTime = time.time()
print("Frame: %s Elapsed Time: %s seconds" % (i, (endTime - startTime)))
scene.frame_current = 0
depsgraph.update()
return {'FINISHED'}
#----------------------------------------------------------------------------------------------------------------------
classes = (
MeshSyncDebugMainPanel,
UpdateDepsgraph,
)
def register():
for c in classes:
bpy.utils.register_class(c)
def unregister():
for c in classes:
bpy.utils.unregister_class(c)
#----------------------------------------------------------------------------------------------------------------------
if __name__ == "__main__":
register()