BLEN-367: Fix code style #14

Merged
Bogdan Nagirniak merged 11 commits from BLEN-367 into hydra-render 2023-03-15 09:42:17 +01:00
18 changed files with 154 additions and 120 deletions
Showing only changes of commit 8bd5ccb525 - Show all commits

View File

@ -58,7 +58,8 @@ CameraData::CameraData(Object *camera_obj, pxr::GfVec2i res, pxr::GfVec4f tile)
break;
}
lens_shift = pxr::GfVec2f(lens_shift[0] / t_size[0] + (t_pos[0] + t_size[0] * 0.5 - 0.5) / t_size[0],
lens_shift = pxr::GfVec2f(
lens_shift[0] / t_size[0] + (t_pos[0] + t_size[0] * 0.5 - 0.5) / t_size[0],
lens_shift[1] / t_size[1] + (t_pos[1] + t_size[1] * 0.5 - 0.5) / t_size[1]);
switch (camera->type) {

View File

@ -18,7 +18,7 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &delegateId) : bl_engi
{
pxr::HdRendererPluginRegistry &registry = pxr::HdRendererPluginRegistry::GetInstance();
//TF_PY_ALLOW_THREADS_IN_SCOPE();
pxr::TF_PY_ALLOW_THREADS_IN_SCOPE();
render_delegate = registry.CreateRenderDelegate(pxr::TfToken(delegateId));
pxr::HdDriverVector hd_drivers;
@ -37,7 +37,8 @@ Engine::Engine(RenderEngine *bl_engine, const std::string &delegateId) : bl_engi
render_index.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("renderTask"));
if (render_delegate->GetRendererDisplayName() == "GL") {
simple_light_task_delegate = std::make_unique<SimpleLightTaskDelegate>(
render_index.get(), pxr::SdfPath::AbsoluteRootPath().AppendElementString("simpleLightTask"));
render_index.get(),
pxr::SdfPath::AbsoluteRootPath().AppendElementString("simpleLightTask"));
}
engine = std::make_unique<pxr::HdEngine>();

View File

@ -48,7 +48,8 @@ void FinalEngine::render(Depsgraph *depsgraph)
}
pxr::GfVec2i image_res(r.xsch * r.size / 100, r.ysch * r.size / 100);
pxr::GfVec2i res(int(image_res[0] * border[2]), int(image_res[1] * border[3]));
pxr::GfCamera camera = CameraData(scene->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border);
pxr::GfCamera camera =
CameraData(scene->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border);
free_camera_delegate->SetCamera(camera);
render_task_delegate->SetCameraAndViewport(free_camera_delegate->GetCameraId(),
@ -64,7 +65,8 @@ void FinalEngine::render(Depsgraph *depsgraph)
}
tasks.push_back(render_task_delegate->GetTask());
std::chrono::time_point<std::chrono::steady_clock> timeBegin = std::chrono::steady_clock::now(), timeCurrent;
std::chrono::time_point<std::chrono::steady_clock> timeBegin = std::chrono::steady_clock::now(),
timeCurrent;
std::chrono::milliseconds elapsedTime;
float percentDone = 0.0;
@ -113,7 +115,8 @@ pxr::GfVec2i FinalEngine::get_resolution(Scene *scene)
border_w = r.border.xmax - r.border.xmin;
border_h = r.border.ymax - r.border.ymin;
}
return pxr::GfVec2i(int(r.xsch * border_w * r.size / 100), int(r.ysch * border_h * r.size / 100));
return pxr::GfVec2i(int(r.xsch * border_w * r.size / 100),
int(r.ysch * border_h * r.size / 100));
}
void FinalEngine::updateRenderResult(std::map<std::string, std::vector<float>> &renderImages,
@ -164,7 +167,8 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
}
pxr::GfVec2i image_res = {r.xsch * r.size / 100, r.ysch * r.size / 100};
pxr::GfVec2i res = {int(image_res[0] * border[2]), int(image_res[1] * border[3])};
pxr::GfCamera camera = CameraData(scene->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border);
pxr::GfCamera camera =
CameraData(scene->camera, image_res, pxr::GfVec4f(0, 0, 1, 1)).gf_camera(border);
free_camera_delegate->SetCamera(camera);
render_task_delegate->SetCameraAndViewport(free_camera_delegate->GetCameraId(),
@ -182,7 +186,8 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
}
tasks.push_back(render_task_delegate->GetTask());
std::chrono::time_point<std::chrono::steady_clock> timeBegin = std::chrono::steady_clock::now(), timeCurrent;
std::chrono::time_point<std::chrono::steady_clock> timeBegin = std::chrono::steady_clock::now(),
timeCurrent;
std::chrono::milliseconds elapsedTime;
float percentDone = 0.0;

View File

@ -107,7 +107,8 @@ static PyObject *get_render_plugins_func(PyObject * /*self*/, PyObject *args)
PyDict_SetItemString(descr, "id", val = PyUnicode_FromString(plugin_ids[i].GetText()));
Py_DECREF(val);
PyDict_SetItemString(descr,
PyDict_SetItemString(
descr,
"name",
val = PyUnicode_FromString(
pxr::UsdImagingGLEngine::GetRendererDisplayName(plugin_ids[i]).c_str()));

View File

@ -13,7 +13,8 @@
namespace blender::render::hydra {
RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parentIndex, pxr::SdfPath const &delegateID)
RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parentIndex,
pxr::SdfPath const &delegateID)
: pxr::HdSceneDelegate(parentIndex, delegateID)
{
pxr::SdfPath renderTaskId = GetTaskID();
@ -44,8 +45,10 @@ pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const
return pxr::VtValue(taskParams);
}
if (key == pxr::HdTokens->collection) {
pxr::HdRprimCollection rprimCollection(
pxr::HdTokens->geometry, pxr::HdReprSelector(pxr::HdReprTokens->smoothHull), false, pxr::TfToken());
pxr::HdRprimCollection rprimCollection(pxr::HdTokens->geometry,
pxr::HdReprSelector(pxr::HdReprTokens->smoothHull),
false,
pxr::TfToken());
rprimCollection.SetRootPath(pxr::SdfPath::AbsoluteRootPath());
return pxr::VtValue(rprimCollection);
}
@ -72,8 +75,10 @@ bool RenderTaskDelegate::IsConverged()
void RenderTaskDelegate::SetRendererAov(pxr::TfToken const &aov)
{
pxr::HdAovDescriptor aovDesc = GetRenderIndex().GetRenderDelegate()->GetDefaultAovDescriptor(aov);
pxr::HdRenderBufferDescriptor desc(pxr::GfVec3i(taskParams.viewport[2], taskParams.viewport[3], 1),
pxr::HdAovDescriptor aovDesc = GetRenderIndex().GetRenderDelegate()->GetDefaultAovDescriptor(
aov);
pxr::HdRenderBufferDescriptor desc(
pxr::GfVec3i(taskParams.viewport[2], taskParams.viewport[3], 1),
aovDesc.format,
aovDesc.multiSampled);
pxr::SdfPath bufferId = GetAovID(aov);
@ -81,7 +86,8 @@ void RenderTaskDelegate::SetRendererAov(pxr::TfToken const &aov)
if (bufferDescriptors.find(bufferId) == bufferDescriptors.end()) {
GetRenderIndex().InsertBprim(pxr::HdPrimTypeTokens->renderBuffer, this, bufferId);
bufferDescriptors[bufferId] = desc;
GetRenderIndex().GetChangeTracker().MarkBprimDirty(bufferId, pxr::HdRenderBuffer::DirtyDescription);
GetRenderIndex().GetChangeTracker().MarkBprimDirty(bufferId,
pxr::HdRenderBuffer::DirtyDescription);
pxr::HdRenderPassAovBinding binding;
binding.aovName = aov;
@ -89,18 +95,20 @@ void RenderTaskDelegate::SetRendererAov(pxr::TfToken const &aov)
binding.aovSettings = aovDesc.aovSettings;
taskParams.aovBindings.push_back(binding);
GetRenderIndex().GetChangeTracker().MarkTaskDirty(GetTaskID(), pxr::HdChangeTracker::DirtyParams);
GetRenderIndex().GetChangeTracker().MarkTaskDirty(GetTaskID(),
pxr::HdChangeTracker::DirtyParams);
}
else if (bufferDescriptors[bufferId] != desc) {
bufferDescriptors[bufferId] = desc;
GetRenderIndex().GetChangeTracker().MarkBprimDirty(bufferId, pxr::HdRenderBuffer::DirtyDescription);
GetRenderIndex().GetChangeTracker().MarkBprimDirty(bufferId,
pxr::HdRenderBuffer::DirtyDescription);
}
}
pxr::HdRenderBuffer *RenderTaskDelegate::GetRendererAov(pxr::TfToken const &aov)
{
return (
pxr::HdRenderBuffer *)(GetRenderIndex().GetBprim(pxr::HdPrimTypeTokens->renderBuffer, GetAovID(aov)));
return (pxr::HdRenderBuffer *)(GetRenderIndex().GetBprim(pxr::HdPrimTypeTokens->renderBuffer,
GetAovID(aov)));
}
void RenderTaskDelegate::GetRendererAovData(pxr::TfToken const &aov, void *data)
@ -118,12 +126,14 @@ pxr::HdTaskSharedPtr RenderTaskDelegate::GetTask()
return GetRenderIndex().GetTask(GetTaskID());
}
void RenderTaskDelegate::SetCameraAndViewport(pxr::SdfPath const &cameraId, pxr::GfVec4d const &viewport)
void RenderTaskDelegate::SetCameraAndViewport(pxr::SdfPath const &cameraId,
pxr::GfVec4d const &viewport)
{
if (taskParams.viewport != viewport || taskParams.camera != cameraId) {
taskParams.viewport = viewport;
taskParams.camera = cameraId;
GetRenderIndex().GetChangeTracker().MarkTaskDirty(GetTaskID(), pxr::HdChangeTracker::DirtyParams);
GetRenderIndex().GetChangeTracker().MarkTaskDirty(GetTaskID(),
pxr::HdChangeTracker::DirtyParams);
}
}

View File

@ -30,7 +30,8 @@ class RenderTaskDelegate : public pxr::HdSceneDelegate {
private:
pxr::HdxRenderTaskParams taskParams;
pxr::TfHashMap<pxr::SdfPath, pxr::HdRenderBufferDescriptor, pxr::SdfPath::Hash> bufferDescriptors;
pxr::TfHashMap<pxr::SdfPath, pxr::HdRenderBufferDescriptor, pxr::SdfPath::Hash>
bufferDescriptors;
};
} // namespace blender::render::hydra

View File

@ -465,7 +465,8 @@ pxr::GfMatrix4d BlenderSceneDelegate::GetTransform(pxr::SdfPath const &id)
return pxr::GfMatrix4d();
}
pxr::VtValue BlenderSceneDelegate::GetLightParamValue(pxr::SdfPath const &id, pxr::TfToken const &key)
pxr::VtValue BlenderSceneDelegate::GetLightParamValue(pxr::SdfPath const &id,
pxr::TfToken const &key)
{
LightData *l_data = light_data(id);
if (l_data) {

View File

@ -93,7 +93,8 @@ void MaterialData::export_mtlx()
void MaterialData::insert_prim()
{
pxr::SdfPath p_id = prim_id(scene_delegate, (Material *)id);
scene_delegate->GetRenderIndex().InsertSprim(pxr::HdPrimTypeTokens->material, scene_delegate, p_id);
scene_delegate->GetRenderIndex().InsertSprim(
pxr::HdPrimTypeTokens->material, scene_delegate, p_id);
LOG(INFO) << "Add material: " << name() << " id=" << p_id.GetAsString();
}

View File

@ -78,7 +78,8 @@ pxr::HdPrimvarDescriptorVector MeshData::primvar_descriptors(pxr::HdInterpolatio
}
else if (interpolation == pxr::HdInterpolationFaceVarying) {
if (!normals.empty()) {
primvars.emplace_back(pxr::HdTokens->normals, interpolation, pxr::HdPrimvarRoleTokens->normal);
primvars.emplace_back(
pxr::HdTokens->normals, interpolation, pxr::HdPrimvarRoleTokens->normal);
}
if (!uvs.empty()) {
primvars.emplace_back(pxr::HdPrimvarRoleTokens->textureCoordinate,
@ -89,7 +90,8 @@ pxr::HdPrimvarDescriptorVector MeshData::primvar_descriptors(pxr::HdInterpolatio
return primvars;
}
pxr::HdPrimvarDescriptorVector MeshData::instancer_primvar_descriptors(pxr::HdInterpolation interpolation)
pxr::HdPrimvarDescriptorVector MeshData::instancer_primvar_descriptors(
pxr::HdInterpolation interpolation)
{
pxr::HdPrimvarDescriptorVector primvars;
if (interpolation == pxr::HdInterpolationInstance) {

View File

@ -48,11 +48,17 @@ void HdMtlxConvertToMaterialNetworkMap(std::string const &mtlxPath,
pxr::UsdMtlxRead(doc, stage);
}
catch (mx::ExceptionFoundCycle &x) {
Tf_PostErrorHelper(pxr::TF_CALL_CONTEXT, pxr::TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE, "MaterialX cycle found: %s\n", x.what());
Tf_PostErrorHelper(pxr::TF_CALL_CONTEXT,
pxr::TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE,
"MaterialX cycle found: %s\n",
x.what());
return;
}
catch (mx::Exception &x) {
Tf_PostErrorHelper(pxr::TF_CALL_CONTEXT, pxr::TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE, "MaterialX error: %s\n", x.what());
Tf_PostErrorHelper(pxr::TF_CALL_CONTEXT,
pxr::TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE,
"MaterialX error: %s\n",
x.what());
return;
}

View File

@ -102,12 +102,15 @@ WorldData::WorldData(BlenderSceneDelegate *scene_delegate, World *world, bContex
pxr::GfMatrix4d WorldData::transform()
{
pxr::GfMatrix4d transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d());
pxr::GfMatrix4d transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90),
pxr::GfVec3d());
/* TODO : do this check via RenderSettings*/
if (scene_delegate->GetRenderIndex().GetRenderDelegate()->GetRendererDisplayName() == "RPR") {
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180), pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0), pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0),
pxr::GfVec3d());
}
return transform;
}
@ -125,7 +128,8 @@ pxr::VtValue WorldData::get_data(pxr::TfToken const &key)
void WorldData::insert_prim()
{
pxr::SdfPath p_id = prim_id(scene_delegate);
scene_delegate->GetRenderIndex().InsertSprim(pxr::HdPrimTypeTokens->domeLight, scene_delegate, p_id);
scene_delegate->GetRenderIndex().InsertSprim(
pxr::HdPrimTypeTokens->domeLight, scene_delegate, p_id);
LOG(INFO) << "Add World: id=" << p_id.GetAsString();
}

View File

@ -1,9 +1,9 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#include <chrono>
#include <filesystem>
#include <sstream>
#include <chrono>
#include <pxr/base/tf/stringUtils.h>
@ -18,7 +18,7 @@
namespace blender::render::hydra {
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4])
pxr::GfMatrix4d gf_matrix_from_transform(float m[4][4])
{
return pxr::GfMatrix4d(m[0][0],
m[0][1],

View File

@ -7,19 +7,19 @@
#include <pxr/imaging/glf/drawTarget.h>
#include <pxr/usd/usdGeom/camera.h>
#include "DNA_vec_types.h"
#include "BKE_camera.h"
#include "BLI_math_matrix.h"
#include "DEG_depsgraph_query.h"
#include "DNA_camera_types.h"
#include "DNA_screen_types.h"
#include "DNA_vec_types.h"
#include "GPU_shader.h"
#include "glog/logging.h"
#include "viewport_engine.h"
#include "camera.h"
#include "utils.h"
#include "viewport_engine.h"
namespace blender::render::hydra {
@ -305,9 +305,10 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
GPU_shader_unbind();
std::chrono::time_point<std::chrono::steady_clock> timeCurrent = std::chrono::steady_clock::now();
std::chrono::milliseconds elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(timeCurrent -
timeBegin);
std::chrono::time_point<std::chrono::steady_clock> timeCurrent =
std::chrono::steady_clock::now();
std::chrono::milliseconds elapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(
timeCurrent - timeBegin);
std::string formattedTime = format_duration(elapsedTime);