Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScenePicker is no longer created everytime we pick something #2805

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions src/appleseed.studio/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,9 @@ void MainWindow::start_rendering(const RenderingMode rendering_mode)
rendering_mode == RenderingMode::InteractiveRendering ? "interactive" : "final";
const ParamArray params = get_project_params(configuration_name);

if (!project->has_texture_store())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to manually initialize the texture store before a render is a big problem. In fact, you haven't updated all the other places where we start a render, meaning that rendering there is now broken (appleseed.cli, appleseed.bench, Max plugin, Maya plugin, Blender plugin, Gaffer integration and possibly many others).

project->initialize_texture_store(params.child("texture_store"));

// Effectively start rendering.
m_rendering_manager.start_rendering(
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ namespace appleseed {
namespace studio {

MaterialDropHandler::MaterialDropHandler(
const renderer::Project& project,
RenderingManager& rendering_manager)
const renderer::Project& project,
RenderingManager& rendering_manager)
: m_project(project), m_rendering_manager(rendering_manager)
{
}

void MaterialDropHandler::slot_material_dropped(
const foundation::Vector2d& drop_pos,
const QString& material_name)
const foundation::Vector2d& drop_pos,
const QString& material_name)
{
m_drop_pos = drop_pos;
m_material_name = material_name.toStdString();
Expand Down
16 changes: 8 additions & 8 deletions src/appleseed.studio/mainwindow/rendering/materialdrophandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ class MaterialDropHandler

public:
MaterialDropHandler(
const renderer::Project& project,
RenderingManager& rendering_manager);
const renderer::Project& project,
RenderingManager& rendering_manager);

public slots:
void slot_material_dropped(
const foundation::Vector2d& drop_pos,
const QString& material_name);
const foundation::Vector2d& drop_pos,
const QString& material_name);

private:
const renderer::Project& m_project;
RenderingManager& m_rendering_manager;
foundation::Vector2d m_drop_pos;
std::string m_material_name;
const renderer::Project& m_project;
RenderingManager& m_rendering_manager;
foundation::Vector2d m_drop_pos;
std::string m_material_name;

void assign_material(const renderer::ObjectInstance::Side side);

Expand Down
1 change: 0 additions & 1 deletion src/appleseed.studio/mainwindow/rendering/rendertab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ void RenderTab::recreate_handlers()
// Set initial state.
m_pixel_inspector_handler->set_enabled(false);
m_camera_controller->set_enabled(false);
m_scene_picking_handler->set_enabled(true);
achalpandeyy marked this conversation as resolved.
Show resolved Hide resolved
}

} // namespace studio
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/string/internedstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace foundation
//
// There are also some disadvantages:
//
// - Constructing an interned string can be slower that a normal string.
// - Constructing an interned string can be slower than a normal string.
dictoon marked this conversation as resolved.
Show resolved Hide resolved
// - Memory for the string characters is never freed.
//
// This implementation relies internally on OpenImageIO's ustring class.
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/renderer/device/cpu/cpurenderdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CPURenderDevice::CPURenderDevice(
Project& project,
const ParamArray& params)
: RenderDeviceBase(project, params)
, m_texture_store(*project.get_scene(), params.child("texture_store"))
, m_texture_store(project.get_texture_store())
{
m_error_handler = new OIIOErrorHandler();
#ifndef NDEBUG
Expand Down
4 changes: 2 additions & 2 deletions src/appleseed/renderer/device/cpu/cpurenderdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
// appleseed.renderer headers.
#include "renderer/device/cpu/cpurendercontext.h"
#include "renderer/device/renderdevicebase.h"
#include "renderer/kernel/texturing/texturestore.h"
#include "renderer/modeling/shadergroup/shadercompiler.h"

// appleseed.foundation headers.
Expand All @@ -47,6 +46,7 @@ namespace renderer { class OIIOTextureSystem; }
namespace renderer { class OSLShadingSystem; }
namespace renderer { class RendererComponents; }
namespace renderer { class RendererServices; }
namespace renderer { class TextureStore; }

namespace renderer
{
Expand Down Expand Up @@ -99,7 +99,7 @@ class CPURenderDevice
RendererServices* m_renderer_services;
OSLShadingSystem* m_shading_system;
foundation::auto_release_ptr<ShaderCompiler> m_osl_compiler;
TextureStore m_texture_store;
TextureStore& m_texture_store;
std::unique_ptr<RendererComponents> m_components;
};

Expand Down
15 changes: 8 additions & 7 deletions src/appleseed/renderer/kernel/intersection/assemblytree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "renderer/modeling/object/meshobject.h"
#include "renderer/modeling/object/object.h"
#include "renderer/modeling/object/proceduralobject.h"
#include "renderer/modeling/project/project.h"
#include "renderer/modeling/scene/assemblyinstance.h"
#include "renderer/modeling/scene/objectinstance.h"
#include "renderer/modeling/scene/scene.h"
Expand Down Expand Up @@ -77,9 +78,9 @@ namespace renderer
// AssemblyTree class implementation.
//

AssemblyTree::AssemblyTree(const Scene& scene)
AssemblyTree::AssemblyTree(const Project& project)
: TreeType(AlignedAllocator<void>(System::get_l1_data_cache_line_size()))
, m_scene(scene)
, m_project(project)
dictoon marked this conversation as resolved.
Show resolved Hide resolved
#ifdef APPLESEED_WITH_EMBREE
, m_use_embree(false)
, m_dirty(false)
Expand Down Expand Up @@ -163,7 +164,7 @@ void AssemblyTree::rebuild_assembly_tree()
RENDERER_LOG_INFO("collecting assembly instances...");
AABBVector assembly_instance_bboxes;
collect_assembly_instances(
m_scene.assembly_instances(),
m_project.get_scene()->assembly_instances(),
TransformSequence(),
assembly_instance_bboxes);

Expand All @@ -185,7 +186,7 @@ void AssemblyTree::rebuild_assembly_tree()
Builder builder;
builder.build<DefaultWallclockTimer>(*this, partitioner, m_items.size(), AssemblyTreeMaxLeafSize);
statistics.insert_time("build time", builder.get_build_time());
statistics.merge(bvh::TreeStatistics<AssemblyTree>(*this, AABB3d(m_scene.compute_bbox())));
statistics.merge(bvh::TreeStatistics<AssemblyTree>(*this, AABB3d(m_project.get_scene()->compute_bbox())));

if (!m_items.empty())
{
Expand Down Expand Up @@ -407,7 +408,7 @@ void AssemblyTree::create_triangle_tree(const Assembly& assembly)
std::unique_ptr<ILazyFactory<TriangleTree>> triangle_tree_factory(
new TriangleTreeFactory(
TriangleTree::Arguments(
m_scene,
m_project,
assembly.get_uid(),
assembly_bbox,
assembly)));
Expand Down Expand Up @@ -435,7 +436,7 @@ void AssemblyTree::create_curve_tree(const Assembly& assembly)
std::unique_ptr<ILazyFactory<CurveTree>> curve_tree_factory(
new CurveTreeFactory(
CurveTree::Arguments(
m_scene,
*m_project.get_scene(),
assembly.get_uid(),
assembly_bbox,
assembly)));
Expand Down Expand Up @@ -473,7 +474,7 @@ void AssemblyTree::create_embree_scene(const Assembly& assembly)
std::unique_ptr<ILazyFactory<EmbreeScene>> embree_scene_factory(
new EmbreeSceneFactory(
EmbreeScene::Arguments(
m_scene.get_embree_device(),
m_project.get_scene()->get_embree_device(),
assembly
)));

Expand Down
6 changes: 3 additions & 3 deletions src/appleseed/renderer/kernel/intersection/assemblytree.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
// Forward declarations.
namespace foundation { class Statistics; }
namespace renderer { class AssemblyInstance; }
namespace renderer { class Scene; }
namespace renderer { class Project; }
namespace renderer { class ShadingPoint; }

namespace renderer
Expand All @@ -77,7 +77,7 @@ class AssemblyTree
{
public:
// Constructor, builds the tree for a given scene.
explicit AssemblyTree(const Scene& scene);
explicit AssemblyTree(const Project& project);

// Destructor.
~AssemblyTree();
Expand Down Expand Up @@ -126,7 +126,7 @@ class AssemblyTree
typedef std::vector<const Assembly*> AssemblyVector;
typedef std::map<foundation::UniqueID, foundation::VersionID> AssemblyVersionMap;

const Scene& m_scene;
const Project& m_project;
ItemVector m_items;
AssemblyVersionMap m_assembly_versions;

Expand Down
6 changes: 3 additions & 3 deletions src/appleseed/renderer/kernel/intersection/tracecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace renderer
// TraceContext class implementation.
//

TraceContext::TraceContext(const Scene& scene)
: m_scene(scene)
, m_assembly_tree(new AssemblyTree(scene))
TraceContext::TraceContext(const Project& project)
: m_project(project)
, m_assembly_tree(new AssemblyTree(project))
{
RENDERER_LOG_DEBUG(
"data structures size:\n"
Expand Down
9 changes: 6 additions & 3 deletions src/appleseed/renderer/kernel/intersection/tracecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"

// appleseed.renderer headers.
#include "renderer/modeling/project/project.h"

// appleseed.main headers.
#include "main/dllsymbol.h"

Expand All @@ -54,7 +57,7 @@ class APPLESEED_DLLSYMBOL TraceContext
{
public:
// Constructor, initializes the trace context for a given scene.
explicit TraceContext(const Scene& scene);
explicit TraceContext(const Project& project);
dictoon marked this conversation as resolved.
Show resolved Hide resolved

// Destructor.
~TraceContext();
Expand All @@ -73,7 +76,7 @@ class APPLESEED_DLLSYMBOL TraceContext
#endif

private:
const Scene& m_scene;
const Project& m_project;
AssemblyTree* m_assembly_tree;
};

Expand All @@ -84,7 +87,7 @@ class APPLESEED_DLLSYMBOL TraceContext

inline const Scene& TraceContext::get_scene() const
{
return m_scene;
return *m_project.get_scene();
}

inline const AssemblyTree& TraceContext::get_assembly_tree() const
Expand Down
8 changes: 4 additions & 4 deletions src/appleseed/renderer/kernel/intersection/triangletree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include "renderer/modeling/object/meshobject.h"
#include "renderer/modeling/object/object.h"
#include "renderer/modeling/object/triangle.h"
#include "renderer/modeling/project/project.h"
#include "renderer/modeling/scene/assembly.h"
#include "renderer/modeling/scene/containers.h"
#include "renderer/modeling/scene/objectinstance.h"
Expand Down Expand Up @@ -383,11 +384,11 @@ namespace
}

TriangleTree::Arguments::Arguments(
const Scene& scene,
const Project& project,
const UniqueID triangle_tree_uid,
const GAABB3& bbox,
const Assembly& assembly)
: m_scene(scene)
: m_project(project)
, m_triangle_tree_uid(triangle_tree_uid)
, m_bbox(bbox)
, m_assembly(assembly)
Expand Down Expand Up @@ -1262,8 +1263,7 @@ void TriangleTree::update_intersection_filters()
object_instances_to_filter_keys);

// Create missing intersection filters and update existing ones.
TextureStore texture_store(m_arguments.m_scene);
TextureCache texture_cache(texture_store);
TextureCache texture_cache(m_arguments.m_project.get_texture_store());
create_missing_intersection_filters(
texture_cache,
filter_keys,
Expand Down
6 changes: 3 additions & 3 deletions src/appleseed/renderer/kernel/intersection/triangletree.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace foundation { class Statistics; }
namespace renderer { class Assembly; }
namespace renderer { class IntersectionFilter; }
namespace renderer { class ParamArray; }
namespace renderer { class Scene; }
namespace renderer { class Project; }
namespace renderer { class ShadingPoint; }

namespace renderer
Expand All @@ -83,14 +83,14 @@ class TriangleTree
// Construction arguments.
struct Arguments
{
const Scene& m_scene;
const Project& m_project;
const foundation::UniqueID m_triangle_tree_uid;
const GAABB3 m_bbox;
const Assembly& m_assembly;

// Constructor.
Arguments(
const Scene& scene,
const Project& project,
const foundation::UniqueID triangle_tree_uid,
const GAABB3& bbox,
const Assembly& assembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ BackwardLightSampler::BackwardLightSampler(
}
else
{
// Prepare the light-emitting shapes CDF for smapling.
// Prepare the light-emitting shapes CDF for sampling.
if (m_emitting_shapes_cdf.valid())
m_emitting_shapes_cdf.prepare();

Expand Down
8 changes: 5 additions & 3 deletions src/appleseed/renderer/kernel/rendering/scenepicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "renderer/kernel/intersection/tracecontext.h"
#include "renderer/kernel/shading/shadingray.h"
#include "renderer/kernel/texturing/texturecache.h"
#include "renderer/kernel/texturing/texturestore.h"
#include "renderer/modeling/bsdf/bsdftraits.h"
#include "renderer/modeling/bssrdf/bssrdftraits.h"
#include "renderer/modeling/camera/camera.h"
Expand All @@ -57,6 +56,9 @@
#include <cstddef>
#include <limits>

// Forward declarations.
namespace renderer { class TextureStore; }

using namespace foundation;

namespace renderer
Expand All @@ -66,14 +68,14 @@ struct ScenePicker::Impl
{
const Project& m_project;
const TraceContext& m_trace_context;
TextureStore m_texture_store;
TextureStore& m_texture_store;
TextureCache m_texture_cache;
Intersector m_intersector;

explicit Impl(const Project& project)
: m_project(project)
, m_trace_context(m_project.get_trace_context())
, m_texture_store(m_trace_context.get_scene())
, m_texture_store(m_project.get_texture_store())
, m_texture_cache(m_texture_store)
, m_intersector(m_trace_context, m_texture_cache)
{
Expand Down
10 changes: 6 additions & 4 deletions src/appleseed/renderer/meta/tests/test_intersector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "renderer/kernel/shading/shadingpoint.h"
#include "renderer/kernel/shading/shadingray.h"
#include "renderer/kernel/texturing/texturecache.h"
#include "renderer/kernel/texturing/texturestore.h"
#include "renderer/modeling/object/object.h"
#include "renderer/modeling/scene/assembly.h"
#include "renderer/modeling/scene/assemblyinstance.h"
Expand All @@ -53,6 +52,9 @@
#include "foundation/memory/autoreleaseptr.h"
#include "foundation/utility/test.h"

// Forward declarations.
namespace renderer { class TextureStore; }

using namespace foundation;
using namespace renderer;

Expand Down Expand Up @@ -96,13 +98,13 @@ TEST_SUITE(Renderer_Kernel_Intersection_Intersector)
: public StaticTestSceneContext<TestScene>
{
TraceContext m_trace_context;
TextureStore m_texture_store;
TextureStore& m_texture_store;
TextureCache m_texture_cache;
Intersector m_intersector;

Fixture()
: m_trace_context(m_scene)
, m_texture_store(m_scene)
: m_trace_context(m_project)
, m_texture_store(m_project.get_texture_store())
, m_texture_cache(m_texture_store)
, m_intersector(m_trace_context, m_texture_cache)
{
Expand Down
Loading