Mesh: Replace auto smooth with node group #108014
|
@ -937,7 +937,6 @@ def brush_settings_advanced(layout, context, brush, popover=False):
|
|||
|
||||
col = layout.column(heading="Auto-Masking", align=True)
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.prop(brush, "use_automasking_topology", text="Topology")
|
||||
col.prop(brush, "use_automasking_face_sets", text="Face Sets")
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ typedef struct BlendFileData {
|
|||
*/
|
||||
typedef struct BlendFileReadWMSetupData {
|
||||
struct wmWindowManager *old_wm; /** The existing WM when filereading process is started. */
|
||||
|
||||
bool is_read_homefile;
|
||||
} BlendFileReadWMSetupData;
|
||||
|
||||
struct BlendFileReadParams {
|
||||
|
|
|
@ -2184,46 +2184,6 @@ static void versioning_replace_legacy_mix_rgb_node(bNodeTree *ntree)
|
|||
}
|
||||
}
|
||||
|
||||
static void versioning_replace_legacy_glossy_node(bNodeTree *ntree)
|
||||
{
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->type == SH_NODE_BSDF_GLOSSY_LEGACY) {
|
||||
strcpy(node->idname, "ShaderNodeBsdfAnisotropic");
|
||||
node->type = SH_NODE_BSDF_GLOSSY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void versioning_remove_microfacet_sharp_distribution(bNodeTree *ntree)
|
||||
{
|
||||
/* Find all glossy, glass and refraction BSDF nodes that have their distribution
|
||||
* set to SHARP and set them to GGX, disconnect any link to the Roughness input
|
||||
* and set its value to zero. */
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (!ELEM(node->type, SH_NODE_BSDF_GLOSSY, SH_NODE_BSDF_GLASS, SH_NODE_BSDF_REFRACTION)) {
|
||||
continue;
|
||||
}
|
||||
if (node->custom1 != SHD_GLOSSY_SHARP_DEPRECATED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
node->custom1 = SHD_GLOSSY_GGX;
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
||||
if (!STREQ(socket->identifier, "Roughness")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (socket->link != nullptr) {
|
||||
nodeRemLink(ntree, socket->link);
|
||||
}
|
||||
bNodeSocketValueFloat *socket_value = (bNodeSocketValueFloat *)socket->default_value;
|
||||
socket_value->value = 0.0f;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void version_fix_image_format_copy(Main *bmain, ImageFormatData *format)
|
||||
{
|
||||
/* Fix bug where curves in image format were not properly copied to file output
|
||||
|
@ -4461,26 +4421,8 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
|
||||
/* Convert anisotropic BSDF node to glossy BSDF. */
|
||||
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
|
||||
versioning_replace_legacy_glossy_node(ntree);
|
||||
versioning_remove_microfacet_sharp_distribution(ntree);
|
||||
}
|
||||
FOREACH_NODETREE_END;
|
||||
|
||||
BKE_animdata_main_cb(bmain, version_liboverride_nla_frame_start_end, nullptr);
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 306, 11)) {
|
||||
BKE_animdata_main_cb(bmain, version_liboverride_nla_frame_start_end, NULL);
|
||||
|
||||
/* Store simulation bake directory in geometry nodes modifier. */
|
||||
LISTBASE_FOREACH (Object *, ob, &bmain->objects) {
|
||||
|
@ -4519,4 +4461,18 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - #do_versions_after_linking_300 in this file.
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,9 +152,24 @@ static void version_mesh_objects_replace_auto_smooth(Main &bmain)
|
|||
}
|
||||
}
|
||||
|
||||
void do_versions_after_linking_400(FileData * /*fd*/, Main *bmain)
|
||||
void do_versions_after_linking_400(FileData * /*fd*/, Main * /*bmain*/)
|
||||
{
|
||||
version_mesh_objects_replace_auto_smooth(*bmain);
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - #blo_do_versions_400 in this file.
|
||||
* - "versioning_cycles.cc", #blo_do_versions_cycles
|
||||
* - "versioning_cycles.cc", #do_versions_after_linking_cycles
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Keep this block, even when empty. */
|
||||
version_mesh_objects_replace_auto_smooth(*bmain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void version_mesh_legacy_to_struct_of_array_format(Mesh &mesh)
|
||||
|
@ -224,6 +239,46 @@ static void version_geometry_nodes_add_realize_instance_nodes(bNodeTree *ntree)
|
|||
}
|
||||
}
|
||||
|
||||
static void versioning_replace_legacy_glossy_node(bNodeTree *ntree)
|
||||
{
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (node->type == SH_NODE_BSDF_GLOSSY_LEGACY) {
|
||||
strcpy(node->idname, "ShaderNodeBsdfAnisotropic");
|
||||
node->type = SH_NODE_BSDF_GLOSSY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void versioning_remove_microfacet_sharp_distribution(bNodeTree *ntree)
|
||||
{
|
||||
/* Find all glossy, glass and refraction BSDF nodes that have their distribution
|
||||
* set to SHARP and set them to GGX, disconnect any link to the Roughness input
|
||||
* and set its value to zero. */
|
||||
LISTBASE_FOREACH (bNode *, node, &ntree->nodes) {
|
||||
if (!ELEM(node->type, SH_NODE_BSDF_GLOSSY, SH_NODE_BSDF_GLASS, SH_NODE_BSDF_REFRACTION)) {
|
||||
continue;
|
||||
}
|
||||
if (node->custom1 != SHD_GLOSSY_SHARP_DEPRECATED) {
|
||||
continue;
|
||||
}
|
||||
|
||||
node->custom1 = SHD_GLOSSY_GGX;
|
||||
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
|
||||
if (!STREQ(socket->identifier, "Roughness")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (socket->link != nullptr) {
|
||||
nodeRemLink(ntree, socket->link);
|
||||
}
|
||||
bNodeSocketValueFloat *socket_value = (bNodeSocketValueFloat *)socket->default_value;
|
||||
socket_value->value = 0.0f;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
||||
{
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 400, 1)) {
|
||||
|
@ -263,12 +318,22 @@ void blo_do_versions_400(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
|
|||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
* \note Be sure to check when bumping the version:
|
||||
* - #do_versions_after_linking_400 in this file.
|
||||
* - "versioning_cycles.cc", #blo_do_versions_cycles
|
||||
* - "versioning_cycles.cc", #do_versions_after_linking_cycles
|
||||
* - "versioning_userdef.c", #blo_do_versions_userdef
|
||||
* - "versioning_userdef.c", #do_versions_theme
|
||||
*
|
||||
* \note Keep this message at the bottom of the function.
|
||||
*/
|
||||
{
|
||||
/* Convert anisotropic BSDF node to glossy BSDF. */
|
||||
FOREACH_NODETREE_BEGIN (bmain, ntree, id) {
|
||||
versioning_replace_legacy_glossy_node(ntree);
|
||||
versioning_remove_microfacet_sharp_distribution(ntree);
|
||||
}
|
||||
FOREACH_NODETREE_END;
|
||||
|
||||
/* Keep this block, even when empty. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1385,7 +1385,7 @@ eSnapMode snapObjectsTransform(
|
|||
SnapObjectParams snap_object_params{};
|
||||
snap_object_params.snap_target_select = t->tsnap.target_operation;
|
||||
snap_object_params.edit_mode_type = (t->flag & T_EDIT) != 0 ? SNAP_GEOM_EDIT : SNAP_GEOM_FINAL;
|
||||
snap_object_params.use_occlusion_test = t->settings->snap_mode != SCE_SNAP_MODE_FACE;
|
||||
snap_object_params.use_occlusion_test = true;
|
||||
snap_object_params.use_backface_culling = (t->tsnap.flag & SCE_SNAP_BACKFACE_CULLING) != 0;
|
||||
|
||||
float *target = (t->tsnap.status & SNAP_SOURCE_FOUND) ? t->tsnap.snap_source : t->center_global;
|
||||
|
|
|
@ -969,7 +969,8 @@ struct RaycastObjUserData {
|
|||
/* read/write args */
|
||||
float *ray_depth;
|
||||
|
||||
bool use_occlusion_test;
|
||||
uint use_occlusion_test : 1;
|
||||
uint use_occlusion_test_edit : 1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -986,21 +987,17 @@ static eSnapMode raycast_obj_fn(SnapObjectContext *sctx,
|
|||
{
|
||||
RaycastObjUserData *dt = static_cast<RaycastObjUserData *>(data);
|
||||
const uint ob_index = dt->ob_index++;
|
||||
bool use_occlusion_test = dt->use_occlusion_test;
|
||||
/* read/write args */
|
||||
float *ray_depth = dt->ray_depth;
|
||||
|
||||
bool retval = false;
|
||||
bool is_edit = false;
|
||||
if (use_occlusion_test) {
|
||||
if (ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) {
|
||||
/* Do not hit objects that are in wire or bounding box
|
||||
* display mode. */
|
||||
return SCE_SNAP_MODE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (ob_data == nullptr) {
|
||||
if (dt->use_occlusion_test_edit && ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) {
|
||||
/* Do not hit objects that are in wire or bounding box display mode. */
|
||||
return SCE_SNAP_MODE_NONE;
|
||||
}
|
||||
if (ob_eval->type == OB_MESH) {
|
||||
BMEditMesh *em = BKE_editmesh_from_object(ob_eval);
|
||||
if (UNLIKELY(!em)) { /* See #mesh_for_snap doc-string. */
|
||||
|
@ -1028,6 +1025,10 @@ static eSnapMode raycast_obj_fn(SnapObjectContext *sctx,
|
|||
return SCE_SNAP_MODE_NONE;
|
||||
}
|
||||
}
|
||||
else if (dt->use_occlusion_test && ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) {
|
||||
/* Do not hit objects that are in wire or bounding box display mode. */
|
||||
return SCE_SNAP_MODE_NONE;
|
||||
}
|
||||
else if (GS(ob_data->name) != ID_ME) {
|
||||
return SCE_SNAP_MODE_NONE;
|
||||
}
|
||||
|
@ -1080,26 +1081,20 @@ static bool raycastObjects(SnapObjectContext *sctx,
|
|||
const SnapObjectParams *params,
|
||||
const float ray_start[3],
|
||||
const float ray_dir[3],
|
||||
const bool use_occlusion_test,
|
||||
const bool use_occlusion_test_edit,
|
||||
/* read/write args */
|
||||
/* Parameters below cannot be const, because they are assigned to a
|
||||
* non-const variable (readability-non-const-parameter). */
|
||||
float *ray_depth /* NOLINT */)
|
||||
{
|
||||
const View3D *v3d = sctx->runtime.v3d;
|
||||
if (params->use_occlusion_test && v3d && XRAY_FLAG_ENABLED(v3d)) {
|
||||
/* General testing of occlusion geometry is disabled if the snap is not intended for the edit
|
||||
* cage. */
|
||||
if (params->edit_mode_type == SNAP_GEOM_EDIT) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RaycastObjUserData data = {};
|
||||
data.ray_start = ray_start;
|
||||
data.ray_dir = ray_dir;
|
||||
data.ob_index = 0;
|
||||
data.ray_depth = ray_depth;
|
||||
data.use_occlusion_test = params->use_occlusion_test;
|
||||
data.use_occlusion_test = use_occlusion_test;
|
||||
data.use_occlusion_test_edit = use_occlusion_test_edit;
|
||||
|
||||
return iter_snap_objects(sctx, params, raycast_obj_fn, &data) != SCE_SNAP_MODE_NONE;
|
||||
}
|
||||
|
@ -3117,7 +3112,14 @@ bool ED_transform_snap_object_project_ray_ex(SnapObjectContext *sctx,
|
|||
sctx->ret.dist_sq = FLT_MAX;
|
||||
sctx->ret.is_edit = false;
|
||||
|
||||
if (raycastObjects(sctx, params, ray_start, ray_normal, ray_depth)) {
|
||||
if (raycastObjects(sctx,
|
||||
params,
|
||||
ray_start,
|
||||
ray_normal,
|
||||
params->use_occlusion_test,
|
||||
params->use_occlusion_test,
|
||||
ray_depth))
|
||||
{
|
||||
copy_v3_v3(r_loc, sctx->ret.loc);
|
||||
if (r_no) {
|
||||
copy_v3_v3(r_no, sctx->ret.no);
|
||||
|
@ -3167,7 +3169,14 @@ bool ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx,
|
|||
float ray_depth_prev = ray_depth;
|
||||
#endif
|
||||
|
||||
if (raycastObjects(sctx, params, ray_start, ray_normal, &ray_depth)) {
|
||||
if (raycastObjects(sctx,
|
||||
params,
|
||||
ray_start,
|
||||
ray_normal,
|
||||
params->use_occlusion_test,
|
||||
params->use_occlusion_test,
|
||||
&ray_depth))
|
||||
{
|
||||
if (sort) {
|
||||
BLI_listbase_sort(r_hit_list, hit_depth_cmp);
|
||||
}
|
||||
|
@ -3275,17 +3284,21 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
|
|||
|
||||
const RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
|
||||
|
||||
if (snap_to_flag & (SCE_SNAP_MODE_FACE | SCE_SNAP_MODE_FACE_NEAREST)) {
|
||||
if (params->use_occlusion_test && XRAY_ENABLED(v3d)) {
|
||||
/* Remove Snap to Face with Occlusion Test as they are not visible in wireframe mode. */
|
||||
snap_to_flag &= ~(SCE_SNAP_MODE_FACE | SCE_SNAP_MODE_FACE_NEAREST);
|
||||
}
|
||||
else if (prev_co == nullptr || init_co == nullptr) {
|
||||
/* No location to work with #SCE_SNAP_MODE_FACE_NEAREST. */
|
||||
snap_to_flag &= ~SCE_SNAP_MODE_FACE_NEAREST;
|
||||
bool use_occlusion_test = params->use_occlusion_test;
|
||||
|
||||
if (use_occlusion_test && XRAY_ENABLED(v3d) && (snap_to_flag & SCE_SNAP_MODE_FACE)) {
|
||||
if (snap_to_flag != SCE_SNAP_MODE_FACE) {
|
||||
/* In theory everything is visible in X-Ray except faces. */
|
||||
snap_to_flag &= ~SCE_SNAP_MODE_FACE;
|
||||
use_occlusion_test = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && ELEM(nullptr, prev_co, init_co)) {
|
||||
/* No location to work with #SCE_SNAP_MODE_FACE_NEAREST. */
|
||||
snap_to_flag &= ~SCE_SNAP_MODE_FACE_NEAREST;
|
||||
}
|
||||
|
||||
/* NOTE: if both face ray-cast and face nearest are enabled, first find result of nearest, then
|
||||
* override with ray-cast. */
|
||||
if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && !has_hit) {
|
||||
|
@ -3310,8 +3323,6 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
|
|||
}
|
||||
}
|
||||
|
||||
bool use_occlusion_test = params->use_occlusion_test && !XRAY_ENABLED(v3d);
|
||||
|
||||
if ((snap_to_flag & SCE_SNAP_MODE_FACE) || use_occlusion_test) {
|
||||
float ray_start[3], ray_normal[3];
|
||||
if (!ED_view3d_win_to_ray_clipped_ex(
|
||||
|
@ -3322,7 +3333,13 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont
|
|||
|
||||
float dummy_ray_depth = BVH_RAYCAST_DIST_MAX;
|
||||
|
||||
has_hit = raycastObjects(sctx, params, ray_start, ray_normal, &dummy_ray_depth);
|
||||
has_hit = raycastObjects(sctx,
|
||||
params,
|
||||
ray_start,
|
||||
ray_normal,
|
||||
use_occlusion_test,
|
||||
use_occlusion_test && (snap_to_flag & SCE_SNAP_MODE_FACE) == 0,
|
||||
&dummy_ray_depth);
|
||||
|
||||
if (has_hit) {
|
||||
if (r_face_nor) {
|
||||
|
|
|
@ -72,7 +72,6 @@ set(SRC
|
|||
intern/usd_asset_utils.cc
|
||||
intern/usd_capi_export.cc
|
||||
intern/usd_capi_import.cc
|
||||
intern/usd_common.cc
|
||||
intern/usd_hierarchy_iterator.cc
|
||||
intern/usd_writer_abstract.cc
|
||||
intern/usd_writer_camera.cc
|
||||
|
@ -101,7 +100,6 @@ set(SRC
|
|||
usd.h
|
||||
|
||||
intern/usd_asset_utils.h
|
||||
intern/usd_common.h
|
||||
intern/usd_exporter_context.h
|
||||
intern/usd_hierarchy_iterator.h
|
||||
intern/usd_writer_abstract.h
|
||||
|
@ -161,8 +159,6 @@ if(WITH_GTESTS)
|
|||
tests/usd_curves_test.cc
|
||||
tests/usd_export_test.cc
|
||||
tests/usd_stage_creation_test.cc
|
||||
tests/usd_tests_common.cc
|
||||
tests/usd_tests_common.h
|
||||
tests/usd_usdz_export_test.cc
|
||||
intern/usd_writer_material.h
|
||||
)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_common.h"
|
||||
#include "usd_hierarchy_iterator.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include "IO_types.h"
|
||||
#include "usd.h"
|
||||
#include "usd_common.h"
|
||||
#include "usd_hierarchy_iterator.h"
|
||||
#include "usd_reader_geom.h"
|
||||
#include "usd_reader_prim.h"
|
||||
|
@ -409,11 +408,6 @@ static void import_freejob(void *user_data)
|
|||
|
||||
using namespace blender::io::usd;
|
||||
|
||||
void USD_ensure_plugin_path_registered()
|
||||
{
|
||||
blender::io::usd::ensure_usd_plugin_path_registered();
|
||||
}
|
||||
|
||||
bool USD_import(struct bContext *C,
|
||||
const char *filepath,
|
||||
const USDImportParams *params,
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2021 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "usd_common.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
void ensure_usd_plugin_path_registered()
|
||||
{
|
||||
/* If #PXR_PYTHON_SUPPORT_ENABLED is defined, we *must* be dynamic and
|
||||
* the plugins are placed relative to the USD shared library hence no
|
||||
* hinting is required. */
|
||||
#ifndef PXR_PYTHON_SUPPORT_ENABLED
|
||||
static bool plugin_path_registered = false;
|
||||
if (plugin_path_registered) {
|
||||
return;
|
||||
}
|
||||
plugin_path_registered = true;
|
||||
|
||||
/* Tell USD which directory to search for its JSON files. If 'datafiles/usd'
|
||||
* does not exist, the USD library will not be able to read or write any files. */
|
||||
const char *blender_usd_datafiles = BKE_appdir_folder_id(BLENDER_DATAFILES, "usd");
|
||||
if (blender_usd_datafiles) {
|
||||
const std::string blender_usd_data_folder = blender_usd_datafiles;
|
||||
/* The trailing slash indicates to the USD library that the path is a directory. */
|
||||
pxr::PlugRegistry::GetInstance().RegisterPlugins(blender_usd_data_folder + SEP_STR);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -1,10 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2021 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#pragma once
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
void ensure_usd_plugin_path_registered();
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -41,7 +41,6 @@
|
|||
#include "WM_api.h"
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
@ -86,10 +85,6 @@ class UsdCurvesTest : public BlendfileLoadingBaseTest {
|
|||
virtual void SetUp() override
|
||||
{
|
||||
BlendfileLoadingBaseTest::SetUp();
|
||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
||||
if (usd_plugin_path.empty()) {
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void TearDown() override
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "WM_api.h"
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_tests_common.h"
|
||||
#include "usd_writer_material.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
@ -73,10 +72,6 @@ class UsdExportTest : public BlendfileLoadingBaseTest {
|
|||
virtual void SetUp() override
|
||||
{
|
||||
BlendfileLoadingBaseTest::SetUp();
|
||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
||||
if (usd_plugin_path.empty()) {
|
||||
FAIL() << "Unable to find the USD Plugins path.";
|
||||
}
|
||||
}
|
||||
|
||||
virtual void TearDown() override
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
#include <pxr/usd/usdGeom/capsule.h>
|
||||
#include <pxr/usdImaging/usdImaging/capsuleAdapter.h>
|
||||
|
@ -21,13 +19,6 @@ TEST_F(USDImagingTest, CapsuleAdapterTest)
|
|||
* We create a capsule shape on an in-memory stage and attempt
|
||||
* to access the shape's points and topology. */
|
||||
|
||||
/* We must register USD plugin paths before creating the stage
|
||||
* to avoid a crash in the USD asset resolver initialization code. */
|
||||
if (register_usd_plugins_for_tests().empty()) {
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
|
||||
|
||||
if (!stage) {
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
|
||||
|
@ -22,12 +20,6 @@ class USDStageCreationTest : public testing::Test {
|
|||
|
||||
TEST_F(USDStageCreationTest, JSONFileLoadingTest)
|
||||
{
|
||||
std::string usd_datafiles_dir = register_usd_plugins_for_tests();
|
||||
if (usd_datafiles_dir.empty()) {
|
||||
FAIL();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Simply the ability to create a USD Stage for a specific filename means that the extension
|
||||
* has been recognized by the USD library, and that a USD plugin has been loaded to write such
|
||||
* files. Practically, this is a test to see whether the USD JSON files can be found and
|
||||
|
@ -41,8 +33,7 @@ TEST_F(USDStageCreationTest, JSONFileLoadingTest)
|
|||
unlink(filename.c_str());
|
||||
}
|
||||
else {
|
||||
FAIL() << "unable to find suitable USD plugin to write " << filename << "; looked in "
|
||||
<< usd_datafiles_dir;
|
||||
FAIL() << "unable to find suitable USD plugin to write " << filename;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
std::string register_usd_plugins_for_tests()
|
||||
{
|
||||
static char usd_datafiles_dir[FILE_MAX] = {'\0'};
|
||||
static bool plugin_path_registered = false;
|
||||
if (plugin_path_registered) {
|
||||
return usd_datafiles_dir;
|
||||
}
|
||||
plugin_path_registered = true;
|
||||
|
||||
const std::string &release_dir = blender::tests::flags_test_release_dir();
|
||||
if (release_dir.empty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const size_t path_len = BLI_path_join(
|
||||
usd_datafiles_dir, FILE_MAX, release_dir.c_str(), "datafiles", "usd");
|
||||
|
||||
/* #BLI_path_join removes trailing slashes, but the USD library requires one in order to
|
||||
* recognize the path as directory. */
|
||||
BLI_assert(path_len + 1 < FILE_MAX);
|
||||
usd_datafiles_dir[path_len] = '/';
|
||||
usd_datafiles_dir[path_len + 1] = '\0';
|
||||
/* If #PXR_PYTHON_SUPPORT_ENABLED is defined, we *must* be dynamic and
|
||||
* the plugins are placed relative to the USD shared library hence no
|
||||
* hinting is required. */
|
||||
#ifndef PXR_PYTHON_SUPPORT_ENABLED
|
||||
pxr::PlugRegistry::GetInstance().RegisterPlugins(usd_datafiles_dir);
|
||||
#endif
|
||||
return usd_datafiles_dir;
|
||||
}
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -1,21 +0,0 @@
|
|||
/* SPDX-FileCopyrightText: 2022 Blender Foundation
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
/* Calls the function to load the USD plugins from the
|
||||
* USD data directory under the Blender bin directory
|
||||
* that was supplied as the --test-release-dir flag to `ctest`.
|
||||
* Thus function must be called before instantiating a USD
|
||||
* stage to avoid errors. The returned string is the path to
|
||||
* the USD data files directory from which the plugins were
|
||||
* loaded. If the USD data files directory can't be determined,
|
||||
* plugin registration is skipped and the empty string is
|
||||
* returned. */
|
||||
std::string register_usd_plugins_for_tests();
|
||||
|
||||
} // namespace blender::io::usd
|
|
@ -20,7 +20,6 @@
|
|||
#include "WM_api.h"
|
||||
|
||||
#include "usd.h"
|
||||
#include "usd_tests_common.h"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
@ -52,10 +51,6 @@ class UsdUsdzExportTest : public BlendfileLoadingBaseTest {
|
|||
virtual void SetUp() override
|
||||
{
|
||||
BlendfileLoadingBaseTest::SetUp();
|
||||
std::string usd_plugin_path = register_usd_plugins_for_tests();
|
||||
if (usd_plugin_path.empty()) {
|
||||
FAIL();
|
||||
}
|
||||
|
||||
BKE_tempdir_init(nullptr);
|
||||
const char *temp_base_dir = BKE_tempdir_base();
|
||||
|
|
|
@ -149,7 +149,6 @@ struct CacheReader *CacheReader_open_usd_object(struct CacheArchiveHandle *handl
|
|||
|
||||
void USD_CacheReader_incref(struct CacheReader *reader);
|
||||
void USD_CacheReader_free(struct CacheReader *reader);
|
||||
void USD_ensure_plugin_path_registered(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2047,13 +2047,18 @@ static const EnumPropertyItem *rna_SpaceProperties_context_itemf(bContext *UNUSE
|
|||
BLI_assert(totitem <= ARRAY_SIZE(context_tabs_array));
|
||||
|
||||
int totitem_added = 0;
|
||||
bool add_separator = true;
|
||||
for (int i = 0; i < totitem; i++) {
|
||||
if (context_tabs_array[i] == -1) {
|
||||
RNA_enum_item_add_separator(&item, &totitem_added);
|
||||
if (add_separator) {
|
||||
RNA_enum_item_add_separator(&item, &totitem_added);
|
||||
add_separator = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
RNA_enum_items_add_value(&item, &totitem_added, buttons_context_items, context_tabs_array[i]);
|
||||
add_separator = true;
|
||||
|
||||
/* Add the object data icon dynamically for the data tab. */
|
||||
if (context_tabs_array[i] == BCONTEXT_DATA) {
|
||||
|
|
|
@ -182,7 +182,7 @@ void ntreeCompositExecTree(Render *render,
|
|||
#ifdef WITH_COMPOSITOR_CPU
|
||||
COM_execute(render, rd, scene, ntree, rendering, view_name);
|
||||
#else
|
||||
UNUSED_VARS(scene, ntree, rd, rendering, view_name);
|
||||
UNUSED_VARS(render, scene, ntree, rd, rendering, view_name);
|
||||
#endif
|
||||
|
||||
UNUSED_VARS(do_preview);
|
||||
|
|
|
@ -216,7 +216,7 @@ class Context : public realtime_compositor::Context {
|
|||
* incomplete support, and leave more specific message to individual nodes? */
|
||||
}
|
||||
|
||||
IDRecalcFlag query_id_recalc_flag(ID *id) const override
|
||||
IDRecalcFlag query_id_recalc_flag(ID * /* id */) const override
|
||||
{
|
||||
/* TODO: implement? */
|
||||
return IDRecalcFlag(0);
|
||||
|
|
|
@ -182,11 +182,14 @@ bool wm_file_or_session_data_has_unsaved_changes(const Main *bmain, const wmWind
|
|||
* Clear several WM/UI runtime data that would make later complex WM handling impossible.
|
||||
*
|
||||
* Return data should be cleared by #wm_file_read_setup_wm_finalize. */
|
||||
static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C, Main *bmain)
|
||||
static BlendFileReadWMSetupData *wm_file_read_setup_wm_init(bContext *C,
|
||||
Main *bmain,
|
||||
const bool is_read_homefile)
|
||||
{
|
||||
BLI_assert(BLI_listbase_count_at_most(&bmain->wm, 2) <= 1);
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
BlendFileReadWMSetupData *wm_setup_data = MEM_cnew<BlendFileReadWMSetupData>(__func__);
|
||||
wm_setup_data->is_read_homefile = is_read_homefile;
|
||||
|
||||
if (wm == nullptr) {
|
||||
return wm_setup_data;
|
||||
|
@ -401,6 +404,13 @@ static void wm_file_read_setup_wm_finalize(bContext *C,
|
|||
BLI_assert(wm_setup_data != nullptr);
|
||||
wmWindowManager *wm = static_cast<wmWindowManager *>(bmain->wm.first);
|
||||
|
||||
/* If reading home (startup) file, and there was no previous WM, clear the size of the windows in
|
||||
* newly read WM so that they get resized to occupy the whole available space on current monitor.
|
||||
*/
|
||||
if (wm_setup_data->is_read_homefile && wm_setup_data->old_wm == nullptr) {
|
||||
wm_clear_default_size(C);
|
||||
}
|
||||
|
||||
if (wm == nullptr) {
|
||||
/* Add a default WM in case none exists in newly read main (should only happen when opening
|
||||
* an old pre-2.5 .blend file at startup). */
|
||||
|
@ -994,7 +1004,7 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports)
|
|||
|
||||
/* Put WM into a stable state for post-readfile processes (kill jobs, removes event handlers,
|
||||
* message bus, and so on). */
|
||||
BlendFileReadWMSetupData *wm_setup_data = wm_file_read_setup_wm_init(C, bmain);
|
||||
BlendFileReadWMSetupData *wm_setup_data = wm_file_read_setup_wm_init(C, bmain, false);
|
||||
|
||||
/* This flag is initialized by the operator but overwritten on read.
|
||||
* need to re-enable it here else drivers and registered scripts won't work. */
|
||||
|
@ -1117,7 +1127,6 @@ void wm_homefile_read_ex(bContext *C,
|
|||
/* Context does not always have valid main pointer here. */
|
||||
Main *bmain = G_MAIN;
|
||||
#endif
|
||||
ListBase wmbase;
|
||||
bool success = false;
|
||||
|
||||
/* May be enabled, when the user configuration doesn't exist. */
|
||||
|
@ -1223,7 +1232,7 @@ void wm_homefile_read_ex(bContext *C,
|
|||
if (use_data) {
|
||||
/* Put WM into a stable state for post-readfile processes (kill jobs, removes event handlers,
|
||||
* message bus, and so on). */
|
||||
wm_setup_data = wm_file_read_setup_wm_init(C, bmain);
|
||||
wm_setup_data = wm_file_read_setup_wm_init(C, bmain, true);
|
||||
}
|
||||
|
||||
filepath_startup[0] = '\0';
|
||||
|
@ -1357,10 +1366,6 @@ void wm_homefile_read_ex(bContext *C,
|
|||
success = true;
|
||||
bmain = CTX_data_main(C);
|
||||
}
|
||||
|
||||
if (use_data && BLI_listbase_is_empty(&wmbase)) {
|
||||
wm_clear_default_size(C);
|
||||
}
|
||||
}
|
||||
|
||||
if (use_empty_data) {
|
||||
|
|
|
@ -96,10 +96,6 @@
|
|||
# include "sdlew.h"
|
||||
#endif
|
||||
|
||||
#ifdef WITH_USD
|
||||
# include "usd.h"
|
||||
#endif
|
||||
|
||||
#include "creator_intern.h" /* Own include. */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -476,10 +472,6 @@ int main(int argc,
|
|||
/* Initialize sub-systems that use `BKE_appdir.h`. */
|
||||
IMB_init();
|
||||
|
||||
#ifdef WITH_USD
|
||||
USD_ensure_plugin_path_registered();
|
||||
#endif
|
||||
|
||||
#ifndef WITH_PYTHON_MODULE
|
||||
/* First test for background-mode (#Global.background) */
|
||||
BLI_args_parse(ba, ARG_PASS_SETTINGS, NULL, NULL);
|
||||
|
|
Loading…
Reference in New Issue
Creating IDs in versioning code is forbidden. Until a better system (more generic) is implemented, a specific call needs to be added after all versioning is done, see e.g. the call to
BKE_lib_override_library_main_proxy_convert
insetup_app_data()