powroupi / blender_mmd_tools

mmd_tools is a blender addon for importing Models and Motions of MikuMikuDance.
GNU General Public License v3.0
1.83k stars 277 forks source link

properties\camera.py has infinity loop and causes crash in 2.8 #228

Closed Filexor closed 5 years ago

Filexor commented 5 years ago

See attached file for information. If you load motion to camera with default settings, crash happens at 26th frame. CameraMotion.zip

powroupi commented 5 years ago

Thank you for reporting this issue. :smile:

You may modify mmd_tools/properties/camera.py#L12 to see if it works or not. It was a temporary fix for old Blender 2.8 daily build in #196, so now I want to wait for Blender 2.8 final relase before fixing these issues. :)

if bpy.app.version < (2, 80, 0) or 1: # <-- modify this line
    def __update_depsgraph(cam, data_prop_name):
        pass
nagadomi commented 5 years ago

A related report. cam.data.lens is set via theMMDCamera.Angle, but when using CONSTANT Interpolation (I converted camera to 60FPS) it didn't work correctly with animation rendering mode(render(animation=True)). The lens of the camera was changed after the frame was rendered. It works fine when rendering 1 frame on GUI.

I am not sure if it is a 2.8 issue or it should set the driver directly to cam.data.lens. I used the following quick-fix script.

import bpy
import math

def my_camera_handler(scene):
    cf = scene.frame_current
    mmd_cam = bpy.data.objects["MMD_Camera"]
    cam = bpy.data.objects["Camera"]
    angle = mmd_cam.animation_data.action.fcurves[9].evaluate(cf)
    lens = cam.data.sensor_height/math.tan(angle/2)/2
    if (abs(cam.data.lens - lens) > 0.0001):
        cam.data.lens = lens

bpy.app.handlers.frame_change_pre.clear()
bpy.app.handlers.frame_change_pre.append(my_camera_handler)
powroupi commented 5 years ago

Okay, I've updated mmd_tools, it should work on RC2 now. :smile: (1 frame delay issue is not tested :P )