forked from blender/blender
Rename some functions #25
@ -15,8 +15,8 @@ CameraData::CameraData(bContext *context)
|
|||||||
RegionView3D *region_data = (RegionView3D *)CTX_wm_region_data(context);
|
RegionView3D *region_data = (RegionView3D *)CTX_wm_region_data(context);
|
||||||
ARegion *region = CTX_wm_region(context);
|
ARegion *region = CTX_wm_region(context);
|
||||||
|
|
||||||
// this constant was found experimentally, didn't find such option in
|
/* This constant was found experimentally, didn't find such option in
|
||||||
// context.view3d or context.region_data
|
* context.view3d or context.region_data. */
|
||||||
float VIEWPORT_SENSOR_SIZE = 72.0;
|
float VIEWPORT_SENSOR_SIZE = 72.0;
|
||||||
|
|
||||||
pxr::GfVec2i res(region->winx, region->winy);
|
pxr::GfVec2i res(region->winx, region->winy);
|
||||||
@ -62,13 +62,13 @@ CameraData::CameraData(bContext *context)
|
|||||||
*this = CameraData(view3d->camera, res, pxr::GfVec4f(0, 0, 1, 1));
|
*this = CameraData(view3d->camera, res, pxr::GfVec4f(0, 0, 1, 1));
|
||||||
transform_ = mat;
|
transform_ = mat;
|
||||||
|
|
||||||
// This formula was taken from previous plugin with corresponded comment
|
/* This formula was taken from previous plugin with corresponded comment.
|
||||||
// See blender/intern/cycles/blender/blender_camera.cpp:blender_camera_from_view (look
|
* See blender/intern/cycles/blender/blender_camera.cpp:blender_camera_from_view (look
|
||||||
// for 1.41421f)
|
* for 1.41421f). */
|
||||||
float zoom = 4.0 / pow((pow(2.0, 0.5) + region_data->camzoom / 50.0), 2);
|
float zoom = 4.0 / pow((pow(2.0, 0.5) + region_data->camzoom / 50.0), 2);
|
||||||
|
|
||||||
// Updating l_shift due to viewport zoom and view_camera_offset
|
/* Updating l_shift due to viewport zoom and view_camera_offset
|
||||||
// view_camera_offset should be multiplied by 2
|
* view_camera_offset should be multiplied by 2. */
|
||||||
lens_shift_ = pxr::GfVec2f((lens_shift_[0] + region_data->camdx * 2) / zoom,
|
lens_shift_ = pxr::GfVec2f((lens_shift_[0] + region_data->camdx * 2) / zoom,
|
||||||
(lens_shift_[1] + region_data->camdy * 2) / zoom);
|
(lens_shift_[1] + region_data->camdy * 2) / zoom);
|
||||||
|
|
||||||
@ -255,8 +255,8 @@ pxr::GfCamera CameraData::gf_camera(pxr::GfVec4f tile)
|
|||||||
case CAM_ORTHO: {
|
case CAM_ORTHO: {
|
||||||
gf_camera.SetProjection(pxr::GfCamera::Projection::Orthographic);
|
gf_camera.SetProjection(pxr::GfCamera::Projection::Orthographic);
|
||||||
|
|
||||||
// Use tenths of a world unit accorging to USD docs
|
/* Use tenths of a world unit accorging to USD docs
|
||||||
// https://graphics.pixar.com/usd/docs/api/class_gf_camera.html
|
* https://graphics.pixar.com/usd/docs/api/class_gf_camera.html */
|
||||||
float o_size[2] = {ortho_size_[0] * t_size[0] * 10, ortho_size_[1] * t_size[1] * 10};
|
float o_size[2] = {ortho_size_[0] * t_size[0] * 10, ortho_size_[1] * t_size[1] * 10};
|
||||||
|
|
||||||
gf_camera.SetHorizontalAperture(o_size[0]);
|
gf_camera.SetHorizontalAperture(o_size[0]);
|
||||||
|
@ -70,11 +70,11 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
|||||||
float percent_done = 0.0;
|
float percent_done = 0.0;
|
||||||
|
|
||||||
std::map<std::string, std::vector<float>> render_images{
|
std::map<std::string, std::vector<float>> render_images{
|
||||||
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; // 4 - number of channels
|
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; /* 4 - number of channels. */
|
||||||
std::vector<float> &pixels = render_images["Combined"];
|
std::vector<float> &pixels = render_images["Combined"];
|
||||||
|
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
@ -179,8 +179,8 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
|||||||
pxr::HdTaskSharedPtrVector tasks;
|
pxr::HdTaskSharedPtrVector tasks;
|
||||||
if (simple_light_task_delegate_) {
|
if (simple_light_task_delegate_) {
|
||||||
/* TODO: Uncomment this and fix GL error:
|
/* TODO: Uncomment this and fix GL error:
|
||||||
invalid operation, reported from void __cdecl
|
* invalid operation, reported from void __cdecl
|
||||||
pxrInternal_v0_22__pxrReserved__::HgiGLResourceBindings::BindResources(void) */
|
* pxrInternal_v0_22__pxrReserved__::HgiGLResourceBindings::BindResources(void) */
|
||||||
// tasks.push_back(simple_light_task_delegate_->get_task());
|
// tasks.push_back(simple_light_task_delegate_->get_task());
|
||||||
}
|
}
|
||||||
tasks.push_back(render_task_delegate_->get_task());
|
tasks.push_back(render_task_delegate_->get_task());
|
||||||
@ -192,7 +192,7 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
|||||||
float percent_done = 0.0;
|
float percent_done = 0.0;
|
||||||
|
|
||||||
std::map<std::string, std::vector<float>> render_images{
|
std::map<std::string, std::vector<float>> render_images{
|
||||||
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; // 4 - number of channels
|
{"Combined", std::vector<float>(res[0] * res[1] * 4)}}; /* 4 - number of channels. */
|
||||||
std::vector<float> &pixels = render_images["Combined"];
|
std::vector<float> &pixels = render_images["Combined"];
|
||||||
|
|
||||||
GPUFrameBuffer *framebuffer = GPU_framebuffer_create("fbHydraRenderFinal");
|
GPUFrameBuffer *framebuffer = GPU_framebuffer_create("fbHydraRenderFinal");
|
||||||
@ -212,7 +212,7 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
|||||||
GPU_framebuffer_clear_color_depth(framebuffer, clear_color, 1.0);
|
GPU_framebuffer_clear_color_depth(framebuffer, clear_color, 1.0);
|
||||||
|
|
||||||
{
|
{
|
||||||
// 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);
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,10 @@ void PreviewEngine::render(Depsgraph *depsgraph)
|
|||||||
}
|
}
|
||||||
tasks.push_back(render_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
|
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);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ ViewSettings::ViewSettings(bContext *context) : camera_data(context)
|
|||||||
|
|
||||||
Scene *scene = CTX_data_scene(context);
|
Scene *scene = CTX_data_scene(context);
|
||||||
|
|
||||||
// getting render border
|
/* Getting render border. */
|
||||||
int x1 = 0, y1 = 0;
|
int x1 = 0, y1 = 0;
|
||||||
int x2 = screen_width, y2 = screen_height;
|
int x2 = screen_width, y2 = screen_height;
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ ViewSettings::ViewSettings(bContext *context) : camera_data(context)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getting camera view region
|
/* Getting camera view region. */
|
||||||
float x1_f = std::min(
|
float x1_f = std::min(
|
||||||
{screen_points[0][0], screen_points[1][0], screen_points[2][0], screen_points[3][0]});
|
{screen_points[0][0], screen_points[1][0], screen_points[2][0], screen_points[3][0]});
|
||||||
float x2_f = std::max(
|
float x2_f = std::max(
|
||||||
@ -83,7 +83,7 @@ ViewSettings::ViewSettings(bContext *context) : camera_data(context)
|
|||||||
float y2_f = std::max(
|
float y2_f = std::max(
|
||||||
{screen_points[0][1], screen_points[1][1], screen_points[2][1], screen_points[3][1]});
|
{screen_points[0][1], screen_points[1][1], screen_points[2][1], screen_points[3][1]});
|
||||||
|
|
||||||
// adjusting region to border
|
/* Adjusting region to border. */
|
||||||
float x = x1_f, y = y1_f;
|
float x = x1_f, y = y1_f;
|
||||||
float dx = x2_f - x1_f, dy = y2_f - y1_f;
|
float dx = x2_f - x1_f, dy = y2_f - y1_f;
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ ViewSettings::ViewSettings(bContext *context) : camera_data(context)
|
|||||||
y1 = y + scene->r.border.ymin * dy;
|
y1 = y + scene->r.border.ymin * dy;
|
||||||
y2 = y + scene->r.border.ymax * dy;
|
y2 = y + scene->r.border.ymax * dy;
|
||||||
|
|
||||||
// adjusting to region screen resolution
|
/* Adjusting to region screen resolution. */
|
||||||
x1 = std::max(std::min(x1, screen_width), 0);
|
x1 = std::max(std::min(x1, screen_width), 0);
|
||||||
x2 = std::max(std::min(x2, screen_width), 0);
|
x2 = std::max(std::min(x2, screen_width), 0);
|
||||||
y1 = std::max(std::min(y1, screen_height), 0);
|
y1 = std::max(std::min(y1, screen_height), 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user