forked from blender/blender
BLEN-343: Create PreviewEngine #8
@ -46,7 +46,7 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
||||
delegate_settings = self.get_delegate_settings(engine_type)
|
||||
|
||||
_hydra.engine_sync(self.engine_ptr, depsgraph.as_pointer(), bpy.context.as_pointer(), delegate_settings)
|
||||
_hydra.engine_render(self.engine_ptr, depsgraph.as_pointer(), engine_type)
|
||||
_hydra.engine_render(self.engine_ptr, depsgraph.as_pointer())
|
||||
|
||||
|
||||
# viewport render
|
||||
def view_update(self, context, depsgraph):
|
||||
|
@ -12,7 +12,7 @@ namespace blender::render::hydra {
|
||||
class FinalEngine : public Engine {
|
||||
public:
|
||||
using Engine::Engine;
|
||||
void sync(BL::Depsgraph &b_depsgraph, BL::Context &b_context, pxr::HdRenderSettingsMap &renderSettings) override;
|
||||
virtual void sync(BL::Depsgraph &b_depsgraph, BL::Context &b_context, pxr::HdRenderSettingsMap &renderSettings) override;
|
||||
virtual void render(BL::Depsgraph &b_depsgraph) override;
|
||||
|
||||
protected:
|
||||
|
@ -3,20 +3,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "engine.h"
|
||||
#include "finalEngine.h"
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
class PreviewEngine : public Engine {
|
||||
class PreviewEngine : public FinalEngine {
|
||||
DagerD marked this conversation as resolved
Bogdan Nagirniak
commented
Maybe inherit from FinalEngine? Maybe inherit from FinalEngine?
|
||||
public:
|
||||
using Engine::Engine;
|
||||
using FinalEngine::FinalEngine;
|
||||
void sync(BL::Depsgraph &b_depsgraph, BL::Context &b_context, pxr::HdRenderSettingsMap &renderSettings) override;
|
||||
void render(BL::Depsgraph &b_depsgraph) override;
|
||||
|
||||
protected:
|
||||
pxr::GfVec2i get_resolution(BL::RenderSettings b_render);
|
||||
void updateRenderResult(const std::string &layerName, int width, int height, std::vector<float> &pixels);
|
||||
void notifyStatus(float progress, const std::string &title, const std::string &info);
|
||||
|
||||
protected:
|
||||
HdRenderSettingsMap renderSettings;
|
||||
|
@ -209,20 +209,12 @@ static PyObject *engine_sync_func(PyObject * /*self*/, PyObject *args)
|
||||
static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
PyObject *pyengine, *pydepsgraph;
|
||||
char *engineType;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OOs", &pyengine, &pydepsgraph, &engineType)) {
|
||||
if (!PyArg_ParseTuple(args, "OO", &pyengine, &pydepsgraph)) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Engine *engine;
|
||||
|
||||
if (string(engineType) == "PREVIEW") {
|
||||
engine = (PreviewEngine *)PyLong_AsVoidPtr(pyengine);
|
||||
}
|
||||
else {
|
||||
engine = (FinalEngine *)PyLong_AsVoidPtr(pyengine);
|
||||
}
|
||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||
|
||||
PointerRNA depsgraphptr;
|
||||
RNA_pointer_create(NULL, &RNA_Depsgraph, (ID *)PyLong_AsVoidPtr(pydepsgraph), &depsgraphptr);
|
||||
@ -255,7 +247,7 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args)
|
||||
|
||||
/* Allow Blender to execute other Python scripts. */
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
engine->viewDraw(b_depsgraph, b_context);
|
||||
engine->render(b_depsgraph, b_context);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
Py_RETURN_NONE;
|
||||
|
@ -27,14 +27,6 @@ void BlenderSceneDelegate::set_material(MeshData &mesh_data)
|
||||
mesh_data.material_id = SdfPath::EmptyPath();
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Haven't found any description about this flag. It disables some materials
|
||||
* that don't exist for preview render
|
||||
*/
|
||||
if (!material->flag) {
|
||||
mesh_data.material_id = SdfPath::EmptyPath();
|
||||
return;
|
||||
}
|
||||
SdfPath id = MaterialData::prim_id(this, material);
|
||||
MaterialData *mat_data = material_data(id);
|
||||
if (!mat_data) {
|
||||
|
@ -253,7 +253,7 @@ void ViewportEngine::sync(BL::Depsgraph &b_depsgraph, BL::Context &b_context, Hd
|
||||
}
|
||||
}
|
||||
|
||||
void ViewportEngine::viewDraw(BL::Depsgraph &b_depsgraph, BL::Context &b_context)
|
||||
void ViewportEngine::render(BL::Depsgraph &b_depsgraph, BL::Context &b_context)
|
||||
{
|
||||
ViewSettings viewSettings(b_context);
|
||||
if (viewSettings.width() * viewSettings.height() == 0) {
|
||||
@ -307,7 +307,7 @@ void ViewportEngine::viewDraw(BL::Depsgraph &b_depsgraph, BL::Context &b_context
|
||||
}
|
||||
}
|
||||
|
||||
void ViewportEngine::render(BL::Depsgraph& b_depsgraph)
|
||||
void ViewportEngine::render(BL::Depsgraph &b_depsgraph)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,8 @@ class ViewportEngine : public Engine {
|
||||
public:
|
||||
using Engine::Engine;
|
||||
void sync(BL::Depsgraph &b_depsgraph, BL::Context &b_context, pxr::HdRenderSettingsMap &renderSettings) override;
|
||||
void viewDraw(BL::Depsgraph &b_depsgraph, BL::Context &b_context);
|
||||
void render(BL::Depsgraph &b_depsgraph) override;
|
||||
void render(BL::Depsgraph &b_depsgraph, BL::Context &b_context);
|
||||
|
||||
private:
|
||||
void notifyStatus(const std::string &title, const std::string &info);
|
||||
|
Loading…
Reference in New Issue
Block a user
revert this