mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Refactor: Move code in source/ into blender namespace
Previously only a subset of the code was in this namespace. This improves
consistency, and means common types like Vector, StringRef and float3
don't need blender:: prefixes anywhere.
This does not move code into sub-namespaces, but gets us a step closer to
the end goal.
* Add namespace blender {} to almost all files.
* Remove unnecessary blender:: prefixes and using namespace blender;.
* Freestyle was not not moved, it remains in top level namespace freestyle.
* Cycles integration code was modified to use blender:: prefixes.
* bUUID existed both in the top level and blender namespace. To resolve this
conflict, the wrapper class is now blender::UUID.
Some blender:: prefixes remain primarily because of ambiguous namespaces, for
example animrig:: could refer to both blender::animrig and blender::ed::animrig.
Pull Request: https://projects.blender.org/blender/blender/pulls/152329
This commit is contained in:
parent
45b9f2b65b
commit
41a27b4eed
3865 changed files with 40394 additions and 31623 deletions
1
extern/nanosvg/blender_nanosvg.c
vendored
1
extern/nanosvg/blender_nanosvg.c
vendored
|
|
@ -6,5 +6,4 @@
|
|||
#define NANOSVG_ALL_COLOR_KEYWORDS
|
||||
|
||||
#include <stdio.h>
|
||||
#include "BLI_utildefines.h"
|
||||
#include "nanosvg.h"
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ CCL_NAMESPACE_BEGIN
|
|||
|
||||
class BlenderCamera {
|
||||
public:
|
||||
explicit BlenderCamera(const ::RenderData &b_render)
|
||||
explicit BlenderCamera(const blender::RenderData &b_render)
|
||||
{
|
||||
full_width = render_width = render_resolution_x(b_render);
|
||||
full_height = render_height = render_resolution_y(b_render);
|
||||
};
|
||||
|
||||
PointerRNA custom_props;
|
||||
blender::PointerRNA custom_props;
|
||||
string custom_bytecode;
|
||||
string custom_bytecode_hash;
|
||||
string custom_filepath;
|
||||
|
|
@ -113,12 +113,12 @@ class BlenderCamera {
|
|||
int motion_steps = 0;
|
||||
};
|
||||
|
||||
static float blender_camera_focal_distance(::RenderEngine &b_engine,
|
||||
::Object &b_ob,
|
||||
::Camera &b_camera,
|
||||
static float blender_camera_focal_distance(blender::RenderEngine &b_engine,
|
||||
blender::Object &b_ob,
|
||||
blender::Camera &b_camera,
|
||||
BlenderCamera *bcam)
|
||||
{
|
||||
::Object *b_dof_object = b_camera.dof.focus_object;
|
||||
blender::Object *b_dof_object = b_camera.dof.focus_object;
|
||||
|
||||
if (!b_dof_object) {
|
||||
return b_camera.dof.focus_distance;
|
||||
|
|
@ -128,8 +128,8 @@ static float blender_camera_focal_distance(::RenderEngine &b_engine,
|
|||
|
||||
const string focus_subtarget = b_camera.dof.focus_subtarget;
|
||||
if (b_dof_object->pose && !focus_subtarget.empty()) {
|
||||
if (bPoseChannel *pchan = BKE_pose_channel_find_name(b_dof_object->pose,
|
||||
focus_subtarget.c_str()))
|
||||
if (blender::bPoseChannel *pchan = BKE_pose_channel_find_name(b_dof_object->pose,
|
||||
focus_subtarget.c_str()))
|
||||
{
|
||||
dofmat = dofmat * get_transform(blender::float4x4(pchan->pose_mat));
|
||||
}
|
||||
|
|
@ -148,19 +148,19 @@ static float blender_camera_focal_distance(::RenderEngine &b_engine,
|
|||
static PanoramaType blender_panorama_type_to_cycles(const int type)
|
||||
{
|
||||
switch (type) {
|
||||
case CAM_PANORAMA_EQUIRECTANGULAR:
|
||||
case blender::CAM_PANORAMA_EQUIRECTANGULAR:
|
||||
return PANORAMA_EQUIRECTANGULAR;
|
||||
case CAM_PANORAMA_EQUIANGULAR_CUBEMAP_FACE:
|
||||
case blender::CAM_PANORAMA_EQUIANGULAR_CUBEMAP_FACE:
|
||||
return PANORAMA_EQUIANGULAR_CUBEMAP_FACE;
|
||||
case CAM_PANORAMA_MIRRORBALL:
|
||||
case blender::CAM_PANORAMA_MIRRORBALL:
|
||||
return PANORAMA_MIRRORBALL;
|
||||
case CAM_PANORAMA_FISHEYE_EQUIDISTANT:
|
||||
case blender::CAM_PANORAMA_FISHEYE_EQUIDISTANT:
|
||||
return PANORAMA_FISHEYE_EQUIDISTANT;
|
||||
case CAM_PANORAMA_FISHEYE_EQUISOLID:
|
||||
case blender::CAM_PANORAMA_FISHEYE_EQUISOLID:
|
||||
return PANORAMA_FISHEYE_EQUISOLID;
|
||||
case CAM_PANORAMA_FISHEYE_LENS_POLYNOMIAL:
|
||||
case blender::CAM_PANORAMA_FISHEYE_LENS_POLYNOMIAL:
|
||||
return PANORAMA_FISHEYE_LENS_POLYNOMIAL;
|
||||
case CAM_PANORAMA_CENTRAL_CYLINDRICAL:
|
||||
case blender::CAM_PANORAMA_CENTRAL_CYLINDRICAL:
|
||||
return PANORAMA_CENTRAL_CYLINDRICAL;
|
||||
}
|
||||
/* Could happen if loading a newer file that has an unsupported type. */
|
||||
|
|
@ -168,30 +168,30 @@ static PanoramaType blender_panorama_type_to_cycles(const int type)
|
|||
}
|
||||
|
||||
static void blender_camera_from_object(BlenderCamera *bcam,
|
||||
::RenderEngine &b_engine,
|
||||
::Object &b_ob,
|
||||
::Main &b_data,
|
||||
blender::RenderEngine &b_engine,
|
||||
blender::Object &b_ob,
|
||||
blender::Main &b_data,
|
||||
bool skip_panorama = false)
|
||||
{
|
||||
::ID &b_ob_data = *static_cast<::ID *>(b_ob.data);
|
||||
blender::ID &b_ob_data = *static_cast<blender::ID *>(b_ob.data);
|
||||
|
||||
if (GS(b_ob_data.name) == ID_CA) {
|
||||
::Camera &b_camera = blender::id_cast<::Camera &>(b_ob_data);
|
||||
if (GS(b_ob_data.name) == blender::ID_CA) {
|
||||
blender::Camera &b_camera = blender::id_cast<blender::Camera &>(b_ob_data);
|
||||
|
||||
bcam->nearclip = b_camera.clip_start;
|
||||
bcam->farclip = b_camera.clip_end;
|
||||
|
||||
switch (b_camera.type) {
|
||||
case CAM_ORTHO:
|
||||
case blender::CAM_ORTHO:
|
||||
bcam->type = CAMERA_ORTHOGRAPHIC;
|
||||
break;
|
||||
case CAM_CUSTOM:
|
||||
case blender::CAM_CUSTOM:
|
||||
bcam->type = skip_panorama ? CAMERA_PERSPECTIVE : CAMERA_CUSTOM;
|
||||
break;
|
||||
case CAM_PANO:
|
||||
case blender::CAM_PANO:
|
||||
bcam->type = skip_panorama ? CAMERA_PERSPECTIVE : CAMERA_PANORAMA;
|
||||
break;
|
||||
case CAM_PERSP:
|
||||
case blender::CAM_PERSP:
|
||||
default:
|
||||
bcam->type = CAMERA_PERSPECTIVE;
|
||||
break;
|
||||
|
|
@ -218,7 +218,7 @@ static void blender_camera_from_object(BlenderCamera *bcam,
|
|||
bcam->central_cylindrical_radius = b_camera.central_cylindrical_radius;
|
||||
|
||||
bcam->interocular_distance = b_camera.stereo.interocular_distance;
|
||||
if (b_camera.stereo.convergence_mode == CAM_S3D_PARALLEL) {
|
||||
if (b_camera.stereo.convergence_mode == blender::CAM_S3D_PARALLEL) {
|
||||
bcam->convergence_distance = FLT_MAX;
|
||||
}
|
||||
else {
|
||||
|
|
@ -226,7 +226,7 @@ static void blender_camera_from_object(BlenderCamera *bcam,
|
|||
}
|
||||
bcam->use_spherical_stereo = RE_engine_get_spherical_stereo(&b_engine, &b_ob);
|
||||
|
||||
bcam->use_pole_merge = b_camera.stereo.flag & CAM_S3D_POLE_MERGE;
|
||||
bcam->use_pole_merge = b_camera.stereo.flag & blender::CAM_S3D_POLE_MERGE;
|
||||
bcam->pole_merge_angle_from = b_camera.stereo.pole_merge_angle_from;
|
||||
bcam->pole_merge_angle_to = b_camera.stereo.pole_merge_angle_to;
|
||||
|
||||
|
|
@ -234,11 +234,11 @@ static void blender_camera_from_object(BlenderCamera *bcam,
|
|||
|
||||
bcam->lens = b_camera.lens;
|
||||
|
||||
bcam->passepartout_alpha = (b_camera.flag & CAM_SHOWPASSEPARTOUT) != 0 ?
|
||||
bcam->passepartout_alpha = (b_camera.flag & blender::CAM_SHOWPASSEPARTOUT) != 0 ?
|
||||
b_camera.passepartalpha :
|
||||
0.0f;
|
||||
|
||||
if (b_camera.dof.flag & CAM_DOF_ENABLED) {
|
||||
if (b_camera.dof.flag & blender::CAM_DOF_ENABLED) {
|
||||
/* allow f/stop number to change aperture_size but still
|
||||
* give manual control over aperture radius */
|
||||
float fstop = b_camera.dof.aperture_fstop;
|
||||
|
|
@ -271,10 +271,10 @@ static void blender_camera_from_object(BlenderCamera *bcam,
|
|||
bcam->sensor_width = b_camera.sensor_x;
|
||||
bcam->sensor_height = b_camera.sensor_y;
|
||||
|
||||
if (b_camera.sensor_fit == CAMERA_SENSOR_FIT_AUTO) {
|
||||
if (b_camera.sensor_fit == blender::CAMERA_SENSOR_FIT_AUTO) {
|
||||
bcam->sensor_fit = BlenderCamera::AUTO;
|
||||
}
|
||||
else if (b_camera.sensor_fit == CAMERA_SENSOR_FIT_HOR) {
|
||||
else if (b_camera.sensor_fit == blender::CAMERA_SENSOR_FIT_HOR) {
|
||||
bcam->sensor_fit = BlenderCamera::HORIZONTAL;
|
||||
}
|
||||
else {
|
||||
|
|
@ -282,7 +282,7 @@ static void blender_camera_from_object(BlenderCamera *bcam,
|
|||
}
|
||||
|
||||
if (bcam->type == CAMERA_CUSTOM) {
|
||||
PointerRNA camera_rna_ptr = RNA_id_pointer_create(&b_camera.id);
|
||||
blender::PointerRNA camera_rna_ptr = RNA_id_pointer_create(&b_camera.id);
|
||||
bcam->custom_props = RNA_pointer_get(&camera_rna_ptr, "cycles_custom");
|
||||
bcam->custom_bytecode_hash = b_camera.custom_bytecode_hash;
|
||||
if (!bcam->custom_bytecode_hash.empty()) {
|
||||
|
|
@ -294,9 +294,9 @@ static void blender_camera_from_object(BlenderCamera *bcam,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (GS(b_ob_data.name) == ID_LA) {
|
||||
else if (GS(b_ob_data.name) == blender::ID_LA) {
|
||||
/* Can also look through spot light. */
|
||||
const ::Light &b_light = reinterpret_cast<const ::Light &>(b_ob_data);
|
||||
const blender::Light &b_light = reinterpret_cast<const blender::Light &>(b_ob_data);
|
||||
const float lens = 16.0f / tanf(b_light.spotsize * 0.5f);
|
||||
if (lens > 0.0f) {
|
||||
bcam->lens = lens;
|
||||
|
|
@ -402,12 +402,12 @@ static void blender_camera_viewplane(BlenderCamera *bcam,
|
|||
|
||||
class BlenderCameraParamQuery : public OSLCameraParamQuery {
|
||||
public:
|
||||
BlenderCameraParamQuery(PointerRNA custom_props) : custom_props(custom_props) {}
|
||||
virtual ~BlenderCameraParamQuery() = default;
|
||||
BlenderCameraParamQuery(blender::PointerRNA custom_props) : custom_props(custom_props) {}
|
||||
~BlenderCameraParamQuery() override = default;
|
||||
|
||||
bool get_float(ustring name, vector<float> &data) override
|
||||
{
|
||||
PropertyRNA *prop = get_prop(name);
|
||||
blender::PropertyRNA *prop = get_prop(name);
|
||||
if (!prop) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ class BlenderCameraParamQuery : public OSLCameraParamQuery {
|
|||
|
||||
bool get_int(ustring name, vector<int> &data) override
|
||||
{
|
||||
PropertyRNA *prop = get_prop(name);
|
||||
blender::PropertyRNA *prop = get_prop(name);
|
||||
if (!prop) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -435,7 +435,7 @@ class BlenderCameraParamQuery : public OSLCameraParamQuery {
|
|||
|
||||
/* OSL represents booleans as integers, but we represent them as boolean-type
|
||||
* properties in RNA, so convert here. */
|
||||
if (RNA_property_type(prop) == PROP_BOOLEAN) {
|
||||
if (RNA_property_type(prop) == blender::PROP_BOOLEAN) {
|
||||
if (array_len > 0) {
|
||||
/* Can't use std::vector<bool> here since it's a weird special case. */
|
||||
array<bool> bool_data(array_len);
|
||||
|
|
@ -446,7 +446,7 @@ class BlenderCameraParamQuery : public OSLCameraParamQuery {
|
|||
data.push_back(RNA_property_boolean_get(&custom_props, prop));
|
||||
}
|
||||
}
|
||||
else if (RNA_property_type(prop) == PROP_ENUM) {
|
||||
else if (RNA_property_type(prop) == blender::PROP_ENUM) {
|
||||
const char *identifier = "";
|
||||
const int value = RNA_property_enum_get(&custom_props, prop);
|
||||
if (RNA_property_enum_identifier(nullptr, &custom_props, prop, value, &identifier)) {
|
||||
|
|
@ -470,7 +470,7 @@ class BlenderCameraParamQuery : public OSLCameraParamQuery {
|
|||
|
||||
bool get_string(ustring name, string &data) override
|
||||
{
|
||||
PropertyRNA *prop = get_prop(name);
|
||||
blender::PropertyRNA *prop = get_prop(name);
|
||||
if (!prop) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -479,9 +479,9 @@ class BlenderCameraParamQuery : public OSLCameraParamQuery {
|
|||
}
|
||||
|
||||
private:
|
||||
PointerRNA custom_props;
|
||||
blender::PointerRNA custom_props;
|
||||
|
||||
PropertyRNA *get_prop(ustring param)
|
||||
blender::PropertyRNA *get_prop(ustring param)
|
||||
{
|
||||
string name = string_printf("[\"%s\"]", param.c_str());
|
||||
return RNA_struct_find_property(&custom_props, name.c_str());
|
||||
|
|
@ -494,7 +494,7 @@ static void blender_camera_sync(Camera *cam,
|
|||
const int width,
|
||||
const int height,
|
||||
const char *viewname,
|
||||
PointerRNA *cscene)
|
||||
blender::PointerRNA *cscene)
|
||||
{
|
||||
float aspectratio;
|
||||
float sensor_size;
|
||||
|
|
@ -656,18 +656,18 @@ static void blender_camera_sync(Camera *cam,
|
|||
static MotionPosition blender_motion_blur_position_type_to_cycles(const int type)
|
||||
{
|
||||
switch (type) {
|
||||
case SCE_MB_START:
|
||||
case blender::SCE_MB_START:
|
||||
return MOTION_POSITION_START;
|
||||
case SCE_MB_CENTER:
|
||||
case blender::SCE_MB_CENTER:
|
||||
return MOTION_POSITION_CENTER;
|
||||
case SCE_MB_END:
|
||||
case blender::SCE_MB_END:
|
||||
return MOTION_POSITION_END;
|
||||
}
|
||||
/* Could happen if loading a newer file that has an unsupported type. */
|
||||
return MOTION_POSITION_CENTER;
|
||||
}
|
||||
|
||||
void BlenderSync::sync_camera(const RenderData &b_render,
|
||||
void BlenderSync::sync_camera(const blender::RenderData &b_render,
|
||||
const int width,
|
||||
const int height,
|
||||
const char *viewname)
|
||||
|
|
@ -681,11 +681,11 @@ void BlenderSync::sync_camera(const RenderData &b_render,
|
|||
bcam.motion_position = blender_motion_blur_position_type_to_cycles(
|
||||
b_render.motion_blur_position);
|
||||
|
||||
const ::CurveMapping &b_shutter_curve = b_render.mblur_shutter_curve;
|
||||
const blender::CurveMapping &b_shutter_curve = b_render.mblur_shutter_curve;
|
||||
curvemapping_to_array(b_shutter_curve, bcam.shutter_curve, RAMP_TABLE_SIZE);
|
||||
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
bcam.rolling_shutter_type = (Camera::RollingShutterType)get_enum(
|
||||
cscene,
|
||||
"rolling_shutter_type",
|
||||
|
|
@ -694,7 +694,7 @@ void BlenderSync::sync_camera(const RenderData &b_render,
|
|||
bcam.rolling_shutter_duration = RNA_float_get(&cscene, "rolling_shutter_duration");
|
||||
|
||||
/* border */
|
||||
if (b_render.mode & R_BORDER) {
|
||||
if (b_render.mode & blender::R_BORDER) {
|
||||
bcam.border.left = b_render.border.xmin;
|
||||
bcam.border.right = b_render.border.xmax;
|
||||
bcam.border.bottom = b_render.border.ymin;
|
||||
|
|
@ -702,7 +702,7 @@ void BlenderSync::sync_camera(const RenderData &b_render,
|
|||
}
|
||||
|
||||
/* camera object */
|
||||
::Object *b_ob = get_camera_object(nullptr, nullptr);
|
||||
blender::Object *b_ob = get_camera_object(nullptr, nullptr);
|
||||
|
||||
if (b_ob) {
|
||||
blender::float4x4 b_ob_matrix;
|
||||
|
|
@ -710,7 +710,8 @@ void BlenderSync::sync_camera(const RenderData &b_render,
|
|||
RE_engine_get_camera_model_matrix(
|
||||
b_engine, b_ob, bcam.use_spherical_stereo, b_ob_matrix.base_ptr());
|
||||
bcam.matrix = get_transform(b_ob_matrix);
|
||||
scene->bake_manager->set_use_camera(b_render.bake.view_from == R_BAKE_VIEW_FROM_ACTIVE_CAMERA);
|
||||
scene->bake_manager->set_use_camera(b_render.bake.view_from ==
|
||||
blender::R_BAKE_VIEW_FROM_ACTIVE_CAMERA);
|
||||
}
|
||||
else {
|
||||
scene->bake_manager->set_use_camera(false);
|
||||
|
|
@ -721,7 +722,7 @@ void BlenderSync::sync_camera(const RenderData &b_render,
|
|||
blender_camera_sync(cam, scene, &bcam, width, height, viewname, &cscene);
|
||||
|
||||
/* dicing camera */
|
||||
b_ob = RNA_pointer_get(&cscene, "dicing_camera").data_as<::Object>();
|
||||
b_ob = RNA_pointer_get(&cscene, "dicing_camera").data_as<blender::Object>();
|
||||
if (b_ob) {
|
||||
blender::float4x4 b_ob_matrix;
|
||||
blender_camera_from_object(&bcam, *b_engine, *b_ob, *b_data);
|
||||
|
|
@ -737,37 +738,39 @@ void BlenderSync::sync_camera(const RenderData &b_render,
|
|||
}
|
||||
|
||||
/* See #rna_RenderEngine_camera_override_get. */
|
||||
static ::Object *camera_override_get(::RenderEngine *engine)
|
||||
static blender::Object *camera_override_get(blender::RenderEngine *engine)
|
||||
{
|
||||
/* TODO(sergey): Shouldn't engine point to an evaluated datablocks already? */
|
||||
if (engine->re) {
|
||||
::Object *cam = RE_GetCamera(engine->re);
|
||||
::Object *cam_eval = DEG_get_evaluated(engine->depsgraph, cam);
|
||||
blender::Object *cam = RE_GetCamera(engine->re);
|
||||
blender::Object *cam_eval = DEG_get_evaluated(engine->depsgraph, cam);
|
||||
return cam_eval;
|
||||
}
|
||||
return engine->camera_override;
|
||||
}
|
||||
|
||||
::Object *BlenderSync::get_camera_object(::View3D *b_v3d, ::RegionView3D *b_rv3d)
|
||||
blender::Object *BlenderSync::get_camera_object(blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d)
|
||||
{
|
||||
/* TODO(sergey): Shouldn't engine point to an evaluated datablocks already? */
|
||||
::Object *b_camera_override = camera_override_get(b_engine);
|
||||
blender::Object *b_camera_override = camera_override_get(b_engine);
|
||||
if (b_camera_override) {
|
||||
return b_camera_override;
|
||||
}
|
||||
|
||||
if (b_v3d && b_rv3d && b_rv3d->persp == RV3D_CAMOB && b_v3d->scenelock) {
|
||||
if (b_v3d && b_rv3d && b_rv3d->persp == blender::RV3D_CAMOB && b_v3d->scenelock) {
|
||||
return b_v3d->camera;
|
||||
}
|
||||
|
||||
return b_scene->camera;
|
||||
}
|
||||
|
||||
::Object *BlenderSync::get_dicing_camera_object(::View3D *b_v3d, ::RegionView3D *b_rv3d)
|
||||
blender::Object *BlenderSync::get_dicing_camera_object(blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d)
|
||||
{
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
::Object *b_ob = RNA_pointer_get(&cscene, "dicing_camera").data_as<::Object>();
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::Object *b_ob = RNA_pointer_get(&cscene, "dicing_camera").data_as<blender::Object>();
|
||||
if (b_ob) {
|
||||
return b_ob;
|
||||
}
|
||||
|
|
@ -775,8 +778,8 @@ static ::Object *camera_override_get(::RenderEngine *engine)
|
|||
return get_camera_object(b_v3d, b_rv3d);
|
||||
}
|
||||
|
||||
void BlenderSync::sync_camera_motion(const ::RenderData &b_render,
|
||||
::Object *b_ob,
|
||||
void BlenderSync::sync_camera_motion(const blender::RenderData &b_render,
|
||||
blender::Object *b_ob,
|
||||
const int width,
|
||||
const int height,
|
||||
const float motion_time)
|
||||
|
|
@ -839,13 +842,13 @@ void BlenderSync::sync_camera_motion(const ::RenderData &b_render,
|
|||
|
||||
/* Sync 3D View Camera */
|
||||
|
||||
static void blender_camera_view_subset(::RenderEngine &b_engine,
|
||||
const ::RenderData &b_render,
|
||||
::Scene &b_scene,
|
||||
::Main &b_data,
|
||||
::Object &b_ob,
|
||||
::View3D *&b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
static void blender_camera_view_subset(blender::RenderEngine &b_engine,
|
||||
const blender::RenderData &b_render,
|
||||
blender::Scene &b_scene,
|
||||
blender::Main &b_data,
|
||||
blender::Object &b_ob,
|
||||
blender::View3D *&b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height,
|
||||
BoundBox2D &view_box,
|
||||
|
|
@ -853,11 +856,11 @@ static void blender_camera_view_subset(::RenderEngine &b_engine,
|
|||
float &view_aspect);
|
||||
|
||||
static void blender_camera_from_view(BlenderCamera *bcam,
|
||||
::RenderEngine &b_engine,
|
||||
::Scene &b_scene,
|
||||
::Main &b_data,
|
||||
::View3D *&b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
blender::RenderEngine &b_engine,
|
||||
blender::Scene &b_scene,
|
||||
blender::Main &b_data,
|
||||
blender::View3D *&b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height,
|
||||
bool skip_panorama = false)
|
||||
|
|
@ -868,12 +871,12 @@ static void blender_camera_from_view(BlenderCamera *bcam,
|
|||
bcam->lens = b_v3d->lens;
|
||||
bcam->shuttertime = b_scene.r.motion_blur_shutter;
|
||||
|
||||
::CurveMapping &b_shutter_curve = b_scene.r.mblur_shutter_curve;
|
||||
blender::CurveMapping &b_shutter_curve = b_scene.r.mblur_shutter_curve;
|
||||
curvemapping_to_array(b_shutter_curve, bcam->shutter_curve, RAMP_TABLE_SIZE);
|
||||
|
||||
if (b_rv3d->persp == RV3D_CAMOB) {
|
||||
if (b_rv3d->persp == blender::RV3D_CAMOB) {
|
||||
/* camera view */
|
||||
::Object *b_ob = (b_v3d->scenelock) ? b_v3d->camera : b_scene.camera;
|
||||
blender::Object *b_ob = (b_v3d->scenelock) ? b_v3d->camera : b_scene.camera;
|
||||
|
||||
if (b_ob) {
|
||||
blender_camera_from_object(bcam, b_engine, *b_ob, b_data, skip_panorama);
|
||||
|
|
@ -912,7 +915,7 @@ static void blender_camera_from_view(BlenderCamera *bcam,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (b_rv3d->persp == RV3D_ORTHO) {
|
||||
else if (b_rv3d->persp == blender::RV3D_ORTHO) {
|
||||
/* orthographic view */
|
||||
bcam->farclip *= 0.5f;
|
||||
bcam->nearclip = -bcam->farclip;
|
||||
|
|
@ -939,13 +942,13 @@ static void blender_camera_from_view(BlenderCamera *bcam,
|
|||
bcam->full_height = height;
|
||||
}
|
||||
|
||||
static void blender_camera_view_subset(::RenderEngine &b_engine,
|
||||
const ::RenderData &b_render,
|
||||
::Scene &b_scene,
|
||||
::Main &b_data,
|
||||
::Object &b_ob,
|
||||
::View3D *&b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
static void blender_camera_view_subset(blender::RenderEngine &b_engine,
|
||||
const blender::RenderData &b_render,
|
||||
blender::Scene &b_scene,
|
||||
blender::Main &b_data,
|
||||
blender::Object &b_ob,
|
||||
blender::View3D *&b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height,
|
||||
BoundBox2D &view_box,
|
||||
|
|
@ -980,13 +983,13 @@ static void blender_camera_view_subset(::RenderEngine &b_engine,
|
|||
cam_box = cam * (1.0f / cam_aspect);
|
||||
}
|
||||
|
||||
static void blender_camera_border_subset(::RenderEngine &b_engine,
|
||||
const ::RenderData &b_render,
|
||||
::Scene &b_scene,
|
||||
::Main &b_data,
|
||||
::View3D *&b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
::Object &b_ob,
|
||||
static void blender_camera_border_subset(blender::RenderEngine &b_engine,
|
||||
const blender::RenderData &b_render,
|
||||
blender::Scene &b_scene,
|
||||
blender::Main &b_data,
|
||||
blender::View3D *&b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
blender::Object &b_ob,
|
||||
const int width,
|
||||
const int height,
|
||||
const BoundBox2D &border,
|
||||
|
|
@ -1015,26 +1018,26 @@ static void blender_camera_border_subset(::RenderEngine &b_engine,
|
|||
}
|
||||
|
||||
static void blender_camera_border(BlenderCamera *bcam,
|
||||
::RenderEngine &b_engine,
|
||||
const ::RenderData &b_render,
|
||||
::Scene &b_scene,
|
||||
::Main &b_data,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
blender::RenderEngine &b_engine,
|
||||
const blender::RenderData &b_render,
|
||||
blender::Scene &b_scene,
|
||||
blender::Main &b_data,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height)
|
||||
{
|
||||
bool is_camera_view;
|
||||
|
||||
/* camera view? */
|
||||
is_camera_view = b_rv3d->persp == RV3D_CAMOB;
|
||||
is_camera_view = b_rv3d->persp == blender::RV3D_CAMOB;
|
||||
|
||||
if (!is_camera_view) {
|
||||
/* for non-camera view check whether render border is enabled for viewport
|
||||
* and if so use border from 3d viewport
|
||||
* assume viewport has got correctly clamped border already
|
||||
*/
|
||||
if (b_v3d->flag2 & V3D_RENDER_BORDER) {
|
||||
if (b_v3d->flag2 & blender::V3D_RENDER_BORDER) {
|
||||
bcam->border.left = b_v3d->render_border.xmin;
|
||||
bcam->border.right = b_v3d->render_border.xmax;
|
||||
bcam->border.bottom = b_v3d->render_border.ymin;
|
||||
|
|
@ -1043,7 +1046,7 @@ static void blender_camera_border(BlenderCamera *bcam,
|
|||
return;
|
||||
}
|
||||
|
||||
::Object *b_ob = (b_v3d->scenelock) ? b_v3d->camera : b_scene.camera;
|
||||
blender::Object *b_ob = (b_v3d->scenelock) ? b_v3d->camera : b_scene.camera;
|
||||
|
||||
if (!b_ob) {
|
||||
return;
|
||||
|
|
@ -1063,7 +1066,7 @@ static void blender_camera_border(BlenderCamera *bcam,
|
|||
full_border,
|
||||
&bcam->viewport_camera_border);
|
||||
|
||||
if (b_render.mode & R_BORDER) {
|
||||
if (b_render.mode & blender::R_BORDER) {
|
||||
bcam->border.left = b_render.border.xmin;
|
||||
bcam->border.right = b_render.border.xmax;
|
||||
bcam->border.bottom = b_render.border.ymin;
|
||||
|
|
@ -1091,22 +1094,22 @@ static void blender_camera_border(BlenderCamera *bcam,
|
|||
bcam->border = bcam->border.clamp();
|
||||
}
|
||||
|
||||
void BlenderSync::sync_view(::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
void BlenderSync::sync_view(blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height)
|
||||
{
|
||||
const ::RenderData &b_render_settings = b_scene->r;
|
||||
const blender::RenderData &b_render_settings = b_scene->r;
|
||||
BlenderCamera bcam(b_render_settings);
|
||||
blender_camera_from_view(&bcam, *b_engine, *b_scene, *b_data, b_v3d, b_rv3d, width, height);
|
||||
blender_camera_border(
|
||||
&bcam, *b_engine, b_render_settings, *b_scene, *b_data, b_v3d, b_rv3d, width, height);
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender_camera_sync(scene->camera, scene, &bcam, width, height, "", &cscene);
|
||||
|
||||
/* dicing camera */
|
||||
::Object *b_ob = RNA_pointer_get(&cscene, "dicing_camera").data_as<::Object>();
|
||||
blender::Object *b_ob = RNA_pointer_get(&cscene, "dicing_camera").data_as<blender::Object>();
|
||||
if (b_ob) {
|
||||
blender::float4x4 b_ob_matrix;
|
||||
blender_camera_from_object(&bcam, *b_engine, *b_ob, *b_data);
|
||||
|
|
@ -1121,8 +1124,11 @@ void BlenderSync::sync_view(::View3D *b_v3d,
|
|||
}
|
||||
}
|
||||
|
||||
BufferParams BlenderSync::get_buffer_params(
|
||||
::View3D *b_v3d, ::RegionView3D *b_rv3d, Camera *cam, const int width, const int height)
|
||||
BufferParams BlenderSync::get_buffer_params(blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
Camera *cam,
|
||||
const int width,
|
||||
const int height)
|
||||
{
|
||||
BufferParams params;
|
||||
bool use_border = false;
|
||||
|
|
@ -1130,8 +1136,8 @@ BufferParams BlenderSync::get_buffer_params(
|
|||
params.full_width = width;
|
||||
params.full_height = height;
|
||||
|
||||
if (b_v3d && b_rv3d && b_rv3d->persp != RV3D_CAMOB) {
|
||||
use_border = b_v3d->flag2 & V3D_RENDER_BORDER;
|
||||
if (b_v3d && b_rv3d && b_rv3d->persp != blender::RV3D_CAMOB) {
|
||||
use_border = b_v3d->flag2 & blender::V3D_RENDER_BORDER;
|
||||
}
|
||||
else {
|
||||
/* the camera can always have a passepartout */
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@
|
|||
#include "BKE_mesh_legacy_convert.hh"
|
||||
#include "BKE_particle.h"
|
||||
|
||||
namespace blender {
|
||||
struct ModifierData;
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
|
@ -62,8 +64,8 @@ static float shaperadius(const float shape, const float root, const float tip, c
|
|||
/* curve functions */
|
||||
|
||||
static bool ObtainCacheParticleData(Hair *hair,
|
||||
const ::Mesh *b_mesh,
|
||||
const ::Object *b_ob,
|
||||
const blender::Mesh *b_mesh,
|
||||
const blender::Object *b_ob,
|
||||
ParticleCurveData *CData,
|
||||
bool background)
|
||||
{
|
||||
|
|
@ -77,16 +79,16 @@ static bool ObtainCacheParticleData(Hair *hair,
|
|||
const Transform tfm = get_transform(b_ob->object_to_world());
|
||||
const Transform itfm = transform_inverse(tfm);
|
||||
|
||||
for (const ::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == eModifierType_ParticleSystem) &&
|
||||
(background ? ((b_mod.mode & eModifierMode_Render) != 0) :
|
||||
((b_mod.mode & eModifierMode_Realtime) != 0)))
|
||||
for (const blender::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == blender::eModifierType_ParticleSystem) &&
|
||||
(background ? ((b_mod.mode & blender::eModifierMode_Render) != 0) :
|
||||
((b_mod.mode & blender::eModifierMode_Realtime) != 0)))
|
||||
{
|
||||
const auto *psmd = reinterpret_cast<const ::ParticleSystemModifierData *>(&b_mod);
|
||||
::ParticleSystem *b_psys = psmd->psys;
|
||||
::ParticleSettings *b_part = b_psys->part;
|
||||
const auto *psmd = reinterpret_cast<const blender::ParticleSystemModifierData *>(&b_mod);
|
||||
blender::ParticleSystem *b_psys = psmd->psys;
|
||||
blender::ParticleSettings *b_part = b_psys->part;
|
||||
|
||||
if ((b_part->ren_as == PART_DRAW_PATH) && (b_part->type == PART_HAIR)) {
|
||||
if ((b_part->ren_as == blender::PART_DRAW_PATH) && (b_part->type == blender::PART_HAIR)) {
|
||||
const int shader = clamp(b_part->omat - 1, 0, hair->get_used_shaders().size() - 1);
|
||||
const int display_step = background ? b_part->ren_step : b_part->draw_step;
|
||||
const int totparts = b_psys->totpart;
|
||||
|
|
@ -104,7 +106,7 @@ static bool ObtainCacheParticleData(Hair *hair,
|
|||
}
|
||||
|
||||
int ren_step = (1 << display_step) + 1;
|
||||
if (b_part->kink == PART_KINK_SPIRAL) {
|
||||
if (b_part->kink == blender::PART_KINK_SPIRAL) {
|
||||
ren_step += b_part->kink_extra_steps;
|
||||
}
|
||||
|
||||
|
|
@ -117,7 +119,8 @@ static bool ObtainCacheParticleData(Hair *hair,
|
|||
CData->psys_rootradius.push_back_slow(radius * b_part->rad_root);
|
||||
CData->psys_tipradius.push_back_slow(radius * b_part->rad_tip);
|
||||
CData->psys_shape.push_back_slow(b_part->shape);
|
||||
CData->psys_closetip.push_back_slow((b_part->shape_flag & PART_SHAPE_CLOSE_TIP) != 0);
|
||||
CData->psys_closetip.push_back_slow((b_part->shape_flag & blender::PART_SHAPE_CLOSE_TIP) !=
|
||||
0);
|
||||
|
||||
int pa_no = 0;
|
||||
if (!(b_part->childtype == 0) && totchild != 0) {
|
||||
|
|
@ -166,8 +169,8 @@ static bool ObtainCacheParticleData(Hair *hair,
|
|||
}
|
||||
|
||||
static bool ObtainCacheParticleUV(Hair *hair,
|
||||
const ::Mesh *b_mesh,
|
||||
const ::Object *b_ob,
|
||||
const blender::Mesh *b_mesh,
|
||||
const blender::Object *b_ob,
|
||||
ParticleCurveData *CData,
|
||||
bool background,
|
||||
const int uv_num)
|
||||
|
|
@ -178,16 +181,16 @@ static bool ObtainCacheParticleUV(Hair *hair,
|
|||
|
||||
CData->curve_uv.clear();
|
||||
|
||||
for (::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == eModifierType_ParticleSystem) &&
|
||||
(background ? ((b_mod.mode & eModifierMode_Render) != 0) :
|
||||
((b_mod.mode & eModifierMode_Realtime) != 0)))
|
||||
for (blender::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == blender::eModifierType_ParticleSystem) &&
|
||||
(background ? ((b_mod.mode & blender::eModifierMode_Render) != 0) :
|
||||
((b_mod.mode & blender::eModifierMode_Realtime) != 0)))
|
||||
{
|
||||
auto *psmd = reinterpret_cast<::ParticleSystemModifierData *>(&b_mod);
|
||||
::ParticleSystem *b_psys = psmd->psys;
|
||||
::ParticleSettings *b_part = b_psys->part;
|
||||
auto *psmd = reinterpret_cast<blender::ParticleSystemModifierData *>(&b_mod);
|
||||
blender::ParticleSystem *b_psys = psmd->psys;
|
||||
blender::ParticleSettings *b_part = b_psys->part;
|
||||
|
||||
if ((b_part->ren_as == PART_DRAW_PATH) && (b_part->type == PART_HAIR)) {
|
||||
if ((b_part->ren_as == blender::PART_DRAW_PATH) && (b_part->type == blender::PART_HAIR)) {
|
||||
const int totparts = b_psys->totpart;
|
||||
const int totchild = background ?
|
||||
b_psys->totchild :
|
||||
|
|
@ -210,7 +213,8 @@ static bool ObtainCacheParticleUV(Hair *hair,
|
|||
const int num_add = (totparts + totchild - pa_no);
|
||||
CData->curve_uv.reserve(CData->curve_uv.size() + num_add);
|
||||
|
||||
blender::MutableSpan<::ParticleData> b_psys_particles(b_psys->particles, b_psys->totpart);
|
||||
blender::MutableSpan<blender::ParticleData> b_psys_particles(b_psys->particles,
|
||||
b_psys->totpart);
|
||||
auto *b_pa = b_psys_particles.begin();
|
||||
for (; pa_no < totparts + totchild; pa_no++) {
|
||||
/* Add UVs */
|
||||
|
|
@ -230,8 +234,8 @@ static bool ObtainCacheParticleUV(Hair *hair,
|
|||
}
|
||||
|
||||
static bool ObtainCacheParticleVcol(Hair *hair,
|
||||
const ::Mesh *b_mesh,
|
||||
const ::Object *b_ob,
|
||||
const blender::Mesh *b_mesh,
|
||||
const blender::Object *b_ob,
|
||||
ParticleCurveData *CData,
|
||||
bool background,
|
||||
const int vcol_num)
|
||||
|
|
@ -242,16 +246,16 @@ static bool ObtainCacheParticleVcol(Hair *hair,
|
|||
|
||||
CData->curve_vcol.clear();
|
||||
|
||||
for (::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == eModifierType_ParticleSystem) &&
|
||||
(background ? ((b_mod.mode & eModifierMode_Render) != 0) :
|
||||
((b_mod.mode & eModifierMode_Realtime) != 0)))
|
||||
for (blender::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == blender::eModifierType_ParticleSystem) &&
|
||||
(background ? ((b_mod.mode & blender::eModifierMode_Render) != 0) :
|
||||
((b_mod.mode & blender::eModifierMode_Realtime) != 0)))
|
||||
{
|
||||
auto *psmd = reinterpret_cast<::ParticleSystemModifierData *>(&b_mod);
|
||||
::ParticleSystem *b_psys = psmd->psys;
|
||||
::ParticleSettings *b_part = b_psys->part;
|
||||
auto *psmd = reinterpret_cast<blender::ParticleSystemModifierData *>(&b_mod);
|
||||
blender::ParticleSystem *b_psys = psmd->psys;
|
||||
blender::ParticleSettings *b_part = b_psys->part;
|
||||
|
||||
if ((b_part->ren_as == PART_DRAW_PATH) && (b_part->type == PART_HAIR)) {
|
||||
if ((b_part->ren_as == blender::PART_DRAW_PATH) && (b_part->type == blender::PART_HAIR)) {
|
||||
const int totparts = b_psys->totpart;
|
||||
const int totchild = background ?
|
||||
b_psys->totchild :
|
||||
|
|
@ -274,7 +278,8 @@ static bool ObtainCacheParticleVcol(Hair *hair,
|
|||
const int num_add = (totparts + totchild - pa_no);
|
||||
CData->curve_vcol.reserve(CData->curve_vcol.size() + num_add);
|
||||
|
||||
blender::MutableSpan<::ParticleData> b_psys_particles(b_psys->particles, b_psys->totpart);
|
||||
blender::MutableSpan<blender::ParticleData> b_psys_particles(b_psys->particles,
|
||||
b_psys->totpart);
|
||||
auto *b_pa = b_psys_particles.begin();
|
||||
for (; pa_no < totparts + totchild; pa_no++) {
|
||||
/* Add vertex colors */
|
||||
|
|
@ -547,19 +552,19 @@ static void ExportCurveSegmentsMotion(Hair *hair, ParticleCurveData *CData, cons
|
|||
|
||||
/* Hair Curve Sync */
|
||||
|
||||
bool BlenderSync::object_has_particle_hair(::Object *b_ob)
|
||||
bool BlenderSync::object_has_particle_hair(blender::Object *b_ob)
|
||||
{
|
||||
/* Test if the object has a particle modifier with hair. */
|
||||
for (::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == eModifierType_ParticleSystem) &&
|
||||
(preview ? ((b_mod.mode & eModifierMode_Realtime) != 0) :
|
||||
((b_mod.mode & eModifierMode_Render) != 0)))
|
||||
for (blender::ModifierData &b_mod : b_ob->modifiers) {
|
||||
if ((b_mod.type == blender::eModifierType_ParticleSystem) &&
|
||||
(preview ? ((b_mod.mode & blender::eModifierMode_Realtime) != 0) :
|
||||
((b_mod.mode & blender::eModifierMode_Render) != 0)))
|
||||
{
|
||||
auto *psmd = reinterpret_cast<::ParticleSystemModifierData *>(&b_mod);
|
||||
::ParticleSystem *b_psys = psmd->psys;
|
||||
::ParticleSettings *b_part = b_psys->part;
|
||||
auto *psmd = reinterpret_cast<blender::ParticleSystemModifierData *>(&b_mod);
|
||||
blender::ParticleSystem *b_psys = psmd->psys;
|
||||
blender::ParticleSettings *b_part = b_psys->part;
|
||||
|
||||
if ((b_part->ren_as == PART_DRAW_PATH) && (b_part->type == PART_HAIR)) {
|
||||
if ((b_part->ren_as == blender::PART_DRAW_PATH) && (b_part->type == blender::PART_HAIR)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -569,16 +574,19 @@ bool BlenderSync::object_has_particle_hair(::Object *b_ob)
|
|||
}
|
||||
|
||||
/* Old particle hair. */
|
||||
void BlenderSync::sync_particle_hair(
|
||||
Hair *hair, const ::Mesh &b_mesh, BObjectInfo &b_ob_info, bool motion, const int motion_step)
|
||||
void BlenderSync::sync_particle_hair(Hair *hair,
|
||||
const blender::Mesh &b_mesh,
|
||||
BObjectInfo &b_ob_info,
|
||||
bool motion,
|
||||
const int motion_step)
|
||||
{
|
||||
if (!b_ob_info.is_real_object_data()) {
|
||||
return;
|
||||
}
|
||||
const ::Object &b_ob = *b_ob_info.real_object;
|
||||
const blender::Object &b_ob = *b_ob_info.real_object;
|
||||
|
||||
/* obtain general settings */
|
||||
if (b_ob.mode == OB_MODE_PARTICLE_EDIT || b_ob.mode == OB_MODE_EDIT) {
|
||||
if (b_ob.mode == blender::OB_MODE_PARTICLE_EDIT || b_ob.mode == blender::OB_MODE_EDIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1008,7 +1016,7 @@ void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, con
|
|||
|
||||
/* Convert Blender hair to Cycles curves. */
|
||||
const blender::bke::CurvesGeometry &b_curves(
|
||||
blender::id_cast<const ::Curves *>(b_ob_info.object_data)->geometry.wrap());
|
||||
blender::id_cast<const blender::Curves *>(b_ob_info.object_data)->geometry.wrap());
|
||||
if (motion) {
|
||||
export_hair_curves_motion(hair, b_curves, motion_step);
|
||||
}
|
||||
|
|
@ -1018,7 +1026,7 @@ void BlenderSync::sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, con
|
|||
|
||||
const blender::VArray<int8_t> b_types = b_curves.curve_types();
|
||||
/* This does not handle cases where the curve type is not the same across all curves */
|
||||
if (!b_types.is_empty() && b_types[0] == CURVE_TYPE_POLY) {
|
||||
if (!b_types.is_empty() && b_types[0] == blender::CURVE_TYPE_POLY) {
|
||||
hair->curve_shape = CURVE_THICK_LINEAR;
|
||||
}
|
||||
else {
|
||||
|
|
@ -1036,13 +1044,13 @@ void BlenderSync::sync_hair(BObjectInfo &b_ob_info, Hair *hair)
|
|||
new_hair.set_used_shaders(used_shaders);
|
||||
|
||||
if (view_layer.use_hair) {
|
||||
if (GS(b_ob_info.object_data->name) == ID_CV) {
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_CV) {
|
||||
/* Hair object. */
|
||||
sync_hair(&new_hair, b_ob_info, false);
|
||||
}
|
||||
else {
|
||||
/* Particle hair. */
|
||||
::Mesh *b_mesh = object_to_mesh(b_ob_info);
|
||||
blender::Mesh *b_mesh = object_to_mesh(b_ob_info);
|
||||
|
||||
if (b_mesh) {
|
||||
sync_particle_hair(&new_hair, *b_mesh, b_ob_info, false);
|
||||
|
|
@ -1083,14 +1091,14 @@ void BlenderSync::sync_hair_motion(BObjectInfo &b_ob_info, Hair *hair, const int
|
|||
|
||||
/* Export deformed coordinates. */
|
||||
if (ccl::BKE_object_is_deform_modified(b_ob_info, *b_scene, preview)) {
|
||||
if (GS(b_ob_info.object_data->name) == ID_CV) {
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_CV) {
|
||||
/* Hair object. */
|
||||
sync_hair(hair, b_ob_info, true, motion_step);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Particle hair. */
|
||||
::Mesh *b_mesh = object_to_mesh(b_ob_info);
|
||||
blender::Mesh *b_mesh = object_to_mesh(b_ob_info);
|
||||
if (b_mesh) {
|
||||
sync_particle_hair(hair, *b_mesh, b_ob_info, true, motion_step);
|
||||
free_object_to_mesh(b_ob_info, *b_mesh);
|
||||
|
|
|
|||
|
|
@ -22,18 +22,18 @@ enum ComputeDevice {
|
|||
COMPUTE_DEVICE_NUM
|
||||
};
|
||||
|
||||
int blender_device_threads(::Scene &b_scene)
|
||||
int blender_device_threads(blender::Scene &b_scene)
|
||||
{
|
||||
::RenderData &b_r = b_scene.r;
|
||||
int threads_override = BLI_system_num_threads_override_get();
|
||||
if (threads_override > 0 || (b_r.mode & R_FIXED_THREADS) != 0) {
|
||||
blender::RenderData &b_r = b_scene.r;
|
||||
int threads_override = blender::BLI_system_num_threads_override_get();
|
||||
if (threads_override > 0 || (b_r.mode & blender::R_FIXED_THREADS) != 0) {
|
||||
return BKE_render_num_threads(&b_r);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void adjust_device_info_from_preferences(DeviceInfo &info, PointerRNA cpreferences)
|
||||
static void adjust_device_info_from_preferences(DeviceInfo &info, blender::PointerRNA cpreferences)
|
||||
{
|
||||
if (!get_boolean(cpreferences, "peer_memory")) {
|
||||
info.has_peer_memory = false;
|
||||
|
|
@ -61,7 +61,7 @@ static void adjust_device_info_from_preferences(DeviceInfo &info, PointerRNA cpr
|
|||
}
|
||||
}
|
||||
|
||||
static void adjust_device_info(DeviceInfo &device, PointerRNA cpreferences, bool preview)
|
||||
static void adjust_device_info(DeviceInfo &device, blender::PointerRNA cpreferences, bool preview)
|
||||
{
|
||||
adjust_device_info_from_preferences(device, cpreferences);
|
||||
for (DeviceInfo &info : device.multi_devices) {
|
||||
|
|
@ -81,20 +81,21 @@ static void adjust_device_info(DeviceInfo &device, PointerRNA cpreferences, bool
|
|||
}
|
||||
}
|
||||
|
||||
DeviceInfo blender_device_info(::UserDef &b_preferences,
|
||||
::Scene &b_scene,
|
||||
DeviceInfo blender_device_info(blender::UserDef &b_preferences,
|
||||
blender::Scene &b_scene,
|
||||
bool background,
|
||||
bool preview,
|
||||
DeviceInfo &preferences_device)
|
||||
{
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
|
||||
/* Find cycles preferences. */
|
||||
PointerRNA cpreferences;
|
||||
for (bAddon &b_addon : b_preferences.addons) {
|
||||
blender::PointerRNA cpreferences;
|
||||
for (blender::bAddon &b_addon : b_preferences.addons) {
|
||||
if (STREQ(b_addon.module, "cycles")) {
|
||||
PointerRNA addon_rna_ptr = RNA_pointer_create_discrete(nullptr, &RNA_Addon, &b_addon);
|
||||
blender::PointerRNA addon_rna_ptr = RNA_pointer_create_discrete(
|
||||
nullptr, &blender::RNA_Addon, &b_addon);
|
||||
cpreferences = RNA_pointer_get(&addon_rna_ptr, "preferences");
|
||||
break;
|
||||
}
|
||||
|
|
@ -132,7 +133,11 @@ DeviceInfo blender_device_info(::UserDef &b_preferences,
|
|||
|
||||
/* Match device preferences and available devices. */
|
||||
vector<DeviceInfo> used_devices;
|
||||
RNA_BEGIN (&cpreferences, device, "devices") {
|
||||
blender::CollectionPropertyIterator rna_iter;
|
||||
for (RNA_collection_begin(&cpreferences, "devices", &rna_iter); rna_iter.valid;
|
||||
RNA_property_collection_next(&rna_iter))
|
||||
{
|
||||
blender::PointerRNA device = rna_iter.ptr;
|
||||
if (get_boolean(device, "use")) {
|
||||
const string id = get_string(device, "id");
|
||||
for (const DeviceInfo &info : devices) {
|
||||
|
|
@ -143,7 +148,7 @@ DeviceInfo blender_device_info(::UserDef &b_preferences,
|
|||
}
|
||||
}
|
||||
}
|
||||
RNA_END;
|
||||
blender::RNA_property_collection_end(&rna_iter);
|
||||
|
||||
if (!used_devices.empty()) {
|
||||
const int threads = blender_device_threads(b_scene);
|
||||
|
|
|
|||
|
|
@ -4,21 +4,23 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace blender {
|
||||
struct Scene;
|
||||
struct UserDef;
|
||||
} // namespace blender
|
||||
|
||||
#include "device/device.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Get number of threads to use for rendering. */
|
||||
int blender_device_threads(::Scene &b_scene);
|
||||
int blender_device_threads(blender::Scene &b_scene);
|
||||
|
||||
/* Convert Blender settings to device specification. In addition, preferences_device contains the
|
||||
* device chosen in Cycles global preferences, which is useful for the denoiser device selection.
|
||||
*/
|
||||
DeviceInfo blender_device_info(::UserDef &b_preferences,
|
||||
::Scene &b_scene,
|
||||
DeviceInfo blender_device_info(blender::UserDef &b_preferences,
|
||||
blender::Scene &b_scene,
|
||||
bool background,
|
||||
bool preview,
|
||||
DeviceInfo &preferences_device);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ CCL_NAMESPACE_BEGIN
|
|||
* BlenderDisplayShader.
|
||||
*/
|
||||
|
||||
unique_ptr<BlenderDisplayShader> BlenderDisplayShader::create(::RenderEngine &b_engine,
|
||||
::Scene &b_scene)
|
||||
unique_ptr<BlenderDisplayShader> BlenderDisplayShader::create(blender::RenderEngine &b_engine,
|
||||
blender::Scene &b_scene)
|
||||
{
|
||||
/* See #engine_support_display_space_shader in rna_render.cc. */
|
||||
if (true) {
|
||||
|
|
@ -39,8 +39,8 @@ int BlenderDisplayShader::get_position_attrib_location()
|
|||
{
|
||||
if (position_attribute_location_ == -1) {
|
||||
blender::gpu::Shader *shader_program = get_shader_program();
|
||||
position_attribute_location_ = GPU_shader_get_attribute(shader_program,
|
||||
position_attribute_name);
|
||||
position_attribute_location_ = blender::GPU_shader_get_attribute(shader_program,
|
||||
position_attribute_name);
|
||||
}
|
||||
return position_attribute_location_;
|
||||
}
|
||||
|
|
@ -49,8 +49,8 @@ int BlenderDisplayShader::get_tex_coord_attrib_location()
|
|||
{
|
||||
if (tex_coord_attribute_location_ == -1) {
|
||||
blender::gpu::Shader *shader_program = get_shader_program();
|
||||
tex_coord_attribute_location_ = GPU_shader_get_attribute(shader_program,
|
||||
tex_coord_attribute_name);
|
||||
tex_coord_attribute_location_ = blender::GPU_shader_get_attribute(shader_program,
|
||||
tex_coord_attribute_name);
|
||||
}
|
||||
return tex_coord_attribute_location_;
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ int BlenderDisplayShader::get_tex_coord_attrib_location()
|
|||
static blender::gpu::Shader *compile_fallback_shader()
|
||||
{
|
||||
/* NOTE: Compilation errors are logged to console. */
|
||||
blender::gpu::Shader *shader = GPU_shader_create_from_info_name(
|
||||
blender::gpu::Shader *shader = blender::GPU_shader_create_from_info_name(
|
||||
"gpu_shader_cycles_display_fallback");
|
||||
return shader;
|
||||
}
|
||||
|
|
@ -80,19 +80,19 @@ blender::gpu::Shader *BlenderFallbackDisplayShader::bind(const int width, const
|
|||
}
|
||||
|
||||
/* Bind shader now to enable uniform assignment. */
|
||||
GPU_shader_bind(shader_program_);
|
||||
blender::GPU_shader_bind(shader_program_);
|
||||
const int slot = 0;
|
||||
GPU_shader_uniform_int_ex(shader_program_, image_texture_location_, 1, 1, &slot);
|
||||
blender::GPU_shader_uniform_int_ex(shader_program_, image_texture_location_, 1, 1, &slot);
|
||||
float size[2];
|
||||
size[0] = width;
|
||||
size[1] = height;
|
||||
GPU_shader_uniform_float_ex(shader_program_, fullscreen_location_, 2, 1, size);
|
||||
blender::GPU_shader_uniform_float_ex(shader_program_, fullscreen_location_, 2, 1, size);
|
||||
return shader_program_;
|
||||
}
|
||||
|
||||
void BlenderFallbackDisplayShader::unbind()
|
||||
{
|
||||
GPU_shader_unbind();
|
||||
blender::GPU_shader_unbind();
|
||||
}
|
||||
|
||||
blender::gpu::Shader *BlenderFallbackDisplayShader::get_shader_program()
|
||||
|
|
@ -114,14 +114,14 @@ void BlenderFallbackDisplayShader::create_shader_if_needed()
|
|||
return;
|
||||
}
|
||||
|
||||
image_texture_location_ = GPU_shader_get_uniform(shader_program_, "image_texture");
|
||||
image_texture_location_ = blender::GPU_shader_get_uniform(shader_program_, "image_texture");
|
||||
if (image_texture_location_ < 0) {
|
||||
LOG_ERROR << "Shader doesn't contain the 'image_texture' uniform.";
|
||||
destroy_shader();
|
||||
return;
|
||||
}
|
||||
|
||||
fullscreen_location_ = GPU_shader_get_uniform(shader_program_, "fullscreen");
|
||||
fullscreen_location_ = blender::GPU_shader_get_uniform(shader_program_, "fullscreen");
|
||||
if (fullscreen_location_ < 0) {
|
||||
LOG_ERROR << "Shader doesn't contain the 'fullscreen' uniform.";
|
||||
destroy_shader();
|
||||
|
|
@ -132,7 +132,7 @@ void BlenderFallbackDisplayShader::create_shader_if_needed()
|
|||
void BlenderFallbackDisplayShader::destroy_shader()
|
||||
{
|
||||
if (shader_program_) {
|
||||
GPU_shader_free(shader_program_);
|
||||
blender::GPU_shader_free(shader_program_);
|
||||
shader_program_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -141,28 +141,30 @@ void BlenderFallbackDisplayShader::destroy_shader()
|
|||
* BlenderDisplaySpaceShader.
|
||||
*/
|
||||
|
||||
BlenderDisplaySpaceShader::BlenderDisplaySpaceShader(::RenderEngine &b_engine, ::Scene &b_scene)
|
||||
BlenderDisplaySpaceShader::BlenderDisplaySpaceShader(blender::RenderEngine &b_engine,
|
||||
blender::Scene &b_scene)
|
||||
: b_engine_(b_engine), b_scene_(b_scene)
|
||||
{
|
||||
}
|
||||
|
||||
blender::gpu::Shader *BlenderDisplaySpaceShader::bind(int /*width*/, int /*height*/)
|
||||
{
|
||||
blender::gpu::Shader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_IMAGE);
|
||||
GPU_shader_bind(shader);
|
||||
blender::gpu::Shader *shader = blender::GPU_shader_get_builtin_shader(
|
||||
blender::GPU_SHADER_3D_IMAGE);
|
||||
blender::GPU_shader_bind(shader);
|
||||
/** \note "image" binding slot is 0. */
|
||||
return GPU_shader_get_bound();
|
||||
return blender::GPU_shader_get_bound();
|
||||
}
|
||||
|
||||
void BlenderDisplaySpaceShader::unbind()
|
||||
{
|
||||
GPU_shader_unbind();
|
||||
blender::GPU_shader_unbind();
|
||||
}
|
||||
|
||||
blender::gpu::Shader *BlenderDisplaySpaceShader::get_shader_program()
|
||||
{
|
||||
if (!shader_program_) {
|
||||
shader_program_ = GPU_shader_get_bound();
|
||||
shader_program_ = blender::GPU_shader_get_bound();
|
||||
}
|
||||
if (!shader_program_) {
|
||||
LOG_ERROR << "Error retrieving shader program for display space shader.";
|
||||
|
|
@ -178,7 +180,7 @@ blender::gpu::Shader *BlenderDisplaySpaceShader::get_shader_program()
|
|||
/* Higher level representation of a texture from the graphics library. */
|
||||
class DisplayGPUTexture {
|
||||
public:
|
||||
/* Global counter for all allocated GPUTextures used by instances of this class. */
|
||||
/* Global counter for all allocated blender::GPUTextures used by instances of this class. */
|
||||
static inline std::atomic<int> num_used = 0;
|
||||
|
||||
DisplayGPUTexture() = default;
|
||||
|
|
@ -226,21 +228,21 @@ class DisplayGPUTexture {
|
|||
height = texture_height;
|
||||
|
||||
/* Texture must have a minimum size of 1x1. */
|
||||
gpu_texture = GPU_texture_create_2d("CyclesBlitTexture",
|
||||
max(width, 1),
|
||||
max(height, 1),
|
||||
1,
|
||||
blender::gpu::TextureFormat::SFLOAT_16_16_16_16,
|
||||
GPU_TEXTURE_USAGE_GENERAL,
|
||||
nullptr);
|
||||
gpu_texture = blender::GPU_texture_create_2d("CyclesBlitTexture",
|
||||
max(width, 1),
|
||||
max(height, 1),
|
||||
1,
|
||||
blender::gpu::TextureFormat::SFLOAT_16_16_16_16,
|
||||
blender::GPU_TEXTURE_USAGE_GENERAL,
|
||||
nullptr);
|
||||
|
||||
if (!gpu_texture) {
|
||||
LOG_ERROR << "Error creating texture.";
|
||||
return false;
|
||||
}
|
||||
|
||||
GPU_texture_filter_mode(gpu_texture, false);
|
||||
GPU_texture_extend_mode(gpu_texture, GPU_SAMPLER_EXTEND_MODE_EXTEND);
|
||||
blender::GPU_texture_filter_mode(gpu_texture, false);
|
||||
blender::GPU_texture_extend_mode(gpu_texture, blender::GPU_SAMPLER_EXTEND_MODE_EXTEND);
|
||||
|
||||
++num_used;
|
||||
|
||||
|
|
@ -260,7 +262,7 @@ class DisplayGPUTexture {
|
|||
--num_used;
|
||||
}
|
||||
|
||||
/* Texture resource allocated by the GPU module.
|
||||
/* Texture resource allocated by the blender::GPU module.
|
||||
*
|
||||
* NOTE: Allocated on the render engine's context. */
|
||||
blender::gpu::Texture *gpu_texture = nullptr;
|
||||
|
|
@ -281,7 +283,7 @@ class DisplayGPUTexture {
|
|||
/* Higher level representation of a Pixel Buffer Object (PBO) from the graphics library. */
|
||||
class DisplayGPUPixelBuffer {
|
||||
public:
|
||||
/* Global counter for all allocated GPU module PBOs used by instances of this class. */
|
||||
/* Global counter for all allocated blender::GPU module PBOs used by instances of this class. */
|
||||
static inline std::atomic<int> num_used = 0;
|
||||
|
||||
DisplayGPUPixelBuffer() = default;
|
||||
|
|
@ -324,7 +326,7 @@ class DisplayGPUPixelBuffer {
|
|||
/* Try to re-use the existing PBO if it has usable size. */
|
||||
if (gpu_pixel_buffer) {
|
||||
if (new_width != width || new_height != height ||
|
||||
GPU_pixel_buffer_size(gpu_pixel_buffer) < required_size)
|
||||
blender::GPU_pixel_buffer_size(gpu_pixel_buffer) < required_size)
|
||||
{
|
||||
buffer_recreated = true;
|
||||
gpu_resources_destroy();
|
||||
|
|
@ -337,7 +339,7 @@ class DisplayGPUPixelBuffer {
|
|||
|
||||
/* Create pixel buffer if not already created. */
|
||||
if (!gpu_pixel_buffer) {
|
||||
gpu_pixel_buffer = GPU_pixel_buffer_create(required_size);
|
||||
gpu_pixel_buffer = blender::GPU_pixel_buffer_create(required_size);
|
||||
buffer_recreated = true;
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +359,7 @@ class DisplayGPUPixelBuffer {
|
|||
return;
|
||||
}
|
||||
|
||||
GPU_pixel_buffer_free(gpu_pixel_buffer);
|
||||
blender::GPU_pixel_buffer_free(gpu_pixel_buffer);
|
||||
gpu_pixel_buffer = nullptr;
|
||||
|
||||
reset();
|
||||
|
|
@ -365,10 +367,10 @@ class DisplayGPUPixelBuffer {
|
|||
--num_used;
|
||||
}
|
||||
|
||||
/* Pixel Buffer Object allocated by the GPU module.
|
||||
/* Pixel Buffer Object allocated by the blender::GPU module.
|
||||
*
|
||||
* NOTE: Allocated on the render engine's context. */
|
||||
GPUPixelBuffer *gpu_pixel_buffer = nullptr;
|
||||
blender::GPUPixelBuffer *gpu_pixel_buffer = nullptr;
|
||||
|
||||
/* Dimensions of the PBO. */
|
||||
int width = 0;
|
||||
|
|
@ -448,8 +450,8 @@ struct BlenderDisplayDriver::Tiles {
|
|||
} finished_tiles;
|
||||
};
|
||||
|
||||
BlenderDisplayDriver::BlenderDisplayDriver(::RenderEngine &b_engine,
|
||||
::Scene &b_scene,
|
||||
BlenderDisplayDriver::BlenderDisplayDriver(blender::RenderEngine &b_engine,
|
||||
blender::Scene &b_scene,
|
||||
const bool background)
|
||||
: b_engine_(b_engine),
|
||||
background_(background),
|
||||
|
|
@ -502,7 +504,7 @@ bool BlenderDisplayDriver::update_begin(const Params ¶ms,
|
|||
return false;
|
||||
}
|
||||
|
||||
GPU_fence_wait(gpu_render_sync_);
|
||||
blender::GPU_fence_wait(gpu_render_sync_);
|
||||
|
||||
DrawTile ¤t_tile = tiles_->current_tile.tile;
|
||||
DisplayGPUPixelBuffer ¤t_tile_buffer_object = tiles_->current_tile.buffer_object;
|
||||
|
|
@ -521,7 +523,7 @@ bool BlenderDisplayDriver::update_begin(const Params ¶ms,
|
|||
* at a resolution divider 1. This was we don't need to recreate graphics interoperability
|
||||
* objects which are costly and which are tied to the specific underlying buffer size.
|
||||
* The downside of this approach is that when graphics interoperability is not used we are
|
||||
* sending too much data to GPU when resolution divider is not 1. */
|
||||
* sending too much data to blender::GPU when resolution divider is not 1. */
|
||||
/* TODO(sergey): Investigate whether keeping the PBO exact size of the texture makes non-interop
|
||||
* mode faster. */
|
||||
const int buffer_width = params.size.x;
|
||||
|
|
@ -558,15 +560,15 @@ static void update_tile_texture_pixels(const DrawTileAndPBO &tile)
|
|||
LOG_ERROR << "Display driver tile pixel buffer unavailable.";
|
||||
return;
|
||||
}
|
||||
GPU_texture_update_sub_from_pixel_buffer(texture.gpu_texture,
|
||||
GPU_DATA_HALF_FLOAT,
|
||||
tile.buffer_object.gpu_pixel_buffer,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
texture.width,
|
||||
texture.height,
|
||||
0);
|
||||
blender::GPU_texture_update_sub_from_pixel_buffer(texture.gpu_texture,
|
||||
blender::GPU_DATA_HALF_FLOAT,
|
||||
tile.buffer_object.gpu_pixel_buffer,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
texture.width,
|
||||
texture.height,
|
||||
0);
|
||||
}
|
||||
|
||||
void BlenderDisplayDriver::update_end()
|
||||
|
|
@ -575,18 +577,21 @@ void BlenderDisplayDriver::update_end()
|
|||
*
|
||||
* This allows to ensure that the unpacking happens while resources like graphics interop (which
|
||||
* lifetime is outside of control of the display driver) are still valid, as well as allows to
|
||||
* move the tile from being current to finished immediately after this call.
|
||||
* move the tile from being current to finished blender::immediately after this call.
|
||||
*
|
||||
* One concern with this approach is that if the update happens more often than drawing then
|
||||
* doing the unpack here occupies GPU transfer for no good reason. However, the render scheduler
|
||||
* takes care of ensuring updates don't happen that often. In regular applications redraw will
|
||||
* happen much more often than this update.
|
||||
* doing the unpack here occupies blender::GPU transfer for no good reason. However, the render
|
||||
* scheduler takes care of ensuring updates don't happen that often. In regular applications
|
||||
* redraw will happen much more often than this update.
|
||||
*
|
||||
* On some older GPUs on macOS, there is a driver crash when updating the texture for viewport
|
||||
* renders while Blender is drawing. As a workaround update texture during draw, under assumption
|
||||
* that there is no graphics interop on macOS and viewport render has a single tile. */
|
||||
if (!background_ &&
|
||||
GPU_type_matches_ex(GPU_DEVICE_NVIDIA, GPU_OS_MAC, GPU_DRIVER_ANY, GPU_BACKEND_ANY))
|
||||
* On some older blender::GPUs on macOS, there is a driver crash when updating the texture for
|
||||
* viewport renders while Blender is drawing. As a workaround update texture during draw, under
|
||||
* assumption that there is no graphics interop on macOS and viewport render has a single tile.
|
||||
*/
|
||||
if (!background_ && blender::GPU_type_matches_ex(blender::GPU_DEVICE_NVIDIA,
|
||||
blender::GPU_OS_MAC,
|
||||
blender::GPU_DRIVER_ANY,
|
||||
blender::GPU_BACKEND_ANY))
|
||||
{
|
||||
tiles_->current_tile.need_update_texture_pixels = true;
|
||||
}
|
||||
|
|
@ -594,10 +599,10 @@ void BlenderDisplayDriver::update_end()
|
|||
update_tile_texture_pixels(tiles_->current_tile);
|
||||
}
|
||||
|
||||
/* Ensure GPU fence exists to synchronize upload. */
|
||||
GPU_fence_signal(gpu_upload_sync_);
|
||||
/* Ensure blender::GPU fence exists to synchronize upload. */
|
||||
blender::GPU_fence_signal(gpu_upload_sync_);
|
||||
|
||||
GPU_flush();
|
||||
blender::GPU_flush();
|
||||
|
||||
gpu_context_disable();
|
||||
}
|
||||
|
|
@ -612,16 +617,16 @@ half4 *BlenderDisplayDriver::map_texture_buffer()
|
|||
* and not. For the denoised image it may be able to use graphics interop as that
|
||||
* buffer is written to by one device, while the noisy renders can not use it.
|
||||
*
|
||||
* We need to clear the graphics interop buffer on that switch, as GPU_pixel_buffer_map
|
||||
* We need to clear the graphics interop buffer on that switch, as blender::GPU_pixel_buffer_map
|
||||
* may recreate the buffer or handle. */
|
||||
graphics_interop_buffer_.clear();
|
||||
|
||||
GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
|
||||
blender::GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
|
||||
if (!DCHECK_NOTNULL(pix_buf)) {
|
||||
LOG_ERROR << "Display driver tile pixel buffer unavailable.";
|
||||
return nullptr;
|
||||
}
|
||||
half4 *mapped_rgba_pixels = reinterpret_cast<half4 *>(GPU_pixel_buffer_map(pix_buf));
|
||||
half4 *mapped_rgba_pixels = reinterpret_cast<half4 *>(blender::GPU_pixel_buffer_map(pix_buf));
|
||||
if (!mapped_rgba_pixels) {
|
||||
LOG_ERROR << "Error mapping BlenderDisplayDriver pixel buffer object.";
|
||||
}
|
||||
|
|
@ -630,12 +635,12 @@ half4 *BlenderDisplayDriver::map_texture_buffer()
|
|||
|
||||
void BlenderDisplayDriver::unmap_texture_buffer()
|
||||
{
|
||||
GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
|
||||
blender::GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
|
||||
if (!DCHECK_NOTNULL(pix_buf)) {
|
||||
LOG_ERROR << "Display driver tile pixel buffer unavailable.";
|
||||
return;
|
||||
}
|
||||
GPU_pixel_buffer_unmap(pix_buf);
|
||||
blender::GPU_pixel_buffer_unmap(pix_buf);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
|
|
@ -646,23 +651,23 @@ GraphicsInteropDevice BlenderDisplayDriver::graphics_interop_get_device()
|
|||
{
|
||||
GraphicsInteropDevice interop_device;
|
||||
|
||||
switch (GPU_backend_get_type()) {
|
||||
case GPU_BACKEND_OPENGL:
|
||||
switch (blender::GPU_backend_get_type()) {
|
||||
case blender::GPU_BACKEND_OPENGL:
|
||||
interop_device.type = GraphicsInteropDevice::OPENGL;
|
||||
break;
|
||||
case GPU_BACKEND_VULKAN:
|
||||
case blender::GPU_BACKEND_VULKAN:
|
||||
interop_device.type = GraphicsInteropDevice::VULKAN;
|
||||
break;
|
||||
case GPU_BACKEND_METAL:
|
||||
case blender::GPU_BACKEND_METAL:
|
||||
interop_device.type = GraphicsInteropDevice::METAL;
|
||||
break;
|
||||
case GPU_BACKEND_NONE:
|
||||
case GPU_BACKEND_ANY:
|
||||
case blender::GPU_BACKEND_NONE:
|
||||
case blender::GPU_BACKEND_ANY:
|
||||
interop_device.type = GraphicsInteropDevice::NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
blender::Span<uint8_t> uuid = GPU_platform_uuid();
|
||||
blender::Span<uint8_t> uuid = blender::GPU_platform_uuid();
|
||||
interop_device.uuid.resize(uuid.size());
|
||||
std::copy_n(uuid.data(), uuid.size(), interop_device.uuid.data());
|
||||
|
||||
|
|
@ -673,22 +678,22 @@ void BlenderDisplayDriver::graphics_interop_update_buffer()
|
|||
{
|
||||
if (graphics_interop_buffer_.is_empty()) {
|
||||
GraphicsInteropDevice::Type type = GraphicsInteropDevice::NONE;
|
||||
switch (GPU_backend_get_type()) {
|
||||
case GPU_BACKEND_OPENGL:
|
||||
switch (blender::GPU_backend_get_type()) {
|
||||
case blender::GPU_BACKEND_OPENGL:
|
||||
type = GraphicsInteropDevice::OPENGL;
|
||||
break;
|
||||
case GPU_BACKEND_VULKAN:
|
||||
case blender::GPU_BACKEND_VULKAN:
|
||||
type = GraphicsInteropDevice::VULKAN;
|
||||
break;
|
||||
case GPU_BACKEND_METAL:
|
||||
case blender::GPU_BACKEND_METAL:
|
||||
type = GraphicsInteropDevice::METAL;
|
||||
break;
|
||||
case GPU_BACKEND_NONE:
|
||||
case GPU_BACKEND_ANY:
|
||||
case blender::GPU_BACKEND_NONE:
|
||||
case blender::GPU_BACKEND_ANY:
|
||||
break;
|
||||
}
|
||||
|
||||
GPUPixelBufferNativeHandle handle = GPU_pixel_buffer_get_native_handle(
|
||||
blender::GPUPixelBufferNativeHandle handle = blender::GPU_pixel_buffer_get_native_handle(
|
||||
tiles_->current_tile.buffer_object.gpu_pixel_buffer);
|
||||
graphics_interop_buffer_.assign(type, handle.handle, handle.size);
|
||||
}
|
||||
|
|
@ -732,21 +737,21 @@ static void vertex_draw(const DisplayDriver::Params ¶ms,
|
|||
const int width = params.size.x;
|
||||
const int height = params.size.y;
|
||||
|
||||
immBegin(GPU_PRIM_TRI_STRIP, 4);
|
||||
blender::immBegin(blender::GPU_PRIM_TRI_STRIP, 4);
|
||||
|
||||
immAttr2f(texcoord_attribute, 1.0f, 0.0f);
|
||||
immVertex2f(position_attribute, x + width, y);
|
||||
blender::immAttr2f(texcoord_attribute, 1.0f, 0.0f);
|
||||
blender::immVertex2f(position_attribute, x + width, y);
|
||||
|
||||
immAttr2f(texcoord_attribute, 1.0f, 1.0f);
|
||||
immVertex2f(position_attribute, x + width, y + height);
|
||||
blender::immAttr2f(texcoord_attribute, 1.0f, 1.0f);
|
||||
blender::immVertex2f(position_attribute, x + width, y + height);
|
||||
|
||||
immAttr2f(texcoord_attribute, 0.0f, 0.0f);
|
||||
immVertex2f(position_attribute, x, y);
|
||||
blender::immAttr2f(texcoord_attribute, 0.0f, 0.0f);
|
||||
blender::immVertex2f(position_attribute, x, y);
|
||||
|
||||
immAttr2f(texcoord_attribute, 0.0f, 1.0f);
|
||||
immVertex2f(position_attribute, x, y + height);
|
||||
blender::immAttr2f(texcoord_attribute, 0.0f, 1.0f);
|
||||
blender::immVertex2f(position_attribute, x, y + height);
|
||||
|
||||
immEnd();
|
||||
blender::immEnd();
|
||||
}
|
||||
|
||||
static void draw_tile(const float2 &zoom,
|
||||
|
|
@ -761,11 +766,11 @@ static void draw_tile(const float2 &zoom,
|
|||
const DisplayGPUTexture &texture = draw_tile.texture;
|
||||
|
||||
if (!DCHECK_NOTNULL(texture.gpu_texture)) {
|
||||
LOG_ERROR << "Display driver tile GPU texture resource unavailable.";
|
||||
LOG_ERROR << "Display driver tile blender::GPU texture resource unavailable.";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Trick to keep sharp rendering without jagged edges on all GPUs.
|
||||
/* Trick to keep sharp rendering without jagged edges on all blender::GPUs.
|
||||
*
|
||||
* The idea here is to enforce driver to use linear interpolation when the image is zoomed out.
|
||||
* For the render result with a resolution divider in effect we always use nearest interpolation.
|
||||
|
|
@ -776,15 +781,17 @@ static void draw_tile(const float2 &zoom,
|
|||
const float zoomed_height = draw_tile.params.size.y * zoom.y;
|
||||
if (texture.width != draw_tile.params.size.x || texture.height != draw_tile.params.size.y) {
|
||||
/* Resolution divider is different from 1, force nearest interpolation. */
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPUSamplerState::default_sampler(), 0);
|
||||
blender::GPU_texture_bind_ex(
|
||||
texture.gpu_texture, blender::GPUSamplerState::default_sampler(), 0);
|
||||
}
|
||||
else if (zoomed_width - draw_tile.params.size.x > -0.5f ||
|
||||
zoomed_height - draw_tile.params.size.y > -0.5f)
|
||||
{
|
||||
GPU_texture_bind_ex(texture.gpu_texture, GPUSamplerState::default_sampler(), 0);
|
||||
blender::GPU_texture_bind_ex(
|
||||
texture.gpu_texture, blender::GPUSamplerState::default_sampler(), 0);
|
||||
}
|
||||
else {
|
||||
GPU_texture_bind_ex(texture.gpu_texture, {GPU_SAMPLER_FILTERING_LINEAR}, 0);
|
||||
blender::GPU_texture_bind_ex(texture.gpu_texture, {blender::GPU_SAMPLER_FILTERING_LINEAR}, 0);
|
||||
}
|
||||
|
||||
/* Draw at the parameters for which the texture has been updated for. This allows to always draw
|
||||
|
|
@ -812,8 +819,8 @@ void BlenderDisplayDriver::flush()
|
|||
return;
|
||||
}
|
||||
|
||||
GPU_fence_wait(gpu_upload_sync_);
|
||||
GPU_fence_wait(gpu_render_sync_);
|
||||
blender::GPU_fence_wait(gpu_upload_sync_);
|
||||
blender::GPU_fence_wait(gpu_render_sync_);
|
||||
|
||||
gpu_context_disable();
|
||||
}
|
||||
|
|
@ -832,18 +839,18 @@ void BlenderDisplayDriver::draw(const Params ¶ms)
|
|||
return;
|
||||
}
|
||||
|
||||
GPU_fence_wait(gpu_upload_sync_);
|
||||
GPU_blend(GPU_BLEND_ALPHA_PREMULT);
|
||||
blender::GPU_fence_wait(gpu_upload_sync_);
|
||||
blender::GPU_blend(blender::GPU_BLEND_ALPHA_PREMULT);
|
||||
|
||||
blender::gpu::Shader *active_shader = display_shader_->bind(params.full_size.x,
|
||||
params.full_size.y);
|
||||
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
const int texcoord_attribute = GPU_vertformat_attr_add(
|
||||
blender::GPUVertFormat *format = blender::immVertexFormat();
|
||||
const int texcoord_attribute = blender::GPU_vertformat_attr_add(
|
||||
format,
|
||||
ccl::BlenderDisplayShader::tex_coord_attribute_name,
|
||||
blender::gpu::VertAttrType::SFLOAT_32_32);
|
||||
const int position_attribute = GPU_vertformat_attr_add(
|
||||
const int position_attribute = blender::GPU_vertformat_attr_add(
|
||||
format,
|
||||
ccl::BlenderDisplayShader::position_attribute_name,
|
||||
blender::gpu::VertAttrType::SFLOAT_32_32);
|
||||
|
|
@ -852,7 +859,7 @@ void BlenderDisplayDriver::draw(const Params ¶ms)
|
|||
* and perform required setup for IMM rendering. This is required as the IMM module
|
||||
* needs to be aware of which shader is bound, and the main display shader
|
||||
* is bound externally. */
|
||||
immBindShader(active_shader);
|
||||
blender::immBindShader(active_shader);
|
||||
|
||||
if (tiles_->current_tile.need_update_texture_pixels) {
|
||||
update_tile_texture_pixels(tiles_->current_tile);
|
||||
|
|
@ -866,14 +873,14 @@ void BlenderDisplayDriver::draw(const Params ¶ms)
|
|||
}
|
||||
|
||||
/* Reset IMM shader bind state. */
|
||||
immUnbindProgram();
|
||||
blender::immUnbindProgram();
|
||||
|
||||
display_shader_->unbind();
|
||||
|
||||
GPU_blend(GPU_BLEND_NONE);
|
||||
blender::GPU_blend(blender::GPU_BLEND_NONE);
|
||||
|
||||
GPU_fence_signal(gpu_render_sync_);
|
||||
GPU_flush();
|
||||
blender::GPU_fence_signal(gpu_render_sync_);
|
||||
blender::GPU_flush();
|
||||
|
||||
gpu_context_unlock();
|
||||
|
||||
|
|
@ -884,13 +891,13 @@ void BlenderDisplayDriver::draw(const Params ¶ms)
|
|||
void BlenderDisplayDriver::gpu_context_create()
|
||||
{
|
||||
if (!RE_engine_gpu_context_create(&b_engine_)) {
|
||||
LOG_ERROR << "Error creating GPU context.";
|
||||
LOG_ERROR << "Error creating blender::GPU context.";
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create global GPU resources for display driver. */
|
||||
/* Create global blender::GPU resources for display driver. */
|
||||
if (!gpu_resources_create()) {
|
||||
LOG_ERROR << "Error creating GPU resources for Display Driver.";
|
||||
LOG_ERROR << "Error creating blender::GPU resources for Display Driver.";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -924,15 +931,15 @@ bool BlenderDisplayDriver::gpu_resources_create()
|
|||
{
|
||||
/* Ensure context is active for resource creation. */
|
||||
if (!gpu_context_enable()) {
|
||||
LOG_ERROR << "Error enabling GPU context.";
|
||||
LOG_ERROR << "Error enabling blender::GPU context.";
|
||||
return false;
|
||||
}
|
||||
|
||||
gpu_upload_sync_ = GPU_fence_create();
|
||||
gpu_render_sync_ = GPU_fence_create();
|
||||
gpu_upload_sync_ = blender::GPU_fence_create();
|
||||
gpu_render_sync_ = blender::GPU_fence_create();
|
||||
|
||||
if (!DCHECK_NOTNULL(gpu_upload_sync_) || !DCHECK_NOTNULL(gpu_render_sync_)) {
|
||||
LOG_ERROR << "Error creating GPU synchronization primitives.";
|
||||
LOG_ERROR << "Error creating blender::GPU synchronization primitives.";
|
||||
assert(0);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -954,11 +961,11 @@ void BlenderDisplayDriver::gpu_resources_destroy()
|
|||
|
||||
/* Fences. */
|
||||
if (gpu_render_sync_) {
|
||||
GPU_fence_free(gpu_render_sync_);
|
||||
blender::GPU_fence_free(gpu_render_sync_);
|
||||
gpu_render_sync_ = nullptr;
|
||||
}
|
||||
if (gpu_upload_sync_) {
|
||||
GPU_fence_free(gpu_upload_sync_);
|
||||
blender::GPU_fence_free(gpu_upload_sync_);
|
||||
gpu_upload_sync_ = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,13 +10,15 @@
|
|||
|
||||
#include "util/unique_ptr.h"
|
||||
|
||||
namespace blender {
|
||||
struct GPUContext;
|
||||
struct GPUFence;
|
||||
struct RenderEngine;
|
||||
struct Scene;
|
||||
namespace blender::gpu {
|
||||
namespace gpu {
|
||||
class Shader;
|
||||
} // namespace blender::gpu
|
||||
} // namespace gpu
|
||||
} // namespace blender
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
|
@ -27,7 +29,8 @@ class BlenderDisplayShader {
|
|||
static constexpr const char *tex_coord_attribute_name = "texCoord";
|
||||
|
||||
/* Create shader implementation suitable for the given render engine and scene configuration. */
|
||||
static unique_ptr<BlenderDisplayShader> create(::RenderEngine &b_engine, ::Scene &b_scene);
|
||||
static unique_ptr<BlenderDisplayShader> create(blender::RenderEngine &b_engine,
|
||||
blender::Scene &b_scene);
|
||||
|
||||
BlenderDisplayShader() = default;
|
||||
virtual ~BlenderDisplayShader() = default;
|
||||
|
|
@ -76,7 +79,7 @@ class BlenderFallbackDisplayShader : public BlenderDisplayShader {
|
|||
|
||||
class BlenderDisplaySpaceShader : public BlenderDisplayShader {
|
||||
public:
|
||||
BlenderDisplaySpaceShader(::RenderEngine &b_engine, ::Scene &b_scene);
|
||||
BlenderDisplaySpaceShader(blender::RenderEngine &b_engine, blender::Scene &b_scene);
|
||||
|
||||
blender::gpu::Shader *bind(const int width, const int height) override;
|
||||
void unbind() override;
|
||||
|
|
@ -84,8 +87,8 @@ class BlenderDisplaySpaceShader : public BlenderDisplayShader {
|
|||
protected:
|
||||
blender::gpu::Shader *get_shader_program() override;
|
||||
|
||||
::RenderEngine &b_engine_;
|
||||
::Scene &b_scene_;
|
||||
blender::RenderEngine &b_engine_;
|
||||
blender::Scene &b_scene_;
|
||||
|
||||
/* Cached values of various OpenGL resources. */
|
||||
blender::gpu::Shader *shader_program_ = nullptr;
|
||||
|
|
@ -94,7 +97,9 @@ class BlenderDisplaySpaceShader : public BlenderDisplayShader {
|
|||
/* Display driver implementation which is specific for Blender viewport integration. */
|
||||
class BlenderDisplayDriver : public DisplayDriver {
|
||||
public:
|
||||
BlenderDisplayDriver(::RenderEngine &b_engine, ::Scene &b_scene, const bool background);
|
||||
BlenderDisplayDriver(blender::RenderEngine &b_engine,
|
||||
blender::Scene &b_scene,
|
||||
const bool background);
|
||||
~BlenderDisplayDriver() override;
|
||||
|
||||
void graphics_interop_activate() override;
|
||||
|
|
@ -136,7 +141,7 @@ class BlenderDisplayDriver : public DisplayDriver {
|
|||
/* Destroy all GPU resources which are being used by this object. */
|
||||
void gpu_resources_destroy();
|
||||
|
||||
::RenderEngine &b_engine_;
|
||||
blender::RenderEngine &b_engine_;
|
||||
bool background_;
|
||||
|
||||
/* Content of the display is to be filled with zeroes. */
|
||||
|
|
@ -148,8 +153,8 @@ class BlenderDisplayDriver : public DisplayDriver {
|
|||
struct Tiles;
|
||||
unique_ptr<Tiles> tiles_;
|
||||
|
||||
GPUFence *gpu_render_sync_ = nullptr;
|
||||
GPUFence *gpu_upload_sync_ = nullptr;
|
||||
blender::GPUFence *gpu_render_sync_ = nullptr;
|
||||
blender::GPUFence *gpu_upload_sync_ = nullptr;
|
||||
|
||||
float2 zoom_ = make_float2(1.0f, 1.0f);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,19 +22,19 @@ CCL_NAMESPACE_BEGIN
|
|||
|
||||
static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_particle_hair)
|
||||
{
|
||||
if (GS(b_ob_info.object_data->name) == ID_LA) {
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_LA) {
|
||||
return Geometry::LIGHT;
|
||||
}
|
||||
|
||||
if (GS(b_ob_info.object_data->name) == ID_CV || use_particle_hair) {
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_CV || use_particle_hair) {
|
||||
return Geometry::HAIR;
|
||||
}
|
||||
|
||||
if (GS(b_ob_info.object_data->name) == ID_PT) {
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_PT) {
|
||||
return Geometry::POINTCLOUD;
|
||||
}
|
||||
|
||||
if (GS(b_ob_info.object_data->name) == ID_VO ||
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_VO ||
|
||||
(b_ob_info.object_data ==
|
||||
object_get_data(*b_ob_info.real_object, b_ob_info.use_adaptive_subdivision) &&
|
||||
object_fluid_gas_domain_find(*b_ob_info.real_object)))
|
||||
|
|
@ -45,26 +45,26 @@ static Geometry::Type determine_geom_type(BObjectInfo &b_ob_info, bool use_parti
|
|||
return Geometry::MESH;
|
||||
}
|
||||
|
||||
array<Node *> BlenderSync::find_used_shaders(::Object &b_ob)
|
||||
array<Node *> BlenderSync::find_used_shaders(blender::Object &b_ob)
|
||||
{
|
||||
array<Node *> used_shaders;
|
||||
|
||||
if (b_ob.type == OB_LAMP) {
|
||||
find_shader(static_cast<::ID *>(b_ob.data), used_shaders, scene->default_light);
|
||||
if (b_ob.type == blender::OB_LAMP) {
|
||||
find_shader(static_cast<blender::ID *>(b_ob.data), used_shaders, scene->default_light);
|
||||
return used_shaders;
|
||||
}
|
||||
|
||||
::Material *material_override = view_layer.material_override;
|
||||
Shader *default_shader = (b_ob.type == OB_VOLUME) ? scene->default_volume :
|
||||
scene->default_surface;
|
||||
blender::Material *material_override = view_layer.material_override;
|
||||
Shader *default_shader = (b_ob.type == blender::OB_VOLUME) ? scene->default_volume :
|
||||
scene->default_surface;
|
||||
|
||||
for (const int i : blender::IndexRange(BKE_object_material_count_eval(&b_ob))) {
|
||||
if (material_override) {
|
||||
find_shader(&material_override->id, used_shaders, default_shader);
|
||||
}
|
||||
else {
|
||||
::Material *b_material = BKE_object_material_get(&b_ob, i + 1);
|
||||
find_shader(reinterpret_cast<::ID *>(b_material), used_shaders, default_shader);
|
||||
blender::Material *b_material = BKE_object_material_get(&b_ob, i + 1);
|
||||
find_shader(reinterpret_cast<blender::ID *>(b_material), used_shaders, default_shader);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,10 +87,10 @@ Geometry *BlenderSync::sync_geometry(BObjectInfo &b_ob_info,
|
|||
{
|
||||
/* Test if we can instance or if the object is modified. */
|
||||
const Geometry::Type geom_type = determine_geom_type(b_ob_info, use_particle_hair);
|
||||
::ID *const b_key_id = (b_ob_info.is_real_object_data() &&
|
||||
BKE_object_is_modified(*b_ob_info.real_object)) ?
|
||||
&b_ob_info.real_object->id :
|
||||
b_ob_info.object_data;
|
||||
blender::ID *const b_key_id = (b_ob_info.is_real_object_data() &&
|
||||
BKE_object_is_modified(*b_ob_info.real_object)) ?
|
||||
&b_ob_info.real_object->id :
|
||||
b_ob_info.object_data;
|
||||
const GeometryKey key(b_key_id, geom_type);
|
||||
|
||||
/* Find shader indices. */
|
||||
|
|
@ -258,16 +258,16 @@ void BlenderSync::sync_geometry_motion(BObjectInfo &b_ob_info,
|
|||
return;
|
||||
}
|
||||
|
||||
if (GS(b_ob_info.object_data->name) == ID_CV || use_particle_hair) {
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_CV || use_particle_hair) {
|
||||
Hair *hair = static_cast<Hair *>(geom);
|
||||
sync_hair_motion(b_ob_info, hair, motion_step);
|
||||
}
|
||||
else if (GS(b_ob_info.object_data->name) == ID_VO ||
|
||||
else if (GS(b_ob_info.object_data->name) == blender::ID_VO ||
|
||||
object_fluid_gas_domain_find(*b_ob_info.real_object))
|
||||
{
|
||||
/* No volume motion blur support yet. */
|
||||
}
|
||||
else if (GS(b_ob_info.object_data->name) == ID_PT) {
|
||||
else if (GS(b_ob_info.object_data->name) == blender::ID_PT) {
|
||||
PointCloud *pointcloud = static_cast<PointCloud *>(geom);
|
||||
sync_pointcloud_motion(pointcloud, b_ob_info, motion_step);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@
|
|||
#include "util/map.h"
|
||||
#include "util/set.h"
|
||||
|
||||
namespace blender {
|
||||
struct ID;
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* ID Map
|
||||
|
|
@ -50,7 +54,7 @@ template<typename K, typename T, typename Flags = uint> class id_map {
|
|||
b_recalc.insert(id_ptr);
|
||||
}
|
||||
|
||||
bool check_recalc(const ::ID *id)
|
||||
bool check_recalc(const blender::ID *id)
|
||||
{
|
||||
return id && b_recalc.find(id) != b_recalc.end();
|
||||
}
|
||||
|
|
@ -74,11 +78,11 @@ template<typename K, typename T, typename Flags = uint> class id_map {
|
|||
}
|
||||
|
||||
/* Update existing data. */
|
||||
bool update(T *data, const ::ID *id)
|
||||
bool update(T *data, const blender::ID *id)
|
||||
{
|
||||
return update(data, id, id);
|
||||
}
|
||||
bool update(T *data, const ::ID *id, const ::ID *parent)
|
||||
bool update(T *data, const blender::ID *id, const blender::ID *parent)
|
||||
{
|
||||
bool recalc = (b_recalc.find(id) != b_recalc.end());
|
||||
if (parent && parent != id) {
|
||||
|
|
@ -89,15 +93,15 @@ template<typename K, typename T, typename Flags = uint> class id_map {
|
|||
}
|
||||
|
||||
/* Combined add and update as needed. */
|
||||
bool add_or_update(T **r_data, const ::ID *id)
|
||||
bool add_or_update(T **r_data, const blender::ID *id)
|
||||
{
|
||||
return add_or_update(r_data, id, id, id);
|
||||
}
|
||||
bool add_or_update(T **r_data, const ::ID *id, const K &key)
|
||||
bool add_or_update(T **r_data, const blender::ID *id, const K &key)
|
||||
{
|
||||
return add_or_update(r_data, id, id, key);
|
||||
}
|
||||
bool add_or_update(T **r_data, const ::ID *id, const ::ID *parent, const K &key)
|
||||
bool add_or_update(T **r_data, const blender::ID *id, const blender::ID *parent, const K &key)
|
||||
{
|
||||
T *data = find(key);
|
||||
bool recalc;
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ CCL_NAMESPACE_BEGIN
|
|||
|
||||
/* Packed Images */
|
||||
|
||||
BlenderImageLoader::BlenderImageLoader(Image *b_image,
|
||||
ImageUser *b_iuser,
|
||||
BlenderImageLoader::BlenderImageLoader(blender::Image *b_image,
|
||||
blender::ImageUser *b_iuser,
|
||||
const int frame,
|
||||
const int tile_number,
|
||||
const bool is_preview_render)
|
||||
|
|
@ -33,9 +33,9 @@ BlenderImageLoader::BlenderImageLoader(Image *b_image,
|
|||
free_cache(!is_preview_render && !BKE_image_has_loaded_ibuf(b_image))
|
||||
{
|
||||
this->b_iuser.framenr = frame;
|
||||
if (b_image->source != IMA_SRC_TILED) {
|
||||
if (b_image->source != blender::IMA_SRC_TILED) {
|
||||
/* Image sequences currently not supported by this image loader. */
|
||||
assert(b_image->source != IMA_SRC_SEQUENCE);
|
||||
assert(b_image->source != blender::IMA_SRC_SEQUENCE);
|
||||
}
|
||||
else {
|
||||
/* Set UDIM tile, each can have different resolution. */
|
||||
|
|
@ -50,7 +50,7 @@ bool BlenderImageLoader::load_metadata(const ImageDeviceFeatures & /*features*/,
|
|||
|
||||
{
|
||||
void *lock;
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(b_image, &b_iuser, &lock);
|
||||
blender::ImBuf *ibuf = BKE_image_acquire_ibuf(b_image, &b_iuser, &lock);
|
||||
if (ibuf) {
|
||||
is_float = ibuf->float_buffer.data != nullptr;
|
||||
metadata.width = ibuf->x;
|
||||
|
|
@ -88,7 +88,9 @@ bool BlenderImageLoader::load_metadata(const ImageDeviceFeatures & /*features*/,
|
|||
return true;
|
||||
}
|
||||
|
||||
static void load_float_pixels(const ImBuf *ibuf, const ImageMetaData &metadata, float *out_pixels)
|
||||
static void load_float_pixels(const blender::ImBuf *ibuf,
|
||||
const ImageMetaData &metadata,
|
||||
float *out_pixels)
|
||||
{
|
||||
const size_t num_pixels = ((size_t)metadata.width) * metadata.height;
|
||||
const int out_channels = metadata.channels;
|
||||
|
|
@ -125,7 +127,7 @@ static void load_float_pixels(const ImBuf *ibuf, const ImageMetaData &metadata,
|
|||
}
|
||||
}
|
||||
|
||||
static void load_half_pixels(const ImBuf *ibuf,
|
||||
static void load_half_pixels(const blender::ImBuf *ibuf,
|
||||
const ImageMetaData &metadata,
|
||||
half *out_pixels,
|
||||
const bool associate_alpha)
|
||||
|
|
@ -172,7 +174,7 @@ static void load_half_pixels(const ImBuf *ibuf,
|
|||
}
|
||||
}
|
||||
|
||||
static void load_byte_pixels(const ImBuf *ibuf,
|
||||
static void load_byte_pixels(const blender::ImBuf *ibuf,
|
||||
const ImageMetaData &metadata,
|
||||
uchar *out_pixels,
|
||||
const bool associate_alpha)
|
||||
|
|
@ -214,7 +216,7 @@ bool BlenderImageLoader::load_pixels(const ImageMetaData &metadata,
|
|||
const bool associate_alpha)
|
||||
{
|
||||
void *lock;
|
||||
ImBuf *ibuf = BKE_image_acquire_ibuf(b_image, &b_iuser, &lock);
|
||||
blender::ImBuf *ibuf = BKE_image_acquire_ibuf(b_image, &b_iuser, &lock);
|
||||
|
||||
/* Image changed since we requested metadata, assume we'll get a signal to reload it later. */
|
||||
const bool mismatch = (ibuf == nullptr || ibuf->x != metadata.width ||
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ CCL_NAMESPACE_BEGIN
|
|||
|
||||
class BlenderImageLoader : public ImageLoader {
|
||||
public:
|
||||
BlenderImageLoader(::Image *b_image,
|
||||
::ImageUser *b_iuser,
|
||||
BlenderImageLoader(blender::Image *b_image,
|
||||
blender::ImageUser *b_iuser,
|
||||
const int frame,
|
||||
const int tile_number,
|
||||
const bool is_preview_render);
|
||||
|
|
@ -32,8 +32,8 @@ class BlenderImageLoader : public ImageLoader {
|
|||
|
||||
int get_tile_number() const override;
|
||||
|
||||
::Image *b_image;
|
||||
::ImageUser b_iuser;
|
||||
blender::Image *b_image;
|
||||
blender::ImageUser b_iuser;
|
||||
bool free_cache;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,49 +15,49 @@ CCL_NAMESPACE_BEGIN
|
|||
|
||||
void BlenderSync::sync_light(BObjectInfo &b_ob_info, Light *light)
|
||||
{
|
||||
::Light &b_light = *blender::id_cast<::Light *>(b_ob_info.object_data);
|
||||
blender::Light &b_light = *blender::id_cast<blender::Light *>(b_ob_info.object_data);
|
||||
|
||||
light->name = b_light.id.name + 2;
|
||||
|
||||
/* type */
|
||||
switch (b_light.type) {
|
||||
case LA_LOCAL: {
|
||||
case blender::LA_LOCAL: {
|
||||
light->set_size(b_light.radius);
|
||||
light->set_light_type(LIGHT_POINT);
|
||||
light->set_is_sphere(!(b_light.mode & LA_USE_SOFT_FALLOFF));
|
||||
light->set_is_sphere(!(b_light.mode & blender::LA_USE_SOFT_FALLOFF));
|
||||
break;
|
||||
}
|
||||
case LA_SPOT: {
|
||||
case blender::LA_SPOT: {
|
||||
light->set_size(b_light.radius);
|
||||
light->set_light_type(LIGHT_SPOT);
|
||||
light->set_spot_angle(b_light.spotsize);
|
||||
light->set_spot_smooth(b_light.spotblend);
|
||||
light->set_is_sphere(!(b_light.mode & LA_USE_SOFT_FALLOFF));
|
||||
light->set_is_sphere(!(b_light.mode & blender::LA_USE_SOFT_FALLOFF));
|
||||
break;
|
||||
}
|
||||
case LA_SUN: {
|
||||
case blender::LA_SUN: {
|
||||
light->set_angle(b_light.sun_angle);
|
||||
light->set_light_type(LIGHT_DISTANT);
|
||||
break;
|
||||
}
|
||||
case LA_AREA: {
|
||||
case blender::LA_AREA: {
|
||||
light->set_size(1.0f);
|
||||
light->set_sizeu(b_light.area_size);
|
||||
light->set_spread(b_light.area_spread);
|
||||
switch (b_light.area_shape) {
|
||||
case LA_AREA_SQUARE:
|
||||
case blender::LA_AREA_SQUARE:
|
||||
light->set_sizev(light->get_sizeu());
|
||||
light->set_ellipse(false);
|
||||
break;
|
||||
case LA_AREA_RECT:
|
||||
case blender::LA_AREA_RECT:
|
||||
light->set_sizev(b_light.area_sizey);
|
||||
light->set_ellipse(false);
|
||||
break;
|
||||
case LA_AREA_DISK:
|
||||
case blender::LA_AREA_DISK:
|
||||
light->set_sizev(light->get_sizeu());
|
||||
light->set_ellipse(true);
|
||||
break;
|
||||
case LA_AREA_ELLIPSE:
|
||||
case blender::LA_AREA_ELLIPSE:
|
||||
light->set_sizev(b_light.area_sizey);
|
||||
light->set_ellipse(true);
|
||||
break;
|
||||
|
|
@ -67,11 +67,11 @@ void BlenderSync::sync_light(BObjectInfo &b_ob_info, Light *light)
|
|||
}
|
||||
}
|
||||
|
||||
PointerRNA light_rna_ptr = RNA_id_pointer_create(&b_light.id);
|
||||
blender::PointerRNA light_rna_ptr = RNA_id_pointer_create(&b_light.id);
|
||||
|
||||
/* Color and strength. */
|
||||
float3 light_color = make_float3(b_light.r, b_light.g, b_light.b);
|
||||
if (b_light.mode & LA_USE_TEMPERATURE) {
|
||||
if (b_light.mode & blender::LA_USE_TEMPERATURE) {
|
||||
float color[3];
|
||||
RNA_float_get_array(&light_rna_ptr, "temperature_color", color);
|
||||
light_color *= make_float3(color[0], color[1], color[2]);
|
||||
|
|
@ -81,11 +81,11 @@ void BlenderSync::sync_light(BObjectInfo &b_ob_info, Light *light)
|
|||
light->set_strength(strength);
|
||||
|
||||
/* normalize */
|
||||
light->set_normalize(!(b_light.mode & LA_UNNORMALIZED));
|
||||
light->set_normalize(!(b_light.mode & blender::LA_UNNORMALIZED));
|
||||
|
||||
/* shadow */
|
||||
PointerRNA clight = RNA_pointer_get(&light_rna_ptr, "cycles");
|
||||
light->set_cast_shadow(b_light.mode & LA_SHADOW);
|
||||
blender::PointerRNA clight = RNA_pointer_get(&light_rna_ptr, "cycles");
|
||||
light->set_cast_shadow(b_light.mode & blender::LA_SHADOW);
|
||||
light->set_use_mis(get_boolean(clight, "use_multiple_importance_sampling"));
|
||||
|
||||
/* caustics light */
|
||||
|
|
@ -104,13 +104,13 @@ void BlenderSync::sync_light(BObjectInfo &b_ob_info, Light *light)
|
|||
light->tag_update(scene);
|
||||
}
|
||||
|
||||
void BlenderSync::sync_background_light(::bScreen *b_screen, ::View3D *b_v3d)
|
||||
void BlenderSync::sync_background_light(blender::bScreen *b_screen, blender::View3D *b_v3d)
|
||||
{
|
||||
::World *b_world = view_layer.world_override ? view_layer.world_override : b_scene->world;
|
||||
blender::World *b_world = view_layer.world_override ? view_layer.world_override : b_scene->world;
|
||||
|
||||
if (b_world) {
|
||||
PointerRNA world_rna_ptr = RNA_id_pointer_create(&b_world->id);
|
||||
PointerRNA cworld = RNA_pointer_get(&world_rna_ptr, "cycles");
|
||||
blender::PointerRNA world_rna_ptr = RNA_id_pointer_create(&b_world->id);
|
||||
blender::PointerRNA cworld = RNA_pointer_get(&world_rna_ptr, "cycles");
|
||||
|
||||
enum SamplingMethod { SAMPLING_NONE = 0, SAMPLING_AUTOMATIC, SAMPLING_MANUAL, SAMPLING_NUM };
|
||||
const int sampling_method = get_enum(
|
||||
|
|
|
|||
|
|
@ -10,48 +10,50 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
static const ::LightLinking *get_light_linking(const ::Object &b_object)
|
||||
static const blender::LightLinking *get_light_linking(const blender::Object &b_object)
|
||||
{
|
||||
return b_object.light_linking;
|
||||
}
|
||||
|
||||
uint64_t BlenderLightLink::get_light_set_membership(const ::Object * /*parent*/,
|
||||
const ::Object &object)
|
||||
uint64_t BlenderLightLink::get_light_set_membership(const blender::Object * /*parent*/,
|
||||
const blender::Object &object)
|
||||
{
|
||||
const ::LightLinking *light_linking = get_light_linking(object);
|
||||
const blender::LightLinking *light_linking = get_light_linking(object);
|
||||
return (light_linking) ? light_linking->runtime.light_set_membership : LIGHT_LINK_MASK_ALL;
|
||||
}
|
||||
|
||||
uint BlenderLightLink::get_receiver_light_set(const ::Object *parent, const ::Object &object)
|
||||
uint BlenderLightLink::get_receiver_light_set(const blender::Object *parent,
|
||||
const blender::Object &object)
|
||||
{
|
||||
if (parent) {
|
||||
const ::LightLinking *parent_light_linking = get_light_linking(*parent);
|
||||
const blender::LightLinking *parent_light_linking = get_light_linking(*parent);
|
||||
if (parent_light_linking && parent_light_linking->runtime.receiver_light_set) {
|
||||
return parent_light_linking->runtime.receiver_light_set;
|
||||
}
|
||||
}
|
||||
|
||||
const ::LightLinking *light_linking = get_light_linking(object);
|
||||
const blender::LightLinking *light_linking = get_light_linking(object);
|
||||
return (light_linking) ? light_linking->runtime.receiver_light_set : 0;
|
||||
}
|
||||
|
||||
uint64_t BlenderLightLink::get_shadow_set_membership(const ::Object * /*parent*/,
|
||||
const ::Object &object)
|
||||
uint64_t BlenderLightLink::get_shadow_set_membership(const blender::Object * /*parent*/,
|
||||
const blender::Object &object)
|
||||
{
|
||||
const ::LightLinking *light_linking = get_light_linking(object);
|
||||
const blender::LightLinking *light_linking = get_light_linking(object);
|
||||
return (light_linking) ? light_linking->runtime.shadow_set_membership : LIGHT_LINK_MASK_ALL;
|
||||
}
|
||||
|
||||
uint BlenderLightLink::get_blocker_shadow_set(const ::Object *parent, const ::Object &object)
|
||||
uint BlenderLightLink::get_blocker_shadow_set(const blender::Object *parent,
|
||||
const blender::Object &object)
|
||||
{
|
||||
if (parent) {
|
||||
const ::LightLinking *parent_light_linking = get_light_linking(*parent);
|
||||
const blender::LightLinking *parent_light_linking = get_light_linking(*parent);
|
||||
if (parent_light_linking && parent_light_linking->runtime.blocker_shadow_set) {
|
||||
return parent_light_linking->runtime.blocker_shadow_set;
|
||||
}
|
||||
}
|
||||
|
||||
const ::LightLinking *light_linking = get_light_linking(object);
|
||||
const blender::LightLinking *light_linking = get_light_linking(object);
|
||||
return (light_linking) ? light_linking->runtime.blocker_shadow_set : 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,17 +8,21 @@
|
|||
|
||||
#include <cstdint>
|
||||
|
||||
namespace blender {
|
||||
struct Object;
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
class BlenderLightLink {
|
||||
public:
|
||||
static uint64_t get_light_set_membership(const ::Object *parent, const ::Object &object);
|
||||
static uint get_receiver_light_set(const ::Object *parent, const ::Object &object);
|
||||
static uint64_t get_light_set_membership(const blender::Object *parent,
|
||||
const blender::Object &object);
|
||||
static uint get_receiver_light_set(const blender::Object *parent, const blender::Object &object);
|
||||
|
||||
static uint64_t get_shadow_set_membership(const ::Object *parent, const ::Object &object);
|
||||
static uint get_blocker_shadow_set(const ::Object *parent, const ::Object &object);
|
||||
static uint64_t get_shadow_set_membership(const blender::Object *parent,
|
||||
const blender::Object &object);
|
||||
static uint get_blocker_shadow_set(const blender::Object *parent, const blender::Object &object);
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -35,9 +35,11 @@
|
|||
|
||||
#include "GEO_mesh_split_edges.hh"
|
||||
|
||||
using blender::Attribute;
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
void mesh_split_edges_for_corner_normals(::Mesh &mesh)
|
||||
void mesh_split_edges_for_corner_normals(blender::Mesh &mesh)
|
||||
{
|
||||
using namespace blender;
|
||||
const OffsetIndices polys = mesh.faces();
|
||||
|
|
@ -51,7 +53,7 @@ void mesh_split_edges_for_corner_normals(::Mesh &mesh)
|
|||
Array<bool> sharp_edges(mesh.edges_num);
|
||||
mesh_sharp_edges.materialize(sharp_edges);
|
||||
|
||||
threading::parallel_for(polys.index_range(), 1024, [&](const IndexRange range) {
|
||||
threading::parallel_for(polys.index_range(), 1024, [&](const blender::IndexRange range) {
|
||||
for (const int face_i : range) {
|
||||
if (!sharp_faces.is_empty() && sharp_faces[face_i]) {
|
||||
for (const int edge : corner_edges.slice(polys[face_i])) {
|
||||
|
|
@ -105,7 +107,7 @@ static void attr_create_motion_from_velocity(Mesh *mesh,
|
|||
|
||||
static void attr_create_generic(Scene *scene,
|
||||
Mesh *mesh,
|
||||
const ::Mesh &b_mesh,
|
||||
const blender::Mesh &b_mesh,
|
||||
const bool subdivision,
|
||||
const bool need_motion,
|
||||
const float motion_scale)
|
||||
|
|
@ -259,7 +261,7 @@ static void attr_create_generic(Scene *scene,
|
|||
});
|
||||
}
|
||||
|
||||
static set<ustring> get_blender_uv_names(const ::Mesh &b_mesh)
|
||||
static set<ustring> get_blender_uv_names(const blender::Mesh &b_mesh)
|
||||
{
|
||||
set<ustring> uv_names;
|
||||
b_mesh.attributes().foreach_attribute([&](const blender::bke::AttributeIter &iter) {
|
||||
|
|
@ -277,7 +279,7 @@ static set<ustring> get_blender_uv_names(const ::Mesh &b_mesh)
|
|||
/* Create uv map attributes. */
|
||||
static void attr_create_uv_map(Scene *scene,
|
||||
Mesh *mesh,
|
||||
const ::Mesh &b_mesh,
|
||||
const blender::Mesh &b_mesh,
|
||||
const set<ustring> &blender_uv_names)
|
||||
{
|
||||
const blender::Span<blender::int3> corner_tris = b_mesh.corner_tris();
|
||||
|
|
@ -320,7 +322,7 @@ static void attr_create_uv_map(Scene *scene,
|
|||
|
||||
static void attr_create_subd_uv_map(Scene *scene,
|
||||
Mesh *mesh,
|
||||
const ::Mesh &b_mesh,
|
||||
const blender::Mesh &b_mesh,
|
||||
const set<ustring> &blender_uv_names)
|
||||
{
|
||||
const blender::OffsetIndices faces = b_mesh.faces();
|
||||
|
|
@ -550,7 +552,7 @@ static void attr_create_pointiness(Mesh *mesh,
|
|||
* making the output unsafe to hash. */
|
||||
static void attr_create_random_per_island(Scene *scene,
|
||||
Mesh *mesh,
|
||||
const ::Mesh &b_mesh,
|
||||
const blender::Mesh &b_mesh,
|
||||
bool subdivision)
|
||||
{
|
||||
if (!mesh->need_attribute(scene, ATTR_STD_RANDOM_PER_ISLAND)) {
|
||||
|
|
@ -598,7 +600,7 @@ static void attr_create_random_per_island(Scene *scene,
|
|||
|
||||
static void create_mesh(Scene *scene,
|
||||
Mesh *mesh,
|
||||
const ::Mesh &b_mesh,
|
||||
const blender::Mesh &b_mesh,
|
||||
const array<Node *> &used_shaders,
|
||||
const bool need_motion,
|
||||
const float motion_scale,
|
||||
|
|
@ -662,7 +664,7 @@ static void create_mesh(Scene *scene,
|
|||
(mesh->need_attribute(scene, ATTR_STD_UV_TANGENT));
|
||||
if (mesh->need_attribute(scene, ATTR_STD_GENERATED) || need_default_tangent) {
|
||||
const float (*orco)[3] = static_cast<const float (*)[3]>(
|
||||
CustomData_get_layer(&b_mesh.vert_data, CD_ORCO));
|
||||
CustomData_get_layer(&b_mesh.vert_data, blender::CD_ORCO));
|
||||
Attribute *attr = attributes.add(ATTR_STD_GENERATED);
|
||||
|
||||
float3 loc;
|
||||
|
|
@ -671,9 +673,10 @@ static void create_mesh(Scene *scene,
|
|||
|
||||
float texspace_location[3];
|
||||
float texspace_size[3];
|
||||
BKE_mesh_texspace_get(const_cast<::Mesh *>(b_mesh.texcomesh ? b_mesh.texcomesh : &b_mesh),
|
||||
texspace_location,
|
||||
texspace_size);
|
||||
BKE_mesh_texspace_get(
|
||||
const_cast<blender::Mesh *>(b_mesh.texcomesh ? b_mesh.texcomesh : &b_mesh),
|
||||
texspace_location,
|
||||
texspace_size);
|
||||
|
||||
float3 *generated = attr->data_float3();
|
||||
|
||||
|
|
@ -830,18 +833,19 @@ static void create_mesh(Scene *scene,
|
|||
static void create_subd_mesh(Scene *scene,
|
||||
Mesh *mesh,
|
||||
BObjectInfo &b_ob_info,
|
||||
const ::Mesh &b_mesh,
|
||||
const blender::Mesh &b_mesh,
|
||||
const array<Node *> &used_shaders,
|
||||
const bool need_motion,
|
||||
const float motion_scale,
|
||||
const float dicing_rate,
|
||||
const int max_subdivisions)
|
||||
{
|
||||
const ::Object *b_ob = b_ob_info.real_object;
|
||||
const blender::Object *b_ob = b_ob_info.real_object;
|
||||
|
||||
const auto &subsurf_mod = *reinterpret_cast<const ::SubsurfModifierData *>(b_ob->modifiers.last);
|
||||
const auto &subsurf_mod = *reinterpret_cast<const blender::SubsurfModifierData *>(
|
||||
b_ob->modifiers.last);
|
||||
|
||||
const bool use_creases = (subsurf_mod.flags & eSubsurfModifierFlag_UseCrease) != 0;
|
||||
const bool use_creases = (subsurf_mod.flags & blender::eSubsurfModifierFlag_UseCrease) != 0;
|
||||
|
||||
create_mesh(scene, mesh, b_mesh, used_shaders, need_motion, motion_scale, true);
|
||||
|
||||
|
|
@ -882,10 +886,10 @@ static void create_subd_mesh(Scene *scene,
|
|||
/* Set subd parameters. */
|
||||
Mesh::SubdivisionAdaptiveSpace space = Mesh::SUBDIVISION_ADAPTIVE_SPACE_PIXEL;
|
||||
switch (subsurf_mod.adaptive_space) {
|
||||
case SUBSURF_ADAPTIVE_SPACE_OBJECT:
|
||||
case blender::SUBSURF_ADAPTIVE_SPACE_OBJECT:
|
||||
space = Mesh::SUBDIVISION_ADAPTIVE_SPACE_OBJECT;
|
||||
break;
|
||||
case SUBSURF_ADAPTIVE_SPACE_PIXEL:
|
||||
case blender::SUBSURF_ADAPTIVE_SPACE_PIXEL:
|
||||
space = Mesh::SUBDIVISION_ADAPTIVE_SPACE_PIXEL;
|
||||
break;
|
||||
}
|
||||
|
|
@ -913,7 +917,7 @@ void BlenderSync::sync_mesh(BObjectInfo &b_ob_info, Mesh *mesh)
|
|||
if (view_layer.use_surfaces) {
|
||||
object_subdivision_to_mesh(
|
||||
*b_ob_info.real_object, new_mesh, preview, use_adaptive_subdivision);
|
||||
const ::Mesh *b_mesh = object_to_mesh(b_ob_info);
|
||||
const blender::Mesh *b_mesh = object_to_mesh(b_ob_info);
|
||||
|
||||
if (b_mesh) {
|
||||
/* Motion blur attribute is relative to seconds, we need it relative to frames. */
|
||||
|
|
@ -945,7 +949,7 @@ void BlenderSync::sync_mesh(BObjectInfo &b_ob_info, Mesh *mesh)
|
|||
false);
|
||||
}
|
||||
|
||||
free_object_to_mesh(b_ob_info, const_cast<::Mesh &>(*b_mesh));
|
||||
free_object_to_mesh(b_ob_info, const_cast<blender::Mesh &>(*b_mesh));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -986,7 +990,7 @@ void BlenderSync::sync_mesh_motion(BObjectInfo &b_ob_info, Mesh *mesh, const int
|
|||
|
||||
/* Skip objects without deforming modifiers. this is not totally reliable,
|
||||
* would need a more extensive check to see which objects are animated. */
|
||||
const ::Mesh *b_mesh = nullptr;
|
||||
const blender::Mesh *b_mesh = nullptr;
|
||||
if (ccl::BKE_object_is_deform_modified(b_ob_info, *b_scene, preview)) {
|
||||
/* get derived mesh */
|
||||
b_mesh = object_to_mesh(b_ob_info);
|
||||
|
|
@ -999,7 +1003,7 @@ void BlenderSync::sync_mesh_motion(BObjectInfo &b_ob_info, Mesh *mesh, const int
|
|||
const int b_verts_num = b_mesh->verts_num;
|
||||
const blender::Span<blender::float3> positions = b_mesh->vert_positions();
|
||||
if (positions.is_empty()) {
|
||||
free_object_to_mesh(b_ob_info, *const_cast<::Mesh *>(b_mesh));
|
||||
free_object_to_mesh(b_ob_info, *const_cast<blender::Mesh *>(b_mesh));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1082,7 +1086,7 @@ void BlenderSync::sync_mesh_motion(BObjectInfo &b_ob_info, Mesh *mesh, const int
|
|||
}
|
||||
}
|
||||
|
||||
free_object_to_mesh(b_ob_info, *const_cast<::Mesh *>(b_mesh));
|
||||
free_object_to_mesh(b_ob_info, *const_cast<blender::Mesh *>(b_mesh));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,19 +31,21 @@
|
|||
|
||||
#include "RE_engine.h"
|
||||
|
||||
using blender::Object;
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Utilities */
|
||||
|
||||
bool BlenderSync::BKE_object_is_modified(::Object &b_ob)
|
||||
bool BlenderSync::BKE_object_is_modified(blender::Object &b_ob)
|
||||
{
|
||||
/* test if we can instance or if the object is modified */
|
||||
if (b_ob.type == OB_MBALL) {
|
||||
if (b_ob.type == blender::OB_MBALL) {
|
||||
/* Multi-user and dupli meta-balls are fused, can't instance. */
|
||||
return true;
|
||||
}
|
||||
const int settings = preview ? eModifierMode_Realtime : eModifierMode_Render;
|
||||
if ((::BKE_object_is_modified(b_scene, &b_ob) & settings) != 0) {
|
||||
const int settings = preview ? blender::eModifierMode_Realtime : blender::eModifierMode_Render;
|
||||
if ((blender::BKE_object_is_modified(b_scene, &b_ob) & settings) != 0) {
|
||||
/* modifiers */
|
||||
return true;
|
||||
}
|
||||
|
|
@ -60,55 +62,59 @@ bool BlenderSync::BKE_object_is_modified(::Object &b_ob)
|
|||
|
||||
bool BlenderSync::object_is_geometry(BObjectInfo &b_ob_info)
|
||||
{
|
||||
::ID *b_ob_data = b_ob_info.object_data;
|
||||
blender::ID *b_ob_data = b_ob_info.object_data;
|
||||
|
||||
if (!b_ob_data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const ObjectType type = ObjectType(b_ob_info.iter_object->type);
|
||||
const blender::ObjectType type = blender::ObjectType(b_ob_info.iter_object->type);
|
||||
|
||||
if (type == OB_VOLUME || type == OB_CURVES || type == OB_POINTCLOUD || type == OB_LAMP) {
|
||||
if (type == blender::OB_VOLUME || type == blender::OB_CURVES || type == blender::OB_POINTCLOUD ||
|
||||
type == blender::OB_LAMP)
|
||||
{
|
||||
/* Will be exported as geometry. */
|
||||
return true;
|
||||
}
|
||||
|
||||
return GS(b_ob_data->name) == ID_ME;
|
||||
return GS(b_ob_data->name) == blender::ID_ME;
|
||||
}
|
||||
|
||||
bool BlenderSync::object_can_have_geometry(::Object &b_ob)
|
||||
bool BlenderSync::object_can_have_geometry(blender::Object &b_ob)
|
||||
{
|
||||
const ObjectType type = ObjectType(b_ob.type);
|
||||
const blender::ObjectType type = blender::ObjectType(b_ob.type);
|
||||
switch (type) {
|
||||
case OB_MESH:
|
||||
case OB_CURVES_LEGACY:
|
||||
case OB_SURF:
|
||||
case OB_MBALL:
|
||||
case OB_FONT:
|
||||
case OB_CURVES:
|
||||
case OB_POINTCLOUD:
|
||||
case OB_VOLUME:
|
||||
case blender::OB_MESH:
|
||||
case blender::OB_CURVES_LEGACY:
|
||||
case blender::OB_SURF:
|
||||
case blender::OB_MBALL:
|
||||
case blender::OB_FONT:
|
||||
case blender::OB_CURVES:
|
||||
case blender::OB_POINTCLOUD:
|
||||
case blender::OB_VOLUME:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool BlenderSync::object_is_light(::Object &b_ob)
|
||||
bool BlenderSync::object_is_light(blender::Object &b_ob)
|
||||
{
|
||||
::ID *b_ob_data = object_get_data(b_ob, true);
|
||||
blender::ID *b_ob_data = object_get_data(b_ob, true);
|
||||
|
||||
return (b_ob_data && GS(b_ob_data->name) == ID_LA);
|
||||
return (b_ob_data && GS(b_ob_data->name) == blender::ID_LA);
|
||||
}
|
||||
|
||||
bool BlenderSync::object_is_camera(::Object &b_ob)
|
||||
bool BlenderSync::object_is_camera(blender::Object &b_ob)
|
||||
{
|
||||
::ID *b_ob_data = object_get_data(b_ob, true);
|
||||
blender::ID *b_ob_data = object_get_data(b_ob, true);
|
||||
|
||||
return (b_ob_data && GS(b_ob_data->name) == ID_CA);
|
||||
return (b_ob_data && GS(b_ob_data->name) == blender::ID_CA);
|
||||
}
|
||||
|
||||
void BlenderSync::sync_object_motion_init(::Object &b_parent, ::Object &b_ob, Object *object)
|
||||
void BlenderSync::sync_object_motion_init(blender::Object &b_parent,
|
||||
blender::Object &b_ob,
|
||||
Object *object)
|
||||
{
|
||||
/* Initialize motion blur for object, detecting if it's enabled and creating motion
|
||||
* steps array if so. */
|
||||
|
|
@ -150,9 +156,9 @@ void BlenderSync::sync_object_motion_init(::Object &b_parent, ::Object &b_ob, Ob
|
|||
}
|
||||
}
|
||||
|
||||
Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
||||
::Object &b_ob,
|
||||
::DEGObjectIterData &b_deg_iter_data,
|
||||
Object *BlenderSync::sync_object(blender::ViewLayer &b_view_layer,
|
||||
blender::Object &b_ob,
|
||||
blender::DEGObjectIterData &b_deg_iter_data,
|
||||
const float motion_time,
|
||||
bool use_particle_hair,
|
||||
bool show_lights,
|
||||
|
|
@ -160,8 +166,8 @@ Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
|||
TaskPool *geom_task_pool)
|
||||
{
|
||||
const bool is_instance = b_deg_iter_data.dupli_object_current;
|
||||
::Object *b_parent = is_instance ? b_deg_iter_data.dupli_parent : &b_ob;
|
||||
::Object *b_real_object = is_instance ? b_deg_iter_data.dupli_object_current->ob : &b_ob;
|
||||
blender::Object *b_parent = is_instance ? b_deg_iter_data.dupli_parent : &b_ob;
|
||||
blender::Object *b_real_object = is_instance ? b_deg_iter_data.dupli_object_current->ob : &b_ob;
|
||||
const bool use_adaptive_subdiv = object_subdivision_type(
|
||||
*b_real_object, preview, use_adaptive_subdivision) !=
|
||||
Mesh::SUBDIVISION_NONE;
|
||||
|
|
@ -195,11 +201,11 @@ Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
|||
}
|
||||
|
||||
/* Visibility flags for both parent and child. */
|
||||
PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
const Base *base_parent = BKE_view_layer_base_find(&b_view_layer, b_parent);
|
||||
const bool use_holdout = ((base_parent->flag & BASE_HOLDOUT) != 0) ||
|
||||
((b_parent->visibility_flag & OB_HOLDOUT) != 0);
|
||||
blender::PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
blender::PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
const blender::Base *base_parent = BKE_view_layer_base_find(&b_view_layer, b_parent);
|
||||
const bool use_holdout = ((base_parent->flag & blender::BASE_HOLDOUT) != 0) ||
|
||||
((b_parent->visibility_flag & blender::OB_HOLDOUT) != 0);
|
||||
uint visibility = object_ray_visibility(b_ob) & PATH_RAY_ALL_VISIBILITY;
|
||||
|
||||
if (b_parent != &b_ob) {
|
||||
|
|
@ -214,7 +220,8 @@ Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
|||
#endif
|
||||
|
||||
/* Clear camera visibility for indirect only objects. */
|
||||
const bool use_indirect_only = !use_holdout && ((base_parent->flag & BASE_INDIRECT_ONLY) != 0);
|
||||
const bool use_indirect_only = !use_holdout &&
|
||||
((base_parent->flag & blender::BASE_INDIRECT_ONLY) != 0);
|
||||
if (use_indirect_only) {
|
||||
visibility &= ~PATH_RAY_CAMERA;
|
||||
}
|
||||
|
|
@ -275,8 +282,8 @@ Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
|||
|
||||
object->set_visibility(visibility);
|
||||
|
||||
object->set_is_shadow_catcher((b_ob.visibility_flag & OB_SHADOW_CATCHER) != 0 ||
|
||||
(b_parent->visibility_flag & OB_SHADOW_CATCHER) != 0);
|
||||
object->set_is_shadow_catcher((b_ob.visibility_flag & blender::OB_SHADOW_CATCHER) != 0 ||
|
||||
(b_parent->visibility_flag & blender::OB_SHADOW_CATCHER) != 0);
|
||||
|
||||
object->set_shadow_terminator_shading_offset(b_ob.shadow_terminator_shading_offset);
|
||||
|
||||
|
|
@ -284,8 +291,8 @@ Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
|||
|
||||
float ao_distance = get_float(cobject, "ao_distance");
|
||||
if (ao_distance == 0.0f && b_parent != &b_ob) {
|
||||
PointerRNA b_parent_rna_ptr = RNA_id_pointer_create(&b_parent->id);
|
||||
PointerRNA cparent = RNA_pointer_get(&b_parent_rna_ptr, "cycles");
|
||||
blender::PointerRNA b_parent_rna_ptr = RNA_id_pointer_create(&b_parent->id);
|
||||
blender::PointerRNA cparent = RNA_pointer_get(&b_parent_rna_ptr, "cycles");
|
||||
ao_distance = get_float(cparent, "ao_distance");
|
||||
}
|
||||
object->set_ao_distance(ao_distance);
|
||||
|
|
@ -299,7 +306,7 @@ Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
|||
object->set_is_bake_target(b_ob_info.real_object == b_bake_target);
|
||||
|
||||
/* sync the asset name for Cryptomatte */
|
||||
::Object *parent = b_ob.parent;
|
||||
blender::Object *parent = b_ob.parent;
|
||||
ustring parent_name;
|
||||
if (parent) {
|
||||
while (parent->parent) {
|
||||
|
|
@ -367,15 +374,16 @@ Object *BlenderSync::sync_object(::ViewLayer &b_view_layer,
|
|||
return object;
|
||||
}
|
||||
|
||||
extern "C" DupliObject *rna_hack_DepsgraphObjectInstance_dupli_object_get(PointerRNA *ptr);
|
||||
extern "C" blender::DupliObject *rna_hack_DepsgraphObjectInstance_dupli_object_get(
|
||||
blender::PointerRNA *ptr);
|
||||
|
||||
static float4 lookup_instance_property(::Object &ob,
|
||||
::DEGObjectIterData &b_deg_iter_data,
|
||||
static float4 lookup_instance_property(blender::Object &ob,
|
||||
blender::DEGObjectIterData &b_deg_iter_data,
|
||||
const string &name,
|
||||
bool use_instancer)
|
||||
{
|
||||
::DupliObject *dupli = nullptr;
|
||||
::Object *dupli_parent = nullptr;
|
||||
blender::DupliObject *dupli = nullptr;
|
||||
blender::Object *dupli_parent = nullptr;
|
||||
|
||||
/* If requesting instance data, check the parent particle system and object. */
|
||||
if (use_instancer && b_deg_iter_data.dupli_object_current) {
|
||||
|
|
@ -389,8 +397,8 @@ static float4 lookup_instance_property(::Object &ob,
|
|||
return value;
|
||||
}
|
||||
|
||||
bool BlenderSync::sync_object_attributes(::Object &b_ob,
|
||||
::DEGObjectIterData &b_deg_iter_data,
|
||||
bool BlenderSync::sync_object_attributes(blender::Object &b_ob,
|
||||
blender::DEGObjectIterData &b_deg_iter_data,
|
||||
Object *object)
|
||||
{
|
||||
/* Find which attributes are needed. */
|
||||
|
|
@ -414,8 +422,8 @@ bool BlenderSync::sync_object_attributes(::Object &b_ob,
|
|||
std::string real_name;
|
||||
const int type = blender_attribute_name_split_type(name, &real_name);
|
||||
|
||||
if (type == SHD_ATTRIBUTE_OBJECT || type == SHD_ATTRIBUTE_INSTANCER) {
|
||||
const bool use_instancer = (type == SHD_ATTRIBUTE_INSTANCER);
|
||||
if (type == blender::SHD_ATTRIBUTE_OBJECT || type == blender::SHD_ATTRIBUTE_INSTANCER) {
|
||||
const bool use_instancer = (type == blender::SHD_ATTRIBUTE_INSTANCER);
|
||||
float4 value = lookup_instance_property(b_ob, b_deg_iter_data, real_name, use_instancer);
|
||||
|
||||
/* Try finding the existing attribute value. */
|
||||
|
|
@ -448,9 +456,9 @@ bool BlenderSync::sync_object_attributes(::Object &b_ob,
|
|||
|
||||
/* Object Loop */
|
||||
|
||||
void BlenderSync::sync_objects(::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
void BlenderSync::sync_objects(blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
const float motion_time)
|
||||
{
|
||||
/* Task pool for multithreaded geometry sync. */
|
||||
|
|
@ -485,23 +493,23 @@ void BlenderSync::sync_objects(::Depsgraph &b_depsgraph,
|
|||
const bool show_lights =
|
||||
BlenderViewportParameters(b_screen, b_v3d, use_developer_ui).use_scene_lights;
|
||||
|
||||
::ViewLayer &b_view_layer = *DEG_get_evaluated_view_layer(&b_depsgraph);
|
||||
blender::ViewLayer &b_view_layer = *DEG_get_evaluated_view_layer(&b_depsgraph);
|
||||
|
||||
BKE_view_layer_synced_ensure(b_scene, &b_view_layer);
|
||||
|
||||
::DEGObjectIterSettings deg_iter_settings{};
|
||||
blender::DEGObjectIterSettings deg_iter_settings{};
|
||||
deg_iter_settings.depsgraph = &b_depsgraph;
|
||||
deg_iter_settings.flags = DEG_OBJECT_ITER_FOR_RENDER_ENGINE_FLAGS;
|
||||
DEGObjectIterData deg_iter_data{};
|
||||
blender::DEGObjectIterData deg_iter_data{};
|
||||
deg_iter_data.settings = °_iter_settings;
|
||||
deg_iter_data.graph = deg_iter_settings.depsgraph;
|
||||
deg_iter_data.flag = deg_iter_settings.flags;
|
||||
|
||||
ITER_BEGIN (DEG_iterator_objects_begin,
|
||||
DEG_iterator_objects_next,
|
||||
DEG_iterator_objects_end,
|
||||
ITER_BEGIN (blender::DEG_iterator_objects_begin,
|
||||
blender::DEG_iterator_objects_next,
|
||||
blender::DEG_iterator_objects_end,
|
||||
°_iter_data,
|
||||
::Object *,
|
||||
blender::Object *,
|
||||
b_ob)
|
||||
{
|
||||
/* Viewport visibility. */
|
||||
|
|
@ -518,11 +526,11 @@ void BlenderSync::sync_objects(::Depsgraph &b_depsgraph,
|
|||
/* Ensure the object geom supporting the hair is processed before adding
|
||||
* the hair processing task to the task pool, calling .to_mesh() on the
|
||||
* same object in parallel does not work. */
|
||||
const bool sync_hair = (ob_visibility & OB_VISIBLE_PARTICLES) != 0 &&
|
||||
const bool sync_hair = (ob_visibility & blender::OB_VISIBLE_PARTICLES) != 0 &&
|
||||
object_has_particle_hair(b_ob);
|
||||
|
||||
/* Object itself. */
|
||||
if ((ob_visibility & OB_VISIBLE_SELF) != 0) {
|
||||
if ((ob_visibility & blender::OB_VISIBLE_SELF) != 0) {
|
||||
sync_object(b_view_layer,
|
||||
*b_ob,
|
||||
deg_iter_data,
|
||||
|
|
@ -574,11 +582,11 @@ void BlenderSync::sync_objects(::Depsgraph &b_depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
void BlenderSync::sync_motion(::RenderData &b_render,
|
||||
::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
void BlenderSync::sync_motion(blender::RenderData &b_render,
|
||||
blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height,
|
||||
void **python_thread_state)
|
||||
|
|
@ -588,7 +596,7 @@ void BlenderSync::sync_motion(::RenderData &b_render,
|
|||
}
|
||||
|
||||
/* get camera object here to deal with camera switch */
|
||||
::Object *b_cam = get_camera_object(b_v3d, b_rv3d);
|
||||
blender::Object *b_cam = get_camera_object(b_v3d, b_rv3d);
|
||||
|
||||
const int frame_center = b_scene->r.cfra;
|
||||
const float subframe_center = b_scene->r.subframe;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
BlenderObjectCulling::BlenderObjectCulling(Scene *scene, ::Scene &b_scene)
|
||||
BlenderObjectCulling::BlenderObjectCulling(Scene *scene, blender::Scene &b_scene)
|
||||
: use_scene_camera_cull_(false),
|
||||
use_camera_cull_(false),
|
||||
camera_cull_margin_(0.0f),
|
||||
|
|
@ -21,16 +21,17 @@ BlenderObjectCulling::BlenderObjectCulling(Scene *scene, ::Scene &b_scene)
|
|||
use_distance_cull_(false),
|
||||
distance_cull_margin_(0.0f)
|
||||
{
|
||||
if ((b_scene.r.mode & R_SIMPLIFY) != 0) {
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
if ((b_scene.r.mode & blender::R_SIMPLIFY) != 0) {
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
|
||||
const bool cam_supported = (scene->camera->get_camera_type() == CAMERA_PERSPECTIVE) ||
|
||||
(scene->camera->get_camera_type() == CAMERA_ORTHOGRAPHIC);
|
||||
|
||||
use_scene_camera_cull_ = cam_supported && ((b_scene.r.scemode & R_MULTIVIEW) == 0) &&
|
||||
use_scene_camera_cull_ = cam_supported && ((b_scene.r.scemode & blender::R_MULTIVIEW) == 0) &&
|
||||
get_boolean(cscene, "use_camera_cull");
|
||||
use_scene_distance_cull_ = cam_supported && ((b_scene.r.scemode & R_MULTIVIEW) == 0) &&
|
||||
use_scene_distance_cull_ = cam_supported &&
|
||||
((b_scene.r.scemode & blender::R_MULTIVIEW) == 0) &&
|
||||
get_boolean(cscene, "use_distance_cull");
|
||||
|
||||
camera_cull_margin_ = get_float(cscene, "camera_cull_margin");
|
||||
|
|
@ -42,14 +43,14 @@ BlenderObjectCulling::BlenderObjectCulling(Scene *scene, ::Scene &b_scene)
|
|||
}
|
||||
}
|
||||
|
||||
void BlenderObjectCulling::init_object(Scene *scene, ::Object &b_ob)
|
||||
void BlenderObjectCulling::init_object(Scene *scene, blender::Object &b_ob)
|
||||
{
|
||||
if (!use_scene_camera_cull_ && !use_scene_distance_cull_) {
|
||||
return;
|
||||
}
|
||||
|
||||
PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
blender::PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
blender::PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
|
||||
use_camera_cull_ = use_scene_camera_cull_ && get_boolean(cobject, "use_camera_cull");
|
||||
use_distance_cull_ = use_scene_distance_cull_ && get_boolean(cobject, "use_distance_cull");
|
||||
|
|
@ -60,7 +61,7 @@ void BlenderObjectCulling::init_object(Scene *scene, ::Object &b_ob)
|
|||
}
|
||||
}
|
||||
|
||||
bool BlenderObjectCulling::test(Scene *scene, ::Object &b_ob, Transform &tfm)
|
||||
bool BlenderObjectCulling::test(Scene *scene, blender::Object &b_ob, Transform &tfm)
|
||||
{
|
||||
if (!use_camera_cull_ && !use_distance_cull_) {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -13,10 +13,10 @@ class Scene;
|
|||
|
||||
class BlenderObjectCulling {
|
||||
public:
|
||||
BlenderObjectCulling(Scene *scene, ::Scene &b_scene);
|
||||
BlenderObjectCulling(Scene *scene, blender::Scene &b_scene);
|
||||
|
||||
void init_object(Scene *scene, ::Object &b_ob);
|
||||
bool test(Scene *scene, ::Object &b_ob, Transform &tfm);
|
||||
void init_object(Scene *scene, blender::Object &b_ob);
|
||||
bool test(Scene *scene, blender::Object &b_ob, Transform &tfm);
|
||||
|
||||
private:
|
||||
bool test_camera(Scene *scene, const float3 bb[8]);
|
||||
|
|
|
|||
|
|
@ -10,20 +10,20 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
BlenderOutputDriver::BlenderOutputDriver(::RenderEngine &b_engine) : b_engine_(b_engine) {}
|
||||
BlenderOutputDriver::BlenderOutputDriver(blender::RenderEngine &b_engine) : b_engine_(b_engine) {}
|
||||
|
||||
BlenderOutputDriver::~BlenderOutputDriver() = default;
|
||||
|
||||
bool BlenderOutputDriver::read_render_tile(const Tile &tile)
|
||||
{
|
||||
/* Get render result. */
|
||||
::RenderResult *b_rr = RE_engine_begin_result(&b_engine_,
|
||||
tile.offset.x,
|
||||
tile.offset.y,
|
||||
tile.size.x,
|
||||
tile.size.y,
|
||||
tile.layer.c_str(),
|
||||
tile.view.c_str());
|
||||
blender::RenderResult *b_rr = RE_engine_begin_result(&b_engine_,
|
||||
tile.offset.x,
|
||||
tile.offset.y,
|
||||
tile.size.x,
|
||||
tile.size.y,
|
||||
tile.layer.c_str(),
|
||||
tile.view.c_str());
|
||||
|
||||
/* Can happen if the intersected rectangle gives 0 width or height. */
|
||||
if (b_rr == nullptr) {
|
||||
|
|
@ -35,11 +35,11 @@ bool BlenderOutputDriver::read_render_tile(const Tile &tile)
|
|||
return false;
|
||||
}
|
||||
|
||||
::RenderLayer *b_rlay = static_cast<::RenderLayer *>(b_rr->layers.first);
|
||||
blender::RenderLayer *b_rlay = static_cast<blender::RenderLayer *>(b_rr->layers.first);
|
||||
|
||||
/* Copy each pass.
|
||||
* TODO:copy only the required ones for better performance? */
|
||||
for (::RenderPass &b_pass : b_rlay->passes) {
|
||||
for (blender::RenderPass &b_pass : b_rlay->passes) {
|
||||
if (b_pass.ibuf && b_pass.ibuf->float_buffer.data) {
|
||||
const float *rect = b_pass.ibuf->float_buffer.data;
|
||||
tile.set_pass_pixels(b_pass.name, b_pass.channels, rect);
|
||||
|
|
@ -59,7 +59,7 @@ bool BlenderOutputDriver::update_render_tile(const Tile &tile)
|
|||
{
|
||||
/* Use final write for preview renders, otherwise render result wouldn't be updated
|
||||
* quickly on Blender side. For all other cases we use the display driver. */
|
||||
if (b_engine_.flag & RE_ENGINE_PREVIEW) {
|
||||
if (b_engine_.flag & blender::RE_ENGINE_PREVIEW) {
|
||||
write_render_tile(tile);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -79,13 +79,13 @@ void BlenderOutputDriver::write_render_tile(const Tile &tile)
|
|||
RE_engine_tile_highlight_clear_all(&b_engine_);
|
||||
|
||||
/* Get render result. */
|
||||
::RenderResult *b_rr = RE_engine_begin_result(&b_engine_,
|
||||
tile.offset.x,
|
||||
tile.offset.y,
|
||||
tile.size.x,
|
||||
tile.size.y,
|
||||
tile.layer.c_str(),
|
||||
tile.view.c_str());
|
||||
blender::RenderResult *b_rr = RE_engine_begin_result(&b_engine_,
|
||||
tile.offset.x,
|
||||
tile.offset.y,
|
||||
tile.size.x,
|
||||
tile.size.y,
|
||||
tile.layer.c_str(),
|
||||
tile.view.c_str());
|
||||
|
||||
/* Can happen if the intersected rectangle gives 0 width or height. */
|
||||
if (b_rr == nullptr) {
|
||||
|
|
@ -97,12 +97,12 @@ void BlenderOutputDriver::write_render_tile(const Tile &tile)
|
|||
return;
|
||||
}
|
||||
|
||||
::RenderLayer *b_rlay = static_cast<::RenderLayer *>(b_rr->layers.first);
|
||||
blender::RenderLayer *b_rlay = static_cast<blender::RenderLayer *>(b_rr->layers.first);
|
||||
|
||||
vector<float> pixels(static_cast<size_t>(tile.size.x) * tile.size.y * 4);
|
||||
|
||||
/* Copy each pass. */
|
||||
for (::RenderPass &b_pass : b_rlay->passes) {
|
||||
for (blender::RenderPass &b_pass : b_rlay->passes) {
|
||||
if (!tile.get_pass_pixels(b_pass.name, b_pass.channels, pixels.data())) {
|
||||
memset(pixels.data(), 0, pixels.size() * sizeof(float));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,15 @@
|
|||
|
||||
#include "session/output_driver.h"
|
||||
|
||||
namespace blender {
|
||||
struct RenderEngine;
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
class BlenderOutputDriver : public OutputDriver {
|
||||
public:
|
||||
explicit BlenderOutputDriver(::RenderEngine &b_engine);
|
||||
explicit BlenderOutputDriver(blender::RenderEngine &b_engine);
|
||||
~BlenderOutputDriver() override;
|
||||
|
||||
void write_render_tile(const Tile &tile) override;
|
||||
|
|
@ -20,7 +22,7 @@ class BlenderOutputDriver : public OutputDriver {
|
|||
bool read_render_tile(const Tile &tile) override;
|
||||
|
||||
protected:
|
||||
::RenderEngine &b_engine_;
|
||||
blender::RenderEngine &b_engine_;
|
||||
};
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@ CCL_NAMESPACE_BEGIN
|
|||
|
||||
/* Utilities */
|
||||
|
||||
bool BlenderSync::sync_dupli_particle(::Object &b_parent,
|
||||
::DEGObjectIterData &b_deg_iter_data,
|
||||
::Object &b_ob,
|
||||
bool BlenderSync::sync_dupli_particle(blender::Object &b_parent,
|
||||
blender::DEGObjectIterData &b_deg_iter_data,
|
||||
blender::Object &b_ob,
|
||||
Object *object)
|
||||
{
|
||||
/* Test if this dupli was generated from a particle system. */
|
||||
::ParticleSystem *b_psys = b_deg_iter_data.dupli_object_current->particle_system;
|
||||
blender::ParticleSystem *b_psys = b_deg_iter_data.dupli_object_current->particle_system;
|
||||
if (!b_psys) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ bool BlenderSync::sync_dupli_particle(::Object &b_parent,
|
|||
}
|
||||
|
||||
/* add particle */
|
||||
::ParticleData &b_pa = b_psys->particles[persistent_id[0]];
|
||||
blender::ParticleData &b_pa = b_psys->particles[persistent_id[0]];
|
||||
Particle pa;
|
||||
|
||||
pa.index = persistent_id[0];
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ static void attr_create_motion_from_velocity(PointCloud *pointcloud,
|
|||
}
|
||||
|
||||
static void copy_attributes(PointCloud *pointcloud,
|
||||
const ::PointCloud &b_pointcloud,
|
||||
const blender::PointCloud &b_pointcloud,
|
||||
const bool need_motion,
|
||||
const float motion_scale)
|
||||
{
|
||||
|
|
@ -96,7 +96,7 @@ static void copy_attributes(PointCloud *pointcloud,
|
|||
|
||||
static void export_pointcloud(Scene *scene,
|
||||
PointCloud *pointcloud,
|
||||
const ::PointCloud &b_pointcloud,
|
||||
const blender::PointCloud &b_pointcloud,
|
||||
const bool need_motion,
|
||||
const float motion_scale)
|
||||
{
|
||||
|
|
@ -135,7 +135,7 @@ static void export_pointcloud(Scene *scene,
|
|||
}
|
||||
|
||||
static void export_pointcloud_motion(PointCloud *pointcloud,
|
||||
const ::PointCloud &b_pointcloud,
|
||||
const blender::PointCloud &b_pointcloud,
|
||||
const int motion_step)
|
||||
{
|
||||
/* Find or add attribute. */
|
||||
|
|
@ -194,7 +194,8 @@ void BlenderSync::sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info
|
|||
new_pointcloud.set_used_shaders(used_shaders);
|
||||
|
||||
/* TODO: add option to filter out points in the view layer. */
|
||||
const ::PointCloud *b_pointcloud = blender::id_cast<::PointCloud *>(b_ob_info.object_data);
|
||||
const blender::PointCloud *b_pointcloud = blender::id_cast<blender::PointCloud *>(
|
||||
b_ob_info.object_data);
|
||||
/* Motion blur attribute is relative to seconds, we need it relative to frames. */
|
||||
const bool need_motion = object_need_motion_attribute(b_ob_info, scene);
|
||||
const float motion_scale = (need_motion) ? scene->motion_shutter_time() /
|
||||
|
|
@ -232,7 +233,8 @@ void BlenderSync::sync_pointcloud_motion(PointCloud *pointcloud,
|
|||
/* Export deformed coordinates. */
|
||||
if (ccl::BKE_object_is_deform_modified(b_ob_info, *b_scene, preview)) {
|
||||
/* PointCloud object. */
|
||||
const ::PointCloud *b_pointcloud = blender::id_cast<::PointCloud *>(b_ob_info.object_data);
|
||||
const blender::PointCloud *b_pointcloud = blender::id_cast<blender::PointCloud *>(
|
||||
b_ob_info.object_data);
|
||||
export_pointcloud_motion(pointcloud, *b_pointcloud, motion_step);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ PyObject *pyunicode_from_string(const char *str)
|
|||
/* Synchronize debug flags from a given Blender scene.
|
||||
* Return truth when device list needs invalidation.
|
||||
*/
|
||||
void debug_flags_sync_from_scene(::Scene &b_scene)
|
||||
void debug_flags_sync_from_scene(blender::Scene &b_scene)
|
||||
{
|
||||
DebugFlagsRef flags = DebugFlags();
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
/* Synchronize CPU flags. */
|
||||
flags.cpu.avx2 = get_boolean(cscene, "debug_use_cpu_avx2");
|
||||
flags.cpu.sse42 = get_boolean(cscene, "debug_use_cpu_sse42");
|
||||
|
|
@ -183,19 +183,19 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args)
|
|||
}
|
||||
|
||||
/* RNA */
|
||||
ID *bScreen = (ID *)PyLong_AsVoidPtr(pyscreen);
|
||||
blender::ID *bScreen = (blender::ID *)PyLong_AsVoidPtr(pyscreen);
|
||||
|
||||
::RenderEngine *engine = static_cast<::RenderEngine *>(PyLong_AsVoidPtr(pyengine));
|
||||
::UserDef *preferences = static_cast<::UserDef *>(PyLong_AsVoidPtr(pypreferences));
|
||||
::Main *data = static_cast<::Main *>(PyLong_AsVoidPtr(pydata));
|
||||
::View3D *v3d = static_cast<::View3D *>(pylong_as_voidptr_typesafe(pyv3d));
|
||||
::ARegion *region = static_cast<::ARegion *>(pylong_as_voidptr_typesafe(pyregion));
|
||||
blender::RenderEngine *engine = static_cast<blender::RenderEngine *>(PyLong_AsVoidPtr(pyengine));
|
||||
blender::UserDef *preferences = static_cast<blender::UserDef *>(PyLong_AsVoidPtr(pypreferences));
|
||||
blender::Main *data = static_cast<blender::Main *>(PyLong_AsVoidPtr(pydata));
|
||||
blender::View3D *v3d = static_cast<blender::View3D *>(pylong_as_voidptr_typesafe(pyv3d));
|
||||
blender::ARegion *region = static_cast<blender::ARegion *>(pylong_as_voidptr_typesafe(pyregion));
|
||||
|
||||
/* create session */
|
||||
BlenderSession *session;
|
||||
|
||||
if (region) {
|
||||
::RegionView3D *rv3d = static_cast<::RegionView3D *>(region->regiondata);
|
||||
blender::RegionView3D *rv3d = static_cast<blender::RegionView3D *>(region->regiondata);
|
||||
/* interactive viewport session */
|
||||
const int width = region->winx;
|
||||
const int height = region->winy;
|
||||
|
|
@ -203,7 +203,7 @@ static PyObject *create_func(PyObject * /*self*/, PyObject *args)
|
|||
session = new BlenderSession(*engine,
|
||||
*preferences,
|
||||
*data,
|
||||
blender::id_cast<::bScreen *>(bScreen),
|
||||
blender::id_cast<blender::bScreen *>(bScreen),
|
||||
v3d,
|
||||
rv3d,
|
||||
width,
|
||||
|
|
@ -234,7 +234,8 @@ static PyObject *render_func(PyObject * /*self*/, PyObject *args)
|
|||
}
|
||||
|
||||
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
||||
::Depsgraph *b_depsgraph = static_cast<::Depsgraph *>(PyLong_AsVoidPtr(pydepsgraph));
|
||||
blender::Depsgraph *b_depsgraph = static_cast<blender::Depsgraph *>(
|
||||
PyLong_AsVoidPtr(pydepsgraph));
|
||||
|
||||
/* Allow Blender to execute other Python scripts. */
|
||||
python_thread_state_save(&session->python_thread_state);
|
||||
|
|
@ -279,12 +280,12 @@ static PyObject *draw_func(PyObject * /*self*/, PyObject *args)
|
|||
|
||||
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(py_session);
|
||||
|
||||
ID *b_screen = (ID *)PyLong_AsVoidPtr(py_screen);
|
||||
blender::ID *b_screen = (blender::ID *)PyLong_AsVoidPtr(py_screen);
|
||||
|
||||
::SpaceImage *b_space_image = static_cast<::SpaceImage *>(
|
||||
blender::SpaceImage *b_space_image = static_cast<blender::SpaceImage *>(
|
||||
pylong_as_voidptr_typesafe(py_space_image));
|
||||
|
||||
session->draw(blender::id_cast<::bScreen &>(*b_screen), *b_space_image);
|
||||
session->draw(blender::id_cast<blender::bScreen &>(*b_screen), *b_space_image);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
|
@ -315,8 +316,9 @@ static PyObject *bake_func(PyObject * /*self*/, PyObject *args)
|
|||
|
||||
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
||||
|
||||
::Depsgraph *b_depsgraph = static_cast<::Depsgraph *>(PyLong_AsVoidPtr(pydepsgraph));
|
||||
::Object *b_object = static_cast<::Object *>(PyLong_AsVoidPtr(pyobject));
|
||||
blender::Depsgraph *b_depsgraph = static_cast<blender::Depsgraph *>(
|
||||
PyLong_AsVoidPtr(pydepsgraph));
|
||||
blender::Object *b_object = static_cast<blender::Object *>(PyLong_AsVoidPtr(pyobject));
|
||||
|
||||
python_thread_state_save(&session->python_thread_state);
|
||||
|
||||
|
|
@ -343,7 +345,7 @@ static PyObject *view_draw_func(PyObject * /*self*/, PyObject *args)
|
|||
if (PyLong_AsVoidPtr(pyrv3d)) {
|
||||
/* 3d view drawing */
|
||||
int viewport[4];
|
||||
GPU_viewport_size_get_i(viewport);
|
||||
blender::GPU_viewport_size_get_i(viewport);
|
||||
|
||||
session->view_draw(viewport[2], viewport[3]);
|
||||
}
|
||||
|
|
@ -363,8 +365,9 @@ static PyObject *reset_func(PyObject * /*self*/, PyObject *args)
|
|||
|
||||
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
||||
|
||||
::Main *b_data = static_cast<::Main *>(PyLong_AsVoidPtr(pydata));
|
||||
::Depsgraph *b_depsgraph = static_cast<::Depsgraph *>(PyLong_AsVoidPtr(pydepsgraph));
|
||||
blender::Main *b_data = static_cast<blender::Main *>(PyLong_AsVoidPtr(pydata));
|
||||
blender::Depsgraph *b_depsgraph = static_cast<blender::Depsgraph *>(
|
||||
PyLong_AsVoidPtr(pydepsgraph));
|
||||
|
||||
python_thread_state_save(&session->python_thread_state);
|
||||
|
||||
|
|
@ -386,7 +389,8 @@ static PyObject *sync_func(PyObject * /*self*/, PyObject *args)
|
|||
|
||||
BlenderSession *session = (BlenderSession *)PyLong_AsVoidPtr(pysession);
|
||||
|
||||
::Depsgraph *b_depsgraph = static_cast<::Depsgraph *>(PyLong_AsVoidPtr(pydepsgraph));
|
||||
blender::Depsgraph *b_depsgraph = static_cast<blender::Depsgraph *>(
|
||||
PyLong_AsVoidPtr(pydepsgraph));
|
||||
|
||||
python_thread_state_save(&session->python_thread_state);
|
||||
|
||||
|
|
@ -515,15 +519,17 @@ static PyObject *denoise_func(PyObject * /*self*/, PyObject *args, PyObject *key
|
|||
}
|
||||
|
||||
/* Get device specification from preferences and scene. */
|
||||
::UserDef *b_preferences = static_cast<::UserDef *>(PyLong_AsVoidPtr(pypreferences));
|
||||
::Scene *b_scene = static_cast<::Scene *>(PyLong_AsVoidPtr(pyscene));
|
||||
blender::UserDef *b_preferences = static_cast<blender::UserDef *>(
|
||||
PyLong_AsVoidPtr(pypreferences));
|
||||
blender::Scene *b_scene = static_cast<blender::Scene *>(PyLong_AsVoidPtr(pyscene));
|
||||
|
||||
DeviceInfo preferences_device;
|
||||
const DeviceInfo pathtrace_device = blender_device_info(
|
||||
*b_preferences, *b_scene, true, true, preferences_device);
|
||||
|
||||
/* Get denoising parameters from view layer. */
|
||||
::ViewLayer *b_view_layer = static_cast<::ViewLayer *>(PyLong_AsVoidPtr(pyviewlayer));
|
||||
blender::ViewLayer *b_view_layer = static_cast<blender::ViewLayer *>(
|
||||
PyLong_AsVoidPtr(pyviewlayer));
|
||||
|
||||
DenoiseParams params = BlenderSync::get_denoise_params(
|
||||
*b_scene, b_view_layer, true, preferences_device);
|
||||
|
|
@ -617,7 +623,7 @@ static PyObject *debug_flags_update_func(PyObject * /*self*/, PyObject *args)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
::Scene *b_scene = static_cast<::Scene *>(PyLong_AsVoidPtr(pyscene));
|
||||
blender::Scene *b_scene = static_cast<blender::Scene *>(PyLong_AsVoidPtr(pyscene));
|
||||
|
||||
debug_flags_sync_from_scene(*b_scene);
|
||||
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ DeviceTypeMask BlenderSession::device_override = DEVICE_MASK_ALL;
|
|||
bool BlenderSession::headless = false;
|
||||
bool BlenderSession::print_render_stats = false;
|
||||
|
||||
BlenderSession::BlenderSession(::RenderEngine &b_engine,
|
||||
::UserDef &b_userpref,
|
||||
::Main &b_data,
|
||||
BlenderSession::BlenderSession(blender::RenderEngine &b_engine,
|
||||
blender::UserDef &b_userpref,
|
||||
blender::Main &b_data,
|
||||
bool preview_osl)
|
||||
: session(nullptr),
|
||||
scene(nullptr),
|
||||
|
|
@ -66,7 +66,7 @@ BlenderSession::BlenderSession(::RenderEngine &b_engine,
|
|||
preview_osl(preview_osl),
|
||||
python_thread_state(nullptr),
|
||||
use_developer_ui(b_userpref.experimental.use_cycles_debug &&
|
||||
(b_userpref.flag & USER_DEVELOPER_UI) != 0)
|
||||
(b_userpref.flag & blender::USER_DEVELOPER_UI) != 0)
|
||||
{
|
||||
/* offline render */
|
||||
background = true;
|
||||
|
|
@ -75,12 +75,12 @@ BlenderSession::BlenderSession(::RenderEngine &b_engine,
|
|||
last_status_time = 0.0;
|
||||
}
|
||||
|
||||
BlenderSession::BlenderSession(::RenderEngine &b_engine,
|
||||
::UserDef &b_userpref,
|
||||
::Main &b_data,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
BlenderSession::BlenderSession(blender::RenderEngine &b_engine,
|
||||
blender::UserDef &b_userpref,
|
||||
blender::Main &b_data,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height)
|
||||
: session(nullptr),
|
||||
|
|
@ -100,7 +100,7 @@ BlenderSession::BlenderSession(::RenderEngine &b_engine,
|
|||
preview_osl(false),
|
||||
python_thread_state(nullptr),
|
||||
use_developer_ui(b_userpref.experimental.use_cycles_debug &&
|
||||
(b_userpref.flag & USER_DEVELOPER_UI) != 0)
|
||||
(b_userpref.flag & blender::USER_DEVELOPER_UI) != 0)
|
||||
{
|
||||
/* 3d view render */
|
||||
background = false;
|
||||
|
|
@ -158,12 +158,12 @@ void BlenderSession::create_session()
|
|||
* The offline rendering will make a decision when tile is being written. The penalty of asking
|
||||
* the engine to keep track of tiles state is minimal, so there is nothing to worry about here
|
||||
* about possible single-tiled final render. */
|
||||
if ((b_engine.flag & RE_ENGINE_PREVIEW) == 0 && !b_v3d) {
|
||||
b_engine.flag |= RE_ENGINE_HIGHLIGHT_TILES;
|
||||
if ((b_engine.flag & blender::RE_ENGINE_PREVIEW) == 0 && !b_v3d) {
|
||||
b_engine.flag |= blender::RE_ENGINE_HIGHLIGHT_TILES;
|
||||
}
|
||||
}
|
||||
|
||||
void BlenderSession::reset_session(::Main &b_data, ::Depsgraph &b_depsgraph)
|
||||
void BlenderSession::reset_session(blender::Main &b_data, blender::Depsgraph &b_depsgraph)
|
||||
{
|
||||
/* Update data, scene and depsgraph pointers. These can change after undo. */
|
||||
this->b_data = &b_data;
|
||||
|
|
@ -174,8 +174,8 @@ void BlenderSession::reset_session(::Main &b_data, ::Depsgraph &b_depsgraph)
|
|||
}
|
||||
|
||||
if (preview_osl) {
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
RNA_boolean_set(&cscene, "shading_system", preview_osl);
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ void BlenderSession::reset_session(::Main &b_data, ::Depsgraph &b_depsgraph)
|
|||
*b_scene, background, use_developer_ui);
|
||||
|
||||
if (scene->params.modified(scene_params) || session->params.modified(session_params) ||
|
||||
(this->b_render->mode & R_PERSISTENT_DATA) == 0)
|
||||
(this->b_render->mode & blender::R_PERSISTENT_DATA) == 0)
|
||||
{
|
||||
/* if scene or session parameters changed, it's easier to simply re-create
|
||||
* them rather than trying to distinguish which settings need to be updated
|
||||
|
|
@ -270,7 +270,7 @@ void BlenderSession::full_buffer_written(string_view filename)
|
|||
full_buffer_files_.emplace_back(filename);
|
||||
}
|
||||
|
||||
static void add_cryptomatte_layer(::RenderResult &b_rr, string name, string manifest)
|
||||
static void add_cryptomatte_layer(blender::RenderResult &b_rr, string name, string manifest)
|
||||
{
|
||||
const string identifier = string_printf("%08x",
|
||||
util_murmur_hash3(name.c_str(), name.length(), 0));
|
||||
|
|
@ -284,7 +284,7 @@ static void add_cryptomatte_layer(::RenderResult &b_rr, string name, string mani
|
|||
|
||||
void BlenderSession::stamp_view_layer_metadata(Scene *scene, const string &view_layer_name)
|
||||
{
|
||||
::RenderResult *b_rr = RE_engine_get_result(&b_engine);
|
||||
blender::RenderResult *b_rr = RE_engine_get_result(&b_engine);
|
||||
const string prefix = "cycles." + view_layer_name + ".";
|
||||
|
||||
/* Configured number of samples for the view layer. */
|
||||
|
|
@ -333,7 +333,7 @@ void BlenderSession::stamp_view_layer_metadata(Scene *scene, const string &view_
|
|||
time_human_readable_from_seconds(total_time - render_time).c_str());
|
||||
}
|
||||
|
||||
void BlenderSession::render(::Depsgraph &b_depsgraph_)
|
||||
void BlenderSession::render(blender::Depsgraph &b_depsgraph_)
|
||||
{
|
||||
b_depsgraph = &b_depsgraph_;
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ void BlenderSession::render(::Depsgraph &b_depsgraph_)
|
|||
|
||||
session->full_buffer_written_cb = [&](string_view filename) { full_buffer_written(filename); };
|
||||
|
||||
::ViewLayer &b_view_layer = *DEG_get_evaluated_view_layer(b_depsgraph);
|
||||
blender::ViewLayer &b_view_layer = *DEG_get_evaluated_view_layer(b_depsgraph);
|
||||
|
||||
/* get buffer parameters */
|
||||
const SessionParams session_params = BlenderSync::get_session_params(
|
||||
|
|
@ -357,8 +357,9 @@ void BlenderSession::render(::Depsgraph &b_depsgraph_)
|
|||
b_v3d, b_rv3d, scene->camera, width, height);
|
||||
|
||||
/* temporary render result to find needed passes and views */
|
||||
::RenderResult *b_rr = RE_engine_begin_result(&b_engine, 0, 0, 1, 1, b_view_layer.name, nullptr);
|
||||
::RenderLayer *b_rlay = static_cast<::RenderLayer *>(b_rr->layers.first);
|
||||
blender::RenderResult *b_rr = RE_engine_begin_result(
|
||||
&b_engine, 0, 0, 1, 1, b_view_layer.name, nullptr);
|
||||
blender::RenderLayer *b_rlay = static_cast<blender::RenderLayer *>(b_rr->layers.first);
|
||||
|
||||
{
|
||||
const thread_scoped_lock lock(draw_state_.mutex);
|
||||
|
|
@ -440,14 +441,14 @@ void BlenderSession::render(::Depsgraph &b_depsgraph_)
|
|||
session->reset(effective_session_params, buffer_params);
|
||||
|
||||
/* render */
|
||||
if ((b_engine.flag & RE_ENGINE_PREVIEW) == 0 && background && print_render_stats) {
|
||||
if ((b_engine.flag & blender::RE_ENGINE_PREVIEW) == 0 && background && print_render_stats) {
|
||||
scene->enable_update_stats();
|
||||
}
|
||||
|
||||
session->start();
|
||||
session->wait();
|
||||
|
||||
if ((b_engine.flag & RE_ENGINE_PREVIEW) == 0 && background && print_render_stats) {
|
||||
if ((b_engine.flag & blender::RE_ENGINE_PREVIEW) == 0 && background && print_render_stats) {
|
||||
RenderStats stats;
|
||||
session->collect_statistics(&stats);
|
||||
printf("Render statistics:\n%s\n", stats.full_report().c_str());
|
||||
|
|
@ -483,7 +484,7 @@ void BlenderSession::render_frame_finish()
|
|||
b_rlay_name = "";
|
||||
b_rview_name = "";
|
||||
|
||||
if ((b_render->mode & R_PERSISTENT_DATA) == 0) {
|
||||
if ((b_render->mode & blender::R_PERSISTENT_DATA) == 0) {
|
||||
/* Free the sync object so that it can properly dereference nodes from the scene graph before
|
||||
* the graph is freed. */
|
||||
sync.reset();
|
||||
|
|
@ -526,9 +527,9 @@ static bool bake_setup_pass(Scene *scene, const string &bake_type, const int bak
|
|||
Integrator *integrator = scene->integrator;
|
||||
Film *film = scene->film;
|
||||
|
||||
const bool filter_direct = (bake_filter & R_BAKE_PASS_FILTER_DIRECT) != 0;
|
||||
const bool filter_indirect = (bake_filter & R_BAKE_PASS_FILTER_INDIRECT) != 0;
|
||||
const bool filter_color = (bake_filter & R_BAKE_PASS_FILTER_COLOR) != 0;
|
||||
const bool filter_direct = (bake_filter & blender::R_BAKE_PASS_FILTER_DIRECT) != 0;
|
||||
const bool filter_indirect = (bake_filter & blender::R_BAKE_PASS_FILTER_INDIRECT) != 0;
|
||||
const bool filter_color = (bake_filter & blender::R_BAKE_PASS_FILTER_COLOR) != 0;
|
||||
|
||||
PassType type = PASS_NONE;
|
||||
bool use_direct_light = false;
|
||||
|
|
@ -583,10 +584,10 @@ static bool bake_setup_pass(Scene *scene, const string &bake_type, const int bak
|
|||
use_indirect_light = filter_indirect;
|
||||
include_albedo = filter_color;
|
||||
|
||||
integrator->set_use_diffuse((bake_filter & R_BAKE_PASS_FILTER_DIFFUSE) != 0);
|
||||
integrator->set_use_glossy((bake_filter & R_BAKE_PASS_FILTER_GLOSSY) != 0);
|
||||
integrator->set_use_transmission((bake_filter & R_BAKE_PASS_FILTER_TRANSM) != 0);
|
||||
integrator->set_use_emission((bake_filter & R_BAKE_PASS_FILTER_EMIT) != 0);
|
||||
integrator->set_use_diffuse((bake_filter & blender::R_BAKE_PASS_FILTER_DIFFUSE) != 0);
|
||||
integrator->set_use_glossy((bake_filter & blender::R_BAKE_PASS_FILTER_GLOSSY) != 0);
|
||||
integrator->set_use_transmission((bake_filter & blender::R_BAKE_PASS_FILTER_TRANSM) != 0);
|
||||
integrator->set_use_emission((bake_filter & blender::R_BAKE_PASS_FILTER_EMIT) != 0);
|
||||
}
|
||||
/* Light component passes. */
|
||||
else if ((bake_type == "DIFFUSE") || (bake_type == "GLOSSY") || (bake_type == "TRANSMISSION")) {
|
||||
|
|
@ -666,8 +667,8 @@ static bool bake_setup_pass(Scene *scene, const string &bake_type, const int bak
|
|||
return true;
|
||||
}
|
||||
|
||||
void BlenderSession::bake(::Depsgraph &b_depsgraph_,
|
||||
::Object &b_object,
|
||||
void BlenderSession::bake(blender::Depsgraph &b_depsgraph_,
|
||||
blender::Object &b_object,
|
||||
const string &bake_type,
|
||||
const int bake_filter,
|
||||
const int bake_width,
|
||||
|
|
@ -768,7 +769,7 @@ void BlenderSession::bake(::Depsgraph &b_depsgraph_,
|
|||
integrator->set_use_denoise(was_denoiser_enabled);
|
||||
}
|
||||
|
||||
void BlenderSession::synchronize(::Depsgraph &b_depsgraph_)
|
||||
void BlenderSession::synchronize(blender::Depsgraph &b_depsgraph_)
|
||||
{
|
||||
/* only used for viewport render */
|
||||
if (!b_v3d) {
|
||||
|
|
@ -853,7 +854,7 @@ void BlenderSession::synchronize(::Depsgraph &b_depsgraph_)
|
|||
session->start();
|
||||
}
|
||||
|
||||
void BlenderSession::draw(bScreen &b_screen, ::SpaceImage &space_image)
|
||||
void BlenderSession::draw(blender::bScreen &b_screen, blender::SpaceImage &space_image)
|
||||
{
|
||||
if (!session || !session->scene) {
|
||||
/* Offline render drawing does not force the render engine update, which means it's possible
|
||||
|
|
@ -865,7 +866,7 @@ void BlenderSession::draw(bScreen &b_screen, ::SpaceImage &space_image)
|
|||
|
||||
const int pass_index = space_image.iuser.pass;
|
||||
if (pass_index != draw_state_.last_pass_index) {
|
||||
::RenderPass *b_display_pass = RE_engine_pass_by_index_get(
|
||||
blender::RenderPass *b_display_pass = RE_engine_pass_by_index_get(
|
||||
&b_engine, b_rlay_name.c_str(), pass_index);
|
||||
if (!b_display_pass) {
|
||||
return;
|
||||
|
|
@ -886,8 +887,8 @@ void BlenderSession::draw(bScreen &b_screen, ::SpaceImage &space_image)
|
|||
}
|
||||
|
||||
if (display_driver_) {
|
||||
PointerRNA space_image_rna_ptr = RNA_pointer_create_id_subdata(
|
||||
b_screen.id, &RNA_SpaceImageEditor, &space_image);
|
||||
blender::PointerRNA space_image_rna_ptr = RNA_pointer_create_id_subdata(
|
||||
b_screen.id, &blender::RNA_SpaceImageEditor, &space_image);
|
||||
float zoom[2];
|
||||
RNA_float_get_array(&space_image_rna_ptr, "zoom", zoom);
|
||||
display_driver_->set_zoom(zoom[0], zoom[1]);
|
||||
|
|
@ -1057,7 +1058,7 @@ bool BlenderSession::check_and_report_session_error()
|
|||
void BlenderSession::tag_update()
|
||||
{
|
||||
/* tell blender that we want to get another update callback */
|
||||
b_engine.flag |= RE_ENGINE_DO_UPDATE;
|
||||
b_engine.flag |= blender::RE_ENGINE_DO_UPDATE;
|
||||
}
|
||||
|
||||
void BlenderSession::tag_redraw()
|
||||
|
|
@ -1069,13 +1070,13 @@ void BlenderSession::tag_redraw()
|
|||
|
||||
/* offline render, redraw if timeout passed */
|
||||
if (time_dt() - last_redraw_time > 1.0) {
|
||||
b_engine.flag |= RE_ENGINE_DO_DRAW;
|
||||
b_engine.flag |= blender::RE_ENGINE_DO_DRAW;
|
||||
last_redraw_time = time_dt();
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* tell blender that we want to redraw */
|
||||
b_engine.flag |= RE_ENGINE_DO_DRAW;
|
||||
b_engine.flag |= blender::RE_ENGINE_DO_DRAW;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1113,7 +1114,7 @@ void BlenderSession::ensure_display_driver_if_needed()
|
|||
return;
|
||||
}
|
||||
|
||||
if ((b_engine.flag & RE_ENGINE_PREVIEW) != 0) {
|
||||
if ((b_engine.flag & blender::RE_ENGINE_PREVIEW) != 0) {
|
||||
/* TODO(sergey): Investigate whether DisplayDriver can be used for the preview as well. */
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "util/unique_ptr.h"
|
||||
#include "util/vector.h"
|
||||
|
||||
namespace blender {
|
||||
struct bScreen;
|
||||
struct Depsgraph;
|
||||
struct Main;
|
||||
|
|
@ -23,6 +24,7 @@ struct Scene;
|
|||
struct SpaceImage;
|
||||
struct UserDef;
|
||||
struct View3D;
|
||||
} // namespace blender
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
|
@ -34,17 +36,17 @@ class Session;
|
|||
|
||||
class BlenderSession {
|
||||
public:
|
||||
BlenderSession(::RenderEngine &b_engine,
|
||||
::UserDef &b_userpref,
|
||||
::Main &b_data,
|
||||
BlenderSession(blender::RenderEngine &b_engine,
|
||||
blender::UserDef &b_userpref,
|
||||
blender::Main &b_data,
|
||||
bool preview_osl);
|
||||
|
||||
BlenderSession(::RenderEngine &b_engine,
|
||||
::UserDef &b_userpref,
|
||||
::Main &b_data,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
BlenderSession(blender::RenderEngine &b_engine,
|
||||
blender::UserDef &b_userpref,
|
||||
blender::Main &b_data,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
int height);
|
||||
|
||||
|
|
@ -54,15 +56,15 @@ class BlenderSession {
|
|||
void create_session();
|
||||
void free_session();
|
||||
|
||||
void reset_session(::Main &b_data, ::Depsgraph &b_depsgraph);
|
||||
void reset_session(blender::Main &b_data, blender::Depsgraph &b_depsgraph);
|
||||
|
||||
/* offline render */
|
||||
void render(::Depsgraph &b_depsgraph);
|
||||
void render(blender::Depsgraph &b_depsgraph);
|
||||
|
||||
void render_frame_finish();
|
||||
|
||||
void bake(::Depsgraph &b_depsgraph_,
|
||||
::Object &b_object,
|
||||
void bake(blender::Depsgraph &b_depsgraph_,
|
||||
blender::Object &b_object,
|
||||
const string &bake_type,
|
||||
const int bake_filter,
|
||||
const int bake_width,
|
||||
|
|
@ -70,10 +72,10 @@ class BlenderSession {
|
|||
|
||||
void full_buffer_written(string_view filename);
|
||||
/* interactive updates */
|
||||
void synchronize(::Depsgraph &b_depsgraph);
|
||||
void synchronize(blender::Depsgraph &b_depsgraph);
|
||||
|
||||
/* drawing */
|
||||
void draw(bScreen &b_screen, ::SpaceImage &space_image);
|
||||
void draw(blender::bScreen &b_screen, blender::SpaceImage &space_image);
|
||||
void view_draw(const int w, const int h);
|
||||
void tag_redraw();
|
||||
void tag_update();
|
||||
|
|
@ -89,17 +91,17 @@ class BlenderSession {
|
|||
unique_ptr<BlenderSync> sync;
|
||||
double last_redraw_time;
|
||||
|
||||
::RenderEngine &b_engine;
|
||||
::UserDef &b_userpref;
|
||||
::Main *b_data;
|
||||
::RenderData *b_render;
|
||||
::Depsgraph *b_depsgraph;
|
||||
blender::RenderEngine &b_engine;
|
||||
blender::UserDef &b_userpref;
|
||||
blender::Main *b_data;
|
||||
blender::RenderData *b_render;
|
||||
blender::Depsgraph *b_depsgraph;
|
||||
/* NOTE: Blender's scene might become invalid after call
|
||||
* #free_blender_memory_if_possible(). */
|
||||
::Scene *b_scene;
|
||||
::bScreen *b_screen;
|
||||
::View3D *b_v3d;
|
||||
::RegionView3D *b_rv3d;
|
||||
blender::Scene *b_scene;
|
||||
blender::bScreen *b_screen;
|
||||
blender::View3D *b_v3d;
|
||||
blender::RegionView3D *b_rv3d;
|
||||
string b_rlay_name;
|
||||
string b_rview_name;
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -44,9 +44,9 @@ static const char *cryptomatte_prefix = "Crypto";
|
|||
|
||||
/* Constructor */
|
||||
|
||||
BlenderSync::BlenderSync(::RenderEngine &b_engine,
|
||||
::Main &b_data,
|
||||
::Scene &b_scene,
|
||||
BlenderSync::BlenderSync(blender::RenderEngine &b_engine,
|
||||
blender::Main &b_data,
|
||||
blender::Scene &b_scene,
|
||||
Scene *scene,
|
||||
bool preview,
|
||||
bool use_developer_ui,
|
||||
|
|
@ -70,8 +70,8 @@ BlenderSync::BlenderSync(::RenderEngine &b_engine,
|
|||
progress(progress)
|
||||
|
||||
{
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") :
|
||||
RNA_float_get(&cscene, "dicing_rate");
|
||||
max_subdivisions = RNA_int_get(&cscene, "max_subdivisions");
|
||||
|
|
@ -79,7 +79,7 @@ BlenderSync::BlenderSync(::RenderEngine &b_engine,
|
|||
|
||||
BlenderSync::~BlenderSync() = default;
|
||||
|
||||
void BlenderSync::reset(::Main &b_data, ::Scene &b_scene)
|
||||
void BlenderSync::reset(blender::Main &b_data, blender::Scene &b_scene)
|
||||
{
|
||||
/* Update data and scene pointers in case they change in session reset,
|
||||
* for example after undo.
|
||||
|
|
@ -94,65 +94,67 @@ void BlenderSync::tag_update()
|
|||
has_updates_ = true;
|
||||
}
|
||||
|
||||
void BlenderSync::set_bake_target(::Object &b_object)
|
||||
void BlenderSync::set_bake_target(blender::Object &b_object)
|
||||
{
|
||||
b_bake_target = &b_object;
|
||||
}
|
||||
|
||||
/* Sync */
|
||||
|
||||
void BlenderSync::sync_recalc(::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d)
|
||||
void BlenderSync::sync_recalc(blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d)
|
||||
{
|
||||
/* Sync recalc flags from blender to cycles. Actual update is done separate,
|
||||
* so we can do it later on if doing it immediate is not suitable. */
|
||||
::Object *b_dicing_camera_object = get_dicing_camera_object(b_v3d, b_rv3d);
|
||||
blender::Object *b_dicing_camera_object = get_dicing_camera_object(b_v3d, b_rv3d);
|
||||
bool dicing_camera_updated = false;
|
||||
|
||||
/* Iterate over all IDs in this depsgraph. */
|
||||
DEGIDIterData deg_iter_data{};
|
||||
/* Iterate over all blender::IDs in this depsgraph. */
|
||||
blender::DEGIDIterData deg_iter_data{};
|
||||
deg_iter_data.graph = &b_depsgraph;
|
||||
deg_iter_data.only_updated = true;
|
||||
ITER_BEGIN (DEG_iterator_ids_begin,
|
||||
DEG_iterator_ids_next,
|
||||
DEG_iterator_ids_end,
|
||||
ITER_BEGIN (blender::DEG_iterator_ids_begin,
|
||||
blender::DEG_iterator_ids_next,
|
||||
blender::DEG_iterator_ids_end,
|
||||
°_iter_data,
|
||||
ID *,
|
||||
blender::ID *,
|
||||
b_id)
|
||||
{
|
||||
/* TODO(sergey): Can do more selective filter here. For example, ignore changes made to
|
||||
* screen data-block. Note that sync_data() needs to be called after object deletion, and
|
||||
* currently this is ensured by the scene ID tagged for update, which sets the `has_updates_`
|
||||
* flag. */
|
||||
* currently this is ensured by the scene blender::ID tagged for update, which sets the
|
||||
* `has_updates_` flag. */
|
||||
has_updates_ = true;
|
||||
|
||||
const bool updated_shading = ((b_id->recalc & (ID_RECALC_SHADING | ID_RECALC_ANIMATION)) != 0);
|
||||
const bool updated_shading = ((b_id->recalc & (blender::ID_RECALC_SHADING |
|
||||
blender::ID_RECALC_ANIMATION)) != 0);
|
||||
|
||||
/* Material */
|
||||
if (GS(b_id->name) == ID_MA) {
|
||||
if (GS(b_id->name) == blender::ID_MA) {
|
||||
shader_map.set_recalc(b_id);
|
||||
}
|
||||
/* Light */
|
||||
else if (GS(b_id->name) == ID_LA) {
|
||||
else if (GS(b_id->name) == blender::ID_LA) {
|
||||
shader_map.set_recalc(b_id);
|
||||
geometry_map.set_recalc(b_id);
|
||||
}
|
||||
/* Object */
|
||||
else if (GS(b_id->name) == ID_OB) {
|
||||
::Object *b_ob = blender::id_cast<::Object *>(b_id);
|
||||
else if (GS(b_id->name) == blender::ID_OB) {
|
||||
blender::Object *b_ob = blender::id_cast<blender::Object *>(b_id);
|
||||
const bool can_have_geometry = object_can_have_geometry(*b_ob);
|
||||
const bool is_light = !can_have_geometry && object_is_light(*b_ob);
|
||||
|
||||
if (((b_ob->transflag & OB_DUPLI) != 0) && updated_shading) {
|
||||
if (((b_ob->transflag & blender::OB_DUPLI) != 0) && updated_shading) {
|
||||
/* Needed for object color updates on instancer, among other things. */
|
||||
object_map.set_recalc(b_ob);
|
||||
}
|
||||
|
||||
if (can_have_geometry || is_light) {
|
||||
const bool updated_geometry = (b_id->recalc & (ID_RECALC_GEOMETRY | ID_RECALC_ALL)) != 0;
|
||||
const bool updated_transform = (b_id->recalc & ID_RECALC_TRANSFORM) != 0;
|
||||
const bool updated_geometry = (b_id->recalc & (blender::ID_RECALC_GEOMETRY |
|
||||
blender::ID_RECALC_ALL)) != 0;
|
||||
const bool updated_transform = (b_id->recalc & blender::ID_RECALC_TRANSFORM) != 0;
|
||||
|
||||
/* Geometry (mesh, hair, volume). */
|
||||
if (can_have_geometry) {
|
||||
|
|
@ -167,16 +169,16 @@ void BlenderSync::sync_recalc(::Depsgraph &b_depsgraph,
|
|||
/* Need to recompute geometry if the geometry changed, or the transform changed
|
||||
* and using adaptive subdivision. */
|
||||
if (updated_geometry || (updated_transform && use_adaptive_subdiv)) {
|
||||
::ID *key = BKE_object_is_modified(*b_ob) ?
|
||||
&b_ob->id :
|
||||
object_get_data(*b_ob, use_adaptive_subdiv);
|
||||
blender::ID *key = BKE_object_is_modified(*b_ob) ?
|
||||
&b_ob->id :
|
||||
object_get_data(*b_ob, use_adaptive_subdiv);
|
||||
geometry_map.set_recalc(key);
|
||||
|
||||
/* Sync all contained geometry instances as well when the object changed.. */
|
||||
const map<void *, set<::ID *>>::const_iterator instance_geometries =
|
||||
const map<void *, set<blender::ID *>>::const_iterator instance_geometries =
|
||||
instance_geometries_by_object.find(b_ob);
|
||||
if (instance_geometries != instance_geometries_by_object.end()) {
|
||||
for (::ID *geometry : instance_geometries->second) {
|
||||
for (blender::ID *geometry : instance_geometries->second) {
|
||||
geometry_map.set_recalc(geometry);
|
||||
}
|
||||
}
|
||||
|
|
@ -209,27 +211,27 @@ void BlenderSync::sync_recalc(::Depsgraph &b_depsgraph,
|
|||
}
|
||||
}
|
||||
/* Mesh */
|
||||
else if (GS(b_id->name) == ID_ME) {
|
||||
else if (GS(b_id->name) == blender::ID_ME) {
|
||||
geometry_map.set_recalc(b_id);
|
||||
}
|
||||
/* World */
|
||||
else if (GS(b_id->name) == ID_WO) {
|
||||
const ::World *b_world = blender::id_cast<::World *>(b_id);
|
||||
else if (GS(b_id->name) == blender::ID_WO) {
|
||||
const blender::World *b_world = blender::id_cast<blender::World *>(b_id);
|
||||
if (world_map == b_world) {
|
||||
world_recalc = true;
|
||||
}
|
||||
shader_map.set_recalc(b_id);
|
||||
}
|
||||
/* World */
|
||||
else if (GS(b_id->name) == ID_SCE) {
|
||||
else if (GS(b_id->name) == blender::ID_SCE) {
|
||||
shader_map.set_recalc(b_id);
|
||||
}
|
||||
/* Volume */
|
||||
else if (GS(b_id->name) == ID_VO) {
|
||||
else if (GS(b_id->name) == blender::ID_VO) {
|
||||
geometry_map.set_recalc(b_id);
|
||||
}
|
||||
/* Camera */
|
||||
else if (GS(b_id->name) == ID_CA) {
|
||||
else if (GS(b_id->name) == blender::ID_CA) {
|
||||
if (b_dicing_camera_object && b_dicing_camera_object->data == b_id) {
|
||||
dicing_camera_updated = true;
|
||||
}
|
||||
|
|
@ -238,8 +240,8 @@ void BlenderSync::sync_recalc(::Depsgraph &b_depsgraph,
|
|||
|
||||
if (use_adaptive_subdivision) {
|
||||
/* Mark all meshes as needing to be exported again if dicing changed. */
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
bool dicing_prop_changed = false;
|
||||
|
||||
const float updated_dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") :
|
||||
|
|
@ -287,11 +289,11 @@ void BlenderSync::sync_recalc(::Depsgraph &b_depsgraph,
|
|||
}
|
||||
}
|
||||
|
||||
void BlenderSync::sync_data(::RenderData &b_render,
|
||||
::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
void BlenderSync::sync_data(blender::RenderData &b_render,
|
||||
blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height,
|
||||
void **python_thread_state,
|
||||
|
|
@ -308,7 +310,7 @@ void BlenderSync::sync_data(::RenderData &b_render,
|
|||
|
||||
const scoped_timer timer;
|
||||
|
||||
::ViewLayer &b_view_layer = *DEG_get_evaluated_view_layer(&b_depsgraph);
|
||||
blender::ViewLayer &b_view_layer = *DEG_get_evaluated_view_layer(&b_depsgraph);
|
||||
|
||||
/* TODO(sergey): This feels weak to pass view layer to the integrator, and even weaker to have an
|
||||
* implicit check on whether it is a background render or not. What is the nicer thing here? */
|
||||
|
|
@ -322,7 +324,7 @@ void BlenderSync::sync_data(::RenderData &b_render,
|
|||
|
||||
geometry_synced.clear(); /* use for objects and motion sync */
|
||||
|
||||
if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE ||
|
||||
if (scene->need_motion() == Scene::MOTION_NONE || scene->need_motion() == Scene::MOTION_PASS ||
|
||||
scene->camera->get_motion_position() == MOTION_POSITION_CENTER)
|
||||
{
|
||||
sync_objects(b_depsgraph, b_screen, b_v3d);
|
||||
|
|
@ -342,12 +344,12 @@ void BlenderSync::sync_data(::RenderData &b_render,
|
|||
|
||||
/* Integrator */
|
||||
|
||||
void BlenderSync::sync_integrator(::ViewLayer &b_view_layer,
|
||||
void BlenderSync::sync_integrator(blender::ViewLayer &b_view_layer,
|
||||
bool background,
|
||||
const DeviceInfo &denoise_device_info)
|
||||
{
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
|
||||
/* No adaptive subdivision for baking, mesh needs to match Blender exactly. */
|
||||
use_adaptive_subdivision = !b_bake_target;
|
||||
|
|
@ -429,7 +431,7 @@ void BlenderSync::sync_integrator(::ViewLayer &b_view_layer,
|
|||
}
|
||||
|
||||
const bool is_vertex_baking = b_bake_target &&
|
||||
b_scene->r.bake.target != R_BAKE_TARGET_IMAGE_TEXTURES;
|
||||
b_scene->r.bake.target != blender::R_BAKE_TARGET_IMAGE_TEXTURES;
|
||||
scene->bake_manager->set_use_seed(is_vertex_baking);
|
||||
if (is_vertex_baking) {
|
||||
/* When baking vertex colors, the "pixels" in the output are unrelated to their neighbors,
|
||||
|
|
@ -561,13 +563,15 @@ void BlenderSync::sync_integrator(::ViewLayer &b_view_layer,
|
|||
|
||||
/* Film */
|
||||
|
||||
void BlenderSync::sync_film(::ViewLayer &b_view_layer, ::bScreen *b_screen, ::View3D *b_v3d)
|
||||
void BlenderSync::sync_film(blender::ViewLayer &b_view_layer,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d)
|
||||
{
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
PointerRNA view_layer_rna_ptr = RNA_pointer_create_id_subdata(
|
||||
b_scene->id, &RNA_ViewLayer, &b_view_layer);
|
||||
PointerRNA crl = RNA_pointer_get(&view_layer_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA view_layer_rna_ptr = RNA_pointer_create_id_subdata(
|
||||
b_scene->id, &blender::RNA_ViewLayer, &b_view_layer);
|
||||
blender::PointerRNA crl = RNA_pointer_get(&view_layer_rna_ptr, "cycles");
|
||||
|
||||
Film *film = scene->film;
|
||||
|
||||
|
|
@ -590,13 +594,13 @@ void BlenderSync::sync_film(::ViewLayer &b_view_layer, ::bScreen *b_screen, ::Vi
|
|||
film->set_mist_depth(b_scene->world->mistdist);
|
||||
|
||||
switch (b_scene->world->mistype) {
|
||||
case WO_MIST_QUADRATIC:
|
||||
case blender::WO_MIST_QUADRATIC:
|
||||
film->set_mist_falloff(2.0f);
|
||||
break;
|
||||
case WO_MIST_LINEAR:
|
||||
case blender::WO_MIST_LINEAR:
|
||||
film->set_mist_falloff(1.0f);
|
||||
break;
|
||||
case WO_MIST_INVERSE_QUADRATIC:
|
||||
case blender::WO_MIST_INVERSE_QUADRATIC:
|
||||
film->set_mist_falloff(0.5f);
|
||||
break;
|
||||
}
|
||||
|
|
@ -614,18 +618,18 @@ void BlenderSync::sync_film(::ViewLayer &b_view_layer, ::bScreen *b_screen, ::Vi
|
|||
|
||||
/* Render Layer */
|
||||
|
||||
void BlenderSync::sync_view_layer(::ViewLayer &b_view_layer)
|
||||
void BlenderSync::sync_view_layer(blender::ViewLayer &b_view_layer)
|
||||
{
|
||||
view_layer.name = b_view_layer.name;
|
||||
|
||||
/* Filter. */
|
||||
view_layer.use_background_shader = (b_view_layer.layflag & SCE_LAY_SKY) != 0;
|
||||
view_layer.use_background_shader = (b_view_layer.layflag & blender::SCE_LAY_SKY) != 0;
|
||||
/* Always enable surfaces for baking, otherwise there is nothing to bake to. */
|
||||
view_layer.use_surfaces = (b_view_layer.layflag & SCE_LAY_SOLID) != 0 || b_bake_target;
|
||||
view_layer.use_hair = (b_view_layer.layflag & SCE_LAY_STRAND) != 0;
|
||||
view_layer.use_volumes = (b_view_layer.layflag & SCE_LAY_VOLUMES) != 0;
|
||||
view_layer.use_motion_blur = (b_view_layer.layflag & SCE_LAY_MOTION_BLUR) != 0 &&
|
||||
(b_scene->r.mode & R_MBLUR) != 0;
|
||||
view_layer.use_surfaces = (b_view_layer.layflag & blender::SCE_LAY_SOLID) != 0 || b_bake_target;
|
||||
view_layer.use_hair = (b_view_layer.layflag & blender::SCE_LAY_STRAND) != 0;
|
||||
view_layer.use_volumes = (b_view_layer.layflag & blender::SCE_LAY_VOLUMES) != 0;
|
||||
view_layer.use_motion_blur = (b_view_layer.layflag & blender::SCE_LAY_MOTION_BLUR) != 0 &&
|
||||
(b_scene->r.mode & blender::R_MBLUR) != 0;
|
||||
|
||||
/* Material override. */
|
||||
view_layer.material_override = b_view_layer.mat_override;
|
||||
|
|
@ -633,8 +637,8 @@ void BlenderSync::sync_view_layer(::ViewLayer &b_view_layer)
|
|||
view_layer.world_override = b_view_layer.world_override;
|
||||
|
||||
/* Sample override. */
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene->id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
const int use_layer_samples = get_enum(cscene, "use_layer_samples");
|
||||
|
||||
view_layer.bound_samples = (use_layer_samples == 1);
|
||||
|
|
@ -646,7 +650,7 @@ void BlenderSync::sync_view_layer(::ViewLayer &b_view_layer)
|
|||
}
|
||||
}
|
||||
|
||||
static RenderData *engine_render_get(RenderEngine *engine)
|
||||
static blender::RenderData *engine_render_get(blender::RenderEngine *engine)
|
||||
{
|
||||
if (engine->re) {
|
||||
return RE_engine_get_render_data(engine->re);
|
||||
|
|
@ -668,7 +672,7 @@ void BlenderSync::sync_images()
|
|||
return;
|
||||
}
|
||||
/* Free buffers used by images which are not needed for render. */
|
||||
for (::Image &b_image : b_data->images) {
|
||||
for (blender::Image &b_image : b_data->images) {
|
||||
const bool is_builtin = image_is_builtin(b_image, *b_engine);
|
||||
if (is_builtin == false) {
|
||||
BKE_image_free_buffers_ex(&b_image, true);
|
||||
|
|
@ -679,7 +683,7 @@ void BlenderSync::sync_images()
|
|||
|
||||
/* Passes */
|
||||
|
||||
static bool get_known_pass_type(::RenderPass &b_pass, PassType &type, PassMode &mode)
|
||||
static bool get_known_pass_type(blender::RenderPass &b_pass, PassType &type, PassMode &mode)
|
||||
{
|
||||
const string name = b_pass.name;
|
||||
#define MAP_PASS(passname, passtype, noisy) \
|
||||
|
|
@ -769,7 +773,8 @@ static Pass *pass_add(Scene *scene,
|
|||
return pass;
|
||||
}
|
||||
|
||||
void BlenderSync::sync_render_passes(::RenderLayer &b_rlay, ::ViewLayer &b_view_layer)
|
||||
void BlenderSync::sync_render_passes(blender::RenderLayer &b_rlay,
|
||||
blender::ViewLayer &b_view_layer)
|
||||
{
|
||||
/* Delete all existing passes. */
|
||||
const vector<Pass *> &scene_passes = scene->passes;
|
||||
|
|
@ -778,18 +783,18 @@ void BlenderSync::sync_render_passes(::RenderLayer &b_rlay, ::ViewLayer &b_view_
|
|||
/* Always add combined pass. */
|
||||
pass_add(scene, PASS_COMBINED, "Combined");
|
||||
|
||||
/* Cryptomatte stores two ID/weight pairs per RGBA layer.
|
||||
/* Cryptomatte stores two blender::ID/weight pairs per RGBA layer.
|
||||
* User facing parameter is the number of pairs. */
|
||||
const int crypto_depth = divide_up(min(16, b_view_layer.cryptomatte_levels), 2);
|
||||
scene->film->set_cryptomatte_depth(crypto_depth);
|
||||
CryptomatteType cryptomatte_passes = CRYPT_NONE;
|
||||
if ((b_view_layer.cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_OBJECT) != 0) {
|
||||
if ((b_view_layer.cryptomatte_flag & blender::VIEW_LAYER_CRYPTOMATTE_OBJECT) != 0) {
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT);
|
||||
}
|
||||
if ((b_view_layer.cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_MATERIAL) != 0) {
|
||||
if ((b_view_layer.cryptomatte_flag & blender::VIEW_LAYER_CRYPTOMATTE_MATERIAL) != 0) {
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL);
|
||||
}
|
||||
if ((b_view_layer.cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_ASSET) != 0) {
|
||||
if ((b_view_layer.cryptomatte_flag & blender::VIEW_LAYER_CRYPTOMATTE_ASSET) != 0) {
|
||||
cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET);
|
||||
}
|
||||
scene->film->set_cryptomatte_passes(cryptomatte_passes);
|
||||
|
|
@ -797,20 +802,21 @@ void BlenderSync::sync_render_passes(::RenderLayer &b_rlay, ::ViewLayer &b_view_
|
|||
unordered_set<string> expected_passes;
|
||||
|
||||
/* Custom AOV passes. */
|
||||
for (ViewLayerAOV &b_aov : b_view_layer.aovs) {
|
||||
if ((b_aov.flag & AOV_CONFLICT) != 0) {
|
||||
for (blender::ViewLayerAOV &b_aov : b_view_layer.aovs) {
|
||||
if ((b_aov.flag & blender::AOV_CONFLICT) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const string name = b_aov.name;
|
||||
const PassType type = (b_aov.type == AOV_TYPE_COLOR) ? PASS_AOV_COLOR : PASS_AOV_VALUE;
|
||||
const PassType type = (b_aov.type == blender::AOV_TYPE_COLOR) ? PASS_AOV_COLOR :
|
||||
PASS_AOV_VALUE;
|
||||
|
||||
pass_add(scene, type, name.c_str());
|
||||
expected_passes.insert(name);
|
||||
}
|
||||
|
||||
/* Light Group passes. */
|
||||
for (ViewLayerLightgroup &b_lightgroup : b_view_layer.lightgroups) {
|
||||
for (blender::ViewLayerLightgroup &b_lightgroup : b_view_layer.lightgroups) {
|
||||
const string name = string_printf("Combined_%s", b_lightgroup.name);
|
||||
|
||||
Pass *pass = pass_add(scene, PASS_COMBINED, name.c_str(), PassMode::NOISY);
|
||||
|
|
@ -819,7 +825,7 @@ void BlenderSync::sync_render_passes(::RenderLayer &b_rlay, ::ViewLayer &b_view_
|
|||
}
|
||||
|
||||
/* Sync the passes that were defined in engine.py. */
|
||||
for (::RenderPass &b_pass : b_rlay.passes) {
|
||||
for (blender::RenderPass &b_pass : b_rlay.passes) {
|
||||
PassType pass_type = PASS_NONE;
|
||||
PassMode pass_mode = PassMode::DENOISED;
|
||||
|
||||
|
|
@ -830,8 +836,8 @@ void BlenderSync::sync_render_passes(::RenderLayer &b_rlay, ::ViewLayer &b_view_
|
|||
continue;
|
||||
}
|
||||
|
||||
if (pass_type == PASS_MOTION &&
|
||||
((b_view_layer.layflag & SCE_LAY_MOTION_BLUR) != 0 && (b_scene->r.mode & R_MBLUR) != 0))
|
||||
if (pass_type == PASS_MOTION && ((b_view_layer.layflag & blender::SCE_LAY_MOTION_BLUR) != 0 &&
|
||||
(b_scene->r.mode & blender::R_MBLUR) != 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
@ -842,7 +848,7 @@ void BlenderSync::sync_render_passes(::RenderLayer &b_rlay, ::ViewLayer &b_view_
|
|||
scene->film->set_pass_alpha_threshold(b_view_layer.pass_alpha_threshold);
|
||||
}
|
||||
|
||||
void BlenderSync::free_data_after_sync(::Depsgraph &b_depsgraph)
|
||||
void BlenderSync::free_data_after_sync(blender::Depsgraph &b_depsgraph)
|
||||
{
|
||||
/* When viewport display is not needed during render we can force some
|
||||
* caches to be releases from blender side in order to reduce peak memory
|
||||
|
|
@ -852,7 +858,7 @@ void BlenderSync::free_data_after_sync(::Depsgraph &b_depsgraph)
|
|||
const bool is_interface_locked = engine_render_get(b_engine) &&
|
||||
engine_render_get(b_engine)->use_lock_interface;
|
||||
const bool is_persistent_data = engine_render_get(b_engine) &&
|
||||
engine_render_get(b_engine)->mode & R_PERSISTENT_DATA;
|
||||
engine_render_get(b_engine)->mode & blender::R_PERSISTENT_DATA;
|
||||
const bool can_free_caches =
|
||||
(BlenderSession::headless || is_interface_locked) &&
|
||||
/* Baking re-uses the depsgraph multiple times, clearing crashes
|
||||
|
|
@ -870,25 +876,26 @@ void BlenderSync::free_data_after_sync(::Depsgraph &b_depsgraph)
|
|||
* but that will need some API support first.
|
||||
*/
|
||||
|
||||
DEGObjectIterSettings deg_iter_settings{};
|
||||
blender::DEGObjectIterSettings deg_iter_settings{};
|
||||
deg_iter_settings.depsgraph = &b_depsgraph;
|
||||
deg_iter_settings.flags = DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY | DEG_ITER_OBJECT_FLAG_VISIBLE |
|
||||
DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
|
||||
DEGObjectIterData deg_iter_data{};
|
||||
deg_iter_settings.flags = blender::DEG_ITER_OBJECT_FLAG_LINKED_DIRECTLY |
|
||||
blender::DEG_ITER_OBJECT_FLAG_VISIBLE |
|
||||
blender::DEG_ITER_OBJECT_FLAG_LINKED_VIA_SET;
|
||||
blender::DEGObjectIterData deg_iter_data{};
|
||||
deg_iter_data.settings = °_iter_settings;
|
||||
deg_iter_data.graph = deg_iter_settings.depsgraph;
|
||||
deg_iter_data.flag = deg_iter_settings.flags;
|
||||
|
||||
ITER_BEGIN (DEG_iterator_objects_begin,
|
||||
DEG_iterator_objects_next,
|
||||
DEG_iterator_objects_end,
|
||||
ITER_BEGIN (blender::DEG_iterator_objects_begin,
|
||||
blender::DEG_iterator_objects_next,
|
||||
blender::DEG_iterator_objects_end,
|
||||
°_iter_data,
|
||||
::Object *,
|
||||
blender::Object *,
|
||||
b_ob)
|
||||
{
|
||||
/* Grease pencil render requires all evaluated objects available as-is after Cycles is done
|
||||
* with its part. */
|
||||
if (b_ob->type == OB_GREASE_PENCIL) {
|
||||
if (b_ob->type == blender::OB_GREASE_PENCIL) {
|
||||
continue;
|
||||
}
|
||||
BKE_object_free_caches(b_ob);
|
||||
|
|
@ -898,13 +905,13 @@ void BlenderSync::free_data_after_sync(::Depsgraph &b_depsgraph)
|
|||
|
||||
/* Scene Parameters */
|
||||
|
||||
SceneParams BlenderSync::get_scene_params(::Scene &b_scene,
|
||||
SceneParams BlenderSync::get_scene_params(blender::Scene &b_scene,
|
||||
const bool background,
|
||||
const bool use_developer_ui)
|
||||
{
|
||||
SceneParams params;
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
const bool shadingsystem = RNA_boolean_get(&cscene, "shading_system");
|
||||
|
||||
if (shadingsystem == 0) {
|
||||
|
|
@ -926,7 +933,7 @@ SceneParams BlenderSync::get_scene_params(::Scene &b_scene,
|
|||
params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
|
||||
params.num_bvh_time_steps = RNA_int_get(&cscene, "debug_bvh_time_steps");
|
||||
|
||||
PointerRNA csscene = RNA_pointer_get(&scene_rna_ptr, "cycles_curves");
|
||||
blender::PointerRNA csscene = RNA_pointer_get(&scene_rna_ptr, "cycles_curves");
|
||||
params.hair_subdivisions = get_int(csscene, "subdivisions");
|
||||
params.hair_shape = (CurveShapeType)get_enum(
|
||||
csscene, "shape", CURVE_NUM_SHAPE_TYPES, CURVE_THICK);
|
||||
|
|
@ -938,7 +945,7 @@ SceneParams BlenderSync::get_scene_params(::Scene &b_scene,
|
|||
else {
|
||||
texture_limit = RNA_enum_get(&cscene, "texture_limit");
|
||||
}
|
||||
if (texture_limit > 0 && (b_scene.r.mode & R_SIMPLIFY) != 0) {
|
||||
if (texture_limit > 0 && (b_scene.r.mode & blender::R_SIMPLIFY) != 0) {
|
||||
params.texture_limit = 1 << (texture_limit + 6);
|
||||
}
|
||||
else {
|
||||
|
|
@ -954,28 +961,28 @@ SceneParams BlenderSync::get_scene_params(::Scene &b_scene,
|
|||
|
||||
/* Session Parameters */
|
||||
|
||||
bool BlenderSync::get_session_pause(::Scene &b_scene, bool background)
|
||||
bool BlenderSync::get_session_pause(blender::Scene &b_scene, bool background)
|
||||
{
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
return (background) ? false : get_boolean(cscene, "preview_pause");
|
||||
}
|
||||
|
||||
SessionParams BlenderSync::get_session_params(::RenderEngine &b_engine,
|
||||
::UserDef &b_preferences,
|
||||
::Scene &b_scene,
|
||||
SessionParams BlenderSync::get_session_params(blender::RenderEngine &b_engine,
|
||||
blender::UserDef &b_preferences,
|
||||
blender::Scene &b_scene,
|
||||
bool background)
|
||||
{
|
||||
SessionParams params;
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
|
||||
if (background && (b_engine.flag & RE_ENGINE_PREVIEW) == 0) {
|
||||
if (background && (b_engine.flag & blender::RE_ENGINE_PREVIEW) == 0) {
|
||||
/* Viewport and preview renders do not require temp directory and do request session
|
||||
* parameters more often than the background render.
|
||||
* Optimize RNA-C++ usage and memory allocation a bit by saving string access which we know
|
||||
* is not needed for viewport render. */
|
||||
params.temp_dir = BKE_tempdir_session();
|
||||
params.temp_dir = blender::BKE_tempdir_session();
|
||||
}
|
||||
|
||||
/* Headless and background rendering. */
|
||||
|
|
@ -987,7 +994,7 @@ SessionParams BlenderSync::get_session_params(::RenderEngine &b_engine,
|
|||
params.device = blender_device_info(b_preferences,
|
||||
b_scene,
|
||||
params.background,
|
||||
(b_engine.flag & RE_ENGINE_PREVIEW) != 0,
|
||||
(b_engine.flag & blender::RE_ENGINE_PREVIEW) != 0,
|
||||
params.denoise_device);
|
||||
|
||||
/* samples */
|
||||
|
|
@ -1044,8 +1051,9 @@ SessionParams BlenderSync::get_session_params(::RenderEngine &b_engine,
|
|||
}
|
||||
|
||||
/* Profiling. */
|
||||
params.use_profiling = params.device.has_profiling && (b_engine.flag & RE_ENGINE_PREVIEW) == 0 &&
|
||||
background && BlenderSession::print_render_stats;
|
||||
params.use_profiling = params.device.has_profiling &&
|
||||
(b_engine.flag & blender::RE_ENGINE_PREVIEW) == 0 && background &&
|
||||
BlenderSession::print_render_stats;
|
||||
|
||||
if (background) {
|
||||
params.use_auto_tile = true;
|
||||
|
|
@ -1058,8 +1066,8 @@ SessionParams BlenderSync::get_session_params(::RenderEngine &b_engine,
|
|||
return params;
|
||||
}
|
||||
|
||||
DenoiseParams BlenderSync::get_denoise_params(::Scene &b_scene,
|
||||
::ViewLayer *b_view_layer,
|
||||
DenoiseParams BlenderSync::get_denoise_params(blender::Scene &b_scene,
|
||||
blender::ViewLayer *b_view_layer,
|
||||
bool background,
|
||||
const DeviceInfo &denoise_device_info)
|
||||
{
|
||||
|
|
@ -1072,8 +1080,8 @@ DenoiseParams BlenderSync::get_denoise_params(::Scene &b_scene,
|
|||
};
|
||||
|
||||
DenoiseParams denoising;
|
||||
PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
blender::PointerRNA scene_rna_ptr = RNA_id_pointer_create(&b_scene.id);
|
||||
blender::PointerRNA cscene = RNA_pointer_get(&scene_rna_ptr, "cycles");
|
||||
|
||||
int input_passes = -1;
|
||||
|
||||
|
|
@ -1091,9 +1099,9 @@ DenoiseParams BlenderSync::get_denoise_params(::Scene &b_scene,
|
|||
cscene, "denoising_input_passes", DENOISER_INPUT_NUM, DENOISER_INPUT_RGB_ALBEDO_NORMAL);
|
||||
|
||||
if (b_view_layer) {
|
||||
PointerRNA view_layer_rna_ptr = RNA_pointer_create_id_subdata(
|
||||
b_scene.id, &RNA_ViewLayer, b_view_layer);
|
||||
PointerRNA clayer = RNA_pointer_get(&view_layer_rna_ptr, "cycles");
|
||||
blender::PointerRNA view_layer_rna_ptr = RNA_pointer_create_id_subdata(
|
||||
b_scene.id, &blender::RNA_ViewLayer, b_view_layer);
|
||||
blender::PointerRNA clayer = RNA_pointer_get(&view_layer_rna_ptr, "cycles");
|
||||
if (!get_boolean(clayer, "use_denoising")) {
|
||||
denoising.use = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,10 @@
|
|||
#include "util/map.h"
|
||||
#include "util/set.h"
|
||||
|
||||
namespace blender {
|
||||
struct DEGObjectIterData;
|
||||
struct MeshSequenceCacheModifier;
|
||||
} // namespace blender
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
|
@ -38,45 +40,48 @@ class TaskPool;
|
|||
|
||||
class BlenderSync {
|
||||
public:
|
||||
BlenderSync(::RenderEngine &b_engine,
|
||||
::Main &b_data,
|
||||
::Scene &b_scene,
|
||||
BlenderSync(blender::RenderEngine &b_engine,
|
||||
blender::Main &b_data,
|
||||
blender::Scene &b_scene,
|
||||
Scene *scene,
|
||||
bool preview,
|
||||
bool use_developer_ui,
|
||||
Progress &progress);
|
||||
~BlenderSync();
|
||||
|
||||
void reset(::Main &b_data, ::Scene &b_scene);
|
||||
void reset(blender::Main &b_data, blender::Scene &b_scene);
|
||||
|
||||
void tag_update();
|
||||
|
||||
void set_bake_target(::Object &b_object);
|
||||
void set_bake_target(blender::Object &b_object);
|
||||
|
||||
/* sync */
|
||||
void sync_recalc(::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d);
|
||||
void sync_data(::RenderData &b_render,
|
||||
::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
void sync_recalc(blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d);
|
||||
void sync_data(blender::RenderData &b_render,
|
||||
blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height,
|
||||
void **python_thread_state,
|
||||
const DeviceInfo &denoise_device_info);
|
||||
void sync_view_layer(::ViewLayer &b_view_layer);
|
||||
void sync_render_passes(::RenderLayer &b_rlay, ::ViewLayer &b_view_layer);
|
||||
void sync_integrator(::ViewLayer &b_view_layer,
|
||||
void sync_view_layer(blender::ViewLayer &b_view_layer);
|
||||
void sync_render_passes(blender::RenderLayer &b_rlay, blender::ViewLayer &b_view_layer);
|
||||
void sync_integrator(blender::ViewLayer &b_view_layer,
|
||||
bool background,
|
||||
const DeviceInfo &denoise_device_info);
|
||||
void sync_camera(const ::RenderData &b_render,
|
||||
void sync_camera(const blender::RenderData &b_render,
|
||||
const int width,
|
||||
const int height,
|
||||
const char *viewname);
|
||||
void sync_view(::View3D *b_v3d, ::RegionView3D *b_rv3d, const int width, const int height);
|
||||
void sync_view(blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height);
|
||||
int get_layer_samples()
|
||||
{
|
||||
return view_layer.samples;
|
||||
|
|
@ -87,73 +92,83 @@ class BlenderSync {
|
|||
}
|
||||
|
||||
/* Early data free. */
|
||||
void free_data_after_sync(::Depsgraph &b_depsgraph);
|
||||
void free_data_after_sync(blender::Depsgraph &b_depsgraph);
|
||||
|
||||
/* get parameters */
|
||||
static SceneParams get_scene_params(::Scene &b_scene,
|
||||
static SceneParams get_scene_params(blender::Scene &b_scene,
|
||||
const bool background,
|
||||
const bool use_developer_ui);
|
||||
static SessionParams get_session_params(::RenderEngine &b_engine,
|
||||
::UserDef &b_preferences,
|
||||
::Scene &b_scene,
|
||||
static SessionParams get_session_params(blender::RenderEngine &b_engine,
|
||||
blender::UserDef &b_preferences,
|
||||
blender::Scene &b_scene,
|
||||
bool background);
|
||||
static bool get_session_pause(::Scene &b_scene, bool background);
|
||||
static BufferParams get_buffer_params(
|
||||
::View3D *b_v3d, ::RegionView3D *b_rv3d, Camera *cam, const int width, const int height);
|
||||
static bool get_session_pause(blender::Scene &b_scene, bool background);
|
||||
static BufferParams get_buffer_params(blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
Camera *cam,
|
||||
const int width,
|
||||
const int height);
|
||||
|
||||
static DenoiseParams get_denoise_params(::Scene &b_scene,
|
||||
::ViewLayer *b_view_layer,
|
||||
static DenoiseParams get_denoise_params(blender::Scene &b_scene,
|
||||
blender::ViewLayer *b_view_layer,
|
||||
bool background,
|
||||
const DeviceInfo &denoise_device);
|
||||
|
||||
private:
|
||||
/* sync */
|
||||
void sync_lights(::Depsgraph &b_depsgraph, bool update_all);
|
||||
void sync_materials(::Depsgraph &b_depsgraph, bool update_all);
|
||||
void sync_objects(::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
void sync_lights(blender::Depsgraph &b_depsgraph, bool update_all);
|
||||
void sync_materials(blender::Depsgraph &b_depsgraph, bool update_all);
|
||||
void sync_objects(blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
const float motion_time = 0.0f);
|
||||
void sync_motion(::RenderData &b_render,
|
||||
::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
::RegionView3D *b_rv3d,
|
||||
void sync_motion(blender::RenderData &b_render,
|
||||
blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
blender::RegionView3D *b_rv3d,
|
||||
const int width,
|
||||
const int height,
|
||||
void **python_thread_state);
|
||||
void sync_film(::ViewLayer &b_view_layer, ::bScreen *b_screen, ::View3D *b_v3d);
|
||||
void sync_film(blender::ViewLayer &b_view_layer,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d);
|
||||
void sync_view();
|
||||
|
||||
/* Shader */
|
||||
array<Node *> find_used_shaders(::Object &b_ob);
|
||||
void sync_world(::Depsgraph &b_depsgraph, ::bScreen *b_screen, ::View3D *b_v3d, bool update_all);
|
||||
void sync_shaders(::Depsgraph &b_depsgraph,
|
||||
::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
array<Node *> find_used_shaders(blender::Object &b_ob);
|
||||
void sync_world(blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
bool update_all);
|
||||
void sync_shaders(blender::Depsgraph &b_depsgraph,
|
||||
blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
bool update_all);
|
||||
void sync_nodes(Shader *shader, ::bNodeTree &b_ntree);
|
||||
void sync_nodes(Shader *shader, blender::bNodeTree &b_ntree);
|
||||
|
||||
bool scene_attr_needs_recalc(Shader *shader, ::Depsgraph &b_depsgraph);
|
||||
void resolve_view_layer_attributes(Shader *shader, ShaderGraph *graph, ::Depsgraph &b_depsgraph);
|
||||
bool scene_attr_needs_recalc(Shader *shader, blender::Depsgraph &b_depsgraph);
|
||||
void resolve_view_layer_attributes(Shader *shader,
|
||||
ShaderGraph *graph,
|
||||
blender::Depsgraph &b_depsgraph);
|
||||
|
||||
/* Object */
|
||||
Object *sync_object(::ViewLayer &b_view_layer,
|
||||
::Object &b_ob,
|
||||
::DEGObjectIterData &b_deg_iter_data,
|
||||
Object *sync_object(blender::ViewLayer &b_view_layer,
|
||||
blender::Object &b_ob,
|
||||
blender::DEGObjectIterData &b_deg_iter_data,
|
||||
const float motion_time,
|
||||
bool use_particle_hair,
|
||||
bool show_lights,
|
||||
BlenderObjectCulling &culling,
|
||||
TaskPool *geom_task_pool);
|
||||
void sync_object_motion_init(::Object &b_parent, ::Object &b_ob, Object *object);
|
||||
void sync_object_motion_init(blender::Object &b_parent, blender::Object &b_ob, Object *object);
|
||||
|
||||
void sync_procedural(::Object &b_ob,
|
||||
::MeshSequenceCacheModifier &b_mesh_cache,
|
||||
void sync_procedural(blender::Object &b_ob,
|
||||
blender::MeshSequenceCacheModifier &b_mesh_cache,
|
||||
bool has_subdivision);
|
||||
|
||||
bool sync_object_attributes(::Object &b_ob,
|
||||
::DEGObjectIterData &b_deg_iter_data,
|
||||
bool sync_object_attributes(blender::Object &b_ob,
|
||||
blender::DEGObjectIterData &b_deg_iter_data,
|
||||
Object *object);
|
||||
|
||||
/* Volume */
|
||||
|
|
@ -168,11 +183,11 @@ class BlenderSync {
|
|||
void sync_hair_motion(BObjectInfo &b_ob_info, Hair *hair, int motion_step);
|
||||
void sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, const int motion_step = 0);
|
||||
void sync_particle_hair(Hair *hair,
|
||||
const ::Mesh &b_mesh,
|
||||
const blender::Mesh &b_mesh,
|
||||
BObjectInfo &b_ob_info,
|
||||
bool motion,
|
||||
const int motion_step = 0);
|
||||
bool object_has_particle_hair(::Object *b_ob);
|
||||
bool object_has_particle_hair(blender::Object *b_ob);
|
||||
|
||||
/* Point Cloud */
|
||||
void sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info);
|
||||
|
|
@ -181,8 +196,8 @@ class BlenderSync {
|
|||
const int motion_step = 0);
|
||||
|
||||
/* Camera */
|
||||
void sync_camera_motion(const ::RenderData &b_render,
|
||||
::Object *b_ob,
|
||||
void sync_camera_motion(const blender::RenderData &b_render,
|
||||
blender::Object *b_ob,
|
||||
const int width,
|
||||
const int height,
|
||||
const float motion_time);
|
||||
|
|
@ -201,33 +216,33 @@ class BlenderSync {
|
|||
|
||||
/* Light */
|
||||
void sync_light(BObjectInfo &b_ob_info, Light *light);
|
||||
void sync_background_light(::bScreen *b_screen, ::View3D *b_v3d);
|
||||
void sync_background_light(blender::bScreen *b_screen, blender::View3D *b_v3d);
|
||||
|
||||
/* Particles */
|
||||
bool sync_dupli_particle(::Object &b_parent,
|
||||
::DEGObjectIterData &b_deg_iter_data,
|
||||
::Object &b_ob,
|
||||
bool sync_dupli_particle(blender::Object &b_parent,
|
||||
blender::DEGObjectIterData &b_deg_iter_data,
|
||||
blender::Object &b_ob,
|
||||
Object *object);
|
||||
|
||||
/* Images. */
|
||||
void sync_images();
|
||||
|
||||
/* util */
|
||||
void find_shader(const ::ID *id, array<Node *> &used_shaders, Shader *default_shader);
|
||||
bool BKE_object_is_modified(::Object &b_ob);
|
||||
void find_shader(const blender::ID *id, array<Node *> &used_shaders, Shader *default_shader);
|
||||
bool BKE_object_is_modified(blender::Object &b_ob);
|
||||
bool object_is_geometry(BObjectInfo &b_ob_info);
|
||||
bool object_can_have_geometry(::Object &b_ob);
|
||||
bool object_is_light(::Object &b_ob);
|
||||
bool object_is_camera(::Object &b_ob);
|
||||
bool object_can_have_geometry(blender::Object &b_ob);
|
||||
bool object_is_light(blender::Object &b_ob);
|
||||
bool object_is_camera(blender::Object &b_ob);
|
||||
|
||||
::Object *get_camera_object(::View3D *b_v3d, ::RegionView3D *b_rv3d);
|
||||
::Object *get_dicing_camera_object(::View3D *b_v3d, ::RegionView3D *b_rv3d);
|
||||
blender::Object *get_camera_object(blender::View3D *b_v3d, blender::RegionView3D *b_rv3d);
|
||||
blender::Object *get_dicing_camera_object(blender::View3D *b_v3d, blender::RegionView3D *b_rv3d);
|
||||
|
||||
/* variables */
|
||||
::RenderEngine *b_engine;
|
||||
::Main *b_data;
|
||||
::Scene *b_scene;
|
||||
::Object *b_bake_target;
|
||||
blender::RenderEngine *b_engine;
|
||||
blender::Main *b_data;
|
||||
blender::Scene *b_scene;
|
||||
blender::Object *b_bake_target;
|
||||
|
||||
enum ShaderFlags { SHADER_WITH_LAYER_ATTRS };
|
||||
|
||||
|
|
@ -240,7 +255,7 @@ class BlenderSync {
|
|||
set<Geometry *> geometry_motion_synced;
|
||||
set<Geometry *> geometry_motion_attribute_synced;
|
||||
/** Remember which geometries come from which objects to be able to sync them after changes. */
|
||||
map<void *, set<::ID *>> instance_geometries_by_object;
|
||||
map<void *, set<blender::ID *>> instance_geometries_by_object;
|
||||
set<float> motion_times;
|
||||
void *world_map;
|
||||
bool world_recalc;
|
||||
|
|
@ -257,11 +272,9 @@ class BlenderSync {
|
|||
int max_subdivisions;
|
||||
|
||||
struct RenderLayerInfo {
|
||||
RenderLayerInfo() : material_override(nullptr), world_override(nullptr) {}
|
||||
|
||||
string name;
|
||||
::Material *material_override;
|
||||
::World *world_override;
|
||||
blender::Material *material_override = nullptr;
|
||||
blender::World *world_override = nullptr;
|
||||
bool use_background_shader = true;
|
||||
bool use_surfaces = true;
|
||||
bool use_hair = true;
|
||||
|
|
|
|||
|
|
@ -39,28 +39,32 @@
|
|||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
static inline ::ID *object_get_data(const ::Object &b_ob, const bool use_adaptive_subdivision)
|
||||
/* To make GS macro work. */
|
||||
using ID_Type = blender::ID_Type;
|
||||
|
||||
static inline blender::ID *object_get_data(const blender::Object &b_ob,
|
||||
const bool use_adaptive_subdivision)
|
||||
{
|
||||
if (!use_adaptive_subdivision && b_ob.type == OB_MESH) {
|
||||
return &BKE_mesh_wrapper_ensure_subdivision(blender::id_cast<::Mesh *>(b_ob.data))->id;
|
||||
if (!use_adaptive_subdivision && b_ob.type == blender::OB_MESH) {
|
||||
return &BKE_mesh_wrapper_ensure_subdivision(blender::id_cast<blender::Mesh *>(b_ob.data))->id;
|
||||
}
|
||||
|
||||
return reinterpret_cast<ID *>(b_ob.data);
|
||||
return reinterpret_cast<blender::ID *>(b_ob.data);
|
||||
}
|
||||
|
||||
struct BObjectInfo {
|
||||
/* Object directly provided by the depsgraph iterator. This object is only valid during one
|
||||
* iteration and must not be accessed afterwards. Transforms and visibility should be checked on
|
||||
* this object. */
|
||||
::Object *iter_object;
|
||||
blender::Object *iter_object;
|
||||
|
||||
/* This object remains alive even after the object iterator is done. It corresponds to one
|
||||
* original object. It is the object that owns the object data below. */
|
||||
::Object *real_object;
|
||||
blender::Object *real_object;
|
||||
|
||||
/* The object-data referenced by the iter object. This is still valid after the depsgraph
|
||||
* iterator is done. It might have a different type compared to object_get_data(real_object). */
|
||||
::ID *object_data;
|
||||
blender::ID *object_data;
|
||||
|
||||
/* Object will use adaptive subdivision. */
|
||||
bool use_adaptive_subdivision;
|
||||
|
|
@ -73,9 +77,9 @@ struct BObjectInfo {
|
|||
}
|
||||
};
|
||||
|
||||
static inline ::Mesh *object_copy_mesh_data(const BObjectInfo &b_ob_info)
|
||||
static inline blender::Mesh *object_copy_mesh_data(const BObjectInfo &b_ob_info)
|
||||
{
|
||||
::Mesh *mesh = BKE_mesh_new_from_object(
|
||||
blender::Mesh *mesh = BKE_mesh_new_from_object(
|
||||
nullptr, b_ob_info.real_object, false, false, !b_ob_info.use_adaptive_subdivision);
|
||||
return mesh;
|
||||
}
|
||||
|
|
@ -85,19 +89,19 @@ int blender_attribute_name_split_type(ustring name, string *r_real_name);
|
|||
void python_thread_state_save(void **python_thread_state);
|
||||
void python_thread_state_restore(void **python_thread_state);
|
||||
|
||||
static bool mesh_use_corner_normals(const BObjectInfo &b_ob_info, ::Mesh *mesh)
|
||||
static bool mesh_use_corner_normals(const BObjectInfo &b_ob_info, blender::Mesh *mesh)
|
||||
{
|
||||
return mesh && !b_ob_info.use_adaptive_subdivision &&
|
||||
(mesh->normals_domain(true) == blender::bke::MeshNormalDomain::Corner);
|
||||
}
|
||||
|
||||
void mesh_split_edges_for_corner_normals(::Mesh &mesh);
|
||||
void mesh_split_edges_for_corner_normals(blender::Mesh &mesh);
|
||||
|
||||
static inline ::Mesh *object_to_mesh(BObjectInfo &b_ob_info)
|
||||
static inline blender::Mesh *object_to_mesh(BObjectInfo &b_ob_info)
|
||||
{
|
||||
::Mesh *mesh = (GS(b_ob_info.object_data->name) == ID_ME) ?
|
||||
blender::id_cast<::Mesh *>(b_ob_info.object_data) :
|
||||
nullptr;
|
||||
blender::Mesh *mesh = (GS(b_ob_info.object_data->name) == blender::ID_ME) ?
|
||||
blender::id_cast<blender::Mesh *>(b_ob_info.object_data) :
|
||||
nullptr;
|
||||
|
||||
bool use_corner_normals = false;
|
||||
|
||||
|
|
@ -137,19 +141,19 @@ static inline ::Mesh *object_to_mesh(BObjectInfo &b_ob_info)
|
|||
return mesh;
|
||||
}
|
||||
|
||||
static inline void free_object_to_mesh(BObjectInfo &b_ob_info, ::Mesh &mesh)
|
||||
static inline void free_object_to_mesh(BObjectInfo &b_ob_info, blender::Mesh &mesh)
|
||||
{
|
||||
if (!b_ob_info.is_real_object_data()) {
|
||||
return;
|
||||
}
|
||||
/* Free mesh if we didn't just use the existing one. */
|
||||
::Object *object = b_ob_info.real_object;
|
||||
blender::Object *object = b_ob_info.real_object;
|
||||
if (object_get_data(*object, b_ob_info.use_adaptive_subdivision) != &mesh.id) {
|
||||
BKE_id_free(nullptr, &mesh.id);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void colorramp_to_array(const ::ColorBand &ramp,
|
||||
static inline void colorramp_to_array(const blender::ColorBand &ramp,
|
||||
array<float3> &ramp_color,
|
||||
array<float> &ramp_alpha,
|
||||
const int size)
|
||||
|
|
@ -167,14 +171,16 @@ static inline void colorramp_to_array(const ::ColorBand &ramp,
|
|||
}
|
||||
}
|
||||
|
||||
static inline void curvemap_minmax_curve(const ::CurveMap &curve, float *min_x, float *max_x)
|
||||
static inline void curvemap_minmax_curve(const blender::CurveMap &curve,
|
||||
float *min_x,
|
||||
float *max_x)
|
||||
{
|
||||
const blender::Span<::CurveMapPoint> points(curve.curve, curve.totpoint);
|
||||
const blender::Span<blender::CurveMapPoint> points(curve.curve, curve.totpoint);
|
||||
*min_x = min(*min_x, points.first().x);
|
||||
*max_x = max(*max_x, points.last().x);
|
||||
}
|
||||
|
||||
static inline void curvemapping_minmax(const ::CurveMapping &cumap,
|
||||
static inline void curvemapping_minmax(const blender::CurveMapping &cumap,
|
||||
const int num_curves,
|
||||
float *min_x,
|
||||
float *max_x)
|
||||
|
|
@ -183,21 +189,21 @@ static inline void curvemapping_minmax(const ::CurveMapping &cumap,
|
|||
*min_x = FLT_MAX;
|
||||
*max_x = -FLT_MAX;
|
||||
for (int i = 0; i < num_curves; ++i) {
|
||||
const ::CurveMap &map(cumap.cm[i]);
|
||||
const blender::CurveMap &map(cumap.cm[i]);
|
||||
curvemap_minmax_curve(map, min_x, max_x);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void curvemapping_to_array(const ::CurveMapping &cumap,
|
||||
static inline void curvemapping_to_array(const blender::CurveMapping &cumap,
|
||||
array<float> &data,
|
||||
const int size)
|
||||
{
|
||||
BKE_curvemapping_changed_all(&const_cast<::CurveMapping &>(cumap));
|
||||
const ::CurveMap &curve = cumap.cm[0];
|
||||
BKE_curvemapping_changed_all(&const_cast<blender::CurveMapping &>(cumap));
|
||||
const blender::CurveMap &curve = cumap.cm[0];
|
||||
const int full_size = size + 1;
|
||||
data.resize(full_size);
|
||||
if (!curve.table) {
|
||||
BKE_curvemapping_init(&const_cast<::CurveMapping &>(cumap));
|
||||
BKE_curvemapping_init(&const_cast<blender::CurveMapping &>(cumap));
|
||||
}
|
||||
for (int i = 0; i < full_size; i++) {
|
||||
const float t = float(i) / float(size);
|
||||
|
|
@ -205,7 +211,7 @@ static inline void curvemapping_to_array(const ::CurveMapping &cumap,
|
|||
}
|
||||
}
|
||||
|
||||
static inline void curvemapping_float_to_array(const ::CurveMapping &cumap,
|
||||
static inline void curvemapping_float_to_array(const blender::CurveMapping &cumap,
|
||||
array<float> &data,
|
||||
const int size)
|
||||
{
|
||||
|
|
@ -216,14 +222,14 @@ static inline void curvemapping_float_to_array(const ::CurveMapping &cumap,
|
|||
|
||||
const float range = max - min;
|
||||
|
||||
BKE_curvemapping_changed_all(&const_cast<::CurveMapping &>(cumap));
|
||||
BKE_curvemapping_changed_all(&const_cast<blender::CurveMapping &>(cumap));
|
||||
|
||||
const ::CurveMap &map = cumap.cm[0];
|
||||
const blender::CurveMap &map = cumap.cm[0];
|
||||
|
||||
const int full_size = size + 1;
|
||||
data.resize(full_size);
|
||||
if (!map.table) {
|
||||
BKE_curvemapping_init(&const_cast<::CurveMapping &>(cumap));
|
||||
BKE_curvemapping_init(&const_cast<blender::CurveMapping &>(cumap));
|
||||
}
|
||||
for (int i = 0; i < full_size; i++) {
|
||||
const float t = min + float(i) / float(size) * range;
|
||||
|
|
@ -231,7 +237,7 @@ static inline void curvemapping_float_to_array(const ::CurveMapping &cumap,
|
|||
}
|
||||
}
|
||||
|
||||
static inline void curvemapping_color_to_array(const ::CurveMapping &cumap,
|
||||
static inline void curvemapping_color_to_array(const blender::CurveMapping &cumap,
|
||||
array<float3> &data,
|
||||
const int size,
|
||||
bool rgb_curve)
|
||||
|
|
@ -255,22 +261,22 @@ static inline void curvemapping_color_to_array(const ::CurveMapping &cumap,
|
|||
|
||||
const float range_x = max_x - min_x;
|
||||
|
||||
BKE_curvemapping_changed_all(&const_cast<::CurveMapping &>(cumap));
|
||||
BKE_curvemapping_changed_all(&const_cast<blender::CurveMapping &>(cumap));
|
||||
|
||||
const ::CurveMap &mapR = cumap.cm[0];
|
||||
const ::CurveMap &mapG = cumap.cm[1];
|
||||
const ::CurveMap &mapB = cumap.cm[2];
|
||||
const blender::CurveMap &mapR = cumap.cm[0];
|
||||
const blender::CurveMap &mapG = cumap.cm[1];
|
||||
const blender::CurveMap &mapB = cumap.cm[2];
|
||||
if (!mapR.table || !mapG.table || !mapB.table) {
|
||||
BKE_curvemapping_init(&const_cast<::CurveMapping &>(cumap));
|
||||
BKE_curvemapping_init(&const_cast<blender::CurveMapping &>(cumap));
|
||||
}
|
||||
|
||||
const int full_size = size + 1;
|
||||
data.resize(full_size);
|
||||
|
||||
if (rgb_curve) {
|
||||
const ::CurveMap &mapI = cumap.cm[3];
|
||||
const blender::CurveMap &mapI = cumap.cm[3];
|
||||
if (!mapR.table || !mapG.table || !mapB.table || !mapI.table) {
|
||||
BKE_curvemapping_init(&const_cast<::CurveMapping &>(cumap));
|
||||
BKE_curvemapping_init(&const_cast<blender::CurveMapping &>(cumap));
|
||||
}
|
||||
|
||||
for (int i = 0; i < full_size; i++) {
|
||||
|
|
@ -283,7 +289,7 @@ static inline void curvemapping_color_to_array(const ::CurveMapping &cumap,
|
|||
}
|
||||
else {
|
||||
if (!mapR.table || !mapG.table || !mapB.table) {
|
||||
BKE_curvemapping_init(&const_cast<::CurveMapping &>(cumap));
|
||||
BKE_curvemapping_init(&const_cast<blender::CurveMapping &>(cumap));
|
||||
}
|
||||
|
||||
for (int i = 0; i < full_size; i++) {
|
||||
|
|
@ -295,7 +301,9 @@ static inline void curvemapping_color_to_array(const ::CurveMapping &cumap,
|
|||
}
|
||||
}
|
||||
|
||||
static inline bool BKE_object_is_deform_modified(BObjectInfo &self, ::Scene &scene, bool preview)
|
||||
static inline bool BKE_object_is_deform_modified(BObjectInfo &self,
|
||||
blender::Scene &scene,
|
||||
bool preview)
|
||||
{
|
||||
if (!self.is_real_object_data()) {
|
||||
/* Comes from geometry nodes, can't use heuristic to guess if it's animated. */
|
||||
|
|
@ -303,23 +311,23 @@ static inline bool BKE_object_is_deform_modified(BObjectInfo &self, ::Scene &sce
|
|||
}
|
||||
|
||||
/* Use heuristic to quickly check if object is potentially animated. */
|
||||
const int settings = preview ? eModifierMode_Realtime : eModifierMode_Render;
|
||||
return (::BKE_object_is_deform_modified(&scene, self.real_object) & settings) != 0;
|
||||
const int settings = preview ? blender::eModifierMode_Realtime : blender::eModifierMode_Render;
|
||||
return (blender::BKE_object_is_deform_modified(&scene, self.real_object) & settings) != 0;
|
||||
}
|
||||
|
||||
static inline int render_resolution_x(const ::RenderData &b_render)
|
||||
static inline int render_resolution_x(const blender::RenderData &b_render)
|
||||
{
|
||||
return b_render.xsch * b_render.size / 100;
|
||||
}
|
||||
|
||||
static inline int render_resolution_y(const ::RenderData &b_render)
|
||||
static inline int render_resolution_y(const blender::RenderData &b_render)
|
||||
{
|
||||
return b_render.ysch * b_render.size / 100;
|
||||
}
|
||||
|
||||
static inline string image_user_file_path(::Main &data,
|
||||
::ImageUser &iuser,
|
||||
::Image &ima,
|
||||
static inline string image_user_file_path(blender::Main &data,
|
||||
blender::ImageUser &iuser,
|
||||
blender::Image &ima,
|
||||
const int cfra)
|
||||
{
|
||||
char filepath[1024];
|
||||
|
|
@ -329,30 +337,33 @@ static inline string image_user_file_path(::Main &data,
|
|||
return string(filepath);
|
||||
}
|
||||
|
||||
static inline int image_user_frame_number(::ImageUser &iuser, ::Image &ima, const int cfra)
|
||||
static inline int image_user_frame_number(blender::ImageUser &iuser,
|
||||
blender::Image &ima,
|
||||
const int cfra)
|
||||
{
|
||||
BKE_image_user_frame_calc(&ima, &iuser, cfra);
|
||||
return iuser.framenr;
|
||||
}
|
||||
|
||||
static inline bool image_is_builtin(::Image &ima, ::RenderEngine &engine)
|
||||
static inline bool image_is_builtin(blender::Image &ima, blender::RenderEngine &engine)
|
||||
{
|
||||
const eImageSource image_source = eImageSource(ima.source);
|
||||
if (image_source == IMA_SRC_TILED) {
|
||||
const blender::eImageSource image_source = blender::eImageSource(ima.source);
|
||||
if (image_source == blender::IMA_SRC_TILED) {
|
||||
/* If any tile is marked as generated, then treat the entire Image as built-in. */
|
||||
for (::ImageTile &tile : ima.tiles) {
|
||||
if (tile.gen_flag & IMA_GEN_TILE) {
|
||||
for (blender::ImageTile &tile : ima.tiles) {
|
||||
if (tile.gen_flag & blender::IMA_GEN_TILE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return BKE_image_has_packedfile(&ima) || image_source == IMA_SRC_GENERATED ||
|
||||
image_source == IMA_SRC_MOVIE ||
|
||||
((engine.flag & RE_ENGINE_PREVIEW) != 0 && image_source != IMA_SRC_SEQUENCE);
|
||||
return BKE_image_has_packedfile(&ima) || image_source == blender::IMA_SRC_GENERATED ||
|
||||
image_source == blender::IMA_SRC_MOVIE ||
|
||||
((engine.flag & blender::RE_ENGINE_PREVIEW) != 0 &&
|
||||
image_source != blender::IMA_SRC_SEQUENCE);
|
||||
}
|
||||
|
||||
static inline void render_add_metadata(::RenderResult &b_rr, string name, string value)
|
||||
static inline void render_add_metadata(blender::RenderResult &b_rr, string name, string value)
|
||||
{
|
||||
BKE_render_result_stamp_data(&b_rr, name.c_str(), value.c_str());
|
||||
}
|
||||
|
|
@ -380,56 +391,56 @@ static inline Transform get_transform(const blender::float4x4 &matrix)
|
|||
ptr[14]);
|
||||
}
|
||||
|
||||
static inline float3 get_float3(PointerRNA &ptr, const char *name)
|
||||
static inline float3 get_float3(blender::PointerRNA &ptr, const char *name)
|
||||
{
|
||||
float3 f;
|
||||
RNA_float_get_array(&ptr, name, &f.x);
|
||||
return f;
|
||||
}
|
||||
|
||||
static inline void set_float3(PointerRNA &ptr, const char *name, const float3 value)
|
||||
static inline void set_float3(blender::PointerRNA &ptr, const char *name, const float3 value)
|
||||
{
|
||||
RNA_float_set_array(&ptr, name, &value.x);
|
||||
}
|
||||
|
||||
static inline float4 get_float4(PointerRNA &ptr, const char *name)
|
||||
static inline float4 get_float4(blender::PointerRNA &ptr, const char *name)
|
||||
{
|
||||
float4 f;
|
||||
RNA_float_get_array(&ptr, name, &f.x);
|
||||
return f;
|
||||
}
|
||||
|
||||
static inline void set_float4(PointerRNA &ptr, const char *name, const float4 value)
|
||||
static inline void set_float4(blender::PointerRNA &ptr, const char *name, const float4 value)
|
||||
{
|
||||
RNA_float_set_array(&ptr, name, &value.x);
|
||||
}
|
||||
|
||||
static inline bool get_boolean(PointerRNA &ptr, const char *name)
|
||||
static inline bool get_boolean(blender::PointerRNA &ptr, const char *name)
|
||||
{
|
||||
return RNA_boolean_get(&ptr, name) ? true : false;
|
||||
}
|
||||
|
||||
static inline void set_boolean(PointerRNA &ptr, const char *name, bool value)
|
||||
static inline void set_boolean(blender::PointerRNA &ptr, const char *name, bool value)
|
||||
{
|
||||
RNA_boolean_set(&ptr, name, (int)value);
|
||||
}
|
||||
|
||||
static inline float get_float(PointerRNA &ptr, const char *name)
|
||||
static inline float get_float(blender::PointerRNA &ptr, const char *name)
|
||||
{
|
||||
return RNA_float_get(&ptr, name);
|
||||
}
|
||||
|
||||
static inline void set_float(PointerRNA &ptr, const char *name, const float value)
|
||||
static inline void set_float(blender::PointerRNA &ptr, const char *name, const float value)
|
||||
{
|
||||
RNA_float_set(&ptr, name, value);
|
||||
}
|
||||
|
||||
static inline int get_int(PointerRNA &ptr, const char *name)
|
||||
static inline int get_int(blender::PointerRNA &ptr, const char *name)
|
||||
{
|
||||
return RNA_int_get(&ptr, name);
|
||||
}
|
||||
|
||||
static inline void set_int(PointerRNA &ptr, const char *name, const int value)
|
||||
static inline void set_int(blender::PointerRNA &ptr, const char *name, const int value)
|
||||
{
|
||||
RNA_int_set(&ptr, name, value);
|
||||
}
|
||||
|
|
@ -441,7 +452,7 @@ static inline void set_int(PointerRNA &ptr, const char *name, const int value)
|
|||
* from 0 to num_values-1. Be careful to use it with enums where some values are
|
||||
* deprecated!
|
||||
*/
|
||||
static inline int get_enum(PointerRNA &ptr,
|
||||
static inline int get_enum(blender::PointerRNA &ptr,
|
||||
const char *name,
|
||||
int num_values = -1,
|
||||
int default_value = -1)
|
||||
|
|
@ -454,9 +465,9 @@ static inline int get_enum(PointerRNA &ptr,
|
|||
return value;
|
||||
}
|
||||
|
||||
static inline string get_enum_identifier(PointerRNA &ptr, const char *name)
|
||||
static inline string get_enum_identifier(blender::PointerRNA &ptr, const char *name)
|
||||
{
|
||||
PropertyRNA *prop = RNA_struct_find_property(&ptr, name);
|
||||
blender::PropertyRNA *prop = RNA_struct_find_property(&ptr, name);
|
||||
const char *identifier = "";
|
||||
const int value = RNA_property_enum_get(&ptr, prop);
|
||||
|
||||
|
|
@ -465,29 +476,31 @@ static inline string get_enum_identifier(PointerRNA &ptr, const char *name)
|
|||
return string(identifier);
|
||||
}
|
||||
|
||||
static inline void set_enum(PointerRNA &ptr, const char *name, const int value)
|
||||
static inline void set_enum(blender::PointerRNA &ptr, const char *name, const int value)
|
||||
{
|
||||
RNA_enum_set(&ptr, name, value);
|
||||
}
|
||||
|
||||
static inline void set_enum(PointerRNA &ptr, const char *name, const string &identifier)
|
||||
static inline void set_enum(blender::PointerRNA &ptr, const char *name, const string &identifier)
|
||||
{
|
||||
RNA_enum_set_identifier(nullptr, &ptr, name, identifier.c_str());
|
||||
}
|
||||
|
||||
static inline string get_string(PointerRNA &ptr, const char *name)
|
||||
static inline string get_string(blender::PointerRNA &ptr, const char *name)
|
||||
{
|
||||
return RNA_string_get(&ptr, name);
|
||||
}
|
||||
|
||||
static inline void set_string(PointerRNA &ptr, const char *name, const string &value)
|
||||
static inline void set_string(blender::PointerRNA &ptr, const char *name, const string &value)
|
||||
{
|
||||
RNA_string_set(&ptr, name, value.c_str());
|
||||
}
|
||||
|
||||
/* Relative Paths */
|
||||
|
||||
static inline string blender_absolute_path(::Main &b_data, ::ID &b_id, const string &path)
|
||||
static inline string blender_absolute_path(blender::Main &b_data,
|
||||
blender::ID &b_id,
|
||||
const string &path)
|
||||
{
|
||||
if (path.size() >= 2 && path[0] == '/' && path[1] == '/') {
|
||||
string dirname;
|
||||
|
|
@ -505,18 +518,18 @@ static inline string blender_absolute_path(::Main &b_data, ::ID &b_id, const str
|
|||
return path;
|
||||
}
|
||||
|
||||
static inline string get_text_datablock_content(const ::ID *id)
|
||||
static inline string get_text_datablock_content(const blender::ID *id)
|
||||
{
|
||||
if (id == nullptr) {
|
||||
return "";
|
||||
}
|
||||
if (GS(id->name) != ID_TXT) {
|
||||
if (GS(id->name) != blender::ID_TXT) {
|
||||
return "";
|
||||
}
|
||||
const auto &text = *blender::id_cast<const ::Text *>(id);
|
||||
const auto &text = *blender::id_cast<const blender::Text *>(id);
|
||||
|
||||
string content;
|
||||
for (::TextLine &line : text.lines) {
|
||||
for (blender::TextLine &line : text.lines) {
|
||||
content += line.line ? line.line : "";
|
||||
content += "\n";
|
||||
}
|
||||
|
|
@ -526,11 +539,11 @@ static inline string get_text_datablock_content(const ::ID *id)
|
|||
|
||||
/* Texture Space */
|
||||
|
||||
static inline void mesh_texture_space(const ::Mesh &b_mesh, float3 &loc, float3 &size)
|
||||
static inline void mesh_texture_space(const blender::Mesh &b_mesh, float3 &loc, float3 &size)
|
||||
{
|
||||
float texspace_location[3];
|
||||
float texspace_size[3];
|
||||
BKE_mesh_texspace_get(const_cast<::Mesh *>(&b_mesh), texspace_location, texspace_size);
|
||||
BKE_mesh_texspace_get(const_cast<blender::Mesh *>(&b_mesh), texspace_location, texspace_size);
|
||||
|
||||
loc = make_float3(texspace_location[0], texspace_location[1], texspace_location[2]);
|
||||
size = make_float3(texspace_size[0], texspace_size[1], texspace_size[2]);
|
||||
|
|
@ -549,13 +562,13 @@ static inline void mesh_texture_space(const ::Mesh &b_mesh, float3 &loc, float3
|
|||
}
|
||||
|
||||
/* Object motion steps, returns 0 if no motion blur needed. */
|
||||
static inline uint object_motion_steps(::Object &b_parent,
|
||||
::Object &b_ob,
|
||||
static inline uint object_motion_steps(blender::Object &b_parent,
|
||||
blender::Object &b_ob,
|
||||
const int max_steps = INT_MAX)
|
||||
{
|
||||
/* Get motion enabled and steps from object itself. */
|
||||
PointerRNA object_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
PointerRNA cobject = RNA_pointer_get(&object_rna_ptr, "cycles");
|
||||
blender::PointerRNA object_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
blender::PointerRNA cobject = RNA_pointer_get(&object_rna_ptr, "cycles");
|
||||
bool use_motion = get_boolean(cobject, "use_motion_blur");
|
||||
if (!use_motion) {
|
||||
return 0;
|
||||
|
|
@ -566,8 +579,8 @@ static inline uint object_motion_steps(::Object &b_parent,
|
|||
/* Also check parent object, so motion blur and steps can be
|
||||
* controlled by dupli-group duplicator for linked groups. */
|
||||
if (&b_parent != &b_ob) {
|
||||
PointerRNA parent_rna_ptr = RNA_id_pointer_create(&b_parent.id);
|
||||
PointerRNA parent_cobject = RNA_pointer_get(&parent_rna_ptr, "cycles");
|
||||
blender::PointerRNA parent_rna_ptr = RNA_id_pointer_create(&b_parent.id);
|
||||
blender::PointerRNA parent_cobject = RNA_pointer_get(&parent_rna_ptr, "cycles");
|
||||
use_motion &= get_boolean(parent_cobject, "use_motion_blur");
|
||||
|
||||
if (!use_motion) {
|
||||
|
|
@ -584,10 +597,10 @@ static inline uint object_motion_steps(::Object &b_parent,
|
|||
}
|
||||
|
||||
/* object uses deformation motion blur */
|
||||
static inline bool object_use_deform_motion(::Object &b_parent, ::Object &b_ob)
|
||||
static inline bool object_use_deform_motion(blender::Object &b_parent, blender::Object &b_ob)
|
||||
{
|
||||
PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
blender::PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob.id);
|
||||
blender::PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
bool use_deform_motion = get_boolean(cobject, "use_deform_motion");
|
||||
/* If motion blur is enabled for the object we also check
|
||||
* whether it's enabled for the parent object as well.
|
||||
|
|
@ -595,20 +608,22 @@ static inline bool object_use_deform_motion(::Object &b_parent, ::Object &b_ob)
|
|||
* This way we can control motion blur from the dupli-group
|
||||
* duplicator much easier. */
|
||||
if (use_deform_motion && &b_parent != &b_ob) {
|
||||
PointerRNA b_parent_rna_ptr = RNA_id_pointer_create(&b_parent.id);
|
||||
PointerRNA parent_cobject = RNA_pointer_get(&b_parent_rna_ptr, "cycles");
|
||||
blender::PointerRNA b_parent_rna_ptr = RNA_id_pointer_create(&b_parent.id);
|
||||
blender::PointerRNA parent_cobject = RNA_pointer_get(&b_parent_rna_ptr, "cycles");
|
||||
use_deform_motion &= get_boolean(parent_cobject, "use_deform_motion");
|
||||
}
|
||||
return use_deform_motion;
|
||||
}
|
||||
|
||||
static inline ::FluidDomainSettings *object_fluid_gas_domain_find(::Object &b_ob)
|
||||
static inline blender::FluidDomainSettings *object_fluid_gas_domain_find(blender::Object &b_ob)
|
||||
{
|
||||
for (::ModifierData &b_mod : b_ob.modifiers) {
|
||||
if (b_mod.type == eModifierType_Fluid) {
|
||||
auto *b_mmd = reinterpret_cast<::FluidModifierData *>(&b_mod);
|
||||
for (blender::ModifierData &b_mod : b_ob.modifiers) {
|
||||
if (b_mod.type == blender::eModifierType_Fluid) {
|
||||
auto *b_mmd = reinterpret_cast<blender::FluidModifierData *>(&b_mod);
|
||||
|
||||
if (b_mmd->type == MOD_FLUID_TYPE_DOMAIN && b_mmd->domain->type == FLUID_DOMAIN_TYPE_GAS) {
|
||||
if (b_mmd->type == blender::MOD_FLUID_TYPE_DOMAIN &&
|
||||
b_mmd->domain->type == blender::FLUID_DOMAIN_TYPE_GAS)
|
||||
{
|
||||
return b_mmd->domain;
|
||||
}
|
||||
}
|
||||
|
|
@ -617,27 +632,29 @@ static inline ::FluidDomainSettings *object_fluid_gas_domain_find(::Object &b_ob
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
static ::SubsurfModifierData *object_subdivision_modifier(::Object &b_ob, const bool preview)
|
||||
static blender::SubsurfModifierData *object_subdivision_modifier(blender::Object &b_ob,
|
||||
const bool preview)
|
||||
{
|
||||
ModifierData *md = static_cast<ModifierData *>(b_ob.modifiers.last);
|
||||
blender::ModifierData *md = static_cast<blender::ModifierData *>(b_ob.modifiers.last);
|
||||
if (!md) {
|
||||
return nullptr;
|
||||
}
|
||||
if (md->type != eModifierType_Subsurf) {
|
||||
if (md->type != blender::eModifierType_Subsurf) {
|
||||
return nullptr;
|
||||
}
|
||||
const ModifierMode enabled_mode = preview ? eModifierMode_Render : eModifierMode_Realtime;
|
||||
const blender::ModifierMode enabled_mode = preview ? blender::eModifierMode_Render :
|
||||
blender::eModifierMode_Realtime;
|
||||
if ((md->mode & enabled_mode) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
SubsurfModifierData *subsurf = reinterpret_cast<SubsurfModifierData *>(md);
|
||||
if ((subsurf->flags & eSubsurfModifierFlag_UseAdaptiveSubdivision) == 0) {
|
||||
blender::SubsurfModifierData *subsurf = reinterpret_cast<blender::SubsurfModifierData *>(md);
|
||||
if ((subsurf->flags & blender::eSubsurfModifierFlag_UseAdaptiveSubdivision) == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return subsurf;
|
||||
}
|
||||
|
||||
static inline Mesh::SubdivisionType object_subdivision_type(::Object &b_ob,
|
||||
static inline Mesh::SubdivisionType object_subdivision_type(blender::Object &b_ob,
|
||||
const bool preview,
|
||||
const bool use_adaptive_subdivision)
|
||||
{
|
||||
|
|
@ -645,10 +662,10 @@ static inline Mesh::SubdivisionType object_subdivision_type(::Object &b_ob,
|
|||
return Mesh::SUBDIVISION_NONE;
|
||||
}
|
||||
|
||||
::SubsurfModifierData *subsurf = object_subdivision_modifier(b_ob, preview);
|
||||
blender::SubsurfModifierData *subsurf = object_subdivision_modifier(b_ob, preview);
|
||||
|
||||
if (subsurf) {
|
||||
if (subsurf->subdivType == SUBSURF_TYPE_CATMULL_CLARK) {
|
||||
if (subsurf->subdivType == blender::SUBSURF_TYPE_CATMULL_CLARK) {
|
||||
return Mesh::SUBDIVISION_CATMULL_CLARK;
|
||||
}
|
||||
return Mesh::SUBDIVISION_LINEAR;
|
||||
|
|
@ -657,7 +674,7 @@ static inline Mesh::SubdivisionType object_subdivision_type(::Object &b_ob,
|
|||
return Mesh::SUBDIVISION_NONE;
|
||||
}
|
||||
|
||||
static inline void object_subdivision_to_mesh(::Object &b_ob,
|
||||
static inline void object_subdivision_to_mesh(blender::Object &b_ob,
|
||||
Mesh &mesh,
|
||||
const bool preview,
|
||||
const bool use_adaptive_subdivision)
|
||||
|
|
@ -667,14 +684,14 @@ static inline void object_subdivision_to_mesh(::Object &b_ob,
|
|||
return;
|
||||
}
|
||||
|
||||
::SubsurfModifierData *subsurf = object_subdivision_modifier(b_ob, preview);
|
||||
blender::SubsurfModifierData *subsurf = object_subdivision_modifier(b_ob, preview);
|
||||
|
||||
if (!subsurf) {
|
||||
mesh.set_subdivision_type(Mesh::SUBDIVISION_NONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (subsurf->subdivType != SUBSURF_TYPE_CATMULL_CLARK) {
|
||||
if (subsurf->subdivType != blender::SUBSURF_TYPE_CATMULL_CLARK) {
|
||||
mesh.set_subdivision_type(Mesh::SUBDIVISION_LINEAR);
|
||||
return;
|
||||
}
|
||||
|
|
@ -682,48 +699,53 @@ static inline void object_subdivision_to_mesh(::Object &b_ob,
|
|||
mesh.set_subdivision_type(Mesh::SUBDIVISION_CATMULL_CLARK);
|
||||
|
||||
switch (subsurf->boundary_smooth) {
|
||||
case SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS:
|
||||
case blender::SUBSURF_BOUNDARY_SMOOTH_PRESERVE_CORNERS:
|
||||
mesh.set_subdivision_boundary_interpolation(Mesh::SUBDIVISION_BOUNDARY_EDGE_AND_CORNER);
|
||||
break;
|
||||
case SUBSURF_BOUNDARY_SMOOTH_ALL:
|
||||
case blender::SUBSURF_BOUNDARY_SMOOTH_ALL:
|
||||
mesh.set_subdivision_boundary_interpolation(Mesh::SUBDIVISION_BOUNDARY_EDGE_ONLY);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (subsurf->uv_smooth) {
|
||||
case SUBSURF_UV_SMOOTH_NONE:
|
||||
case blender::SUBSURF_UV_SMOOTH_NONE:
|
||||
mesh.set_subdivision_fvar_interpolation(Mesh::SUBDIVISION_FVAR_LINEAR_ALL);
|
||||
break;
|
||||
case SUBSURF_UV_SMOOTH_PRESERVE_CORNERS:
|
||||
case blender::SUBSURF_UV_SMOOTH_PRESERVE_CORNERS:
|
||||
mesh.set_subdivision_fvar_interpolation(Mesh::SUBDIVISION_FVAR_LINEAR_CORNERS_ONLY);
|
||||
break;
|
||||
case SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS:
|
||||
case blender::SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_AND_JUNCTIONS:
|
||||
mesh.set_subdivision_fvar_interpolation(Mesh::SUBDIVISION_FVAR_LINEAR_CORNERS_PLUS1);
|
||||
break;
|
||||
case SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE:
|
||||
case blender::SUBSURF_UV_SMOOTH_PRESERVE_CORNERS_JUNCTIONS_AND_CONCAVE:
|
||||
mesh.set_subdivision_fvar_interpolation(Mesh::SUBDIVISION_FVAR_LINEAR_CORNERS_PLUS2);
|
||||
break;
|
||||
case SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES:
|
||||
case blender::SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES:
|
||||
mesh.set_subdivision_fvar_interpolation(Mesh::SUBDIVISION_FVAR_LINEAR_BOUNDARIES);
|
||||
break;
|
||||
case SUBSURF_UV_SMOOTH_ALL:
|
||||
case blender::SUBSURF_UV_SMOOTH_ALL:
|
||||
mesh.set_subdivision_fvar_interpolation(Mesh::SUBDIVISION_FVAR_LINEAR_NONE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static inline uint object_ray_visibility(::Object &b_ob)
|
||||
static inline uint object_ray_visibility(blender::Object &b_ob)
|
||||
{
|
||||
uint flag = 0;
|
||||
|
||||
flag |= ((b_ob.visibility_flag & OB_HIDE_CAMERA) == 0) ? PATH_RAY_CAMERA : PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & OB_HIDE_DIFFUSE) == 0) ? PATH_RAY_DIFFUSE : PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & OB_HIDE_GLOSSY) == 0) ? PATH_RAY_GLOSSY : PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & OB_HIDE_TRANSMISSION) == 0) ? PATH_RAY_TRANSMIT :
|
||||
PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & OB_HIDE_SHADOW) == 0) ? PATH_RAY_SHADOW : PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & OB_HIDE_VOLUME_SCATTER) == 0) ? PATH_RAY_VOLUME_SCATTER :
|
||||
PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & blender::OB_HIDE_CAMERA) == 0) ? PATH_RAY_CAMERA :
|
||||
PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & blender::OB_HIDE_DIFFUSE) == 0) ? PATH_RAY_DIFFUSE :
|
||||
PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & blender::OB_HIDE_GLOSSY) == 0) ? PATH_RAY_GLOSSY :
|
||||
PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & blender::OB_HIDE_TRANSMISSION) == 0) ? PATH_RAY_TRANSMIT :
|
||||
PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & blender::OB_HIDE_SHADOW) == 0) ? PATH_RAY_SHADOW :
|
||||
PathRayFlag(0);
|
||||
flag |= ((b_ob.visibility_flag & blender::OB_HIDE_VOLUME_SCATTER) == 0) ?
|
||||
PATH_RAY_VOLUME_SCATTER :
|
||||
PathRayFlag(0);
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
|
@ -750,8 +772,8 @@ static inline bool object_need_motion_attribute(BObjectInfo &b_ob_info, Scene *s
|
|||
* - Motion attribute expects non-zero time steps.
|
||||
*
|
||||
* Avoid adding motion attributes if the motion blur will enforce 0 motion steps. */
|
||||
PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob_info.real_object->id);
|
||||
PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
blender::PointerRNA b_ob_rna_ptr = RNA_id_pointer_create(&b_ob_info.real_object->id);
|
||||
blender::PointerRNA cobject = RNA_pointer_get(&b_ob_rna_ptr, "cycles");
|
||||
const bool use_motion = get_boolean(cobject, "use_motion_blur");
|
||||
if (!use_motion) {
|
||||
return false;
|
||||
|
|
@ -763,10 +785,10 @@ static inline bool object_need_motion_attribute(BObjectInfo &b_ob_info, Scene *s
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline bool region_view3d_navigating_or_transforming(const ::RegionView3D *b_rv3d)
|
||||
static inline bool region_view3d_navigating_or_transforming(const blender::RegionView3D *b_rv3d)
|
||||
{
|
||||
return b_rv3d && ((b_rv3d->rflag & (RV3D_NAVIGATING | RV3D_PAINTING)) ||
|
||||
(G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)));
|
||||
return b_rv3d && ((b_rv3d->rflag & (blender::RV3D_NAVIGATING | blender::RV3D_PAINTING)) ||
|
||||
(blender::G.moving & (blender::G_TRANSFORM_OBJ | blender::G_TRANSFORM_EDIT)));
|
||||
}
|
||||
|
||||
class EdgeMap {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ BlenderViewportParameters::BlenderViewportParameters()
|
|||
{
|
||||
}
|
||||
|
||||
BlenderViewportParameters::BlenderViewportParameters(::bScreen *b_screen,
|
||||
::View3D *b_v3d,
|
||||
BlenderViewportParameters::BlenderViewportParameters(blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
bool use_developer_ui)
|
||||
: BlenderViewportParameters()
|
||||
{
|
||||
|
|
@ -34,22 +34,23 @@ BlenderViewportParameters::BlenderViewportParameters(::bScreen *b_screen,
|
|||
return;
|
||||
}
|
||||
|
||||
::View3DShading shading = b_v3d->shading;
|
||||
PointerRNA v3d_rna_ptr = RNA_pointer_create_discrete(&b_screen->id, &RNA_SpaceView3D, b_v3d);
|
||||
PointerRNA shading_rna_ptr = RNA_pointer_get(&v3d_rna_ptr, "shading");
|
||||
blender::View3DShading shading = b_v3d->shading;
|
||||
blender::PointerRNA v3d_rna_ptr = RNA_pointer_create_discrete(
|
||||
&b_screen->id, &blender::RNA_SpaceView3D, b_v3d);
|
||||
blender::PointerRNA shading_rna_ptr = RNA_pointer_get(&v3d_rna_ptr, "shading");
|
||||
|
||||
/* We only copy the shading parameters if we are in look-dev mode.
|
||||
* Otherwise defaults are being used. These defaults mimic normal render settings. */
|
||||
if (shading.type == OB_RENDER) {
|
||||
use_scene_world = shading.flag & V3D_SHADING_SCENE_WORLD_RENDER;
|
||||
use_scene_lights = shading.flag & V3D_SHADING_SCENE_LIGHTS_RENDER;
|
||||
if (shading.type == blender::OB_RENDER) {
|
||||
use_scene_world = shading.flag & blender::V3D_SHADING_SCENE_WORLD_RENDER;
|
||||
use_scene_lights = shading.flag & blender::V3D_SHADING_SCENE_LIGHTS_RENDER;
|
||||
|
||||
if (!use_scene_world) {
|
||||
studiolight_rotate_z = shading.studiolight_rot_z;
|
||||
studiolight_intensity = shading.studiolight_intensity;
|
||||
studiolight_background_alpha = shading.studiolight_background;
|
||||
PointerRNA selected_studiolight_rna_ptr = RNA_pointer_get(&shading_rna_ptr,
|
||||
"selected_studio_light");
|
||||
blender::PointerRNA selected_studiolight_rna_ptr = RNA_pointer_get(&shading_rna_ptr,
|
||||
"selected_studio_light");
|
||||
studiolight_path = RNA_string_get(&selected_studiolight_rna_ptr, "path");
|
||||
}
|
||||
}
|
||||
|
|
@ -62,7 +63,7 @@ BlenderViewportParameters::BlenderViewportParameters(::bScreen *b_screen,
|
|||
|
||||
display_pass = PASS_COMBINED;
|
||||
|
||||
PointerRNA cycles_shading_ptr = RNA_pointer_get(&shading_rna_ptr, "cycles");
|
||||
blender::PointerRNA cycles_shading_ptr = RNA_pointer_get(&shading_rna_ptr, "cycles");
|
||||
const string display_pass_identifier = get_enum_identifier(cycles_shading_ptr, "render_pass");
|
||||
if (!display_pass_identifier.empty()) {
|
||||
const ustring pass_type_identifier(string_to_lower(display_pass_identifier));
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@
|
|||
|
||||
#include "util/param.h"
|
||||
|
||||
namespace blender {
|
||||
struct View3D;
|
||||
struct bScreen;
|
||||
} // namespace blender
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
|
@ -28,7 +30,9 @@ class BlenderViewportParameters {
|
|||
bool show_active_pixels;
|
||||
|
||||
BlenderViewportParameters();
|
||||
BlenderViewportParameters(::bScreen *b_screen, ::View3D *b_v3d, bool use_developer_ui);
|
||||
BlenderViewportParameters(blender::bScreen *b_screen,
|
||||
blender::View3D *b_v3d,
|
||||
bool use_developer_ui);
|
||||
|
||||
/* Check whether any of shading related settings are different from the given parameters. */
|
||||
bool shader_modified(const BlenderViewportParameters &other) const;
|
||||
|
|
|
|||
|
|
@ -26,13 +26,15 @@ CCL_NAMESPACE_BEGIN
|
|||
/* TODO: verify this is not loading unnecessary attributes. */
|
||||
class BlenderSmokeLoader : public VDBImageLoader {
|
||||
public:
|
||||
BlenderSmokeLoader(::Object &b_ob, AttributeStandard attribute, const float clipping)
|
||||
BlenderSmokeLoader(blender::Object &b_ob, AttributeStandard attribute, const float clipping)
|
||||
: VDBImageLoader(Attribute::standard_name(attribute), clipping),
|
||||
b_domain(object_fluid_gas_domain_find(b_ob)),
|
||||
attribute(attribute)
|
||||
{
|
||||
domain_rna_ptr = RNA_pointer_create_discrete(&b_ob.id, &RNA_FluidDomainSettings, b_domain);
|
||||
mesh_texture_space(*blender::id_cast<const ::Mesh *>(b_ob.data), texspace_loc, texspace_size);
|
||||
domain_rna_ptr = RNA_pointer_create_discrete(
|
||||
&b_ob.id, &blender::RNA_FluidDomainSettings, b_domain);
|
||||
mesh_texture_space(
|
||||
*blender::id_cast<const blender::Mesh *>(b_ob.data), texspace_loc, texspace_size);
|
||||
}
|
||||
|
||||
void load_grid() override
|
||||
|
|
@ -58,7 +60,9 @@ class BlenderSmokeLoader : public VDBImageLoader {
|
|||
}
|
||||
|
||||
const int3 resolution = make_int3(b_domain->res[0], b_domain->res[1], b_domain->res[2]);
|
||||
int amplify = (b_domain->flags & FLUID_DOMAIN_USE_NOISE) != 0 ? b_domain->noise_scale : 1;
|
||||
int amplify = (b_domain->flags & blender::FLUID_DOMAIN_USE_NOISE) != 0 ?
|
||||
b_domain->noise_scale :
|
||||
1;
|
||||
|
||||
/* Velocity and heat data is always low-resolution. */
|
||||
if (attribute == ATTR_STD_VOLUME_VELOCITY || attribute == ATTR_STD_VOLUME_HEAT) {
|
||||
|
|
@ -96,14 +100,14 @@ class BlenderSmokeLoader : public VDBImageLoader {
|
|||
voxels.resize(width * height * depth * channels);
|
||||
|
||||
if (attribute == ATTR_STD_VOLUME_DENSITY) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "density_grid");
|
||||
blender::PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "density_grid");
|
||||
if (RNA_property_array_length(&domain_rna_ptr, prop) == voxels.size()) {
|
||||
RNA_property_float_get_array(&domain_rna_ptr, prop, voxels.data());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (attribute == ATTR_STD_VOLUME_FLAME) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "flame_grid");
|
||||
blender::PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "flame_grid");
|
||||
/* this is in range 0..1, and interpreted by the OpenGL smoke viewer
|
||||
* as 1500..3000 K with the first part faded to zero density */
|
||||
if (RNA_property_array_length(&domain_rna_ptr, prop) == voxels.size()) {
|
||||
|
|
@ -112,7 +116,7 @@ class BlenderSmokeLoader : public VDBImageLoader {
|
|||
}
|
||||
}
|
||||
else if (attribute == ATTR_STD_VOLUME_COLOR) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "color_grid");
|
||||
blender::PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "color_grid");
|
||||
/* the RGB is "premultiplied" by density for better interpolation results */
|
||||
if (RNA_property_array_length(&domain_rna_ptr, prop) == voxels.size()) {
|
||||
RNA_property_float_get_array(&domain_rna_ptr, prop, voxels.data());
|
||||
|
|
@ -120,21 +124,21 @@ class BlenderSmokeLoader : public VDBImageLoader {
|
|||
}
|
||||
}
|
||||
else if (attribute == ATTR_STD_VOLUME_VELOCITY) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "velocity_grid");
|
||||
blender::PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "velocity_grid");
|
||||
if (RNA_property_array_length(&domain_rna_ptr, prop) == voxels.size()) {
|
||||
RNA_property_float_get_array(&domain_rna_ptr, prop, voxels.data());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (attribute == ATTR_STD_VOLUME_HEAT) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "heat_grid");
|
||||
blender::PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "heat_grid");
|
||||
if (RNA_property_array_length(&domain_rna_ptr, prop) == voxels.size()) {
|
||||
RNA_property_float_get_array(&domain_rna_ptr, prop, voxels.data());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (attribute == ATTR_STD_VOLUME_TEMPERATURE) {
|
||||
PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "temperature_grid");
|
||||
blender::PropertyRNA *prop = RNA_struct_find_property(&domain_rna_ptr, "temperature_grid");
|
||||
if (RNA_property_array_length(&domain_rna_ptr, prop) == voxels.size()) {
|
||||
RNA_property_float_get_array(&domain_rna_ptr, prop, voxels.data());
|
||||
return true;
|
||||
|
|
@ -168,19 +172,22 @@ class BlenderSmokeLoader : public VDBImageLoader {
|
|||
return b_domain == other_loader.b_domain && attribute == other_loader.attribute;
|
||||
}
|
||||
|
||||
::FluidDomainSettings *b_domain;
|
||||
PointerRNA domain_rna_ptr;
|
||||
blender::FluidDomainSettings *b_domain;
|
||||
blender::PointerRNA domain_rna_ptr;
|
||||
float3 texspace_loc, texspace_size;
|
||||
AttributeStandard attribute;
|
||||
};
|
||||
|
||||
static void sync_smoke_volume(
|
||||
::Scene &b_scene, Scene *scene, BObjectInfo &b_ob_info, Volume *volume, const float frame)
|
||||
static void sync_smoke_volume(blender::Scene &b_scene,
|
||||
Scene *scene,
|
||||
BObjectInfo &b_ob_info,
|
||||
Volume *volume,
|
||||
const float frame)
|
||||
{
|
||||
if (!b_ob_info.is_real_object_data()) {
|
||||
return;
|
||||
}
|
||||
::FluidDomainSettings *b_domain = object_fluid_gas_domain_find(*b_ob_info.real_object);
|
||||
blender::FluidDomainSettings *b_domain = object_fluid_gas_domain_find(*b_ob_info.real_object);
|
||||
if (!b_domain) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -232,10 +239,10 @@ static void sync_smoke_volume(
|
|||
|
||||
class BlenderVolumeLoader : public VDBImageLoader {
|
||||
public:
|
||||
BlenderVolumeLoader(::Main &b_data,
|
||||
::Volume &b_volume,
|
||||
BlenderVolumeLoader(blender::Main &b_data,
|
||||
blender::Volume &b_volume,
|
||||
const string &grid_name,
|
||||
::VolumeRenderPrecision precision_,
|
||||
blender::VolumeRenderPrecision precision_,
|
||||
const float clipping)
|
||||
: VDBImageLoader(grid_name, clipping), b_volume(b_volume)
|
||||
{
|
||||
|
|
@ -256,14 +263,14 @@ class BlenderVolumeLoader : public VDBImageLoader {
|
|||
#endif
|
||||
#ifdef WITH_NANOVDB
|
||||
switch (precision_) {
|
||||
case VOLUME_PRECISION_FULL:
|
||||
case blender::VOLUME_PRECISION_FULL:
|
||||
precision = 32;
|
||||
break;
|
||||
case VOLUME_PRECISION_HALF:
|
||||
case blender::VOLUME_PRECISION_HALF:
|
||||
precision = 16;
|
||||
break;
|
||||
default:
|
||||
case VOLUME_PRECISION_VARIABLE:
|
||||
case blender::VOLUME_PRECISION_VARIABLE:
|
||||
precision = 0;
|
||||
break;
|
||||
}
|
||||
|
|
@ -272,7 +279,7 @@ class BlenderVolumeLoader : public VDBImageLoader {
|
|||
#endif
|
||||
}
|
||||
|
||||
::Volume &b_volume;
|
||||
blender::Volume &b_volume;
|
||||
#ifdef WITH_OPENVDB
|
||||
/* Store tree user so that the OPENVDB grid that is shared with Blender is not unloaded. */
|
||||
blender::bke::GVolumeGrid volume_grid;
|
||||
|
|
@ -280,19 +287,22 @@ class BlenderVolumeLoader : public VDBImageLoader {
|
|||
#endif
|
||||
};
|
||||
|
||||
static void sync_volume_object(
|
||||
::Main &b_data, ::Scene &b_scene, BObjectInfo &b_ob_info, Scene *scene, Volume *volume)
|
||||
static void sync_volume_object(blender::Main &b_data,
|
||||
blender::Scene &b_scene,
|
||||
BObjectInfo &b_ob_info,
|
||||
Scene *scene,
|
||||
Volume *volume)
|
||||
{
|
||||
::Volume &b_volume = *blender::id_cast<::Volume *>(b_ob_info.object_data);
|
||||
blender::Volume &b_volume = *blender::id_cast<blender::Volume *>(b_ob_info.object_data);
|
||||
BKE_volume_load(&b_volume, &b_data);
|
||||
|
||||
::VolumeRender &b_render = b_volume.render;
|
||||
blender::VolumeRender &b_render = b_volume.render;
|
||||
|
||||
volume->set_step_size(b_render.step_size);
|
||||
volume->set_object_space((b_render.space == VOLUME_SPACE_OBJECT));
|
||||
volume->set_object_space((b_render.space == blender::VOLUME_SPACE_OBJECT));
|
||||
|
||||
float velocity_scale = b_volume.velocity_scale;
|
||||
if (b_volume.velocity_unit == CACHEFILE_VELOCITY_UNIT_SECOND) {
|
||||
if (b_volume.velocity_unit == blender::CACHEFILE_VELOCITY_UNIT_SECOND) {
|
||||
/* Motion blur attribute is relative to seconds, we need it relative to frames. */
|
||||
const bool need_motion = object_need_motion_attribute(b_ob_info, scene);
|
||||
const float motion_scale = (need_motion) ? scene->motion_shutter_time() /
|
||||
|
|
@ -358,7 +368,7 @@ static void sync_volume_object(
|
|||
b_data,
|
||||
b_volume,
|
||||
name.string(),
|
||||
VolumeRenderPrecision(b_render.precision),
|
||||
blender::VolumeRenderPrecision(b_render.precision),
|
||||
b_render.clipping);
|
||||
ImageParams params;
|
||||
params.frame = b_volume.runtime->frame;
|
||||
|
|
@ -374,7 +384,7 @@ void BlenderSync::sync_volume(BObjectInfo &b_ob_info, Volume *volume)
|
|||
volume->clear(true);
|
||||
|
||||
if (view_layer.use_volumes) {
|
||||
if (GS(b_ob_info.object_data->name) == ID_VO) {
|
||||
if (GS(b_ob_info.object_data->name) == blender::ID_VO) {
|
||||
/* Volume object. Create only attributes, bounding mesh will then
|
||||
* be automatically generated later. */
|
||||
sync_volume_object(*b_data, *b_scene, b_ob_info, scene, volume);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class GHOST_EventDragnDrop : public GHOST_Event {
|
|||
|
||||
switch (dragn_drop_event_data_.dataType) {
|
||||
case GHOST_kDragnDropTypeBitmap:
|
||||
IMB_freeImBuf((ImBuf *)dragn_drop_event_data_.data);
|
||||
blender::IMB_freeImBuf((blender::ImBuf *)dragn_drop_event_data_.data);
|
||||
break;
|
||||
case GHOST_kDragnDropTypeFilenames: {
|
||||
GHOST_TStringArray *strArray = (GHOST_TStringArray *)dragn_drop_event_data_.data;
|
||||
|
|
|
|||
|
|
@ -1250,10 +1250,11 @@ static NSSize getNSImagePixelSize(NSImage *image)
|
|||
* \param image: NSImage to convert.
|
||||
* \return Pointer to the resulting allocated ImBuf. Caller must free.
|
||||
*/
|
||||
static ImBuf *NSImageToImBuf(NSImage *image)
|
||||
static blender::ImBuf *NSImageToImBuf(NSImage *image)
|
||||
{
|
||||
const NSSize imageSize = getNSImagePixelSize(image);
|
||||
ImBuf *ibuf = IMB_allocImBuf(imageSize.width, imageSize.height, 32, IB_byte_data);
|
||||
blender::ImBuf *ibuf = blender::IMB_allocImBuf(
|
||||
imageSize.width, imageSize.height, 32, blender::IB_byte_data);
|
||||
|
||||
if (!ibuf) {
|
||||
return nullptr;
|
||||
|
|
@ -1375,7 +1376,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
|
|||
}
|
||||
case GHOST_kDragnDropTypeBitmap: {
|
||||
NSImage *droppedImg = static_cast<NSImage *>(data);
|
||||
ImBuf *ibuf = NSImageToImBuf(droppedImg);
|
||||
blender::ImBuf *ibuf = NSImageToImBuf(droppedImg);
|
||||
|
||||
eventData = static_cast<GHOST_TDragnDropDataPtr>(ibuf);
|
||||
|
||||
|
|
@ -2108,7 +2109,7 @@ uint *GHOST_SystemCocoa::getClipboardImage(int *r_width, int *r_height) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
ImBuf *ibuf = NSImageToImBuf(clipboardImage);
|
||||
blender::ImBuf *ibuf = NSImageToImBuf(clipboardImage);
|
||||
const NSSize clipboardImageSize = getNSImagePixelSize(clipboardImage);
|
||||
|
||||
if (ibuf) {
|
||||
|
|
@ -2116,12 +2117,12 @@ uint *GHOST_SystemCocoa::getClipboardImage(int *r_width, int *r_height) const
|
|||
uint *rgba = (uint *)malloc(byteCount);
|
||||
|
||||
if (!rgba) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
memcpy(rgba, ibuf->byte_buffer.data, byteCount);
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
|
||||
*r_width = clipboardImageSize.width;
|
||||
*r_height = clipboardImageSize.height;
|
||||
|
|
|
|||
|
|
@ -8620,7 +8620,7 @@ GHOST_TSuccess GHOST_SystemWayland::hasClipboardImage() const
|
|||
if (!uris.empty()) {
|
||||
const std::string_view &uri = uris.front();
|
||||
char *filepath = GHOST_URL_decode_alloc(uri.data(), uri.size());
|
||||
if (IMB_test_image(filepath)) {
|
||||
if (blender::IMB_test_image(filepath)) {
|
||||
result = GHOST_kSuccess;
|
||||
}
|
||||
free(filepath);
|
||||
|
|
@ -8650,7 +8650,7 @@ uint *GHOST_SystemWayland::getClipboardImage(int *r_width, int *r_height) const
|
|||
|
||||
GWL_DataOffer *data_offer = seat->data_offer_copy_paste;
|
||||
if (data_offer) {
|
||||
ImBuf *ibuf = nullptr;
|
||||
blender::ImBuf *ibuf = nullptr;
|
||||
|
||||
/* Check if the source offers a supported mime type.
|
||||
* This check could be skipped, because the paste option is not supposed to be enabled
|
||||
|
|
@ -8661,8 +8661,8 @@ uint *GHOST_SystemWayland::getClipboardImage(int *r_width, int *r_height) const
|
|||
|
||||
if (data) {
|
||||
/* Generate the image buffer with the received data. */
|
||||
ibuf = IMB_load_image_from_memory(
|
||||
(const uint8_t *)data, data_len, IB_byte_data, "<clipboard>");
|
||||
ibuf = blender::IMB_load_image_from_memory(
|
||||
(const uint8_t *)data, data_len, blender::IB_byte_data, "<clipboard>");
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
|
@ -8677,7 +8677,7 @@ uint *GHOST_SystemWayland::getClipboardImage(int *r_width, int *r_height) const
|
|||
if (!uris.empty()) {
|
||||
const std::string_view &uri = uris.front();
|
||||
char *filepath = GHOST_URL_decode_alloc(uri.data(), uri.size());
|
||||
ibuf = IMB_load_image_from_filepath(filepath, IB_byte_data);
|
||||
ibuf = blender::IMB_load_image_from_filepath(filepath, blender::IB_byte_data);
|
||||
free(filepath);
|
||||
}
|
||||
free(data);
|
||||
|
|
@ -8690,7 +8690,7 @@ uint *GHOST_SystemWayland::getClipboardImage(int *r_width, int *r_height) const
|
|||
const size_t byte_count = size_t(ibuf->x) * size_t(ibuf->y) * 4;
|
||||
rgba = (uint *)malloc(byte_count);
|
||||
std::memcpy(rgba, ibuf->byte_buffer.data, byte_count);
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -8713,11 +8713,12 @@ GHOST_TSuccess GHOST_SystemWayland::putClipboardImage(uint *rgba, int width, int
|
|||
GWL_DataSource *data_source = seat->data_source;
|
||||
|
||||
/* Load buffer into an #ImBuf and convert to PNG. */
|
||||
ImBuf *ibuf = IMB_allocFromBuffer(reinterpret_cast<uint8_t *>(rgba), nullptr, width, height, 32);
|
||||
ibuf->ftype = IMB_FTYPE_PNG;
|
||||
blender::ImBuf *ibuf = blender::IMB_allocFromBuffer(
|
||||
reinterpret_cast<uint8_t *>(rgba), nullptr, width, height, 32);
|
||||
ibuf->ftype = blender::IMB_FTYPE_PNG;
|
||||
ibuf->foptions.quality = 15;
|
||||
if (!IMB_save_image(ibuf, "<memory>", IB_byte_data | IB_mem)) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
if (!IMB_save_image(ibuf, "<memory>", blender::IB_byte_data | blender::IB_mem)) {
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
return GHOST_kFailure;
|
||||
}
|
||||
|
||||
|
|
@ -8741,7 +8742,7 @@ GHOST_TSuccess GHOST_SystemWayland::putClipboardImage(uint *rgba, int width, int
|
|||
seat->wl.data_device, data_source->wl.source, seat->data_source_serial);
|
||||
}
|
||||
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
return GHOST_kSuccess;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2528,11 +2528,11 @@ GHOST_TSuccess GHOST_SystemWin32::hasClipboardImage(void) const
|
|||
WCHAR lpszFile[MAX_PATH] = {0};
|
||||
DragQueryFileW(hDrop, 0, lpszFile, MAX_PATH);
|
||||
char *filepath = alloc_utf_8_from_16(lpszFile, 0);
|
||||
ImBuf *ibuf = IMB_load_image_from_filepath(filepath,
|
||||
IB_byte_data | IB_multilayer | IB_test);
|
||||
blender::ImBuf *ibuf = blender::IMB_load_image_from_filepath(
|
||||
filepath, blender::IB_byte_data | blender::IB_multilayer | blender::IB_test);
|
||||
free(filepath);
|
||||
if (ibuf) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
result = GHOST_kSuccess;
|
||||
}
|
||||
}
|
||||
|
|
@ -2565,7 +2565,8 @@ static uint *getClipboardImageFilepath(int *r_width, int *r_height)
|
|||
}
|
||||
|
||||
if (filepath) {
|
||||
ImBuf *ibuf = IMB_load_image_from_filepath(filepath, IB_byte_data | IB_multilayer);
|
||||
blender::ImBuf *ibuf = blender::IMB_load_image_from_filepath(
|
||||
filepath, blender::IB_byte_data | blender::IB_multilayer);
|
||||
free(filepath);
|
||||
if (ibuf) {
|
||||
*r_width = ibuf->x;
|
||||
|
|
@ -2575,7 +2576,7 @@ static uint *getClipboardImageFilepath(int *r_width, int *r_height)
|
|||
if (rgba) {
|
||||
memcpy(rgba, ibuf->byte_buffer.data, byte_count);
|
||||
}
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
return rgba;
|
||||
}
|
||||
}
|
||||
|
|
@ -2683,8 +2684,8 @@ static uint *getClipboardImageImBuf(int *r_width, int *r_height, UINT format)
|
|||
|
||||
uint *rgba = nullptr;
|
||||
|
||||
ImBuf *ibuf = IMB_load_image_from_memory(
|
||||
(uchar *)pMem, GlobalSize(hGlobal), IB_byte_data, "<clipboard>");
|
||||
blender::ImBuf *ibuf = blender::IMB_load_image_from_memory(
|
||||
(uchar *)pMem, GlobalSize(hGlobal), blender::IB_byte_data, "<clipboard>");
|
||||
|
||||
if (ibuf) {
|
||||
*r_width = ibuf->x;
|
||||
|
|
@ -2692,7 +2693,7 @@ static uint *getClipboardImageImBuf(int *r_width, int *r_height, UINT format)
|
|||
const uint64_t byte_count = uint64_t(ibuf->x) * ibuf->y * 4;
|
||||
rgba = (uint *)malloc(byte_count);
|
||||
memcpy(rgba, ibuf->byte_buffer.data, byte_count);
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
}
|
||||
|
||||
GlobalUnlock(hGlobal);
|
||||
|
|
@ -2792,23 +2793,24 @@ static bool putClipboardImagePNG(uint *rgba, int width, int height)
|
|||
UINT cf = RegisterClipboardFormat("PNG");
|
||||
|
||||
/* Load buffer into ImBuf, convert to PNG. */
|
||||
ImBuf *ibuf = IMB_allocFromBuffer(reinterpret_cast<uint8_t *>(rgba), nullptr, width, height, 32);
|
||||
ibuf->ftype = IMB_FTYPE_PNG;
|
||||
blender::ImBuf *ibuf = blender::IMB_allocFromBuffer(
|
||||
reinterpret_cast<uint8_t *>(rgba), nullptr, width, height, 32);
|
||||
ibuf->ftype = blender::IMB_FTYPE_PNG;
|
||||
ibuf->foptions.quality = 15;
|
||||
if (!IMB_save_image(ibuf, "<memory>", IB_byte_data | IB_mem)) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
if (!blender::IMB_save_image(ibuf, "<memory>", blender::IB_byte_data | blender::IB_mem)) {
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
return false;
|
||||
}
|
||||
|
||||
HGLOBAL hMem = GlobalAlloc(GHND, ibuf->encoded_buffer_size);
|
||||
if (!hMem) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
return false;
|
||||
}
|
||||
|
||||
LPVOID pMem = GlobalLock(hMem);
|
||||
if (!pMem) {
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
GlobalFree(hMem);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2816,7 +2818,7 @@ static bool putClipboardImagePNG(uint *rgba, int width, int height)
|
|||
memcpy(pMem, ibuf->encoded_buffer.data, ibuf->encoded_buffer_size);
|
||||
|
||||
GlobalUnlock(hMem);
|
||||
IMB_freeImBuf(ibuf);
|
||||
blender::IMB_freeImBuf(ibuf);
|
||||
|
||||
if (!SetClipboardData(cf, hMem)) {
|
||||
GlobalFree(hMem);
|
||||
|
|
|
|||
|
|
@ -133,8 +133,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
|
|||
const char *title = "Blender - Unsupported Graphics Card Configuration";
|
||||
const char *text = "";
|
||||
#if defined(WIN32)
|
||||
if (strncmp(BLI_getenv("PROCESSOR_IDENTIFIER"), "ARM", 3) == 0 &&
|
||||
strstr(BLI_getenv("PROCESSOR_IDENTIFIER"), "Qualcomm") != NULL)
|
||||
if (strncmp(blender::BLI_getenv("PROCESSOR_IDENTIFIER"), "ARM", 3) == 0 &&
|
||||
strstr(blender::BLI_getenv("PROCESSOR_IDENTIFIER"), "Qualcomm") != NULL)
|
||||
{
|
||||
text =
|
||||
"A driver with support for OpenGL 4.3 or higher is required.\n\n"
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ void GHOST_XrContext::createOpenXRInstance(
|
|||
{
|
||||
XrInstanceCreateInfo create_info = {XR_TYPE_INSTANCE_CREATE_INFO};
|
||||
|
||||
STRNCPY(create_info.applicationInfo.applicationName, "Blender");
|
||||
blender::STRNCPY(create_info.applicationInfo.applicationName, "Blender");
|
||||
create_info.applicationInfo.apiVersion = XR_CURRENT_API_VERSION;
|
||||
|
||||
getAPILayersToEnable(enabled_layers_);
|
||||
|
|
|
|||
13
intern/mantaflow/extern/manta_fluid_API.h
vendored
13
intern/mantaflow/extern/manta_fluid_API.h
vendored
|
|
@ -6,14 +6,9 @@
|
|||
* \ingroup intern_mantaflow
|
||||
*/
|
||||
|
||||
#ifndef MANTA_API_H
|
||||
#define MANTA_API_H
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
namespace blender {
|
||||
|
||||
struct MANTA;
|
||||
|
||||
|
|
@ -200,8 +195,4 @@ float manta_liquid_get_snd_particle_velocity_x_at(struct MANTA *liquid, int i);
|
|||
float manta_liquid_get_snd_particle_velocity_y_at(struct MANTA *liquid, int i);
|
||||
float manta_liquid_get_snd_particle_velocity_z_at(struct MANTA *liquid, int i);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MANTA_API_H_ */
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -37,12 +37,15 @@ using std::ofstream;
|
|||
using std::ostringstream;
|
||||
using std::to_string;
|
||||
|
||||
namespace blender {
|
||||
|
||||
atomic<int> MANTA::solverID(0);
|
||||
int MANTA::with_debug(0);
|
||||
|
||||
MANTA::MANTA(int *res, FluidModifierData *fmd)
|
||||
: mCurrentID(++solverID), mMaxRes(fmd->domain->maxres)
|
||||
{
|
||||
using namespace blender;
|
||||
if (with_debug) {
|
||||
cout << "FLUID: " << mCurrentID << " with res(" << res[0] << ", " << res[1] << ", " << res[2]
|
||||
<< ")" << endl;
|
||||
|
|
@ -2447,3 +2450,5 @@ string MANTA::getFile(
|
|||
BLI_path_frame(targetFile, sizeof(targetFile), framenr, 0);
|
||||
return targetFile;
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@
|
|||
* \ingroup intern_mantaflow
|
||||
*/
|
||||
|
||||
#ifndef MANTA_A_H
|
||||
#define MANTA_A_H
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
|
|
@ -20,6 +19,8 @@ using std::string;
|
|||
using std::unordered_map;
|
||||
using std::vector;
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct MANTA {
|
||||
public:
|
||||
MANTA(int *res, struct FluidModifierData *fmd);
|
||||
|
|
@ -873,4 +874,4 @@ struct MANTA {
|
|||
int framenr);
|
||||
};
|
||||
|
||||
#endif
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
#include "manta_fluid_API.h"
|
||||
#include "MANTA_main.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
/* Fluid functions */
|
||||
MANTA *manta_init(int *res, struct FluidModifierData *fmd)
|
||||
{
|
||||
|
|
@ -753,3 +755,5 @@ float manta_liquid_get_snd_particle_velocity_z_at(MANTA *liquid, int i)
|
|||
{
|
||||
return liquid->getSndParticleVelocityZAt(i);
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct FCurve;
|
||||
struct FCurve;
|
||||
struct ID;
|
||||
|
|
@ -34,7 +36,7 @@ struct Main;
|
|||
struct PointerRNA;
|
||||
struct Main;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/* Forward declarations for the types defined later in this file. */
|
||||
class Layer;
|
||||
|
|
@ -92,7 +94,7 @@ class Slot;
|
|||
* \see assert_baklava_phase_1_invariants()
|
||||
* \see #animrig::versioning::action_is_layered()
|
||||
*/
|
||||
class Action : public ::bAction {
|
||||
class Action : public bAction {
|
||||
public:
|
||||
Action() = default;
|
||||
/**
|
||||
|
|
@ -530,7 +532,7 @@ class Action : public ::bAction {
|
|||
*/
|
||||
void slot_identifier_ensure_prefix(Slot &slot);
|
||||
};
|
||||
static_assert(sizeof(Action) == sizeof(::bAction),
|
||||
static_assert(sizeof(Action) == sizeof(bAction),
|
||||
"DNA struct and its C++ wrapper must have the same size");
|
||||
|
||||
/**
|
||||
|
|
@ -543,7 +545,7 @@ static_assert(sizeof(Action) == sizeof(::bAction),
|
|||
* Different strips can refer to different types of data, although at the moment
|
||||
* only one type of strip data is implemented: keyframe animation data.
|
||||
*/
|
||||
class Strip : public ::ActionStrip {
|
||||
class Strip : public ActionStrip {
|
||||
public:
|
||||
/**
|
||||
* The possible types of strip data.
|
||||
|
|
@ -643,7 +645,7 @@ class Strip : public ::ActionStrip {
|
|||
template<typename T> const T &data(const Action &owning_action) const;
|
||||
template<typename T> T &data(Action &owning_action);
|
||||
};
|
||||
static_assert(sizeof(Strip) == sizeof(::ActionStrip),
|
||||
static_assert(sizeof(Strip) == sizeof(ActionStrip),
|
||||
"DNA struct and its C++ wrapper must have the same size");
|
||||
|
||||
/**
|
||||
|
|
@ -661,7 +663,7 @@ static_assert(sizeof(Strip) == sizeof(::ActionStrip),
|
|||
* within the strip array, etc.) have not yet been decided. These will be
|
||||
* decided and documented when support for multiple strips is added.
|
||||
*/
|
||||
class Layer : public ::ActionLayer {
|
||||
class Layer : public ActionLayer {
|
||||
public:
|
||||
Layer() = default;
|
||||
Layer(const Layer &other) = delete;
|
||||
|
|
@ -742,7 +744,7 @@ class Layer : public ::ActionLayer {
|
|||
*/
|
||||
int64_t find_strip_index(const Strip &strip) const;
|
||||
};
|
||||
static_assert(sizeof(Layer) == sizeof(::ActionLayer),
|
||||
static_assert(sizeof(Layer) == sizeof(ActionLayer),
|
||||
"DNA struct and its C++ wrapper must have the same size");
|
||||
|
||||
ENUM_OPERATORS(Layer::Flags);
|
||||
|
|
@ -756,7 +758,7 @@ ENUM_OPERATORS(Layer::Flags);
|
|||
*
|
||||
* \see #AnimData::slot_handle
|
||||
*/
|
||||
class Slot : public ::ActionSlot {
|
||||
class Slot : public ActionSlot {
|
||||
public:
|
||||
Slot();
|
||||
explicit Slot(const Slot &other);
|
||||
|
|
@ -914,8 +916,8 @@ class Slot : public ::ActionSlot {
|
|||
*
|
||||
* \note This static method invalidates all user caches of all Action Slots.
|
||||
*
|
||||
* \see #blender::animrig::internal::rebuild_slot_user_cache()
|
||||
* \see #blender::bke::animdata::action_slots_user_cache_invalidate(), which is an alternative to
|
||||
* \see #animrig::internal::rebuild_slot_user_cache()
|
||||
* \see #bke::animdata::action_slots_user_cache_invalidate(), which is an alternative to
|
||||
* calling this static method in case the caller only wants to depend on BKE headers.
|
||||
*/
|
||||
static void users_invalidate(Main &bmain);
|
||||
|
|
@ -951,7 +953,7 @@ class Slot : public ::ActionSlot {
|
|||
*/
|
||||
void set_active(bool active);
|
||||
};
|
||||
static_assert(sizeof(Slot) == sizeof(::ActionSlot),
|
||||
static_assert(sizeof(Slot) == sizeof(ActionSlot),
|
||||
"DNA struct and its C++ wrapper must have the same size");
|
||||
ENUM_OPERATORS(Slot::Flags);
|
||||
|
||||
|
|
@ -964,7 +966,7 @@ ENUM_OPERATORS(Slot::Flags);
|
|||
*
|
||||
* \see ChannelBag
|
||||
*/
|
||||
class StripKeyframeData : public ::ActionStripKeyframeData {
|
||||
class StripKeyframeData : public ActionStripKeyframeData {
|
||||
public:
|
||||
/* Value of `Strip::type()` that corresponds to this type. */
|
||||
static constexpr Strip::Type TYPE = Strip::Type::Keyframe;
|
||||
|
|
@ -1038,7 +1040,7 @@ class StripKeyframeData : public ::ActionStripKeyframeData {
|
|||
eInsertKeyFlags insert_key_flags = INSERTKEY_NOFLAGS,
|
||||
std::optional<float2> cycle_range = std::nullopt);
|
||||
};
|
||||
static_assert(sizeof(StripKeyframeData) == sizeof(::ActionStripKeyframeData),
|
||||
static_assert(sizeof(StripKeyframeData) == sizeof(ActionStripKeyframeData),
|
||||
"DNA struct and its C++ wrapper must have the same size");
|
||||
|
||||
/**
|
||||
|
|
@ -1050,7 +1052,7 @@ static_assert(sizeof(StripKeyframeData) == sizeof(::ActionStripKeyframeData),
|
|||
*
|
||||
* \see ChannelGroup
|
||||
*/
|
||||
class Channelbag : public ::ActionChannelbag {
|
||||
class Channelbag : public ActionChannelbag {
|
||||
public:
|
||||
Channelbag() = default;
|
||||
explicit Channelbag(const Channelbag &other);
|
||||
|
|
@ -1388,7 +1390,7 @@ class Channelbag : public ::ActionChannelbag {
|
|||
void restore_channel_group_invariants();
|
||||
};
|
||||
|
||||
static_assert(sizeof(Channelbag) == sizeof(::ActionChannelbag),
|
||||
static_assert(sizeof(Channelbag) == sizeof(ActionChannelbag),
|
||||
"DNA struct and its C++ wrapper must have the same size");
|
||||
|
||||
/**
|
||||
|
|
@ -1398,7 +1400,7 @@ static_assert(sizeof(Channelbag) == sizeof(::ActionChannelbag),
|
|||
* fcurves for organizational purposes, e.g. for use in the channel list in the
|
||||
* animation editors.
|
||||
*/
|
||||
class ChannelGroup : public ::bActionGroup {
|
||||
class ChannelGroup : public bActionGroup {
|
||||
public:
|
||||
/**
|
||||
* Determine whether this channel group is from a legacy action or a layered action.
|
||||
|
|
@ -1418,7 +1420,7 @@ class ChannelGroup : public ::bActionGroup {
|
|||
Span<const FCurve *> fcurves() const;
|
||||
};
|
||||
|
||||
static_assert(sizeof(ChannelGroup) == sizeof(::bActionGroup),
|
||||
static_assert(sizeof(ChannelGroup) == sizeof(bActionGroup),
|
||||
"DNA struct and its C++ wrapper must have the same size");
|
||||
|
||||
/**
|
||||
|
|
@ -1515,7 +1517,7 @@ ActionSlotAssignmentResult assign_action_and_slot(Action *action,
|
|||
*
|
||||
* Same as calling `assign_action(nullptr, animated_id)`.
|
||||
*
|
||||
* \see #blender::animrig::assign_action(ID &animated_id)
|
||||
* \see #animrig::assign_action(ID &animated_id)
|
||||
*/
|
||||
[[nodiscard]] bool unassign_action(ID &animated_id);
|
||||
|
||||
|
|
@ -1524,7 +1526,7 @@ ActionSlotAssignmentResult assign_action_and_slot(Action *action,
|
|||
*
|
||||
* Same as calling `assign_action(nullptr, owned_adt)`.
|
||||
*
|
||||
* \see #blender::animrig::assign_action(OwnedAnimData owned_adt)
|
||||
* \see #animrig::assign_action(OwnedAnimData owned_adt)
|
||||
*/
|
||||
[[nodiscard]] bool unassign_action(OwnedAnimData owned_adt);
|
||||
|
||||
|
|
@ -1623,7 +1625,7 @@ animrig::Channelbag *channelbag_for_action_slot(Action &action, slot_handle_t sl
|
|||
* The use of this function is also an indicator for code that will have to be altered when
|
||||
* multi-layered Actions are getting implemented.
|
||||
*
|
||||
* \see #blender::animrig::legacy::fcurves_for_action_slot
|
||||
* \see #animrig::legacy::fcurves_for_action_slot
|
||||
*/
|
||||
Span<FCurve *> fcurves_for_action_slot(Action &action, slot_handle_t slot_handle);
|
||||
Span<const FCurve *> fcurves_for_action_slot(const Action &action, slot_handle_t slot_handle);
|
||||
|
|
@ -1701,14 +1703,14 @@ FCurve *action_fcurve_ensure_ex(Main *bmain,
|
|||
* All the Action slots are searched for this F-Curve. To limit to a single
|
||||
* slot, use fcurve_find_in_action_slot().
|
||||
*
|
||||
* \see #blender::animrig::fcurve_find_in_action_slot
|
||||
* \see #animrig::fcurve_find_in_action_slot
|
||||
*/
|
||||
FCurve *fcurve_find_in_action(bAction *act, const FCurveDescriptor &fcurve_descriptor);
|
||||
|
||||
/**
|
||||
* Find the F-Curve in the given Action Slot.
|
||||
*
|
||||
* \see #blender::animrig::fcurve_find_in_action
|
||||
* \see #animrig::fcurve_find_in_action
|
||||
*/
|
||||
FCurve *fcurve_find_in_action_slot(bAction *act,
|
||||
slot_handle_t slot_handle,
|
||||
|
|
@ -1717,7 +1719,7 @@ FCurve *fcurve_find_in_action_slot(bAction *act,
|
|||
/**
|
||||
* Find the F-Curve in the Action Slot assigned to this ADT.
|
||||
*
|
||||
* \see #blender::animrig::fcurve_find_in_action
|
||||
* \see #animrig::fcurve_find_in_action
|
||||
*/
|
||||
FCurve *fcurve_find_in_assigned_slot(AnimData &adt, const FCurveDescriptor &fcurve_descriptor);
|
||||
|
||||
|
|
@ -1803,7 +1805,7 @@ void action_fcurve_attach(Action &action,
|
|||
*
|
||||
* \param action_slot_dst: may not be #Slot::unassigned on layered Actions.
|
||||
*
|
||||
* \see #blender::animrig::action_fcurve_detach
|
||||
* \see #animrig::action_fcurve_detach
|
||||
*/
|
||||
void action_fcurve_move(Action &action_dst,
|
||||
slot_handle_t action_slot_dst,
|
||||
|
|
@ -1818,7 +1820,7 @@ void action_fcurve_move(Action &action_dst,
|
|||
*
|
||||
* If the F-Curves belonged to channel groups, the group membership also carries
|
||||
* over to the destination Channelbag. If groups with the same names don't
|
||||
* exist, they are created. \see #blender::animrig::action_fcurve_detach
|
||||
* exist, they are created. \see #animrig::action_fcurve_detach
|
||||
*
|
||||
* The order of existing channel groups in the destination Channelbag are not
|
||||
* changed, and any new groups are placed after those in the order they appeared
|
||||
|
|
@ -1880,7 +1882,7 @@ ID *action_slot_get_id_best_guess(Main &bmain, Slot &slot, ID *primary_id);
|
|||
*
|
||||
* \return The handle of the first slot, or #Slot::unassigned if there is no slot.
|
||||
*/
|
||||
slot_handle_t first_slot_handle(const ::bAction &dna_action);
|
||||
slot_handle_t first_slot_handle(const bAction &dna_action);
|
||||
|
||||
/**
|
||||
* Assert the invariants of Project Baklava phase 1.
|
||||
|
|
@ -1948,69 +1950,71 @@ void deselect_keys_actions(Span<bAction *> actions);
|
|||
*/
|
||||
void action_deselect_keys(Action &action);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
|
||||
/* Wrap functions for the DNA structs. */
|
||||
|
||||
inline blender::animrig::ChannelGroup &bActionGroup::wrap()
|
||||
inline animrig::ChannelGroup &bActionGroup::wrap()
|
||||
{
|
||||
return *reinterpret_cast<blender::animrig::ChannelGroup *>(this);
|
||||
return *reinterpret_cast<animrig::ChannelGroup *>(this);
|
||||
}
|
||||
inline const blender::animrig::ChannelGroup &bActionGroup::wrap() const
|
||||
inline const animrig::ChannelGroup &bActionGroup::wrap() const
|
||||
{
|
||||
return *reinterpret_cast<const blender::animrig::ChannelGroup *>(this);
|
||||
return *reinterpret_cast<const animrig::ChannelGroup *>(this);
|
||||
}
|
||||
|
||||
inline blender::animrig::Action &bAction::wrap()
|
||||
inline animrig::Action &bAction::wrap()
|
||||
{
|
||||
return *reinterpret_cast<blender::animrig::Action *>(this);
|
||||
return *reinterpret_cast<animrig::Action *>(this);
|
||||
}
|
||||
inline const blender::animrig::Action &bAction::wrap() const
|
||||
inline const animrig::Action &bAction::wrap() const
|
||||
{
|
||||
return *reinterpret_cast<const blender::animrig::Action *>(this);
|
||||
return *reinterpret_cast<const animrig::Action *>(this);
|
||||
}
|
||||
|
||||
inline blender::animrig::Layer &ActionLayer::wrap()
|
||||
inline animrig::Layer &ActionLayer::wrap()
|
||||
{
|
||||
return *reinterpret_cast<blender::animrig::Layer *>(this);
|
||||
return *reinterpret_cast<animrig::Layer *>(this);
|
||||
}
|
||||
inline const blender::animrig::Layer &ActionLayer::wrap() const
|
||||
inline const animrig::Layer &ActionLayer::wrap() const
|
||||
{
|
||||
return *reinterpret_cast<const blender::animrig::Layer *>(this);
|
||||
return *reinterpret_cast<const animrig::Layer *>(this);
|
||||
}
|
||||
|
||||
inline blender::animrig::Slot &ActionSlot::wrap()
|
||||
inline animrig::Slot &ActionSlot::wrap()
|
||||
{
|
||||
return *reinterpret_cast<blender::animrig::Slot *>(this);
|
||||
return *reinterpret_cast<animrig::Slot *>(this);
|
||||
}
|
||||
inline const blender::animrig::Slot &ActionSlot::wrap() const
|
||||
inline const animrig::Slot &ActionSlot::wrap() const
|
||||
{
|
||||
return *reinterpret_cast<const blender::animrig::Slot *>(this);
|
||||
return *reinterpret_cast<const animrig::Slot *>(this);
|
||||
}
|
||||
|
||||
inline blender::animrig::Strip &ActionStrip::wrap()
|
||||
inline animrig::Strip &ActionStrip::wrap()
|
||||
{
|
||||
return *reinterpret_cast<blender::animrig::Strip *>(this);
|
||||
return *reinterpret_cast<animrig::Strip *>(this);
|
||||
}
|
||||
inline const blender::animrig::Strip &ActionStrip::wrap() const
|
||||
inline const animrig::Strip &ActionStrip::wrap() const
|
||||
{
|
||||
return *reinterpret_cast<const blender::animrig::Strip *>(this);
|
||||
return *reinterpret_cast<const animrig::Strip *>(this);
|
||||
}
|
||||
|
||||
inline blender::animrig::StripKeyframeData &ActionStripKeyframeData::wrap()
|
||||
inline animrig::StripKeyframeData &ActionStripKeyframeData::wrap()
|
||||
{
|
||||
return *reinterpret_cast<blender::animrig::StripKeyframeData *>(this);
|
||||
return *reinterpret_cast<animrig::StripKeyframeData *>(this);
|
||||
}
|
||||
inline const blender::animrig::StripKeyframeData &ActionStripKeyframeData::wrap() const
|
||||
inline const animrig::StripKeyframeData &ActionStripKeyframeData::wrap() const
|
||||
{
|
||||
return *reinterpret_cast<const blender::animrig::StripKeyframeData *>(this);
|
||||
return *reinterpret_cast<const animrig::StripKeyframeData *>(this);
|
||||
}
|
||||
|
||||
inline blender::animrig::Channelbag &ActionChannelbag::wrap()
|
||||
inline animrig::Channelbag &ActionChannelbag::wrap()
|
||||
{
|
||||
return *reinterpret_cast<blender::animrig::Channelbag *>(this);
|
||||
return *reinterpret_cast<animrig::Channelbag *>(this);
|
||||
}
|
||||
inline const blender::animrig::Channelbag &ActionChannelbag::wrap() const
|
||||
inline const animrig::Channelbag &ActionChannelbag::wrap() const
|
||||
{
|
||||
return *reinterpret_cast<const blender::animrig::Channelbag *>(this);
|
||||
return *reinterpret_cast<const animrig::Channelbag *>(this);
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -13,17 +13,21 @@
|
|||
#include "BLI_function_ref.hh"
|
||||
#include "DNA_action_types.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct FCurve;
|
||||
namespace blender::animrig {
|
||||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
namespace animrig {
|
||||
class Action;
|
||||
class Layer;
|
||||
class Strip;
|
||||
class Channelbag;
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
using slot_handle_t = decltype(::ActionSlot::handle);
|
||||
using slot_handle_t = decltype(blender::ActionSlot::handle);
|
||||
|
||||
/**
|
||||
* Iterates over all FCurves of the Action and executes the callback on it.
|
||||
|
|
@ -71,9 +75,9 @@ bool foreach_action_slot_use(
|
|||
* necessarily the direct action & slot of that ID: they can also be the action
|
||||
* & slot of an Action Constraint or NLA Strip owned by the ID.
|
||||
*
|
||||
* \see blender::animrig::generic_assign_action
|
||||
* \see blender::animrig::generic_assign_action_slot
|
||||
* \see blender::animrig::generic_assign_action_slot_handle
|
||||
* \see animrig::generic_assign_action
|
||||
* \see animrig::generic_assign_action_slot
|
||||
* \see animrig::generic_assign_action_slot_handle
|
||||
*/
|
||||
bool foreach_action_slot_use_with_references(
|
||||
ID &animated_id,
|
||||
|
|
@ -104,4 +108,5 @@ bool foreach_action_slot_use_with_rna(ID &animated_id,
|
|||
PropertyRNA &action_slot_prop,
|
||||
char *last_slot_identifier)> callback);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ Channelbag &channelbag_ensure(Action &action);
|
|||
* inspected to see if this is _really_ the desired behavior, or whether the
|
||||
* F-Curves for a specific slot/layer/strip should be used instead.
|
||||
*
|
||||
* \see #blender::animrig::legacy::fcurves_for_action_slot
|
||||
* \see #animrig::legacy::fcurves_for_action_slot
|
||||
*/
|
||||
Vector<const FCurve *> fcurves_all(const bAction *action);
|
||||
Vector<FCurve *> fcurves_all(bAction *action);
|
||||
|
|
@ -75,10 +75,10 @@ Vector<FCurve *> fcurves_first_slot(bAction *action);
|
|||
*
|
||||
* The use of this function is an indicator for code that can be simplified when the slotted
|
||||
* Actions feature is no longer experimental. When that switchover happens, calls to this function
|
||||
* can be replaced with the more efficient `blender::animrig::fcurves_for_action_slot()`.
|
||||
* can be replaced with the more efficient `animrig::fcurves_for_action_slot()`.
|
||||
*
|
||||
* \see #blender::animrig::fcurves_for_action_slot
|
||||
* \see #blender::animrig::legacy::fcurves_all
|
||||
* \see #animrig::fcurves_for_action_slot
|
||||
* \see #animrig::legacy::fcurves_all
|
||||
*/
|
||||
Vector<FCurve *> fcurves_for_action_slot(bAction *action, slot_handle_t slot_handle);
|
||||
Vector<const FCurve *> fcurves_for_action_slot(const bAction *action, slot_handle_t slot_handle);
|
||||
|
|
@ -111,7 +111,7 @@ bool assigned_action_has_keyframes(AnimData *adt);
|
|||
* This works for both legacy and layered Actions. For the latter, it will
|
||||
* return all channel groups for all slots/layers/strips.
|
||||
*
|
||||
* \see #blender::animrig::legacy::channel_groups_for_assigned_slot
|
||||
* \see #animrig::legacy::channel_groups_for_assigned_slot
|
||||
*/
|
||||
Vector<bActionGroup *> channel_groups_all(bAction *action);
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ Vector<bActionGroup *> channel_groups_all(bAction *action);
|
|||
* This works for both legacy and layered Actions. For the former, this function
|
||||
* acts identical to channel_groups_all().
|
||||
*
|
||||
* \see #blender::animrig::legacy::channel_groups_all
|
||||
* \see #animrig::legacy::channel_groups_all
|
||||
*/
|
||||
Vector<bActionGroup *> channel_groups_for_assigned_slot(AnimData *adt);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
#include "BLI_string_ref.hh"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct ID;
|
||||
struct Main;
|
||||
|
||||
|
|
@ -20,7 +22,7 @@ struct AnimData;
|
|||
struct FCurve;
|
||||
struct bAction;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
class Action;
|
||||
|
||||
|
|
@ -79,4 +81,5 @@ const FCurve *fcurve_find_by_rna_path(const AnimData &adt,
|
|||
StringRefNull rna_path,
|
||||
int array_index);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace blender::animrig {
|
|||
*/
|
||||
template<typename CB> static void ANIM_armature_foreach_bone(ListBaseT<Bone> *bones, CB callback)
|
||||
{
|
||||
for (Bone *bone : blender::ListBaseWrapper<Bone>(bones)) {
|
||||
for (Bone *bone : ListBaseWrapper<Bone>(bones)) {
|
||||
callback(bone);
|
||||
ANIM_armature_foreach_bone(&bone->childbase, callback);
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ template<typename CB> static void ANIM_armature_foreach_bone(ListBaseT<Bone> *bo
|
|||
template<typename CB>
|
||||
static void ANIM_armature_foreach_bone(const ListBaseT<Bone> *bones, CB callback)
|
||||
{
|
||||
for (const Bone *bone : blender::ConstListBaseWrapper<Bone>(bones)) {
|
||||
for (const Bone *bone : ConstListBaseWrapper<Bone>(bones)) {
|
||||
callback(bone);
|
||||
ANIM_armature_foreach_bone(&bone->childbase, callback);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
#include "DNA_action_types.h"
|
||||
#include "DNA_armature_types.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct bArmature;
|
||||
struct Bone;
|
||||
struct BoneCollection;
|
||||
|
|
@ -168,7 +170,7 @@ bool ANIM_armature_bonecoll_is_editable(const bArmature *armature, const BoneCol
|
|||
*
|
||||
* TODO: add ASCII-art illustration of left & right movement.
|
||||
*
|
||||
* \see blender::animrig::armature_bonecoll_move_to_parent() to move bone
|
||||
* \see animrig::armature_bonecoll_move_to_parent() to move bone
|
||||
* collections between different parents.
|
||||
*/
|
||||
bool ANIM_armature_bonecoll_move_to_index(bArmature *armature, int from_index, int to_index);
|
||||
|
|
@ -191,7 +193,7 @@ int ANIM_armature_bonecoll_move_before_after_index(bArmature *armature,
|
|||
* \note This function is limited to moving between siblings of the bone
|
||||
* collection at `from_index`.
|
||||
*
|
||||
* \see blender::animrig::armature_bonecoll_move_to_parent() to move bone
|
||||
* \see animrig::armature_bonecoll_move_to_parent() to move bone
|
||||
* collections between different parents.
|
||||
*/
|
||||
bool ANIM_armature_bonecoll_move(bArmature *armature, BoneCollection *bcoll, int step);
|
||||
|
|
@ -309,7 +311,7 @@ bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone
|
|||
* Returns true when the edit-bone's collection is visible.
|
||||
*
|
||||
* \note This alone is not enough to check bone visibility since the user may have hidden the bone.
|
||||
* Use `blender::animrig::bone_is_visible` to check bone visibility.
|
||||
* Use `animrig::bone_is_visible` to check bone visibility.
|
||||
*/
|
||||
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone);
|
||||
|
||||
|
|
@ -330,13 +332,13 @@ void ANIM_armature_bonecoll_show_from_bone(bArmature *armature, const Bone *bone
|
|||
void ANIM_armature_bonecoll_show_from_ebone(bArmature *armature, const EditBone *ebone);
|
||||
void ANIM_armature_bonecoll_show_from_pchan(bArmature *armature, const bPoseChannel *pchan);
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/**
|
||||
* Return the index of the given collection in the armature's collection array,
|
||||
* or -1 if not found.
|
||||
*/
|
||||
int armature_bonecoll_find_index(const bArmature *armature, const ::BoneCollection *bcoll);
|
||||
int armature_bonecoll_find_index(const bArmature *armature, const BoneCollection *bcoll);
|
||||
|
||||
/**
|
||||
* Return the index of the given bone collection's parent, or -1 if it has no parent.
|
||||
|
|
@ -351,7 +353,7 @@ int armature_bonecoll_find_parent_index(const bArmature *armature, int bcoll_ind
|
|||
*
|
||||
* This requires a scan of the array, hence the function is called 'find' and not 'get'.
|
||||
*/
|
||||
int armature_bonecoll_child_number_find(const bArmature *armature, const ::BoneCollection *bcoll);
|
||||
int armature_bonecoll_child_number_find(const bArmature *armature, const BoneCollection *bcoll);
|
||||
|
||||
/**
|
||||
* Move this bone collection to a new child number.
|
||||
|
|
@ -362,7 +364,7 @@ int armature_bonecoll_child_number_find(const bArmature *armature, const ::BoneC
|
|||
* \see armature_bonecoll_child_number_find
|
||||
*/
|
||||
int armature_bonecoll_child_number_set(bArmature *armature,
|
||||
::BoneCollection *bcoll,
|
||||
BoneCollection *bcoll,
|
||||
int new_child_number);
|
||||
|
||||
bool armature_bonecoll_is_root(const bArmature *armature, int bcoll_index);
|
||||
|
|
@ -464,4 +466,5 @@ void ANIM_bonecoll_array_free(BoneCollection ***bcoll_array,
|
|||
int *bcoll_array_num,
|
||||
bool do_id_user);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -16,13 +16,15 @@
|
|||
|
||||
#include "DNA_armature_types.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct bPoseChannel;
|
||||
struct ThemeWireColor;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/** C++ wrapper for the DNA BoneColor struct. */
|
||||
class BoneColor : public ::BoneColor {
|
||||
class BoneColor : public blender::BoneColor {
|
||||
public:
|
||||
BoneColor();
|
||||
BoneColor(const BoneColor &other);
|
||||
|
|
@ -30,7 +32,7 @@ class BoneColor : public ::BoneColor {
|
|||
|
||||
const ThemeWireColor *effective_color() const;
|
||||
|
||||
/* Support for storing in a #blender::Set<BoneColor>. */
|
||||
/* Support for storing in a #Set<BoneColor>. */
|
||||
bool operator==(const BoneColor &other) const;
|
||||
bool operator!=(const BoneColor &other) const;
|
||||
uint64_t hash() const;
|
||||
|
|
@ -44,4 +46,6 @@ class BoneColor : public ::BoneColor {
|
|||
*/
|
||||
const BoneColor &ANIM_bonecolor_posebone_get(const bPoseChannel *pose_bone);
|
||||
|
||||
}; // namespace blender::animrig
|
||||
}; // namespace animrig
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct AnimationEvalContext;
|
||||
struct FCurve;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/** Evaluates the driver on the frame given in `anim_eval_context` and returns the value. Returns 0
|
||||
* if the RNA path can't be resolved. */
|
||||
|
|
@ -22,4 +24,5 @@ float evaluate_driver_from_rna_pointer(const AnimationEvalContext *anim_eval_con
|
|||
PropertyRNA *prop,
|
||||
const FCurve *fcu);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -16,10 +16,12 @@
|
|||
|
||||
#include "DNA_anim_types.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct AnimData;
|
||||
struct FCurve;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/**
|
||||
* All the information needed to look up or create an FCurve.
|
||||
|
|
@ -158,7 +160,7 @@ enum class BakeCurveRemove {
|
|||
* \param range: start and end frame to bake. Is inclusive on both ends.
|
||||
* \param remove_existing: choice which keys to remove in relation to the given range.
|
||||
*/
|
||||
void bake_fcurve(FCurve *fcu, blender::int2 range, float step, BakeCurveRemove remove_existing);
|
||||
void bake_fcurve(FCurve *fcu, int2 range, float step, BakeCurveRemove remove_existing);
|
||||
|
||||
/**
|
||||
* Fill the space between selected keyframes with keyframes on full frames.
|
||||
|
|
@ -175,4 +177,5 @@ void bake_fcurve_segments(FCurve *fcu);
|
|||
*/
|
||||
bool fcurve_frame_has_keyframe(const FCurve *fcu, float frame);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#include "RNA_path.hh"
|
||||
#include "RNA_types.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct ID;
|
||||
struct Main;
|
||||
struct Scene;
|
||||
|
|
@ -29,7 +31,7 @@ struct Scene;
|
|||
struct AnimationEvalContext;
|
||||
struct NlaKeyframingContext;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/**
|
||||
* Represents a single success/failure in the keyframing process.
|
||||
|
|
@ -285,4 +287,5 @@ bool autokeyframe_property(bContext *C,
|
|||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include "RNA_types.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct KeyingSet;
|
||||
struct ExtensionRNA;
|
||||
/* Forward declaration for this struct which is declared a bit later. */
|
||||
|
|
@ -75,7 +77,7 @@ struct KeyingSetInfo {
|
|||
ExtensionRNA rna_ext;
|
||||
};
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/** Mode for modify_keyframes. */
|
||||
enum class ModifyKeyMode {
|
||||
|
|
@ -186,4 +188,5 @@ void relative_keyingset_add_source(Vector<PointerRNA> &sources, ID *id);
|
|||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -10,17 +10,19 @@
|
|||
|
||||
#include "ANIM_action.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct ID;
|
||||
struct NlaStrip;
|
||||
|
||||
namespace blender::animrig::nla {
|
||||
namespace animrig::nla {
|
||||
|
||||
/**
|
||||
* Assign the Action to this NLA strip.
|
||||
*
|
||||
* Similar to animrig::assign_action(), this tries to find a suitable slot.
|
||||
*
|
||||
* \see blender::animrig::assign_action
|
||||
* \see animrig::assign_action
|
||||
*
|
||||
* \returns whether the assignment was ok.
|
||||
*/
|
||||
|
|
@ -44,4 +46,5 @@ ActionSlotAssignmentResult assign_action_slot_handle(NlaStrip &strip,
|
|||
slot_handle_t slot_handle,
|
||||
ID &animated_id);
|
||||
|
||||
} // namespace blender::animrig::nla
|
||||
} // namespace animrig::nla
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@
|
|||
#include "ANIM_action.hh"
|
||||
#include "BLI_span.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct AnimationEvalContext;
|
||||
struct Object;
|
||||
struct bAction;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/**
|
||||
* Evaluate the action and apply it to the pose. Ignore selection state of the bones.
|
||||
|
|
@ -67,4 +69,5 @@ bool any_bone_selected(Span<const Object *> objects);
|
|||
* Assumes that the Action has at least one Slot.
|
||||
*/
|
||||
Slot &get_best_pose_slot_for_id(const ID &id, Action &pose_data);
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -15,10 +15,12 @@
|
|||
|
||||
#include "RNA_path.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/** Get the values of the given property. Casts non-float properties to float. */
|
||||
Vector<float> get_rna_values(PointerRNA *ptr, PropertyRNA *prop);
|
||||
|
|
@ -32,4 +34,5 @@ StringRef get_rotation_mode_path(eRotationModes rotation_mode);
|
|||
*/
|
||||
Vector<RNAPath> get_keyable_id_property_paths(const PointerRNA &ptr);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -9,17 +9,19 @@
|
|||
* in the versioning_xxx.cc files, but some is broken out and placed here.
|
||||
*/
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct bAction;
|
||||
struct BlendFileReadReport;
|
||||
struct ID;
|
||||
struct Main;
|
||||
struct ReportList;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
class Action;
|
||||
}
|
||||
|
||||
namespace blender::animrig::versioning {
|
||||
namespace animrig::versioning {
|
||||
|
||||
/**
|
||||
* Return whether an action is layered (as opposed to legacy).
|
||||
|
|
@ -78,4 +80,5 @@ void tag_action_user_for_slotted_actions_conversion(ID &animated_id);
|
|||
*/
|
||||
void convert_legacy_action_assignments(Main &bmain, ReportList *reports);
|
||||
|
||||
} // namespace blender::animrig::versioning
|
||||
} // namespace animrig::versioning
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -10,10 +10,12 @@
|
|||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct PointerRNA;
|
||||
struct PropertyRNA;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/**
|
||||
* This helper function determines if visual-keyframing should be used when
|
||||
|
|
@ -31,4 +33,5 @@ bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop);
|
|||
*/
|
||||
Vector<float> visualkey_get_values(PointerRNA *ptr, PropertyRNA *prop);
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -52,9 +52,11 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
namespace blender {
|
||||
|
||||
static CLG_LogRef LOG = {"anim.action"};
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
namespace {
|
||||
/**
|
||||
|
|
@ -89,7 +91,7 @@ template<typename T> static void grow_array(T **array, int *num, const int add_n
|
|||
const int new_array_num = *num + add_num;
|
||||
T *new_array = MEM_calloc_arrayN<T>(new_array_num, "animrig::action/grow_array");
|
||||
|
||||
blender::uninitialized_relocate_n(*array, *num, new_array);
|
||||
uninitialized_relocate_n(*array, *num, new_array);
|
||||
MEM_SAFE_FREE(*array);
|
||||
|
||||
*array = new_array;
|
||||
|
|
@ -109,9 +111,9 @@ static void grow_array_and_insert(T **array, int *num, const int index, T item)
|
|||
const int new_array_num = *num + 1;
|
||||
T *new_array = MEM_calloc_arrayN<T>(new_array_num, __func__);
|
||||
|
||||
blender::uninitialized_relocate_n(*array, index, new_array);
|
||||
uninitialized_relocate_n(*array, index, new_array);
|
||||
new_array[index] = item;
|
||||
blender::uninitialized_relocate_n(*array + index, *num - index, new_array + index + 1);
|
||||
uninitialized_relocate_n(*array + index, *num - index, new_array + index + 1);
|
||||
|
||||
MEM_SAFE_FREE(*array);
|
||||
|
||||
|
|
@ -132,7 +134,7 @@ template<typename T> static void shrink_array(T **array, int *num, const int shr
|
|||
|
||||
T *new_array = MEM_calloc_arrayN<T>(new_array_num, __func__);
|
||||
|
||||
blender::uninitialized_move_n(*array, new_array_num, new_array);
|
||||
uninitialized_move_n(*array, new_array_num, new_array);
|
||||
MEM_freeN(*array);
|
||||
|
||||
*array = new_array;
|
||||
|
|
@ -145,8 +147,8 @@ template<typename T> static void shrink_array_and_remove(T **array, int *num, co
|
|||
const int new_array_num = *num - 1;
|
||||
T *new_array = MEM_calloc_arrayN<T>(new_array_num, __func__);
|
||||
|
||||
blender::uninitialized_move_n(*array, index, new_array);
|
||||
blender::uninitialized_move_n(*array + index + 1, *num - index - 1, new_array + index);
|
||||
uninitialized_move_n(*array, index, new_array);
|
||||
uninitialized_move_n(*array + index + 1, *num - index - 1, new_array + index);
|
||||
MEM_freeN(*array);
|
||||
|
||||
*array = new_array;
|
||||
|
|
@ -164,10 +166,10 @@ template<typename T> static void shrink_array_and_swap_remove(T **array, int *nu
|
|||
const int new_array_num = *num - 1;
|
||||
T *new_array = MEM_calloc_arrayN<T>(new_array_num, __func__);
|
||||
|
||||
blender::uninitialized_move_n(*array, index, new_array);
|
||||
uninitialized_move_n(*array, index, new_array);
|
||||
if (index < new_array_num) {
|
||||
new_array[index] = (*array)[new_array_num];
|
||||
blender::uninitialized_move_n(*array + index + 1, *num - index - 2, new_array + index + 1);
|
||||
uninitialized_move_n(*array + index + 1, *num - index - 2, new_array + index + 1);
|
||||
}
|
||||
MEM_freeN(*array);
|
||||
|
||||
|
|
@ -262,7 +264,8 @@ Layer &Action::layer_add(const std::optional<StringRefNull> name)
|
|||
STRNCPY_UTF8(new_layer.name, DATA_(layer_default_name));
|
||||
}
|
||||
|
||||
grow_array_and_append<::ActionLayer *>(&this->layer_array, &this->layer_array_num, &new_layer);
|
||||
grow_array_and_append<blender::ActionLayer *>(
|
||||
&this->layer_array, &this->layer_array_num, &new_layer);
|
||||
this->layer_active_index = this->layer_array_num - 1;
|
||||
|
||||
/* If this is the first layer in this Action, it means that it could have been
|
||||
|
|
@ -506,7 +509,7 @@ Slot &Action::slot_add()
|
|||
BLI_strncpy_utf8(slot.identifier + 2, DATA_(slot_default_name), ARRAY_SIZE(slot.identifier) - 2);
|
||||
|
||||
/* Append the Slot to the Action. */
|
||||
grow_array_and_append<::ActionSlot *>(&this->slot_array, &this->slot_array_num, &slot);
|
||||
grow_array_and_append<blender::ActionSlot *>(&this->slot_array, &this->slot_array_num, &slot);
|
||||
|
||||
slot_identifier_ensure_unique(*this, slot);
|
||||
|
||||
|
|
@ -937,7 +940,8 @@ Strip &Layer::strip_add(Action &owning_action, const Strip::Type strip_type)
|
|||
Strip &strip = Strip::create(owning_action, strip_type);
|
||||
|
||||
/* Add the new strip to the strip array. */
|
||||
grow_array_and_append<::ActionStrip *>(&this->strip_array, &this->strip_array_num, &strip);
|
||||
grow_array_and_append<blender::ActionStrip *>(
|
||||
&this->strip_array, &this->strip_array_num, &strip);
|
||||
|
||||
return strip;
|
||||
}
|
||||
|
|
@ -2911,7 +2915,7 @@ ID *action_slot_get_id_best_guess(Main &bmain, Slot &slot, ID *primary_id)
|
|||
return users[0];
|
||||
}
|
||||
|
||||
slot_handle_t first_slot_handle(const ::bAction &dna_action)
|
||||
slot_handle_t first_slot_handle(const blender::bAction &dna_action)
|
||||
{
|
||||
const Action &action = dna_action.wrap();
|
||||
if (action.slot_array_num == 0) {
|
||||
|
|
@ -3109,4 +3113,5 @@ Slot &duplicate_slot(Action &action, const Slot &slot)
|
|||
return cloned_slot;
|
||||
}
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@
|
|||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct ID;
|
||||
struct Main;
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
/**
|
||||
* Not placed in the 'internal' namespace, as this type is forward-declared in
|
||||
|
|
@ -54,4 +56,5 @@ void rebuild_slot_user_cache(Main &bmain);
|
|||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
#include <cstring>
|
||||
|
||||
namespace blender {
|
||||
|
||||
using std::strcmp;
|
||||
|
||||
using namespace blender::animrig;
|
||||
|
|
@ -127,7 +129,7 @@ static void bonecoll_ensure_name_unique(bArmature *armature, BoneCollection *bco
|
|||
{
|
||||
/* Cannot capture armature & bcoll by reference in the lambda, as that would change its signature
|
||||
* and no longer be compatible with BLI_uniquename_cb(). */
|
||||
auto bonecoll_name_is_duplicate = [&](const blender::StringRef name) -> bool {
|
||||
auto bonecoll_name_is_duplicate = [&](const StringRef name) -> bool {
|
||||
for (BoneCollection *bcoll_iter : armature->collections_span()) {
|
||||
if (bcoll_iter != bcoll && bcoll_iter->name == name) {
|
||||
return true;
|
||||
|
|
@ -165,7 +167,7 @@ static void bonecoll_insert_at_index(bArmature *armature, BoneCollection *bcoll,
|
|||
armature->collection_array_num++;
|
||||
|
||||
const int rotate_count = armature->collection_array_num - index - 1;
|
||||
internal::bonecolls_rotate_block(armature, index, rotate_count, +1);
|
||||
animrig::internal::bonecolls_rotate_block(armature, index, rotate_count, +1);
|
||||
|
||||
if (armature->runtime.active_collection_index >= index) {
|
||||
ANIM_armature_bonecoll_active_index_set(armature,
|
||||
|
|
@ -494,7 +496,7 @@ bool ANIM_armature_bonecoll_move_to_index(bArmature *armature,
|
|||
|
||||
if (parent_index < 0) {
|
||||
/* Roots can just be moved around, as there is no `child_index` to update in this case. */
|
||||
internal::bonecolls_move_to_index(armature, from_index, to_index);
|
||||
animrig::internal::bonecolls_move_to_index(armature, from_index, to_index);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -503,7 +505,7 @@ bool ANIM_armature_bonecoll_move_to_index(bArmature *armature,
|
|||
BoneCollection *parent_bcoll = armature->collection_array[parent_index];
|
||||
const int old_parent_child_index = parent_bcoll->child_index;
|
||||
|
||||
internal::bonecolls_move_to_index(armature, from_index, to_index);
|
||||
animrig::internal::bonecolls_move_to_index(armature, from_index, to_index);
|
||||
|
||||
parent_bcoll->child_index = old_parent_child_index;
|
||||
|
||||
|
|
@ -636,11 +638,11 @@ void ANIM_armature_bonecoll_remove_from_index(bArmature *armature, int index)
|
|||
);
|
||||
|
||||
/* Both 'index' and 'parent_bcoll_index' can change each iteration. */
|
||||
index = internal::bonecolls_find_index_near(armature, bcoll, index);
|
||||
index = animrig::internal::bonecolls_find_index_near(armature, bcoll, index);
|
||||
BLI_assert_msg(index >= 0, "could not find bone collection after moving things around");
|
||||
|
||||
if (parent_bcoll_index >= 0) { /* If there is no parent, its index should stay -1. */
|
||||
parent_bcoll_index = internal::bonecolls_find_index_near(
|
||||
parent_bcoll_index = animrig::internal::bonecolls_find_index_near(
|
||||
armature, parent_bcoll, parent_bcoll_index);
|
||||
BLI_assert_msg(parent_bcoll_index >= 0,
|
||||
"could not find bone collection parent after moving things around");
|
||||
|
|
@ -663,7 +665,7 @@ void ANIM_armature_bonecoll_remove_from_index(bArmature *armature, int index)
|
|||
}
|
||||
|
||||
/* Rotate the to-be-removed collection to the last array element. */
|
||||
internal::bonecolls_move_to_index(armature, index, armature->collection_array_num - 1);
|
||||
animrig::internal::bonecolls_move_to_index(armature, index, armature->collection_array_num - 1);
|
||||
|
||||
/* NOTE: we don't bother to shrink the allocation. It's okay if the
|
||||
* capacity has extra space, because the number of valid items is tracked. */
|
||||
|
|
@ -695,7 +697,7 @@ void ANIM_armature_bonecoll_remove_from_index(bArmature *armature, int index)
|
|||
}
|
||||
|
||||
const bool is_solo = bcoll->is_solo();
|
||||
internal::bonecoll_unassign_and_free(armature, bcoll);
|
||||
animrig::internal::bonecoll_unassign_and_free(armature, bcoll);
|
||||
if (is_solo) {
|
||||
/* This might have been the last solo'ed bone collection, so check whether
|
||||
* solo'ing should still be active on the armature. */
|
||||
|
|
@ -711,8 +713,8 @@ void ANIM_armature_bonecoll_remove(bArmature *armature, BoneCollection *bcoll)
|
|||
}
|
||||
|
||||
template<typename MaybeConstBoneCollection>
|
||||
static MaybeConstBoneCollection *bonecolls_get_by_name(
|
||||
blender::Span<MaybeConstBoneCollection *> bonecolls, const char *name)
|
||||
static MaybeConstBoneCollection *bonecolls_get_by_name(Span<MaybeConstBoneCollection *> bonecolls,
|
||||
const char *name)
|
||||
{
|
||||
for (MaybeConstBoneCollection *bcoll : bonecolls) {
|
||||
if (STREQ(bcoll->name, name)) {
|
||||
|
|
@ -1113,7 +1115,7 @@ void ANIM_armature_bonecoll_show_from_pchan(bArmature *armature, const bPoseChan
|
|||
|
||||
/* ********* */
|
||||
/* C++ only. */
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
int armature_bonecoll_find_index(const bArmature *armature, const BoneCollection *bcoll)
|
||||
{
|
||||
|
|
@ -1149,7 +1151,8 @@ int armature_bonecoll_find_parent_index(const bArmature *armature, const int bco
|
|||
return -1;
|
||||
}
|
||||
|
||||
int armature_bonecoll_child_number_find(const bArmature *armature, const ::BoneCollection *bcoll)
|
||||
int armature_bonecoll_child_number_find(const bArmature *armature,
|
||||
const blender::BoneCollection *bcoll)
|
||||
{
|
||||
const int bcoll_index = armature_bonecoll_find_index(armature, bcoll);
|
||||
const int parent_index = armature_bonecoll_find_parent_index(armature, bcoll_index);
|
||||
|
|
@ -1157,7 +1160,7 @@ int armature_bonecoll_child_number_find(const bArmature *armature, const ::BoneC
|
|||
}
|
||||
|
||||
int armature_bonecoll_child_number_set(bArmature *armature,
|
||||
::BoneCollection *bcoll,
|
||||
blender::BoneCollection *bcoll,
|
||||
int new_child_number)
|
||||
{
|
||||
const int bcoll_index = armature_bonecoll_find_index(armature, bcoll);
|
||||
|
|
@ -1186,7 +1189,7 @@ int armature_bonecoll_child_number_set(bArmature *armature,
|
|||
* (bonecolls_move_to_index() will keep it pointing at that first child). */
|
||||
const int old_parent_child_index = parent_bcoll->child_index;
|
||||
const int to_index = parent_bcoll->child_index + new_child_number;
|
||||
internal::bonecolls_move_to_index(armature, bcoll_index, to_index);
|
||||
animrig::internal::bonecolls_move_to_index(armature, bcoll_index, to_index);
|
||||
|
||||
parent_bcoll->child_index = old_parent_child_index;
|
||||
|
||||
|
|
@ -1353,7 +1356,7 @@ int armature_bonecoll_move_to_parent(bArmature *armature,
|
|||
/* bonecolls_move_to_index() will try and keep the hierarchy correct, and thus change
|
||||
* to_parent->child_index to keep pointing to its current-first child. */
|
||||
const bool becomes_new_first_child = to_child_num == 0 || to_parent->child_count == 0;
|
||||
internal::bonecolls_move_to_index(armature, from_bcoll_index, to_bcoll_index);
|
||||
animrig::internal::bonecolls_move_to_index(armature, from_bcoll_index, to_bcoll_index);
|
||||
|
||||
/* Update child index & count of the old parent. */
|
||||
from_parent->child_count--;
|
||||
|
|
@ -1593,4 +1596,5 @@ void bonecoll_unassign_and_free(bArmature *armature, BoneCollection *bcoll)
|
|||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -11,10 +11,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct bArmature;
|
||||
struct BoneCollection;
|
||||
|
||||
namespace blender::animrig::internal {
|
||||
namespace animrig::internal {
|
||||
|
||||
/**
|
||||
* Move a block of BoneCollections in the Armature's `collections_array`, from
|
||||
|
|
@ -68,4 +70,5 @@ void bonecolls_debug_list(const bArmature *armature);
|
|||
*/
|
||||
void bonecoll_unassign_and_free(bArmature *armature, BoneCollection *bcoll);
|
||||
|
||||
} // namespace blender::animrig::internal
|
||||
} // namespace animrig::internal
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const ThemeWireColor *BoneColor::effective_color() const
|
|||
return &this->custom;
|
||||
}
|
||||
|
||||
const bTheme *btheme = blender::ui::theme::theme_get();
|
||||
const bTheme *btheme = ui::theme::theme_get();
|
||||
return &btheme->tarm[(color_index - 1)];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@
|
|||
|
||||
#include "evaluation_internal.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static CLG_LogRef LOG = {"anim.evaluation"};
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
using namespace internal;
|
||||
|
||||
|
|
@ -325,4 +327,5 @@ EvaluationResult evaluate_layer(PointerRNA &animated_id_ptr,
|
|||
|
||||
} // namespace internal
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "ANIM_evaluation.hh"
|
||||
struct Action;
|
||||
struct Layer;
|
||||
namespace blender {
|
||||
|
||||
struct AnimationEvalContext;
|
||||
struct PointerRNA;
|
||||
struct Action;
|
||||
struct Layer;
|
||||
|
||||
namespace blender::animrig::internal {
|
||||
namespace animrig::internal {
|
||||
|
||||
/**
|
||||
* Evaluate the animation data on the given layer, for the given slot. This
|
||||
|
|
@ -24,4 +24,5 @@ EvaluationResult evaluate_layer(PointerRNA &animated_id_ptr,
|
|||
slot_handle_t slot_handle,
|
||||
const AnimationEvalContext &anim_eval_context);
|
||||
|
||||
} // namespace blender::animrig::internal
|
||||
} // namespace animrig::internal
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -665,8 +665,7 @@ void bake_fcurve_segments(FCurve *fcu)
|
|||
|
||||
/* Add keyframes with these, tagging as 'breakdowns'. */
|
||||
for (n = 1, fp = value_cache; n < range && fp; n++, fp++) {
|
||||
blender::animrig::insert_vert_fcurve(
|
||||
fcu, {fp->frame, fp->val}, settings, INSERTKEY_NOFLAGS);
|
||||
animrig::insert_vert_fcurve(fcu, {fp->frame, fp->val}, settings, INSERTKEY_NOFLAGS);
|
||||
}
|
||||
|
||||
MEM_freeN(value_cache);
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ static bool assigned_action_has_keyframe_at(AnimData &adt, const float frame)
|
|||
return false;
|
||||
}
|
||||
|
||||
for (FCurve *fcu : blender::animrig::legacy::fcurves_for_assigned_action(&adt)) {
|
||||
for (FCurve *fcu : animrig::legacy::fcurves_for_assigned_action(&adt)) {
|
||||
if (fcurve_frame_has_keyframe(fcu, frame)) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -314,7 +314,7 @@ bool id_frame_has_keyframe(ID *id, float frame)
|
|||
/* Perform special checks for 'macro' types. */
|
||||
switch (GS(id->name)) {
|
||||
case ID_OB:
|
||||
return object_frame_has_keyframe(blender::id_cast<Object *>(id), frame);
|
||||
return object_frame_has_keyframe(id_cast<Object *>(id), frame);
|
||||
|
||||
default: {
|
||||
AnimData *adt = BKE_animdata_from_id(id);
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ void autokeyframe_pose_channel(bContext *C,
|
|||
Main *bmain = CTX_data_main(C);
|
||||
ID *id = &ob->id;
|
||||
|
||||
if (!blender::animrig::autokeyframe_cfra_can_key(scene, id)) {
|
||||
if (!animrig::autokeyframe_cfra_can_key(scene, id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ class KeyframingTest : public testing::Test {
|
|||
BLI_addtail(&armature->bonebase, bone);
|
||||
|
||||
armature_object = BKE_object_add_only_object(bmain, OB_ARMATURE, "Armature");
|
||||
armature_object->data = blender::id_cast<ID *>(armature);
|
||||
armature_object->data = id_cast<ID *>(armature);
|
||||
BKE_pose_ensure(bmain, armature_object, armature, false);
|
||||
armature_object_rna_pointer = RNA_id_pointer_create(&armature_object->id);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,13 @@
|
|||
|
||||
#include "WM_api.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
/* Keying Set Type Info declarations. */
|
||||
static ListBaseT<KeyingSetInfo> keyingset_type_infos = {nullptr, nullptr};
|
||||
ListBaseT<KeyingSet> builtin_keyingsets = {nullptr, nullptr};
|
||||
|
||||
namespace blender::animrig {
|
||||
namespace animrig {
|
||||
|
||||
void keyingset_info_register(KeyingSetInfo *keyingset_info)
|
||||
{
|
||||
|
|
@ -459,4 +461,5 @@ int apply_keyingset(bContext *C,
|
|||
return keyed_channels;
|
||||
}
|
||||
|
||||
} // namespace blender::animrig
|
||||
} // namespace animrig
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -33,9 +33,7 @@ void pose_apply_restore_fcurves(const Span<FCurve *> fcurves)
|
|||
|
||||
/* Returns a vector of all FCurves on which the fcurve flag was modified. */
|
||||
Vector<FCurve *> pose_apply_disable_fcurves_for_unselected_bones(
|
||||
bAction *action,
|
||||
const slot_handle_t slot_handle,
|
||||
const blender::bke::BoneNameSet &selected_bone_names)
|
||||
bAction *action, const slot_handle_t slot_handle, const bke::BoneNameSet &selected_bone_names)
|
||||
{
|
||||
Vector<FCurve *> modified_fcurves;
|
||||
auto disable_unselected_fcurve = [&](FCurve *fcu, const char *bone_name) {
|
||||
|
|
@ -48,7 +46,7 @@ Vector<FCurve *> pose_apply_disable_fcurves_for_unselected_bones(
|
|||
fcu->flag |= FCURVE_DISABLED;
|
||||
}
|
||||
};
|
||||
blender::bke::BKE_action_find_fcurves_with_bones(action, slot_handle, disable_unselected_fcurve);
|
||||
bke::BKE_action_find_fcurves_with_bones(action, slot_handle, disable_unselected_fcurve);
|
||||
return modified_fcurves;
|
||||
}
|
||||
|
||||
|
|
@ -67,8 +65,7 @@ void pose_apply(Object *ob,
|
|||
return;
|
||||
}
|
||||
|
||||
const blender::bke::BoneNameSet selected_bone_names =
|
||||
blender::bke::BKE_pose_channel_find_selected_names(ob);
|
||||
const bke::BoneNameSet selected_bone_names = bke::BKE_pose_channel_find_selected_names(ob);
|
||||
|
||||
/* Mute all FCurves that are not associated with selected bones. This separates the concept of
|
||||
* bone selection from the FCurve evaluation code. */
|
||||
|
|
|
|||
|
|
@ -24,10 +24,12 @@
|
|||
#include "CLG_log.h"
|
||||
#include "testing/testing.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
constexpr char msg_unexpected_modification[] =
|
||||
"Properties not stored in the pose are expected to not be modified.";
|
||||
|
||||
namespace blender::animrig::tests {
|
||||
namespace animrig::tests {
|
||||
|
||||
class PoseTest : public testing::Test {
|
||||
public:
|
||||
|
|
@ -37,8 +39,7 @@ class PoseTest : public testing::Test {
|
|||
Object *obj_armature_a;
|
||||
Object *obj_armature_b;
|
||||
StripKeyframeData *keyframe_data;
|
||||
const blender::animrig::KeyframeSettings key_settings = {
|
||||
BEZT_KEYTYPE_KEYFRAME, HD_AUTO, BEZT_IPO_BEZ};
|
||||
const animrig::KeyframeSettings key_settings = {BEZT_KEYTYPE_KEYFRAME, HD_AUTO, BEZT_IPO_BEZ};
|
||||
|
||||
static void SetUpTestSuite()
|
||||
{
|
||||
|
|
@ -67,7 +68,7 @@ class PoseTest : public testing::Test {
|
|||
obj_armature_b = BKE_object_add_only_object(bmain, OB_ARMATURE, "obj_armature_b");
|
||||
|
||||
bArmature *armature = BKE_armature_add(bmain, "ArmatureA");
|
||||
obj_armature_a->data = blender::id_cast<ID *>(armature);
|
||||
obj_armature_a->data = id_cast<ID *>(armature);
|
||||
|
||||
Bone *bone = MEM_new_for_free<Bone>("BONE");
|
||||
STRNCPY(bone->name, "BoneA");
|
||||
|
|
@ -80,7 +81,7 @@ class PoseTest : public testing::Test {
|
|||
BKE_pose_ensure(bmain, obj_armature_a, armature, false);
|
||||
|
||||
armature = BKE_armature_add(bmain, "ArmatureB");
|
||||
obj_armature_b->data = blender::id_cast<ID *>(armature);
|
||||
obj_armature_b->data = id_cast<ID *>(armature);
|
||||
|
||||
bone = MEM_new_for_free<Bone>("BONE");
|
||||
STRNCPY(bone->name, "BoneA");
|
||||
|
|
@ -116,8 +117,7 @@ TEST_F(PoseTest, apply_action_object)
|
|||
EXPECT_EQ(obj_empty->loc[0], 0.0f);
|
||||
keyframe_data->keyframe_insert(bmain, first_slot, {"location", 0}, {1, 10}, key_settings);
|
||||
AnimationEvalContext eval_context = {nullptr, 1.0f};
|
||||
blender::animrig::pose_apply_action_all_bones(
|
||||
obj_empty, pose_action, first_slot.handle, &eval_context);
|
||||
animrig::pose_apply_action_all_bones(obj_empty, pose_action, first_slot.handle, &eval_context);
|
||||
EXPECT_EQ(obj_empty->loc[0], 10.0f);
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ TEST_F(PoseTest, apply_action_all_bones_single_slot)
|
|||
bone_a->loc[2] = 2.0;
|
||||
|
||||
AnimationEvalContext eval_context = {nullptr, 1.0f};
|
||||
blender::animrig::pose_apply_action_all_bones(
|
||||
animrig::pose_apply_action_all_bones(
|
||||
obj_armature_a, pose_action, first_slot.handle, &eval_context);
|
||||
EXPECT_EQ(bone_a->loc[0], 10.0);
|
||||
EXPECT_EQ(bone_b->loc[1], 5.0);
|
||||
|
|
@ -168,8 +168,7 @@ TEST_F(PoseTest, apply_action_all_bones_multiple_slots)
|
|||
bPoseChannel *arm_b_bone_b = BKE_pose_channel_find_name(obj_armature_b->pose, "BoneB");
|
||||
|
||||
AnimationEvalContext eval_context = {nullptr, 1.0f};
|
||||
blender::animrig::pose_apply_action_all_bones(
|
||||
obj_armature_a, pose_action, slot_a.handle, &eval_context);
|
||||
animrig::pose_apply_action_all_bones(obj_armature_a, pose_action, slot_a.handle, &eval_context);
|
||||
|
||||
EXPECT_EQ(arm_a_bone_a->loc[0], 5.0);
|
||||
EXPECT_EQ(arm_a_bone_a->loc[1], 0.0) << msg_unexpected_modification;
|
||||
|
|
@ -179,8 +178,7 @@ TEST_F(PoseTest, apply_action_all_bones_multiple_slots)
|
|||
|
||||
EXPECT_EQ(arm_b_bone_a->loc[1], 0.0) << "Other armature should not be affected yet.";
|
||||
|
||||
blender::animrig::pose_apply_action_all_bones(
|
||||
obj_armature_b, pose_action, slot_b.handle, &eval_context);
|
||||
animrig::pose_apply_action_all_bones(obj_armature_b, pose_action, slot_b.handle, &eval_context);
|
||||
|
||||
EXPECT_EQ(arm_b_bone_b->loc[0], 0.0) << msg_unexpected_modification;
|
||||
EXPECT_EQ(arm_b_bone_b->loc[1], 10.0);
|
||||
|
|
@ -189,8 +187,7 @@ TEST_F(PoseTest, apply_action_all_bones_multiple_slots)
|
|||
EXPECT_EQ(arm_a_bone_a->loc[0], 5.0) << "Other armature should not be affected.";
|
||||
|
||||
/* Any slot can be applied, even if it hasn't been added for the ID. */
|
||||
blender::animrig::pose_apply_action_all_bones(
|
||||
obj_armature_a, pose_action, slot_b.handle, &eval_context);
|
||||
animrig::pose_apply_action_all_bones(obj_armature_a, pose_action, slot_b.handle, &eval_context);
|
||||
|
||||
EXPECT_EQ(arm_b_bone_b->loc[1], arm_b_bone_a->loc[1])
|
||||
<< "Applying the same pose should result in the same values.";
|
||||
|
|
@ -211,7 +208,7 @@ TEST_F(PoseTest, apply_action_blend_single_slot)
|
|||
bone_b->loc[1] = 0.0;
|
||||
|
||||
AnimationEvalContext eval_context = {nullptr, 1.0f};
|
||||
blender::animrig::pose_apply_action_blend_all_bones(
|
||||
animrig::pose_apply_action_blend_all_bones(
|
||||
obj_armature_a, pose_action, first_slot.handle, &eval_context, 1.0);
|
||||
|
||||
EXPECT_NEAR(bone_a->loc[0], 10.0, 0.001);
|
||||
|
|
@ -220,7 +217,7 @@ TEST_F(PoseTest, apply_action_blend_single_slot)
|
|||
bone_a->loc[0] = 0.0;
|
||||
bone_b->loc[1] = 0.0;
|
||||
|
||||
blender::animrig::pose_apply_action_blend_all_bones(
|
||||
animrig::pose_apply_action_blend_all_bones(
|
||||
obj_armature_a, pose_action, first_slot.handle, &eval_context, 0.5);
|
||||
|
||||
EXPECT_NEAR(bone_a->loc[0], 5.0, 0.001);
|
||||
|
|
@ -233,7 +230,7 @@ TEST_F(PoseTest, apply_action_blend_single_slot)
|
|||
bone_b->flag &= ~POSE_SELECTED;
|
||||
|
||||
/* This should only affect the selected bone. */
|
||||
blender::animrig::pose_apply_action_blend(
|
||||
animrig::pose_apply_action_blend(
|
||||
obj_armature_a, pose_action, first_slot.handle, &eval_context, 0.5);
|
||||
|
||||
EXPECT_NEAR(bone_a->loc[0], 5.0, 0.001);
|
||||
|
|
@ -270,8 +267,7 @@ TEST_F(PoseTest, apply_action_multiple_objects)
|
|||
}
|
||||
|
||||
AnimationEvalContext eval_context = {nullptr, 1.0f};
|
||||
blender::animrig::pose_apply_action(
|
||||
{obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
animrig::pose_apply_action({obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
|
||||
/* No bones are selected, this should affect all bones. */
|
||||
EXPECT_NEAR(arm_a_bone_a->loc[0], 5, 0.001);
|
||||
|
|
@ -286,8 +282,7 @@ TEST_F(PoseTest, apply_action_multiple_objects)
|
|||
|
||||
arm_a_bone_a->flag |= POSE_SELECTED;
|
||||
|
||||
blender::animrig::pose_apply_action(
|
||||
{obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
animrig::pose_apply_action({obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
|
||||
/* Only the one selected bone should be affected. */
|
||||
EXPECT_NEAR(arm_a_bone_a->loc[0], 5, 0.001);
|
||||
|
|
@ -303,8 +298,7 @@ TEST_F(PoseTest, apply_action_multiple_objects)
|
|||
arm_a_bone_a->flag |= POSE_SELECTED;
|
||||
arm_b_bone_a->flag |= POSE_SELECTED;
|
||||
|
||||
blender::animrig::pose_apply_action(
|
||||
{obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
animrig::pose_apply_action({obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
|
||||
/* Only the two selected bones from different armatures should be affected. */
|
||||
EXPECT_NEAR(arm_a_bone_a->loc[0], 5, 0.001);
|
||||
|
|
@ -317,8 +311,7 @@ TEST_F(PoseTest, apply_action_multiple_objects)
|
|||
pose_bone->loc[1] = 0.0;
|
||||
}
|
||||
|
||||
blender::animrig::pose_apply_action(
|
||||
{obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 0.5);
|
||||
animrig::pose_apply_action({obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 0.5);
|
||||
|
||||
/* Blending half way. */
|
||||
EXPECT_NEAR(arm_a_bone_a->loc[0], 2.5, 0.001);
|
||||
|
|
@ -335,8 +328,7 @@ TEST_F(PoseTest, apply_action_multiple_objects)
|
|||
arm_a_bone_b->flag |= POSE_SELECTED;
|
||||
arm_b_bone_a->flag |= POSE_SELECTED;
|
||||
|
||||
blender::animrig::pose_apply_action(
|
||||
{obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
animrig::pose_apply_action({obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
|
||||
EXPECT_NEAR(arm_a_bone_a->loc[0], 5, 0.001);
|
||||
EXPECT_NEAR(arm_a_bone_b->loc[0], 5, 0.001);
|
||||
|
|
@ -368,8 +360,7 @@ TEST_F(PoseTest, apply_action_multiple_objects_single_slot)
|
|||
}
|
||||
|
||||
AnimationEvalContext eval_context = {nullptr, 1.0f};
|
||||
blender::animrig::pose_apply_action(
|
||||
{obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
animrig::pose_apply_action({obj_armature_a, obj_armature_b}, *pose_action, &eval_context, 1.0);
|
||||
|
||||
/* No bones are selected, this should affect all bones. Armature B has no slot, it should fall
|
||||
* back to slot 0. */
|
||||
|
|
@ -379,4 +370,5 @@ TEST_F(PoseTest, apply_action_multiple_objects_single_slot)
|
|||
EXPECT_NEAR(arm_b_bone_b->loc[0], 5, 0.001);
|
||||
}
|
||||
|
||||
} // namespace blender::animrig::tests
|
||||
} // namespace animrig::tests
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ bool action_is_layered(const bAction &dna_action)
|
|||
void convert_legacy_animato_actions(Main &bmain)
|
||||
{
|
||||
for (bAction &dna_action : bmain.actions) {
|
||||
blender::animrig::Action &action = dna_action.wrap();
|
||||
animrig::Action &action = dna_action.wrap();
|
||||
|
||||
if (action_is_layered(action) && !action.is_empty()) {
|
||||
/* This is just a safety net. Blender files that trigger this versioning code are not
|
||||
|
|
@ -94,8 +94,7 @@ void convert_legacy_animato_action(bAction &dna_action)
|
|||
action.slot_identifier_define(slot, slot_identifier);
|
||||
|
||||
Layer &layer = action.layer_add(DATA_(legacy::DEFAULT_LEGACY_LAYER_NAME));
|
||||
blender::animrig::Strip &strip = layer.strip_add(action,
|
||||
blender::animrig::Strip::Type::Keyframe);
|
||||
animrig::Strip &strip = layer.strip_add(action, animrig::Strip::Type::Keyframe);
|
||||
Channelbag &bag = strip.data<StripKeyframeData>(action).channelbag_for_slot_ensure(slot);
|
||||
const int fcu_count = BLI_listbase_count(&action.curves);
|
||||
const int group_count = BLI_listbase_count(&action.groups);
|
||||
|
|
@ -164,7 +163,7 @@ void tag_action_users_for_slotted_actions_conversion(Main &bmain)
|
|||
* have their own Action+Slot. Unfortunately there is no generic looper
|
||||
* for embedded IDs. At this moment the only animatable embedded ID is a
|
||||
* node tree. */
|
||||
bNodeTree *node_tree = blender::bke::node_tree_from_id(id);
|
||||
bNodeTree *node_tree = bke::node_tree_from_id(id);
|
||||
if (node_tree) {
|
||||
foreach_action_slot_use_with_references(node_tree->id, flag_adt);
|
||||
}
|
||||
|
|
@ -256,7 +255,7 @@ void convert_legacy_action_assignments(Main &bmain, ReportList *reports)
|
|||
* have their own Action+Slot. Unfortunately there is no generic looper
|
||||
* for embedded IDs. At this moment the only animatable embedded ID is a
|
||||
* node tree. */
|
||||
bNodeTree *node_tree = blender::bke::node_tree_from_id(id);
|
||||
bNodeTree *node_tree = bke::node_tree_from_id(id);
|
||||
if (node_tree && BLO_readfile_id_runtime_tags(node_tree->id).action_assignment_needs_slot) {
|
||||
foreach_action_slot_use_with_rna(node_tree->id, version_slot_assignment);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class AssetCatalogDefinitionFile;
|
|||
class AssetCatalogFilter;
|
||||
class AssetCatalogTree;
|
||||
|
||||
using CatalogID = bUUID;
|
||||
using CatalogID = UUID;
|
||||
using CatalogPathComponent = std::string;
|
||||
/* Would be nice to be able to use `std::filesystem::path` for this, but it's currently not
|
||||
* available on the minimum macOS target version. */
|
||||
|
|
|
|||
|
|
@ -22,13 +22,15 @@
|
|||
|
||||
#include "BKE_callbacks.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct Main;
|
||||
|
||||
namespace blender::bke::id {
|
||||
namespace bke::id {
|
||||
class IDRemapper;
|
||||
}
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
class AssetRepresentation;
|
||||
|
||||
|
|
@ -171,7 +173,7 @@ class AssetLibrary {
|
|||
* mapped to null (typically when an ID gets removed), the asset is removed, because we don't
|
||||
* support such empty/null assets.
|
||||
*/
|
||||
void remap_ids_and_remove_invalid(const blender::bke::id::IDRemapper &mappings);
|
||||
void remap_ids_and_remove_invalid(const bke::id::IDRemapper &mappings);
|
||||
|
||||
/**
|
||||
* Update `catalog_simple_name` by looking up the asset's catalog by its ID.
|
||||
|
|
@ -204,7 +206,7 @@ AssetLibraryReference all_library_reference();
|
|||
AssetLibraryReference current_file_library_reference();
|
||||
void all_library_reload_catalogs_if_dirty();
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
/**
|
||||
* Load the data for an asset library, but not the asset representations themselves (loading these
|
||||
|
|
@ -217,8 +219,8 @@ void all_library_reload_catalogs_if_dirty();
|
|||
* \warning Catalogs are reloaded, invalidating catalog pointers. Do not store catalog pointers,
|
||||
* store CatalogIDs instead and lookup the catalog where needed.
|
||||
*/
|
||||
blender::asset_system::AssetLibrary *AS_asset_library_load(
|
||||
const Main *bmain, const AssetLibraryReference &library_reference);
|
||||
asset_system::AssetLibrary *AS_asset_library_load(const Main *bmain,
|
||||
const AssetLibraryReference &library_reference);
|
||||
|
||||
std::string AS_asset_library_root_path_from_library_ref(
|
||||
const AssetLibraryReference &library_reference);
|
||||
|
|
@ -244,7 +246,7 @@ std::string AS_asset_library_root_path_from_library_ref(
|
|||
* \return True if the function could find a valid, that is, a non-empty path to return in \a
|
||||
* r_library_path.
|
||||
*/
|
||||
std::string AS_asset_library_find_suitable_root_path_from_path(blender::StringRefNull input_path);
|
||||
std::string AS_asset_library_find_suitable_root_path_from_path(StringRefNull input_path);
|
||||
|
||||
/**
|
||||
* Uses the current location on disk of the file represented by \a bmain as input to
|
||||
|
|
@ -272,8 +274,8 @@ void AS_asset_libraries_exit();
|
|||
*
|
||||
* To get the in-memory-only "current file" asset library, pass an empty path.
|
||||
*/
|
||||
blender::asset_system::AssetLibrary *AS_asset_library_load_from_directory(
|
||||
const char *name, const char *library_dirpath);
|
||||
asset_system::AssetLibrary *AS_asset_library_load_from_directory(const char *name,
|
||||
const char *library_dirpath);
|
||||
|
||||
/** Return whether any loaded AssetLibrary has unsaved changes to its catalogs. */
|
||||
bool AS_asset_library_has_any_unsaved_catalogs();
|
||||
|
|
@ -282,7 +284,7 @@ bool AS_asset_library_has_any_unsaved_catalogs();
|
|||
* An asset library can include local IDs (IDs in the current file). Their pointers need to be
|
||||
* remapped on change (or assets removed as IDs gets removed).
|
||||
*/
|
||||
void AS_asset_library_remap_ids(const blender::bke::id::IDRemapper &mappings);
|
||||
void AS_asset_library_remap_ids(const bke::id::IDRemapper &mappings);
|
||||
|
||||
/**
|
||||
* Attempt to resolve a full path to an asset based on the currently available (not necessary
|
||||
|
|
@ -319,3 +321,5 @@ void AS_asset_library_import_method_ensure_valid(Main &bmain);
|
|||
* when run during versioning).
|
||||
*/
|
||||
void AS_asset_library_essential_import_method_update();
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -24,11 +24,13 @@
|
|||
#include "DNA_ID_enums.h"
|
||||
#include "DNA_asset_types.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct AssetMetaData;
|
||||
struct ID;
|
||||
struct PreviewImage;
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
class AssetLibrary;
|
||||
|
||||
|
|
@ -150,4 +152,6 @@ class AssetRepresentation : NonCopyable, NonMovable {
|
|||
AssetLibrary &owner_asset_library() const;
|
||||
};
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -27,9 +27,11 @@
|
|||
|
||||
#include "CLG_log.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static CLG_LogRef LOG = {"asset.catalog"};
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
const CatalogFilePath AssetCatalogService::DEFAULT_CATALOG_FILENAME = "blender_assets.cats.txt";
|
||||
|
||||
|
|
@ -743,4 +745,6 @@ bool AssetCatalogFilter::is_known(const CatalogID asset_catalog_id) const
|
|||
return known_catalog_ids_.contains(asset_catalog_id);
|
||||
}
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@
|
|||
|
||||
#include "asset_catalog_definition_file.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static CLG_LogRef LOG = {"asset.catalog"};
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
const int AssetCatalogDefinitionFile::SUPPORTED_VERSION = 1;
|
||||
const std::string AssetCatalogDefinitionFile::VERSION_MARKER = "VERSION ";
|
||||
|
|
@ -291,4 +293,6 @@ std::unique_ptr<AssetCatalogDefinitionFile> AssetCatalogDefinitionFile::copy_and
|
|||
return copy;
|
||||
}
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@
|
|||
#include "runtime_library.hh"
|
||||
#include "utils.hh"
|
||||
|
||||
using namespace blender;
|
||||
namespace blender {
|
||||
|
||||
using namespace blender::asset_system;
|
||||
|
||||
bool AssetLibrary::save_catalogs_when_file_is_saved = true;
|
||||
|
|
@ -224,7 +225,7 @@ void AS_asset_library_essential_import_method_update()
|
|||
}
|
||||
}
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
AssetLibrary::AssetLibrary(
|
||||
eAssetLibraryType library_type,
|
||||
|
|
@ -479,4 +480,6 @@ void all_library_reload_catalogs_if_dirty()
|
|||
service->reload_all_library_catalogs_if_dirty();
|
||||
}
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
#include "runtime_library.hh"
|
||||
#include "utils.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
/* When enabled, use a pre file load handler (#BKE_CB_EVT_LOAD_PRE) callback to destroy the asset
|
||||
* library service. Without this an explicit call from the file loading code is needed to do this,
|
||||
* which is not as nice.
|
||||
|
|
@ -43,7 +45,7 @@
|
|||
|
||||
static CLG_LogRef LOG = {"asset.library"};
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
std::unique_ptr<AssetLibraryService> AssetLibraryService::instance_;
|
||||
bool AssetLibraryService::atexit_handler_registered_ = false;
|
||||
|
|
@ -614,4 +616,6 @@ void AssetLibraryService::foreach_loaded_asset_library(FunctionRef<void(AssetLib
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -18,10 +18,12 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct AssetLibraryReference;
|
||||
struct bUserAssetLibrary;
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
class AllAssetLibrary;
|
||||
class OnDiskAssetLibrary;
|
||||
|
|
@ -199,4 +201,6 @@ class AssetLibraryService {
|
|||
void app_handler_unregister();
|
||||
};
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@
|
|||
|
||||
#include "CLG_log.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
static CLG_LogRef LOG = {"asset.library"};
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace asset_system {
|
||||
|
||||
AllAssetLibrary::AllAssetLibrary() : AssetLibrary(ASSET_LIBRARY_ALL) {}
|
||||
|
||||
|
|
@ -82,4 +84,6 @@ void AllAssetLibrary::refresh_catalogs()
|
|||
this->rebuild_catalogs_from_nested(/*reload_nested_catalogs=*/true);
|
||||
}
|
||||
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -22,19 +22,19 @@
|
|||
namespace blender::asset_system::tests {
|
||||
|
||||
/* UUIDs from tests/files/asset_library/blender_assets.cats.txt */
|
||||
const bUUID UUID_ID_WITHOUT_PATH("e34dd2c5-5d2e-4668-9794-1db5de2a4f71");
|
||||
const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
const bUUID UUID_POSES_ELLIE_WHITESPACE("b06132f6-5687-4751-a6dd-392740eb3c46");
|
||||
const bUUID UUID_POSES_ELLIE_TRAILING_SLASH("3376b94b-a28d-4d05-86c1-bf30b937130d");
|
||||
const bUUID UUID_POSES_ELLIE_BACKSLASHES("a51e17ae-34fc-47d5-ba0f-64c2c9b771f7");
|
||||
const bUUID UUID_POSES_RUZENA("79a4f887-ab60-4bd4-94da-d572e27d6aed");
|
||||
const bUUID UUID_POSES_RUZENA_HAND("81811c31-1a88-4bd7-bb34-c6fc2607a12e");
|
||||
const bUUID UUID_POSES_RUZENA_FACE("82162c1f-06cc-4d91-a9bf-4f72c104e348");
|
||||
const bUUID UUID_WITHOUT_SIMPLENAME("d7916a31-6ca9-4909-955f-182ca2b81fa3");
|
||||
const bUUID UUID_ANOTHER_RUZENA("00000000-d9fa-4b91-b704-e6af1f1339ef");
|
||||
const UUID UUID_ID_WITHOUT_PATH("e34dd2c5-5d2e-4668-9794-1db5de2a4f71");
|
||||
const UUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
const UUID UUID_POSES_ELLIE_WHITESPACE("b06132f6-5687-4751-a6dd-392740eb3c46");
|
||||
const UUID UUID_POSES_ELLIE_TRAILING_SLASH("3376b94b-a28d-4d05-86c1-bf30b937130d");
|
||||
const UUID UUID_POSES_ELLIE_BACKSLASHES("a51e17ae-34fc-47d5-ba0f-64c2c9b771f7");
|
||||
const UUID UUID_POSES_RUZENA("79a4f887-ab60-4bd4-94da-d572e27d6aed");
|
||||
const UUID UUID_POSES_RUZENA_HAND("81811c31-1a88-4bd7-bb34-c6fc2607a12e");
|
||||
const UUID UUID_POSES_RUZENA_FACE("82162c1f-06cc-4d91-a9bf-4f72c104e348");
|
||||
const UUID UUID_WITHOUT_SIMPLENAME("d7916a31-6ca9-4909-955f-182ca2b81fa3");
|
||||
const UUID UUID_ANOTHER_RUZENA("00000000-d9fa-4b91-b704-e6af1f1339ef");
|
||||
|
||||
/* UUIDs from tests/files/asset_library/modified_assets.cats.txt */
|
||||
const bUUID UUID_AGENT_47("c5744ba5-43f5-4f73-8e52-010ad4a61b34");
|
||||
const UUID UUID_AGENT_47("c5744ba5-43f5-4f73-8e52-010ad4a61b34");
|
||||
|
||||
/* Subclass that adds accessors such that protected fields can be used in tests. */
|
||||
class TestableAssetCatalogService : public AssetCatalogService {
|
||||
|
|
@ -304,7 +304,7 @@ TEST_F(AssetCatalogTest, read_write_unicode_filepath)
|
|||
loaded_service.load_from_disk();
|
||||
|
||||
/* Test that the file was loaded correctly. */
|
||||
const bUUID materials_uuid("a2151dff-dead-4f29-b6bc-b2c7d6cccdb4");
|
||||
const UUID materials_uuid("a2151dff-dead-4f29-b6bc-b2c7d6cccdb4");
|
||||
const AssetCatalog *cat = loaded_service.find_catalog(materials_uuid);
|
||||
ASSERT_NE(nullptr, cat);
|
||||
EXPECT_EQ(materials_uuid, cat->catalog_id);
|
||||
|
|
@ -502,7 +502,7 @@ TEST_F(AssetCatalogTest, create_catalog_after_loading_file)
|
|||
|
||||
/* This should create a new catalog but not write to disk. */
|
||||
const AssetCatalog *new_catalog = service.create_catalog("new/catalog");
|
||||
const bUUID new_catalog_id = new_catalog->catalog_id;
|
||||
const UUID new_catalog_id = new_catalog->catalog_id;
|
||||
service.tag_has_unsaved_changes();
|
||||
|
||||
/* Reload the on-disk catalog file. */
|
||||
|
|
@ -601,8 +601,8 @@ TEST_F(AssetCatalogTest, delete_catalog_parent_by_path)
|
|||
/* Create an extra catalog with the to-be-deleted path, and one with a child of that.
|
||||
* This creates some duplicates that are bound to occur in production asset libraries as well.
|
||||
*/
|
||||
const bUUID cat1_uuid = service.create_catalog("character/Ružena/poselib")->catalog_id;
|
||||
const bUUID cat2_uuid = service.create_catalog("character/Ružena/poselib/body")->catalog_id;
|
||||
const UUID cat1_uuid = service.create_catalog("character/Ružena/poselib")->catalog_id;
|
||||
const UUID cat2_uuid = service.create_catalog("character/Ružena/poselib/body")->catalog_id;
|
||||
|
||||
/* Delete a parent catalog. */
|
||||
service.prune_catalogs_by_path("character/Ružena/poselib");
|
||||
|
|
@ -914,8 +914,8 @@ TEST_F(AssetCatalogTest, backups)
|
|||
|
||||
TEST_F(AssetCatalogTest, order_by_path)
|
||||
{
|
||||
const bUUID cat2_uuid("22222222-b847-44d9-bdca-ff04db1c24f5");
|
||||
const bUUID cat4_uuid("11111111-b847-44d9-bdca-ff04db1c24f5"); /* Sorts earlier than above. */
|
||||
const UUID cat2_uuid("22222222-b847-44d9-bdca-ff04db1c24f5");
|
||||
const UUID cat4_uuid("11111111-b847-44d9-bdca-ff04db1c24f5"); /* Sorts earlier than above. */
|
||||
const AssetCatalog cat1(BLI_uuid_generate_random(), "simple/path/child", "");
|
||||
const AssetCatalog cat2(cat2_uuid, "simple/path", "");
|
||||
const AssetCatalog cat3(BLI_uuid_generate_random(), "complex/path/...or/is/it?", "");
|
||||
|
|
@ -956,9 +956,9 @@ TEST_F(AssetCatalogTest, order_by_path_and_first_seen)
|
|||
AssetCatalogService service;
|
||||
service.load_from_disk(asset_library_root_);
|
||||
|
||||
const bUUID first_seen_uuid("3d451c87-27d1-40fd-87fc-f4c9e829c848");
|
||||
const bUUID first_sorted_uuid("00000000-0000-0000-0000-000000000001");
|
||||
const bUUID last_sorted_uuid("ffffffff-ffff-ffff-ffff-ffffffffffff");
|
||||
const UUID first_seen_uuid("3d451c87-27d1-40fd-87fc-f4c9e829c848");
|
||||
const UUID first_sorted_uuid("00000000-0000-0000-0000-000000000001");
|
||||
const UUID last_sorted_uuid("ffffffff-ffff-ffff-ffff-ffffffffffff");
|
||||
|
||||
AssetCatalog first_seen_cat(first_seen_uuid, "simple/path/child", "");
|
||||
const AssetCatalog first_sorted_cat(first_sorted_uuid, "simple/path/child", "");
|
||||
|
|
@ -1084,7 +1084,7 @@ TEST_F(AssetCatalogTest, create_catalog_filter)
|
|||
TEST_F(AssetCatalogTest, create_catalog_filter_for_unknown_uuid)
|
||||
{
|
||||
AssetCatalogService service;
|
||||
const bUUID unknown_uuid = BLI_uuid_generate_random();
|
||||
const UUID unknown_uuid = BLI_uuid_generate_random();
|
||||
|
||||
AssetCatalogFilter filter = service.create_catalog_filter(unknown_uuid);
|
||||
EXPECT_TRUE(filter.contains(unknown_uuid));
|
||||
|
|
@ -1227,7 +1227,7 @@ TEST_F(AssetCatalogTest, undo_redo_one_step)
|
|||
<< "Undo steps should be created explicitly, and not after creating any catalog.";
|
||||
|
||||
service.undo_push();
|
||||
const bUUID other_catalog_id = service.create_catalog("other/catalog/path")->catalog_id;
|
||||
const UUID other_catalog_id = service.create_catalog("other/catalog/path")->catalog_id;
|
||||
EXPECT_TRUE(service.is_undo_possbile())
|
||||
<< "Undo should be possible after creating an undo snapshot.";
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
namespace blender::asset_system::tests {
|
||||
|
||||
const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
const UUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
|
||||
class AssetLibraryServiceTest : public testing::Test {
|
||||
public:
|
||||
|
|
@ -175,7 +175,7 @@ TEST_F(AssetLibraryServiceTest, catalogs_loaded)
|
|||
asset_library_root_);
|
||||
AssetCatalogService &cat_service = lib->catalog_service();
|
||||
|
||||
const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
const UUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
EXPECT_NE(nullptr, cat_service.find_catalog(UUID_POSES_ELLIE))
|
||||
<< "Catalogs should be loaded after getting an asset library from disk.";
|
||||
}
|
||||
|
|
@ -192,13 +192,13 @@ TEST_F(AssetLibraryServiceTest, has_any_unsaved_catalogs)
|
|||
EXPECT_FALSE(service->has_any_unsaved_catalogs())
|
||||
<< "Unchanged AssetLibrary should have no unsaved catalogs";
|
||||
|
||||
const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
const UUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
cat_service.prune_catalogs_by_id(UUID_POSES_ELLIE);
|
||||
EXPECT_FALSE(service->has_any_unsaved_catalogs())
|
||||
<< "Deletion of catalogs via AssetCatalogService should not automatically tag as 'unsaved "
|
||||
"changes'.";
|
||||
|
||||
const bUUID UUID_POSES_RUZENA("79a4f887-ab60-4bd4-94da-d572e27d6aed");
|
||||
const UUID UUID_POSES_RUZENA("79a4f887-ab60-4bd4-94da-d572e27d6aed");
|
||||
AssetCatalog *cat = cat_service.find_catalog(UUID_POSES_RUZENA);
|
||||
ASSERT_NE(nullptr, cat) << "Catalog " << UUID_POSES_RUZENA << " should be known";
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ TEST_F(AssetLibraryTest, AS_asset_library_load_from_directory)
|
|||
/* Check that the catalogs defined in the library are actually loaded. This just tests one single
|
||||
* catalog, as that indicates the file has been loaded. Testing that loading went OK is for
|
||||
* the asset catalog service tests. */
|
||||
const bUUID uuid_poses_ellie("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
const UUID uuid_poses_ellie("df60e1f6-2259-475b-93d9-69a1b4a8db78");
|
||||
AssetCatalog *poses_ellie = service.find_catalog(uuid_poses_ellie);
|
||||
ASSERT_NE(nullptr, poses_ellie) << "unable to find POSES_ELLIE catalog";
|
||||
EXPECT_EQ("character/Ellie/poselib", poses_ellie->path.str());
|
||||
|
|
|
|||
|
|
@ -23,13 +23,15 @@
|
|||
|
||||
#include "testing/testing.h"
|
||||
|
||||
namespace blender::asset_system {
|
||||
namespace blender {
|
||||
|
||||
namespace asset_system {
|
||||
class AssetCatalogTree;
|
||||
class AssetCatalogTreeItem;
|
||||
class AssetCatalogPath;
|
||||
} // namespace blender::asset_system
|
||||
} // namespace asset_system
|
||||
|
||||
namespace blender::asset_system::tests {
|
||||
namespace asset_system::tests {
|
||||
|
||||
/**
|
||||
* Functionality to setup and access directories on disk within which asset library related testing
|
||||
|
|
@ -178,4 +180,6 @@ inline void AssetCatalogTreeTestFunctions::expect_tree_item_child_items(
|
|||
});
|
||||
}
|
||||
|
||||
} // namespace blender::asset_system::tests
|
||||
} // namespace asset_system::tests
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#include "blendthumb.hh"
|
||||
|
||||
using namespace blender;
|
||||
|
||||
/**
|
||||
* This function opens .blend file from src_blend, extracts thumbnail from file if there is one,
|
||||
* and writes `.png` image into `dst_png`.
|
||||
|
|
@ -73,13 +75,12 @@ static eThumbStatus extract_png_from_blend_file(const char *src_blend, const cha
|
|||
return BT_FILE_ERR;
|
||||
}
|
||||
|
||||
std::optional<blender::Vector<uint8_t>> png_buf_opt = blendthumb_create_png_data_from_thumb(
|
||||
&thumb);
|
||||
std::optional<Vector<uint8_t>> png_buf_opt = blendthumb_create_png_data_from_thumb(&thumb);
|
||||
if (!png_buf_opt) {
|
||||
err = BT_ERROR;
|
||||
}
|
||||
else {
|
||||
blender::Vector<uint8_t> png_buf = *png_buf_opt;
|
||||
Vector<uint8_t> png_buf = *png_buf_opt;
|
||||
err = (write(dst_file, png_buf.data(), png_buf.size()) == png_buf.size()) ? BT_OK :
|
||||
BT_FILE_ERR;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@
|
|||
#include "BLI_array.hh"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
struct FileReader;
|
||||
|
||||
struct Thumbnail {
|
||||
blender::Array<uint8_t> data;
|
||||
Array<uint8_t> data;
|
||||
int width;
|
||||
int height;
|
||||
};
|
||||
|
|
@ -36,8 +38,7 @@ enum eThumbStatus {
|
|||
BT_ERROR = 9
|
||||
};
|
||||
|
||||
std::optional<blender::Vector<uint8_t>> blendthumb_create_png_data_from_thumb(
|
||||
const Thumbnail *thumb);
|
||||
std::optional<Vector<uint8_t>> blendthumb_create_png_data_from_thumb(const Thumbnail *thumb);
|
||||
/**
|
||||
* This function extracts the thumbnail from the .blend file into thumb.
|
||||
* Returns #BT_OK for success and the relevant error code otherwise.
|
||||
|
|
@ -47,3 +48,5 @@ eThumbStatus blendthumb_create_thumb_from_file(FileReader *rawfile, Thumbnail *t
|
|||
/* INTEGER CODES */
|
||||
/* NOTE: this is endianness-sensitive. */
|
||||
#define MAKE_ID(a, b, c, d) ((int)(d) << 24 | (int)(c) << 16 | (b) << 8 | (a))
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "blendthumb.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
BLI_STATIC_ASSERT(ENDIAN_ORDER == L_ENDIAN, "Blender only builds on little endian systems")
|
||||
|
||||
static void thumb_data_vertical_flip(Thumbnail *thumb)
|
||||
|
|
@ -70,7 +72,7 @@ static bool file_seek(FileReader *file, size_t len)
|
|||
|
||||
/* File doesn't support seeking (e.g. gzip), so read and discard in chunks. */
|
||||
constexpr size_t dummy_data_size = 4096;
|
||||
blender::Array<char> dummy_data(dummy_data_size);
|
||||
Array<char> dummy_data(dummy_data_size);
|
||||
while (len > 0) {
|
||||
const size_t len_chunk = std::min(len, dummy_data_size);
|
||||
if (size_t(file->read(file, dummy_data.data(), len_chunk)) != len_chunk) {
|
||||
|
|
@ -114,7 +116,7 @@ static eThumbStatus blendthumb_extract_from_file_impl(FileReader *file,
|
|||
return BT_INVALID_THUMB;
|
||||
}
|
||||
|
||||
thumb->data = blender::Array<uint8_t>(data_size);
|
||||
thumb->data = Array<uint8_t>(data_size);
|
||||
if (!file_read(file, thumb->data.data(), data_size)) {
|
||||
return BT_INVALID_THUMB;
|
||||
}
|
||||
|
|
@ -175,3 +177,5 @@ eThumbStatus blendthumb_create_thumb_from_file(FileReader *rawfile, Thumbnail *t
|
|||
thumb_data_vertical_flip(thumb);
|
||||
return BT_OK;
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -19,20 +19,22 @@
|
|||
#include "BLI_endian_switch.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
static void png_extend_native_int32(blender::Vector<uint8_t> &output, int32_t data)
|
||||
namespace blender {
|
||||
|
||||
static void png_extend_native_int32(Vector<uint8_t> &output, int32_t data)
|
||||
{
|
||||
/* NOTE: this is endianness-sensitive. */
|
||||
/* PNG is big-endian, its values need to be switched on little-endian systems. */
|
||||
BLI_endian_switch_int32(&data);
|
||||
output.extend_unchecked(blender::Span(reinterpret_cast<uint8_t *>(&data), 4));
|
||||
output.extend_unchecked(Span(reinterpret_cast<uint8_t *>(&data), 4));
|
||||
}
|
||||
|
||||
/** The number of bytes each chunk uses on top of the data that's written. */
|
||||
#define PNG_CHUNK_EXTRA 12
|
||||
|
||||
static void png_chunk_create(blender::Vector<uint8_t> &output,
|
||||
static void png_chunk_create(Vector<uint8_t> &output,
|
||||
const uint32_t tag,
|
||||
const blender::Vector<uint8_t> &data)
|
||||
const Vector<uint8_t> &data)
|
||||
{
|
||||
uint32_t crc = crc32(0, nullptr, 0);
|
||||
crc = crc32(crc, reinterpret_cast<uint8_t *>(const_cast<uint32_t *>(&tag)), sizeof(tag));
|
||||
|
|
@ -40,33 +42,33 @@ static void png_chunk_create(blender::Vector<uint8_t> &output,
|
|||
|
||||
png_extend_native_int32(output, data.size());
|
||||
output.extend_unchecked(
|
||||
blender::Span(reinterpret_cast<uint8_t *>(const_cast<uint32_t *>(&tag)), sizeof(tag)));
|
||||
Span(reinterpret_cast<uint8_t *>(const_cast<uint32_t *>(&tag)), sizeof(tag)));
|
||||
output.extend_unchecked(data);
|
||||
png_extend_native_int32(output, crc);
|
||||
}
|
||||
|
||||
static blender::Vector<uint8_t> filtered_rows_from_thumb(const Thumbnail *thumb)
|
||||
static Vector<uint8_t> filtered_rows_from_thumb(const Thumbnail *thumb)
|
||||
{
|
||||
/* In the image data sent to the compression step, each scan-line is preceded by a filter type
|
||||
* byte containing the numeric code of the filter algorithm used for that scan-line. */
|
||||
const size_t line_size = thumb->width * 4;
|
||||
blender::Vector<uint8_t> filtered;
|
||||
Vector<uint8_t> filtered;
|
||||
size_t final_size = thumb->height * (line_size + 1);
|
||||
filtered.reserve(final_size);
|
||||
for (int i = 0; i < thumb->height; i++) {
|
||||
filtered.append_unchecked(0x00);
|
||||
filtered.extend_unchecked(blender::Span(&thumb->data[i * line_size], line_size));
|
||||
filtered.extend_unchecked(Span(&thumb->data[i * line_size], line_size));
|
||||
}
|
||||
BLI_assert(final_size == filtered.size());
|
||||
return filtered;
|
||||
}
|
||||
|
||||
static std::optional<blender::Vector<uint8_t>> zlib_compress(const blender::Vector<uint8_t> &data)
|
||||
static std::optional<Vector<uint8_t>> zlib_compress(const Vector<uint8_t> &data)
|
||||
{
|
||||
ulong uncompressed_size = data.size();
|
||||
uLongf compressed_size = compressBound(uncompressed_size);
|
||||
|
||||
blender::Vector<uint8_t> compressed(compressed_size, 0x00);
|
||||
Vector<uint8_t> compressed(compressed_size, 0x00);
|
||||
|
||||
int return_value = compress2(static_cast<uchar *>(compressed.data()),
|
||||
&compressed_size,
|
||||
|
|
@ -81,15 +83,14 @@ static std::optional<blender::Vector<uint8_t>> zlib_compress(const blender::Vect
|
|||
return compressed;
|
||||
}
|
||||
|
||||
std::optional<blender::Vector<uint8_t>> blendthumb_create_png_data_from_thumb(
|
||||
const Thumbnail *thumb)
|
||||
std::optional<Vector<uint8_t>> blendthumb_create_png_data_from_thumb(const Thumbnail *thumb)
|
||||
{
|
||||
if (thumb->data.is_empty()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/* Create `IDAT` chunk data. */
|
||||
blender::Vector<uint8_t> image_data;
|
||||
Vector<uint8_t> image_data;
|
||||
{
|
||||
auto image_data_opt = zlib_compress(filtered_rows_from_thumb(thumb));
|
||||
if (image_data_opt == std::nullopt) {
|
||||
|
|
@ -99,7 +100,7 @@ std::optional<blender::Vector<uint8_t>> blendthumb_create_png_data_from_thumb(
|
|||
}
|
||||
|
||||
/* Create the IHDR chunk data. */
|
||||
blender::Vector<uint8_t> ihdr_data;
|
||||
Vector<uint8_t> ihdr_data;
|
||||
{
|
||||
const size_t ihdr_data_final_size = 4 + 4 + 5;
|
||||
ihdr_data.reserve(ihdr_data_final_size);
|
||||
|
|
@ -116,7 +117,7 @@ std::optional<blender::Vector<uint8_t>> blendthumb_create_png_data_from_thumb(
|
|||
}
|
||||
|
||||
/* Join it all together to create a PNG image. */
|
||||
blender::Vector<uint8_t> png_buf;
|
||||
Vector<uint8_t> png_buf;
|
||||
{
|
||||
const size_t png_buf_final_size = (
|
||||
/* Header. */
|
||||
|
|
@ -142,3 +143,5 @@ std::optional<blender::Vector<uint8_t>> blendthumb_create_png_data_from_thumb(
|
|||
|
||||
return png_buf;
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
|
||||
using namespace blender;
|
||||
|
||||
/**
|
||||
* This thumbnail provider implements #IInitializeWithStream to enable being hosted
|
||||
* in an isolated process for robustness.
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ class FileDescriptorRAII : blender::NonCopyable, blender::NonMovable {
|
|||
public:
|
||||
explicit FileDescriptorRAII(const char *file_path)
|
||||
{
|
||||
src_fd = BLI_open(file_path, O_BINARY | O_RDONLY, 0);
|
||||
src_fd = blender::BLI_open(file_path, O_BINARY | O_RDONLY, 0);
|
||||
}
|
||||
|
||||
~FileDescriptorRAII()
|
||||
|
|
@ -116,16 +116,16 @@ static NSImage *generate_nsimage_for_file(const char *src_blend_path, NSError *e
|
|||
return nil;
|
||||
}
|
||||
|
||||
FileReader *file_content = BLI_filereader_new_file(src_file_fd.get());
|
||||
blender::FileReader *file_content = blender::BLI_filereader_new_file(src_file_fd.get());
|
||||
if (file_content == nullptr) {
|
||||
error = create_nserror_from_string(@"Failed to read from blend");
|
||||
return nil;
|
||||
}
|
||||
|
||||
/* Extract thumbnail from file. */
|
||||
Thumbnail thumb;
|
||||
eThumbStatus err = blendthumb_create_thumb_from_file(file_content, &thumb);
|
||||
if (err != BT_OK) {
|
||||
blender::Thumbnail thumb;
|
||||
blender::eThumbStatus err = blendthumb_create_thumb_from_file(file_content, &thumb);
|
||||
if (err != blender::BT_OK) {
|
||||
error = create_nserror_from_string(@"Failed to create thumbnail from file");
|
||||
return nil;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
namespace blender {
|
||||
|
||||
/** Name of sub-directory inside #BLENDER_DATAFILES that contains font files. */
|
||||
#define BLF_DATAFILES_FONTS_DIR "fonts"
|
||||
|
||||
|
|
@ -34,10 +36,10 @@ struct ResultBLF;
|
|||
struct rcti;
|
||||
struct rctf;
|
||||
|
||||
namespace blender::ocio {
|
||||
namespace ocio {
|
||||
class ColorSpace;
|
||||
} // namespace blender::ocio
|
||||
using ColorSpace = blender::ocio::ColorSpace;
|
||||
} // namespace ocio
|
||||
using ColorSpace = ocio::ColorSpace;
|
||||
|
||||
int BLF_init();
|
||||
void BLF_exit();
|
||||
|
|
@ -196,15 +198,14 @@ void BLF_draw_svg_icon(uint icon_id,
|
|||
const float color[4] = nullptr,
|
||||
float outline_alpha = 1.0f,
|
||||
bool multicolor = false,
|
||||
blender::FunctionRef<void(std::string &)> edit_source_cb = nullptr);
|
||||
FunctionRef<void(std::string &)> edit_source_cb = nullptr);
|
||||
|
||||
blender::Array<uchar> BLF_svg_icon_bitmap(
|
||||
uint icon_id,
|
||||
float size,
|
||||
int *r_width,
|
||||
int *r_height,
|
||||
bool multicolor = false,
|
||||
blender::FunctionRef<void(std::string &)> edit_source_cb = nullptr);
|
||||
Array<uchar> BLF_svg_icon_bitmap(uint icon_id,
|
||||
float size,
|
||||
int *r_width,
|
||||
int *r_height,
|
||||
bool multicolor = false,
|
||||
FunctionRef<void(std::string &)> edit_source_cb = nullptr);
|
||||
|
||||
using BLF_GlyphBoundsFn = bool (*)(const char *str,
|
||||
size_t str_step_ofs,
|
||||
|
|
@ -252,7 +253,7 @@ int BLF_str_offset_to_cursor(
|
|||
* Return bounds of selection boxes. There is just one normally but there could
|
||||
* be more for multi-line and when containing text of differing directions.
|
||||
*/
|
||||
blender::Vector<blender::Bounds<int>> BLF_str_selection_boxes(
|
||||
Vector<Bounds<int>> BLF_str_selection_boxes(
|
||||
int fontid, const char *str, size_t str_len, size_t sel_start, size_t sel_length);
|
||||
|
||||
/**
|
||||
|
|
@ -337,10 +338,10 @@ void BLF_rotation(int fontid, float angle);
|
|||
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax);
|
||||
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode = BLFWrapMode::Minimal);
|
||||
|
||||
blender::Vector<blender::StringRef> BLF_string_wrap(int fontid,
|
||||
blender::StringRef str,
|
||||
const int max_pixel_width,
|
||||
BLFWrapMode mode = BLFWrapMode::Minimal);
|
||||
Vector<StringRef> BLF_string_wrap(int fontid,
|
||||
StringRef str,
|
||||
const int max_pixel_width,
|
||||
BLFWrapMode mode = BLFWrapMode::Minimal);
|
||||
|
||||
void BLF_enable(int fontid, FontFlags flag);
|
||||
void BLF_disable(int fontid, FontFlags flag);
|
||||
|
|
@ -458,3 +459,5 @@ struct ResultBLF {
|
|||
*/
|
||||
int width;
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include "BLI_enum_flags.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
enum class FontShadowType {
|
||||
None = 0,
|
||||
Blur3x3 = 3,
|
||||
|
|
@ -63,3 +65,5 @@ enum FontFlags {
|
|||
BLF_NO_FALLBACK = 1 << 19,
|
||||
};
|
||||
ENUM_OPERATORS(FontFlags);
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
#include "blf_internal.hh"
|
||||
#include "blf_internal_types.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
#define BLF_RESULT_CHECK_INIT(r_info) \
|
||||
if (r_info) { \
|
||||
memset(r_info, 0, sizeof(*(r_info))); \
|
||||
|
|
@ -48,7 +50,7 @@ FontBLF *global_font[BLF_MAX_FONT] = {nullptr};
|
|||
int blf_mono_font = -1;
|
||||
int blf_mono_font_render = -1;
|
||||
|
||||
static blender::Mutex g_blf_load_mutex;
|
||||
static Mutex g_blf_load_mutex;
|
||||
|
||||
static FontBLF *blf_get(int fontid)
|
||||
{
|
||||
|
|
@ -629,7 +631,7 @@ void BLF_draw_svg_icon(uint icon_id,
|
|||
const float color[4],
|
||||
float outline_alpha,
|
||||
bool multicolor,
|
||||
blender::FunctionRef<void(std::string &)> edit_source_cb)
|
||||
FunctionRef<void(std::string &)> edit_source_cb)
|
||||
{
|
||||
#ifndef WITH_HEADLESS
|
||||
FontBLF *font = global_font[0];
|
||||
|
|
@ -643,12 +645,12 @@ void BLF_draw_svg_icon(uint icon_id,
|
|||
#endif /* WITH_HEADLESS */
|
||||
}
|
||||
|
||||
blender::Array<uchar> BLF_svg_icon_bitmap(uint icon_id,
|
||||
float size,
|
||||
int *r_width,
|
||||
int *r_height,
|
||||
bool multicolor,
|
||||
blender::FunctionRef<void(std::string &)> edit_source_cb)
|
||||
Array<uchar> BLF_svg_icon_bitmap(uint icon_id,
|
||||
float size,
|
||||
int *r_width,
|
||||
int *r_height,
|
||||
bool multicolor,
|
||||
FunctionRef<void(std::string &)> edit_source_cb)
|
||||
{
|
||||
#ifndef WITH_HEADLESS
|
||||
FontBLF *font = global_font[0];
|
||||
|
|
@ -715,7 +717,7 @@ int BLF_str_offset_to_cursor(int fontid,
|
|||
return 0;
|
||||
}
|
||||
|
||||
blender::Vector<blender::Bounds<int>> BLF_str_selection_boxes(
|
||||
Vector<Bounds<int>> BLF_str_selection_boxes(
|
||||
int fontid, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
|
|
@ -1058,10 +1060,10 @@ void BLF_draw_buffer(int fontid, const char *str, const size_t str_len, ResultBL
|
|||
}
|
||||
}
|
||||
|
||||
blender::Vector<blender::StringRef> BLF_string_wrap(int fontid,
|
||||
blender::StringRef str,
|
||||
const int max_pixel_width,
|
||||
BLFWrapMode mode)
|
||||
Vector<StringRef> BLF_string_wrap(int fontid,
|
||||
StringRef str,
|
||||
const int max_pixel_width,
|
||||
BLFWrapMode mode)
|
||||
{
|
||||
FontBLF *font = blf_get(fontid);
|
||||
if (!font) {
|
||||
|
|
@ -1179,3 +1181,5 @@ void BLF_state_print(int fontid)
|
|||
fflush(stdout);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "BLF_api.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
/* call BLF_default_set first! */
|
||||
#define ASSERT_DEFAULT_SET BLI_assert(global_font_default != -1)
|
||||
|
||||
|
|
@ -57,3 +59,5 @@ void BLF_draw_default(
|
|||
BLF_position(global_font_default, x, y, z);
|
||||
BLF_draw(global_font_default, str, str_len);
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
#include "blf_internal.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
char *blf_dir_metrics_search(const char *filepath)
|
||||
{
|
||||
char *mfile;
|
||||
|
|
@ -55,3 +57,5 @@ char *blf_dir_metrics_search(const char *filepath)
|
|||
MEM_freeN(mfile);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
namespace blender {
|
||||
|
||||
#ifdef WIN32
|
||||
# define FT_New_Face FT_New_Face__win32_compat
|
||||
#endif
|
||||
|
|
@ -64,13 +66,13 @@ static FTC_Manager ftc_manager = nullptr;
|
|||
static FTC_CMapCache ftc_charmap_cache = nullptr;
|
||||
|
||||
/* Mutex around face creation and deletion. */
|
||||
static blender::Mutex ft_face_load_mutex;
|
||||
static Mutex ft_face_load_mutex;
|
||||
|
||||
/* Lock around places that query free type caching system, and use the
|
||||
* calculated ft_size result. `FTC_Manager_LookupSize` can remove
|
||||
* ft_size of a completely different font instance, when the cache
|
||||
* is full! */
|
||||
static blender::Mutex ft_cache_size_mutex;
|
||||
static Mutex ft_cache_size_mutex;
|
||||
|
||||
/* May be set to #widgetbase_draw_cache_flush. */
|
||||
static void (*blf_draw_cache_flush)() = nullptr;
|
||||
|
|
@ -263,7 +265,7 @@ void blf_batch_draw_begin(FontBLF *font)
|
|||
}
|
||||
}
|
||||
|
||||
static blender::gpu::Texture *blf_batch_cache_texture_load()
|
||||
static gpu::Texture *blf_batch_cache_texture_load()
|
||||
{
|
||||
GlyphCacheBLF *gc = g_batch.glyph_cache;
|
||||
BLI_assert(gc);
|
||||
|
|
@ -316,7 +318,7 @@ void blf_batch_draw()
|
|||
blf_draw_cache_flush();
|
||||
}
|
||||
|
||||
blender::gpu::Texture *texture = blf_batch_cache_texture_load();
|
||||
gpu::Texture *texture = blf_batch_cache_texture_load();
|
||||
GPU_storagebuf_usage_size_set(g_batch.glyph_buf, size_t(g_batch.glyph_len) * sizeof(GlyphQuad));
|
||||
GPU_storagebuf_update(g_batch.glyph_buf, g_batch.glyph_data);
|
||||
GPU_storagebuf_bind(g_batch.glyph_buf, 0);
|
||||
|
|
@ -536,7 +538,7 @@ void blf_draw_svg_icon(FontBLF *font,
|
|||
const float color[4],
|
||||
const float outline_alpha,
|
||||
const bool multicolor,
|
||||
blender::FunctionRef<void(std::string &)> edit_source_cb)
|
||||
FunctionRef<void(std::string &)> edit_source_cb)
|
||||
{
|
||||
BLI_assert(outline_alpha <= 1.0f); /* Higher values overflow, caller must ensure. */
|
||||
blf_font_size(font, size);
|
||||
|
|
@ -575,13 +577,13 @@ void blf_draw_svg_icon(FontBLF *font,
|
|||
blf_glyph_cache_release(font);
|
||||
}
|
||||
|
||||
blender::Array<uchar> blf_svg_icon_bitmap(FontBLF *font,
|
||||
const uint icon_id,
|
||||
const float size,
|
||||
int *r_width,
|
||||
int *r_height,
|
||||
const bool multicolor,
|
||||
blender::FunctionRef<void(std::string &)> edit_source_cb)
|
||||
Array<uchar> blf_svg_icon_bitmap(FontBLF *font,
|
||||
const uint icon_id,
|
||||
const float size,
|
||||
int *r_width,
|
||||
int *r_height,
|
||||
const bool multicolor,
|
||||
FunctionRef<void(std::string &)> edit_source_cb)
|
||||
{
|
||||
blf_font_size(font, size);
|
||||
GlyphCacheBLF *gc = blf_glyph_cache_acquire(font);
|
||||
|
|
@ -596,7 +598,7 @@ blender::Array<uchar> blf_svg_icon_bitmap(FontBLF *font,
|
|||
|
||||
*r_width = g->dims[0];
|
||||
*r_height = g->dims[1];
|
||||
blender::Array<uchar> bitmap(g->dims[0] * g->dims[1] * 4);
|
||||
Array<uchar> bitmap(g->dims[0] * g->dims[1] * 4);
|
||||
|
||||
if (g->num_channels == 4) {
|
||||
memcpy(bitmap.data(), g->bitmap, size_t(bitmap.size()));
|
||||
|
|
@ -1232,13 +1234,13 @@ int blf_str_offset_to_cursor(FontBLF *font,
|
|||
return int(blf_font_width(font, str, str_len, nullptr));
|
||||
}
|
||||
|
||||
blender::Vector<blender::Bounds<int>> blf_str_selection_boxes(
|
||||
Vector<Bounds<int>> blf_str_selection_boxes(
|
||||
FontBLF *font, const char *str, size_t str_len, size_t sel_start, size_t sel_length)
|
||||
{
|
||||
blender::Vector<blender::Bounds<int>> boxes;
|
||||
Vector<Bounds<int>> boxes;
|
||||
const int start = blf_str_offset_to_cursor(font, str, str_len, sel_start, 0);
|
||||
const int end = blf_str_offset_to_cursor(font, str, str_len, sel_start + sel_length, 0);
|
||||
boxes.append(blender::Bounds(start, end));
|
||||
boxes.append(Bounds(start, end));
|
||||
return boxes;
|
||||
}
|
||||
|
||||
|
|
@ -1504,7 +1506,7 @@ void blf_font_draw_buffer__wrap(FontBLF *font,
|
|||
nullptr);
|
||||
}
|
||||
|
||||
/** Wrap a blender::StringRef. */
|
||||
/** Wrap a StringRef. */
|
||||
static void blf_font_string_wrap_cb(FontBLF * /*font*/,
|
||||
GlyphCacheBLF * /*gc*/,
|
||||
const char *str,
|
||||
|
|
@ -1512,18 +1514,17 @@ static void blf_font_string_wrap_cb(FontBLF * /*font*/,
|
|||
const ft_pix /*pen_y*/,
|
||||
void *str_list_ptr)
|
||||
{
|
||||
blender::Vector<blender::StringRef> *list = static_cast<blender::Vector<blender::StringRef> *>(
|
||||
str_list_ptr);
|
||||
blender::StringRef line(str, str + str_len);
|
||||
Vector<StringRef> *list = static_cast<Vector<StringRef> *>(str_list_ptr);
|
||||
StringRef line(str, str + str_len);
|
||||
list->append(line);
|
||||
}
|
||||
|
||||
blender::Vector<blender::StringRef> blf_font_string_wrap(FontBLF *font,
|
||||
blender::StringRef str,
|
||||
int max_pixel_width,
|
||||
BLFWrapMode mode)
|
||||
Vector<StringRef> blf_font_string_wrap(FontBLF *font,
|
||||
StringRef str,
|
||||
int max_pixel_width,
|
||||
BLFWrapMode mode)
|
||||
{
|
||||
blender::Vector<blender::StringRef> list;
|
||||
Vector<StringRef> list;
|
||||
blf_font_wrap_apply(font,
|
||||
str.data(),
|
||||
size_t(str.size()),
|
||||
|
|
@ -2174,3 +2175,5 @@ bool blf_font_size(FontBLF *font, float size)
|
|||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
# include "BLI_winstuff.h"
|
||||
#endif
|
||||
|
||||
namespace blender {
|
||||
|
||||
static int blf_load_font_default(const char *filename, const bool unique)
|
||||
{
|
||||
const std::optional<std::string> dir = BKE_appdir_folder_id(BLENDER_DATAFILES,
|
||||
|
|
@ -97,3 +99,5 @@ void BLF_load_font_stack()
|
|||
BLF_load_mono_default(false);
|
||||
blf_load_datafiles_dir();
|
||||
}
|
||||
|
||||
} // namespace blender
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
# define STREAM_FILE(stream) static_cast<FILE *>(stream->descriptor.pointer)
|
||||
# define FT_THROW(e) -1
|
||||
|
||||
using namespace blender;
|
||||
|
||||
static void ft_ansi_stream_close(FT_Stream stream)
|
||||
{
|
||||
fclose(STREAM_FILE(stream));
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue