Skip to content

Commit aaedfad

Browse files
committed
Fixed transformation segments over 2. Simplified shutter logic on cameras.
1 parent 92afceb commit aaedfad

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

src/GafferCycles/IECoreCyclesPreview/CameraAlgo.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,18 @@ ccl::Camera *convertCommon( const IECoreScene::Camera *camera, const std::string
113113

114114
// Shutter TODO: Need to see if this is correct or not, cycles also has a shutter curve...
115115
const Imath::V2f &shutter = camera->getShutter();
116-
if ((shutter.x > 0.0) && (shutter.y > 0.0))
116+
ccam->shuttertime = abs(shutter.x) + abs(shutter.y);
117+
if( (shutter.x == 0.0) && (shutter.y > shutter.x) )
117118
{
118119
ccam->motion_position = ccl::Camera::MOTION_POSITION_START;
119-
ccam->shuttertime = shutter.x + shutter.y;
120120
}
121-
else if ((shutter.x < 0.0) && (shutter.y > 0.0))
122-
{
123-
ccam->motion_position = ccl::Camera::MOTION_POSITION_CENTER;
124-
ccam->shuttertime = abs(shutter.x) + shutter.y;
125-
}
126-
else if ((shutter.x < 0.0) && (shutter.y <= 0.0))
121+
else if( (shutter.x < shutter.y) && (shutter.y == 0.0) )
127122
{
128123
ccam->motion_position = ccl::Camera::MOTION_POSITION_END;
129-
ccam->shuttertime = abs(shutter.x) + abs(shutter.y);
130124
}
131125
else
132126
{
133127
ccam->motion_position = ccl::Camera::MOTION_POSITION_CENTER;
134-
ccam->shuttertime = 1.0;
135128
}
136129

137130
for( CompoundDataMap::const_iterator it = camera->parameters().begin(), eIt = camera->parameters().end(); it != eIt; ++it )

src/GafferCycles/IECoreCyclesPreview/Renderer.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,7 +2463,8 @@ class CyclesObject : public IECoreScenePreview::Renderer::ObjectInterface
24632463

24642464
if( object->mesh->use_motion_blur )
24652465
{
2466-
object->motion = ccl::array<ccl::Transform>( object->mesh->motion_steps );
2466+
object->motion.clear();
2467+
object->motion.resize( object->mesh->motion_steps, ccl::transform_empty() );
24672468
for( int i = 0; i < object->motion.size(); ++i )
24682469
{
24692470
object->motion[i] = object->tfm;
@@ -2486,7 +2487,7 @@ class CyclesObject : public IECoreScenePreview::Renderer::ObjectInterface
24862487
{
24872488
IECore::msg( IECore::Msg::Error, "IECoreCycles::Renderer", boost::format( "Transform step size on \"%s\" must match deformation step size." ) % object->name.c_str() );
24882489
object->tfm = SocketAlgo::setTransform( samples.front() );
2489-
object->motion = ccl::array<ccl::Transform>( object->mesh->motion_steps );
2490+
object->motion.resize( object->mesh->motion_steps, ccl::transform_empty() );
24902491
for( int i = 0; i < object->motion.size(); ++i )
24912492
{
24922493
object->motion[i] = object->tfm;
@@ -2513,7 +2514,7 @@ class CyclesObject : public IECoreScenePreview::Renderer::ObjectInterface
25132514

25142515
if( numSamples % 2 ) // Odd numSamples
25152516
{
2516-
object->motion = ccl::array<ccl::Transform>( numSamples );
2517+
object->motion.resize( numSamples, ccl::transform_empty() );
25172518

25182519
for( int i = 0; i < numSamples; ++i )
25192520
{
@@ -2528,7 +2529,7 @@ class CyclesObject : public IECoreScenePreview::Renderer::ObjectInterface
25282529
else if( numSamples == 2 )
25292530
{
25302531
Imath::M44f matrix;
2531-
object->motion = ccl::array<ccl::Transform>( numSamples+1 );
2532+
object->motion.resize( numSamples+1, ccl::transform_empty() );
25322533
IECore::LinearInterpolator<Imath::M44f>()( samples[0], samples[1], 0.5f, matrix );
25332534

25342535
if( frameIdx == -1 ) // Center frame
@@ -2549,7 +2550,7 @@ class CyclesObject : public IECoreScenePreview::Renderer::ObjectInterface
25492550
}
25502551
else // Even numSamples
25512552
{
2552-
object->motion = ccl::array<ccl::Transform>( numSamples );
2553+
object->motion.resize( numSamples, ccl::transform_empty() );
25532554

25542555
if( frameIdx == -1 ) // Center frame
25552556
{
@@ -2573,6 +2574,11 @@ class CyclesObject : public IECoreScenePreview::Renderer::ObjectInterface
25732574
}
25742575
}
25752576

2577+
if( !object->mesh->use_motion_blur )
2578+
{
2579+
object->mesh->motion_steps = object->motion.size();
2580+
}
2581+
25762582
if( object->mesh->subd_params )
25772583
{
25782584
object->mesh->subd_params->objecttoworld = object->tfm;

0 commit comments

Comments
 (0)