forked from blender/blender
Hydra code cleanup #81
@ -13,7 +13,7 @@
|
||||
|
||||
namespace blender::io::hydra {
|
||||
|
||||
CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA_SCENE, "render.hydra.scene");
|
||||
CLG_LOGREF_DECLARE_GLOBAL(LOG_HYDRA_SCENE, "hydra.scene");
|
||||
|
||||
bool HydraSceneDelegate::ShadingSettings::operator==(const ShadingSettings &other)
|
||||
{
|
||||
@ -38,21 +38,21 @@ HydraSceneDelegate::HydraSceneDelegate(pxr::HdRenderIndex *parent_index,
|
||||
|
||||
pxr::HdMeshTopology HydraSceneDelegate::GetMeshTopology(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
MeshData *m_data = mesh_data(id);
|
||||
return m_data->topology(id);
|
||||
}
|
||||
|
||||
pxr::HdBasisCurvesTopology HydraSceneDelegate::GetBasisCurvesTopology(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CurvesData *c_data = curves_data(id);
|
||||
return c_data->topology();
|
||||
};
|
||||
|
||||
pxr::GfMatrix4d HydraSceneDelegate::GetTransform(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
InstancerData *i_data = instancer_data(id, true);
|
||||
if (i_data) {
|
||||
return i_data->transform(id);
|
||||
@ -69,7 +69,7 @@ pxr::GfMatrix4d HydraSceneDelegate::GetTransform(pxr::SdfPath const &id)
|
||||
|
||||
pxr::VtValue HydraSceneDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText());
|
||||
ObjectData *obj_data = object_data(id);
|
||||
if (obj_data) {
|
||||
return obj_data->get_data(id, key);
|
||||
@ -88,7 +88,7 @@ pxr::VtValue HydraSceneDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const
|
||||
pxr::VtValue HydraSceneDelegate::GetLightParamValue(pxr::SdfPath const &id,
|
||||
pxr::TfToken const &key)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %s", id.GetText(), key.GetText());
|
||||
LightData *l_data = light_data(id);
|
||||
if (l_data) {
|
||||
return l_data->get_data(key);
|
||||
@ -99,7 +99,7 @@ pxr::VtValue HydraSceneDelegate::GetLightParamValue(pxr::SdfPath const &id,
|
||||
pxr::HdPrimvarDescriptorVector HydraSceneDelegate::GetPrimvarDescriptors(
|
||||
pxr::SdfPath const &id, pxr::HdInterpolation interpolation)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %d", id.GetText(), interpolation);
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %d", id.GetText(), interpolation);
|
||||
MeshData *m_data = mesh_data(id);
|
||||
if (m_data) {
|
||||
return m_data->primvar_descriptors(interpolation);
|
||||
@ -117,7 +117,7 @@ pxr::HdPrimvarDescriptorVector HydraSceneDelegate::GetPrimvarDescriptors(
|
||||
|
||||
pxr::SdfPath HydraSceneDelegate::GetMaterialId(pxr::SdfPath const &rprim_id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", rprim_id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", rprim_id.GetText());
|
||||
ObjectData *obj_data = object_data(rprim_id);
|
||||
if (obj_data) {
|
||||
return obj_data->material_id(rprim_id);
|
||||
@ -127,7 +127,7 @@ pxr::SdfPath HydraSceneDelegate::GetMaterialId(pxr::SdfPath const &rprim_id)
|
||||
|
||||
pxr::VtValue HydraSceneDelegate::GetMaterialResource(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
MaterialData *mat_data = material_data(id);
|
||||
if (mat_data) {
|
||||
return mat_data->get_material_resource();
|
||||
@ -137,7 +137,7 @@ pxr::VtValue HydraSceneDelegate::GetMaterialResource(pxr::SdfPath const &id)
|
||||
|
||||
bool HydraSceneDelegate::GetVisible(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
if (id == world_prim_id()) {
|
||||
return true;
|
||||
}
|
||||
@ -150,19 +150,19 @@ bool HydraSceneDelegate::GetVisible(pxr::SdfPath const &id)
|
||||
|
||||
bool HydraSceneDelegate::GetDoubleSided(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
return mesh_data(id)->double_sided(id);
|
||||
}
|
||||
|
||||
pxr::HdCullStyle HydraSceneDelegate::GetCullStyle(pxr::SdfPath const &id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", id.GetText());
|
||||
return mesh_data(id)->cull_style(id);
|
||||
}
|
||||
|
||||
pxr::SdfPath HydraSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", prim_id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", prim_id.GetText());
|
||||
InstancerData *i_data = instancer_data(prim_id, true);
|
||||
if (i_data && mesh_data(prim_id)) {
|
||||
return i_data->prim_id;
|
||||
@ -172,7 +172,7 @@ pxr::SdfPath HydraSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)
|
||||
|
||||
pxr::SdfPathVector HydraSceneDelegate::GetInstancerPrototypes(pxr::SdfPath const &instancer_id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", instancer_id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", instancer_id.GetText());
|
||||
InstancerData *i_data = instancer_data(instancer_id);
|
||||
return i_data->prototypes();
|
||||
}
|
||||
@ -180,14 +180,14 @@ pxr::SdfPathVector HydraSceneDelegate::GetInstancerPrototypes(pxr::SdfPath const
|
||||
pxr::VtIntArray HydraSceneDelegate::GetInstanceIndices(pxr::SdfPath const &instancer_id,
|
||||
pxr::SdfPath const &prototype_id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s, %s", instancer_id.GetText(), prototype_id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s, %s", instancer_id.GetText(), prototype_id.GetText());
|
||||
InstancerData *i_data = instancer_data(instancer_id);
|
||||
return i_data->indices(prototype_id);
|
||||
}
|
||||
|
||||
pxr::GfMatrix4d HydraSceneDelegate::GetInstancerTransform(pxr::SdfPath const &instancer_id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", instancer_id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", instancer_id.GetText());
|
||||
InstancerData *i_data = instancer_data(instancer_id);
|
||||
return i_data->transform(instancer_id);
|
||||
}
|
||||
@ -195,7 +195,7 @@ pxr::GfMatrix4d HydraSceneDelegate::GetInstancerTransform(pxr::SdfPath const &in
|
||||
pxr::HdVolumeFieldDescriptorVector HydraSceneDelegate::GetVolumeFieldDescriptors(
|
||||
pxr::SdfPath const &volume_id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", volume_id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 3, "%s", volume_id.GetText());
|
||||
VolumeData *v_data = volume_data(volume_id);
|
||||
return v_data->field_descriptors();
|
||||
}
|
||||
@ -271,8 +271,8 @@ ObjectData *HydraSceneDelegate::object_data(pxr::SdfPath const &id) const
|
||||
if (id == world_prim_id()) {
|
||||
return world_data_.get();
|
||||
}
|
||||
|
||||
pxr::SdfPath p_id = (id.GetName().find("SM_") == 0 || id.GetName().find("VF_") == 0) ?
|
||||
auto name = id.GetName();
|
||||
pxr::SdfPath p_id = (STRPREFIX(name.c_str(), "SM_") || STRPREFIX(name.c_str(), "VF_")) ?
|
||||
id.GetParentPath() :
|
||||
id;
|
||||
auto obj_data = objects_.lookup_ptr(p_id);
|
||||
@ -378,7 +378,7 @@ void HydraSceneDelegate::check_updates()
|
||||
data.only_updated = true;
|
||||
ITER_BEGIN (DEG_iterator_ids_begin, DEG_iterator_ids_next, DEG_iterator_ids_end, &data, ID *, id)
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE,
|
||||
CLOG_INFO(LOG_HYDRA_SCENE,
|
||||
0,
|
||||
"Update: %s [%s]",
|
||||
id->name,
|
||||
@ -459,7 +459,7 @@ void HydraSceneDelegate::update_collection()
|
||||
continue;
|
||||
}
|
||||
|
||||
instancer_data_->update_instance(data.dupli_parent, dupli);
|
||||
instancer_data_->update_instance(dupli);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ struct View3D;
|
||||
|
||||
namespace blender::io::hydra {
|
||||
|
||||
extern struct CLG_LogRef *LOG_RENDER_HYDRA_SCENE;
|
||||
extern struct CLG_LogRef *LOG_HYDRA_SCENE;
|
||||
|
||||
class Engine;
|
||||
|
||||
|
@ -50,10 +50,10 @@ class IdData {
|
||||
};
|
||||
|
||||
#define ID_LOG(level, msg, ...) \
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, level, "%s: " msg, prim_id.GetText(), ##__VA_ARGS__);
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, level, "%s: " msg, prim_id.GetText(), ##__VA_ARGS__);
|
||||
|
||||
#define ID_LOGN(level, msg, ...) \
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, \
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, \
|
||||
level, \
|
||||
"%s (%s): " msg, \
|
||||
prim_id.GetText(), \
|
||||
|
@ -56,10 +56,10 @@ static std::string cache_image_file(
|
||||
opts.save_copy = true;
|
||||
STRNCPY(opts.filepath, file_path.c_str());
|
||||
if (BKE_image_save(nullptr, bmain, image, iuser, &opts)) {
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str());
|
||||
}
|
||||
else {
|
||||
CLOG_ERROR(LOG_RENDER_HYDRA_SCENE, "Can't save %s", file_path.c_str());
|
||||
CLOG_ERROR(LOG_HYDRA_SCENE, "Can't save %s", file_path.c_str());
|
||||
file_path = "";
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ std::string cache_or_get_image_file(Main *bmain, Scene *scene, Image *image, Ima
|
||||
}
|
||||
}
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s -> %s", image->id.name, file_path.c_str());
|
||||
return file_path;
|
||||
}
|
||||
|
||||
@ -109,10 +109,10 @@ std::string cache_image_color(float color[4])
|
||||
ibuf->ftype = IMB_FTYPE_RADHDR;
|
||||
|
||||
if (IMB_saveiff(ibuf, file_path.c_str(), IB_rectfloat)) {
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", file_path.c_str());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s", file_path.c_str());
|
||||
}
|
||||
else {
|
||||
CLOG_ERROR(LOG_RENDER_HYDRA_SCENE, "Can't save %s", file_path.c_str());
|
||||
CLOG_ERROR(LOG_HYDRA_SCENE, "Can't save %s", file_path.c_str());
|
||||
file_path = "";
|
||||
}
|
||||
IMB_freeImBuf(ibuf);
|
||||
|
@ -23,7 +23,7 @@ void InstancerData::insert() {}
|
||||
|
||||
void InstancerData::remove()
|
||||
{
|
||||
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 1, "%s", prim_id.GetText());
|
||||
CLOG_INFO(LOG_HYDRA_SCENE, 1, "%s", prim_id.GetText());
|
||||
for (auto &m_inst : mesh_instances_.values()) {
|
||||
m_inst.data->remove();
|
||||
}
|
||||
@ -129,7 +129,7 @@ void InstancerData::pre_update()
|
||||
}
|
||||
}
|
||||
|
||||
void InstancerData::update_instance(Object * /* parent_ob */, DupliObject *dupli)
|
||||
void InstancerData::update_instance(DupliObject *dupli)
|
||||
{
|
||||
Object *object = dupli->ob;
|
||||
pxr::SdfPath p_id = object_prim_id(object);
|
||||
|
@ -51,7 +51,7 @@ class InstancerData : public IdData {
|
||||
...
|
||||
post_update() */
|
||||
void pre_update();
|
||||
void update_instance(Object *parent_ob, DupliObject *dupli);
|
||||
void update_instance(DupliObject *dupli);
|
||||
void post_update();
|
||||
|
||||
private:
|
||||
|
@ -155,28 +155,28 @@ pxr::TfToken LightData::prim_type(Light *light)
|
||||
switch (light->area_shape) {
|
||||
case LA_AREA_SQUARE:
|
||||
case LA_AREA_RECT:
|
||||
return pxr::TfToken(pxr::HdPrimTypeTokens->rectLight);
|
||||
return pxr::HdPrimTypeTokens->rectLight;
|
||||
|
||||
case LA_AREA_DISK:
|
||||
case LA_AREA_ELLIPSE:
|
||||
return pxr::TfToken(pxr::HdPrimTypeTokens->diskLight);
|
||||
return pxr::HdPrimTypeTokens->diskLight;
|
||||
|
||||
default:
|
||||
return pxr::TfToken(pxr::HdPrimTypeTokens->rectLight);
|
||||
return pxr::HdPrimTypeTokens->rectLight;
|
||||
}
|
||||
break;
|
||||
|
||||
case LA_LOCAL:
|
||||
case LA_SPOT:
|
||||
return pxr::TfToken(pxr::HdPrimTypeTokens->sphereLight);
|
||||
return pxr::HdPrimTypeTokens->sphereLight;
|
||||
|
||||
case LA_SUN:
|
||||
return pxr::TfToken(pxr::HdPrimTypeTokens->distantLight);
|
||||
return pxr::HdPrimTypeTokens->distantLight;
|
||||
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
return pxr::TfToken(pxr::HdPrimTypeTokens->sphereLight);
|
||||
}
|
||||
return pxr::TfToken();
|
||||
}
|
||||
|
||||
} // namespace blender::io::hydra
|
||||
|
@ -151,7 +151,7 @@ void MaterialData::export_mtlx()
|
||||
err_str += PyUnicode_AsUTF8(pstr);
|
||||
Py_DECREF(pstr);
|
||||
}
|
||||
CLOG_ERROR(LOG_RENDER_HYDRA_SCENE,
|
||||
CLOG_ERROR(LOG_HYDRA_SCENE,
|
||||
"Export error for %s (%s): %s",
|
||||
prim_id.GetText(),
|
||||
id->name,
|
||||
|
@ -50,7 +50,7 @@ void VolumeModifierData::init()
|
||||
scene_delegate_->depsgraph, object, md);
|
||||
|
||||
if ((modifier_->domain->cache_data_format & FLUID_DOMAIN_FILE_OPENVDB) == 0) {
|
||||
CLOG_WARN(LOG_RENDER_HYDRA_SCENE,
|
||||
CLOG_WARN(LOG_HYDRA_SCENE,
|
||||
"Volume %s is't exported: only OpenVDB file format supported",
|
||||
prim_id.GetText());
|
||||
return;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
CLG_LOGREF_DECLARE_GLOBAL(LOG_RENDER_HYDRA, "render.hydra");
|
||||
CLG_LOGREF_DECLARE_GLOBAL(LOG_HYDRA_RENDER, "hydra.render");
|
||||
|
||||
Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name)
|
||||
: render_delegate_name_(render_delegate_name), bl_engine_(bl_engine)
|
||||
@ -78,9 +78,11 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &render_delegate_name)
|
||||
|
||||
void Engine::sync(Depsgraph *depsgraph, bContext *context)
|
||||
{
|
||||
const Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
||||
depsgraph_ = depsgraph;
|
||||
context_ = context;
|
||||
scene_ = DEG_get_evaluated_scene(depsgraph);
|
||||
|
||||
if (scene->hydra.export_method == SCE_HYDRA_EXPORT_HYDRA) {
|
||||
if (scene_->hydra.export_method == SCE_HYDRA_EXPORT_HYDRA) {
|
||||
/* Fast path. */
|
||||
usd_scene_delegate_.reset();
|
||||
|
||||
@ -128,7 +130,7 @@ float Engine::renderer_percent_done()
|
||||
pxr::VtDictionary render_stats = render_delegate_->GetRenderStats();
|
||||
auto it = render_stats.find("percentDone");
|
||||
if (it == render_stats.end()) {
|
||||
return 0.0;
|
||||
return 0.0f;
|
||||
}
|
||||
return (float)it->second.UncheckedGet<double>();
|
||||
}
|
||||
|
@ -27,12 +27,15 @@ struct CLG_LogRef;
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
extern struct CLG_LogRef *LOG_RENDER_HYDRA;
|
||||
extern struct CLG_LogRef *LOG_HYDRA_RENDER;
|
||||
|
||||
class Engine {
|
||||
protected:
|
||||
std::string render_delegate_name_;
|
||||
RenderEngine *bl_engine_ = nullptr;
|
||||
Depsgraph *depsgraph_ = nullptr;
|
||||
bContext *context_ = nullptr;
|
||||
Scene *scene_ = nullptr;
|
||||
|
||||
/* The order is important due to deletion order */
|
||||
pxr::HgiUniquePtr hgi_;
|
||||
@ -54,13 +57,14 @@ class Engine {
|
||||
virtual ~Engine() = default;
|
||||
|
||||
void sync(Depsgraph *depsgraph, bContext *context);
|
||||
virtual void render(Depsgraph *depsgraph) = 0;
|
||||
virtual void render() = 0;
|
||||
|
||||
void set_sync_setting(const std::string &key, const pxr::VtValue &val);
|
||||
void set_render_setting(const std::string &key, const pxr::VtValue &val);
|
||||
|
||||
protected:
|
||||
float renderer_percent_done();
|
||||
virtual void notify_status(float progress, const std::string &title, const std::string &info) = 0;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -23,19 +23,14 @@
|
||||
|
||||
namespace blender::render::hydra {
|
||||
|
||||
/* FinalEngine implementation */
|
||||
|
||||
void FinalEngine::render(Depsgraph *depsgraph)
|
||||
void FinalEngine::render()
|
||||
{
|
||||
const Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
||||
const ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
|
||||
const ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph_);
|
||||
|
||||
char scene_name[MAX_ID_FULL_NAME];
|
||||
BKE_id_full_name_get(scene_name, &scene->id, 0);
|
||||
scene_name_ = scene_name;
|
||||
layer_name_ = view_layer->name;
|
||||
BKE_id_full_name_get(scene_name, &scene_->id, 0);
|
||||
|
||||
const RenderData &r = scene->r;
|
||||
const RenderData &r = scene_->r;
|
||||
pxr::GfVec4f border(0, 0, 1, 1);
|
||||
if (r.mode & R_BORDER) {
|
||||
border.Set(r.border.xmin,
|
||||
@ -44,14 +39,15 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
||||
r.border.ymax - r.border.ymin);
|
||||
}
|
||||
pxr::GfVec2i image_res(r.xsch * r.size / 100, r.ysch * r.size / 100);
|
||||
resolution_ = pxr::GfVec2i(int(image_res[0] * border[2]), int(image_res[1] * border[3]));
|
||||
int width = image_res[0] * border[2];
|
||||
int height = image_res[1] * border[3];
|
||||
pxr::GfCamera camera =
|
||||
io::hydra::CameraData(scene->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border);
|
||||
io::hydra::CameraData(scene_->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border);
|
||||
|
||||
free_camera_delegate_->SetCamera(camera);
|
||||
render_task_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1]));
|
||||
render_task_delegate_->set_viewport(pxr::GfVec4d(0, 0, width, height));
|
||||
if (light_tasks_delegate_) {
|
||||
light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1]));
|
||||
light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, width, height));
|
||||
}
|
||||
|
||||
render_task_delegate_->add_aov(pxr::HdAovTokens->color);
|
||||
@ -61,7 +57,7 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
||||
|
||||
pxr::HdTaskSharedPtrVector tasks;
|
||||
if (light_tasks_delegate_) {
|
||||
if (scene->r.alphamode != R_ALPHAPREMUL) {
|
||||
if (scene_->r.alphamode != R_ALPHAPREMUL) {
|
||||
tasks.push_back(light_tasks_delegate_->skydome_task());
|
||||
}
|
||||
tasks.push_back(light_tasks_delegate_->simple_task());
|
||||
@ -82,7 +78,7 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
||||
BLI_timecode_string_from_time_simple(
|
||||
elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin);
|
||||
notify_status(percent_done / 100.0,
|
||||
scene_name_ + ": " + layer_name_,
|
||||
std::string(scene_name) + ": " + view_layer->name,
|
||||
std::string("Render Time: ") + elapsed_time +
|
||||
" | Done: " + std::to_string(int(percent_done)) + "%");
|
||||
|
||||
@ -90,10 +86,10 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
||||
break;
|
||||
}
|
||||
|
||||
update_render_result();
|
||||
update_render_result(width, height, view_layer->name);
|
||||
}
|
||||
|
||||
update_render_result();
|
||||
update_render_result(width, height, view_layer->name);
|
||||
render_task_delegate_->unbind();
|
||||
}
|
||||
|
||||
@ -103,13 +99,12 @@ void FinalEngine::notify_status(float progress, const std::string &title, const
|
||||
RE_engine_update_stats(bl_engine_, title.c_str(), info.c_str());
|
||||
}
|
||||
|
||||
void FinalEngine::update_render_result()
|
||||
void FinalEngine::update_render_result(int width, int height, const char *layer_name)
|
||||
{
|
||||
RenderResult *rr = RE_engine_begin_result(
|
||||
bl_engine_, 0, 0, resolution_[0], resolution_[1], layer_name_.c_str(), nullptr);
|
||||
RenderResult *rr = RE_engine_begin_result(bl_engine_, 0, 0, width, height, layer_name, nullptr);
|
||||
|
||||
RenderLayer *rlayer = static_cast<RenderLayer *>(
|
||||
BLI_findstring(&rr->layers, layer_name_.c_str(), offsetof(RenderLayer, name)));
|
||||
BLI_findstring(&rr->layers, layer_name, offsetof(RenderLayer, name)));
|
||||
|
||||
if (rlayer) {
|
||||
LISTBASE_FOREACH (RenderPass *, rpass, &rlayer->passes) {
|
||||
|
@ -8,19 +8,16 @@
|
||||
namespace blender::render::hydra {
|
||||
|
||||
class FinalEngine : public Engine {
|
||||
protected:
|
||||
std::string scene_name_;
|
||||
std::string layer_name_;
|
||||
pxr::GfVec2i resolution_;
|
||||
|
||||
public:
|
||||
using Engine::Engine;
|
||||
|
||||
void render(Depsgraph *depsgraph) override;
|
||||
void render() override;
|
||||
|
||||
protected:
|
||||
virtual void notify_status(float progress, const std::string &title, const std::string &info);
|
||||
void update_render_result();
|
||||
void notify_status(float progress, const std::string &title, const std::string &info) override;
|
||||
|
||||
private:
|
||||
void update_render_result(int width, int height, const char *layer_name);
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -50,11 +50,11 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
|
||||
}
|
||||
}
|
||||
catch (std::runtime_error &e) {
|
||||
CLOG_ERROR(LOG_RENDER_HYDRA, "%s", e.what());
|
||||
CLOG_ERROR(LOG_HYDRA_RENDER, "%s", e.what());
|
||||
}
|
||||
|
||||
if (engine) {
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p %s", engine, engine_type);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 1, "Engine %p %s", engine, engine_type);
|
||||
}
|
||||
return PyLong_FromVoidPtr(engine);
|
||||
}
|
||||
@ -69,7 +69,7 @@ static PyObject *engine_free_func(PyObject * /*self*/, PyObject *args)
|
||||
Engine *engine = static_cast<Engine *>(PyLong_AsVoidPtr(pyengine));
|
||||
delete engine;
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p", engine);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 1, "Engine %p", engine);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ static PyObject *engine_update_func(PyObject * /*self*/, PyObject *args)
|
||||
Depsgraph *depsgraph = pyrna_to_pointer<Depsgraph>(pydepsgraph, &RNA_Depsgraph);
|
||||
bContext *context = pyrna_to_pointer<bContext>(pycontext, &RNA_Context);
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 2, "Engine %p", engine);
|
||||
engine->sync(depsgraph, context);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@ -93,19 +93,17 @@ static PyObject *engine_update_func(PyObject * /*self*/, PyObject *args)
|
||||
static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args)
|
||||
{
|
||||
PyObject *pyengine, *pydepsgraph;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "OO", &pyengine, &pydepsgraph)) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
Engine *engine = static_cast<Engine *>(PyLong_AsVoidPtr(pyengine));
|
||||
Depsgraph *depsgraph = pyrna_to_pointer<Depsgraph>(pydepsgraph, &RNA_Depsgraph);
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 2, "Engine %p", engine);
|
||||
|
||||
/* Allow Blender to execute other Python scripts. */
|
||||
Py_BEGIN_ALLOW_THREADS;
|
||||
engine->render(depsgraph);
|
||||
engine->render();
|
||||
Py_END_ALLOW_THREADS;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@ -119,14 +117,12 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args)
|
||||
}
|
||||
|
||||
ViewportEngine *engine = static_cast<ViewportEngine *>(PyLong_AsVoidPtr(pyengine));
|
||||
Depsgraph *depsgraph = pyrna_to_pointer<Depsgraph>(pydepsgraph, &RNA_Depsgraph);
|
||||
bContext *context = pyrna_to_pointer<bContext>(pycontext, &RNA_Context);
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p", engine);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 3, "Engine %p", engine);
|
||||
|
||||
/* Allow Blender to execute other Python scripts. */
|
||||
Py_BEGIN_ALLOW_THREADS;
|
||||
engine->render(depsgraph, context);
|
||||
engine->render();
|
||||
Py_END_ALLOW_THREADS;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@ -160,7 +156,7 @@ static PyObject *engine_set_sync_setting_func(PyObject * /*self*/, PyObject *arg
|
||||
|
||||
Engine *engine = static_cast<Engine *>(PyLong_AsVoidPtr(pyengine));
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p: %s", engine, key);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 3, "Engine %p: %s", engine, key);
|
||||
engine->set_sync_setting(key, get_setting_val(pyval));
|
||||
|
||||
Py_RETURN_NONE;
|
||||
@ -176,7 +172,7 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a
|
||||
|
||||
Engine *engine = static_cast<Engine *>(PyLong_AsVoidPtr(pyengine));
|
||||
|
||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p: %s", engine, key);
|
||||
CLOG_INFO(LOG_HYDRA_RENDER, 3, "Engine %p: %s", engine, key);
|
||||
engine->set_render_setting(key, get_setting_val(pyval));
|
||||
|
||||
Py_RETURN_NONE;
|
||||
|
@ -212,15 +212,9 @@ GPUTexture *DrawTexture::texture() const
|
||||
return texture_;
|
||||
}
|
||||
|
||||
void ViewportEngine::render(Depsgraph * /* depsgraph */)
|
||||
void ViewportEngine::render()
|
||||
{
|
||||
/* Empty function */
|
||||
}
|
||||
|
||||
void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
{
|
||||
ViewSettings view_settings(context);
|
||||
const Scene *scene = DEG_get_evaluated_scene(depsgraph);
|
||||
ViewSettings view_settings(context_);
|
||||
if (view_settings.width() * view_settings.height() == 0) {
|
||||
return;
|
||||
};
|
||||
@ -254,7 +248,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
|
||||
pxr::HdTaskSharedPtrVector tasks;
|
||||
if (light_tasks_delegate_) {
|
||||
if (scene->r.alphamode != R_ALPHAPREMUL) {
|
||||
if (scene_->r.alphamode != R_ALPHAPREMUL) {
|
||||
tasks.push_back(light_tasks_delegate_->skydome_task());
|
||||
}
|
||||
tasks.push_back(light_tasks_delegate_->simple_task());
|
||||
@ -283,18 +277,21 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
BLI_timecode_string_from_time_simple(
|
||||
elapsed_time, sizeof(elapsed_time), PIL_check_seconds_timer() - time_begin_);
|
||||
|
||||
float percent_done = renderer_percent_done();
|
||||
if (!render_task_delegate_->is_converged()) {
|
||||
notify_status(std::string("Time: ") + elapsed_time +
|
||||
" | Done: " + std::to_string(int(renderer_percent_done())) + "%",
|
||||
notify_status(percent_done / 100.0,
|
||||
std ::string("Time: ") + elapsed_time +
|
||||
" | Done: " + std::to_string(int(percent_done)) + "%",
|
||||
"Render");
|
||||
bl_engine_->flag |= RE_ENGINE_DO_DRAW;
|
||||
}
|
||||
else {
|
||||
notify_status((std::string("Time: ") + elapsed_time).c_str(), "Rendering Done");
|
||||
notify_status(percent_done / 100.0, std::string("Time: ") + elapsed_time, "Rendering Done");
|
||||
}
|
||||
}
|
||||
|
||||
void ViewportEngine::notify_status(const std::string &info, const std::string &status)
|
||||
void ViewportEngine::notify_status(float /*progress*/, const std::string &info,
|
||||
const std::string &status)
|
||||
{
|
||||
RE_engine_update_stats(bl_engine_, status.c_str(), info.c_str());
|
||||
}
|
||||
|
@ -38,11 +38,10 @@ class ViewportEngine : public Engine {
|
||||
public:
|
||||
using Engine::Engine;
|
||||
|
||||
void render(Depsgraph *depsgraph) override;
|
||||
void render(Depsgraph *depsgraph, bContext *context);
|
||||
void render() override;
|
||||
|
||||
private:
|
||||
void notify_status(const std::string &title, const std::string &info);
|
||||
protected:
|
||||
void notify_status(float progress, const std::string &title, const std::string &info) override;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
Loading…
Reference in New Issue
Block a user