Skip to content

Commit

Permalink
Merge pull request #26 from murraystevenson/cropwindow
Browse files Browse the repository at this point in the history
Crop window support
  • Loading branch information
boberfly authored Oct 27, 2019
2 parents 8d36cf3 + ca96159 commit e4ec1f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 12 additions & 1 deletion src/GafferCycles/IECoreCyclesPreview/CameraAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,18 @@ ccl::Camera *convertCommon( const IECoreScene::Camera *camera, const std::string
const Imath::V2f &clippingPlanes = camera->getClippingPlanes();
ccam->nearclip = clippingPlanes.x;
ccam->farclip = clippingPlanes.y;


// Crop window
if ( camera->hasCropWindow() )
{
const Imath::Box2f &cropWindow = camera->getCropWindow();
ccam->border.left = cropWindow.min.x;
ccam->border.right = cropWindow.max.x;
ccam->border.top = cropWindow.max.y;
ccam->border.bottom = cropWindow.min.y;
ccam->border.clamp();
}

// Shutter TODO: Need to see if this is correct or not, cycles also has a shutter curve...
const Imath::V2f &shutter = camera->getShutter();
if ((shutter.x > 0.0) && (shutter.y > 0.0))
Expand Down
12 changes: 6 additions & 6 deletions src/GafferCycles/IECoreCyclesPreview/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ class CyclesOutput : public IECore::RefCounted
V2i( camera->width - 1, camera->height - 1 )
);
Box2i dataWindow(
V2i( 0, 0 ),
V2i( camera->width - 1, camera->height - 1 )
V2i( (int)(camera->border.left * (float)camera->width), (int)(camera->border.bottom * (float)camera->height) ),
V2i( (int)(camera->border.right * (float)camera->width) - 1, (int)(camera->border.top * (float)camera->height - 1 ) )
);

vector<string> channelNames;
Expand Down Expand Up @@ -514,8 +514,8 @@ class RenderCallback : public IECore::RefCounted
V2i( camera->width - 1, camera->height - 1 )
);
Box2i dataWindow(
V2i( 0, 0 ),
V2i( camera->width - 1, camera->height - 1 )
V2i( (int)(camera->border.left * (float)camera->width), (int)(camera->border.bottom * (float)camera->height) ),
V2i( (int)(camera->border.right * (float)camera->width) - 1, (int)(camera->border.top * (float)camera->height - 1 ) )
);

//CompoundDataPtr parameters = new CompoundData();
Expand Down Expand Up @@ -633,8 +633,8 @@ class RenderCallback : public IECore::RefCounted
IECore::msg( IECore::Msg::Warning, "CyclesRenderer::CyclesOutput", "No interactive outputs to render to." );
return;
}
const int x = rtile.x - m_session->tile_manager.params.full_x;
const int y = rtile.y - m_session->tile_manager.params.full_y;
const int x = rtile.x;
const int y = rtile.y;
const int w = rtile.w;
const int h = rtile.h;

Expand Down

0 comments on commit e4ec1f3

Please sign in to comment.