Cleanup: USD: various non-functional changes
- Use const in more places - Use more appropriate headers and forward decls elsewhere - Remove one instance of variable shadowing - Rename an internal rna enum list and the USD operator property object to follow surrounding code and naming guidelines Pull Request: https://projects.blender.org/blender/blender/pulls/136112
This commit is contained in:
committed by
Jesse Yurkovich
parent
d267ec3ec1
commit
e9a21cf14c
@@ -145,7 +145,7 @@ const EnumPropertyItem rna_enum_usd_xform_op_mode_items[] = {
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
const EnumPropertyItem prop_usdz_downscale_size[] = {
|
||||
const EnumPropertyItem rna_enum_usdz_downscale_size[] = {
|
||||
{USD_TEXTURE_SIZE_KEEP, "KEEP", 0, "Keep", "Keep all current texture sizes"},
|
||||
{USD_TEXTURE_SIZE_256, "256", 0, "256", "Resize to a maximum of 256 pixels"},
|
||||
{USD_TEXTURE_SIZE_512, "512", 0, "512", "Resize to a maximum of 512 pixels"},
|
||||
@@ -218,7 +218,7 @@ const EnumPropertyItem rna_enum_usd_convert_scene_units_items[] = {
|
||||
|
||||
/* Stored in the wmOperator's customdata field to indicate it should run as a background job.
|
||||
* This is set when the operator is invoked, and not set when it is only executed. */
|
||||
struct eUSDOperatorOptions {
|
||||
struct USDOperatorOptions {
|
||||
bool as_background_job;
|
||||
};
|
||||
|
||||
@@ -246,7 +246,7 @@ static void process_prim_path(char *prim_path)
|
||||
|
||||
static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/)
|
||||
{
|
||||
eUSDOperatorOptions *options = MEM_callocN<eUSDOperatorOptions>("eUSDOperatorOptions");
|
||||
USDOperatorOptions *options = MEM_callocN<USDOperatorOptions>("USDOperatorOptions");
|
||||
options->as_background_job = true;
|
||||
op->customdata = options;
|
||||
|
||||
@@ -267,7 +267,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
|
||||
char filepath[FILE_MAX];
|
||||
RNA_string_get(op->ptr, "filepath", filepath);
|
||||
|
||||
eUSDOperatorOptions *options = static_cast<eUSDOperatorOptions *>(op->customdata);
|
||||
USDOperatorOptions *options = static_cast<USDOperatorOptions *>(op->customdata);
|
||||
const bool as_background_job = (options != nullptr && options->as_background_job);
|
||||
MEM_SAFE_FREE(op->customdata);
|
||||
|
||||
@@ -868,7 +868,7 @@ void WM_OT_usd_export(wmOperatorType *ot)
|
||||
|
||||
RNA_def_enum(ot->srna,
|
||||
"usdz_downscale_size",
|
||||
prop_usdz_downscale_size,
|
||||
rna_enum_usdz_downscale_size,
|
||||
DAG_EVAL_VIEWPORT,
|
||||
"USDZ Texture Downsampling",
|
||||
"Choose a maximum size for all exported textures");
|
||||
@@ -913,7 +913,7 @@ void WM_OT_usd_export(wmOperatorType *ot)
|
||||
|
||||
static int wm_usd_import_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
eUSDOperatorOptions *options = MEM_callocN<eUSDOperatorOptions>("eUSDOperatorOptions");
|
||||
USDOperatorOptions *options = MEM_callocN<USDOperatorOptions>("USDOperatorOptions");
|
||||
options->as_background_job = true;
|
||||
op->customdata = options;
|
||||
|
||||
@@ -930,7 +930,7 @@ static int wm_usd_import_exec(bContext *C, wmOperator *op)
|
||||
char filepath[FILE_MAX];
|
||||
RNA_string_get(op->ptr, "filepath", filepath);
|
||||
|
||||
eUSDOperatorOptions *options = static_cast<eUSDOperatorOptions *>(op->customdata);
|
||||
USDOperatorOptions *options = static_cast<USDOperatorOptions *>(op->customdata);
|
||||
const bool as_background_job = (options != nullptr && options->as_background_job);
|
||||
MEM_SAFE_FREE(op->customdata);
|
||||
|
||||
|
||||
@@ -69,8 +69,7 @@ void visit_bones(const Object *ob_arm, FunctionRef<void(const Bone *)> visitor)
|
||||
return;
|
||||
}
|
||||
|
||||
bArmature *armature = (bArmature *)ob_arm->data;
|
||||
|
||||
const bArmature *armature = (bArmature *)ob_arm->data;
|
||||
LISTBASE_FOREACH (const Bone *, bone, &armature->bonebase) {
|
||||
visit_bones(bone, visitor);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
#include <pxr/usd/usd/common.h>
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
||||
@@ -341,8 +341,8 @@ void remap_blend_shape_anim(pxr::UsdStageRefPtr stage,
|
||||
for (const pxr::SdfPath &mesh_path : mesh_paths) {
|
||||
|
||||
pxr::UsdPrim mesh_prim = stage->GetPrimAtPath(mesh_path);
|
||||
pxr::UsdSkelBindingAPI skel_api = pxr::UsdSkelBindingAPI::Apply(mesh_prim);
|
||||
if (!skel_api) {
|
||||
pxr::UsdSkelBindingAPI mesh_skel_api = pxr::UsdSkelBindingAPI::Apply(mesh_prim);
|
||||
if (!mesh_skel_api) {
|
||||
CLOG_WARN(&LOG,
|
||||
"Couldn't apply UsdSkelBindingAPI to mesh prim %s",
|
||||
mesh_path.GetAsString().c_str());
|
||||
@@ -350,14 +350,14 @@ void remap_blend_shape_anim(pxr::UsdStageRefPtr stage,
|
||||
}
|
||||
|
||||
/* Get the blend shape names for this mesh. */
|
||||
pxr::UsdAttribute blend_shapes_attr = skel_api.GetBlendShapesAttr();
|
||||
pxr::UsdAttribute blend_shapes_attr = mesh_skel_api.GetBlendShapesAttr();
|
||||
|
||||
if (!blend_shapes_attr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pxr::VtTokenArray names;
|
||||
if (!skel_api.GetBlendShapesAttr().Get(&names)) {
|
||||
if (!mesh_skel_api.GetBlendShapesAttr().Get(&names)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ void remap_blend_shape_anim(pxr::UsdStageRefPtr stage,
|
||||
}
|
||||
|
||||
/* Set the unique names back on the mesh. */
|
||||
skel_api.GetBlendShapesAttr().Set(unique_names);
|
||||
mesh_skel_api.GetBlendShapesAttr().Set(unique_names);
|
||||
|
||||
/* Look up the temporary weights time sample we wrote to the mesh. */
|
||||
const pxr::UsdAttribute temp_weights_attr = pxr::UsdGeomPrimvarsAPI(mesh_prim).GetPrimvar(
|
||||
@@ -448,7 +448,7 @@ Mesh *get_shape_key_basis_mesh(Object *obj)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
KeyBlock *basis = reinterpret_cast<KeyBlock *>(mesh->key->block.first);
|
||||
const KeyBlock *basis = reinterpret_cast<KeyBlock *>(mesh->key->block.first);
|
||||
|
||||
if (mesh->verts_num != basis->totelem) {
|
||||
CLOG_WARN(&LOG, "Vertex and shape key element count mismatch for mesh %s", obj->id.name + 2);
|
||||
|
||||
@@ -314,7 +314,7 @@ static void import_endjob(void *customdata)
|
||||
/* Delete objects on cancellation. */
|
||||
if (data->was_canceled && data->archive) {
|
||||
|
||||
for (USDPrimReader *reader : data->archive->readers()) {
|
||||
for (const USDPrimReader *reader : data->archive->readers()) {
|
||||
|
||||
if (!reader) {
|
||||
continue;
|
||||
@@ -341,7 +341,7 @@ static void import_endjob(void *customdata)
|
||||
data->archive->create_proto_collections(data->bmain, lc->collection);
|
||||
|
||||
/* Add all objects to the collection. */
|
||||
for (USDPrimReader *reader : data->archive->readers()) {
|
||||
for (const USDPrimReader *reader : data->archive->readers()) {
|
||||
if (!reader) {
|
||||
continue;
|
||||
}
|
||||
@@ -358,7 +358,7 @@ static void import_endjob(void *customdata)
|
||||
|
||||
/* Sync and do the view layer operations. */
|
||||
BKE_view_layer_synced_ensure(scene, view_layer);
|
||||
for (USDPrimReader *reader : data->archive->readers()) {
|
||||
for (const USDPrimReader *reader : data->archive->readers()) {
|
||||
if (!reader) {
|
||||
continue;
|
||||
}
|
||||
@@ -621,7 +621,7 @@ void USD_get_transform(CacheReader *reader, float r_mat_world[4][4], float time,
|
||||
if (!reader) {
|
||||
return;
|
||||
}
|
||||
USDXformReader *usd_reader = reinterpret_cast<USDXformReader *>(reader);
|
||||
const USDXformReader *usd_reader = reinterpret_cast<USDXformReader *>(reader);
|
||||
|
||||
bool is_constant = false;
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ struct Depsgraph;
|
||||
struct Main;
|
||||
struct Image;
|
||||
struct ImageUser;
|
||||
struct Scene;
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ template<> struct DefaultHash<pxr::TfToken> {
|
||||
template<> struct DefaultHash<pxr::SdfPath> {
|
||||
uint64_t operator()(const pxr::SdfPath &value) const
|
||||
{
|
||||
return (uint64_t)value.GetHash();
|
||||
return value.GetHash();
|
||||
}
|
||||
};
|
||||
} // namespace blender
|
||||
|
||||
@@ -55,8 +55,8 @@ class USDHierarchyIterator : public AbstractHierarchyIterator {
|
||||
|
||||
void release_writer(AbstractHierarchyWriter *writer) override;
|
||||
|
||||
virtual bool include_data_writers(const HierarchyContext *context) const override;
|
||||
virtual bool include_child_writers(const HierarchyContext *context) const override;
|
||||
bool include_data_writers(const HierarchyContext *context) const override;
|
||||
bool include_child_writers(const HierarchyContext *context) const override;
|
||||
|
||||
private:
|
||||
USDExporterContext create_usd_export_context(const HierarchyContext *context);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
#include <pxr/usd/usd/common.h>
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "usd.hh"
|
||||
#include "usd_asset_utils.hh"
|
||||
#include "usd_private.hh"
|
||||
#include "usd_reader_prim.hh"
|
||||
#include "usd_writer_material.hh"
|
||||
|
||||
#include <pxr/base/gf/rotation.h>
|
||||
@@ -27,10 +26,10 @@
|
||||
#include "BKE_node_tree_update.hh"
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_path_utils.hh"
|
||||
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_world_types.h"
|
||||
@@ -552,14 +551,13 @@ void dome_light_to_world_material(const USDImportParams ¶ms,
|
||||
}
|
||||
|
||||
bNode *mapping = append_node(tex, SH_NODE_MAPPING, "Vector", "Vector", ntree, 200);
|
||||
|
||||
if (!mapping) {
|
||||
CLOG_WARN(&LOG, "Couldn't create mapping node");
|
||||
return;
|
||||
}
|
||||
|
||||
bNode *tex_coord = append_node(mapping, SH_NODE_TEX_COORD, "Generated", "Vector", ntree, 200);
|
||||
|
||||
const bNode *tex_coord = append_node(
|
||||
mapping, SH_NODE_TEX_COORD, "Generated", "Vector", ntree, 200);
|
||||
if (!tex_coord) {
|
||||
CLOG_WARN(&LOG, "Couldn't create texture coordinate node");
|
||||
return;
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
#include <pxr/usd/usdGeom/camera.h>
|
||||
|
||||
struct Main;
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
class USDCameraReader : public USDXformReader {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <pxr/usd/usd/prim.h>
|
||||
#include <pxr/usd/usdGeom/basisCurves.h>
|
||||
#include <pxr/usd/usdGeom/curves.h>
|
||||
|
||||
struct Curves;
|
||||
struct Main;
|
||||
|
||||
@@ -18,6 +18,7 @@ struct Main;
|
||||
struct Material;
|
||||
struct bNode;
|
||||
struct bNodeTree;
|
||||
struct ReportList;
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
||||
@@ -788,7 +788,7 @@ void USDStageReader::create_proto_collections(Main *bmain, Collection *parent_co
|
||||
continue;
|
||||
}
|
||||
|
||||
for (USDPrimReader *reader : item.value) {
|
||||
for (const USDPrimReader *reader : item.value) {
|
||||
Object *ob = reader->object();
|
||||
|
||||
if (!ob) {
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include <pxr/usd/usdGeom/imageable.h>
|
||||
#include <pxr/usd/usdLux/domeLight.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
struct Collection;
|
||||
struct ImportSettings;
|
||||
struct Main;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
/* For #UsdGeomXformable. */
|
||||
#include <pxr/usd/usdGeom/xformable.h>
|
||||
|
||||
struct Main;
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_bounds_types.hh"
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
|
||||
#include "CLG_log.h"
|
||||
@@ -164,8 +165,7 @@ pxr::UsdTimeCode USDAbstractWriter::get_export_time_code() const
|
||||
}
|
||||
/* By using the default time-code USD won't even write a single `timeSample` for non-animated
|
||||
* data. Instead, it writes it as non-time-sampled. */
|
||||
static pxr::UsdTimeCode default_timecode = pxr::UsdTimeCode::Default();
|
||||
return default_timecode;
|
||||
return pxr::UsdTimeCode::Default();
|
||||
}
|
||||
|
||||
void USDAbstractWriter::write(HierarchyContext &context)
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
#include "WM_types.hh"
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
struct ID;
|
||||
struct IDProperty;
|
||||
struct Material;
|
||||
struct ReportList;
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
||||
#include "DNA_material_types.h"
|
||||
|
||||
#include "RNA_access.hh"
|
||||
#include "RNA_enum_types.hh"
|
||||
|
||||
|
||||
@@ -38,16 +38,15 @@
|
||||
|
||||
#include <pxr/base/tf/stringUtils.h>
|
||||
|
||||
#include "CLG_log.h"
|
||||
static CLG_LogRef LOG = {"io.usd"};
|
||||
|
||||
#ifdef WITH_MATERIALX
|
||||
# include "shader/materialx/material.h"
|
||||
# include <pxr/usd/sdf/copyUtils.h>
|
||||
# include <pxr/usd/usdMtlx/reader.h>
|
||||
# include <pxr/usd/usdMtlx/utils.h>
|
||||
#endif
|
||||
|
||||
#include "CLG_log.h"
|
||||
static CLG_LogRef LOG = {"io.usd"};
|
||||
|
||||
/* `TfToken` objects are not cheap to construct, so we do it once. */
|
||||
namespace usdtokens {
|
||||
/* Materials. */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include "usd_writer_abstract.hh"
|
||||
|
||||
#include <pxr/usd/usdGeom/xform.h>
|
||||
#include <pxr/usd/usdGeom/xformable.h>
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
|
||||
@@ -5,26 +5,23 @@
|
||||
#include "testing/testing.h"
|
||||
#include "tests/blendfile_loading_base_test.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
#include <pxr/base/tf/stringUtils.h>
|
||||
#include <pxr/base/vt/types.h>
|
||||
#include <pxr/base/vt/value.h>
|
||||
#include <pxr/usd/sdf/types.h>
|
||||
#include <pxr/usd/usd/common.h>
|
||||
#include <pxr/usd/usd/prim.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
#include <pxr/usd/usdGeom/mesh.h>
|
||||
#include <pxr/usd/usdGeom/subset.h>
|
||||
#include <pxr/usd/usdGeom/tokens.h>
|
||||
|
||||
#include "DNA_image_types.h"
|
||||
#include "DNA_material_types.h"
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
#include "BKE_context.hh"
|
||||
#include "BKE_lib_id.hh"
|
||||
#include "BKE_main.hh"
|
||||
#include "BKE_mesh.hh"
|
||||
#include "BKE_node.hh"
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_listbase.h"
|
||||
@@ -37,8 +34,6 @@
|
||||
|
||||
#include "DEG_depsgraph.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
|
||||
#include "usd.hh"
|
||||
#include "usd_utils.hh"
|
||||
#include "usd_writer_material.hh"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#include "testing/testing.h"
|
||||
|
||||
#include <pxr/base/plug/registry.h>
|
||||
#include <pxr/usd/usd/common.h>
|
||||
#include <pxr/usd/usd/stage.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
#include "DEG_depsgraph.hh"
|
||||
|
||||
#include "WM_api.hh"
|
||||
|
||||
#include "usd.hh"
|
||||
|
||||
namespace blender::io::usd {
|
||||
|
||||
Reference in New Issue
Block a user