forked from blender/blender
Fix review comments 2 #31
@ -57,33 +57,12 @@ void PreviewEngine::sync(Depsgraph *depsgraph,
|
|||||||
|
|
||||||
void PreviewEngine::render(Depsgraph *depsgraph)
|
void PreviewEngine::render(Depsgraph *depsgraph)
|
||||||
{
|
{
|
||||||
const Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
prepare_for_render(depsgraph);
|
||||||
const ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
|
|
||||||
|
|
||||||
std::string layer_name = view_layer->name;
|
|
||||||
pxr::GfVec2i res(scene->r.xsch, scene->r.ysch);
|
|
||||||
|
|
||||||
pxr::GfCamera camera =
|
|
||||||
CameraData(scene->camera, res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(pxr::GfVec4f(0, 0, 1, 1));
|
|
||||||
|
|
||||||
free_camera_delegate_->SetCamera(camera);
|
|
||||||
render_task_delegate_->set_camera_and_viewport(free_camera_delegate_->GetCameraId(),
|
|
||||||
pxr::GfVec4d(0, 0, res[0], res[1]));
|
|
||||||
render_task_delegate_->set_renderer_aov(pxr::HdAovTokens->color);
|
|
||||||
|
|
||||||
pxr::HdTaskSharedPtrVector tasks;
|
|
||||||
if (simple_light_task_delegate_) {
|
|
||||||
tasks.push_back(simple_light_task_delegate_->get_task());
|
|
||||||
}
|
|
||||||
tasks.push_back(render_task_delegate_->get_task());
|
|
||||||
|
|
||||||
std::vector<float> pixels = std::vector<float>(res[0] * res[1] *
|
|
||||||
4); /* 4 - number of channels. */
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Release the GIL before calling into hydra, in case any hydra plugins call into python. */
|
/* Release the GIL before calling into hydra, in case any hydra plugins call into python. */
|
||||||
pxr::TF_PY_ALLOW_THREADS_IN_SCOPE();
|
pxr::TF_PY_ALLOW_THREADS_IN_SCOPE();
|
||||||
engine_->Execute(render_index_.get(), &tasks);
|
engine_->Execute(render_index_.get(), &tasks_);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
@ -94,13 +73,13 @@ void PreviewEngine::render(Depsgraph *depsgraph)
|
|||||||
if (render_task_delegate_->is_converged()) {
|
if (render_task_delegate_->is_converged()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels.data());
|
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_->data());
|
||||||
update_render_result(layer_name, res[0], res[1], pixels);
|
update_render_result(layer_name_, resolution_[0], resolution_[1], pixels_);
|
||||||
}
|
}
|
||||||
|
|
||||||
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels.data());
|
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_->data());
|
||||||
update_render_result(layer_name, res[0], res[1], pixels);
|
update_render_result(layer_name_, resolution_[0], resolution_[1], pixels_);
|
||||||
}
|
}
|
||||||
|
|
||||||
double PreviewEngine::free_instance(uintptr_t uuid, void *user_data)
|
double PreviewEngine::free_instance(uintptr_t uuid, void *user_data)
|
||||||
@ -124,14 +103,14 @@ void PreviewEngine::update(RenderEngine *bl_engine, const std::string &render_de
|
|||||||
void PreviewEngine::update_render_result(const std::string &layer_name,
|
void PreviewEngine::update_render_result(const std::string &layer_name,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
std::vector<float> &pixels)
|
std::vector<float> *pixels)
|
||||||
{
|
{
|
||||||
RenderResult *result = RE_engine_begin_result(
|
RenderResult *result = RE_engine_begin_result(
|
||||||
bl_engine_, 0, 0, width, height, layer_name.c_str(), nullptr);
|
bl_engine_, 0, 0, width, height, layer_name.c_str(), nullptr);
|
||||||
|
|
||||||
RenderLayer *layer = (RenderLayer *)result->layers.first;
|
RenderLayer *layer = (RenderLayer *)result->layers.first;
|
||||||
RenderPass *pass = (RenderPass *)layer->passes.first;
|
RenderPass *pass = (RenderPass *)layer->passes.first;
|
||||||
memcpy(pass->rect, pixels.data(), sizeof(float) * pass->rectx * pass->recty * pass->channels);
|
memcpy(pass->rect, pixels->data(), sizeof(float) * pass->rectx * pass->recty * pass->channels);
|
||||||
|
|
||||||
RE_engine_end_result(bl_engine_, result, false, false, false);
|
RE_engine_end_result(bl_engine_, result, false, false, false);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class PreviewEngine : public FinalEngine {
|
|||||||
void update_render_result(const std::string &layer_name,
|
void update_render_result(const std::string &layer_name,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
std::vector<float> &pixels);
|
std::vector<float> *pixels);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace blender::render::hydra
|
} // namespace blender::render::hydra
|
||||||
|
Loading…
Reference in New Issue
Block a user