diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-06-13 15:25:36 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-06-13 15:25:36 +0400 |
commit | 74a85df0c1fa9b564f128b71898777c9b826c0fd (patch) | |
tree | 3e2eb8e8867144a5376a82167233f9b65140bcbd /intern/cycles/blender | |
parent | 5e2a9a261bbffdb01bd8fffbc41c02163b97596e (diff) |
Fix cycles crash when viewport camera border goes out of view.
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_camera.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 122d0bd7c17..46d5fefd4dc 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -485,10 +485,10 @@ static void blender_camera_border(BlenderCamera *bcam, BL::Scene b_scene, BL::Sp bcam->border_top = tmp_bottom + bcam->border_top*(tmp_top - tmp_bottom); /* clamp */ - bcam->border_left = max(bcam->border_left, 0.0f); - bcam->border_right = min(bcam->border_right, 1.0f); - bcam->border_bottom = max(bcam->border_bottom, 0.0f); - bcam->border_top = min(bcam->border_top, 1.0f); + bcam->border_left = clamp(bcam->border_left, 0.0f, 1.0f); + bcam->border_right = clamp(bcam->border_right, 0.0f, 1.0f); + bcam->border_bottom = clamp(bcam->border_bottom, 0.0f, 1.0f); + bcam->border_top = clamp(bcam->border_top, 0.0f, 1.0f); } void BlenderSync::sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height) @@ -514,6 +514,10 @@ BufferParams BlenderSync::get_buffer_params(BL::Scene b_scene, Camera *cam, int params.full_y = cam->border_bottom*height; params.width = (int)(cam->border_right*width) - params.full_x; params.height = (int)(cam->border_top*height) - params.full_y; + + /* survive in case border goes out of view or becomes too small */ + params.width = max(params.width, 1); + params.height = max(params.height, 1); } else { params.width = width; |