Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

#include "IECore/CompoundData.h"

#include "IECoreAppleseed/private/RendererController.h"

namespace IECoreAppleseed
{

Expand All @@ -70,8 +72,6 @@ class EditBlockHandler : boost::noncopyable

private :

class RendererController;

renderer::Project &m_project;
std::auto_ptr<RendererController> m_rendererController;
std::auto_ptr<renderer::MasterRenderer> m_renderer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
//////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2015, Esteban Tovagliari. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// * Neither the name of Image Engine Design nor the names of any
// other contributors to this software may be used to endorse or
// promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef IECOREAPPLESEED_RENDERERCONTROLLER_H
#define IECOREAPPLESEED_RENDERERCONTROLLER_H

#include "tbb/atomic.h"

#include "renderer/api/rendering.h"

namespace IECoreAppleseed
{

class RendererController : public renderer::DefaultRendererController
{
public :

RendererController()
{
m_status = ContinueRendering;
}

virtual Status get_status() const
{
return m_status;
}

void set_status( Status status )
{
m_status = status;
}

private :

tbb::atomic<Status> m_status;
};

} // namespace IECoreAppleseed

#endif // IECOREAPPLESEED_RENDERERCONTROLLER_H
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class RendererImplementation : public IECore::Renderer

void constructCommon();

bool isInteractive() const;
bool isProjectGen() const;
bool isEditable() const;

void setCamera( const std::string &name, IECore::CameraPtr cortexCamera,
foundation::auto_release_ptr<renderer::Camera> &camera );
Expand Down
26 changes: 0 additions & 26 deletions contrib/IECoreAppleseed/src/IECoreAppleseed/EditBlockHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@

#include <cassert>

#include "tbb/atomic.h"

#include "IECore/MessageHandler.h"
#include "IECore/SimpleTypedData.h"

Expand All @@ -50,30 +48,6 @@ using namespace std;
namespace asf = foundation;
namespace asr = renderer;

class IECoreAppleseed::EditBlockHandler::RendererController : public asr::DefaultRendererController
{
public :

RendererController()
{
m_status = ContinueRendering;
}

virtual Status get_status() const
{
return m_status;
}

void set_status( Status status )
{
m_status = status;
}

private :

tbb::atomic<Status> m_status;
};

IECoreAppleseed::EditBlockHandler::EditBlockHandler( asr::Project &project )
: m_project( project )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "IECoreAppleseed/private/LogTarget.h"
#include "IECoreAppleseed/private/BatchPrimitiveConverter.h"
#include "IECoreAppleseed/private/InteractivePrimitiveConverter.h"
#include "IECoreAppleseed/private/RendererController.h"
#include "IECoreAppleseed/ToAppleseedCameraConverter.h"

using namespace IECore;
Expand Down Expand Up @@ -92,11 +93,15 @@ IECoreAppleseed::RendererImplementation::RendererImplementation()

m_primitiveConverter.reset( new InteractivePrimitiveConverter( m_project->search_paths() ) );
m_motionHandler.reset( new MotionBlockHandler( m_transformStack, *m_primitiveConverter ) );
m_editHandler.reset( new EditBlockHandler( *m_project ) );
}

IECoreAppleseed::RendererImplementation::RendererImplementation( const string &fileName )
{
if( fileName.empty() )
{
msg( MessageHandler::Error, "IECoreAppleseed::RendererImplementation::RendererImplementation", "Empty project filename" );
}

m_fileName = fileName;
m_projectPath = filesystem::path( fileName ).parent_path();

Expand Down Expand Up @@ -233,10 +238,7 @@ void IECoreAppleseed::RendererImplementation::setOption( const string &name, Con

// if the number of passes is greater than one, we need to
// switch the shading result framebuffer in the final rendering config.
if( !isInteractive() )
{
m_project->configurations().get_by_name( "final" )->get_parameters().insert( "shading_result_framebuffer", numPasses > 1 ? "permanent" : "ephemeral" );
}
m_project->configurations().get_by_name( "final" )->get_parameters().insert( "shading_result_framebuffer", numPasses > 1 ? "permanent" : "ephemeral" );

// enable decorrelate pixels if the number of render passes is greater than one.
m_project->configurations().get_by_name( "final" )->get_parameters().insert_path( "uniform_pixel_renderer.decorrelate_pixels", numPasses > 1 ? "true" : "false" );
Expand Down Expand Up @@ -284,7 +286,21 @@ void IECoreAppleseed::RendererImplementation::setOption( const string &name, Con
}
else if( name == "editable" )
{
// ignore
if( const BoolData *editableData = runTimeCast<const BoolData>( value.get() ) )
{
if( editableData->readable() )
{
m_editHandler.reset( new EditBlockHandler( *m_project ) );
}
else
{
m_editHandler.reset();
}
}
else
{
msg( Msg::Error, "IECoreAppleseed::RendererImplementation::setOption", "editable option expects an BoolData value." );
}
}
else
{
Expand Down Expand Up @@ -449,14 +465,23 @@ void IECoreAppleseed::RendererImplementation::worldEnd()
asf::auto_release_ptr<asr::AssemblyInstance> assemblyInstance = asr::AssemblyInstanceFactory::create( "assembly_inst", asr::ParamArray(), "assembly" );
m_project->get_scene()->assembly_instances().insert( assemblyInstance );

if( isInteractive() )
// render or export the project
if( isEditable() )
{
m_editHandler->startRendering();
}
else
else if( isProjectGen() )
{
asr::ProjectFileWriter::write( *m_project, m_fileName.c_str(), asr::ProjectFileWriter::OmitBringingAssets | asr::ProjectFileWriter::OmitWritingGeometryFiles );
}
else
{
// interactive non-editable render.
RendererController rendererController;
asr::Configuration *cfg = m_project->configurations().get_by_name( "final" );
asr::MasterRenderer renderer( *m_project, cfg->get_parameters(), &rendererController);
renderer.render();
}
}

/////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -787,7 +812,7 @@ DataPtr IECoreAppleseed::RendererImplementation::command( const string &name, co

void IECoreAppleseed::RendererImplementation::editBegin( const string &editType, const CompoundDataMap &parameters )
{
if( isInteractive() )
if( isEditable() )
{
m_transformStack.clear();

Expand All @@ -813,7 +838,7 @@ void IECoreAppleseed::RendererImplementation::editBegin( const string &editType,

void IECoreAppleseed::RendererImplementation::editEnd()
{
if( isInteractive() )
if( isEditable() )
{
m_editHandler->editEnd();
}
Expand All @@ -827,9 +852,14 @@ void IECoreAppleseed::RendererImplementation::editEnd()
// private
/////////////////////////////////////////////////////////////////////////////////////////

bool IECoreAppleseed::RendererImplementation::isInteractive() const
bool IECoreAppleseed::RendererImplementation::isProjectGen() const
{
return !m_fileName.empty();
}

bool IECoreAppleseed::RendererImplementation::isEditable() const
{
return m_fileName.empty();
return m_editHandler.get();
}

void IECoreAppleseed::RendererImplementation::setCamera( const string &name, CameraPtr cortexCamera,
Expand Down